diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-18 20:41:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-18 20:41:38 +0200 |
commit | db1085a5630ffdaa2e9f342c06cc739ebdf1a99a (patch) | |
tree | d72b91e375b1b8bb2a246468669b9e69465ad08f /src | |
parent | f0bc15c769b60f472d411b3ef98d57db510113c1 (diff) |
patch 8.1.1885: comments in libvterm are inconsistentv8.1.1885
Problem: Comments in libvterm are inconsistent.
Solution: Use // comments. Als update the table of combining characters.
Diffstat (limited to 'src')
-rw-r--r-- | src/libvterm/bin/unterm.c | 16 | ||||
-rw-r--r-- | src/libvterm/bin/vterm-ctrl.c | 16 | ||||
-rw-r--r-- | src/libvterm/bin/vterm-dump.c | 26 | ||||
-rw-r--r-- | src/libvterm/include/vterm.h | 98 | ||||
-rw-r--r-- | src/libvterm/include/vterm_keycodes.h | 8 | ||||
-rw-r--r-- | src/libvterm/src/encoding.c | 10 | ||||
-rw-r--r-- | src/libvterm/src/keyboard.c | 21 | ||||
-rw-r--r-- | src/libvterm/src/mouse.c | 2 | ||||
-rw-r--r-- | src/libvterm/src/parser.c | 24 | ||||
-rw-r--r-- | src/libvterm/src/pen.c | 4 | ||||
-rw-r--r-- | src/libvterm/src/rect.h | 12 | ||||
-rw-r--r-- | src/libvterm/src/state.c | 67 | ||||
-rw-r--r-- | src/libvterm/src/termscreen.c | 78 | ||||
-rw-r--r-- | src/libvterm/src/unicode.c | 372 | ||||
-rw-r--r-- | src/libvterm/src/utf8.h | 4 | ||||
-rw-r--r-- | src/libvterm/src/vterm.c | 42 | ||||
-rw-r--r-- | src/libvterm/src/vterm_internal.h | 22 | ||||
-rw-r--r-- | src/version.c | 2 |
18 files changed, 526 insertions, 298 deletions
diff --git a/src/libvterm/bin/unterm.c b/src/libvterm/bin/unterm.c index 5c310d7955..987ba691d0 100644 --- a/src/libvterm/bin/unterm.c +++ b/src/libvterm/bin/unterm.c @@ -208,14 +208,14 @@ static int screen_resize(int new_rows, int new_cols, void *user) } static VTermScreenCallbacks cb_screen = { - NULL, /* damage */ - NULL, /* moverect */ - NULL, /* movecursor */ - NULL, /* settermprop */ - NULL, /* bell */ - &screen_resize, /* resize */ - &screen_sb_pushline, /* sb_pushline */ - NULL, /* popline */ + NULL, // damage + NULL, // moverect + NULL, // movecursor + NULL, // settermprop + NULL, // bell + &screen_resize, // resize + &screen_sb_pushline, // sb_pushline + NULL, // popline }; int main(int argc, char *argv[]) diff --git a/src/libvterm/bin/vterm-ctrl.c b/src/libvterm/bin/vterm-ctrl.c index 7c08fe1f9e..9e06011d17 100644 --- a/src/libvterm/bin/vterm-ctrl.c +++ b/src/libvterm/bin/vterm-ctrl.c @@ -1,4 +1,4 @@ -#define _XOPEN_SOURCE 500 /* strdup */ +#define _XOPEN_SOURCE 500 // strdup #include <stdio.h> #include <stdlib.h> @@ -86,7 +86,7 @@ static void await_c1(unsigned char c1) { unsigned char c; - /* await CSI - 8bit or 2byte 7bit form */ + // await CSI - 8bit or 2byte 7bit form int in_esc = FALSE; while((c = getchar())) { if(c == c1) @@ -107,8 +107,7 @@ static char *read_csi() await_c1(0x9B); // CSI - /* TODO: This really should be a more robust CSI parser - */ + // TODO: This really should be a more robust CSI parser for(; i < sizeof(csi)-1; i++) { int c = csi[i] = getchar(); if(c >= 0x40 && c <= 0x7e) @@ -175,12 +174,11 @@ static int query_dec_mode(int mode) free(s); s = read_csi(); - /* expect "?" mode ";" value "$y" */ + // expect "?" mode ";" value "$y" - /* If the sscanf format string ends in a literal, we can't tell from - * its return value if it matches. Hence we'll %c the cmd and check it - * explicitly - */ + // If the sscanf format string ends in a literal, we can't tell from + // its return value if it matches. Hence we'll %c the cmd and check it + // explicitly if(sscanf(s, "?%d;%d$%c", &reply_mode, &reply_value, &reply_cmd) < 3) continue; if(reply_cmd != 'y') diff --git a/src/libvterm/bin/vterm-dump.c b/src/libvterm/bin/vterm-dump.c index a299d9c938..7d39165956 100644 --- a/src/libvterm/bin/vterm-dump.c +++ b/src/libvterm/bin/vterm-dump.c @@ -21,7 +21,7 @@ static int parser_text(const char bytes[], size_t len, void *user) unsigned char *b = (unsigned char *)bytes; int i; - for(i = 0; i < len; /* none */) { + for(i = 0; i < len; ) { if(b[i] < 0x20) // C0 break; else if(b[i] < 0x80) // ASCII @@ -51,7 +51,7 @@ static int parser_text(const char bytes[], size_t len, void *user) return i; } -/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ +// 0 1 2 3 4 5 6 7 8 9 A B C D E F static const char *name_c0[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "LS0", "LS1", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", @@ -91,14 +91,14 @@ static int parser_escape(const char bytes[], size_t len, void *user) return len; } -/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ +// 0 1 2 3 4 5 6 7 8 9 A B C D E F static const char *name_csi_plain[] = { "ICH", "CUU", "CUD", "CUF", "CUB", "CNL", "CPL", "CHA", "CUP", "CHT", "ED", "EL", "IL", "DL", "EF", "EA", "DCH", "SSE", "CPR", "SU", "SD", "NP", "PP", "CTC", "ECH", "CVT", "CBT", "SRS", "PTX", "SDS", "SIMD",NULL, "HPA", "HPR", "REP", "DA", "VPA", "VPR", "HVP", "TBC", "SM", "MC", "HPB", "VPB", "RM", "SGR", "DSR", "DAQ", }; -/*0 4 8 B */ +//0 4 8 B static const int newline_csi_plain[] = { 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, @@ -111,7 +111,7 @@ static int parser_csi(const char *leader, const long args[], int argcount, const if(!leader && !intermed && command < 0x70) name = name_csi_plain[command - 0x40]; else if(leader && streq(leader, "?") && !intermed) { - /* DEC */ + // DEC switch(command) { case 'h': name = "DECSM"; break; case 'l': name = "DECRM"; break; @@ -172,13 +172,13 @@ static int parser_dcs(const char *command, size_t cmdlen, void *user) } static VTermParserCallbacks parser_cbs = { - &parser_text, /* text */ - &parser_control, /* control */ - &parser_escape, /* escape */ - &parser_csi, /* csi */ - &parser_osc, /* osc */ - &parser_dcs, /* dcs */ - NULL /* resize */ + &parser_text, // text + &parser_control, // control + &parser_escape, // escape + &parser_csi, // csi + &parser_osc, // osc + &parser_dcs, // dcs + NULL // resize }; int main(int argc, char *argv[]) @@ -214,7 +214,7 @@ int main(int argc, char *argv[]) special_end = "}\x1b[m"; } - /* Size matters not for the parser */ + // Size matters not for the parser vt = vterm_new(25, 80); vterm_set_utf8(vt, 1); vterm_parser_set_callbacks(vt, &parser_cbs, NULL); diff --git a/src/libvterm/include/vterm.h b/src/libvterm/include/vterm.h index 3b77cd2d57..02ea91cd59 100644 --- a/src/libvterm/include/vterm.h +++ b/src/libvterm/include/vterm.h @@ -15,7 +15,7 @@ extern "C" { #define TRUE 1 #define FALSE 0 -/* from stdint.h */ +// from stdint.h typedef unsigned char uint8_t; typedef unsigned int uint32_t; @@ -23,7 +23,7 @@ typedef struct VTerm VTerm; typedef struct VTermState VTermState; typedef struct VTermScreen VTermScreen; -/* Specifies a screen point. */ +// Specifies a screen point. typedef struct { int row; int col; @@ -48,7 +48,7 @@ INLINE int vterm_pos_cmp(VTermPos a, VTermPos b) } #endif -/* Specifies a rectangular screen area. */ +// Specifies a rectangular screen area. typedef struct { int start_row; int end_row; @@ -56,7 +56,7 @@ typedef struct { int end_col; } VTermRect; -/* Return true if the rect "r" contains the point "p". */ +// Return true if the rect "r" contains the point "p". int vterm_rect_contains(VTermRect r, VTermPos p); #if defined(DEFINE_INLINES) || USE_INLINE @@ -67,8 +67,8 @@ INLINE int vterm_rect_contains(VTermRect r, VTermPos p) } #endif -/* Move "rect" "row_delta" down and "col_delta" right. - * Does not check boundaries. */ +// Move "rect" "row_delta" down and "col_delta" right. +// Does not check boundaries. void vterm_rect_move(VTermRect *rect, int row_delta, int col_delta); #if defined(DEFINE_INLINES) || USE_INLINE @@ -79,12 +79,12 @@ INLINE void vterm_rect_move(VTermRect *rect, int row_delta, int col_delta) } #endif -/* The ansi_index is used for the lower 16 colors, which can be set to any - * color. */ -#define VTERM_ANSI_INDEX_DEFAULT 0 /* color cleared */ +// The ansi_index is used for the lower 16 colors, which can be set to any +// color. +#define VTERM_ANSI_INDEX_DEFAULT 0 // color cleared #define VTERM_ANSI_INDEX_MIN 1 #define VTERM_ANSI_INDEX_MAX 16 -#define VTERM_ANSI_INDEX_NONE 255 /* non-ANSI color, use red/green/blue */ +#define VTERM_ANSI_INDEX_NONE 255 // non-ANSI color, use red/green/blue typedef struct { uint8_t red, green, blue; @@ -92,7 +92,7 @@ typedef struct { } VTermColor; typedef enum { - /* VTERM_VALUETYPE_NONE = 0 */ + // VTERM_VALUETYPE_NONE = 0 VTERM_VALUETYPE_BOOL = 1, VTERM_VALUETYPE_INT, VTERM_VALUETYPE_STRING, @@ -109,7 +109,7 @@ typedef union { } VTermValue; typedef enum { - /* VTERM_ATTR_NONE = 0 */ + // VTERM_ATTR_NONE = 0 VTERM_ATTR_BOLD = 1, // bool: 1, 22 VTERM_ATTR_UNDERLINE, // number: 4, 21, 24 VTERM_ATTR_ITALIC, // bool: 3, 23 @@ -124,7 +124,7 @@ typedef enum { } VTermAttr; typedef enum { - /* VTERM_PROP_NONE = 0 */ + // VTERM_PROP_NONE = 0 VTERM_PROP_CURSORVISIBLE = 1, // bool VTERM_PROP_CURSORBLINK, // bool VTERM_PROP_ALTSCREEN, // bool @@ -158,33 +158,33 @@ enum { typedef struct { const uint32_t *chars; int width; - unsigned int protected_cell:1; /* DECSCA-protected against DECSEL/DECSED */ - unsigned int dwl:1; /* DECDWL or DECDHL double-width line */ - unsigned int dhl:2; /* DECDHL double-height line (1=top 2=bottom) */ + unsigned int protected_cell:1; // DECSCA-protected against DECSEL/DECSED + unsigned int dwl:1; // DECDWL or DECDHL double-width line + unsigned int dhl:2; // DECDHL double-height line (1=top 2=bottom) } VTermGlyphInfo; typedef struct { - unsigned int doublewidth:1; /* DECDWL or DECDHL line */ - unsigned int doubleheight:2; /* DECDHL line (1=top 2=bottom) */ + unsigned int doublewidth:1; // DECDWL or DECDHL line + unsigned int doubleheight:2; // DECDHL line (1=top 2=bottom) } VTermLineInfo; typedef struct { - /* libvterm relies on the allocated memory to be zeroed out before it is - * returned by the allocator. */ + // libvterm relies on the allocated memory to be zeroed out before it is + // returned by the allocator. void *(*malloc)(size_t size, void *allocdata); void (*free)(void *ptr, void *allocdata); } VTermAllocatorFunctions; -/* Allocate and initialize a new terminal with default allocators. */ +// Allocate and initialize a new terminal with default allocators. VTerm *vterm_new(int rows, int cols); -/* Allocate and initialize a new terminal with specified allocators. */ +// Allocate and initialize a new terminal with specified allocators. VTerm *vterm_new_with_allocator(int rows, int cols, VTermAllocatorFunctions *funcs, void *allocdata); -/* Free and cleanup a terminal and all its data. */ +// Free and cleanup a terminal and all its data. void vterm_free(VTerm* vt); -/* Get the current size of the terminal and store in "rowsp" and "colsp". */ +// Get the current size of the terminal and store in "rowsp" and "colsp". void vterm_get_size(const VTerm *vt, int *rowsp, int *colsp); void vterm_set_size(VTerm *vt, int rows, int cols); @@ -207,8 +207,8 @@ void vterm_keyboard_start_paste(VTerm *vt); void vterm_keyboard_end_paste(VTerm *vt); void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod); -/* "button" is 1 for left, 2 for middle, 3 for right. - * Button 4 is scroll wheel down, button 5 is scroll wheel up. */ +// "button" is 1 for left, 2 for middle, 3 for right. +// Button 4 is scroll wheel down, button 5 is scroll wheel up. void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod); // ------------ @@ -229,7 +229,7 @@ void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod); #define CSI_ARG_HAS_MORE(a) ((a) & CSI_ARG_FLAG_MORE) #define CSI_ARG(a) ((a) & CSI_ARG_MASK) -/* Can't use -1 to indicate a missing argument; use this instead */ +// Can't use -1 to indicate a missing argument; use this instead #define CSI_ARG_MISSING ((1<<30)-1) #define CSI_ARG_IS_MISSING(a) (CSI_ARG(a) == CSI_ARG_MISSING) @@ -261,8 +261,8 @@ typedef struct { int (*erase)(VTermRect rect, int selective, void *user); int (*initpen)(void *user); int (*setpenattr)(VTermAttr attr, VTermValue *val, void *user); - /* Callback for setting various properties. Must return 1 if the property - * was accepted, 0 otherwise. */ + // Callback for setting various properties. Must return 1 if the property + // was accepted, 0 otherwise. int (*settermprop)(VTermProp prop, VTermValue *val, void *user); int (*bell)(void *user); int (*resize)(int rows, int cols, VTermPos *delta, void *user); @@ -279,7 +279,7 @@ typedef struct { #define MOUSE_WANT_CLICK 0x01 #define MOUSE_WANT_DRAG 0x02 #define MOUSE_WANT_MOVE 0x04 - /* useful to add protocol? */ + // useful to add protocol? } VTermMouseState; VTermState *vterm_obtain_state(VTerm *vt); @@ -291,7 +291,7 @@ void *vterm_state_get_cbdata(VTermState *state); void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermParserCallbacks *fallbacks, void *user); void *vterm_state_get_unrecognised_fbdata(VTermState *state); -/* Initialize the state. */ +// Initialize the state. void vterm_state_reset(VTermState *state, int hard); void vterm_state_get_cursorpos(const VTermState *state, VTermPos *cursorpos); @@ -318,9 +318,9 @@ typedef struct { unsigned int blink : 1; unsigned int reverse : 1; unsigned int strike : 1; - unsigned int font : 4; /* 0 to 9 */ - unsigned int dwl : 1; /* On a DECDWL or DECDHL line */ - unsigned int dhl : 2; /* On a DECDHL line (1=top 2=bottom) */ + unsigned int font : 4; // 0 to 9 + unsigned int dwl : 1; // On a DECDWL or DECDHL line + unsigned int dhl : 2; // On a DECDHL line (1=top 2=bottom) } VTermScreenCellAttrs; typedef struct { @@ -331,7 +331,7 @@ typedef struct { VTermColor fg, bg; } VTermScreenCell; -/* All fields are optional, NULL when not used. */ +// All fields are optional, NULL when not used. typedef struct { int (*damage)(VTermRect rect, void *user); int (*moverect)(VTermRect dest, VTermRect src, void *user); @@ -339,14 +339,14 @@ typedef struct { int (*settermprop)(VTermProp prop, VTermValue *val, void *user); int (*bell)(void *user); int (*resize)(int rows, int cols, void *user); - /* A line was pushed off the top of the window. - * "cells[cols]" contains the cells of that line. - * Return value is unused. */ + // A line was pushed off the top of the window. + // "cells[cols]" contains the cells of that line. + // Return value is unused. int (*sb_pushline)(int cols, const VTermScreenCell *cells, void *user); int (*sb_popline)(int cols, VTermScreenCell *cells, void *user); } VTermScreenCallbacks; -/* Return the screen of the vterm. */ +// Return the screen of the vterm. VTermScreen *vterm_obtain_screen(VTerm *vt); /* @@ -356,25 +356,25 @@ VTermScreen *vterm_obtain_screen(VTerm *vt); void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user); void *vterm_screen_get_cbdata(VTermScreen *screen); -// Only invokes control, csi, osc, dcs +/* Only invokes control, csi, osc, dcs */ void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user); void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen); -/* Enable support for using the alternate screen if "altscreen" is non-zero. - * Before that switching to the alternate screen won't work. - * Calling with "altscreen" zero has no effect. */ +// Enable support for using the alternate screen if "altscreen" is non-zero. +// Before that switching to the alternate screen won't work. +// Calling with "altscreen" zero has no effect. void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen); typedef enum { - VTERM_DAMAGE_CELL, /* every cell */ - VTERM_DAMAGE_ROW, /* entire rows */ - VTERM_DAMAGE_SCREEN, /* entire screen */ - VTERM_DAMAGE_SCROLL, /* entire screen + scrollrect */ + VTERM_DAMAGE_CELL, // every cell + VTERM_DAMAGE_ROW, // entire rows + VTERM_DAMAGE_SCREEN, // entire screen + VTERM_DAMAGE_SCROLL, // entire screen + scrollrect VTERM_N_DAMAGES } VTermDamageSize; -/* Invoke the relevant callbacks to update the screen. */ +// Invoke the relevant callbacks to update the screen. void vterm_screen_flush_damage(VTermScreen *screen); void vterm_screen_set_damage_merge(VTermScreen *screen, VTermDamageSize size); @@ -385,7 +385,7 @@ void vterm_screen_set_damage_merge(VTermScreen *screen, VTermDamageSize size); */ void vterm_screen_reset(VTermScreen *screen, int hard); -/* Neither of these functions NUL-terminate the buffer */ +// Neither of these functions NUL-terminate the buffer size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRect rect); size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect); diff --git a/src/libvterm/include/vterm_keycodes.h b/src/libvterm/include/vterm_keycodes.h index 22bdf918b6..e5fb5ab086 100644 --- a/src/libvterm/include/vterm_keycodes.h +++ b/src/libvterm/include/vterm_keycodes.h @@ -7,10 +7,10 @@ typedef enum { VTERM_MOD_ALT = 0x02, VTERM_MOD_CTRL = 0x04, - VTERM_ALL_MODS_MASK = 0x07 + VTERM_ALL_MODS_MASK = 0x07 } VTermModifier; -/* The order here must match keycodes[] in src/keyboard.c! */ +// The order here must match keycodes[] in src/keyboard.c! typedef enum { VTERM_KEY_NONE, @@ -31,11 +31,11 @@ typedef enum { VTERM_KEY_PAGEUP, VTERM_KEY_PAGEDOWN, - /* F1 is VTERM_KEY_FUNCTION(1), F2 VTERM_KEY_FUNCTION(2), etc. */ + // F1 is VTERM_KEY_FUNCTION(1), F2 VTERM_KEY_FUNCTION(2), etc. VTERM_KEY_FUNCTION_0 = 256, VTERM_KEY_FUNCTION_MAX = VTERM_KEY_FUNCTION_0 + 255, - /* keypad keys */ + // keypad keys VTERM_KEY_KP_0, VTERM_KEY_KP_1, VTERM_KEY_KP_2, diff --git a/src/libvterm/src/encoding.c b/src/libvterm/src/encoding.c index dbe129c1ed..623b14f2ac 100644 --- a/src/libvterm/src/encoding.c +++ b/src/libvterm/src/encoding.c @@ -157,8 +157,8 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_, } static VTermEncoding encoding_utf8 = { - &init_utf8, /* init */ - &decode_utf8 /* decode */ + &init_utf8, // init + &decode_utf8 // decode }; static void decode_usascii(VTermEncoding *enc UNUSED, void *data UNUSED, @@ -178,8 +178,8 @@ static void decode_usascii(VTermEncoding *enc UNUSED, void *data UNUSED, } static VTermEncoding encoding_usascii = { - NULL, /* init */ - &decode_usascii /* decode */ + NULL, // init + &decode_usascii // decode }; struct StaticTableEncoding { @@ -223,7 +223,7 @@ encodings[] = { { 0, 0, NULL }, }; -/* This ought to be INTERNAL but isn't because it's used by unit testing */ +// This ought to be INTERNAL but isn't because it's used by unit testing VTermEncoding *vterm_lookup_encoding(VTermEncodingType type, char designation) { int i; diff --git a/src/libvterm/src/keyboard.c b/src/libvterm/src/keyboard.c index 8cc781f305..62338c638d 100644 --- a/src/libvterm/src/keyboard.c +++ b/src/libvterm/src/keyboard.c @@ -8,9 +8,8 @@ void vterm_keyboard_unichar(VTerm *vt, uint32_t c, VTermModifier mod) { int needs_CSIu; - /* The shift modifier is never important for Unicode characters - * apart from Space - */ + // The shift modifier is never important for Unicode characters + // apart from Space if(c != ' ') mod &= ~VTERM_MOD_SHIFT; @@ -23,24 +22,24 @@ void vterm_keyboard_unichar(VTerm *vt, uint32_t c, VTermModifier mod) } switch(c) { - /* Special Ctrl- letters that can't be represented elsewise */ + // Special Ctrl- letters that can't be represented elsewise case 'i': case 'j': case 'm': case '[': needs_CSIu = 1; break; - /* Ctrl-\ ] ^ _ don't need CSUu */ + // Ctrl-\ ] ^ _ don't need CSUu case '\\': case ']': case '^': case '_': needs_CSIu = 0; break; - /* Shift-space needs CSIu */ + // Shift-space needs CSIu case ' ': needs_CSIu = !!(mod & VTERM_MOD_SHIFT); break; - /* All other characters needs CSIu except for letters a-z */ + // All other characters needs CSIu except for letters a-z default: needs_CSIu = (c < 'a' || c > 'z'); } - /* ALT we can just prefix with ESC; anything else requires CSI u */ + // ALT we can just prefix with ESC; anything else requires CSI u if(needs_CSIu && (mod & ~VTERM_MOD_ALT)) { vterm_push_output_sprintf_ctrl(vt, C1_CSI, "%d;%du", c, mod+1); return; @@ -68,7 +67,7 @@ typedef struct { int csinum; } keycodes_s; -/* Order here must be exactly the same as VTermKey enum! */ +// Order here must be exactly the same as VTermKey enum! static keycodes_s keycodes[] = { { KEYCODE_NONE, 0, 0 }, // NONE @@ -155,7 +154,7 @@ void vterm_keyboard_key(VTerm *vt, VTermKey key, VTermModifier mod) break; case KEYCODE_TAB: - /* Shift-Tab is CSI Z but plain Tab is 0x09 */ + // Shift-Tab is CSI Z but plain Tab is 0x09 if(mod == VTERM_MOD_SHIFT) vterm_push_output_sprintf_ctrl(vt, C1_CSI, "Z"); else if(mod & VTERM_MOD_SHIFT) @@ -165,7 +164,7 @@ void vterm_keyboard_key(VTerm *vt, VTermKey key, VTermModifier mod) break; case KEYCODE_ENTER: - /* Enter is CRLF in newline mode, but just LF in linefeed */ + // Enter is CRLF in newline mode, but just LF in linefeed if(vt->state->mode.newline) vterm_push_output_sprintf(vt, "\r\n"); else diff --git a/src/libvterm/src/mouse.c b/src/libvterm/src/mouse.c index 4e363134eb..ae74cfc4bb 100644 --- a/src/libvterm/src/mouse.c +++ b/src/libvterm/src/mouse.c @@ -83,7 +83,7 @@ void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod) state->mouse_buttons &= ~(1 << (button-1)); } - /* Most of the time we don't get button releases from 4/5 */ + // Most of the time we don't get button releases from 4/5 if(state->mouse_buttons == old_buttons && button < 4) return; if (!(state->mouse_flags & MOUSE_WANT_CLICK)) diff --git a/src/libvterm/src/parser.c b/src/libvterm/src/parser.c index db45692d59..77a2c17e5c 100644 --- a/src/libvterm/src/parser.c +++ b/src/libvterm/src/parser.c @@ -125,7 +125,7 @@ static void done_string(VTerm *vt, const char *str, size_t len) size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len) { size_t pos = 0; - const char *string_start = NULL; /* init to avoid gcc warning */ + const char *string_start = NULL; // init to avoid gcc warning switch(vt->parser.state) { case NORMAL: @@ -226,23 +226,23 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len) break; case CSI_LEADER: - /* Extract leader bytes 0x3c to 0x3f */ + // Extract leader bytes 0x3c to 0x3f if(c >= 0x3c && c <= 0x3f) { if(vt->parser.csi_leaderlen < CSI_LEADER_MAX-1) vt->parser.csi_leader[vt->parser.csi_leaderlen++] = c; break; } - /* else fallthrough */ + // else fallthrough vt->parser.csi_leader[vt->parser.csi_leaderlen] = 0; vt->parser.csi_argi = 0; vt->parser.csi_args[0] = CSI_ARG_MISSING; vt->parser.state = CSI_ARGS; - /* fallthrough */ + // fallthrough case CSI_ARGS: - /* Numerical value of argument */ + // Numerical value of argument if(c >= '0' && c <= '9') { if(vt->parser.csi_args[vt->parser.csi_argi] == CSI_ARG_MISSING) vt->parser.csi_args[vt->parser.csi_argi] = 0; @@ -260,11 +260,11 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len) break; } - /* else fallthrough */ + // else fallthrough vt->parser.csi_argi++; vt->parser.intermedlen = 0; vt->parser.state = CSI_INTERMED; - /* fallthrough */ + // fallthrough case CSI_INTERMED: if(is_intermed(c)) { if(vt->parser.intermedlen < INTERMED_MAX-1) @@ -272,13 +272,13 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len) break; } else if(c == 0x1b) { - /* ESC in CSI cancels */ + // ESC in CSI cancels } else if(c >= 0x40 && c <= 0x7e) { vt->parser.intermed[vt->parser.intermedlen] = 0; do_csi(vt, c); } - /* else was invalid CSI */ + // else was invalid CSI ENTER_NORMAL_STATE(); break; @@ -289,8 +289,8 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len) ENTER_NORMAL_STATE(); } else if (pos + 1 == len) { - /* end of input but OSC string isn't finished yet, copy it to - * vt->parser.strbuffer to continue it later */ + // end of input but OSC string isn't finished yet, copy it to + // vt->parser.strbuffer to continue it later more_string(vt, string_start, bytes + pos + 1 - string_start); } break; @@ -321,7 +321,7 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len) if(!eaten) { DEBUG_LOG("libvterm: Text callback did not consume any input\n"); - /* force it to make progress */ + // force it to make progress eaten = 1; } diff --git a/src/libvterm/src/pen.c b/src/libvterm/src/pen.c index 7d8cdc369e..c55f6931f8 100644 --- a/src/libvterm/src/pen.c +++ b/src/libvterm/src/pen.c @@ -3,7 +3,7 @@ #include <stdio.h> static const VTermColor ansi_colors[] = { - /* R G B index */ + // R G B index { 0, 0, 0, 1 }, // black { 224, 0, 0, 2 }, // red { 0, 224, 0, 3 }, // green @@ -28,7 +28,7 @@ static int ramp6[] = { 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF, }; -/* Use 0x81 instead of 0x80 to be able to distinguish from ansi black */ +// Use 0x81 instead of 0x80 to be able to distinguish from ansi black static int ramp24[] = { 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76, 0x81, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE, diff --git a/src/libvterm/src/rect.h b/src/libvterm/src/rect.h index 2114f24c1b..3c070e1cd5 100644 --- a/src/libvterm/src/rect.h +++ b/src/libvterm/src/rect.h @@ -5,7 +5,7 @@ #define STRFrect "(%d,%d-%d,%d)" #define ARGSrect(r) (r).start_row, (r).start_col, (r).end_row, (r).end_col -/* Expand dst to contain src as well */ +// Expand dst to contain src as well static void rect_expand(VTermRect *dst, VTermRect *src) { if(dst->start_row > src->start_row) dst->start_row = src->start_row; @@ -14,19 +14,19 @@ static void rect_expand(VTermRect *dst, VTermRect *src) if(dst->end_col < src->end_col) dst->end_col = src->end_col; } -/* Clip the dst to ensure it does not step outside of bounds */ +// Clip the dst to ensure it does not step outside of bounds static void rect_clip(VTermRect *dst, VTermRect *bounds) { if(dst->start_row < bounds->start_row) dst->start_row = bounds->start_row; if(dst->start_col < bounds->start_col) dst->start_col = bounds->start_col; if(dst->end_row > bounds->end_row) dst->end_row = bounds->end_row; if(dst->end_col > bounds->end_col) dst->end_col = bounds->end_col; - /* Ensure it doesn't end up negatively-sized */ + // Ensure it doesn't end up negatively-sized if(dst->end_row < dst->start_row) dst->end_row = dst->start_row; if(dst->end_col < dst->start_col) dst->end_col = dst->start_col; } -/* True if the two rectangles are equal */ +// True if the two rectangles are equal static int rect_equal(VTermRect *a, VTermRect *b) { return (a->start_row == b->start_row) && @@ -35,7 +35,7 @@ static int rect_equal(VTermRect *a, VTermRect *b) (a->end_col == b->end_col); } -/* True if small is contained entirely within big */ +// True if small is contained entirely within big static int rect_contains(VTermRect *big, VTermRect *small) { if(small->start_row < big->start_row) return 0; @@ -45,7 +45,7 @@ static int rect_contains(VTermRect *big, VTermRect *small) return 1; } -/* True if the rectangles overlap at all */ +// True if the rectangles overlap at all static int rect_intersects(VTermRect *a, VTermRect *b) { if(a->start_row > b->end_row || b->start_row > a->end_row) diff --git a/src/libvterm/src/state.c b/src/libvterm/src/state.c index b50e3667ad..22168d6df4 100644 --- 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[], size_t len, void *user) 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[], size_t len, void *user) 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[], size_t len, void *user) 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[], size_t len, void *user) 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[], size_t len, void *user) } 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[], size_t len, void *user) putglyph(state, chars, width, state->pos); |