mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-06 21:48:05 -05:00
Stop cursor attributes being temporary
When telling front ends to paint the screen, the terminal code treats the cursor as an attribute applied to the character cell(s) it appears in. do_paint() detects changes to most such attributes by storing what it last sent to the front end in term->disptext and comparing that with what it thinks should be displayed in the window. However, before this commit the cursor was special. Its last-drawn position was recorded in special structure members and invalidated parts of the display based on those. The cursor attributes were treated as "temporary attributes" and were not saved in term->disptext. This commit regularizes this and turns the cursor attributes into normal attributes that are stored in term->disptext. This removes a bunch of special-case code in do_paint() because now the normal update code handles the cursor properly, and also removes some members from the Terminal structure. I hope it will also make future cursor-handling changes (for instance for input method pre-editing) simpler. This commit makes the required semantic changes but doesn't make the rather more pervasive change of actually renaming the attributes from TATTR_ to ATTR_. That will be in the next commit.
This commit is contained in:
parent
7f96069954
commit
f2d63388a8
2
putty.h
2
putty.h
@ -215,7 +215,7 @@ extern const int colour_indices_oscp_to_osc4[OSCP_NCOLOURS];
|
||||
|
||||
#define DATTR_STARTRUN 0x80000000UL /* start of redraw run */
|
||||
|
||||
#define TDATTR_MASK 0xF0000000UL
|
||||
#define TDATTR_MASK 0x80000000UL
|
||||
#define TATTR_MASK (TDATTR_MASK)
|
||||
#define DATTR_MASK (TDATTR_MASK)
|
||||
|
||||
|
@ -2066,7 +2066,6 @@ Terminal *term_init(Conf *myconf, struct unicode_data *ucsdata, TermWin *win)
|
||||
|
||||
term_copy_stuff_from_conf(term);
|
||||
|
||||
term->dispcursx = term->dispcursy = -1;
|
||||
deselect(term);
|
||||
term->rows = term->cols = -1;
|
||||
power_on(term, true);
|
||||
@ -2297,7 +2296,6 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
|
||||
}
|
||||
sfree(term->disptext);
|
||||
term->disptext = newdisp;
|
||||
term->dispcursx = term->dispcursy = -1;
|
||||
|
||||
/* Make a new alternate screen. */
|
||||
newalt = newtree234(NULL);
|
||||
@ -6092,27 +6090,6 @@ static void do_paint(Terminal *term)
|
||||
unlineptr(ldata);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the cursor is not where it was last time we painted, and
|
||||
* its previous position is visible on screen, invalidate its
|
||||
* previous position.
|
||||
*/
|
||||
if (term->dispcursy >= 0 &&
|
||||
(term->curstype != cursor ||
|
||||
term->dispcursy != our_curs_y ||
|
||||
term->dispcursx != our_curs_x)) {
|
||||
termchar *dispcurs = term->disptext[term->dispcursy]->chars +
|
||||
term->dispcursx;
|
||||
|
||||
if (term->dispcursx > 0 && dispcurs->chr == UCSWIDE)
|
||||
dispcurs[-1].attr |= ATTR_INVALID;
|
||||
if (term->dispcursx < term->cols-1 && dispcurs[1].chr == UCSWIDE)
|
||||
dispcurs[1].attr |= ATTR_INVALID;
|
||||
dispcurs->attr |= ATTR_INVALID;
|
||||
|
||||
term->curstype = 0;
|
||||
}
|
||||
term->dispcursx = term->dispcursy = -1;
|
||||
|
||||
/* The normal screen data */
|
||||
for (i = 0; i < term->rows; i++) {
|
||||
@ -6220,12 +6197,8 @@ static void do_paint(Terminal *term)
|
||||
} else if (term->disptext[i]->chars[j].attr & ATTR_NARROW)
|
||||
tattr |= ATTR_NARROW;
|
||||
|
||||
if (i == our_curs_y && j == our_curs_x) {
|
||||
if (i == our_curs_y && j == our_curs_x)
|
||||
tattr |= cursor;
|
||||
term->curstype = cursor;
|
||||
term->dispcursx = j;
|
||||
term->dispcursy = i;
|
||||
}
|
||||
|
||||
/* FULL-TERMCHAR */
|
||||
newline[j].attr = tattr;
|
||||
|
@ -95,8 +95,6 @@ struct terminal_tag {
|
||||
("temporary scrollback") */
|
||||
|
||||
termline **disptext; /* buffer of text on real screen */
|
||||
int dispcursx, dispcursy; /* location of cursor on real screen */
|
||||
int curstype; /* type of cursor on real screen */
|
||||
|
||||
#define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user