unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex Gramiak <agrambot@gmail.com>
To: Keith David Bershatsky <esq@lawlist.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Universal functions to manage multiple window caches.
Date: Thu, 18 Apr 2019 15:02:15 -0600	[thread overview]
Message-ID: <878sw79gdk.fsf@gmail.com> (raw)
In-Reply-To: <m21s20flg8.wl%esq@lawlist.com> (Keith David Bershatsky's message of "Wed, 17 Apr 2019 13:03:51 -0700")

Keith David Bershatsky <esq@lawlist.com> writes:

> I am working on feature requests 22873 (multiple fake cursors) and 17684 (crosshairs that track the cursor position).
>
> window.h defines four different caches of fake cursors, with the only difference between them being their names:
>
>   struct multiple_cursors_cache *temp_elts;
>   ptrdiff_t temp_elts_allocated;
>   int temp_nelts;
>
>   struct multiple_cursors_cache *mc_elts;
>   ptrdiff_t mc_elts_allocated;
>   int mc_nelts;
>
>   struct multiple_cursors_cache *ch_elts;
>   ptrdiff_t ch_elts_allocated;
>   int ch_nelts;
>
>   struct multiple_cursors_cache *fc_elts;
>   ptrdiff_t fc_elts_allocated;
>   int fc_nelts;

Each of the four could just be structs themselves. Something like:

  struct multiple_cursor_cache
  {
    ptrdiff_t allocated;
    ptrdiff_t used;
    struct items
    {
      int x;
      int fx;
      int y;
      int fy;
      int hpos;
      int vpos;
      int wd;
      int h;
      int cursor_type;
      int cursor_width;
      struct RGB
      {
        double red;
        double green;
        double blue;
      } foreground, background;
      bool active_p;
      int glyph_flavor;
      bool enabled_p;
    } *caches;
  };

If you need to differentiate them in a helper procedure, you can add an
enum element to the outermost struct.

P.S. Why do you need to memset the used portion of the caches on every
window update? I would think that just setting the used/*_nelts count
would be sufficient as long as you make sure not to go past that and
access garbage data.



  reply	other threads:[~2019-04-18 21:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-17 20:03 Universal functions to manage multiple window caches Keith David Bershatsky
2019-04-18 21:02 ` Alex Gramiak [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-04-18  3:17 Keith David Bershatsky
2019-04-19  1:44 Keith David Bershatsky
2019-04-19 13:59 ` Alex Gramiak
2019-04-20  6:58 Keith David Bershatsky
2019-04-20 17:17 ` Alex Gramiak
2019-04-20 20:29 Keith David Bershatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sw79gdk.fsf@gmail.com \
    --to=agrambot@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=esq@lawlist.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).