Mercurial > vim
diff src/libvterm/src/state.c @ 17777:811a12a78164 v8.1.1885
patch 8.1.1885: comments in libvterm are inconsistent
commit https://github.com/vim/vim/commit/db1085a5630ffdaa2e9f342c06cc739ebdf1a99a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 18 20:41:38 2019 +0200
patch 8.1.1885: comments in libvterm are inconsistent
Problem: Comments in libvterm are inconsistent.
Solution: Use // comments. Als update the table of combining characters.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 18 Aug 2019 20:45:04 +0200 |
parents | 65d5f7039131 |
children | 8b4f9be5db73 |
line wrap: on
line diff
--- a/src/libvterm/src/state.c +++ b/src/libvterm/src/state.c @@ -11,7 +11,7 @@ static int on_resize(int rows, int cols, void *user); -/* Some convenient wrappers to make callback functions easier */ +// Some convenient wrappers to make callback functions easier static void putglyph(VTermState *state, const uint32_t chars[], int width, VTermPos pos) { @@ -266,9 +266,8 @@ static int on_text(const char bytes[], s codepoints, &npoints, state->gsingle_set ? 1 : (int)len, bytes, &eaten, len); - /* There's a chance an encoding (e.g. UTF-8) hasn't found enough bytes yet - * for even a single codepoint - */ + // There's a chance an encoding (e.g. UTF-8) hasn't found enough bytes yet + // for even a single codepoint if(!npoints) { vterm_allocator_free(state->vt, codepoints); @@ -278,10 +277,10 @@ static int on_text(const char bytes[], s if(state->gsingle_set && npoints) state->gsingle_set = 0; - /* This is a combining char. that needs to be merged with the previous - * glyph output */ + // This is a combining char. that needs to be merged with the previous + // glyph output if(vterm_unicode_is_combining(codepoints[i])) { - /* See if the cursor has moved since */ + // See if the cursor has moved since if(state->pos.row == state->combine_pos.row && state->pos.col == state->combine_pos.col + state->combine_width) { #ifdef DEBUG_GLYPH_COMBINE int printpos; @@ -291,12 +290,12 @@ static int on_text(const char bytes[], s printf("} + {"); #endif - /* Find where we need to append these combining chars */ + // Find where we need to append these combining chars int saved_i = 0; while(state->combine_chars[saved_i]) saved_i++; - /* Add extra ones */ + // Add extra ones while(i < npoints && vterm_unicode_is_combining(codepoints[i])) { if(saved_i >= (int)state->combine_chars_size) grow_combine_buffer(state); @@ -312,7 +311,7 @@ static int on_text(const char bytes[], s printf("}\n"); #endif - /* Now render it */ + // Now render it putglyph(state, state->combine_chars, state->combine_width, state->combine_pos); } else { @@ -366,10 +365,9 @@ static int on_text(const char bytes[], s } if(state->mode.insert) { - /* TODO: This will be a little inefficient for large bodies of text, as - * it'll have to 'ICH' effectively before every glyph. We should scan - * ahead and ICH as many times as required - */ + // TODO: This will be a little inefficient for large bodies of text, as + // it'll have to 'ICH' effectively before every glyph. We should scan + // ahead and ICH as many times as required VTermRect rect; rect.start_row = state->pos.row; rect.end_row = state->pos.row + 1; @@ -381,8 +379,8 @@ static int on_text(const char bytes[], s putglyph(state, chars, width, state->pos); if(i == npoints - 1) { - /* End of the buffer. Save the chars in case we have to combine with - * more on the next call */ + // End of the buffer. Save the chars in case we have to combine with + // more on the next call int save_i; for(save_i = 0; chars[save_i]; save_i++) { if(save_i >= (int)state->combine_chars_size) @@ -577,9 +575,8 @@ static int on_escape(const char *bytes, { VTermState *state = user; - /* Easier to decode this from the first byte, even though the final - * byte terminates it - */ + // Easier to decode this from the first byte, even though the final + // byte terminates it switch(bytes[0]) { case ' ': if(len != 2) @@ -911,7 +908,7 @@ static int on_csi(const char *leader, co VTermPos oldpos = state->pos; int handled = 1; - /* Some temporaries for later code */ + // Some temporaries for later code int count, val; int row, col; VTermRect rect; @@ -1258,7 +1255,7 @@ static int on_csi(const char *leader, co case 2: case 4: break; - /* TODO: 1, 2 and 4 aren't meaningful yet without line tab stops */ + // TODO: 1, 2 and 4 aren't meaningful yet without line tab stops default: return 0; } @@ -1418,7 +1415,7 @@ static int on_csi(const char *leader, co case 0x74: switch(CSI_ARG(args[0])) { - case 8: /* CSI 8 ; rows ; cols t set size */ + case 8: // CSI 8 ; rows ; cols t set size if (argcount == 3) on_resize(CSI_ARG(args[1]), CSI_ARG(args[2]), state); break; @@ -1531,7 +1528,7 @@ static int on_osc(const char *command, s return 1; } else if(strneq(command, "10;", 3)) { - /* request foreground color: <Esc>]10;?<0x07> */ + // request foreground color: <Esc>]10;?<0x07> int red = state->default_fg.red; int blue = state->default_fg.blue; int green = state->default_fg.green; @@ -1539,7 +1536,7 @@ static int on_osc(const char *command, s return 1; } else if(strneq(command, "11;", 3)) { - /* request background color: <Esc>]11;?<0x07> */ + // request background color: <Esc>]11;?<0x07> int red = state->default_bg.red; int blue = state->default_bg.blue; int green = state->default_bg.green; @@ -1591,7 +1588,7 @@ static void request_status_string(VTermS switch(state->mode.cursor_shape) { case VTERM_PROP_CURSORSHAPE_BLOCK: reply = 2; break; case VTERM_PROP_CURSORSHAPE_UNDERLINE: reply = 4; break; - default: /* VTERM_PROP_CURSORSHAPE_BAR_LEFT */ reply = 6; break; + default: /* VTERM_PROP_CURSORSHAPE_BAR_LEFT */ reply = 6; break; } if(state->mode.cursor_blink) reply--; @@ -1634,7 +1631,7 @@ static int on_resize(int rows, int cols, if (newtabstops == NULL) return 0; - /* TODO: This can all be done much more efficiently bytewise */ + // TODO: This can all be done much more efficiently bytewise for(col = 0; col < state->cols && col < cols; col++) { unsigned char mask = 1 << (col & 7); if(state->tabstops[col >> 3] & mask) @@ -1704,13 +1701,13 @@ static int on_resize(int rows, int cols, } static const VTermParserCallbacks parser_callbacks = { - on_text, /* text */ - on_control, /* control */ - on_escape, /* escape */ - on_csi, /* csi */ - on_osc, /* osc */ - on_dcs, /* dcs */ - on_resize /* resize */ + on_text, // text + on_control, // control + on_escape, // escape + on_csi, // csi + on_osc, // osc + on_dcs, // dcs + on_resize // resize }; /* @@ -1875,8 +1872,8 @@ void *vterm_state_get_unrecognised_fbdat int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val) { - /* Only store the new value of the property if usercode said it was happy. - * This is especially important for altscreen switching */ + // Only store the new value of the property if usercode said it was happy. + // This is especially important for altscreen switching if(state->callbacks && state->callbacks->settermprop) if(!(*state->callbacks->settermprop)(prop, val, state->cbdata)) return 0;