1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Indentation fixes in terminal.c.

While working on the palette code I noticed several sections where a
2-space indent policy was used. Let's keep things consistent.

This patch is whitespace-only, with the single exception that I've
removed a pair of braces where a for statement contains only a switch
(and, cheatingly, put the for and switch on the same indent level so
that the interior of it doesn't go _too_ far off to the right).
This commit is contained in:
Simon Tatham 2021-02-07 19:59:20 +00:00
parent da3197f395
commit cd32ef8733

View File

@ -3471,7 +3471,7 @@ static void term_out(Terminal *term)
term->curs.x, &term->erase_char); term->curs.x, &term->erase_char);
} }
} else } else
/* Or normal C0 controls. */ /* Or normal C0 controls. */
if ((c & ~0x1F) == 0 && term->termstate < DO_CTRLS) { if ((c & ~0x1F) == 0 && term->termstate < DO_CTRLS) {
switch (c) { switch (c) {
case '\005': /* ENQ: terminal type query */ case '\005': /* ENQ: terminal type query */
@ -3498,15 +3498,15 @@ static void term_out(Terminal *term)
ticks = GETTICKCOUNT(); ticks = GETTICKCOUNT();
if (!term->beep_overloaded) { if (!term->beep_overloaded) {
newbeep = snew(struct beeptime); newbeep = snew(struct beeptime);
newbeep->ticks = ticks; newbeep->ticks = ticks;
newbeep->next = NULL; newbeep->next = NULL;
if (!term->beephead) if (!term->beephead)
term->beephead = newbeep; term->beephead = newbeep;
else else
term->beeptail->next = newbeep; term->beeptail->next = newbeep;
term->beeptail = newbeep; term->beeptail = newbeep;
term->nbeeps++; term->nbeeps++;
} }
/* /*
@ -3515,30 +3515,30 @@ static void term_out(Terminal *term)
*/ */
while (term->beephead && while (term->beephead &&
term->beephead->ticks < ticks - term->bellovl_t) { term->beephead->ticks < ticks - term->bellovl_t) {
struct beeptime *tmp = term->beephead; struct beeptime *tmp = term->beephead;
term->beephead = tmp->next; term->beephead = tmp->next;
sfree(tmp); sfree(tmp);
if (!term->beephead) if (!term->beephead)
term->beeptail = NULL; term->beeptail = NULL;
term->nbeeps--; term->nbeeps--;
} }
if (term->bellovl && term->beep_overloaded && if (term->bellovl && term->beep_overloaded &&
ticks - term->lastbeep >= (unsigned)term->bellovl_s) { ticks - term->lastbeep >= (unsigned)term->bellovl_s) {
/* /*
* If we're currently overloaded and the * If we're currently overloaded and the
* last beep was more than s seconds ago, * last beep was more than s seconds ago,
* leave overload mode. * leave overload mode.
*/ */
term->beep_overloaded = false; term->beep_overloaded = false;
} else if (term->bellovl && !term->beep_overloaded && } else if (term->bellovl && !term->beep_overloaded &&
term->nbeeps >= term->bellovl_n) { term->nbeeps >= term->bellovl_n) {
/* /*
* Now, if we have n or more beeps * Now, if we have n or more beeps
* remaining in the queue, go into overload * remaining in the queue, go into overload
* mode. * mode.
*/ */
term->beep_overloaded = true; term->beep_overloaded = true;
} }
term->lastbeep = ticks; term->lastbeep = ticks;
@ -3546,11 +3546,11 @@ static void term_out(Terminal *term)
* Perform an actual beep if we're not overloaded. * Perform an actual beep if we're not overloaded.
*/ */
if (!term->bellovl || !term->beep_overloaded) { if (!term->bellovl || !term->beep_overloaded) {
win_bell(term->win, term->beep); win_bell(term->win, term->beep);
if (term->beep == BELL_VISUAL) { if (term->beep == BELL_VISUAL) {
term_schedule_vbell(term, false, 0); term_schedule_vbell(term, false, 0);
} }
} }
seen_disp_event(term); seen_disp_event(term);
break; break;
@ -3626,16 +3626,16 @@ static void term_out(Terminal *term)
termline *ldata = scrlineptr(term->curs.y); termline *ldata = scrlineptr(term->curs.y);
do { do {
term->curs.x++; term->curs.x++;
} while (term->curs.x < term->cols - 1 && } while (term->curs.x < term->cols - 1 &&
!term->tabs[term->curs.x]); !term->tabs[term->curs.x]);
if ((ldata->lattr & LATTR_MODE) != LATTR_NORM) { if ((ldata->lattr & LATTR_MODE) != LATTR_NORM) {
if (term->curs.x >= term->cols / 2) if (term->curs.x >= term->cols / 2)
term->curs.x = term->cols / 2 - 1; term->curs.x = term->cols / 2 - 1;
} else { } else {
if (term->curs.x >= term->cols) if (term->curs.x >= term->cols)
term->curs.x = term->cols - 1; term->curs.x = term->cols - 1;
} }
check_selection(term, old_curs, term->curs); check_selection(term, old_curs, term->curs);
@ -3764,14 +3764,14 @@ static void term_out(Terminal *term)
pos scrtop, scrbot; pos scrtop, scrbot;
for (i = 0; i < term->rows; i++) { for (i = 0; i < term->rows; i++) {
ldata = scrlineptr(i); ldata = scrlineptr(i);
check_line_size(term, ldata); check_line_size(term, ldata);
for (j = 0; j < term->cols; j++) { for (j = 0; j < term->cols; j++) {
copy_termchar(ldata, j, copy_termchar(ldata, j,
&term->basic_erase_char); &term->basic_erase_char);
ldata->chars[j].chr = 'E'; ldata->chars[j].chr = 'E';
} }
ldata->lattr = LATTR_NORM; ldata->lattr = LATTR_NORM;
} }
if (term->scroll_on_disp) if (term->scroll_on_disp)
term->disptop = 0; term->disptop = 0;
@ -3992,15 +3992,15 @@ static void term_out(Terminal *term)
case 'J': { /* ED: erase screen or parts of it */ case 'J': { /* ED: erase screen or parts of it */
unsigned int i = def(term->esc_args[0], 0); unsigned int i = def(term->esc_args[0], 0);
if (i == 3) { if (i == 3) {
/* Erase Saved Lines (xterm) /* Erase Saved Lines (xterm)
* This follows Thomas Dickey's xterm. */ * This follows Thomas Dickey's xterm. */
if (!term->no_remote_clearscroll) if (!term->no_remote_clearscroll)
term_clrsb(term); term_clrsb(term);
} else { } else {
i++; i++;
if (i > 3) if (i > 3)
i = 0; i = 0;
erase_lots(term, false, !!(i & 2), !!(i & 1)); erase_lots(term, false, !!(i & 2), !!(i & 1));
} }
if (term->scroll_on_disp) if (term->scroll_on_disp)
term->disptop = 0; term->disptop = 0;
@ -4080,13 +4080,13 @@ static void term_out(Terminal *term)
if (term->esc_args[0] == 5 && if (term->esc_args[0] == 5 &&
(printer = conf_get_str(term->conf, (printer = conf_get_str(term->conf,
CONF_printer))[0]) { CONF_printer))[0]) {
term->printing = true; term->printing = true;
term->only_printing = !term->esc_query; term->only_printing = !term->esc_query;
term->print_state = 0; term->print_state = 0;
term_print_setup(term, printer); term_print_setup(term, printer);
} else if (term->esc_args[0] == 4 && } else if (term->esc_args[0] == 4 &&
term->printing) { term->printing) {
term_print_finish(term); term_print_finish(term);
} }
break; break;
} }
@ -4171,159 +4171,159 @@ static void term_out(Terminal *term)
* The 39 and 49 attributes are likely to be * The 39 and 49 attributes are likely to be
* unimplemented. * unimplemented.
*/ */
for (int i = 0; i < term->esc_nargs; i++) { for (int i = 0; i < term->esc_nargs; i++)
switch (def(term->esc_args[i], 0)) { switch (def(term->esc_args[i], 0)) {
case 0: /* restore defaults */ case 0: /* restore defaults */
term->curr_attr = term->default_attr; term->curr_attr = term->default_attr;
term->curr_truecolour = term->curr_truecolour =
term->basic_erase_char.truecolour; term->basic_erase_char.truecolour;
break; break;
case 1: /* enable bold */ case 1: /* enable bold */
compatibility(VT100AVO); compatibility(VT100AVO);
term->curr_attr |= ATTR_BOLD; term->curr_attr |= ATTR_BOLD;
break; break;
case 2: /* enable dim */ case 2: /* enable dim */
compatibility(OTHER); compatibility(OTHER);
term->curr_attr |= ATTR_DIM; term->curr_attr |= ATTR_DIM;
break; break;
case 21: /* (enable double underline) */ case 21: /* (enable double underline) */
compatibility(OTHER); compatibility(OTHER);
case 4: /* enable underline */ case 4: /* enable underline */
compatibility(VT100AVO); compatibility(VT100AVO);
term->curr_attr |= ATTR_UNDER; term->curr_attr |= ATTR_UNDER;
break; break;
case 5: /* enable blink */ case 5: /* enable blink */
compatibility(VT100AVO); compatibility(VT100AVO);
term->curr_attr |= ATTR_BLINK; term->curr_attr |= ATTR_BLINK;
break; break;
case 6: /* SCO light bkgrd */ case 6: /* SCO light bkgrd */
compatibility(SCOANSI); compatibility(SCOANSI);
term->blink_is_real = false; term->blink_is_real = false;
term->curr_attr |= ATTR_BLINK; term->curr_attr |= ATTR_BLINK;
term_schedule_tblink(term); term_schedule_tblink(term);
break; break;
case 7: /* enable reverse video */ case 7: /* enable reverse video */
term->curr_attr |= ATTR_REVERSE; term->curr_attr |= ATTR_REVERSE;
break; break;
case 9: /* enable strikethrough */ case 9: /* enable strikethrough */
term->curr_attr |= ATTR_STRIKE; term->curr_attr |= ATTR_STRIKE;
break; break;
case 10: /* SCO acs off */ case 10: /* SCO acs off */
compatibility(SCOANSI); compatibility(SCOANSI);
if (term->no_remote_charset) break; if (term->no_remote_charset) break;
term->sco_acs = 0; break; term->sco_acs = 0; break;
case 11: /* SCO acs on */ case 11: /* SCO acs on */
compatibility(SCOANSI); compatibility(SCOANSI);
if (term->no_remote_charset) break; if (term->no_remote_charset) break;
term->sco_acs = 1; break; term->sco_acs = 1; break;
case 12: /* SCO acs on, |0x80 */ case 12: /* SCO acs on, |0x80 */
compatibility(SCOANSI); compatibility(SCOANSI);
if (term->no_remote_charset) break; if (term->no_remote_charset) break;
term->sco_acs = 2; break; term->sco_acs = 2; break;
case 22: /* disable bold and dim */ case 22: /* disable bold and dim */
compatibility2(OTHER, VT220); compatibility2(OTHER, VT220);
term->curr_attr &= ~(ATTR_BOLD | ATTR_DIM); term->curr_attr &= ~(ATTR_BOLD | ATTR_DIM);
break; break;
case 24: /* disable underline */ case 24: /* disable underline */
compatibility2(OTHER, VT220); compatibility2(OTHER, VT220);
term->curr_attr &= ~ATTR_UNDER; term->curr_attr &= ~ATTR_UNDER;
break; break;
case 25: /* disable blink */ case 25: /* disable blink */
compatibility2(OTHER, VT220); compatibility2(OTHER, VT220);
term->curr_attr &= ~ATTR_BLINK; term->curr_attr &= ~ATTR_BLINK;
break; break;
case 27: /* disable reverse video */ case 27: /* disable reverse video */
compatibility2(OTHER, VT220); compatibility2(OTHER, VT220);
term->curr_attr &= ~ATTR_REVERSE; term->curr_attr &= ~ATTR_REVERSE;
break; break;
case 29: /* disable strikethrough */ case 29: /* disable strikethrough */
term->curr_attr &= ~ATTR_STRIKE; term->curr_attr &= ~ATTR_STRIKE;
break; break;
case 30: case 30:
case 31: case 31:
case 32: case 32:
case 33: case 33:
case 34: case 34:
case 35: case 35:
case 36: case 36:
case 37: case 37:
/* foreground */ /* foreground */
term->curr_truecolour.fg.enabled = false; term->curr_truecolour.fg.enabled = false;
term->curr_attr &= ~ATTR_FGMASK; term->curr_attr &= ~ATTR_FGMASK;
term->curr_attr |= term->curr_attr |=
(term->esc_args[i] - 30)<<ATTR_FGSHIFT; (term->esc_args[i] - 30)<<ATTR_FGSHIFT;
break; break;
case 90: case 90:
case 91: case 91:
case 92: case 92:
case 93: case 93:
case 94: case 94:
case 95: case 95:
case 96: case 96:
case 97: case 97:
/* aixterm-style bright foreground */ /* aixterm-style bright foreground */
term->curr_truecolour.fg.enabled = false; term->curr_truecolour.fg.enabled = false;
term->curr_attr &= ~ATTR_FGMASK; term->curr_attr &= ~ATTR_FGMASK;
term->curr_attr |= term->curr_attr |=
((term->esc_args[i] - 90 + 8) ((term->esc_args[i] - 90 + 8)
<< ATTR_FGSHIFT); << ATTR_FGSHIFT);
break; break;
case 39: /* default-foreground */ case 39: /* default-foreground */
term->curr_truecolour.fg.enabled = false; term->curr_truecolour.fg.enabled = false;
term->curr_attr &= ~ATTR_FGMASK; term->curr_attr &= ~ATTR_FGMASK;
term->curr_attr |= ATTR_DEFFG; term->curr_attr |= ATTR_DEFFG;
break; break;
case 40: case 40:
case 41: case 41:
case 42: case 42:
case 43: case 43:
case 44: case 44:
case 45: case 45:
case 46: case 46:
case 47: case 47:
/* background */ /* background */
term->curr_truecolour.bg.enabled = false; term->curr_truecolour.bg.enabled = false;
term->curr_attr &= ~ATTR_BGMASK; term->curr_attr &= ~ATTR_BGMASK;
term->curr_attr |= term->curr_attr |=
(term->esc_args[i] - 40)<<ATTR_BGSHIFT; (term->esc_args[i] - 40)<<ATTR_BGSHIFT;
break; break;
case 100: case 100:
case 101: case 101:
case 102: case 102:
case 103: case 103:
case 104: case 104:
case 105: case 105:
case 106: case 106:
case 107: case 107:
/* aixterm-style bright background */ /* aixterm-style bright background */
term->curr_truecolour.bg.enabled = false; term->curr_truecolour.bg.enabled = false;
term->curr_attr &= ~ATTR_BGMASK; term->curr_attr &= ~ATTR_BGMASK;
term->curr_attr |= term->curr_attr |=
((term->esc_args[i] - 100 + 8) ((term->esc_args[i] - 100 + 8)
<< ATTR_BGSHIFT); << ATTR_BGSHIFT);
break; break;
case 49: /* default-background */ case 49: /* default-background */
term->curr_truecolour.bg.enabled = false; term->curr_truecolour.bg.enabled = false;
term->curr_attr &= ~ATTR_BGMASK; term->curr_attr &= ~ATTR_BGMASK;
term->curr_attr |= ATTR_DEFBG; term->curr_attr |= ATTR_DEFBG;
break; break;
/* /*
* 256-colour and true-colour * 256-colour and true-colour
* sequences. A 256-colour * sequences. A 256-colour
* foreground is selected by a * foreground is selected by a
* sequence of 3 arguments in the * sequence of 3 arguments in the
* form 38;5;n, where n is in the * form 38;5;n, where n is in the
* range 0-255. A true-colour RGB * range 0-255. A true-colour RGB
* triple is selected by 5 args of * triple is selected by 5 args of
* the form 38;2;r;g;b. Replacing * the form 38;2;r;g;b. Replacing
* the initial 38 with 48 in both * the initial 38 with 48 in both
* cases selects the same colour * cases selects the same colour
* as the background. * as the background.
*/ */
case 38: case 38:
if (i+2 < term->esc_nargs && if (i+2 < term->esc_nargs &&
term->esc_args[i+1] == 5) { term->esc_args[i+1] == 5) {
term->curr_attr &= ~ATTR_FGMASK; term->curr_attr &= ~ATTR_FGMASK;
term->curr_attr |= term->curr_attr |=
((term->esc_args[i+2] & 0xFF) ((term->esc_args[i+2] & 0xFF)
@ -4331,18 +4331,18 @@ static void term_out(Terminal *term)
term->curr_truecolour.fg = term->curr_truecolour.fg =
optionalrgb_none; optionalrgb_none;
i += 2; i += 2;
} }
if (i + 4 < term->esc_nargs && if (i + 4 < term->esc_nargs &&
term->esc_args[i + 1] == 2) { term->esc_args[i + 1] == 2) {
parse_optionalrgb( parse_optionalrgb(
&term->curr_truecolour.fg, &term->curr_truecolour.fg,
term->esc_args + (i+2)); term->esc_args + (i+2));
i += 4; i += 4;
} }
break; break;
case 48: case 48:
if (i+2 < term->esc_nargs && if (i+2 < term->esc_nargs &&
term->esc_args[i+1] == 5) { term->esc_args[i+1] == 5) {
term->curr_attr &= ~ATTR_BGMASK; term->curr_attr &= ~ATTR_BGMASK;
term->curr_attr |= term->curr_attr |=
((term->esc_args[i+2] & 0xFF) ((term->esc_args[i+2] & 0xFF)
@ -4350,16 +4350,15 @@ static void term_out(Terminal *term)
term->curr_truecolour.bg = term->curr_truecolour.bg =
optionalrgb_none; optionalrgb_none;
i += 2; i += 2;
} }
if (i + 4 < term->esc_nargs && if (i + 4 < term->esc_nargs &&
term->esc_args[i+1] == 2) { term->esc_args[i+1] == 2) {
parse_optionalrgb( parse_optionalrgb(
&term->curr_truecolour.bg, &term->curr_truecolour.bg,
term->esc_args + (i+2)); term->esc_args + (i+2));
i += 4; i += 4;
} }
break; break;
}
} }
set_erase_char(term); set_erase_char(term);
break; break;
@ -4612,10 +4611,10 @@ static void term_out(Terminal *term)
pos old_curs = term->curs; pos old_curs = term->curs;
for(;i>0 && term->curs.x>0; i--) { for(;i>0 && term->curs.x>0; i--) {
do { do {
term->curs.x--; term->curs.x--;
} while (term->curs.x >0 && } while (term->curs.x >0 &&
!term->tabs[term->curs.x]); !term->tabs[term->curs.x]);
} }
check_selection(term, old_curs, term->curs); check_selection(term, old_curs, term->curs);
break; break;
@ -4881,23 +4880,23 @@ static void term_out(Terminal *term)
else if ((int)c >= 'a' && (int)c <= 'a' + max - 10) else if ((int)c >= 'a' && (int)c <= 'a' + max - 10)
val = c - 'a' + 10; val = c - 'a' + 10;
else { else {
term->termstate = TOPLEVEL; term->termstate = TOPLEVEL;
break; break;
} }
term->osc_string[term->osc_strlen++] = val; term->osc_string[term->osc_strlen++] = val;
if (term->osc_strlen >= 7) { if (term->osc_strlen >= 7) {
unsigned oscp_index = term->osc_string[0]; unsigned oscp_index = term->osc_string[0];
assert(oscp_index < OSCP_NCOLOURS); assert(oscp_index < OSCP_NCOLOURS);
unsigned osc4_index = unsigned osc4_index =
colour_indices_oscp_to_osc4[oscp_index]; colour_indices_oscp_to_osc4[oscp_index];
win_palette_set( win_palette_set(
term->win, osc4_index, term->win, osc4_index,
term->osc_string[1] * 16 + term->osc_string[2], term->osc_string[1] * 16 + term->osc_string[2],
term->osc_string[3] * 16 + term->osc_string[4], term->osc_string[3] * 16 + term->osc_string[4],
term->osc_string[5] * 16 + term->osc_string[6]); term->osc_string[5] * 16 + term->osc_string[6]);
term_invalidate(term); term_invalidate(term);
term->termstate = TOPLEVEL; term->termstate = TOPLEVEL;
} }
break; break;
} }