mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Cleanup: make an enum for the values of CONF_cursor_type.
These have been magic numbers 0, 1 and 2 in the source for ages. I think it's about time they had actual names, to make all the points of use clearer.
This commit is contained in:
parent
8bd75b85ed
commit
dfa91dfa8f
6
config.c
6
config.c
@ -2248,9 +2248,9 @@ void setup_config_box(struct controlbox *b, bool midsession,
|
||||
HELPCTX(appearance_cursor),
|
||||
conf_radiobutton_handler,
|
||||
I(CONF_cursor_type),
|
||||
"Block", 'l', I(0),
|
||||
"Underline", 'u', I(1),
|
||||
"Vertical line", 'v', I(2));
|
||||
"Block", 'l', I(CURSOR_BLOCK),
|
||||
"Underline", 'u', I(CURSOR_UNDERLINE),
|
||||
"Vertical line", 'v', I(CURSOR_VERTICAL_LINE));
|
||||
ctrl_checkbox(s, "Cursor blinks", 'b',
|
||||
HELPCTX(appearance_cursor),
|
||||
conf_checkbox_handler, I(CONF_blink_cur));
|
||||
|
4
putty.h
4
putty.h
@ -508,6 +508,10 @@ enum {
|
||||
FQ_DEFAULT, FQ_ANTIALIASED, FQ_NONANTIALIASED, FQ_CLEARTYPE
|
||||
};
|
||||
|
||||
enum {
|
||||
CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_VERTICAL_LINE
|
||||
};
|
||||
|
||||
enum {
|
||||
SER_PAR_NONE, SER_PAR_ODD, SER_PAR_EVEN, SER_PAR_MARK, SER_PAR_SPACE
|
||||
};
|
||||
|
@ -4075,7 +4075,7 @@ static void gtkwin_draw_cursor(
|
||||
passive = true;
|
||||
} else
|
||||
passive = false;
|
||||
if ((attr & TATTR_ACTCURS) && inst->cursor_type != 0) {
|
||||
if ((attr & TATTR_ACTCURS) && inst->cursor_type != CURSOR_BLOCK) {
|
||||
attr &= ~TATTR_ACTCURS;
|
||||
active = true;
|
||||
} else
|
||||
@ -4100,7 +4100,7 @@ static void gtkwin_draw_cursor(
|
||||
len *= 2;
|
||||
}
|
||||
|
||||
if (inst->cursor_type == 0) {
|
||||
if (inst->cursor_type == CURSOR_BLOCK) {
|
||||
/*
|
||||
* An active block cursor will already have been done by
|
||||
* the above do_text call, so we only need to do anything
|
||||
@ -4125,7 +4125,7 @@ static void gtkwin_draw_cursor(
|
||||
else
|
||||
char_width = inst->font_width;
|
||||
|
||||
if (inst->cursor_type == 1) {
|
||||
if (inst->cursor_type == CURSOR_UNDERLINE) {
|
||||
uheight = inst->fonts[0]->ascent + 1;
|
||||
if (uheight >= inst->font_height)
|
||||
uheight = inst->font_height - 1;
|
||||
@ -4135,7 +4135,7 @@ static void gtkwin_draw_cursor(
|
||||
dx = 1;
|
||||
dy = 0;
|
||||
length = len * widefactor * char_width;
|
||||
} else {
|
||||
} else /* inst->cursor_type == CURSOR_VERTICAL_LINE */ {
|
||||
int xadjust = 0;
|
||||
if (attr & TATTR_RIGHTCURS)
|
||||
xadjust = char_width - 1;
|
||||
|
@ -3576,7 +3576,7 @@ static void do_text_internal(
|
||||
y += wgs->offset_height;
|
||||
|
||||
if ((attr & TATTR_ACTCURS) &&
|
||||
(wgs->cursor_type == 0 || wgs->term->big_cursor)) {
|
||||
(wgs->cursor_type == CURSOR_BLOCK || wgs->term->big_cursor)) {
|
||||
truecolour.fg = truecolour.bg = optionalrgb_none;
|
||||
attr &= ~(ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS|ATTR_DIM);
|
||||
/* cursor fg and bg */
|
||||
@ -3971,12 +3971,13 @@ static void wintw_draw_cursor(
|
||||
|
||||
lattr &= LATTR_MODE;
|
||||
|
||||
if ((attr & TATTR_ACTCURS) && (ctype == 0 || wgs->term->big_cursor)) {
|
||||
if ((attr & TATTR_ACTCURS) &&
|
||||
(ctype == CURSOR_BLOCK || wgs->term->big_cursor)) {
|
||||
if (*text != UCSWIDE) {
|
||||
win_draw_text(tw, x, y, text, len, attr, lattr, truecolour);
|
||||
return;
|
||||
}
|
||||
ctype = 2;
|
||||
ctype = CURSOR_VERTICAL_LINE;
|
||||
attr |= TATTR_RIGHTCURS;
|
||||
}
|
||||
|
||||
@ -3988,7 +3989,8 @@ static void wintw_draw_cursor(
|
||||
x += wgs->offset_width;
|
||||
y += wgs->offset_height;
|
||||
|
||||
if ((attr & TATTR_PASCURS) && (ctype == 0 || wgs->term->big_cursor)) {
|
||||
if ((attr & TATTR_PASCURS) &&
|
||||
(ctype == CURSOR_BLOCK || wgs->term->big_cursor)) {
|
||||
POINT pts[5];
|
||||
HPEN oldpen;
|
||||
pts[0].x = pts[1].x = pts[4].x = x;
|
||||
@ -4000,15 +4002,16 @@ static void wintw_draw_cursor(
|
||||
Polyline(wgs->wintw_hdc, pts, 5);
|
||||
oldpen = SelectObject(wgs->wintw_hdc, oldpen);
|
||||
DeleteObject(oldpen);
|
||||
} else if ((attr & (TATTR_ACTCURS | TATTR_PASCURS)) && ctype != 0) {
|
||||
} else if ((attr & (TATTR_ACTCURS | TATTR_PASCURS)) &&
|
||||
ctype != CURSOR_BLOCK) {
|
||||
int startx, starty, dx, dy, length, i;
|
||||
if (ctype == 1) {
|
||||
if (ctype == CURSOR_UNDERLINE) {
|
||||
startx = x;
|
||||
starty = y + wgs->descent;
|
||||
dx = 1;
|
||||
dy = 0;
|
||||
length = char_width;
|
||||
} else {
|
||||
} else /* ctype == CURSOR_VERTICAL_LINE */ {
|
||||
int xadjust = 0;
|
||||
if (attr & TATTR_RIGHTCURS)
|
||||
xadjust = char_width - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user