From 306139005c31ea7e6f892dd119beba3c94dcb982 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 1 Dec 2019 22:11:18 +0100 Subject: patch 8.1.2380: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate. --- src/getchar.c | 375 +++++++++-------- src/gui.c | 989 +++++++++++++++++++++++---------------------- src/gui_at_fs.c | 40 +- src/gui_at_sb.c | 118 +++--- src/gui_athena.c | 351 ++++++++-------- src/gui_beval.c | 136 +++---- src/gui_gtk.c | 420 ++++++++++--------- src/gui_gtk_f.c | 83 ++-- src/gui_gtk_x11.c | 1166 ++++++++++++++++++++++++++--------------------------- src/version.c | 2 + 10 files changed, 1821 insertions(+), 1859 deletions(-) (limited to 'src') diff --git a/src/getchar.c b/src/getchar.c index d8d498e7d9..72ddbb9ad3 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -38,13 +38,13 @@ * Un-escaping is done by vgetc(). */ -#define MINIMAL_SIZE 20 /* minimal size for b_str */ +#define MINIMAL_SIZE 20 // minimal size for b_str static buffheader_T redobuff = {{NULL, {NUL}}, NULL, 0, 0}; static buffheader_T old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0}; -static int typeahead_char = 0; /* typeahead char that's not flushed */ +static int typeahead_char = 0; // typeahead char that's not flushed /* * when block_redo is TRUE redo buffer will not be changed @@ -73,20 +73,19 @@ static int KeyNoremap = 0; // remapping flags * typebuf.tb_noremap[typebuf.tb_off] is the first valid flag. * (typebuf has been put in globals.h, because check_termcode() needs it). */ -#define RM_YES 0 /* tb_noremap: remap */ -#define RM_NONE 1 /* tb_noremap: don't remap */ -#define RM_SCRIPT 2 /* tb_noremap: remap local script mappings */ -#define RM_ABBR 4 /* tb_noremap: don't remap, do abbrev. */ +#define RM_YES 0 // tb_noremap: remap +#define RM_NONE 1 // tb_noremap: don't remap +#define RM_SCRIPT 2 // tb_noremap: remap local script mappings +#define RM_ABBR 4 // tb_noremap: don't remap, do abbrev. -/* typebuf.tb_buf has three parts: room in front (for result of mappings), the - * middle for typeahead and room for new characters (which needs to be 3 * - * MAXMAPLEN) for the Amiga). - */ +// typebuf.tb_buf has three parts: room in front (for result of mappings), the +// middle for typeahead and room for new characters (which needs to be 3 * +// MAXMAPLEN) for the Amiga). #define TYPELEN_INIT (5 * (MAXMAPLEN + 3)) -static char_u typebuf_init[TYPELEN_INIT]; /* initial typebuf.tb_buf */ -static char_u noremapbuf_init[TYPELEN_INIT]; /* initial typebuf.tb_noremap */ +static char_u typebuf_init[TYPELEN_INIT]; // initial typebuf.tb_buf +static char_u noremapbuf_init[TYPELEN_INIT]; // initial typebuf.tb_noremap -static int last_recorded_len = 0; /* number of last recorded chars */ +static int last_recorded_len = 0; // number of last recorded chars static int read_readbuf(buffheader_T *buf, int advance); static void init_typebuf(void); @@ -120,7 +119,7 @@ free_buff(buffheader_T *buf) static char_u * get_buffcont( buffheader_T *buffer, - int dozero) /* count == zero is not an error */ + int dozero) // count == zero is not an error { long_u count = 0; char_u *p = NULL; @@ -128,7 +127,7 @@ get_buffcont( char_u *str; buffblock_T *bp; - /* compute the total length of the string */ + // compute the total length of the string for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next) count += (long_u)STRLEN(bp->b_str); @@ -196,22 +195,22 @@ get_inserted(void) add_buff( buffheader_T *buf, char_u *s, - long slen) /* length of "s" or -1 */ + long slen) // length of "s" or -1 { buffblock_T *p; long_u len; if (slen < 0) slen = (long)STRLEN(s); - if (slen == 0) /* don't add empty strings */ + if (slen == 0) // don't add empty strings return; - if (buf->bh_first.b_next == NULL) /* first add to list */ + if (buf->bh_first.b_next == NULL) // first add to list { buf->bh_space = 0; buf->bh_curr = &(buf->bh_first); } - else if (buf->bh_curr == NULL) /* buffer has already been read */ + else if (buf->bh_curr == NULL) // buffer has already been read { iemsg(_("E222: Add to read buffer")); return; @@ -236,7 +235,7 @@ add_buff( len = slen; p = alloc(offsetof(buffblock_T, b_str) + len + 1); if (p == NULL) - return; /* no space, just forget it */ + return; // no space, just forget it buf->bh_space = (int)(len - slen); vim_strncpy(p->b_str, s, (size_t)slen); @@ -282,7 +281,7 @@ add_char_buff(buffheader_T *buf, int c) if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL) { - /* translate special key code into three byte sequence */ + // translate special key code into three byte sequence temp[0] = K_SPECIAL; temp[1] = K_SECOND(c); temp[2] = K_THIRD(c); @@ -291,7 +290,7 @@ add_char_buff(buffheader_T *buf, int c) #ifdef FEAT_GUI else if (c == CSI) { - /* Translate a CSI to a CSI - KS_EXTRA - KE_CSI sequence */ + // Translate a CSI to a CSI - KS_EXTRA - KE_CSI sequence temp[0] = CSI; temp[1] = KS_EXTRA; temp[2] = (int)KE_CSI; @@ -307,10 +306,10 @@ add_char_buff(buffheader_T *buf, int c) } } -/* First read ahead buffer. Used for translated commands. */ +// First read ahead buffer. Used for translated commands. static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0}; -/* Second read ahead buffer. Used for redo. */ +// Second read ahead buffer. Used for redo. static buffheader_T readbuf2 = {{NULL, {NUL}}, NULL, 0, 0}; /* @@ -336,7 +335,7 @@ read_readbuf(buffheader_T *buf, int advance) char_u c; buffblock_T *curr; - if (buf->bh_first.b_next == NULL) /* buffer is empty */ + if (buf->bh_first.b_next == NULL) // buffer is empty return NUL; curr = buf->bh_first.b_next; @@ -435,8 +434,8 @@ flush_buffers(flush_buffers_T flush_typeahead) typebuf.tb_off = MAXMAPLEN; typebuf.tb_len = 0; #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) - /* Reset the flag that text received from a client or from feedkeys() - * was inserted in the typeahead buffer. */ + // Reset the flag that text received from a client or from feedkeys() + // was inserted in the typeahead buffer. typebuf_was_filled = FALSE; #endif } @@ -493,7 +492,7 @@ saveRedobuff(save_redo_T *save_redo) save_redo->sr_old_redobuff = old_redobuff; old_redobuff.bh_first.b_next = NULL; - /* Make a copy, so that ":normal ." in a function works. */ + // Make a copy, so that ":normal ." in a function works. s = get_buffcont(&save_redo->sr_redobuff, FALSE); if (s != NULL) { @@ -533,7 +532,7 @@ AppendToRedobuff(char_u *s) void AppendToRedobuffLit( char_u *str, - int len) /* length of "str" or -1 for up to the NUL */ + int len) // length of "str" or -1 for up to the NUL { char_u *s = str; int c; @@ -544,18 +543,18 @@ AppendToRedobuffLit( while (len < 0 ? *s != NUL : s - str < len) { - /* Put a string of normal characters in the redo buffer (that's - * faster). */ + // Put a string of normal characters in the redo buffer (that's + // faster). start = s; while (*s >= ' ' #ifndef EBCDIC - && *s < DEL /* EBCDIC: all chars above space are normal */ + && *s < DEL // EBCDIC: all chars above space are normal #endif && (len < 0 || s - str < len)) ++s; - /* Don't put '0' or '^' as last character, just in case a CTRL-D is - * typed next. */ + // Don't put '0' or '^' as last character, just in case a CTRL-D is + // typed next. if (*s == NUL && (s[-1] == '0' || s[-1] == '^')) --s; if (s > start) @@ -564,16 +563,16 @@ AppendToRedobuffLit( if (*s == NUL || (len >= 0 && s - str >= len)) break; - /* Handle a special or multibyte character. */ + // Handle a special or multibyte character. if (has_mbyte) - /* Handle composing chars separately. */ + // Handle composing chars separately. c = mb_cptr2char_adv(&s); else c = *s++; if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^'))) add_char_buff(&redobuff, Ctrl_V); - /* CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) */ + // CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) if (*s == NUL && c == '0') #ifdef EBCDIC add_buff(&redobuff, (char_u *)"xf0", 3L); @@ -647,7 +646,7 @@ stuffReadbuffSpec(char_u *s) { if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL) { - /* Insert special key literally. */ + // Insert special key literally. stuffReadbuffLen(s, 3L); s += 3; } @@ -712,22 +711,22 @@ read_redo(int init, int old_redo) } if ((c = *p) != NUL) { - /* Reverse the conversion done by add_char_buff() */ - /* For a multi-byte character get all the bytes and return the - * converted character. */ + // Reverse the conversion done by add_char_buff() + // For a multi-byte character get all the bytes and return the + // converted character. if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL)) n = MB_BYTE2LEN_CHECK(c); else n = 1; for (i = 0; ; ++i) { - if (c == K_SPECIAL) /* special key or escaped K_SPECIAL */ + if (c == K_SPECIAL) // special key or escaped K_SPECIAL { c = TO_SPECIAL(p[1], p[2]); p += 2; } #ifdef FEAT_GUI - if (c == CSI) /* escaped CSI */ + if (c == CSI) // escaped CSI p += 2; #endif if (*++p == NUL && bp->b_next != NULL) @@ -736,14 +735,14 @@ read_redo(int init, int old_redo) p = bp->b_str; } buf[i] = c; - if (i == n - 1) /* last byte of a character */ + if (i == n - 1) // last byte of a character { if (n != 1) c = (*mb_ptr2char)(buf); break; } c = *p; - if (c == NUL) /* cannot happen? */ + if (c == NUL) // cannot happen? break; } } @@ -779,24 +778,24 @@ start_redo(long count, int old_redo) { int c; - /* init the pointers; return if nothing to redo */ + // init the pointers; return if nothing to redo if (read_redo(TRUE, old_redo) == FAIL) return FAIL; c = read_redo(FALSE, old_redo); - /* copy the buffer name, if present */ + // copy the buffer name, if present if (c == '"') { add_buff(&readbuf2, (char_u *)"\"", 1L); c = read_redo(FALSE, old_redo); - /* if a numbered buffer is used, increment the number */ + // if a numbered buffer is used, increment the number if (c >= '1' && c < '9') ++c; add_char_buff(&readbuf2, c); - /* the expression register should be re-evaluated */ + // the expression register should be re-evaluated if (c == '=') { add_char_buff(&readbuf2, CAR); @@ -806,7 +805,7 @@ start_redo(long count, int old_redo) c = read_redo(FALSE, old_redo); } - if (c == 'v') /* redo Visual */ + if (c == 'v') // redo Visual { VIsual = curwin->w_cursor; VIsual_active = TRUE; @@ -816,15 +815,15 @@ start_redo(long count, int old_redo) c = read_redo(FALSE, old_redo); } - /* try to enter the count (in place of a previous count) */ + // try to enter the count (in place of a previous count) if (count) { - while (VIM_ISDIGIT(c)) /* skip "old" count */ + while (VIM_ISDIGIT(c)) // skip "old" count c = read_redo(FALSE, old_redo); add_num_buff(&readbuf2, count); } - /* copy from the redo buffer into the stuff buffer */ + // copy from the redo buffer into the stuff buffer add_char_buff(&readbuf2, c); copy_redo(old_redo); return OK; @@ -844,7 +843,7 @@ start_redo_ins(void) return FAIL; start_stuff(); - /* skip the count and the command character */ + // skip the count and the command character while ((c = read_redo(FALSE, FALSE)) != NUL) { if (vim_strchr((char_u *)"AaIiRrOo", c) != NULL) @@ -855,7 +854,7 @@ start_redo_ins(void) } } - /* copy the typed text from the redo buffer into the stuff buffer */ + // copy the typed text from the redo buffer into the stuff buffer copy_redo(FALSE); block_redo = TRUE; return OK; @@ -965,30 +964,30 @@ ins_typebuf( */ newoff = MAXMAPLEN + 4; newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4); - if (newlen < 0) /* string is getting too long */ + if (newlen < 0) // string is getting too long { - emsg(_(e_toocompl)); /* also calls flush_buffers */ + emsg(_(e_toocompl)); // also calls flush_buffers setcursor(); return FAIL; } s1 = alloc(newlen); - if (s1 == NULL) /* out of memory */ + if (s1 == NULL) // out of memory return FAIL; s2 = alloc(newlen); - if (s2 == NULL) /* out of memory */ + if (s2 == NULL) // out of memory { vim_free(s1); return FAIL; } typebuf.tb_buflen = newlen; - /* copy the old chars, before the insertion point */ + // copy the old chars, before the insertion point mch_memmove(s1 + newoff, typebuf.tb_buf + typebuf.tb_off, (size_t)offset); - /* copy the new chars */ + // copy the new chars mch_memmove(s1 + newoff + offset, str, (size_t)addlen); - /* copy the old chars, after the insertion point, including the NUL at - * the end */ + // copy the old chars, after the insertion point, including the NUL at + // the end mch_memmove(s1 + newoff + offset + addlen, typebuf.tb_buf + typebuf.tb_off + offset, (size_t)(typebuf.tb_len - offset + 1)); @@ -1009,7 +1008,7 @@ ins_typebuf( } typebuf.tb_len += addlen; - /* If noremap == REMAP_SCRIPT: do remap script-local mappings. */ + // If noremap == REMAP_SCRIPT: do remap script-local mappings. if (noremap == REMAP_SCRIPT) val = RM_SCRIPT; else if (noremap == REMAP_SKIP) @@ -1035,9 +1034,9 @@ ins_typebuf( typebuf.tb_noremap[typebuf.tb_off + i + offset] = (--nrm >= 0) ? val : RM_YES; - /* tb_maplen and tb_silent only remember the length of mapped and/or - * silent mappings at the start of the buffer, assuming that a mapped - * sequence doesn't result in typed characters. */ + // tb_maplen and tb_silent only remember the length of mapped and/or + // silent mappings at the start of the buffer, assuming that a mapped + // sequence doesn't result in typed characters. if (nottyped || typebuf.tb_maplen > offset) typebuf.tb_maplen += addlen; if (silent || typebuf.tb_silent > offset) @@ -1045,7 +1044,7 @@ ins_typebuf( typebuf.tb_silent += addlen; cmd_silent = TRUE; } - if (typebuf.tb_no_abbr_cnt && offset == 0) /* and not used for abbrev.s */ + if (typebuf.tb_no_abbr_cnt && offset == 0) // and not used for abbrev.s typebuf.tb_no_abbr_cnt += addlen; return OK; @@ -1084,7 +1083,7 @@ ins_char_typebuf(int c) */ int typebuf_changed( - int tb_change_cnt) /* old value of typebuf.tb_change_cnt */ + int tb_change_cnt) // old value of typebuf.tb_change_cnt { return (tb_change_cnt != 0 && (typebuf.tb_change_cnt != tb_change_cnt #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) @@ -1121,7 +1120,7 @@ del_typebuf(int len, int offset) int i; if (len == 0) - return; /* nothing to do */ + return; // nothing to do typebuf.tb_len -= len; @@ -1148,31 +1147,31 @@ del_typebuf(int len, int offset) typebuf.tb_noremap + typebuf.tb_off, (size_t)offset); typebuf.tb_off = MAXMAPLEN; } - /* adjust typebuf.tb_buf (include the NUL at the end) */ + // adjust typebuf.tb_buf (include the NUL at the end) mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, typebuf.tb_buf + i + len, (size_t)(typebuf.tb_len - offset + 1)); - /* adjust typebuf.tb_noremap[] */ + // adjust typebuf.tb_noremap[] mch_memmove(typebuf.tb_noremap + typebuf.tb_off + offset, typebuf.tb_noremap + i + len, (size_t)(typebuf.tb_len - offset)); } - if (typebuf.tb_maplen > offset) /* adjust tb_maplen */ + if (typebuf.tb_maplen > offset) // adjust tb_maplen { if (typebuf.tb_maplen < offset + len) typebuf.tb_maplen = offset; else typebuf.tb_maplen -= len; } - if (typebuf.tb_silent > offset) /* adjust tb_silent */ + if (typebuf.tb_silent > offset) // adjust tb_silent { if (typebuf.tb_silent < offset + len) typebuf.tb_silent = offset; else typebuf.tb_silent -= len; } - if (typebuf.tb_no_abbr_cnt > offset) /* adjust tb_no_abbr_cnt */ + if (typebuf.tb_no_abbr_cnt > offset) // adjust tb_no_abbr_cnt { if (typebuf.tb_no_abbr_cnt < offset + len) typebuf.tb_no_abbr_cnt = offset; @@ -1181,8 +1180,8 @@ del_typebuf(int len, int offset) } #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) - /* Reset the flag that text received from a client or from feedkeys() - * was inserted in the typeahead buffer. */ + // Reset the flag that text received from a client or from feedkeys() + // was inserted in the typeahead buffer. typebuf_was_filled = FALSE; #endif if (++typebuf.tb_change_cnt == 0) @@ -1221,7 +1220,7 @@ gotchars(char_u *chars, int len) continue; } - /* Handle one byte at a time; no translation to be done. */ + // Handle one byte at a time; no translation to be done. for (i = 0; i < buflen; ++i) updatescript(buf[i]); @@ -1229,7 +1228,7 @@ gotchars(char_u *chars, int len) { buf[buflen] = NUL; add_buff(&recordbuff, buf, (long)buflen); - /* remember how many chars were last recorded */ + // remember how many chars were last recorded last_recorded_len += buflen; } buflen = 0; @@ -1237,12 +1236,12 @@ gotchars(char_u *chars, int len) may_sync_undo(); #ifdef FEAT_EVAL - /* output "debug mode" message next time in debug mode */ + // output "debug mode" message next time in debug mode debug_did_msg = FALSE; #endif - /* Since characters have been typed, consider the following to be in - * another mapping. Search string will be kept in history. */ + // Since characters have been typed, consider the following to be in + // another mapping. Search string will be kept in history. ++maptick; } @@ -1277,7 +1276,7 @@ alloc_typebuf(void) return FAIL; } typebuf.tb_buflen = TYPELEN_INIT; - typebuf.tb_off = MAXMAPLEN + 4; /* can insert without realloc */ + typebuf.tb_off = MAXMAPLEN + 4; // can insert without realloc typebuf.tb_len = 0; typebuf.tb_maplen = 0; typebuf.tb_silent = 0; @@ -1314,7 +1313,7 @@ save_typebuf(void) { init_typebuf(); saved_typebuf[curscript] = typebuf; - /* If out of memory: restore typebuf and close file. */ + // If out of memory: restore typebuf and close file. if (alloc_typebuf() == FAIL) { closescript(); @@ -1323,10 +1322,10 @@ save_typebuf(void) return OK; } -static int old_char = -1; /* character put back by vungetc() */ -static int old_mod_mask; /* mod_mask for ungotten character */ -static int old_mouse_row; /* mouse_row related to old_char */ -static int old_mouse_col; /* mouse_col related to old_char */ +static int old_char = -1; // character put back by vungetc() +static int old_mod_mask; // mod_mask for ungotten character +static int old_mouse_row; // mouse_row related to old_char +static int old_mouse_col; // mouse_col related to old_char /* * Save all three kinds of typeahead, so that the user must type at a prompt. @@ -1383,7 +1382,7 @@ restore_typeahead(tasave_T *tp) void openscript( char_u *name, - int directly) /* when TRUE execute directly */ + int directly) // when TRUE execute directly { if (curscript + 1 == NSCRIPT) { @@ -1398,13 +1397,13 @@ openscript( #ifdef FEAT_EVAL if (ignore_script) - /* Not reading from script, also don't open one. Warning message? */ + // Not reading from script, also don't open one. Warning message? return; #endif - if (scriptin[curscript] != NULL) /* already reading script */ + if (scriptin[curscript] != NULL) // already reading script ++curscript; - /* use NameBuff for expanded name */ + // use NameBuff for expanded name expand_env(name, NameBuff, MAXPATHL); if ((scriptin[curscript] = mch_fopen((char *)NameBuff, READBIN)) == NULL) { @@ -1433,9 +1432,9 @@ openscript( int save_msg_scroll = msg_scroll; State = NORMAL; - msg_scroll = FALSE; /* no msg scrolling in Normal mode */ - restart_edit = 0; /* don't go to Insert mode */ - p_im = FALSE; /* don't use 'insertmode' */ + msg_scroll = FALSE; // no msg scrolling in Normal mode + restart_edit = 0; // don't go to Insert mode + p_im = FALSE; // don't use 'insertmode' clear_oparg(&oa); finish_op = FALSE; @@ -1574,8 +1573,8 @@ vgetc(void) int i; #ifdef FEAT_EVAL - /* Do garbage collection when garbagecollect() was called previously and - * we are now at the toplevel. */ + // Do garbage collection when garbagecollect() was called previously and + // we are now at the toplevel. if (may_garbage_collect && want_garbage_collect) garbage_collect(FALSE); #endif @@ -1868,8 +1867,8 @@ plain_vgetc(void) while (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR); if (c == K_PS) - /* Only handle the first pasted character. Drop the rest, since we - * don't know what to do with it. */ + // Only handle the first pasted character. Drop the rest, since we + // don't know what to do with it. c = bracketed_paste(PASTE_ONE_CHAR, FALSE, NULL); return c; @@ -1934,8 +1933,8 @@ char_avail(void) int retval; #ifdef FEAT_EVAL - /* When test_override("char_avail", 1) was called pretend there is no - * typeahead. */ + // When test_override("char_avail", 1) was called pretend there is no + // typeahead. if (disable_char_avail_for_testing) return FALSE; #endif @@ -1962,7 +1961,7 @@ f_getchar(typval_T *argvars, typval_T *rettv) parse_queued_messages(); #endif - /* Position the cursor. Needed after a message that ends in a space. */ + // Position the cursor. Needed after a message that ends in a space. windgoto(msg_row, msg_col); ++no_mapping; @@ -1970,16 +1969,16 @@ f_getchar(typval_T *argvars, typval_T *rettv) for (;;) { if (argvars[0].v_type == VAR_UNKNOWN) - /* getchar(): blocking wait. */ + // getchar(): blocking wait. n = plain_vgetc(); else if (tv_get_number_chk(&argvars[0], &error) == 1) - /* getchar(1): only check if char avail */ + // getchar(1): only check if char avail n = vpeekc_any(); else if (error || vpeekc_any() == NUL) - /* illegal argument or getchar(0) and no char avail: return zero */ + // illegal argument or getchar(0) and no char avail: return zero n = 0; else - /* getchar(0) and char avail: return char */ + // getchar(0) and char avail: return char n = plain_vgetc(); if (n == K_IGNORE) @@ -1997,10 +1996,10 @@ f_getchar(typval_T *argvars, typval_T *rettv) rettv->vval.v_number = n; if (IS_SPECIAL(n) || mod_mask != 0) { - char_u temp[10]; /* modifier: 3, mbyte-char: 6, NUL: 1 */ + char_u temp[10]; // modifier: 3, mbyte-char: 6, NUL: 1 int i = 0; - /* Turn a special key into three bytes, plus modifier. */ + // Turn a special key into three bytes, plus modifier. if (mod_mask != 0) { temp[i++] = K_SPECIAL; @@ -2032,8 +2031,8 @@ f_getchar(typval_T *argvars, typval_T *rettv) if (row >= 0 && col >= 0) { - /* Find the window at the mouse coordinates and compute the - * text position. */ + // Find the window at the mouse coordinates and compute the + // text position. win = mouse_find_win(&row, &col, FIND_POPUP); if (win == NULL) return; @@ -2572,7 +2571,7 @@ handle_mapping( else setcursor(); flush_buffers(FLUSH_MINIMAL); - *mapdepth = 0; /* for next one */ + *mapdepth = 0; // for next one *keylenp = keylen; return map_result_fail; } @@ -2713,15 +2712,15 @@ vungetc(int c) vgetorpeek(int advance) { int c, c1; - int timedout = FALSE; /* waited for more than 1 second - for mapping to complete */ - int mapdepth = 0; /* check for recursive mapping */ - int mode_deleted = FALSE; /* set when mode has been deleted */ + int timedout = FALSE; // waited for more than 1 second + // for mapping to complete + int mapdepth = 0; // check for recursive mapping + int mode_deleted = FALSE; // set when mode has been deleted #ifdef FEAT_CMDL_INFO int new_wcol, new_wrow; #endif #ifdef FEAT_GUI - int shape_changed = FALSE; /* adjusted cursor shape */ + int shape_changed = FALSE; // adjusted cursor shape #endif int n; int old_wcol, old_wrow; @@ -2767,13 +2766,13 @@ vgetorpeek(int advance) { if (advance) { - /* KeyTyped = FALSE; When the command that stuffed something - * was typed, behave like the stuffed command was typed. - * needed for CTRL-W CTRL-] to open a fold, for example. */ + // KeyTyped = FALSE; When the command that stuffed something + // was typed, behave like the stuffed command was typed. + // needed for CTRL-W CTRL-] to open a fold, for example. KeyStuffed = TRUE; } if (typebuf.tb_no_abbr_cnt == 0) - typebuf.tb_no_abbr_cnt = 1; /* no abbreviations now */ + typebuf.tb_no_abbr_cnt = 1; // no abbreviations now } else { @@ -2798,10 +2797,10 @@ vgetorpeek(int advance) if (typebuf.tb_maplen) line_breakcheck(); else - ui_breakcheck(); /* check for CTRL-C */ + ui_breakcheck(); // check for CTRL-C if (got_int) { - /* flush all input */ + // flush all input c = inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 0L); /* @@ -2820,8 +2819,8 @@ vgetorpeek(int advance) if (advance) { - /* Also record this character, it might be needed to - * get out of Insert mode. */ + // Also record this character, it might be needed to + // get out of Insert mode. *typebuf.tb_buf = c; gotchars(typebuf.tb_buf, 1); } @@ -2852,7 +2851,7 @@ vgetorpeek(int advance) * get a character: 2. from the typeahead buffer */ c = typebuf.tb_buf[typebuf.tb_off]; - if (advance) /* remove chars from tb_buf */ + if (advance) // remove chars from tb_buf { cmd_silent = (typebuf.tb_silent > 0); if (typebuf.tb_maplen > 0) @@ -2860,7 +2859,7 @@ vgetorpeek(int advance) else { KeyTyped = TRUE; - /* write char to script file(s) */ + // write char to script file(s) gotchars(typebuf.tb_buf + typebuf.tb_off, 1); } @@ -2911,7 +2910,7 @@ vgetorpeek(int advance) mode_deleted = TRUE; } #ifdef FEAT_GUI - /* may show a different cursor shape */ + // may show a different cursor shape if (gui.in_use && State != NORMAL && !cmd_silent) { int save_State; @@ -2927,7 +2926,7 @@ vgetorpeek(int advance) old_wcol = curwin->w_wcol; old_wrow = curwin->w_wrow; - /* move cursor left, if possible */ + // move cursor left, if possible if (curwin->w_cursor.col != 0) { if (curwin->w_wcol > 0) @@ -2956,7 +2955,7 @@ vgetorpeek(int advance) + curwin->w_wcol / curwin->w_width; curwin->w_wcol %= curwin->w_width; curwin->w_wcol += curwin_col_off(); - col = 0; /* no correction needed */ + col = 0; // no correction needed } else { @@ -2972,8 +2971,8 @@ vgetorpeek(int advance) } if (has_mbyte && col > 0 && curwin->w_wcol > 0) { - /* Correct when the cursor is on the right halve - * of a double-wide character. */ + // Correct when the cursor is on the right halve + // of a double-wide character. ptr = ml_get_curline(); col -= (*mb_head_off)(ptr, ptr + col); if ((*mb_ptr2cells)(ptr + col) > 1) @@ -2990,15 +2989,15 @@ vgetorpeek(int advance) curwin->w_wrow = old_wrow; } if (c < 0) - continue; /* end of input script reached */ + continue; // end of input script reached - /* Allow mapping for just typed characters. When we get here c - * is the number of extra bytes and typebuf.tb_len is 1. */ + // Allow mapping for just typed characters. When we get here c + // is the number of extra bytes and typebuf.tb_len is 1. for (n = 1; n <= c; ++n) typebuf.tb_noremap[typebuf.tb_off + n] = RM_YES; typebuf.tb_len += c; - /* buffer full, don't map */ + // buffer full, don't map if (typebuf.tb_len >= typebuf.tb_maplen + MAXMAPLEN) { timedout = TRUE; @@ -3011,20 +3010,20 @@ vgetorpeek(int advance) static int tc = 0; #endif - /* No typeahead left and inside ":normal". Must return - * something to avoid getting stuck. When an incomplete - * mapping is present, behave like it timed out. */ + // No typeahead left and inside ":normal". Must return + // something to avoid getting stuck. When an incomplete + // mapping is present, behave like it timed out. if (typebuf.tb_len > 0) { timedout = TRUE; continue; } - /* When 'insertmode' is set, ESC just beeps in Insert - * mode. Use CTRL-L to make edit() return. - * For the command line only CTRL-C always breaks it. - * For the cmdline window: Alternate between ESC and - * CTRL-C: ESC for most situations and CTRL-C to close the - * cmdline window. */ + // When 'insertmode' is set, ESC just beeps in Insert + // mode. Use CTRL-L to make edit() return. + // For the command line only CTRL-C always breaks it. + // For the cmdline window: Alternate between ESC and + // CTRL-C: ESC for most situations and CTRL-C to close the + // cmdline window. if (p_im && (State & INSERT)) c = Ctrl_L; #ifdef FEAT_TERMINAL @@ -3048,18 +3047,18 @@ vgetorpeek(int advance) /* * get a character: 3. from the user - update display */ - /* In insert mode a screen update is skipped when characters - * are still available. But when those available characters - * are part of a mapping, and we are going to do a blocking - * wait here. Need to update the screen to display the - * changed text so far. Also for when 'lazyredraw' is set and - * redrawing was postponed because there was something in the - * input buffer (e.g., termresponse). */ + // In insert mode a screen update is skipped when characters + // are still available. But when those available characters + // are part of a mapping, and we are going to do a blocking + // wait here. Need to update the screen to display the + // changed text so far. Also for when 'lazyredraw' is set and + // redrawing was postponed because there was something in the + // input buffer (e.g., termresponse). if (((State & INSERT) != 0 || p_lz) && (State & CMDLINE) == 0 && advance && must_redraw != 0 && !need_wait_return) { update_screen(0); - setcursor(); /* put cursor back where it belongs */ + setcursor(); // put cursor back where it belongs } /* @@ -3076,18 +3075,18 @@ vgetorpeek(int advance) if (((State & (NORMAL | INSERT)) || State == LANGMAP) && State != HITRETURN) { - /* this looks nice when typing a dead character map */ + // this looks nice when typing a dead character map if (State & INSERT && ptr2cells(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_len - 1) == 1) { edit_putchar(typebuf.tb_buf[typebuf.tb_off + typebuf.tb_len - 1], FALSE); - setcursor(); /* put cursor back where it belongs */ + setcursor(); // put cursor back where it belongs c1 = 1; } #ifdef FEAT_CMDL_INFO - /* need to use the col and row from above here */ + // need to use the col and row from above here old_wcol = curwin->w_wcol; old_wrow = curwin->w_wrow; curwin->w_wcol = new_wcol; @@ -3103,7 +3102,7 @@ vgetorpeek(int advance) #endif } - /* this looks nice when typing a dead character map */ + // this looks nice when typing a dead character map if ((State & CMDLINE) #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) && cmdline_star == 0 @@ -3156,37 +3155,37 @@ vgetorpeek(int advance) if (State & CMDLINE) unputcmdline(); else - setcursor(); /* put cursor back where it belongs */ + setcursor(); // put cursor back where it belongs } if (c < 0) - continue; /* end of input script reached */ - if (c == NUL) /* no character available */ + continue; // end of input script reached + if (c == NUL) // no character available { if (!advance) break; - if (wait_tb_len > 0) /* timed out */ + if (wait_tb_len > 0) // timed out { timedout = TRUE; continue; } } else - { /* allow mapping for just typed characters */ + { // allow mapping for just typed characters while (typebuf.tb_buf[typebuf.tb_off + typebuf.tb_len] != NUL) typebuf.tb_noremap[typebuf.tb_off + typebuf.tb_len++] = RM_YES; #ifdef HAVE_INPUT_METHOD - /* Get IM status right after getting keys, not after the - * timeout for a mapping (focus may be lost by then). */ + // Get IM status right after getting keys, not after the + // timeout for a mapping (focus may be lost by then). vgetc_im_active = im_get_status(); #endif } - } /* for (;;) */ - } /* if (!character from stuffbuf) */ + } // for (;;) + } // if (!character from stuffbuf) - /* if advance is FALSE don't loop on NULs */ + // if advance is FALSE don't loop on NULs } while ((c < 0 && c != K_CANCEL) || (advance && c == NUL)); /* @@ -3199,20 +3198,20 @@ vgetorpeek(int advance) if (c == ESC && !mode_deleted && !no_mapping && mode_displayed) { if (typebuf.tb_len && !KeyTyped) - redraw_cmdline = TRUE; /* delete mode later */ + redraw_cmdline = TRUE; // delete mode later else unshowmode(FALSE); } else if (c != ESC && mode_deleted) { if (typebuf.tb_len && !KeyTyped) - redraw_cmdline = TRUE; /* show mode later */ + redraw_cmdline = TRUE; // show mode later else showmode(); } } #ifdef FEAT_GUI - /* may unshow different cursor shape */ + // may unshow different cursor shape if (gui.in_use && shape_changed) gui_update_cursor(TRUE, FALSE); #endif @@ -3260,14 +3259,14 @@ vgetorpeek(int advance) inchar( char_u *buf, int maxlen, - long wait_time) /* milli seconds */ + long wait_time) // milli seconds { - int len = 0; /* init for GCC */ - int retesc = FALSE; /* return ESC with gotint */ + int len = 0; // init for GCC + int retesc = FALSE; // return ESC with gotint int script_char; int tb_change_cnt = typebuf.tb_change_cnt; - if (wait_time == -1L || wait_time > 100L) /* flush output before waiting */ + if (wait_time == -1L || wait_time > 100L) // flush output before waiting { cursor_on(); out_flush_cursor(FALSE, FALSE); @@ -3284,10 +3283,10 @@ inchar( */ if (State != HITRETURN) { - did_outofmem_msg = FALSE; /* display out of memory message (again) */ - did_swapwrite_msg = FALSE; /* display swap file write error again */ + did_outofmem_msg = FALSE; // display out of memory message (again) + did_swapwrite_msg = FALSE; // display swap file write error again } - undo_off = FALSE; /* restart undo now */ + undo_off = FALSE; // restart undo now /* * Get a character from a script file if there is one. @@ -3306,9 +3305,9 @@ inchar( if (got_int || (script_char = getc(scriptin[curscript])) < 0) { - /* Reached EOF. - * Careful: closescript() frees typebuf.tb_buf[] and buf[] may - * point inside typebuf.tb_buf[]. Don't use buf[] after this! */ + // Reached EOF. + // Careful: closescript() frees typebuf.tb_buf[] and buf[] may + // point inside typebuf.tb_buf[]. Don't use buf[] after this! closescript(); /* * When reading script file is interrupted, return an ESC to get @@ -3327,7 +3326,7 @@ inchar( } } - if (script_char < 0) /* did not get a character from script */ + if (script_char < 0) // did not get a character from script { /* * If we got an interrupt, skip all previously typed characters and @@ -3365,14 +3364,14 @@ inchar( len = ui_inchar(buf, maxlen / 3, wait_time, tb_change_cnt); } - /* If the typebuf was changed further down, it is like nothing was added by - * this call. */ + // If the typebuf was changed further down, it is like nothing was added by + // this call. if (typebuf_changed(tb_change_cnt)) return 0; - /* Note the change in the typeahead buffer, this matters for when - * vgetorpeek() is called recursively, e.g. using getchar(1) in a timer - * function. */ + // Note the change in the typeahead buffer, this matters for when + // vgetorpeek() is called recursively, e.g. using getchar(1) in a timer + // function. if (len > 0 && ++typebuf.tb_change_cnt == 0) typebuf.tb_change_cnt = 1; @@ -3400,15 +3399,15 @@ fix_input_buffer(char_u *buf, int len) for (i = len; --i >= 0; ++p) { #ifdef FEAT_GUI - /* When the GUI is used any character can come after a CSI, don't - * escape it. */ + // When the GUI is used any character can come after a CSI, don't + // escape it. if (gui.in_use && p[0] == CSI && i >= 2) { p += 2; i -= 2; } # ifndef MSWIN - /* When the GUI is not used CSI needs to be escaped. */ + // When the GUI is not used CSI needs to be escaped. else if (!gui.in_use && p[0] == CSI) { mch_memmove(p + 3, p + 1, (size_t)i); diff --git a/src/gui.c b/src/gui.c index 3e5eff5d8a..0a7f346dbc 100644 --- a/src/gui.c +++ b/src/gui.c @@ -10,7 +10,7 @@ #include "vim.h" -/* Structure containing all the GUI information */ +// Structure containing all the GUI information gui_T gui; #if !defined(FEAT_GUI_GTK) @@ -38,7 +38,7 @@ static void gui_do_fork(void); static int gui_read_child_pipe(int fd); -/* Return values for gui_read_child_pipe */ +// Return values for gui_read_child_pipe enum { GUI_CHILD_IO_ERROR, GUI_CHILD_OK, @@ -48,8 +48,8 @@ enum { static void gui_attempt_start(void); -static int can_update_cursor = TRUE; /* can display the cursor */ -static int disable_flush = 0; /* If > 0, gui_mch_flush() is disabled. */ +static int can_update_cursor = TRUE; // can display the cursor +static int disable_flush = 0; // If > 0, gui_mch_flush() is disabled. /* * The Athena scrollbars can move the thumb to after the end of the scrollbar, @@ -78,9 +78,9 @@ gui_start(char_u *arg UNUSED) old_term = vim_strsave(T_NAME); - settmode(TMODE_COOK); /* stop RAW mode */ + settmode(TMODE_COOK); // stop RAW mode if (full_screen) - cursor_on(); /* needed for ":gui" in .vimrc */ + cursor_on(); // needed for ":gui" in .vimrc full_screen = FALSE; ++recursive; @@ -125,30 +125,29 @@ gui_start(char_u *arg UNUSED) #endif { #ifdef FEAT_GUI_GTK - /* If there is 'f' in 'guioptions' and specify -g argument, - * gui_mch_init_check() was not called yet. */ + // If there is 'f' in 'guioptions' and specify -g argument, + // gui_mch_init_check() was not called yet. if (gui_mch_init_check() != OK) getout_preserve_modified(1); #endif gui_attempt_start(); } - if (!gui.in_use) /* failed to start GUI */ + if (!gui.in_use) // failed to start GUI { - /* Back to old term settings - * - * FIXME: If we got here because a child process failed and flagged to - * the parent to resume, and X11 is enabled with FEAT_TITLE, this will - * hit an X11 I/O error and do a longjmp(), leaving recursive - * permanently set to 1. This is probably not as big a problem as it - * sounds, because gui_mch_init() in both gui_x11.c and gui_gtk_x11.c - * return "OK" unconditionally, so it would be very difficult to - * actually hit this case. - */ + // Back to old term settings + // + // FIXME: If we got here because a child process failed and flagged to + // the parent to resume, and X11 is enabled with FEAT_TITLE, this will + // hit an X11 I/O error and do a longjmp(), leaving recursive + // permanently set to 1. This is probably not as big a problem as it + // sounds, because gui_mch_init() in both gui_x11.c and gui_gtk_x11.c + // return "OK" unconditionally, so it would be very difficult to + // actually hit this case. termcapinit(old_term); - settmode(TMODE_RAW); /* restart RAW mode */ + settmode(TMODE_RAW); // restart RAW mode #ifdef FEAT_TITLE - set_title_defaults(); /* set 'title' and 'icon' again */ + set_title_defaults(); // set 'title' and 'icon' again #endif #if defined(GUI_MAY_SPAWN) && defined(EXPERIMENTAL_GUI_CMD) if (msg) @@ -158,8 +157,8 @@ gui_start(char_u *arg UNUSED) vim_free(old_term); - /* If the GUI started successfully, trigger the GUIEnter event, otherwise - * the GUIFailed event. */ + // If the GUI started successfully, trigger the GUIEnter event, otherwise + // the GUIFailed event. gui_mch_update(); apply_autocmds(gui.in_use ? EVENT_GUIENTER : EVENT_GUIFAILED, NULL, NULL, FALSE, curbuf); @@ -202,7 +201,7 @@ gui_attempt_start(void) set_vim_var_nr(VV_WINDOWID, (long)x11_window); # endif - /* Display error messages in a dialog now. */ + // Display error messages in a dialog now. display_errors(); } #endif @@ -211,7 +210,7 @@ gui_attempt_start(void) #ifdef GUI_MAY_FORK -/* for waitpid() */ +// for waitpid() # if defined(HAVE_SYS_WAIT_H) || defined(HAVE_UNION_WAIT) # include # endif @@ -231,38 +230,38 @@ gui_attempt_start(void) static void gui_do_fork(void) { - int pipefd[2]; /* pipe between parent and child */ + int pipefd[2]; // pipe between parent and child int pipe_error; int status; int exit_status; pid_t pid = -1; - /* Setup a pipe between the child and the parent, so that the parent - * knows when the child has done the setsid() call and is allowed to - * exit. */ + // Setup a pipe between the child and the parent, so that the parent + // knows when the child has done the setsid() call and is allowed to + // exit. pipe_error = (pipe(pipefd) < 0); pid = fork(); - if (pid < 0) /* Fork error */ + if (pid < 0) // Fork error { emsg(_("E851: Failed to create a new process for the GUI")); return; } - else if (pid > 0) /* Parent */ + else if (pid > 0) // Parent { - /* Give the child some time to do the setsid(), otherwise the - * exit() may kill the child too (when starting gvim from inside a - * gvim). */ + // Give the child some time to do the setsid(), otherwise the + // exit() may kill the child too (when starting gvim from inside a + // gvim). if (!pipe_error) { - /* The read returns when the child closes the pipe (or when - * the child dies for some reason). */ + // The read returns when the child closes the pipe (or when + // the child dies for some reason). close(pipefd[1]); status = gui_read_child_pipe(pipefd[0]); if (status == GUI_CHILD_FAILED) { - /* The child failed to start the GUI, so the caller must - * continue. There may be more error information written - * to stderr by the child. */ + // The child failed to start the GUI, so the caller must + // continue. There may be more error information written + // to stderr by the child. # ifdef __NeXT__ wait4(pid, &exit_status, 0, (struct rusage *)0); # else @@ -275,14 +274,14 @@ gui_do_fork(void) { pipe_error = TRUE; } - /* else GUI_CHILD_OK: parent exit */ + // else GUI_CHILD_OK: parent exit } if (pipe_error) ui_delay(301L, TRUE); - /* When swapping screens we may need to go to the next line, e.g., - * after a hit-enter prompt and using ":gui". */ + // When swapping screens we may need to go to the next line, e.g., + // after a hit-enter prompt and using ":gui". if (newline_on_exit) mch_errmsg("\r\n"); @@ -292,10 +291,10 @@ gui_do_fork(void) */ _exit(0); } - /* Child */ + // Child #ifdef FEAT_GUI_GTK - /* Call gtk_init_check() here after fork(). See gui_init_check(). */ + // Call gtk_init_check() here after fork(). See gui_init_check(). if (gui_mch_init_check() != OK) getout_preserve_modified(1); #endif @@ -315,14 +314,14 @@ gui_do_fork(void) close(pipefd[0]); # if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION) - /* Tell the session manager our new PID */ + // Tell the session manager our new PID gui_mch_forked(); # endif - /* Try to start the GUI */ + // Try to start the GUI gui_attempt_start(); - /* Notify the parent */ + // Notify the parent if (!pipe_error) { if (gui.in_use) @@ -332,7 +331,7 @@ gui_do_fork(void) close(pipefd[1]); } - /* If we failed to start the GUI, exit now. */ + // If we failed to start the GUI, exit now. if (!gui.in_use) getout_preserve_modified(1); } @@ -364,7 +363,7 @@ gui_read_child_pipe(int fd) return GUI_CHILD_FAILED; } -#endif /* GUI_MAY_FORK */ +#endif // GUI_MAY_FORK /* * Call this when vim starts up, whether or not the GUI is started @@ -372,8 +371,8 @@ gui_read_child_pipe(int fd) void gui_prepare(int *argc, char **argv) { - gui.in_use = FALSE; /* No GUI yet (maybe later) */ - gui.starting = FALSE; /* No GUI yet (maybe later) */ + gui.in_use = FALSE; // No GUI yet (maybe later) + gui.starting = FALSE; // No GUI yet (maybe later) gui_mch_prepare(argc, argv); } @@ -397,7 +396,7 @@ gui_init_check(void) gui.shell_created = FALSE; gui.dying = FALSE; - gui.in_focus = TRUE; /* so the guicursor setting works */ + gui.in_focus = TRUE; // so the guicursor setting works gui.dragged_sb = SBAR_NONE; gui.dragged_wp = NULL; gui.pointer_hidden = FALSE; @@ -441,7 +440,7 @@ gui_init_check(void) gui.menu_font = NOFONT; # endif # endif - gui.menu_is_active = TRUE; /* default: include menu */ + gui.menu_is_active = TRUE; // default: include menu # ifndef FEAT_GUI_GTK gui.menu_height = MENU_DEFAULT_HEIGHT; gui.menu_width = 0; @@ -499,7 +498,7 @@ gui_init(void) clip_init(TRUE); - /* If can't initialize, don't try doing the rest */ + // If can't initialize, don't try doing the rest if (gui_init_check() == FAIL) { --recursive; @@ -596,8 +595,8 @@ gui_init(void) { stat_T s; - /* if ".gvimrc" file is not owned by user, set 'secure' - * mode */ + // if ".gvimrc" file is not owned by user, set 'secure' + // mode if (mch_stat(GVIMRC_FILE, &s) || s.st_uid != getuid()) secure = p_secure; } @@ -638,19 +637,19 @@ gui_init(void) --recursive; } - /* If recursive call opened the shell, return here from the first call */ + // If recursive call opened the shell, return here from the first call if (gui.in_use) return; /* * Create the GUI shell. */ - gui.in_use = TRUE; /* Must be set after menus have been set up */ + gui.in_use = TRUE; // Must be set after menus have been set up if (gui_mch_init() == FAIL) goto error; - /* Avoid a delay for an error message that was printed in the terminal - * where Vim was started. */ + // Avoid a delay for an error message that was printed in the terminal + // where Vim was started. emsg_on_display = FALSE; msg_scrolled = 0; clear_sb_text(TRUE); @@ -686,7 +685,7 @@ gui_init(void) gui.num_rows = Rows; gui_reset_scroll_region(); - /* Create initial scrollbars */ + // Create initial scrollbars FOR_ALL_WINDOWS(wp) { gui_create_scrollbar(&wp->w_scrollbars[SBAR_LEFT], SBAR_LEFT, wp); @@ -701,10 +700,10 @@ gui_init(void) sign_gui_started(); #endif - /* Configure the desired menu and scrollbars */ + // Configure the desired menu and scrollbars gui_init_which_components(NULL); - /* All components of the GUI have been created now */ + // All components of the GUI have been created now gui.shell_created = TRUE; #ifdef FEAT_GUI_MSWIN @@ -723,8 +722,8 @@ gui_init(void) # endif #endif #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) - /* Need to set the size of the menubar after all the menus have been - * created. */ + // Need to set the size of the menubar after all the menus have been + // created. gui_mch_compute_menu_height((Widget)0); #endif @@ -739,16 +738,16 @@ gui_init(void) #endif init_gui_options(); #ifdef FEAT_ARABIC - /* Our GUI can't do bidi. */ + // Our GUI can't do bidi. p_tbidi = FALSE; #endif #if defined(FEAT_GUI_GTK) - /* Give GTK+ a chance to put all widget's into place. */ + // Give GTK+ a chance to put all widget's into place. gui_mch_update(); # ifdef FEAT_MENU - /* If there is no 'm' in 'guioptions' we need to remove the menu now. - * It was still there to make F10 work. */ + // If there is no 'm' in 'guioptions' we need to remove the menu now. + // It was still there to make F10 work. if (vim_strchr(p_go, GO_MENUS) == NULL) { --gui.starting; @@ -758,19 +757,19 @@ gui_init(void) } # endif - /* Now make sure the shell fits on the screen. */ + // Now make sure the shell fits on the screen. if (gui_mch_maximized()) gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH); else gui_set_shellsize(TRUE, TRUE, RESIZE_BOTH); #endif - /* When 'lines' was set while starting up the topframe may have to be - * resized. */ + // When 'lines' was set while starting up the topframe may have to be + // resized. win_new_shellsize(); #ifdef FEAT_BEVAL_GUI - /* Always create the Balloon Evaluation area, but disable it when - * 'ballooneval' is off. */ + // Always create the Balloon Evaluation area, but disable it when + // 'ballooneval' is off. if (balloonEval != NULL) { # ifdef FEAT_VARTABS @@ -804,8 +803,8 @@ gui_init(void) if (!im_xim_isvalid_imactivate()) emsg(_("E599: Value of 'imactivatekey' is invalid")); #endif - /* When 'cmdheight' was set during startup it may not have taken - * effect yet. */ + // When 'cmdheight' was set during startup it may not have taken + // effect yet. if (p_ch != 1L) command_height(); @@ -814,7 +813,7 @@ gui_init(void) error2: #ifdef FEAT_GUI_X11 - /* undo gui_mch_init() */ + // undo gui_mch_init() gui_mch_uninit(); #endif @@ -827,8 +826,8 @@ error: void gui_exit(int rc) { - /* don't free the fonts, it leads to a BUS error - * richard@whitequeen.com Jul 99 */ + // don't free the fonts, it leads to a BUS error + // richard@whitequeen.com Jul 99 free_highlight_fonts(); gui.in_use = FALSE; gui_mch_exit(rc); @@ -850,7 +849,7 @@ gui_shell_closed(void) save_cmdmod = cmdmod; - /* Only exit when there are no changed files */ + // Only exit when there are no changed files exiting = TRUE; # ifdef FEAT_BROWSE cmdmod.browse = TRUE; @@ -858,14 +857,14 @@ gui_shell_closed(void) # if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) cmdmod.confirm = TRUE; # endif - /* If there are changed buffers, present the user with a dialog if - * possible, otherwise give an error message. */ + // If there are changed buffers, present the user with a dialog if + // possible, otherwise give an error message. if (!check_changed_any(FALSE, FALSE)) getout(0); exiting = FALSE; cmdmod = save_cmdmod; - gui_update_screen(); /* redraw, window may show changed buffer */ + gui_update_screen(); // redraw, window may show changed buffer } #endif @@ -894,26 +893,26 @@ gui_init_font(char_u *font_list, int fontset UNUSED) else { #ifdef FEAT_XFONTSET - /* When using a fontset, the whole list of fonts is one name. */ + // When using a fontset, the whole list of fonts is one name. if (fontset) ret = gui_mch_init_font(font_list, TRUE); else #endif while (*font_list != NUL) { - /* Isolate one comma separated font name. */ + // Isolate one comma separated font name. (void)copy_option_part(&font_list, font_name, FONTLEN, ","); - /* Careful!!! The Win32 version of gui_mch_init_font(), when - * called with "*" will change p_guifont to the selected font - * name, which frees the old value. This makes font_list - * invalid. Thus when OK is returned here, font_list must no - * longer be used! */ + // Careful!!! The Win32 version of gui_mch_init_font(), when + // called with "*" will change p_guifont to the selected font + // name, which frees the old value. This makes font_list + // invalid. Thus when OK is returned here, font_list must no + // longer be used! if (gui_mch_init_font(font_name, FALSE) == OK) { #if !defined(FEAT_GUI_GTK) - /* If it's a Unicode font, try setting 'guifontwide' to a - * similar double-width font. */ + // If it's a Unicode font, try setting 'guifontwide' to a + // similar double-width font. if ((p_guifontwide == NULL || *p_guifontwide == NUL) && strstr((char *)font_name, "10646") != NULL) set_guifontwide(font_name); @@ -939,7 +938,7 @@ gui_init_font(char_u *font_list, int fontset UNUSED) if (ret == OK) { #ifndef FEAT_GUI_GTK - /* Set normal font as current font */ + // Set normal font as current font # ifdef FEAT_XFONTSET if (gui.fontset != NOFONTSET) gui_mch_set_fontset(gui.fontset); @@ -961,7 +960,7 @@ gui_init_font(char_u *font_list, int fontset UNUSED) set_guifontwide(char_u *name) { int i = 0; - char_u wide_name[FONTLEN + 10]; /* room for 2 * width and '*' */ + char_u wide_name[FONTLEN + 10]; // room for 2 * width and '*' char_u *wp = NULL; char_u *p; GuiFont font; @@ -973,18 +972,18 @@ set_guifontwide(char_u *name) if (*p == '-') { ++i; - if (i == 6) /* font type: change "--" to "-*-" */ + if (i == 6) // font type: change "--" to "-*-" { if (p[1] == '-') *wp++ = '*'; } - else if (i == 12) /* found the width */ + else if (i == 12) // found the width { ++p; i = getdigits(&p); if (i != 0) { - /* Double the width specification. */ + // Double the width specification. sprintf((char *)wp, "%d%s", i * 2, p); font = gui_mch_get_font(wide_name, FALSE); if (font != NOFONT) @@ -1000,7 +999,7 @@ set_guifontwide(char_u *name) } } } -#endif /* !FEAT_GUI_GTK */ +#endif // !FEAT_GUI_GTK /* * Get the font for 'guifontwide'. @@ -1013,14 +1012,14 @@ gui_get_wide_font(void) char_u font_name[FONTLEN]; char_u *p; - if (!gui.in_use) /* Can't allocate font yet, assume it's OK. */ - return OK; /* Will give an error message later. */ + if (!gui.in_use) // Can't allocate font yet, assume it's OK. + return OK; // Will give an error message later. if (p_guifontwide != NULL && *p_guifontwide != NUL) { for (p = p_guifontwide; *p != NUL; ) { - /* Isolate one comma separated font name. */ + // Isolate one comma separated font name. (void)copy_option_part(&p, font_name, FONTLEN, ","); font = gui_mch_get_font(font_name, FALSE); if (font != NOFONT) @@ -1032,7 +1031,7 @@ gui_get_wide_font(void) gui_mch_free_font(gui.wide_font); #ifdef FEAT_GUI_GTK - /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */ + // Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. if (font != NOFONT && gui.norm_font != NOFONT && pango_font_description_equal(font, gui.norm_font)) { @@ -1081,8 +1080,8 @@ gui_check_pos(void) */ void gui_update_cursor( - int force, /* when TRUE, update even when not moved */ - int clear_selection)/* clear selection under cursor */ + int force, // when TRUE, update even when not moved + int clear_selection) // clear selection under cursor { int cur_width = 0; int cur_height = 0; @@ -1093,13 +1092,13 @@ gui_update_cursor( guicolor_T shape_fg = INVALCOLOR; guicolor_T shape_bg = INVALCOLOR; #endif - guicolor_T cfg, cbg, cc; /* cursor fore-/background color */ - int cattr; /* cursor attributes */ + guicolor_T cfg, cbg, cc; // cursor fore-/background color + int cattr; // cursor attributes int attr; attrentry_T *aep = NULL; - /* Don't update the cursor when halfway busy scrolling or the screen size - * doesn't match 'columns' and 'lines. ScreenLines[] isn't valid then. */ + // Don't update the cursor when halfway busy scrolling or the screen size + // doesn't match 'columns' and 'lines. ScreenLines[] isn't valid then. if (!can_update_cursor || screen_Columns != gui.num_cols || screen_Rows != gui.num_rows) return; @@ -1118,15 +1117,15 @@ gui_update_cursor( gui.cursor_row = gui.row; gui.cursor_col = gui.col; - /* Only write to the screen after ScreenLines[] has been initialized */ + // Only write to the screen after ScreenLines[] has been initialized if (!screen_cleared || ScreenLines == NULL) return; - /* Clear the selection if we are about to write over it */ + // Clear the selection if we are about to write over it if (clear_selection) clip_may_clear_selection(gui.row, gui.row); - /* Check that the cursor is inside the shell (resizing may have made - * it invalid) */ + // Check that the cursor is inside the shell (resizing may have made + // it invalid) if (gui.row >= screen_Rows || gui.col >= screen_Columns) return; @@ -1147,7 +1146,7 @@ gui_update_cursor( else id = shape->id; - /* get the colors and attributes for the cursor. Default is inverted */ + // get the colors and attributes for the cursor. Default is inverted cfg = INVALCOLOR; cbg = INVALCOLOR; cattr = HL_INVERSE; @@ -1292,16 +1291,16 @@ gui_update_cursor( if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col, LineOffset[gui.row] + screen_Columns) > 1) { - /* Double wide character. */ + // Double wide character. if (shape->shape != SHAPE_VER) cur_width += gui.char_width; #ifdef FEAT_RIGHTLEFT if (CURSOR_BAR_RIGHT) { - /* gui.col points to the left halve of the character but - * the vertical line needs to be on the right halve. - * A double-wide horizontal line is also drawn from the - * right halve in gui_mch_draw_part_cursor(). */ + // gui.col points to the left halve of the character but + // the vertical line needs to be on the right halve. + // A double-wide horizontal line is also drawn from the + // right halve in gui_mch_draw_part_cursor(). col_off = TRUE; ++gui.col; } @@ -1313,7 +1312,7 @@ gui_update_cursor( --gui.col; #endif -#ifndef FEAT_GUI_MSWIN /* doesn't seem to work for MSWindows */ +#ifndef FEAT_GUI_MSWIN // doesn't seem to work for MSWindows gui.highlight_mask = ScreenAttrs[LineOffset[gui.row] + gui.col]; (void)gui_screenchar(LineOffset[gui.row] + gui.col, GUI_MON_TRS_CURSOR | GUI_MON_NOCLEAR, @@ -1347,7 +1346,7 @@ gui_position_components(int total_width UNUSED) int text_area_width; int text_area_height; - /* avoid that moving components around generates events */ + // avoid that moving components around generates events ++hold_gui_events; text_area_x = 0; @@ -1436,9 +1435,9 @@ gui_get_base_height(void) if (gui.which_scrollbars[SBAR_BOTTOM]) base_height += gui.scrollbar_height; #ifdef FEAT_GUI_GTK - /* We can't take the sizes properly into account until anything is - * realized. Therefore we recalculate all the values here just before - * setting the size. (--mdcki) */ + // We can't take the sizes properly into account until anything is + // realized. Therefore we recalculate all the values here just before + // setting the size. (--mdcki) #else # ifdef FEAT_MENU if (gui.menu_is_active) @@ -1477,7 +1476,7 @@ gui_resize_shell(int pixel_width, int pixel_height) { static int busy = FALSE; - if (!gui.shell_created) /* ignore when still initializing */ + if (!gui.shell_created) // ignore when still initializing return; /* @@ -1496,7 +1495,7 @@ again: new_pixel_height = 0; busy = TRUE; - /* Flush pending output before redrawing */ + // Flush pending output before redrawing out_flush(); gui.num_cols = (pixel_width - gui_get_base_width()) / gui.char_width; @@ -1512,8 +1511,8 @@ again: if (State == ASKMORE || State == CONFIRM) gui.row = gui.num_rows; - /* Only comparing Rows and Columns may be sufficient, but let's stay on - * the safe side. */ + // Only comparing Rows and Columns may be sufficient, but let's stay on + // the safe side. if (gui.num_rows != screen_Rows || gui.num_cols != screen_Columns || gui.num_rows != Rows || gui.num_cols != Columns) shell_resized(); @@ -1526,9 +1525,9 @@ again: busy = FALSE; - /* We may have been called again while redrawing the screen. - * Need to do it all again with the latest size then. But only if the size - * actually changed. */ + // We may have been called again while redrawing the screen. + // Need to do it all again with the latest size then. But only if the size + // actually changed. if (new_pixel_height) { if (pixel_width == new_pixel_width && pixel_height == new_pixel_height) @@ -1552,8 +1551,8 @@ again: gui_may_resize_shell(void) { if (new_pixel_height) - /* careful: gui_resize_shell() may postpone the resize again if we - * were called indirectly by it */ + // careful: gui_resize_shell() may postpone the resize again if we + // were called indirectly by it gui_resize_shell(new_pixel_width, new_pixel_height); } @@ -1576,7 +1575,7 @@ gui_get_shellsize(void) gui_set_shellsize( int mustset UNUSED, int fit_to_display, - int direction) /* RESIZE_HOR, RESIZE_VER */ + int direction) // RESIZE_HOR, RESIZE_VER { int base_width; int base_height; @@ -1596,8 +1595,8 @@ gui_set_shellsize( return; #if defined(MSWIN) || defined(FEAT_GUI_GTK) - /* If not setting to a user specified size and maximized, calculate the - * number of characters that fit in the maximized window. */ + // If not setting to a user specified size and maximized, calculate the + // number of characters that fit in the maximized window. if (!mustset && (vim_strchr(p_go, GO_KEEPWINSIZE) != NULL || gui_mch_maximized())) { @@ -1609,7 +1608,7 @@ gui_set_shellsize( base_width = gui_get_base_width(); base_height = gui_get_base_height(); if (fit_to_display) - /* Remember the original window position. */ + // Remember the original window position. (void)gui_mch_get_winpos(&x, &y); width = Columns * gui.char_width + base_width; @@ -1640,7 +1639,7 @@ gui_set_shellsize( #ifdef FEAT_GUI_GTK if (did_adjust == 2 || (width + gui.char_width >= screen_w && height + gui.char_height >= screen_h)) - /* don't unmaximize if at maximum size */ + // don't unmaximize if at maximum size un_maximize = FALSE; #endif } @@ -1655,8 +1654,8 @@ gui_set_shellsize( #ifdef FEAT_GUI_GTK if (un_maximize) { - /* If the window size is smaller than the screen unmaximize the - * window, otherwise resizing won't work. */ + // If the window size is smaller than the screen unmaximize the + // window, otherwise resizing won't work. gui_mch_get_screen_dimensions(&screen_w, &screen_h); if ((width + gui.char_width < screen_w || height + gui.char_height * 2 < screen_h) @@ -1670,9 +1669,9 @@ gui_set_shellsize( if (fit_to_display && x >= 0 && y >= 0) { - /* Some window managers put the Vim window left of/above the screen. - * Only change the position if it wasn't already negative before - * (happens on MS-Windows with a secondary monitor). */ + // Some window managers put the Vim window left of/above the screen. + // Only change the position if it wasn't already negative before + // (happens on MS-Windows with a secondary monitor). gui_mch_update(); if (gui_mch_get_winpos(&x, &y) == OK && (x < 0 || y < 0)) gui_mch_set_winpos(x < 0 ? 0 : x, y < 0 ? 0 : y); @@ -1707,18 +1706,18 @@ gui_reset_scroll_region(void) static void gui_start_highlight(int mask) { - if (mask > HL_ALL) /* highlight code */ + if (mask > HL_ALL) // highlight code gui.highlight_mask = mask; - else /* mask */ + else // mask gui.highlight_mask |= mask; } void gui_stop_highlight(int mask) { - if (mask > HL_ALL) /* highlight code */ + if (mask > HL_ALL) // highlight code gui.highl