[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Universal functions to manage multiple window caches.
From: |
Alex Gramiak |
Subject: |
Re: Universal functions to manage multiple window caches. |
Date: |
Thu, 18 Apr 2019 15:02:15 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Keith David Bershatsky <address@hidden> 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.