To: vim_dev@googlegroups.com Subject: Patch 8.1.2380 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2380 Problem: Using old C style comments. Solution: Use // comments where appropriate. Files: src/getchar.c, src/gui.c, src/gui_at_fs.c, src/gui_at_sb.c, src/gui_athena.c, src/gui_beval.c, src/gui_gtk.c, src/gui_gtk_f.c, src/gui_gtk_x11.c *** ../vim-8.1.2379/src/getchar.c 2019-11-30 22:47:42.647331219 +0100 --- src/getchar.c 2019-12-01 21:50:57.599048856 +0100 *************** *** 38,50 **** * Un-escaping is done by vgetc(). */ ! #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 */ /* * when block_redo is TRUE redo buffer will not be changed --- 38,50 ---- * Un-escaping is done by vgetc(). */ ! #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 /* * when block_redo is TRUE redo buffer will not be changed *************** *** 73,92 **** * 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. */ ! ! /* 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 int last_recorded_len = 0; /* number of last recorded chars */ static int read_readbuf(buffheader_T *buf, int advance); static void init_typebuf(void); --- 73,91 ---- * 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. ! ! // 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 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,126 **** static char_u * get_buffcont( buffheader_T *buffer, ! int dozero) /* count == zero is not an error */ { long_u count = 0; char_u *p = NULL; --- 119,125 ---- static char_u * get_buffcont( buffheader_T *buffer, ! int dozero) // count == zero is not an error { long_u count = 0; char_u *p = NULL; *************** *** 128,134 **** char_u *str; buffblock_T *bp; ! /* 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); --- 127,133 ---- char_u *str; buffblock_T *bp; ! // 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,217 **** add_buff( buffheader_T *buf, char_u *s, ! 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 */ return; ! 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 */ { iemsg(_("E222: Add to read buffer")); return; --- 195,216 ---- add_buff( buffheader_T *buf, char_u *s, ! 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 return; ! 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 { iemsg(_("E222: Add to read buffer")); return; *************** *** 236,242 **** len = slen; p = alloc(offsetof(buffblock_T, b_str) + len + 1); if (p == NULL) ! return; /* no space, just forget it */ buf->bh_space = (int)(len - slen); vim_strncpy(p->b_str, s, (size_t)slen); --- 235,241 ---- len = slen; p = alloc(offsetof(buffblock_T, b_str) + len + 1); if (p == NULL) ! return; // no space, just forget it buf->bh_space = (int)(len - slen); vim_strncpy(p->b_str, s, (size_t)slen); *************** *** 282,288 **** if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL) { ! /* translate special key code into three byte sequence */ temp[0] = K_SPECIAL; temp[1] = K_SECOND(c); temp[2] = K_THIRD(c); --- 281,287 ---- if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL) { ! // translate special key code into three byte sequence temp[0] = K_SPECIAL; temp[1] = K_SECOND(c); temp[2] = K_THIRD(c); *************** *** 291,297 **** #ifdef FEAT_GUI else if (c == CSI) { ! /* Translate a CSI to a CSI - KS_EXTRA - KE_CSI sequence */ temp[0] = CSI; temp[1] = KS_EXTRA; temp[2] = (int)KE_CSI; --- 290,296 ---- #ifdef FEAT_GUI else if (c == CSI) { ! // Translate a CSI to a CSI - KS_EXTRA - KE_CSI sequence temp[0] = CSI; temp[1] = KS_EXTRA; temp[2] = (int)KE_CSI; *************** *** 307,316 **** } } ! /* First read ahead buffer. Used for translated commands. */ static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0}; ! /* Second read ahead buffer. Used for redo. */ static buffheader_T readbuf2 = {{NULL, {NUL}}, NULL, 0, 0}; /* --- 306,315 ---- } } ! // First read ahead buffer. Used for translated commands. static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0}; ! // Second read ahead buffer. Used for redo. static buffheader_T readbuf2 = {{NULL, {NUL}}, NULL, 0, 0}; /* *************** *** 336,342 **** char_u c; buffblock_T *curr; ! if (buf->bh_first.b_next == NULL) /* buffer is empty */ return NUL; curr = buf->bh_first.b_next; --- 335,341 ---- char_u c; buffblock_T *curr; ! if (buf->bh_first.b_next == NULL) // buffer is empty return NUL; curr = buf->bh_first.b_next; *************** *** 435,442 **** 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. */ typebuf_was_filled = FALSE; #endif } --- 434,441 ---- 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. typebuf_was_filled = FALSE; #endif } *************** *** 493,499 **** save_redo->sr_old_redobuff = old_redobuff; old_redobuff.bh_first.b_next = NULL; ! /* Make a copy, so that ":normal ." in a function works. */ s = get_buffcont(&save_redo->sr_redobuff, FALSE); if (s != NULL) { --- 492,498 ---- save_redo->sr_old_redobuff = old_redobuff; old_redobuff.bh_first.b_next = NULL; ! // Make a copy, so that ":normal ." in a function works. s = get_buffcont(&save_redo->sr_redobuff, FALSE); if (s != NULL) { *************** *** 533,539 **** void AppendToRedobuffLit( char_u *str, ! int len) /* length of "str" or -1 for up to the NUL */ { char_u *s = str; int c; --- 532,538 ---- void AppendToRedobuffLit( char_u *str, ! int len) // length of "str" or -1 for up to the NUL { char_u *s = str; int c; *************** *** 544,561 **** while (len < 0 ? *s != NUL : s - str < len) { ! /* 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 */ #endif && (len < 0 || s - str < len)) ++s; ! /* 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) --- 543,560 ---- while (len < 0 ? *s != NUL : s - str < len) { ! // 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 #endif && (len < 0 || s - str < len)) ++s; ! // 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,579 **** if (*s == NUL || (len >= 0 && s - str >= len)) break; ! /* Handle a special or multibyte character. */ if (has_mbyte) ! /* 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) */ if (*s == NUL && c == '0') #ifdef EBCDIC add_buff(&redobuff, (char_u *)"xf0", 3L); --- 563,578 ---- if (*s == NUL || (len >= 0 && s - str >= len)) break; ! // Handle a special or multibyte character. if (has_mbyte) ! // 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) if (*s == NUL && c == '0') #ifdef EBCDIC add_buff(&redobuff, (char_u *)"xf0", 3L); *************** *** 647,653 **** { if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL) { ! /* Insert special key literally. */ stuffReadbuffLen(s, 3L); s += 3; } --- 646,652 ---- { if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL) { ! // Insert special key literally. stuffReadbuffLen(s, 3L); s += 3; } *************** *** 712,733 **** } 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. */ 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 */ { c = TO_SPECIAL(p[1], p[2]); p += 2; } #ifdef FEAT_GUI ! if (c == CSI) /* escaped CSI */ p += 2; #endif if (*++p == NUL && bp->b_next != NULL) --- 711,732 ---- } 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. 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 { c = TO_SPECIAL(p[1], p[2]); p += 2; } #ifdef FEAT_GUI ! if (c == CSI) // escaped CSI p += 2; #endif if (*++p == NUL && bp->b_next != NULL) *************** *** 736,749 **** p = bp->b_str; } buf[i] = c; ! if (i == n - 1) /* last byte of a character */ { if (n != 1) c = (*mb_ptr2char)(buf); break; } c = *p; ! if (c == NUL) /* cannot happen? */ break; } } --- 735,748 ---- p = bp->b_str; } buf[i] = c; ! if (i == n - 1) // last byte of a character { if (n != 1) c = (*mb_ptr2char)(buf); break; } c = *p; ! if (c == NUL) // cannot happen? break; } } *************** *** 779,802 **** { int c; ! /* 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 */ if (c == '"') { add_buff(&readbuf2, (char_u *)"\"", 1L); c = read_redo(FALSE, old_redo); ! /* 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 */ if (c == '=') { add_char_buff(&readbuf2, CAR); --- 778,801 ---- { int c; ! // 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 if (c == '"') { add_buff(&readbuf2, (char_u *)"\"", 1L); c = read_redo(FALSE, old_redo); ! // 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 if (c == '=') { add_char_buff(&readbuf2, CAR); *************** *** 806,812 **** c = read_redo(FALSE, old_redo); } ! if (c == 'v') /* redo Visual */ { VIsual = curwin->w_cursor; VIsual_active = TRUE; --- 805,811 ---- c = read_redo(FALSE, old_redo); } ! if (c == 'v') // redo Visual { VIsual = curwin->w_cursor; VIsual_active = TRUE; *************** *** 816,830 **** c = read_redo(FALSE, old_redo); } ! /* try to enter the count (in place of a previous count) */ if (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 */ add_char_buff(&readbuf2, c); copy_redo(old_redo); return OK; --- 815,829 ---- c = read_redo(FALSE, old_redo); } ! // try to enter the count (in place of a previous count) if (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 add_char_buff(&readbuf2, c); copy_redo(old_redo); return OK; *************** *** 844,850 **** return FAIL; start_stuff(); ! /* skip the count and the command character */ while ((c = read_redo(FALSE, FALSE)) != NUL) { if (vim_strchr((char_u *)"AaIiRrOo", c) != NULL) --- 843,849 ---- return FAIL; start_stuff(); ! // skip the count and the command character while ((c = read_redo(FALSE, FALSE)) != NUL) { if (vim_strchr((char_u *)"AaIiRrOo", c) != NULL) *************** *** 855,861 **** } } ! /* copy the typed text from the redo buffer into the stuff buffer */ copy_redo(FALSE); block_redo = TRUE; return OK; --- 854,860 ---- } } ! // copy the typed text from the redo buffer into the stuff buffer copy_redo(FALSE); block_redo = TRUE; return OK; *************** *** 965,994 **** */ newoff = MAXMAPLEN + 4; newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4); ! if (newlen < 0) /* string is getting too long */ { ! emsg(_(e_toocompl)); /* also calls flush_buffers */ setcursor(); return FAIL; } s1 = alloc(newlen); ! if (s1 == NULL) /* out of memory */ return FAIL; s2 = alloc(newlen); ! if (s2 == NULL) /* out of memory */ { vim_free(s1); return FAIL; } typebuf.tb_buflen = newlen; ! /* 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 */ mch_memmove(s1 + newoff + offset, str, (size_t)addlen); ! /* 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)); --- 964,993 ---- */ newoff = MAXMAPLEN + 4; newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4); ! if (newlen < 0) // string is getting too long { ! emsg(_(e_toocompl)); // also calls flush_buffers setcursor(); return FAIL; } s1 = alloc(newlen); ! if (s1 == NULL) // out of memory return FAIL; s2 = alloc(newlen); ! if (s2 == NULL) // out of memory { vim_free(s1); return FAIL; } typebuf.tb_buflen = newlen; ! // 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 mch_memmove(s1 + newoff + offset, str, (size_t)addlen); ! // 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,1015 **** } typebuf.tb_len += addlen; ! /* If noremap == REMAP_SCRIPT: do remap script-local mappings. */ if (noremap == REMAP_SCRIPT) val = RM_SCRIPT; else if (noremap == REMAP_SKIP) --- 1008,1014 ---- } typebuf.tb_len += addlen; ! // If noremap == REMAP_SCRIPT: do remap script-local mappings. if (noremap == REMAP_SCRIPT) val = RM_SCRIPT; else if (noremap == REMAP_SKIP) *************** *** 1035,1043 **** 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. */ if (nottyped || typebuf.tb_maplen > offset) typebuf.tb_maplen += addlen; if (silent || typebuf.tb_silent > offset) --- 1034,1042 ---- 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. if (nottyped || typebuf.tb_maplen > offset) typebuf.tb_maplen += addlen; if (silent || typebuf.tb_silent > offset) *************** *** 1045,1051 **** typebuf.tb_silent += addlen; cmd_silent = TRUE; } ! if (typebuf.tb_no_abbr_cnt && offset == 0) /* and not used for abbrev.s */ typebuf.tb_no_abbr_cnt += addlen; return OK; --- 1044,1050 ---- typebuf.tb_silent += addlen; cmd_silent = TRUE; } ! if (typebuf.tb_no_abbr_cnt && offset == 0) // and not used for abbrev.s typebuf.tb_no_abbr_cnt += addlen; return OK; *************** *** 1084,1090 **** */ int typebuf_changed( ! 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) --- 1083,1089 ---- */ int typebuf_changed( ! 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,1127 **** int i; if (len == 0) ! return; /* nothing to do */ typebuf.tb_len -= len; --- 1120,1126 ---- int i; if (len == 0) ! return; // nothing to do typebuf.tb_len -= len; *************** *** 1148,1178 **** typebuf.tb_noremap + typebuf.tb_off, (size_t)offset); typebuf.tb_off = MAXMAPLEN; } ! /* 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[] */ 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 + len) typebuf.tb_maplen = offset; else typebuf.tb_maplen -= len; } ! 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 + len) typebuf.tb_no_abbr_cnt = offset; --- 1147,1177 ---- typebuf.tb_noremap + typebuf.tb_off, (size_t)offset); typebuf.tb_off = MAXMAPLEN; } ! // 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[] 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 + len) typebuf.tb_maplen = offset; else typebuf.tb_maplen -= len; } ! 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 + len) typebuf.tb_no_abbr_cnt = offset; *************** *** 1181,1188 **** } #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. */ typebuf_was_filled = FALSE; #endif if (++typebuf.tb_change_cnt == 0) --- 1180,1187 ---- } #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. typebuf_was_filled = FALSE; #endif if (++typebuf.tb_change_cnt == 0) *************** *** 1221,1227 **** continue; } ! /* Handle one byte at a time; no translation to be done. */ for (i = 0; i < buflen; ++i) updatescript(buf[i]); --- 1220,1226 ---- continue; } ! // Handle one byte at a time; no translation to be done. for (i = 0; i < buflen; ++i) updatescript(buf[i]); *************** *** 1229,1235 **** { buf[buflen] = NUL; add_buff(&recordbuff, buf, (long)buflen); ! /* remember how many chars were last recorded */ last_recorded_len += buflen; } buflen = 0; --- 1228,1234 ---- { buf[buflen] = NUL; add_buff(&recordbuff, buf, (long)buflen); ! // remember how many chars were last recorded last_recorded_len += buflen; } buflen = 0; *************** *** 1237,1248 **** may_sync_undo(); #ifdef FEAT_EVAL ! /* 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. */ ++maptick; } --- 1236,1247 ---- may_sync_undo(); #ifdef FEAT_EVAL ! // 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. ++maptick; } *************** *** 1277,1283 **** return FAIL; } typebuf.tb_buflen = TYPELEN_INIT; ! typebuf.tb_off = MAXMAPLEN + 4; /* can insert without realloc */ typebuf.tb_len = 0; typebuf.tb_maplen = 0; typebuf.tb_silent = 0; --- 1276,1282 ---- return FAIL; } typebuf.tb_buflen = TYPELEN_INIT; ! typebuf.tb_off = MAXMAPLEN + 4; // can insert without realloc typebuf.tb_len = 0; typebuf.tb_maplen = 0; typebuf.tb_silent = 0; *************** *** 1314,1320 **** { init_typebuf(); saved_typebuf[curscript] = typebuf; ! /* If out of memory: restore typebuf and close file. */ if (alloc_typebuf() == FAIL) { closescript(); --- 1313,1319 ---- { init_typebuf(); saved_typebuf[curscript] = typebuf; ! // If out of memory: restore typebuf and close file. if (alloc_typebuf() == FAIL) { closescript(); *************** *** 1323,1332 **** 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 */ /* * Save all three kinds of typeahead, so that the user must type at a prompt. --- 1322,1331 ---- 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 /* * Save all three kinds of typeahead, so that the user must type at a prompt. *************** *** 1383,1389 **** void openscript( char_u *name, ! int directly) /* when TRUE execute directly */ { if (curscript + 1 == NSCRIPT) { --- 1382,1388 ---- void openscript( char_u *name, ! int directly) // when TRUE execute directly { if (curscript + 1 == NSCRIPT) { *************** *** 1398,1410 **** #ifdef FEAT_EVAL if (ignore_script) ! /* Not reading from script, also don't open one. Warning message? */ return; #endif ! if (scriptin[curscript] != NULL) /* already reading script */ ++curscript; ! /* use NameBuff for expanded name */ expand_env(name, NameBuff, MAXPATHL); if ((scriptin[curscript] = mch_fopen((char *)NameBuff, READBIN)) == NULL) { --- 1397,1409 ---- #ifdef FEAT_EVAL if (ignore_script) ! // Not reading from script, also don't open one. Warning message? return; #endif ! if (scriptin[curscript] != NULL) // already reading script ++curscript; ! // use NameBuff for expanded name expand_env(name, NameBuff, MAXPATHL); if ((scriptin[curscript] = mch_fopen((char *)NameBuff, READBIN)) == NULL) { *************** *** 1433,1441 **** 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' */ clear_oparg(&oa); finish_op = FALSE; --- 1432,1440 ---- 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' clear_oparg(&oa); finish_op = FALSE; *************** *** 1574,1581 **** int i; #ifdef FEAT_EVAL ! /* 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 --- 1573,1580 ---- int i; #ifdef FEAT_EVAL ! // 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,1875 **** 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. */ c = bracketed_paste(PASTE_ONE_CHAR, FALSE, NULL); return c; --- 1867,1874 ---- 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. c = bracketed_paste(PASTE_ONE_CHAR, FALSE, NULL); return c; *************** *** 1934,1941 **** int retval; #ifdef FEAT_EVAL ! /* When test_override("char_avail", 1) was called pretend there is no ! * typeahead. */ if (disable_char_avail_for_testing) return FALSE; #endif --- 1933,1940 ---- int retval; #ifdef FEAT_EVAL ! // When test_override("char_avail", 1) was called pretend there is no ! // typeahead. if (disable_char_avail_for_testing) return FALSE; #endif *************** *** 1962,1968 **** parse_queued_messages(); #endif ! /* Position the cursor. Needed after a message that ends in a space. */ windgoto(msg_row, msg_col); ++no_mapping; --- 1961,1967 ---- parse_queued_messages(); #endif ! // Position the cursor. Needed after a message that ends in a space. windgoto(msg_row, msg_col); ++no_mapping; *************** *** 1970,1985 **** for (;;) { if (argvars[0].v_type == VAR_UNKNOWN) ! /* getchar(): blocking wait. */ n = plain_vgetc(); else if (tv_get_number_chk(&argvars[0], &error) == 1) ! /* 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 */ n = 0; else ! /* getchar(0) and char avail: return char */ n = plain_vgetc(); if (n == K_IGNORE) --- 1969,1984 ---- for (;;) { if (argvars[0].v_type == VAR_UNKNOWN) ! // getchar(): blocking wait. n = plain_vgetc(); else if (tv_get_number_chk(&argvars[0], &error) == 1) ! // 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 n = 0; else ! // getchar(0) and char avail: return char n = plain_vgetc(); if (n == K_IGNORE) *************** *** 1997,2006 **** rettv->vval.v_number = n; if (IS_SPECIAL(n) || mod_mask != 0) { ! char_u temp[10]; /* modifier: 3, mbyte-char: 6, NUL: 1 */ int i = 0; ! /* Turn a special key into three bytes, plus modifier. */ if (mod_mask != 0) { temp[i++] = K_SPECIAL; --- 1996,2005 ---- rettv->vval.v_number = n; if (IS_SPECIAL(n) || mod_mask != 0) { ! char_u temp[10]; // modifier: 3, mbyte-char: 6, NUL: 1 int i = 0; ! // Turn a special key into three bytes, plus modifier. if (mod_mask != 0) { temp[i++] = K_SPECIAL; *************** *** 2032,2039 **** if (row >= 0 && col >= 0) { ! /* Find the window at the mouse coordinates and compute the ! * text position. */ win = mouse_find_win(&row, &col, FIND_POPUP); if (win == NULL) return; --- 2031,2038 ---- if (row >= 0 && col >= 0) { ! // 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,2578 **** else setcursor(); flush_buffers(FLUSH_MINIMAL); ! *mapdepth = 0; /* for next one */ *keylenp = keylen; return map_result_fail; } --- 2571,2577 ---- else setcursor(); flush_buffers(FLUSH_MINIMAL); ! *mapdepth = 0; // for next one *keylenp = keylen; return map_result_fail; } *************** *** 2713,2727 **** 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 */ #ifdef FEAT_CMDL_INFO int new_wcol, new_wrow; #endif #ifdef FEAT_GUI ! int shape_changed = FALSE; /* adjusted cursor shape */ #endif int n; int old_wcol, old_wrow; --- 2712,2726 ---- 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 #ifdef FEAT_CMDL_INFO int new_wcol, new_wrow; #endif #ifdef FEAT_GUI ! int shape_changed = FALSE; // adjusted cursor shape #endif int n; int old_wcol, old_wrow; *************** *** 2767,2779 **** { 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. */ KeyStuffed = TRUE; } if (typebuf.tb_no_abbr_cnt == 0) ! typebuf.tb_no_abbr_cnt = 1; /* no abbreviations now */ } else { --- 2766,2778 ---- { 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. KeyStuffed = TRUE; } if (typebuf.tb_no_abbr_cnt == 0) ! typebuf.tb_no_abbr_cnt = 1; // no abbreviations now } else { *************** *** 2798,2807 **** if (typebuf.tb_maplen) line_breakcheck(); else ! ui_breakcheck(); /* check for CTRL-C */ if (got_int) { ! /* flush all input */ c = inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 0L); /* --- 2797,2806 ---- if (typebuf.tb_maplen) line_breakcheck(); else ! ui_breakcheck(); // check for CTRL-C if (got_int) { ! // flush all input c = inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 0L); /* *************** *** 2820,2827 **** if (advance) { ! /* Also record this character, it might be needed to ! * get out of Insert mode. */ *typebuf.tb_buf = c; gotchars(typebuf.tb_buf, 1); } --- 2819,2826 ---- if (advance) { ! // Also record this character, it might be needed to ! // get out of Insert mode. *typebuf.tb_buf = c; gotchars(typebuf.tb_buf, 1); } *************** *** 2852,2858 **** * get a character: 2. from the typeahead buffer */ c = typebuf.tb_buf[typebuf.tb_off]; ! if (advance) /* remove chars from tb_buf */ { cmd_silent = (typebuf.tb_silent > 0); if (typebuf.tb_maplen > 0) --- 2851,2857 ---- * get a character: 2. from the typeahead buffer */ c = typebuf.tb_buf[typebuf.tb_off]; ! if (advance) // remove chars from tb_buf { cmd_silent = (typebuf.tb_silent > 0); if (typebuf.tb_maplen > 0) *************** *** 2860,2866 **** else { KeyTyped = TRUE; ! /* write char to script file(s) */ gotchars(typebuf.tb_buf + typebuf.tb_off, 1); } --- 2859,2865 ---- else { KeyTyped = TRUE; ! // write char to script file(s) gotchars(typebuf.tb_buf + typebuf.tb_off, 1); } *************** *** 2911,2917 **** mode_deleted = TRUE; } #ifdef FEAT_GUI ! /* may show a different cursor shape */ if (gui.in_use && State != NORMAL && !cmd_silent) { int save_State; --- 2910,2916 ---- mode_deleted = TRUE; } #ifdef FEAT_GUI ! // may show a different cursor shape if (gui.in_use && State != NORMAL && !cmd_silent) { int save_State; *************** *** 2927,2933 **** old_wcol = curwin->w_wcol; old_wrow = curwin->w_wrow; ! /* move cursor left, if possible */ if (curwin->w_cursor.col != 0) { if (curwin->w_wcol > 0) --- 2926,2932 ---- old_wcol = curwin->w_wcol; old_wrow = curwin->w_wrow; ! // move cursor left, if possible if (curwin->w_cursor.col != 0) { if (curwin->w_wcol > 0) *************** *** 2956,2962 **** + curwin->w_wcol / curwin->w_width; curwin->w_wcol %= curwin->w_width; curwin->w_wcol += curwin_col_off(); ! col = 0; /* no correction needed */ } else { --- 2955,2961 ---- + curwin->w_wcol / curwin->w_width; curwin->w_wcol %= curwin->w_width; curwin->w_wcol += curwin_col_off(); ! col = 0; // no correction needed } else { *************** *** 2972,2979 **** } if (has_mbyte && col > 0 && curwin->w_wcol > 0) { ! /* 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) --- 2971,2978 ---- } if (has_mbyte && col > 0 && curwin->w_wcol > 0) { ! // 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,3004 **** curwin->w_wrow = old_wrow; } if (c < 0) ! 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. */ for (n = 1; n <= c; ++n) typebuf.tb_noremap[typebuf.tb_off + n] = RM_YES; typebuf.tb_len += c; ! /* buffer full, don't map */ if (typebuf.tb_len >= typebuf.tb_maplen + MAXMAPLEN) { timedout = TRUE; --- 2989,3003 ---- curwin->w_wrow = old_wrow; } if (c < 0) ! 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. for (n = 1; n <= c; ++n) typebuf.tb_noremap[typebuf.tb_off + n] = RM_YES; typebuf.tb_len += c; ! // buffer full, don't map if (typebuf.tb_len >= typebuf.tb_maplen + MAXMAPLEN) { timedout = TRUE; *************** *** 3011,3030 **** 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. */ 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. */ if (p_im && (State & INSERT)) c = Ctrl_L; #ifdef FEAT_TERMINAL --- 3010,3029 ---- 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. 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. if (p_im && (State & INSERT)) c = Ctrl_L; #ifdef FEAT_TERMINAL *************** *** 3048,3065 **** /* * 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). */ 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 */ } /* --- 3047,3064 ---- /* * 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). 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 } /* *************** *** 3076,3093 **** if (((State & (NORMAL | INSERT)) || State == LANGMAP) && State != HITRETURN) { ! /* 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 */ c1 = 1; } #ifdef FEAT_CMDL_INFO ! /* 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; --- 3075,3092 ---- if (((State & (NORMAL | INSERT)) || State == LANGMAP) && State != HITRETURN) { ! // 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 c1 = 1; } #ifdef FEAT_CMDL_INFO ! // 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,3109 **** #endif } ! /* this looks nice when typing a dead character map */ if ((State & CMDLINE) #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) && cmdline_star == 0 --- 3102,3108 ---- #endif } ! // this looks nice when typing a dead character map if ((State & CMDLINE) #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) && cmdline_star == 0 *************** *** 3156,3192 **** if (State & CMDLINE) unputcmdline(); else ! setcursor(); /* put cursor back where it belongs */ } if (c < 0) ! continue; /* end of input script reached */ ! if (c == NUL) /* no character available */ { if (!advance) break; ! if (wait_tb_len > 0) /* timed out */ { timedout = TRUE; continue; } } else ! { /* 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). */ vgetc_im_active = im_get_status(); #endif } ! } /* for (;;) */ ! } /* if (!character from stuffbuf) */ ! /* if advance is FALSE don't loop on NULs */ } while ((c < 0 && c != K_CANCEL) || (advance && c == NUL)); /* --- 3155,3191 ---- if (State & CMDLINE) unputcmdline(); else ! setcursor(); // put cursor back where it belongs } if (c < 0) ! continue; // end of input script reached ! if (c == NUL) // no character available { if (!advance) break; ! if (wait_tb_len > 0) // timed out { timedout = TRUE; continue; } } else ! { // 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). vgetc_im_active = im_get_status(); #endif } ! } // for (;;) ! } // if (!character from stuffbuf) ! // if advance is FALSE don't loop on NULs } while ((c < 0 && c != K_CANCEL) || (advance && c == NUL)); /* *************** *** 3199,3218 **** if (c == ESC && !mode_deleted && !no_mapping && mode_displayed) { if (typebuf.tb_len && !KeyTyped) ! 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 */ else showmode(); } } #ifdef FEAT_GUI ! /* may unshow different cursor shape */ if (gui.in_use && shape_changed) gui_update_cursor(TRUE, FALSE); #endif --- 3198,3217 ---- if (c == ESC && !mode_deleted && !no_mapping && mode_displayed) { if (typebuf.tb_len && !KeyTyped) ! 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 else showmode(); } } #ifdef FEAT_GUI ! // may unshow different cursor shape if (gui.in_use && shape_changed) gui_update_cursor(TRUE, FALSE); #endif *************** *** 3260,3273 **** inchar( char_u *buf, int maxlen, ! long wait_time) /* milli seconds */ { ! 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 */ { cursor_on(); out_flush_cursor(FALSE, FALSE); --- 3259,3272 ---- inchar( char_u *buf, int maxlen, ! long wait_time) // milli seconds { ! 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 { cursor_on(); out_flush_cursor(FALSE, FALSE); *************** *** 3284,3293 **** */ if (State != HITRETURN) { ! 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 */ /* * Get a character from a script file if there is one. --- 3283,3292 ---- */ if (State != HITRETURN) { ! 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 /* * Get a character from a script file if there is one. *************** *** 3306,3314 **** 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! */ closescript(); /* * When reading script file is interrupted, return an ESC to get --- 3305,3313 ---- 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! closescript(); /* * When reading script file is interrupted, return an ESC to get *************** *** 3327,3333 **** } } ! if (script_char < 0) /* did not get a character from script */ { /* * If we got an interrupt, skip all previously typed characters and --- 3326,3332 ---- } } ! if (script_char < 0) // did not get a character from script { /* * If we got an interrupt, skip all previously typed characters and *************** *** 3365,3378 **** 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 (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. */ if (len > 0 && ++typebuf.tb_change_cnt == 0) typebuf.tb_change_cnt = 1; --- 3364,3377 ---- 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 (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. if (len > 0 && ++typebuf.tb_change_cnt == 0) typebuf.tb_change_cnt = 1; *************** *** 3400,3414 **** 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. */ 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. */ else if (!gui.in_use && p[0] == CSI) { mch_memmove(p + 3, p + 1, (size_t)i); --- 3399,3413 ---- 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. 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. else if (!gui.in_use && p[0] == CSI) { mch_memmove(p + 3, p + 1, (size_t)i); *** ../vim-8.1.2379/src/gui.c 2019-11-30 22:47:42.647331219 +0100 --- src/gui.c 2019-12-01 22:09:14.289337616 +0100 *************** *** 10,16 **** #include "vim.h" ! /* Structure containing all the GUI information */ gui_T gui; #if !defined(FEAT_GUI_GTK) --- 10,16 ---- #include "vim.h" ! // Structure containing all the GUI information gui_T gui; #if !defined(FEAT_GUI_GTK) *************** *** 38,44 **** static int gui_read_child_pipe(int fd); ! /* Return values for gui_read_child_pipe */ enum { GUI_CHILD_IO_ERROR, GUI_CHILD_OK, --- 38,44 ---- static int gui_read_child_pipe(int fd); ! // Return values for gui_read_child_pipe enum { GUI_CHILD_IO_ERROR, GUI_CHILD_OK, *************** *** 48,55 **** 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. */ /* * The Athena scrollbars can move the thumb to after the end of the scrollbar, --- 48,55 ---- 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. /* * The Athena scrollbars can move the thumb to after the end of the scrollbar, *************** *** 78,86 **** old_term = vim_strsave(T_NAME); ! settmode(TMODE_COOK); /* stop RAW mode */ if (full_screen) ! cursor_on(); /* needed for ":gui" in .vimrc */ full_screen = FALSE; ++recursive; --- 78,86 ---- old_term = vim_strsave(T_NAME); ! settmode(TMODE_COOK); // stop RAW mode if (full_screen) ! cursor_on(); // needed for ":gui" in .vimrc full_screen = FALSE; ++recursive; *************** *** 125,154 **** #endif { #ifdef FEAT_GUI_GTK ! /* 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 */ { ! /* 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 */ #ifdef FEAT_TITLE ! set_title_defaults(); /* set 'title' and 'icon' again */ #endif #if defined(GUI_MAY_SPAWN) && defined(EXPERIMENTAL_GUI_CMD) if (msg) --- 125,153 ---- #endif { #ifdef FEAT_GUI_GTK ! // 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 { ! // 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 #ifdef FEAT_TITLE ! set_title_defaults(); // set 'title' and 'icon' again #endif #if defined(GUI_MAY_SPAWN) && defined(EXPERIMENTAL_GUI_CMD) if (msg) *************** *** 158,165 **** vim_free(old_term); ! /* 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); --- 157,164 ---- vim_free(old_term); ! // 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,208 **** set_vim_var_nr(VV_WINDOWID, (long)x11_window); # endif ! /* Display error messages in a dialog now. */ display_errors(); } #endif --- 201,207 ---- set_vim_var_nr(VV_WINDOWID, (long)x11_window); # endif ! // Display error messages in a dialog now. display_errors(); } #endif *************** *** 211,217 **** #ifdef GUI_MAY_FORK ! /* for waitpid() */ # if defined(HAVE_SYS_WAIT_H) || defined(HAVE_UNION_WAIT) # include # endif --- 210,216 ---- #ifdef GUI_MAY_FORK ! // for waitpid() # if defined(HAVE_SYS_WAIT_H) || defined(HAVE_UNION_WAIT) # include # endif *************** *** 231,268 **** static void gui_do_fork(void) { ! 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. */ pipe_error = (pipe(pipefd) < 0); pid = fork(); ! if (pid < 0) /* Fork error */ { emsg(_("E851: Failed to create a new process for the GUI")); return; } ! 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). */ if (!pipe_error) { ! /* 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. */ # ifdef __NeXT__ wait4(pid, &exit_status, 0, (struct rusage *)0); # else --- 230,267 ---- static void gui_do_fork(void) { ! 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. pipe_error = (pipe(pipefd) < 0); pid = fork(); ! if (pid < 0) // Fork error { emsg(_("E851: Failed to create a new process for the GUI")); return; } ! 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). if (!pipe_error) { ! // 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. # ifdef __NeXT__ wait4(pid, &exit_status, 0, (struct rusage *)0); # else *************** *** 275,288 **** { pipe_error = TRUE; } ! /* 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". */ if (newline_on_exit) mch_errmsg("\r\n"); --- 274,287 ---- { pipe_error = TRUE; } ! // 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". if (newline_on_exit) mch_errmsg("\r\n"); *************** *** 292,301 **** */ _exit(0); } ! /* Child */ #ifdef FEAT_GUI_GTK ! /* Call gtk_init_check() here after fork(). See gui_init_check(). */ if (gui_mch_init_check() != OK) getout_preserve_modified(1); #endif --- 291,300 ---- */ _exit(0); } ! // Child #ifdef FEAT_GUI_GTK ! // Call gtk_init_check() here after fork(). See gui_init_check(). if (gui_mch_init_check() != OK) getout_preserve_modified(1); #endif *************** *** 315,328 **** close(pipefd[0]); # if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION) ! /* Tell the session manager our new PID */ gui_mch_forked(); # endif ! /* Try to start the GUI */ gui_attempt_start(); ! /* Notify the parent */ if (!pipe_error) { if (gui.in_use) --- 314,327 ---- close(pipefd[0]); # if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION) ! // Tell the session manager our new PID gui_mch_forked(); # endif ! // Try to start the GUI gui_attempt_start(); ! // Notify the parent if (!pipe_error) { if (gui.in_use) *************** *** 332,338 **** close(pipefd[1]); } ! /* If we failed to start the GUI, exit now. */ if (!gui.in_use) getout_preserve_modified(1); } --- 331,337 ---- close(pipefd[1]); } ! // If we failed to start the GUI, exit now. if (!gui.in_use) getout_preserve_modified(1); } *************** *** 364,370 **** return GUI_CHILD_FAILED; } ! #endif /* GUI_MAY_FORK */ /* * Call this when vim starts up, whether or not the GUI is started --- 363,369 ---- return GUI_CHILD_FAILED; } ! #endif // GUI_MAY_FORK /* * Call this when vim starts up, whether or not the GUI is started *************** *** 372,379 **** 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_mch_prepare(argc, argv); } --- 371,378 ---- 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_mch_prepare(argc, argv); } *************** *** 397,403 **** gui.shell_created = FALSE; gui.dying = FALSE; ! gui.in_focus = TRUE; /* so the guicursor setting works */ gui.dragged_sb = SBAR_NONE; gui.dragged_wp = NULL; gui.pointer_hidden = FALSE; --- 396,402 ---- gui.shell_created = FALSE; gui.dying = FALSE; ! gui.in_focus = TRUE; // so the guicursor setting works gui.dragged_sb = SBAR_NONE; gui.dragged_wp = NULL; gui.pointer_hidden = FALSE; *************** *** 441,447 **** gui.menu_font = NOFONT; # endif # endif ! gui.menu_is_active = TRUE; /* default: include menu */ # ifndef FEAT_GUI_GTK gui.menu_height = MENU_DEFAULT_HEIGHT; gui.menu_width = 0; --- 440,446 ---- gui.menu_font = NOFONT; # endif # endif ! gui.menu_is_active = TRUE; // default: include menu # ifndef FEAT_GUI_GTK gui.menu_height = MENU_DEFAULT_HEIGHT; gui.menu_width = 0; *************** *** 499,505 **** clip_init(TRUE); ! /* If can't initialize, don't try doing the rest */ if (gui_init_check() == FAIL) { --recursive; --- 498,504 ---- clip_init(TRUE); ! // If can't initialize, don't try doing the rest if (gui_init_check() == FAIL) { --recursive; *************** *** 596,603 **** { stat_T s; ! /* if ".gvimrc" file is not owned by user, set 'secure' ! * mode */ if (mch_stat(GVIMRC_FILE, &s) || s.st_uid != getuid()) secure = p_secure; } --- 595,602 ---- { stat_T s; ! // 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,656 **** --recursive; } ! /* 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 */ if (gui_mch_init() == FAIL) goto error; ! /* 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); --- 637,655 ---- --recursive; } ! // 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 if (gui_mch_init() == FAIL) goto error; ! // 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,692 **** gui.num_rows = Rows; gui_reset_scroll_region(); ! /* Create initial scrollbars */ FOR_ALL_WINDOWS(wp) { gui_create_scrollbar(&wp->w_scrollbars[SBAR_LEFT], SBAR_LEFT, wp); --- 685,691 ---- gui.num_rows = Rows; gui_reset_scroll_region(); ! // Create initial scrollbars FOR_ALL_WINDOWS(wp) { gui_create_scrollbar(&wp->w_scrollbars[SBAR_LEFT], SBAR_LEFT, wp); *************** *** 701,710 **** sign_gui_started(); #endif ! /* Configure the desired menu and scrollbars */ gui_init_which_components(NULL); ! /* All components of the GUI have been created now */ gui.shell_created = TRUE; #ifdef FEAT_GUI_MSWIN --- 700,709 ---- sign_gui_started(); #endif ! // Configure the desired menu and scrollbars gui_init_which_components(NULL); ! // All components of the GUI have been created now gui.shell_created = TRUE; #ifdef FEAT_GUI_MSWIN *************** *** 723,730 **** # 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. */ gui_mch_compute_menu_height((Widget)0); #endif --- 722,729 ---- # 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. gui_mch_compute_menu_height((Widget)0); #endif *************** *** 739,754 **** #endif init_gui_options(); #ifdef FEAT_ARABIC ! /* 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. */ 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 (vim_strchr(p_go, GO_MENUS) == NULL) { --gui.starting; --- 738,753 ---- #endif init_gui_options(); #ifdef FEAT_ARABIC ! // 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. 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 (vim_strchr(p_go, GO_MENUS) == NULL) { --gui.starting; *************** *** 758,776 **** } # endif ! /* 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. */ win_new_shellsize(); #ifdef FEAT_BEVAL_GUI ! /* Always create the Balloon Evaluation area, but disable it when ! * 'ballooneval' is off. */ if (balloonEval != NULL) { # ifdef FEAT_VARTABS --- 757,775 ---- } # endif ! // 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. win_new_shellsize(); #ifdef FEAT_BEVAL_GUI ! // Always create the Balloon Evaluation area, but disable it when ! // 'ballooneval' is off. if (balloonEval != NULL) { # ifdef FEAT_VARTABS *************** *** 804,811 **** 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. */ if (p_ch != 1L) command_height(); --- 803,810 ---- 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. if (p_ch != 1L) command_height(); *************** *** 814,820 **** error2: #ifdef FEAT_GUI_X11 ! /* undo gui_mch_init() */ gui_mch_uninit(); #endif --- 813,819 ---- error2: #ifdef FEAT_GUI_X11 ! // undo gui_mch_init() gui_mch_uninit(); #endif *************** *** 827,834 **** void gui_exit(int rc) { ! /* 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); --- 826,833 ---- void gui_exit(int rc) { ! // 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,856 **** save_cmdmod = cmdmod; ! /* Only exit when there are no changed files */ exiting = TRUE; # ifdef FEAT_BROWSE cmdmod.browse = TRUE; --- 849,855 ---- save_cmdmod = cmdmod; ! // Only exit when there are no changed files exiting = TRUE; # ifdef FEAT_BROWSE cmdmod.browse = TRUE; *************** *** 858,871 **** # 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 (!check_changed_any(FALSE, FALSE)) getout(0); exiting = FALSE; cmdmod = save_cmdmod; ! gui_update_screen(); /* redraw, window may show changed buffer */ } #endif --- 857,870 ---- # 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 (!check_changed_any(FALSE, FALSE)) getout(0); exiting = FALSE; cmdmod = save_cmdmod; ! gui_update_screen(); // redraw, window may show changed buffer } #endif *************** *** 894,919 **** else { #ifdef FEAT_XFONTSET ! /* 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. */ (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! */ 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 ((p_guifontwide == NULL || *p_guifontwide == NUL) && strstr((char *)font_name, "10646") != NULL) set_guifontwide(font_name); --- 893,918 ---- else { #ifdef FEAT_XFONTSET ! // 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. (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! 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 ((p_guifontwide == NULL || *p_guifontwide == NUL) && strstr((char *)font_name, "10646") != NULL) set_guifontwide(font_name); *************** *** 939,945 **** if (ret == OK) { #ifndef FEAT_GUI_GTK ! /* Set normal font as current font */ # ifdef FEAT_XFONTSET if (gui.fontset != NOFONTSET) gui_mch_set_fontset(gui.fontset); --- 938,944 ---- if (ret == OK) { #ifndef FEAT_GUI_GTK ! // Set normal font as current font # ifdef FEAT_XFONTSET if (gui.fontset != NOFONTSET) gui_mch_set_fontset(gui.fontset); *************** *** 961,967 **** set_guifontwide(char_u *name) { int i = 0; ! char_u wide_name[FONTLEN + 10]; /* room for 2 * width and '*' */ char_u *wp = NULL; char_u *p; GuiFont font; --- 960,966 ---- set_guifontwide(char_u *name) { int i = 0; ! char_u wide_name[FONTLEN + 10]; // room for 2 * width and '*' char_u *wp = NULL; char_u *p; GuiFont font; *************** *** 973,990 **** if (*p == '-') { ++i; ! if (i == 6) /* font type: change "--" to "-*-" */ { if (p[1] == '-') *wp++ = '*'; } ! else if (i == 12) /* found the width */ { ++p; i = getdigits(&p); if (i != 0) { ! /* Double the width specification. */ sprintf((char *)wp, "%d%s", i * 2, p); font = gui_mch_get_font(wide_name, FALSE); if (font != NOFONT) --- 972,989 ---- if (*p == '-') { ++i; ! if (i == 6) // font type: change "--" to "-*-" { if (p[1] == '-') *wp++ = '*'; } ! else if (i == 12) // found the width { ++p; i = getdigits(&p); if (i != 0) { ! // Double the width specification. sprintf((char *)wp, "%d%s", i * 2, p); font = gui_mch_get_font(wide_name, FALSE); if (font != NOFONT) *************** *** 1000,1006 **** } } } ! #endif /* !FEAT_GUI_GTK */ /* * Get the font for 'guifontwide'. --- 999,1005 ---- } } } ! #endif // !FEAT_GUI_GTK /* * Get the font for 'guifontwide'. *************** *** 1013,1026 **** 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 (p_guifontwide != NULL && *p_guifontwide != NUL) { for (p = p_guifontwide; *p != NUL; ) { ! /* 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) --- 1012,1025 ---- 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 (p_guifontwide != NULL && *p_guifontwide != NUL) { for (p = p_guifontwide; *p != NUL; ) { ! // 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,1038 **** gui_mch_free_font(gui.wide_font); #ifdef FEAT_GUI_GTK ! /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */ if (font != NOFONT && gui.norm_font != NOFONT && pango_font_description_equal(font, gui.norm_font)) { --- 1031,1037 ---- gui_mch_free_font(gui.wide_font); #ifdef FEAT_GUI_GTK ! // 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,1088 **** */ void gui_update_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; --- 1080,1087 ---- */ void gui_update_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,1105 **** guicolor_T shape_fg = INVALCOLOR; guicolor_T shape_bg = INVALCOLOR; #endif ! 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. */ if (!can_update_cursor || screen_Columns != gui.num_cols || screen_Rows != gui.num_rows) return; --- 1092,1104 ---- guicolor_T shape_fg = INVALCOLOR; guicolor_T shape_bg = INVALCOLOR; #endif ! 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. if (!can_update_cursor || screen_Columns != gui.num_cols || screen_Rows != gui.num_rows) return; *************** *** 1118,1132 **** gui.cursor_row = gui.row; gui.cursor_col = gui.col; ! /* 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 */ 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) */ if (gui.row >= screen_Rows || gui.col >= screen_Columns) return; --- 1117,1131 ---- gui.cursor_row = gui.row; gui.cursor_col = gui.col; ! // 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 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) if (gui.row >= screen_Rows || gui.col >= screen_Columns) return; *************** *** 1147,1153 **** else id = shape->id; ! /* get the colors and attributes for the cursor. Default is inverted */ cfg = INVALCOLOR; cbg = INVALCOLOR; cattr = HL_INVERSE; --- 1146,1152 ---- else id = shape->id; ! // get the colors and attributes for the cursor. Default is inverted cfg = INVALCOLOR; cbg = INVALCOLOR; cattr = HL_INVERSE; *************** *** 1292,1307 **** if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col, LineOffset[gui.row] + screen_Columns) > 1) { ! /* 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(). */ col_off = TRUE; ++gui.col; } --- 1291,1306 ---- if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col, LineOffset[gui.row] + screen_Columns) > 1) { ! // 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(). col_off = TRUE; ++gui.col; } *************** *** 1313,1319 **** --gui.col; #endif ! #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, --- 1312,1318 ---- --gui.col; #endif ! #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,1353 **** int text_area_width; int text_area_height; ! /* avoid that moving components around generates events */ ++hold_gui_events; text_area_x = 0; --- 1346,1352 ---- int text_area_width; int text_area_height; ! // avoid that moving components around generates events ++hold_gui_events; text_area_x = 0; *************** *** 1436,1444 **** 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) */ #else # ifdef FEAT_MENU if (gui.menu_is_active) --- 1435,1443 ---- 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) #else # ifdef FEAT_MENU if (gui.menu_is_active) *************** *** 1477,1483 **** { static int busy = FALSE; ! if (!gui.shell_created) /* ignore when still initializing */ return; /* --- 1476,1482 ---- { static int busy = FALSE; ! if (!gui.shell_created) // ignore when still initializing return; /* *************** *** 1496,1502 **** new_pixel_height = 0; busy = TRUE; ! /* Flush pending output before redrawing */ out_flush(); gui.num_cols = (pixel_width - gui_get_base_width()) / gui.char_width; --- 1495,1501 ---- new_pixel_height = 0; busy = TRUE; ! // Flush pending output before redrawing out_flush(); gui.num_cols = (pixel_width - gui_get_base_width()) / gui.char_width; *************** *** 1512,1519 **** 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. */ if (gui.num_rows != screen_Rows || gui.num_cols != screen_Columns || gui.num_rows != Rows || gui.num_cols != Columns) shell_resized(); --- 1511,1518 ---- 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. if (gui.num_rows != screen_Rows || gui.num_cols != screen_Columns || gui.num_rows != Rows || gui.num_cols != Columns) shell_resized(); *************** *** 1526,1534 **** 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. */ if (new_pixel_height) { if (pixel_width == new_pixel_width && pixel_height == new_pixel_height) --- 1525,1533 ---- 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. if (new_pixel_height) { if (pixel_width == new_pixel_width && pixel_height == new_pixel_height) *************** *** 1552,1559 **** 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 */ gui_resize_shell(new_pixel_width, new_pixel_height); } --- 1551,1558 ---- 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 gui_resize_shell(new_pixel_width, new_pixel_height); } *************** *** 1576,1582 **** gui_set_shellsize( int mustset UNUSED, int fit_to_display, ! int direction) /* RESIZE_HOR, RESIZE_VER */ { int base_width; int base_height; --- 1575,1581 ---- gui_set_shellsize( int mustset UNUSED, int fit_to_display, ! int direction) // RESIZE_HOR, RESIZE_VER { int base_width; int base_height; *************** *** 1596,1603 **** 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 (!mustset && (vim_strchr(p_go, GO_KEEPWINSIZE) != NULL || gui_mch_maximized())) { --- 1595,1602 ---- 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 (!mustset && (vim_strchr(p_go, GO_KEEPWINSIZE) != NULL || gui_mch_maximized())) { *************** *** 1609,1615 **** base_width = gui_get_base_width(); base_height = gui_get_base_height(); if (fit_to_display) ! /* Remember the original window position. */ (void)gui_mch_get_winpos(&x, &y); width = Columns * gui.char_width + base_width; --- 1608,1614 ---- base_width = gui_get_base_width(); base_height = gui_get_base_height(); if (fit_to_display) ! // Remember the original window position. (void)gui_mch_get_winpos(&x, &y); width = Columns * gui.char_width + base_width; *************** *** 1640,1646 **** #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 */ un_maximize = FALSE; #endif } --- 1639,1645 ---- #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 un_maximize = FALSE; #endif } *************** *** 1655,1662 **** #ifdef FEAT_GUI_GTK if (un_maximize) { ! /* 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) --- 1654,1661 ---- #ifdef FEAT_GUI_GTK if (un_maximize) { ! // 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,1678 **** 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). */ 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); --- 1669,1677 ---- 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). 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,1724 **** static void gui_start_highlight(int mask) { ! if (mask > HL_ALL) /* highlight code */ gui.highlight_mask = mask; ! else /* mask */ gui.highlight_mask |= mask; } void gui_stop_highlight(int mask) { ! if (mask > HL_ALL) /* highlight code */ gui.highlight_mask = HL_NORMAL; ! else /* mask */ gui.highlight_mask &= ~mask; } --- 1706,1723 ---- static void gui_start_highlight(int mask) { ! if (mask > HL_ALL) // highlight code gui.highlight_mask = mask; ! else // mask gui.highlight_mask |= mask; } void gui_stop_highlight(int mask) { ! if (mask > HL_ALL) // highlight code gui.highlight_mask = HL_NORMAL; ! else // mask gui.highlight_mask &= ~mask; } *************** *** 1733,1744 **** int row2, int col2) { ! /* Clear the selection if we are about to write over it */ clip_may_clear_selection(row1, row2); gui_mch_clear_block(row1, col1, row2, col2); ! /* Invalidate cursor if it was in this block */ if ( gui.cursor_row >= row1 && gui.cursor_row <= row2 && gui.cursor_col >= col1 && gui.cursor_col <= col2) gui.cursor_is_valid = FALSE; --- 1732,1743 ---- int row2, int col2) { ! // Clear the selection if we are about to write over it clip_may_clear_selection(row1, row2); gui_mch_clear_block(row1, col1, row2, col2); ! // Invalidate cursor if it was in this block if ( gui.cursor_row >= row1 && gui.cursor_row <= row2 && gui.cursor_col >= col1 && gui.cursor_col <= col2) gui.cursor_is_valid = FALSE; *************** *** 1761,1771 **** { char_u *p; int arg1 = 0, arg2 = 0; ! int force_cursor = FALSE; /* force cursor update */ int force_scrollbar = FALSE; static win_T *old_curwin = NULL; ! /* #define DEBUG_GUI_WRITE */ #ifdef DEBUG_GUI_WRITE { int i; --- 1760,1770 ---- { char_u *p; int arg1 = 0, arg2 = 0; ! int force_cursor = FALSE; // force cursor update int force_scrollbar = FALSE; static win_T *old_curwin = NULL; ! // #define DEBUG_GUI_WRITE #ifdef DEBUG_GUI_WRITE { int i; *************** *** 1810,1828 **** } switch (*p) { ! case 'C': /* Clear screen */ clip_scroll_selection(9999); gui_mch_clear_all(); gui.cursor_is_valid = FALSE; force_scrollbar = TRUE; break; ! case 'M': /* Move cursor */ gui_set_cursor(arg1, arg2); break; ! case 's': /* force cursor (shape) update */ force_cursor = TRUE; break; ! case 'R': /* Set scroll region */ if (arg1 < arg2) { gui.scroll_region_top = arg1; --- 1809,1827 ---- } switch (*p) { ! case 'C': // Clear screen clip_scroll_selection(9999); gui_mch_clear_all(); gui.cursor_is_valid = FALSE; force_scrollbar = TRUE; break; ! case 'M': // Move cursor gui_set_cursor(arg1, arg2); break; ! case 's': // force cursor (shape) update force_cursor = TRUE; break; ! case 'R': // Set scroll region if (arg1 < arg2) { gui.scroll_region_top = arg1; *************** *** 1834,1840 **** gui.scroll_region_bot = arg1; } break; ! case 'V': /* Set vertical scroll region */ if (arg1 < arg2) { gui.scroll_region_left = arg1; --- 1833,1839 ---- gui.scroll_region_bot = arg1; } break; ! case 'V': // Set vertical scroll region if (arg1 < arg2) { gui.scroll_region_left = arg1; *************** *** 1846,1878 **** gui.scroll_region_right = arg1; } break; ! case 'd': /* Delete line */ gui_delete_lines(gui.row, 1); break; ! case 'D': /* Delete lines */ gui_delete_lines(gui.row, arg1); break; ! case 'i': /* Insert line */ gui_insert_lines(gui.row, 1); break; ! case 'I': /* Insert lines */ gui_insert_lines(gui.row, arg1); break; ! case '$': /* Clear to end-of-line */ gui_clear_block(gui.row, gui.col, gui.row, (int)Columns - 1); break; ! case 'h': /* Turn on highlighting */ gui_start_highlight(arg1); break; ! case 'H': /* Turn off highlighting */ gui_stop_highlight(arg1); break; ! case 'f': /* flash the window (visual bell) */ gui_mch_flash(arg1 == 0 ? 20 : arg1); break; default: ! p = s + 1; /* Skip the ESC */ break; } len -= (int)(++p - s); --- 1845,1877 ---- gui.scroll_region_right = arg1; } break; ! case 'd': // Delete line gui_delete_lines(gui.row, 1); break; ! case 'D': // Delete lines gui_delete_lines(gui.row, arg1); break; ! case 'i': // Insert line gui_insert_lines(gui.row, 1); break; ! case 'I': // Insert lines gui_insert_lines(gui.row, arg1); break; ! case '$': // Clear to end-of-line gui_clear_block(gui.row, gui.col, gui.row, (int)Columns - 1); break; ! case 'h': // Turn on highlighting gui_start_highlight(arg1); break; ! case 'H': // Turn off highlighting gui_stop_highlight(arg1); break; ! case 'f': // flash the window (visual bell) gui_mch_flash(arg1 == 0 ? 20 : arg1); break; default: ! p = s + 1; // Skip the ESC break; } len -= (int)(++p - s); *************** *** 1880,1888 **** } else if ( #ifdef EBCDIC ! CtrlChar(s[0]) != 0 /* Ctrl character */ #else ! s[0] < 0x20 /* Ctrl character */ #endif #ifdef FEAT_SIGN_ICONS && s[0] != SIGN_BYTE --- 1879,1887 ---- } else if ( #ifdef EBCDIC ! CtrlChar(s[0]) != 0 // Ctrl character #else ! s[0] < 0x20 // Ctrl character #endif #ifdef FEAT_SIGN_ICONS && s[0] != SIGN_BYTE *************** *** 1892,1898 **** #endif ) { ! if (s[0] == '\n') /* NL */ { gui.col = 0; if (gui.row < gui.scroll_region_bot) --- 1891,1897 ---- #endif ) { ! if (s[0] == '\n') // NL { gui.col = 0; if (gui.row < gui.scroll_region_bot) *************** *** 1900,1925 **** else gui_delete_lines(gui.scroll_region_top, 1); } ! else if (s[0] == '\r') /* CR */ { gui.col = 0; } ! else if (s[0] == '\b') /* Backspace */ { if (gui.col) --gui.col; } ! else if (s[0] == Ctrl_L) /* cursor-right */ { ++gui.col; } ! else if (s[0] == Ctrl_G) /* Beep */ { gui_mch_beep(); } ! /* Other Ctrl character: shouldn't happen! */ ! --len; /* Skip this char */ ++s; } else --- 1899,1924 ---- else gui_delete_lines(gui.scroll_region_top, 1); } ! else if (s[0] == '\r') // CR { gui.col = 0; } ! else if (s[0] == '\b') // Backspace { if (gui.col) --gui.col; } ! else if (s[0] == Ctrl_L) // cursor-right { ++gui.col; } ! else if (s[0] == Ctrl_G) // Beep { gui_mch_beep(); } ! // Other Ctrl character: shouldn't happen! ! --len; // Skip this char ++s; } else *************** *** 1947,1966 **** } } ! /* Postponed update of the cursor (won't work if "can_update_cursor" isn't ! * set). */ if (force_cursor) gui_update_cursor(TRUE, TRUE); ! /* When switching to another window the dragging must have stopped. ! * Required for GTK, dragged_sb isn't reset. */ if (old_curwin != curwin) gui.dragged_sb = SBAR_NONE; ! /* Update the scrollbars after clearing the screen or when switched ! * to another window. ! * Update the horizontal scrollbar always, it's difficult to check all ! * situations where it might change. */ if (force_scrollbar || old_curwin != curwin) gui_update_scrollbars(force_scrollbar); else --- 1946,1965 ---- } } ! // Postponed update of the cursor (won't work if "can_update_cursor" isn't ! // set). if (force_cursor) gui_update_cursor(TRUE, TRUE); ! // When switching to another window the dragging must have stopped. ! // Required for GTK, dragged_sb isn't reset. if (old_curwin != curwin) gui.dragged_sb = SBAR_NONE; ! // Update the scrollbars after clearing the screen or when switched ! // to another window. ! // Update the horizontal scrollbar always, it's difficult to check all ! // situations where it might change. if (force_scrollbar || old_curwin != curwin) gui_update_scrollbars(force_scrollbar); else *************** *** 1975,1981 **** gui.dragged_sb = SBAR_NONE; #endif ! gui_may_flush(); /* In case vim decides to take a nap */ } /* --- 1974,1980 ---- gui.dragged_sb = SBAR_NONE; #endif ! gui_may_flush(); // In case vim decides to take a nap } /* *************** *** 1988,1994 **** { if (gui.in_use) { ! /* Undraw the cursor now, we probably can't do it after the change. */ if (undraw) gui_undraw_cursor(); can_update_cursor = FALSE; --- 1987,1993 ---- { if (gui.in_use) { ! // Undraw the cursor now, we probably can't do it after the change. if (undraw) gui_undraw_cursor(); can_update_cursor = FALSE; *************** *** 1999,2006 **** gui_can_update_cursor(void) { can_update_cursor = TRUE; ! /* No need to update the cursor right now, there is always more output ! * after scrolling. */ } /* --- 1998,2005 ---- gui_can_update_cursor(void) { can_update_cursor = TRUE; ! // No need to update the cursor right now, there is always more output ! // after scrolling. } /* *************** *** 2047,2053 **** { if (has_mbyte) { ! /* Find out how many chars fit in the current line. */ cells = 0; for (this_len = 0; this_len < len; ) { --- 2046,2052 ---- { if (has_mbyte) { ! // Find out how many chars fit in the current line. cells = 0; for (this_len = 0; this_len < len; ) { *************** *** 2057,2063 **** this_len += (*mb_ptr2len)(s + this_len); } if (this_len > len) ! this_len = len; /* don't include following composing char */ } else if (gui.col + len > Columns) --- 2056,2062 ---- this_len += (*mb_ptr2len)(s + this_len); } if (this_len > len) ! this_len = len; // don't include following composing char } else if (gui.col + len > Columns) *************** *** 2069,2079 **** 0, (guicolor_T)0, (guicolor_T)0, 0); s += this_len; len -= this_len; ! /* fill up for a double-width char that doesn't fit. */ if (len > 0 && gui.col < Columns) (void)gui_outstr_nowrap((char_u *)" ", 1, 0, (guicolor_T)0, (guicolor_T)0, 0); ! /* The cursor may wrap to the next line. */ if (gui.col >= Columns) { gui.col = 0; --- 2068,2078 ---- 0, (guicolor_T)0, (guicolor_T)0, 0); s += this_len; len -= this_len; ! // fill up for a double-width char that doesn't fit. if (len > 0 && gui.col < Columns) (void)gui_outstr_nowrap((char_u *)" ", 1, 0, (guicolor_T)0, (guicolor_T)0, 0); ! // The cursor may wrap to the next line. if (gui.col >= Columns) { gui.col = 0; *************** *** 2089,2108 **** */ static int gui_screenchar( ! int off, /* Offset from start of screen */ int flags, ! guicolor_T fg, /* colors for cursor */ ! guicolor_T bg, /* colors for cursor */ ! int back) /* backup this many chars when using bold trick */ { char_u buf[MB_MAXBYTES + 1]; ! /* Don't draw right halve of a double-width UTF-8 char. "cannot happen" */ if (enc_utf8 && ScreenLines[off] == 0) return OK; if (enc_utf8 && ScreenLinesUC[off] != 0) ! /* Draw UTF-8 multi-byte character. */ return gui_outstr_nowrap(buf, utfc_char2bytes(off, buf), flags, fg, bg, back); --- 2088,2107 ---- */ static int gui_screenchar( ! int off, // Offset from start of screen int flags, ! guicolor_T fg, // colors for cursor ! guicolor_T bg, // colors for cursor ! int back) // backup this many chars when using bold trick { char_u buf[MB_MAXBYTES + 1]; ! // Don't draw right halve of a double-width UTF-8 char. "cannot happen" if (enc_utf8 && ScreenLines[off] == 0) return OK; if (enc_utf8 && ScreenLinesUC[off] != 0) ! // Draw UTF-8 multi-byte character. return gui_outstr_nowrap(buf, utfc_char2bytes(off, buf), flags, fg, bg, back); *************** *** 2113,2119 **** return gui_outstr_nowrap(buf, 2, flags, fg, bg, back); } ! /* Draw non-multi-byte character or DBCS character. */ return gui_outstr_nowrap(ScreenLines + off, enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1, flags, fg, bg, back); --- 2112,2118 ---- return gui_outstr_nowrap(buf, 2, flags, fg, bg, back); } ! // Draw non-multi-byte character or DBCS character. return gui_outstr_nowrap(ScreenLines + off, enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1, flags, fg, bg, back); *************** *** 2127,2157 **** */ static int gui_screenstr( ! int off, /* Offset from start of screen */ ! int len, /* string length in screen cells */ int flags, ! guicolor_T fg, /* colors for cursor */ ! guicolor_T bg, /* colors for cursor */ ! int back) /* backup this many chars when using bold trick */ { char_u *buf; int outlen = 0; int i; int retval; ! if (len <= 0) /* "cannot happen"? */ return OK; if (enc_utf8) { buf = alloc(len * MB_MAXBYTES + 1); if (buf == NULL) ! return OK; /* not much we could do here... */ for (i = off; i < off + len; ++i) { if (ScreenLines[i] == 0) ! continue; /* skip second half of double-width char */ if (ScreenLinesUC[i] == 0) buf[outlen++] = ScreenLines[i]; --- 2126,2156 ---- */ static int gui_screenstr( ! int off, // Offset from start of screen ! int len, // string length in screen cells int flags, ! guicolor_T fg, // colors for cursor ! guicolor_T bg, // colors for cursor ! int back) // backup this many chars when using bold trick { char_u *buf; int outlen = 0; int i; int retval; ! if (len <= 0) // "cannot happen"? return OK; if (enc_utf8) { buf = alloc(len * MB_MAXBYTES + 1); if (buf == NULL) ! return OK; // not much we could do here... for (i = off; i < off + len; ++i) { if (ScreenLines[i] == 0) ! continue; // skip second half of double-width char if (ScreenLinesUC[i] == 0) buf[outlen++] = ScreenLines[i]; *************** *** 2159,2165 **** outlen += utfc_char2bytes(i, buf + outlen); } ! buf[outlen] = NUL; /* only to aid debugging */ retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back); vim_free(buf); --- 2158,2164 ---- outlen += utfc_char2bytes(i, buf + outlen); } ! buf[outlen] = NUL; // only to aid debugging retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back); vim_free(buf); *************** *** 2169,2188 **** { buf = alloc(len * 2 + 1); if (buf == NULL) ! return OK; /* not much we could do here... */ for (i = off; i < off + len; ++i) { buf[outlen++] = ScreenLines[i]; ! /* handle double-byte single-width char */ if (ScreenLines[i] == 0x8e) buf[outlen++] = ScreenLines2[i]; else if (MB_BYTE2LEN(ScreenLines[i]) == 2) buf[outlen++] = ScreenLines[++i]; } ! buf[outlen] = NUL; /* only to aid debugging */ retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back); vim_free(buf); --- 2168,2187 ---- { buf = alloc(len * 2 + 1); if (buf == NULL) ! return OK; // not much we could do here... for (i = off; i < off + len; ++i) { buf[outlen++] = ScreenLines[i]; ! // handle double-byte single-width char if (ScreenLines[i] == 0x8e) buf[outlen++] = ScreenLines2[i]; else if (MB_BYTE2LEN(ScreenLines[i]) == 2) buf[outlen++] = ScreenLines[++i]; } ! buf[outlen] = NUL; // only to aid debugging retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back); vim_free(buf); *************** *** 2194,2200 **** flags, fg, bg, back); } } ! #endif /* FEAT_GUI_GTK */ /* * Output the given string at the current cursor position. If the string is --- 2193,2199 ---- flags, fg, bg, back); } } ! #endif // FEAT_GUI_GTK /* * Output the given string at the current cursor position. If the string is *************** *** 2214,2222 **** char_u *s, int len, int flags, ! guicolor_T fg, /* colors for cursor */ ! guicolor_T bg, /* colors for cursor */ ! int back) /* backup this many chars when using bold trick */ { long_u highlight_mask; long_u hl_mask_todo; --- 2213,2221 ---- char_u *s, int len, int flags, ! guicolor_T fg, // colors for cursor ! guicolor_T bg, // colors for cursor ! int back) // backup this many chars when using bold trick { long_u highlight_mask; long_u hl_mask_todo; *************** *** 2258,2264 **** if (*s == MULTISIGN_BYTE) multi_sign = TRUE; # endif ! /* draw spaces instead */ if (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u' && (curwin->w_p_nu || curwin->w_p_rnu)) { --- 2257,2263 ---- if (*s == MULTISIGN_BYTE) multi_sign = TRUE; # endif ! // draw spaces instead if (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u' && (curwin->w_p_nu || curwin->w_p_rnu)) { *************** *** 2283,2289 **** if (gui.highlight_mask > HL_ALL) { aep = syn_gui_attr2entry(gui.highlight_mask); ! if (aep == NULL) /* highlighting not set */ highlight_mask = 0; else highlight_mask = aep->ae_attr; --- 2282,2288 ---- if (gui.highlight_mask > HL_ALL) { aep = syn_gui_attr2entry(gui.highlight_mask); ! if (aep == NULL) // highlighting not set highlight_mask = 0; else highlight_mask = aep->ae_attr; *************** *** 2293,2299 **** hl_mask_todo = highlight_mask; #if !defined(FEAT_GUI_GTK) ! /* Set the font */ if (aep != NULL && aep->ae_u.gui.font != NOFONT) font = aep->ae_u.gui.font; # ifdef FEAT_XFONTSET --- 2292,2298 ---- hl_mask_todo = highlight_mask; #if !defined(FEAT_GUI_GTK) ! // Set the font if (aep != NULL && aep->ae_u.gui.font != NOFONT) font = aep->ae_u.gui.font; # ifdef FEAT_XFONTSET *************** *** 2354,2360 **** draw_flags = 0; ! /* Set the color */ bg_color = gui.back_pixel; if ((flags & GUI_MON_IS_CURSOR) && gui.in_focus) { --- 2353,2359 ---- draw_flags = 0; ! // Set the color bg_color = gui.back_pixel; if ((flags & GUI_MON_IS_CURSOR) && gui.in_focus) { *************** *** 2401,2412 **** } gui_mch_set_sp_color(sp_color); ! /* Clear the selection if we are about to write over it */ if (!(flags & GUI_MON_NOCLEAR)) clip_may_clear_selection(gui.row, gui.row); ! /* If there's no bold font, then fake it */ if (hl_mask_todo & (HL_BOLD | HL_STANDOUT)) draw_flags |= DRAW_BOLD; --- 2400,2411 ---- } gui_mch_set_sp_color(sp_color); ! // Clear the selection if we are about to write over it if (!(flags & GUI_MON_NOCLEAR)) clip_may_clear_selection(gui.row, gui.row); ! // If there's no bold font, then fake it if (hl_mask_todo & (HL_BOLD | HL_STANDOUT)) draw_flags |= DRAW_BOLD; *************** *** 2419,2447 **** return FAIL; #if defined(FEAT_GUI_GTK) ! /* If there's no italic font, then fake it. ! * For GTK2, we don't need a different font for italic style. */ if (hl_mask_todo & HL_ITALIC) draw_flags |= DRAW_ITALIC; ! /* Do we underline the text? */ if (hl_mask_todo & HL_UNDERLINE) draw_flags |= DRAW_UNDERL; #else ! /* Do we underline the text? */ if ((hl_mask_todo & HL_UNDERLINE) || (hl_mask_todo & HL_ITALIC)) draw_flags |= DRAW_UNDERL; #endif ! /* Do we undercurl the text? */ if (hl_mask_todo & HL_UNDERCURL) draw_flags |= DRAW_UNDERC; ! /* Do we strikethrough the text? */ if (hl_mask_todo & HL_STRIKETHROUGH) draw_flags |= DRAW_STRIKE; ! /* Do we draw transparently? */ if (flags & GUI_MON_TRS_CURSOR) draw_flags |= DRAW_TRANSP; --- 2418,2446 ---- return FAIL; #if defined(FEAT_GUI_GTK) ! // If there's no italic font, then fake it. ! // For GTK2, we don't need a different font for italic style. if (hl_mask_todo & HL_ITALIC) draw_flags |= DRAW_ITALIC; ! // Do we underline the text? if (hl_mask_todo & HL_UNDERLINE) draw_flags |= DRAW_UNDERL; #else ! // Do we underline the text? if ((hl_mask_todo & HL_UNDERLINE) || (hl_mask_todo & HL_ITALIC)) draw_flags |= DRAW_UNDERL; #endif ! // Do we undercurl the text? if (hl_mask_todo & HL_UNDERCURL) draw_flags |= DRAW_UNDERC; ! // Do we strikethrough the text? if (hl_mask_todo & HL_STRIKETHROUGH) draw_flags |= DRAW_STRIKE; ! // Do we draw transparently? if (flags & GUI_MON_TRS_CURSOR) draw_flags |= DRAW_TRANSP; *************** *** 2449,2479 **** * Draw the text. */ #ifdef FEAT_GUI_GTK ! /* The value returned is the length in display cells */ len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags); #else if (enc_utf8) { ! int start; /* index of bytes to be drawn */ ! int cells; /* cellwidth of bytes to be drawn */ ! int thislen; /* length of bytes to be drawn */ ! int cn; /* cellwidth of current char */ ! int i; /* index of current char */ ! int c; /* current char value */ ! int cl; /* byte length of current char */ ! int comping; /* current char is composing */ ! int scol = col; /* screen column */ ! int curr_wide = FALSE; /* use 'guifontwide' */ int prev_wide = FALSE; int wide_changed; # ifdef MSWIN ! int sep_comp = FALSE; /* Don't separate composing chars. */ # else ! int sep_comp = TRUE; /* Separate composing chars. */ # endif ! /* Break the string at a composing character, it has to be drawn on ! * top of the previous character. */ start = 0; cells = 0; for (i = 0; i < len; i += cl) --- 2448,2478 ---- * Draw the text. */ #ifdef FEAT_GUI_GTK ! // The value returned is the length in display cells len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags); #else if (enc_utf8) { ! int start; // index of bytes to be drawn ! int cells; // cellwidth of bytes to be drawn ! int thislen; // length of bytes to be drawn ! int cn; // cellwidth of current char ! int i; // index of current char ! int c; // current char value ! int cl; // byte length of current char ! int comping; // current char is composing ! int scol = col; // screen column ! int curr_wide = FALSE; // use 'guifontwide' int prev_wide = FALSE; int wide_changed; # ifdef MSWIN ! int sep_comp = FALSE; // Don't separate composing chars. # else ! int sep_comp = TRUE; // Separate composing chars. # endif ! // Break the string at a composing character, it has to be drawn on ! // top of the previous character. start = 0; cells = 0; for (i = 0; i < len; i += cl) *************** *** 2481,2487 **** c = utf_ptr2char(s + i); cn = utf_char2cells(c); comping = utf_iscomposing(c); ! if (!comping) /* count cells from non-composing chars */ cells += cn; if (!comping || sep_comp) { --- 2480,2486 ---- c = utf_ptr2char(s + i); cn = utf_char2cells(c); comping = utf_iscomposing(c); ! if (!comping) // count cells from non-composing chars cells += cn; if (!comping || sep_comp) { *************** *** 2495,2514 **** curr_wide = FALSE; } cl = utf_ptr2len(s + i); ! if (cl == 0) /* hit end of string */ ! len = i + cl; /* len must be wrong "cannot happen" */ wide_changed = curr_wide != prev_wide; ! /* Print the string so far if it's the last character or there is ! * a composing character. */ if (i + cl >= len || (comping && sep_comp && i > start) || wide_changed # if defined(FEAT_GUI_X11) || (cn > 1 # ifdef FEAT_XFONTSET ! /* No fontset: At least draw char after wide char at ! * right position. */ && fontset == NOFONTSET # endif ) --- 2494,2513 ---- curr_wide = FALSE; } cl = utf_ptr2len(s + i); ! if (cl == 0) // hit end of string ! len = i + cl; // len must be wrong "cannot happen" wide_changed = curr_wide != prev_wide; ! // Print the string so far if it's the last character or there is ! // a composing character. if (i + cl >= len || (comping && sep_comp && i > start) || wide_changed # if defined(FEAT_GUI_X11) || (cn > 1 # ifdef FEAT_XFONTSET ! // No fontset: At least draw char after wide char at ! // right position. && fontset == NOFONTSET # endif ) *************** *** 2531,2538 **** } scol += cells; cells = 0; ! /* Adjust to not draw a character which width is changed ! * against with last one. */ if (wide_changed && !(comping && sep_comp)) { scol -= cn; --- 2530,2537 ---- } scol += cells; cells = 0; ! // Adjust to not draw a character which width is changed ! // against with last one. if (wide_changed && !(comping && sep_comp)) { scol -= cn; *************** *** 2540,2547 **** } # if defined(FEAT_GUI_X11) ! /* No fontset: draw a space to fill the gap after a wide char ! * */ if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0 # ifdef FEAT_XFONTSET && fontset == NOFONTSET --- 2539,2546 ---- } # if defined(FEAT_GUI_X11) ! // No fontset: draw a space to fill the gap after a wide char ! // if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0 # ifdef FEAT_XFONTSET && fontset == NOFONTSET *************** *** 2551,2561 **** 1, draw_flags); # endif } ! /* Draw a composing char on top of the previous char. */ if (comping && sep_comp) { # if defined(__APPLE_CC__) && TARGET_API_MAC_CARBON ! /* Carbon ATSUI autodraws composing char over previous char */ gui_mch_draw_string(gui.row, scol, s + i, cl, draw_flags | DRAW_TRANSP); # else --- 2550,2560 ---- 1, draw_flags); # endif } ! // Draw a composing char on top of the previous char. if (comping && sep_comp) { # if defined(__APPLE_CC__) && TARGET_API_MAC_CARBON ! // Carbon ATSUI autodraws composing char over previous char gui_mch_draw_string(gui.row, scol, s + i, cl, draw_flags | DRAW_TRANSP); # else *************** *** 2566,2572 **** } prev_wide = curr_wide; } ! /* The stuff below assumes "len" is the length in screen columns. */ len = scol - col; } else --- 2565,2571 ---- } prev_wide = curr_wide; } ! // The stuff below assumes "len" is the length in screen columns. len = scol - col; } else *************** *** 2574,2596 **** gui_mch_draw_string(gui.row, col, s, len, draw_flags); if (enc_dbcs == DBCS_JPNU) { ! /* Get the length in display cells, this can be different from the ! * number of bytes for "euc-jp". */ len = mb_string2cells(s, len); } } ! #endif /* !FEAT_GUI_GTK */ if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) gui.col = col + len; ! /* May need to invert it when it's part of the selection. */ if (flags & GUI_MON_NOCLEAR) clip_may_redraw_selection(gui.row, col, len); if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) { ! /* Invalidate the old physical cursor position if we wrote over it */ if (gui.cursor_row == gui.row && gui.cursor_col >= col && gui.cursor_col < col + len) --- 2573,2595 ---- gui_mch_draw_string(gui.row, col, s, len, draw_flags); if (enc_dbcs == DBCS_JPNU) { ! // Get the length in display cells, this can be different from the ! // number of bytes for "euc-jp". len = mb_string2cells(s, len); } } ! #endif // !FEAT_GUI_GTK if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) gui.col = col + len; ! // May need to invert it when it's part of the selection. if (flags & GUI_MON_NOCLEAR) clip_may_redraw_selection(gui.row, col, len); if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) { ! // Invalidate the old physical cursor position if we wrote over it if (gui.cursor_row == gui.row && gui.cursor_col >= col && gui.cursor_col < col + len) *************** *** 2599,2605 **** #ifdef FEAT_SIGN_ICONS if (draw_sign) ! /* Draw the sign on top of the spaces. */ gui_mch_drawsign(gui.row, signcol, gui.highlight_mask); # if defined(FEAT_NETBEANS_INTG) && (defined(FEAT_GUI_X11) \ || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)) --- 2598,2604 ---- #ifdef FEAT_SIGN_ICONS if (draw_sign) ! // Draw the sign on top of the spaces. gui_mch_drawsign(gui.row, signcol, gui.highlight_mask); # if defined(FEAT_NETBEANS_INTG) && (defined(FEAT_GUI_X11) \ || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)) *************** *** 2670,2676 **** int col1, int row2, int col2, ! int flags) /* flags for gui_outstr_nowrap() */ { int old_row, old_col; long_u old_hl_mask; --- 2669,2675 ---- int col1, int row2, int col2, ! int flags) // flags for gui_outstr_nowrap() { int old_row, old_col; long_u old_hl_mask; *************** *** 2681,2698 **** int retval = FALSE; int orig_col1, orig_col2; ! /* Don't try to update when ScreenLines is not valid */ if (!screen_cleared || ScreenLines == NULL) return retval; ! /* Don't try to draw outside the shell! */ ! /* Check everything, strange values may be caused by a big border width */ col1 = check_col(col1); col2 = check_col(col2); row1 = check_row(row1); row2 = check_row(row2); ! /* Remember where our cursor was */ old_row = gui.row; old_col = gui.col; old_hl_mask = gui.highlight_mask; --- 2680,2697 ---- int retval = FALSE; int orig_col1, orig_col2; ! // Don't try to update when ScreenLines is not valid if (!screen_cleared || ScreenLines == NULL) return retval; ! // Don't try to draw outside the shell! ! // Check everything, strange values may be caused by a big border width col1 = check_col(col1); col2 = check_col(col2); row1 = check_row(row1); row2 = check_row(row2); ! // Remember where our cursor was old_row = gui.row; old_col = gui.col; old_hl_mask = gui.highlight_mask; *************** *** 2701,2708 **** for (gui.row = row1; gui.row <= row2; gui.row++) { ! /* When only half of a double-wide character is in the block, include ! * the other half. */ col1 = orig_col1; col2 = orig_col2; off = LineOffset[gui.row]; --- 2700,2707 ---- for (gui.row = row1; gui.row <= row2; gui.row++) { ! // When only half of a double-wide character is in the block, include ! // the other half. col1 = orig_col1; col2 = orig_col2; off = LineOffset[gui.row]; *************** *** 2739,2746 **** off = LineOffset[gui.row] + gui.col; len = col2 - col1 + 1; ! /* Find how many chars back this highlighting starts, or where a space ! * is. Needed for when the bold trick is used */ for (back = 0; back < col1; ++back) if (ScreenAttrs[off - 1 - back] != ScreenAttrs[off] || ScreenLines[off - 1 - back] == ' ') --- 2738,2745 ---- off = LineOffset[gui.row] + gui.col; len = col2 - col1 + 1; ! // Find how many chars back this highlighting starts, or where a space ! // is. Needed for when the bold trick is used for (back = 0; back < col1; ++back) if (ScreenAttrs[off - 1 - back] != ScreenAttrs[off] || ScreenLines[off - 1 - back] == ' ') *************** *** 2748,2755 **** retval = (col1 > 0 && ScreenAttrs[off - 1] != 0 && back == 0 && ScreenLines[off - 1] != ' '); ! /* Break it up in strings of characters with the same attributes. */ ! /* Print UTF-8 characters individually. */ while (len > 0) { first_attr = ScreenAttrs[off]; --- 2747,2754 ---- retval = (col1 > 0 && ScreenAttrs[off - 1] != 0 && back == 0 && ScreenLines[off - 1] != ' '); ! // Break it up in strings of characters with the same attributes. ! // Print UTF-8 characters individually. while (len > 0) { first_attr = ScreenAttrs[off]; *************** *** 2757,2763 **** #if !defined(FEAT_GUI_GTK) if (enc_utf8 && ScreenLinesUC[off] != 0) { ! /* output multi-byte character separately */ nback = gui_screenchar(off, flags, (guicolor_T)0, (guicolor_T)0, back); if (gui.col < Columns && ScreenLines[off + 1] == 0) --- 2756,2762 ---- #if !defined(FEAT_GUI_GTK) if (enc_utf8 && ScreenLinesUC[off] != 0) { ! // output multi-byte character separately nback = gui_screenchar(off, flags, (guicolor_T)0, (guicolor_T)0, back); if (gui.col < Columns && ScreenLines[off + 1] == 0) *************** *** 2767,2773 **** } else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) { ! /* output double-byte, single-width character separately */ nback = gui_screenchar(off, flags, (guicolor_T)0, (guicolor_T)0, back); idx = 1; --- 2766,2772 ---- } else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) { ! // output double-byte, single-width character separately nback = gui_screenchar(off, flags, (guicolor_T)0, (guicolor_T)0, back); idx = 1; *************** *** 2779,2806 **** for (idx = 0; idx < len; ++idx) { if (enc_utf8 && ScreenLines[off + idx] == 0) ! continue; /* skip second half of double-width char */ if (ScreenAttrs[off + idx] != first_attr) break; } ! /* gui_screenstr() takes care of multibyte chars */ nback = gui_screenstr(off, idx, flags, (guicolor_T)0, (guicolor_T)0, back); #else for (idx = 0; idx < len && ScreenAttrs[off + idx] == first_attr; idx++) { ! /* Stop at a multi-byte Unicode character. */ if (enc_utf8 && ScreenLinesUC[off + idx] != 0) break; if (enc_dbcs == DBCS_JPNU) { ! /* Stop at a double-byte single-width char. */ if (ScreenLines[off + idx] == 0x8e) break; if (len > 1 && (*mb_ptr2len)(ScreenLines + off + idx) == 2) ! ++idx; /* skip second byte of double-byte char */ } } nback = gui_outstr_nowrap(ScreenLines + off, idx, flags, --- 2778,2805 ---- for (idx = 0; idx < len; ++idx) { if (enc_utf8 && ScreenLines[off + idx] == 0) ! continue; // skip second half of double-width char if (ScreenAttrs[off + idx] != first_attr) break; } ! // gui_screenstr() takes care of multibyte chars nback = gui_screenstr(off, idx, flags, (guicolor_T)0, (guicolor_T)0, back); #else for (idx = 0; idx < len && ScreenAttrs[off + idx] == first_attr; idx++) { ! // Stop at a multi-byte Unicode character. if (enc_utf8 && ScreenLinesUC[off + idx] != 0) break; if (enc_dbcs == DBCS_JPNU) { ! // Stop at a double-byte single-width char. if (ScreenLines[off + idx] == 0x8e) break; if (len > 1 && (*mb_ptr2len)(ScreenLines + off + idx) == 2) ! ++idx; // skip second byte of double-byte char } } nback = gui_outstr_nowrap(ScreenLines + off, idx, flags, *************** *** 2809,2816 **** } if (nback == FAIL) { ! /* Must back up to start drawing where a bold or italic word ! * starts. */ off -= back; len += back; gui.col -= back; --- 2808,2815 ---- } if (nback == FAIL) { ! // Must back up to start drawing where a bold or italic word ! // starts. off -= back; len += back; gui.col -= back; *************** *** 2824,2830 **** } } ! /* Put the cursor back where it was */ gui.row = old_row; gui.col = old_col; gui.highlight_mask = (int)old_hl_mask; --- 2823,2829 ---- } } ! // Put the cursor back where it was gui.row = old_row; gui.col = old_col; gui.highlight_mask = (int)old_hl_mask; *************** *** 2839,2853 **** return; if (row + count > gui.scroll_region_bot) ! /* Scrolled out of region, just blank the lines out */ gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right); else { gui_mch_delete_lines(row, count); ! /* If the cursor was in the deleted lines it's now gone. If the ! * cursor was in the scrolled lines adjust its position. */ if (gui.cursor_row >= row && gui.cursor_col >= gui.scroll_region_left && gui.cursor_col <= gui.scroll_region_right) --- 2838,2852 ---- return; if (row + count > gui.scroll_region_bot) ! // Scrolled out of region, just blank the lines out gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right); else { gui_mch_delete_lines(row, count); ! // If the cursor was in the deleted lines it's now gone. If the ! // cursor was in the scrolled lines adjust its position. if (gui.cursor_row >= row && gui.cursor_col >= gui.scroll_region_left && gui.cursor_col <= gui.scroll_region_right) *************** *** 2867,2873 **** return; if (row + count > gui.scroll_region_bot) ! /* Scrolled out of region, just blank the lines out */ gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right); else --- 2866,2872 ---- return; if (row + count > gui.scroll_region_bot) ! // Scrolled out of region, just blank the lines out gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right); else *************** *** 2992,2998 **** gui_inchar( char_u *buf, int maxlen, ! long wtime, /* milli seconds */ int tb_change_cnt) { return gui_wait_for_chars_buf(buf, maxlen, wtime, tb_change_cnt); --- 2991,2997 ---- gui_inchar( char_u *buf, int maxlen, ! long wtime, // milli seconds int tb_change_cnt) { return gui_wait_for_chars_buf(buf, maxlen, wtime, tb_change_cnt); *************** *** 3069,3075 **** button_char = KE_MOUSERIGHT; button_set: { ! /* Don't put events in the input queue now. */ if (hold_gui_events) return; --- 3068,3074 ---- button_char = KE_MOUSERIGHT; button_set: { ! // Don't put events in the input queue now. if (hold_gui_events) return; *************** *** 3077,3084 **** string[4] = KS_EXTRA; string[5] = (int)button_char; ! /* Pass the pointer coordinates of the scroll event so that we ! * know which window to scroll. */ row = gui_xy2colrow(x, y, &col); string[6] = (char_u)(col / 128 + ' ' + 1); string[7] = (char_u)(col % 128 + ' ' + 1); --- 3076,3083 ---- string[4] = KS_EXTRA; string[5] = (int)button_char; ! // Pass the pointer coordinates of the scroll event so that we ! // know which window to scroll. row = gui_xy2colrow(x, y, &col); string[6] = (char_u)(col / 128 + ' ' + 1); string[7] = (char_u)(col % 128 + ' ' + 1); *************** *** 3105,3118 **** } #ifdef FEAT_CLIPBOARD ! /* If a clipboard selection is in progress, handle it */ if (clip_star.state == SELECT_IN_PROGRESS) { clip_process_selection(button, X_2_COL(x), Y_2_ROW(y), repeated_click); return; } ! /* Determine which mouse settings to look for based on the current mode */ switch (get_real_state()) { case NORMAL_BUSY: --- 3104,3117 ---- } #ifdef FEAT_CLIPBOARD ! // If a clipboard selection is in progress, handle it if (clip_star.state == SELECT_IN_PROGRESS) { clip_process_selection(button, X_2_COL(x), Y_2_ROW(y), repeated_click); return; } ! // Determine which mouse settings to look for based on the current mode switch (get_real_state()) { case NORMAL_BUSY: *************** *** 3130,3138 **** case INSERT: case INSERT+LANGMAP: checkfor = MOUSE_INSERT; break; case ASKMORE: ! case HITRETURN: /* At the more- and hit-enter prompt pass the ! mouse event for a click on or below the ! message line. */ if (Y_2_ROW(y) >= msg_row) checkfor = MOUSE_NORMAL; else --- 3129,3137 ---- case INSERT: case INSERT+LANGMAP: checkfor = MOUSE_INSERT; break; case ASKMORE: ! case HITRETURN: // At the more- and hit-enter prompt pass the ! // mouse event for a click on or below the ! // message line. if (Y_2_ROW(y) >= msg_row) checkfor = MOUSE_NORMAL; else *************** *** 3192,3198 **** */ if (!mouse_has(checkfor) || checkfor == MOUSE_COMMAND) { ! /* Don't do modeless selection in Visual mode. */ if (checkfor != MOUSE_NONEF && VIsual_active && (State & NORMAL)) return; --- 3191,3197 ---- */ if (!mouse_has(checkfor) || checkfor == MOUSE_COMMAND) { ! // Don't do modeless selection in Visual mode. if (checkfor != MOUSE_NONEF && VIsual_active && (State & NORMAL)) return; *************** *** 3207,3215 **** modifiers &= ~ MOUSE_SHIFT; } ! /* If the selection is done, allow the right button to extend it. ! * If the selection is cleared, allow the right button to start it ! * from the cursor position. */ if (button == MOUSE_RIGHT) { if (clip_star.state == SELECT_CLEARED) --- 3206,3214 ---- modifiers &= ~ MOUSE_SHIFT; } ! // If the selection is done, allow the right button to extend it. ! // If the selection is cleared, allow the right button to start it ! // from the cursor position. if (button == MOUSE_RIGHT) { if (clip_star.state == SELECT_CLEARED) *************** *** 3230,3243 **** repeated_click); did_clip = TRUE; } ! /* Allow the left button to start the selection */ else if (button == MOUSE_LEFT) { clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click); did_clip = TRUE; } ! /* Always allow pasting */ if (button != MOUSE_MIDDLE) { if (!mouse_has(checkfor) || button == MOUSE_RELEASE) --- 3229,3242 ---- repeated_click); did_clip = TRUE; } ! // Allow the left button to start the selection else if (button == MOUSE_LEFT) { clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click); did_clip = TRUE; } ! // Always allow pasting if (button != MOUSE_MIDDLE) { if (!mouse_has(checkfor) || button == MOUSE_RELEASE) *************** *** 3252,3258 **** clip_clear_selection(&clip_star); #endif ! /* Don't put events in the input queue now. */ if (hold_gui_events) return; --- 3251,3257 ---- clip_clear_selection(&clip_star); #endif ! // Don't put events in the input queue now. if (hold_gui_events) return; *************** *** 3266,3272 **** { if (row == prev_row && col == prev_col) return; ! /* Dragging above the window, set "row" to -1 to cause a scroll. */ if (y < 0) row = -1; } --- 3265,3271 ---- { if (row == prev_row && col == prev_col) return; ! // Dragging above the window, set "row" to -1 to cause a scroll. if (y < 0) row = -1; } *************** *** 3283,3289 **** ) repeated_click = FALSE; ! string[0] = CSI; /* this sequence is recognized by check_termcode() */ string[1] = KS_MOUSE; string[2] = KE_FILLER; if (button != MOUSE_DRAG && button != MOUSE_RELEASE) --- 3282,3288 ---- ) repeated_click = FALSE; ! string[0] = CSI; // this sequence is recognized by check_termcode() string[1] = KS_MOUSE; string[2] = KE_FILLER; if (button != MOUSE_DRAG && button != MOUSE_RELEASE) *************** *** 3356,3362 **** { char_u bytes[sizeof(long_u)]; ! /* Don't put events in the input queue now. */ if (hold_gui_events) return; --- 3355,3361 ---- { char_u bytes[sizeof(long_u)]; ! // Don't put events in the input queue now. if (hold_gui_events) return; *************** *** 3464,3470 **** break; #endif case GO_GREY: ! /* make menu's have grey items, ignored here */ break; #ifdef FEAT_TOOLBAR case GO_TOOLBAR: --- 3463,3469 ---- break; #endif case GO_GREY: ! // make menu's have grey items, ignored here break; #ifdef FEAT_TOOLBAR case GO_TOOLBAR: *************** *** 3482,3488 **** #endif break; default: ! /* Ignore options that are not supported */ break; } --- 3481,3487 ---- #endif break; default: ! // Ignore options that are not supported break; } *************** *** 3500,3512 **** #endif #ifdef FEAT_GUI_TABLINE ! /* Update the GUI tab line, it may appear or disappear. This may ! * cause the non-GUI tab line to disappear or appear. */ using_tabline = gui_has_tabline(); if (!gui_mch_showing_tabline() != !using_tabline) { ! /* We don't want a resize event change "Rows" here, save and ! * restore it. Resizing is handled below. */ i = Rows; gui_update_tabline(); Rows = i; --- 3499,3511 ---- #endif #ifdef FEAT_GUI_TABLINE ! // Update the GUI tab line, it may appear or disappear. This may ! // cause the non-GUI tab line to disappear or appear. using_tabline = gui_has_tabline(); if (!gui_mch_showing_tabline() != !using_tabline) { ! // We don't want a resize event change "Rows" here, save and ! // restore it. Resizing is handled below. i = Rows; gui_update_tabline(); Rows = i; *************** *** 3514,3529 **** if (using_tabline) fix_size = TRUE; if (!gui_use_tabline()) ! redraw_tabline = TRUE; /* may draw non-GUI tab line */ } #endif for (i = 0; i < 3; i++) { ! /* The scrollbar needs to be updated when it is shown/unshown and ! * when switching tab pages. But the size only changes when it's ! * shown/unshown. Thus we need two places to remember whether a ! * scrollbar is there or not. */ if (gui.which_scrollbars[i] != prev_which_scrollbars[i] || gui.which_scrollbars[i] != curtab->tp_prev_which_scrollbars[i]) --- 3513,3528 ---- if (using_tabline) fix_size = TRUE; if (!gui_use_tabline()) ! redraw_tabline = TRUE; // may draw non-GUI tab line } #endif for (i = 0; i < 3; i++) { ! // The scrollbar needs to be updated when it is shown/unshown and ! // when switching tab pages. But the size only changes when it's ! // shown/unshown. Thus we need two places to remember whether a ! // scrollbar is there or not. if (gui.which_scrollbars[i] != prev_which_scrollbars[i] || gui.which_scrollbars[i] != curtab->tp_prev_which_scrollbars[i]) *************** *** 3553,3560 **** #ifdef FEAT_MENU if (gui.menu_is_active != prev_menu_is_active) { ! /* We don't want a resize event change "Rows" here, save and ! * restore it. Resizing is handled below. */ i = Rows; gui_mch_enable_menu(gui.menu_is_active); Rows = i; --- 3552,3559 ---- #ifdef FEAT_MENU if (gui.menu_is_active != prev_menu_is_active) { ! // We don't want a resize event change "Rows" here, save and ! // restore it. Resizing is handled below. i = Rows; gui_mch_enable_menu(gui.menu_is_active); Rows = i; *************** *** 3598,3619 **** long prev_Columns = Columns; long prev_Rows = Rows; #endif ! /* Adjust the size of the window to make the text area keep the ! * same size and to avoid that part of our window is off-screen ! * and a scrollbar can't be used, for example. */ gui_set_shellsize(FALSE, fix_size, need_set_size); #ifdef FEAT_GUI_GTK ! /* GTK has the annoying habit of sending us resize events when ! * changing the window size ourselves. This mostly happens when ! * waiting for a character to arrive, quite unpredictably, and may ! * change Columns and Rows when we don't want it. Wait for a ! * character here to avoid this effect. ! * If you remove this, please test this command for resizing ! * effects (with optional left scrollbar): ":vsp|q|vsp|q|vsp|q". ! * Don't do this while starting up though. ! * Don't change Rows when adding menu/toolbar/tabline. ! * Don't change Columns when adding vertical toolbar. */ if (!gui.starting && need_set_size != (RESIZE_VERT | RESIZE_HOR)) (void)char_avail(); if ((need_set_size & RESIZE_VERT) == 0) --- 3597,3618 ---- long prev_Columns = Columns; long prev_Rows = Rows; #endif ! // Adjust the size of the window to make the text area keep the ! // same size and to avoid that part of our window is off-screen ! // and a scrollbar can't be used, for example. gui_set_shellsize(FALSE, fix_size, need_set_size); #ifdef FEAT_GUI_GTK ! // GTK has the annoying habit of sending us resize events when ! // changing the window size ourselves. This mostly happens when ! // waiting for a character to arrive, quite unpredictably, and may ! // change Columns and Rows when we don't want it. Wait for a ! // character here to avoid this effect. ! // If you remove this, please test this command for resizing ! // effects (with optional left scrollbar): ":vsp|q|vsp|q|vsp|q". ! // Don't do this while starting up though. ! // Don't change Rows when adding menu/toolbar/tabline. ! // Don't change Columns when adding vertical toolbar. if (!gui.starting && need_set_size != (RESIZE_VERT | RESIZE_HOR)) (void)char_avail(); if ((need_set_size & RESIZE_VERT) == 0) *************** *** 3622,3631 **** Columns = prev_Columns; #endif } ! /* When the console tabline appears or disappears the window positions ! * change. */ if (firstwin->w_winrow != tabline_height()) ! shell_new_rows(); /* recompute window positions and heights */ } } --- 3621,3630 ---- Columns = prev_Columns; #endif } ! // When the console tabline appears or disappears the window positions ! // change. if (firstwin->w_winrow != tabline_height()) ! shell_new_rows(); // recompute window positions and heights } } *************** *** 3666,3673 **** if (!gui.starting && starting == 0) { ! /* Updating the tabline uses direct GUI commands, flush ! * outstanding instructions first. (esp. clear screen) */ out_flush(); if (!showit != !shown) --- 3665,3672 ---- if (!gui.starting && starting == 0) { ! // Updating the tabline uses direct GUI commands, flush ! // outstanding instructions first. (esp. clear screen) out_flush(); if (!showit != !shown) *************** *** 3675,3682 **** if (showit != 0) gui_mch_update_tabline(); ! /* When the tabs change from hidden to shown or from shown to ! * hidden the size of the text area should remain the same. */ if (!showit != !shown) gui_set_shellsize(FALSE, showit, RESIZE_VERT); } --- 3674,3681 ---- if (showit != 0) gui_mch_update_tabline(); ! // When the tabs change from hidden to shown or from shown to ! // hidden the size of the text area should remain the same. if (!showit != !shown) gui_set_shellsize(FALSE, showit, RESIZE_VERT); } *************** *** 3688,3694 **** void get_tabline_label( tabpage_T *tp, ! int tooltip) /* TRUE: get tooltip */ { int modified = FALSE; char_u buf[40]; --- 3687,3693 ---- void get_tabline_label( tabpage_T *tp, ! int tooltip) // TRUE: get tooltip { int modified = FALSE; char_u buf[40]; *************** *** 3696,3702 **** win_T *wp; char_u **opt; ! /* Use 'guitablabel' or 'guitabtooltip' if it's set. */ opt = (tooltip ? &p_gtt : &p_gtl); if (**opt != NUL) { --- 3695,3701 ---- win_T *wp; char_u **opt; ! // Use 'guitablabel' or 'guitabtooltip' if it's set. opt = (tooltip ? &p_gtt : &p_gtl); if (**opt != NUL) { *************** *** 3714,3720 **** set_vim_var_nr(VV_LNUM, printer_page_num); use_sandbox = was_set_insecurely(opt_name, 0); # endif ! /* It's almost as going to the tabpage, but without autocommands. */ curtab->tp_firstwin = firstwin; curtab->tp_lastwin = lastwin; curtab->tp_curwin = curwin; --- 3713,3719 ---- set_vim_var_nr(VV_LNUM, printer_page_num); use_sandbox = was_set_insecurely(opt_name, 0); # endif ! // It's almost as going to the tabpage, but without autocommands. curtab->tp_firstwin = firstwin; curtab->tp_lastwin = lastwin; curtab->tp_curwin = curwin; *************** *** 3726,3737 **** curwin = curtab->tp_curwin; curbuf = curwin->w_buffer; ! /* Can't use NameBuff directly, build_stl_str_hl() uses it. */ build_stl_str_hl(curwin, res, MAXPATHL, *opt, use_sandbox, 0, (int)Columns, NULL, NULL); STRCPY(NameBuff, res); ! /* Back to the original curtab. */ curtab = save_curtab; topframe = curtab->tp_topframe; firstwin = curtab->tp_firstwin; --- 3725,3736 ---- curwin = curtab->tp_curwin; curbuf = curwin->w_buffer; ! // Can't use NameBuff directly, build_stl_str_hl() uses it. build_stl_str_hl(curwin, res, MAXPATHL, *opt, use_sandbox, 0, (int)Columns, NULL, NULL); STRCPY(NameBuff, res); ! // Back to the original curtab. curtab = save_curtab; topframe = curtab->tp_topframe; firstwin = curtab->tp_firstwin; *************** *** 3745,3755 **** called_emsg |= save_called_emsg; } ! /* If 'guitablabel'/'guitabtooltip' is not set or the result is empty then ! * use a default label. */ if (**opt == NUL || *NameBuff == NUL) { ! /* Get the buffer name into NameBuff[] and shorten it. */ get_trans_bufname(tp == curtab ? curbuf : tp->tp_curwin->w_buffer); if (!tooltip) shorten_dir(NameBuff); --- 3744,3754 ---- called_emsg |= save_called_emsg; } ! // If 'guitablabel'/'guitabtooltip' is not set or the result is empty then ! // use a default label. if (**opt == NUL || *NameBuff == NUL) { ! // Get the buffer name into NameBuff[] and shorten it. get_trans_bufname(tp == curtab ? curbuf : tp->tp_curwin->w_buffer); if (!tooltip) shorten_dir(NameBuff); *************** *** 3786,3799 **** if (nr == tabpage_index(curtab)) return FALSE; ! /* Don't put events in the input queue now. */ if (hold_gui_events # ifdef FEAT_CMDWIN || cmdwin_type != 0 # endif ) { ! /* Set it back to the current tab page. */ gui_mch_set_curtab(tabpage_index(curtab)); return FALSE; } --- 3785,3798 ---- if (nr == tabpage_index(curtab)) return FALSE; ! // Don't put events in the input queue now. if (hold_gui_events # ifdef FEAT_CMDWIN || cmdwin_type != 0 # endif ) { ! // Set it back to the current tab page. gui_mch_set_curtab(tabpage_index(curtab)); return FALSE; } *************** *** 3865,3871 **** { static int sbar_ident = 0; ! sb->ident = sbar_ident++; /* No check for too big, but would it happen? */ sb->wp = wp; sb->type = type; sb->value = 0; --- 3864,3870 ---- { static int sbar_ident = 0; ! sb->ident = sbar_ident++; // No check for too big, but would it happen? sb->wp = wp; sb->type = type; sb->value = 0; *************** *** 3935,3941 **** if (sb == NULL) return; ! /* Don't put events in the input queue now. */ if (hold_gui_events) return; --- 3934,3940 ---- if (sb == NULL) return; ! // Don't put events in the input queue now. if (hold_gui_events) return; *************** *** 3958,3970 **** { gui.dragged_sb = SBAR_NONE; #ifdef FEAT_GUI_GTK ! /* Keep the "dragged_wp" value until after the scrolling, for when the ! * mouse button is released. GTK2 doesn't send the button-up event. */ gui.dragged_wp = NULL; #endif } ! /* Vertical sbar info is kept in the first sbar (the left one) */ if (sb->wp != NULL) sb = &sb->wp->w_scrollbars[0]; --- 3957,3969 ---- { gui.dragged_sb = SBAR_NONE; #ifdef FEAT_GUI_GTK ! // Keep the "dragged_wp" value until after the scrolling, for when the ! // mouse button is released. GTK2 doesn't send the button-up event. gui.dragged_wp = NULL; #endif } ! // Vertical sbar info is kept in the first sbar (the left one) if (sb->wp != NULL) sb = &sb->wp->w_scrollbars[0]; *************** *** 3984,3997 **** sb->value = value; #ifdef USE_ON_FLY_SCROLL ! /* When not allowed to do the scrolling right now, return. ! * This also checked input_available(), but that causes the first click in ! * a scrollbar to be ignored when Vim doesn't have focus. */ if (dont_scroll) return; #endif ! /* Disallow scrolling the current window when the completion popup menu is ! * visible. */ if ((sb->wp == NULL || sb->wp == curwin) && pum_visible()) return; --- 3983,3996 ---- sb->value = value; #ifdef USE_ON_FLY_SCROLL ! // When not allowed to do the scrolling right now, return. ! // This also checked input_available(), but that causes the first click in ! // a scrollbar to be ignored when Vim doesn't have focus. if (dont_scroll) return; #endif ! // Disallow scrolling the current window when the completion popup menu is ! // visible. if ((sb->wp == NULL || sb->wp == curwin) && pum_visible()) return; *************** *** 4004,4010 **** } #endif ! if (sb->wp != NULL) /* vertical scrollbar */ { sb_num = 0; for (wp = firstwin; wp != sb->wp && wp != NULL; wp = wp->w_next) --- 4003,4009 ---- } #endif ! if (sb->wp != NULL) // vertical scrollbar { sb_num = 0; for (wp = firstwin; wp != sb->wp && wp != NULL; wp = wp->w_next) *************** *** 4034,4045 **** } } # ifdef FEAT_FOLDING ! /* Value may have been changed for closed fold. */ sb->value = sb->wp->w_topline - 1; # endif ! /* When dragging one scrollbar and there is another one at the other ! * side move the thumb of that one too. */ if (gui.which_scrollbars[SBAR_RIGHT] && gui.which_scrollbars[SBAR_LEFT]) gui_mch_set_scrollbar_thumb( &sb->wp->w_scrollbars[ --- 4033,4044 ---- } } # ifdef FEAT_FOLDING ! // Value may have been changed for closed fold. sb->value = sb->wp->w_topline - 1; # endif ! // When dragging one scrollbar and there is another one at the other ! // side move the thumb of that one too. if (gui.which_scrollbars[SBAR_RIGHT] && gui.which_scrollbars[SBAR_LEFT]) gui_mch_set_scrollbar_thumb( &sb->wp->w_scrollbars[ *************** *** 4074,4080 **** } if (old_leftcol != curwin->w_leftcol) { ! updateWindow(curwin); /* update window, status and cmdline */ setcursor(); } #else --- 4073,4079 ---- } if (old_leftcol != curwin->w_leftcol) { ! updateWindow(curwin); // update window, status and cmdline setcursor(); } #else *************** *** 4098,4104 **** )))) { do_check_scrollbind(TRUE); ! /* need to update the window right here */ FOR_ALL_WINDOWS(wp) if (wp->w_redr_type > 0) updateWindow(wp); --- 4097,4103 ---- )))) { do_check_scrollbind(TRUE); ! // need to update the window right here FOR_ALL_WINDOWS(wp) if (wp->w_redr_type > 0) updateWindow(wp); *************** *** 4133,4153 **** void gui_update_scrollbars( ! int force) /* Force all scrollbars to get updated */ { win_T *wp; scrollbar_T *sb; ! long val, size, max; /* need 32 bits here */ int which_sb; int h, y; static win_T *prev_curwin = NULL; ! /* Update the horizontal scrollbar */ gui_update_horiz_scrollbar(force); #ifndef MSWIN ! /* Return straight away if there is neither a left nor right scrollbar. ! * On MS-Windows this is required anyway for scrollwheel messages. */ if (!gui.which_scrollbars[SBAR_LEFT] && !gui.which_scrollbars[SBAR_RIGHT]) return; #endif --- 4132,4152 ---- void gui_update_scrollbars( ! int force) // Force all scrollbars to get updated { win_T *wp; scrollbar_T *sb; ! long val, size, max; // need 32 bits here int which_sb; int h, y; static win_T *prev_curwin = NULL; ! // Update the horizontal scrollbar gui_update_horiz_scrollbar(force); #ifndef MSWIN ! // Return straight away if there is neither a left nor right scrollbar. ! // On MS-Windows this is required anyway for scrollwheel messages. if (!gui.which_scrollbars[SBAR_LEFT] && !gui.which_scrollbars[SBAR_RIGHT]) return; #endif *************** *** 4174,4187 **** gui.dragged_wp->w_scrollbars[0].max); } ! /* avoid that moving components around generates events */ ++hold_gui_events; for (wp = firstwin; wp != NULL; wp = W_NEXT(wp)) { ! if (wp->w_buffer == NULL) /* just in case */ continue; ! /* Skip a scrollbar that is being dragged. */ if (!force && (gui.dragged_sb == SBAR_LEFT || gui.dragged_sb == SBAR_RIGHT) && gui.dragged_wp == wp) --- 4173,4186 ---- gui.dragged_wp->w_scrollbars[0].max); } ! // avoid that moving components around generates events ++hold_gui_events; for (wp = firstwin; wp != NULL; wp = W_NEXT(wp)) { ! if (wp->w_buffer == NULL) // just in case continue; ! // Skip a scrollbar that is being dragged. if (!force && (gui.dragged_sb == SBAR_LEFT || gui.dragged_sb == SBAR_RIGHT) && gui.dragged_wp == wp) *************** *** 4192,4211 **** #else max = wp->w_buffer->b_ml.ml_line_count + wp->w_height - 2; #endif ! if (max < 0) /* empty buffer */ max = 0; val = wp->w_topline - 1; size = wp->w_height; #ifdef SCROLL_PAST_END ! if (val > max) /* just in case */ val = max; #else ! if (size > max + 1) /* just in case */ size = max + 1; if (val > max - size + 1) val = max - size + 1; #endif ! if (val < 0) /* minimal value is 0 */ val = 0; /* --- 4191,4210 ---- #else max = wp->w_buffer->b_ml.ml_line_count + wp->w_height - 2; #endif ! if (max < 0) // empty buffer max = 0; val = wp->w_topline - 1; size = wp->w_height; #ifdef SCROLL_PAST_END ! if (val > max) // just in case val = max; #else ! if (size > max + 1) // just in case size = max + 1; if (val > max - size + 1) val = max - size + 1; #endif ! if (val < 0) // minimal value is 0 val = 0; /* *************** *** 4225,4231 **** * This can happen during changing files. Just don't update the * scrollbar for now. */ ! sb->height = 0; /* Force update next time */ if (gui.which_scrollbars[SBAR_LEFT]) gui_do_scrollbar(wp, SBAR_LEFT, FALSE); if (gui.which_scrollbars[SBAR_RIGHT]) --- 4224,4230 ---- * This can happen during changing files. Just don't update the * scrollbar for now. */ ! sb->height = 0; // Force update next time if (gui.which_scrollbars[SBAR_LEFT]) gui_do_scrollbar(wp, SBAR_LEFT, FALSE); if (gui.which_scrollbars[SBAR_RIGHT]) *************** *** 4238,4251 **** || sb->width != wp->w_width || prev_curwin != curwin) { ! /* Height, width or position of scrollbar has changed. For ! * vertical split: curwin changed. */ sb->height = wp->w_height; sb->top = wp->w_winrow; sb->status_height = wp->w_status_height; sb->width = wp->w_width; ! /* Calculate height and position in pixels */ h = (sb->height + sb->status_height) * gui.char_height; y = sb->top * gui.char_height + gui.border_offset; #if defined(FEAT_MENU) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) && !defined(FEAT_GUI_PHOTON) --- 4237,4250 ---- || sb->width != wp->w_width || prev_curwin != curwin) { ! // Height, width or position of scrollbar has changed. For ! // vertical split: curwin changed. sb->height = wp->w_height; sb->top = wp->w_winrow; sb->status_height = wp->w_status_height; sb->width = wp->w_width; ! // Calculate height and position in pixels h = (sb->height + sb->status_height) * gui.char_height; y = sb->top * gui.char_height + gui.border_offset; #if defined(FEAT_MENU) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) && !defined(FEAT_GUI_PHOTON) *************** *** 4271,4277 **** if (wp->w_winrow == 0) { ! /* Height of top scrollbar includes width of top border */ h += gui.border_offset; y -= gui.border_offset; } --- 4270,4276 ---- if (wp->w_winrow == 0) { ! // Height of top scrollbar includes width of top border h += gui.border_offset; y -= gui.border_offset; } *************** *** 4291,4300 **** } } ! /* Reduce the number of calls to gui_mch_set_scrollbar_thumb() by ! * checking if the thumb moved at least a pixel. Only do this for ! * Athena, most other GUIs require the update anyway to make the ! * arrows work. */ #ifdef FEAT_GUI_ATHENA if (max == 0) y = 0; --- 4290,4299 ---- } } ! // Reduce the number of calls to gui_mch_set_scrollbar_thumb() by ! // checking if the thumb moved at least a pixel. Only do this for ! // Athena, most other GUIs require the update anyway to make the ! // arrows work. #ifdef FEAT_GUI_ATHENA if (max == 0) y = 0; *************** *** 4305,4311 **** if (force || sb->value != val || sb->size != size || sb->max != max) #endif { ! /* Thumb of scrollbar has moved */ sb->value = val; #ifdef FEAT_GUI_ATHENA sb->pixval = y; --- 4304,4310 ---- if (force || sb->value != val || sb->size != size || sb->max != max) #endif { ! // Thumb of scrollbar has moved sb->value = val; #ifdef FEAT_GUI_ATHENA sb->pixval = y; *************** *** 4334,4360 **** static void gui_do_scrollbar( win_T *wp, ! int which, /* SBAR_LEFT or SBAR_RIGHT */ ! int enable) /* TRUE to enable scrollbar */ { int midcol = curwin->w_wincol + curwin->w_width / 2; int has_midcol = (wp->w_wincol <= midcol && wp->w_wincol + wp->w_width >= midcol); ! /* Only enable scrollbars that contain the middle column of the current ! * window. */ if (gui.which_scrollbars[SBAR_RIGHT] != gui.which_scrollbars[SBAR_LEFT]) { ! /* Scrollbars only on one side. Don't enable scrollbars that don't ! * contain the middle column of the current window. */ if (!has_midcol) enable = FALSE; } else { ! /* Scrollbars on both sides. Don't enable scrollbars that neither ! * contain the middle column of the current window nor are on the far ! * side. */ if (midcol > Columns / 2) { if (which == SBAR_LEFT ? wp->w_wincol != 0 : !has_midcol) --- 4333,4359 ---- static void gui_do_scrollbar( win_T *wp, ! int which, // SBAR_LEFT or SBAR_RIGHT ! int enable) // TRUE to enable scrollbar { int midcol = curwin->w_wincol + curwin->w_width / 2; int has_midcol = (wp->w_wincol <= midcol && wp->w_wincol + wp->w_width >= midcol); ! // Only enable scrollbars that contain the middle column of the current ! // window. if (gui.which_scrollbars[SBAR_RIGHT] != gui.which_scrollbars[SBAR_LEFT]) { ! // Scrollbars only on one side. Don't enable scrollbars that don't ! // contain the middle column of the current window. if (!has_midcol) enable = FALSE; } else { ! // Scrollbars on both sides. Don't enable scrollbars that neither ! // contain the middle column of the current window nor are on the far ! // side. if (midcol > Columns / 2) { if (which == SBAR_LEFT ? wp->w_wincol != 0 : !has_midcol) *************** *** 4391,4397 **** if (wp == NULL) break; if (wp == NULL) ! /* Couldn't find window */ return FALSE; /* --- 4390,4396 ---- if (wp == NULL) break; if (wp == NULL) ! // Couldn't find window return FALSE; /* *************** *** 4413,4421 **** scrolldown(-nlines, gui.dragged_wp == NULL); else scrollup(nlines, gui.dragged_wp == NULL); ! /* Reset dragged_wp after using it. "dragged_sb" will have been reset for ! * the mouse-up event already, but we still want it to behave like when ! * dragging. But not the next click in an arrow. */ if (gui.dragged_sb == SBAR_NONE) gui.dragged_wp = NULL; --- 4412,4420 ---- scrolldown(-nlines, gui.dragged_wp == NULL); else scrollup(nlines, gui.dragged_wp == NULL); ! // Reset dragged_wp after using it. "dragged_sb" will have been reset for ! // the mouse-up event already, but we still want it to behave like when ! // dragging. But not the next click in an arrow. if (gui.dragged_sb == SBAR_NONE) gui.dragged_wp = NULL; *************** *** 4427,4441 **** { if (get_scrolloff_value() != 0) { ! cursor_correct(); /* fix window for 'so' */ ! update_topline(); /* avoid up/down jump */ } if (old_cursor.lnum != wp->w_cursor.lnum) coladvance(wp->w_curswant); wp->w_scbind_pos = wp->w_topline; } ! /* Make sure wp->w_leftcol and wp->w_skipcol are correct. */ validate_cursor(); curwin = save_wp; --- 4426,4440 ---- { if (get_scrolloff_value() != 0) { ! cursor_correct(); // fix window for 'so' ! update_topline(); // avoid up/down jump } if (old_cursor.lnum != wp->w_cursor.lnum) coladvance(wp->w_curswant); wp->w_scbind_pos = wp->w_topline; } ! // Make sure wp->w_leftcol and wp->w_skipcol are correct. validate_cursor(); curwin = save_wp; *************** *** 4460,4475 **** wp->w_lines_valid = 0; } ! /* Don't set must_redraw here, it may cause the popup menu to ! * disappear when losing focus after a scrollbar drag. */ if (wp->w_redr_type < type) wp->w_redr_type = type; mch_disable_flush(); ! updateWindow(wp); /* update window, status line, and cmdline */ mch_enable_flush(); } ! /* May need to redraw the popup menu. */ if (pum_visible()) pum_redraw(); --- 4459,4474 ---- wp->w_lines_valid = 0; } ! // Don't set must_redraw here, it may cause the popup menu to ! // disappear when losing focus after a scrollbar drag. if (wp->w_redr_type < type) wp->w_redr_type = type; mch_disable_flush(); ! updateWindow(wp); // update window, status line, and cmdline mch_enable_flush(); } ! // May need to redraw the popup menu. if (pum_visible()) pum_redraw(); *************** *** 4498,4512 **** { w = chartabsize(p, col); MB_PTR_ADV(p); ! if (*p == NUL) /* don't count the last character */ break; col += w; } return col; } ! /* Remember which line is currently the longest, so that we don't have to ! * search for it when scrolling horizontally. */ static linenr_T longest_lnum = 0; /* --- 4497,4511 ---- { w = chartabsize(p, col); MB_PTR_ADV(p); ! if (*p == NUL) // don't count the last character break; col += w; } return col; } ! // Remember which line is currently the longest, so that we don't have to ! // search for it when scrolling horizontally. static linenr_T longest_lnum = 0; /* *************** *** 4518,4526 **** { linenr_T ret = 0; ! /* Calculate maximum for horizontal scrollbar. Check for reasonable ! * line numbers, topline and botline can be invalid when displaying is ! * postponed. */ if (vim_strchr(p_go, GO_HORSCROLL) == NULL && curwin->w_topline <= curwin->w_cursor.lnum && curwin->w_botline > curwin->w_cursor.lnum --- 4517,4525 ---- { linenr_T ret = 0; ! // Calculate maximum for horizontal scrollbar. Check for reasonable ! // line numbers, topline and botline can be invalid when displaying is ! // postponed. if (vim_strchr(p_go, GO_HORSCROLL) == NULL && curwin->w_topline <= curwin->w_cursor.lnum && curwin->w_botline > curwin->w_cursor.lnum *************** *** 4530,4538 **** colnr_T n; long max = 0; ! /* Use maximum of all visible lines. Remember the lnum of the ! * longest line, closest to the cursor line. Used when scrolling ! * below. */ for (lnum = curwin->w_topline; lnum < curwin->w_botline; ++lnum) { n = scroll_line_len(lnum); --- 4529,4537 ---- colnr_T n; long max = 0; ! // Use maximum of all visible lines. Remember the lnum of the ! // longest line, closest to the cursor line. Used when scrolling ! // below. for (lnum = curwin->w_topline; lnum < curwin->w_botline; ++lnum) { n = scroll_line_len(lnum); *************** *** 4548,4554 **** } } else ! /* Use cursor line only. */ ret = curwin->w_cursor.lnum; return ret; --- 4547,4553 ---- } } else ! // Use cursor line only. ret = curwin->w_cursor.lnum; return ret; *************** *** 4557,4563 **** static void gui_update_horiz_scrollbar(int force) { ! long value, size, max; /* need 32 bit ints here */ if (!gui.which_scrollbars[SBAR_BOTTOM]) return; --- 4556,4562 ---- static void gui_update_horiz_scrollbar(int force) { ! long value, size, max; // need 32 bit ints here if (!gui.which_scrollbars[SBAR_BOTTOM]) return; *************** *** 4597,4603 **** if (virtual_active()) { ! /* May move the cursor even further to the right. */ if (curwin->w_virtcol >= (colnr_T)max) max = curwin->w_virtcol; } --- 4596,4602 ---- if (virtual_active()) { ! // May move the cursor even further to the right. if (curwin->w_virtcol >= (colnr_T)max) max = curwin->w_virtcol; } *************** *** 4605,4612 **** #ifndef SCROLL_PAST_END max += curwin->w_width - 1; #endif ! /* The line number isn't scrolled, thus there is less space when ! * 'number' or 'relativenumber' is set (also for 'foldcolumn'). */ size -= curwin_col_off(); #ifndef SCROLL_PAST_END max -= curwin_col_off(); --- 4604,4611 ---- #ifndef SCROLL_PAST_END max += curwin->w_width - 1; #endif ! // The line number isn't scrolled, thus there is less space when ! // 'number' or 'relativenumber' is set (also for 'foldcolumn'). size -= curwin_col_off(); #ifndef SCROLL_PAST_END max -= curwin_col_off(); *************** *** 4615,4621 **** #ifndef SCROLL_PAST_END if (value > max - size + 1) ! value = max - size + 1; /* limit the value to allowable range */ #endif #ifdef FEAT_RIGHTLEFT --- 4614,4620 ---- #ifndef SCROLL_PAST_END if (value > max - size + 1) ! value = max - size + 1; // limit the value to allowable range #endif #ifdef FEAT_RIGHTLEFT *************** *** 4647,4653 **** int gui_do_horiz_scroll(long_u leftcol, int compute_longest_lnum) { ! /* no wrapping, no scrolling */ if (curwin->w_p_wrap) return FALSE; --- 4646,4652 ---- int gui_do_horiz_scroll(long_u leftcol, int compute_longest_lnum) { ! // no wrapping, no scrolling if (curwin->w_p_wrap) return FALSE; *************** *** 4656,4663 **** curwin->w_leftcol = (colnr_T)leftcol; ! /* When the line of the cursor is too short, move the cursor to the ! * longest visible line. */ if (vim_strchr(p_go, GO_HORSCROLL) == NULL && !virtual_active() && (colnr_T)leftcol > scroll_line_len(curwin->w_cursor.lnum)) --- 4655,4662 ---- curwin->w_leftcol = (colnr_T)leftcol; ! // When the line of the cursor is too short, move the cursor to the ! // longest visible line. if (vim_strchr(p_go, GO_HORSCROLL) == NULL && !virtual_active() && (colnr_T)leftcol > scroll_line_len(curwin->w_cursor.lnum)) *************** *** 4667,4673 **** curwin->w_cursor.lnum = gui_find_longest_lnum(); curwin->w_cursor.col = 0; } ! /* Do a sanity check on "longest_lnum", just in case. */ else if (longest_lnum >= curwin->w_topline && longest_lnum < curwin->w_botline) { --- 4666,4672 ---- curwin->w_cursor.lnum = gui_find_longest_lnum(); curwin->w_cursor.col = 0; } ! // Do a sanity check on "longest_lnum", just in case. else if (longest_lnum >= curwin->w_topline && longest_lnum < curwin->w_botline) { *************** *** 4756,4763 **** void init_gui_options(void) { ! /* Set the 'background' option according to the lightness of the ! * background color, unless the user has set it already. */ if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) { set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); --- 4755,4762 ---- void init_gui_options(void) { ! // Set the 'background' option according to the lightness of the ! // background color, unless the user has set it already. if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) { set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); *************** *** 4771,4777 **** { win_T *wp; ! /* Nothing to do if GUI hasn't started yet. */ if (!gui.in_use) return; --- 4770,4776 ---- { win_T *wp; ! // Nothing to do if GUI hasn't started yet. if (!gui.in_use) return; *************** *** 4802,4810 **** xim_set_focus(in_focus); # endif ! /* Put events in the input queue only when allowed. ! * ui_focus_change() isn't called directly, because it invokes ! * autocommands and that must not happen asynchronously. */ if (!hold_gui_events) { char_u bytes[3]; --- 4801,4809 ---- xim_set_focus(in_focus); # endif ! // Put events in the input queue only when allowed. ! // ui_focus_change() isn't called directly, because it invokes ! // autocommands and that must not happen asynchronously. if (!hold_gui_events) { char_u bytes[3]; *************** *** 4828,4856 **** char_u st[8]; #ifdef FEAT_MOUSESHAPE ! /* Get window pointer, and update mouse shape as well. */ wp = xy2win(x, y, IGNORE_POPUP); #endif ! /* Only handle this when 'mousefocus' set and ... */ if (p_mousef ! && !hold_gui_events /* not holding events */ ! && (State & (NORMAL|INSERT))/* Normal/Visual/Insert mode */ ! && State != HITRETURN /* but not hit-return prompt */ ! && msg_scrolled == 0 /* no scrolled message */ ! && !need_mouse_correct /* not moving the pointer */ ! && gui.in_focus) /* gvim in focus */ { ! /* Don't move the mouse when it's left or right of the Vim window */ if (x < 0 || x > Columns * gui.char_width) return; #ifndef FEAT_MOUSESHAPE wp = xy2win(x, y, IGNORE_POPUP); #endif if (wp == curwin || wp == NULL) ! return; /* still in the same old window, or none at all */ ! /* Ignore position in the tab pages line. */ if (Y_2_ROW(y) < tabline_height()) return; --- 4827,4855 ---- char_u st[8]; #ifdef FEAT_MOUSESHAPE ! // Get window pointer, and update mouse shape as well. wp = xy2win(x, y, IGNORE_POPUP); #endif ! // Only handle this when 'mousefocus' set and ... if (p_mousef ! && !hold_gui_events // not holding events ! && (State & (NORMAL|INSERT))// Normal/Visual/Insert mode ! && State != HITRETURN // but not hit-return prompt ! && msg_scrolled == 0 // no scrolled message ! && !need_mouse_correct // not moving the pointer ! && gui.in_focus) // gvim in focus { ! // Don't move the mouse when it's left or right of the Vim window if (x < 0 || x > Columns * gui.char_width) return; #ifndef FEAT_MOUSESHAPE wp = xy2win(x, y, IGNORE_POPUP); #endif if (wp == curwin || wp == NULL) ! return; // still in the same old window, or none at all ! // Ignore position in the tab pages line. if (Y_2_ROW(y) < tabline_height()) return; *************** *** 4862,4868 **** */ if (finish_op) { ! /* abort the current operator first */ st[0] = ESC; add_to_input_buf(st, 1); } --- 4861,4867 ---- */ if (finish_op) { ! // abort the current operator first st[0] = ESC; add_to_input_buf(st, 1); } *************** *** 4878,4884 **** st[3] = (char_u)MOUSE_RELEASE; add_to_input_buf(st, 8); #ifdef FEAT_GUI_GTK ! /* Need to wake up the main loop */ if (gtk_main_level() > 0) gtk_main_quit(); #endif --- 4877,4883 ---- st[3] = (char_u)MOUSE_RELEASE; add_to_input_buf(st, 8); #ifdef FEAT_GUI_GTK ! // Need to wake up the main loop if (gtk_main_level() > 0) gtk_main_quit(); #endif *************** *** 4937,4943 **** need_mouse_correct = FALSE; wp = gui_mouse_window(IGNORE_POPUP); ! if (wp != curwin && wp != NULL) /* If in other than current window */ { validate_cline_row(); gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3, --- 4936,4942 ---- need_mouse_correct = FALSE; wp = gui_mouse_window(IGNORE_POPUP); ! if (wp != curwin && wp != NULL) // If in other than current window { validate_cline_row(); gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3, *************** *** 4959,4965 **** row = Y_2_ROW(y); col = X_2_COL(x); ! if (row < 0 || col < 0) /* before first window */ return NULL; wp = mouse_find_win(&row, &col, popup); if (wp == NULL) --- 4958,4964 ---- row = Y_2_ROW(y); col = X_2_COL(x); ! if (row < 0 || col < 0) // before first window return NULL; wp = mouse_find_win(&row, &col, popup); if (wp == NULL) *************** *** 4972,4978 **** else update_mouseshape(SHAPE_IDX_MORE); } ! else if (row > wp->w_height) /* below status line */ update_mouseshape(SHAPE_IDX_CLINE); else if (!(State & CMDLINE) && wp->w_vsep_width > 0 && col == wp->w_width && (row != wp->w_height || !stl_connected(wp)) && msg_scrolled == 0) --- 4971,4977 ---- else update_mouseshape(SHAPE_IDX_MORE); } ! else if (row > wp->w_height) // below status line update_mouseshape(SHAPE_IDX_CLINE); else if (!(State & CMDLINE) && wp->w_vsep_width > 0 && col == wp->w_width && (row != wp->w_height || !stl_connected(wp)) && msg_scrolled == 0) *************** *** 5013,5020 **** emsg(_(e_nogvim)); return; #else ! /* Clear the command. Needed for when forking+exiting, to avoid part ! * of the argument ending up after the shell prompt. */ msg_clr_eos_force(); # ifdef GUI_MAY_SPAWN if (!ends_excmd(*eap->arg)) --- 5012,5019 ---- emsg(_(e_nogvim)); return; #else ! // Clear the command. Needed for when forking+exiting, to avoid part ! // of the argument ending up after the shell prompt. msg_clr_eos_force(); # ifdef GUI_MAY_SPAWN if (!ends_excmd(*eap->arg)) *************** *** 5098,5108 **** fflush(stderr); else if (error_ga.ga_data != NULL) { ! /* avoid putting up a message box with blanks only */ for (p = (char_u *)error_ga.ga_data; *p != NUL; ++p) if (!isspace(*p)) { ! /* Truncate a very long message, it will go off-screen. */ if (STRLEN(p) > 2000) STRCPY(p + 2000 - 14, "...(truncated)"); (void)do_dialog(VIM_ERROR, (char_u *)_("Error"), --- 5097,5107 ---- fflush(stderr); else if (error_ga.ga_data != NULL) { ! // avoid putting up a message box with blanks only for (p = (char_u *)error_ga.ga_data; *p != NUL; ++p) if (!isspace(*p)) { ! // Truncate a very long message, it will go off-screen. if (STRLEN(p) > 2000) STRCPY(p + 2000 - 14, "...(truncated)"); (void)do_dialog(VIM_ERROR, (char_u *)_("Error"), *************** *** 5150,5156 **** update_topline(); validate_cursor(); ! /* Trigger CursorMoved if the cursor moved. */ if (!finish_op && (has_cursormoved() # ifdef FEAT_PROP_POPUP || popup_visible --- 5149,5155 ---- update_topline(); validate_cursor(); ! // Trigger CursorMoved if the cursor moved. if (!finish_op && (has_cursormoved() # ifdef FEAT_PROP_POPUP || popup_visible *************** *** 5190,5196 **** need_cursor_line_redraw = FALSE; } # endif ! update_screen(0); /* may need to update the screen */ setcursor(); out_flush_cursor(TRUE, FALSE); } --- 5189,5195 ---- need_cursor_line_redraw = FALSE; } # endif ! update_screen(0); // may need to update the screen setcursor(); out_flush_cursor(TRUE, FALSE); } *************** *** 5205,5212 **** char_u * get_find_dialog_text( char_u *arg, ! int *wwordp, /* return: TRUE if \< \> found */ ! int *mcasep) /* return: TRUE if \C found */ { char_u *text; --- 5204,5211 ---- char_u * get_find_dialog_text( char_u *arg, ! int *wwordp, // return: TRUE if \< \> found ! int *mcasep) // return: TRUE if \C found { char_u *text; *************** *** 5222,5235 **** int len = (int)STRLEN(text); int i; ! /* Remove "\V" */ if (len >= 2 && STRNCMP(text, "\\V", 2) == 0) { mch_memmove(text, text + 2, (size_t)(len - 1)); len -= 2; } ! /* Recognize "\c" and "\C" and remove. */ if (len >= 2 && *text == '\\' && (text[1] == 'c' || text[1] == 'C')) { *mcasep = (text[1] == 'C'); --- 5221,5234 ---- int len = (int)STRLEN(text); int i; ! // Remove "\V" if (len >= 2 && STRNCMP(text, "\\V", 2) == 0) { mch_memmove(text, text + 2, (size_t)(len - 1)); len -= 2; } ! // Recognize "\c" and "\C" and remove. if (len >= 2 && *text == '\\' && (text[1] == 'c' || text[1] == 'C')) { *mcasep = (text[1] == 'C'); *************** *** 5237,5243 **** len -= 2; } ! /* Recognize "\" and remove. */ if (len >= 4 && STRNCMP(text, "\\<", 2) == 0 && STRNCMP(text + len - 2, "\\>", 2) == 0) --- 5236,5242 ---- len -= 2; } ! // Recognize "\" and remove. if (len >= 4 && STRNCMP(text, "\\<", 2) == 0 && STRNCMP(text + len - 2, "\\>", 2) == 0) *************** *** 5247,5253 **** text[len - 4] = NUL; } ! /* Recognize "\/" or "\?" and remove. */ for (i = 0; i + 1 < len; ++i) if (text[i] == '\\' && (text[i + 1] == '/' || text[i + 1] == '?')) --- 5246,5252 ---- text[len - 4] = NUL; } ! // Recognize "\/" or "\?" and remove. for (i = 0; i + 1 < len; ++i) if (text[i] == '\\' && (text[i + 1] == '/' || text[i + 1] == '?')) *************** *** 5266,5275 **** */ int gui_do_findrepl( ! int flags, /* one of FRD_REPLACE, FRD_FINDNEXT, etc. */ char_u *find_text, char_u *repl_text, ! int down) /* Search downwards. */ { garray_T ga; int i; --- 5265,5274 ---- */ int gui_do_findrepl( ! int flags, // one of FRD_REPLACE, FRD_FINDNEXT, etc. char_u *find_text, char_u *repl_text, ! int down) // Search downwards. { garray_T ga; int i; *************** *** 5279,5291 **** int save_did_emsg = did_emsg; static int busy = FALSE; ! /* When the screen is being updated we should not change buffers and ! * windows structures, it may cause freed memory to be used. Also don't ! * do this recursively (pressing "Find" quickly several times. */ if (updating_screen || busy) return FALSE; ! /* refuse replace when text cannot be changed */ if ((type == FRD_REPLACE || type == FRD_REPLACEALL) && text_locked()) return FALSE; --- 5278,5290 ---- int save_did_emsg = did_emsg; static int busy = FALSE; ! // When the screen is being updated we should not change buffers and ! // windows structures, it may cause freed memory to be used. Also don't ! // do this recursively (pressing "Find" quickly several times. if (updating_screen || busy) return FALSE; ! // refuse replace when text cannot be changed if ((type == FRD_REPLACE || type == FRD_REPLACEALL) && text_locked()) return FALSE; *************** *** 5302,5308 **** ga_concat(&ga, (char_u *)"\\c"); if (flags & FRD_WHOLE_WORD) ga_concat(&ga, (char_u *)"\\<"); ! /* escape / and \ */ p = vim_strsave_escaped(find_text, (char_u *)"/\\"); if (p != NULL) ga_concat(&ga, p); --- 5301,5307 ---- ga_concat(&ga, (char_u *)"\\c"); if (flags & FRD_WHOLE_WORD) ga_concat(&ga, (char_u *)"\\<"); ! // escape slash and backslash p = vim_strsave_escaped(find_text, (char_u *)"/\\"); if (p != NULL) ga_concat(&ga, p); *************** *** 5313,5319 **** if (type == FRD_REPLACEALL) { ga_concat(&ga, (char_u *)"/"); ! /* escape / and \ */ p = vim_strsave_escaped(repl_text, (char_u *)"/\\"); if (p != NULL) ga_concat(&ga, p); --- 5312,5318 ---- if (type == FRD_REPLACEALL) { ga_concat(&ga, (char_u *)"/"); ! // escape slash and backslash p = vim_strsave_escaped(repl_text, (char_u *)"/\\"); if (p != NULL) ga_concat(&ga, p); *************** *** 5324,5331 **** if (type == FRD_REPLACE) { ! /* Do the replacement when the text at the cursor matches. Thus no ! * replacement is done if the cursor was moved! */ regmatch.regprog = vim_regcomp(ga.ga_data, RE_MAGIC + RE_STRING); regmatch.rm_ic = 0; if (regmatch.regprog != NULL) --- 5323,5330 ---- if (type == FRD_REPLACE) { ! // Do the replacement when the text at the cursor matches. Thus no ! // replacement is done if the cursor was moved! regmatch.regprog = vim_regcomp(ga.ga_data, RE_MAGIC + RE_STRING); regmatch.rm_ic = 0; if (regmatch.regprog != NULL) *************** *** 5334,5346 **** if (vim_regexec_nl(®match, p, (colnr_T)0) && regmatch.startp[0] == p) { ! /* Clear the command line to remove any old "No match" ! * error. */ msg_end_prompt(); if (u_save_cursor() == OK) { ! /* A button was pressed thus undo should be synced. */ u_sync(FALSE); del_bytes((long)(regmatch.endp[0] - regmatch.startp[0]), --- 5333,5345 ---- if (vim_regexec_nl(®match, p, (colnr_T)0) && regmatch.startp[0] == p) { ! // Clear the command line to remove any old "No match" ! // error. msg_end_prompt(); if (u_save_cursor() == OK) { ! // A button was pressed thus undo should be synced. u_sync(FALSE); del_bytes((long)(regmatch.endp[0] - regmatch.startp[0]), *************** *** 5356,5362 **** if (type == FRD_REPLACEALL) { ! /* A button was pressed, thus undo should be synced. */ u_sync(FALSE); do_cmdline_cmd(ga.ga_data); } --- 5355,5361 ---- if (type == FRD_REPLACEALL) { ! // A button was pressed, thus undo should be synced. u_sync(FALSE); do_cmdline_cmd(ga.ga_data); } *************** *** 5364,5371 **** { int searchflags = SEARCH_MSG + SEARCH_MARK; ! /* Search for the next match. ! * Don't skip text under cursor for single replace. */ if (type == FRD_REPLACE) searchflags += SEARCH_START; i = msg_scroll; --- 5363,5370 ---- { int searchflags = SEARCH_MSG + SEARCH_MARK; ! // Search for the next match. ! // Don't skip text under cursor for single replace. if (type == FRD_REPLACE) searchflags += SEARCH_START; i = msg_scroll; *************** *** 5375,5400 **** } else { ! /* We need to escape '?' if and only if we are searching in the up ! * direction */ p = vim_strsave_escaped(ga.ga_data, (char_u *)"?"); if (p != NULL) (void)do_search(NULL, '?', p, 1L, searchflags, NULL); vim_free(p); } ! msg_scroll = i; /* don't let an error message set msg_scroll */ } ! /* Don't want to pass did_emsg to other code, it may cause disabling ! * syntax HL if we were busy redrawing. */ did_emsg = save_did_emsg; if (State & (NORMAL | INSERT)) { ! gui_update_screen(); /* update the screen */ ! msg_didout = 0; /* overwrite any message */ ! need_wait_return = FALSE; /* don't wait for return */ } vim_free(ga.ga_data); --- 5374,5399 ---- } else { ! // We need to escape '?' if and only if we are searching in the up ! // direction p = vim_strsave_escaped(ga.ga_data, (char_u *)"?"); if (p != NULL) (void)do_search(NULL, '?', p, 1L, searchflags, NULL); vim_free(p); } ! msg_scroll = i; // don't let an error message set msg_scroll } ! // Don't want to pass did_emsg to other code, it may cause disabling ! // syntax HL if we were busy redrawing. did_emsg = save_did_emsg; if (State & (NORMAL | INSERT)) { ! gui_update_screen(); // update the screen ! msg_didout = 0; // overwrite any message ! need_wait_return = FALSE; // don't wait for return } vim_free(ga.ga_data); *************** *** 5432,5440 **** { char_u *p = cookie; ! /* If Shift held down, change to first file's directory. If the first ! * item is a directory, change to that directory (and let the explorer ! * plugin show the contents). */ if (p != NULL) { if (mch_isdir(p)) --- 5431,5439 ---- { char_u *p = cookie; ! // If Shift held down, change to first file's directory. If the first ! // item is a directory, change to that directory (and let the explorer ! // plugin show the contents). if (p != NULL) { if (mch_isdir(p)) *************** *** 5447,5453 **** vim_free(p); } ! /* Update the screen display */ update_screen(NOT_VALID); # ifdef FEAT_MENU gui_update_menus(0); --- 5446,5452 ---- vim_free(p); } ! // Update the screen display update_screen(NOT_VALID); # ifdef FEAT_MENU gui_update_menus(0); *************** *** 5500,5508 **** if (i > 0) add_to_input_buf((char_u*)" ", 1); ! /* We don't know what command is used thus we can't be sure ! * about which characters need to be escaped. Only escape the ! * most common ones. */ # ifdef BACKSLASH_IN_FILENAME p = vim_strsave_escaped(fnames[i], (char_u *)" \t\"|"); # else --- 5499,5507 ---- if (i > 0) add_to_input_buf((char_u*)" ", 1); ! // We don't know what command is used thus we can't be sure ! // about which characters need to be escaped. Only escape the ! // most common ones. # ifdef BACKSLASH_IN_FILENAME p = vim_strsave_escaped(fnames[i], (char_u *)" \t\"|"); # else *************** *** 5518,5537 **** } else { ! /* Go to the window under mouse cursor, then shorten given "fnames" by ! * current window, because a window can have local current dir. */ gui_wingoto_xy(x, y); shorten_filenames(fnames, count); ! /* If Shift held down, remember the first item. */ if ((modifiers & MOUSE_SHIFT) != 0) p = vim_strsave(fnames[0]); else p = NULL; ! /* Handle the drop, :edit or :split to get to the file. This also ! * frees fnames[]. Skip this if there is only one item, it's a ! * directory and Shift is held down. */ if (count == 1 && (modifiers & MOUSE_SHIFT) != 0 && mch_isdir(fnames[0])) { --- 5517,5536 ---- } else { ! // Go to the window under mouse cursor, then shorten given "fnames" by ! // current window, because a window can have local current dir. gui_wingoto_xy(x, y); shorten_filenames(fnames, count); ! // If Shift held down, remember the first item. if ((modifiers & MOUSE_SHIFT) != 0) p = vim_strsave(fnames[0]); else p = NULL; ! // Handle the drop, :edit or :split to get to the file. This also ! // frees fnames[]. Skip this if there is only one item, it's a ! // directory and Shift is held down. if (count == 1 && (modifiers & MOUSE_SHIFT) != 0 && mch_isdir(fnames[0])) { *** ../vim-8.1.2379/src/gui_at_fs.c 2019-05-24 18:48:36.758128504 +0200 --- src/gui_at_fs.c 2019-12-01 21:55:41.985383432 +0100 *************** *** 43,53 **** #include "vim.h" ! /* Only include this when using the file browser */ #ifdef FEAT_BROWSE ! /* Weird complication: for "make lint" Text.h doesn't combine with Xm.h */ #if defined(FEAT_GUI_MOTIF) && defined(FMT8BIT) # undef FMT8BIT #endif --- 43,53 ---- #include "vim.h" ! // Only include this when using the file browser #ifdef FEAT_BROWSE ! // Weird complication: for "make lint" Text.h doesn't combine with Xm.h #if defined(FEAT_GUI_MOTIF) && defined(FMT8BIT) # undef FMT8BIT #endif *************** *** 56,62 **** # include "gui_at_sb.h" #endif ! /***************** SFinternal.h */ #include #include --- 56,62 ---- # include "gui_at_sb.h" #endif ! ////////////////// SFinternal.h #include #include *************** *** 170,176 **** static int SFstatus = SEL_FILE_NULL; ! /***************** forward declare static functions */ static void SFsetText(char *path); static void SFtextChanged(void); --- 170,176 ---- static int SFstatus = SEL_FILE_NULL; ! ///////////////// forward declare static functions static void SFsetText(char *path); static void SFtextChanged(void); *************** *** 184,190 **** static Boolean SFworkProc(void); static int SFcompareEntries(const void *p, const void *q); ! /***************** xstat.h */ #ifndef S_IXUSR # define S_IXUSR 0100 --- 184,190 ---- static Boolean SFworkProc(void); static int SFcompareEntries(const void *p, const void *q); ! ////////////////// xstat.h #ifndef S_IXUSR # define S_IXUSR 0100 *************** *** 198,204 **** #define S_ISXXX(m) ((m) & (S_IXUSR | S_IXGRP | S_IXOTH)) ! /***************** Path.c */ #include --- 198,204 ---- #define S_ISXXX(m) ((m) & (S_IXUSR | S_IXGRP | S_IXOTH)) ! ////////////////// Path.c #include *************** *** 515,521 **** SFhomeDir.path = SFcurrentPath; SFhomeDir.entries = entries; SFhomeDir.nEntries = i; ! SFhomeDir.vOrigin = 0; /* :-) */ SFhomeDir.nChars = maxChars + 2; SFhomeDir.hOrigin = 0; SFhomeDir.changed = 1; --- 515,521 ---- SFhomeDir.path = SFcurrentPath; SFhomeDir.entries = entries; SFhomeDir.nEntries = i; ! SFhomeDir.vOrigin = 0; // :-) SFhomeDir.nChars = maxChars + 2; SFhomeDir.hOrigin = 0; SFhomeDir.changed = 1; *************** *** 969,975 **** SFdirModTimer, (XtPointer) NULL); } ! /* Return a single character describing what kind of file STATBUF is. */ static char SFstatChar(stat_T *statBuf) --- 969,975 ---- SFdirModTimer, (XtPointer) NULL); } ! // Return a single character describing what kind of file STATBUF is. static char SFstatChar(stat_T *statBuf) *************** *** 981,991 **** #ifdef S_ISSOCK if (S_ISSOCK (statBuf->st_mode)) return '='; ! #endif /* S_ISSOCK */ return ' '; } ! /***************** Draw.c */ #ifdef FEAT_GUI_NEXTAW # include --- 981,991 ---- #ifdef S_ISSOCK if (S_ISSOCK (statBuf->st_mode)) return '='; ! #endif // S_ISSOCK return ' '; } ! ////////////////// Draw.c #ifdef FEAT_GUI_NEXTAW # include *************** *** 1604,1610 **** { int nw; ! /* sanity */ if (SFcurrentInvert[n] != -1) { SFinvertEntry(n); --- 1604,1610 ---- { int nw; ! // sanity if (SFcurrentInvert[n] != -1) { SFinvertEntry(n); *************** *** 1980,1986 **** return True; } ! /***************** Dir.c */ static int SFcompareEntries(const void *p, const void *q) --- 1980,1986 ---- return True; } ! ////////////////// Dir.c static int SFcompareEntries(const void *p, const void *q) *************** *** 2020,2026 **** while ((dp = readdir(dirp))) { ! /* Ignore "." and ".." */ if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; if (i >= Alloc) --- 2020,2026 ---- while ((dp = readdir(dirp))) { ! // Ignore "." and ".." if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; if (i >= Alloc) *************** *** 2051,2057 **** return 0; } ! /***************** SFinternal.h */ #include #include --- 2051,2057 ---- return 0; } ! ////////////////// SFinternal.h #include #include *************** *** 2202,2208 **** XSetForeground(gui.dpy, SFtextGC, fg); XSetForeground(gui.dpy, SFlineGC, fg); ! /* This is an xor GC, so combine the fg and background */ XSetBackground(gui.dpy, SFinvertGC, fg ^ bg); XSetForeground(gui.dpy, SFinvertGC, fg ^ bg); } --- 2202,2208 ---- XSetForeground(gui.dpy, SFtextGC, fg); XSetForeground(gui.dpy, SFlineGC, fg); ! // This is an xor GC, so combine the fg and background XSetBackground(gui.dpy, SFinvertGC, fg ^ bg); XSetForeground(gui.dpy, SFinvertGC, fg ^ bg); } *************** *** 2250,2256 **** XtNtitle, prompt, NULL); ! /* Add WM_DELETE_WINDOW protocol */ XtAppAddActions(XtWidgetToApplicationContext(selFile), actions, XtNumber(actions)); XtOverrideTranslations(selFile, --- 2250,2256 ---- XtNtitle, prompt, NULL); ! // Add WM_DELETE_WINDOW protocol XtAppAddActions(XtWidgetToApplicationContext(selFile), actions, XtNumber(actions)); XtOverrideTranslations(selFile, *************** *** 2522,2528 **** XtSetMappedWhenManaged(selFile, False); XtRealizeWidget(selFile); ! /* Add WM_DELETE_WINDOW protocol */ SFwmDeleteWindow = XInternAtom(SFdisplay, "WM_DELETE_WINDOW", False); XSetWMProtocols(SFdisplay, XtWindow(selFile), &SFwmDeleteWindow, 1); --- 2522,2528 ---- XtSetMappedWhenManaged(selFile, False); XtRealizeWidget(selFile); ! // Add WM_DELETE_WINDOW protocol SFwmDeleteWindow = XInternAtom(SFdisplay, "WM_DELETE_WINDOW", False); XSetWMProtocols(SFdisplay, XtWindow(selFile), &SFwmDeleteWindow, 1); *************** *** 2609,2615 **** XtNstring, &wcbuf, NULL); mbslength = wcstombs(NULL, wcbuf, 0); ! /* Hack: some broken wcstombs() returns zero, just get a large buffer */ if (mbslength == 0 && wcbuf != NULL && wcbuf[0] != 0) mbslength = MAXPATHL; buf=(char *)XtMalloc(mbslength + 1); --- 2609,2615 ---- XtNstring, &wcbuf, NULL); mbslength = wcstombs(NULL, wcbuf, 0); ! // Hack: some broken wcstombs() returns zero, just get a large buffer if (mbslength == 0 && wcbuf != NULL && wcbuf[0] != 0) mbslength = MAXPATHL; buf=(char *)XtMalloc(mbslength + 1); *************** *** 2645,2651 **** guicolor_T fg, guicolor_T bg, guicolor_T scroll_fg, ! guicolor_T scroll_bg) /* The "Scrollbar" group colors */ { static int firstTime = 1; XEvent event; --- 2645,2651 ---- guicolor_T fg, guicolor_T bg, guicolor_T scroll_fg, ! guicolor_T scroll_bg) // The "Scrollbar" group colors { static int firstTime = 1; XEvent event; *************** *** 2731,2734 **** } } } ! #endif /* FEAT_BROWSE */ --- 2731,2734 ---- } } } ! #endif // FEAT_BROWSE *** ../vim-8.1.2379/src/gui_at_sb.c 2019-01-13 23:38:33.391773303 +0100 --- src/gui_at_sb.c 2019-12-01 21:56:52.529000093 +0100 *************** *** 56,64 **** */ ! /* ScrollBar.c */ ! /* created by weissman, Mon Jul 7 13:20:03 1986 */ ! /* converted by swick, Thu Aug 27 1987 */ #include "vim.h" --- 56,64 ---- */ ! // ScrollBar.c ! // created by weissman, Mon Jul 7 13:20:03 1986 ! // converted by swick, Thu Aug 27 1987 #include "vim.h" *************** *** 70,76 **** #include ! /* Private definitions. */ static char defaultTranslations[] = ": NotifyScroll()\n\ --- 70,76 ---- #include ! // Private definitions. static char defaultTranslations[] = ": NotifyScroll()\n\ *************** *** 164,170 **** ScrollbarClassRec vim_scrollbarClassRec = { ! { /* core fields */ /* superclass */ (WidgetClass) &simpleClassRec, /* class_name */ "Scrollbar", /* size */ sizeof(ScrollbarRec), --- 164,170 ---- ScrollbarClassRec vim_scrollbarClassRec = { ! { // core fields /* superclass */ (WidgetClass) &simpleClassRec, /* class_name */ "Scrollbar", /* size */ sizeof(ScrollbarRec), *************** *** 198,210 **** /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL }, ! { /* simple fields */ /* change_sensitive */ XtInheritChangeSensitive, #ifndef OLDXAW /* extension */ NULL #endif }, ! { /* scrollbar fields */ /* empty */ 0 } }; --- 198,210 ---- /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL }, ! { // simple fields /* change_sensitive */ XtInheritChangeSensitive, #ifndef OLDXAW /* extension */ NULL #endif }, ! { // scrollbar fields /* empty */ 0 } }; *************** *** 240,246 **** int fill, int draw_shadow) { ! int tlen = bottom - top; /* length of thumb in pixels */ int sw, margin, floor; int lx, ly, lw, lh; --- 240,246 ---- int fill, int draw_shadow) { ! int tlen = bottom - top; // length of thumb in pixels int sw, margin, floor; int lx, ly, lw, lh; *************** *** 273,296 **** { if (!(sbw->scrollbar.orientation == XtorientHorizontal)) { ! /* Top border */ XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.top_shadow_GC, lx, ly, lx + lw - 1, ly); ! /* Bottom border */ XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.bot_shadow_GC, lx, ly + lh - 1, lx + lw - 1, ly + lh - 1); } else { ! /* Left border */ XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.top_shadow_GC, lx, ly, lx, ly + lh - 1); ! /* Right border */ XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.bot_shadow_GC, lx + lw - 1, ly, lx + lw - 1, ly + lh - 1); --- 273,296 ---- { if (!(sbw->scrollbar.orientation == XtorientHorizontal)) { ! // Top border XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.top_shadow_GC, lx, ly, lx + lw - 1, ly); ! // Bottom border XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.bot_shadow_GC, lx, ly + lh - 1, lx + lw - 1, ly + lh - 1); } else { ! // Left border XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.top_shadow_GC, lx, ly, lx, ly + lh - 1); ! // Right border XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.bot_shadow_GC, lx + lw - 1, ly, lx + lw - 1, ly + lh - 1); *************** *** 306,329 **** if (!(sbw->scrollbar.orientation == XtorientHorizontal)) { ! /* Left border */ XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.top_shadow_GC, lx, ly, lx, ly + lh - 1); ! /* Right border */ XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.bot_shadow_GC, lx + lw - 1, ly, lx + lw - 1, ly + lh - 1); } else { ! /* Top border */ XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.top_shadow_GC, lx, ly, lx + lw - 1, ly); ! /* Bottom border */ XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.bot_shadow_GC, lx, ly + lh - 1, lx + lw - 1, ly + lh - 1); --- 306,329 ---- if (!(sbw->scrollbar.orientation == XtorientHorizontal)) { ! // Left border XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.top_shadow_GC, lx, ly, lx, ly + lh - 1); ! // Right border XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.bot_shadow_GC, lx + lw - 1, ly, lx + lw - 1, ly + lh - 1); } else { ! // Top border XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.top_shadow_GC, lx, ly, lx + lw - 1, ly); ! // Bottom border XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.bot_shadow_GC, lx, ly + lh - 1, lx + lw - 1, ly + lh - 1); *************** *** 336,346 **** } } ! /* Paint the thumb in the area specified by sbw->top and ! sbw->shown. The old area is erased. The painting and ! erasing is done cleverly so that no flickering will occur. */ - static void PaintThumb(ScrollbarWidget sbw) { --- 336,346 ---- } } ! /* ! * Paint the thumb in the area specified by sbw->top and ! * sbw->shown. The old area is erased. The painting and ! * erasing is done cleverly so that no flickering will occur. */ static void PaintThumb(ScrollbarWidget sbw) { *************** *** 369,375 **** if (newbot > oldbot) FillArea(sbw, AT_MAX(newtop, oldbot-1), newbot, 1,0); ! /* Only draw the missing shadows */ FillArea(sbw, newtop, newbot, 0, 1); } } --- 369,375 ---- if (newbot > oldbot) FillArea(sbw, AT_MAX(newtop, oldbot-1), newbot, 1,0); ! // Only draw the missing shadows FillArea(sbw, newtop, newbot, 0, 1); } } *************** *** 408,414 **** point[5].x = thickness / 2; point[5].y = sbw->scrollbar.length - sbw->scrollbar.shadow_width - 1; ! /* horizontal arrows require that x and y coordinates be swapped */ if (sbw->scrollbar.orientation == XtorientHorizontal) { int n; --- 408,414 ---- point[5].x = thickness / 2; point[5].y = sbw->scrollbar.length - sbw->scrollbar.shadow_width - 1; ! // horizontal arrows require that x and y coordinates be swapped if (sbw->scrollbar.orientation == XtorientHorizontal) { int n; *************** *** 420,426 **** point[n].y = swap; } } ! /* draw the up/left arrow */ XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.gc, point, 3, --- 420,426 ---- point[n].y = swap; } } ! // draw the up/left arrow XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.gc, point, 3, *************** *** 433,439 **** sbw->scrollbar.top_shadow_GC, point[0].x, point[0].y, point[2].x, point[2].y); ! /* draw the down/right arrow */ XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.gc, point+3, 3, --- 433,439 ---- sbw->scrollbar.top_shadow_GC, point[0].x, point[0].y, point[2].x, point[2].y); ! // draw the down/right arrow XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw), sbw->scrollbar.gc, point+3, 3, *************** *** 497,504 **** gcValues.fill_style = FillSolid; mask |= GCFillStyle; } ! /* the creation should be non-caching, because */ ! /* we now set and clear clip masks on the gc returned */ sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues); } --- 497,504 ---- gcValues.fill_style = FillSolid; mask |= GCFillStyle; } ! // the creation should be non-caching, because ! // we now set and clear clip masks on the gc returned sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues); } *************** *** 519,526 **** static void Initialize( ! Widget request UNUSED, /* what the client asked for */ ! Widget new, /* what we're going to give him */ ArgList args UNUSED, Cardinal *num_args UNUSED) { --- 519,526 ---- static void Initialize( ! Widget request UNUSED, // what the client asked for ! Widget new, // what we're going to give him ArgList args UNUSED, Cardinal *num_args UNUSED) { *************** *** 551,566 **** Mask *valueMask, XSetWindowAttributes *attributes) { ! /* The Simple widget actually stuffs the value in the valuemask. */ (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize) (w, valueMask, attributes); } static Boolean SetValues( ! Widget current, /* what I am */ ! Widget request UNUSED, /* what he wants me to be */ ! Widget desired, /* what I will become */ ArgList args UNUSED, Cardinal *num_args UNUSED) { --- 551,566 ---- Mask *valueMask, XSetWindowAttributes *attributes) { ! // The Simple widget actually stuffs the value in the valuemask. (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize) (w, valueMask, attributes); } static Boolean SetValues( ! Widget current, // what I am ! Widget request UNUSED, // what he wants me to be ! Widget desired, // what I will become ArgList args UNUSED, Cardinal *num_args UNUSED) { *************** *** 600,607 **** static void Resize(Widget w) { ! /* ForgetGravity has taken care of background, but thumb may ! * have to move as a result of the new size. */ SetDimensions ((ScrollbarWidget) w); Redisplay(w, (XEvent*) NULL, (Region)NULL); } --- 600,607 ---- static void Resize(Widget w) { ! // ForgetGravity has taken care of background, but thumb may ! // have to move as a result of the new size. SetDimensions ((ScrollbarWidget) w); Redisplay(w, (XEvent*) NULL, (Region)NULL); } *************** *** 633,643 **** if (region == NULL || XRectInRegion (region, x, y, width, height) != RectangleOut) { ! /* Forces entire thumb to be painted. */ sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1); PaintThumb (sbw); } ! /* we'd like to be region aware here!!!! */ PaintArrows(sbw); } --- 633,643 ---- if (region == NULL || XRectInRegion (region, x, y, width, height) != RectangleOut) { ! // Forces entire thumb to be painted. sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1); PaintThumb (sbw); } ! // we'd like to be region aware here!!!! PaintArrows(sbw); } *************** *** 693,699 **** { struct EventData *eventData = (struct EventData*)args; ! return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */ || CompareEvents(event, eventData->oldEvent)); } --- 693,699 ---- { struct EventData *eventData = (struct EventData*)args; ! return ((++eventData->count == QLength(dpy)) // since PeekIf blocks || CompareEvents(event, eventData->oldEvent)); } *************** *** 719,727 **** static void ExtractPosition( XEvent *event, ! Position *x, /* RETURN */ ! Position *y, /* RETURN */ ! unsigned int *state) /* RETURN */ { switch (event->type) { --- 719,727 ---- static void ExtractPosition( XEvent *event, ! Position *x, // RETURN ! Position *y, // RETURN ! unsigned int *state) // RETURN { switch (event->type) { *************** *** 771,778 **** ExtractPosition(event, &x, &y, (unsigned int *)NULL); loc = PICKLENGTH(sbw, x, y); ! /* if the motion event puts the pointer in thumb, call Move and Notify */ ! /* also call Move and Notify if we're already in continuous scroll mode */ if (sbw->scrollbar.scroll_mode == SMODE_CONT || (loc >= sbw->scrollbar.topLoc && loc <= sbw->scrollbar.topLoc + (int)sbw->scrollbar.shownLength)) --- 771,778 ---- ExtractPosition(event, &x, &y, (unsigned int *)NULL); loc = PICKLENGTH(sbw, x, y); ! // if the motion event puts the pointer in thumb, call Move and Notify ! // also call Move and Notify if we're already in continuous scroll mode if (sbw->scrollbar.scroll_mode == SMODE_CONT || (loc >= sbw->scrollbar.topLoc && loc <= sbw->scrollbar.topLoc + (int)sbw->scrollbar.shownLength)) *************** *** 876,882 **** { ScrollbarWidget sbw = (ScrollbarWidget) w; ! if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if scroll continuous */ return; if (LookAhead(w, event)) --- 876,882 ---- { ScrollbarWidget sbw = (ScrollbarWidget) w; ! if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if scroll continuous return; if (LookAhead(w, event)) *************** *** 900,906 **** int call_data = 0; unsigned int state; ! if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if scroll continuous */ return; if (LookAhead (w, event)) --- 900,906 ---- int call_data = 0; unsigned int state; ! if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if scroll continuous return; if (LookAhead (w, event)) *************** *** 968,974 **** if (call_data) XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data); ! /* establish autoscroll */ if (delay) sbw->scrollbar.timer_id = XtAppAddTimeOut(XtWidgetToApplicationContext(w), --- 968,974 ---- if (call_data) XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data); ! // establish autoscroll if (delay) sbw->scrollbar.timer_id = XtAppAddTimeOut(XtWidgetToApplicationContext(w), *************** *** 985,993 **** ScrollbarWidget sbw = (ScrollbarWidget) w; sbw->scrollbar.scroll_mode = SMODE_NONE; ! /* no need to remove any autoscroll timeout; it will no-op */ ! /* because the scroll_mode is SMODE_NONE */ ! /* but be sure to remove timeout in destroy proc */ } static float --- 985,993 ---- ScrollbarWidget sbw = (ScrollbarWidget) w; sbw->scrollbar.scroll_mode = SMODE_NONE; ! // no need to remove any autoscroll timeout; it will no-op ! // because the scroll_mode is SMODE_NONE ! // but be sure to remove timeout in destroy proc } static float *************** *** 1016,1022 **** float top; char old_mode = sbw->scrollbar.scroll_mode; ! sbw->scrollbar.scroll_mode = SMODE_CONT; /* indicate continuous scroll */ if (LookAhead(w, event)) return; --- 1016,1022 ---- float top; char old_mode = sbw->scrollbar.scroll_mode; ! sbw->scrollbar.scroll_mode = SMODE_CONT; // indicate continuous scroll if (LookAhead(w, event)) return; *************** *** 1028,1034 **** top = FractionLoc(sbw, x, y); ! if (old_mode != SMODE_CONT) /* start dragging: set offset */ { if (event->xbutton.button == Button2) sbw->scrollbar.scroll_off = sbw->scrollbar.shown / 2.; --- 1028,1034 ---- top = FractionLoc(sbw, x, y); ! if (old_mode != SMODE_CONT) // start dragging: set offset { if (event->xbutton.button == Button2) sbw->scrollbar.scroll_off = sbw->scrollbar.shown / 2.; *************** *** 1045,1051 **** sbw->scrollbar.top = top; PaintThumb(sbw); ! XFlush(XtDisplay(w)); /* re-draw it before Notifying */ } --- 1045,1051 ---- sbw->scrollbar.top = top; PaintThumb(sbw); ! XFlush(XtDisplay(w)); // re-draw it before Notifying } *************** *** 1057,1064 **** Cardinal *num_params UNUSED) { ScrollbarWidget sbw = (ScrollbarWidget)w; ! /* Use a union to avoid a warning for the weird conversion from float to ! * XtPointer. Comes from Xaw/Scrollbar.c. */ union { XtPointer xtp; float xtf; --- 1057,1064 ---- Cardinal *num_params UNUSED) { ScrollbarWidget sbw = (ScrollbarWidget)w; ! // Use a union to avoid a warning for the weird conversion from float to ! // XtPointer. Comes from Xaw/Scrollbar.c. union { XtPointer xtp; float xtf; *************** *** 1067,1075 **** if (LookAhead(w, event)) return; ! /* thumbProc is not pretty, but is necessary for backwards ! compatibility on those architectures for which it work{s,ed}; ! the intent is to pass a (truncated) float by value. */ xtpf.xtf = sbw->scrollbar.top; XtCallCallbacks(w, XtNthumbProc, xtpf.xtp); XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top); --- 1067,1075 ---- if (LookAhead(w, event)) return; ! // thumbProc is not pretty, but is necessary for backwards ! // compatibility on those architectures for which it work{s,ed}; ! // the intent is to pass a (truncated) float by value. xtpf.xtf = sbw->scrollbar.top; XtCallCallbacks(w, XtNthumbProc, xtpf.xtp); XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top); *************** *** 1137,1143 **** bot = sbw->scrollbar.top_shadow_GC; } ! /* top-left shadow */ if ((region == NULL) || (XRectInRegion (region, 0, 0, w, s) != RectangleOut) || (XRectInRegion (region, 0, 0, s, h) != RectangleOut)) --- 1137,1143 ---- bot = sbw->scrollbar.top_shadow_GC; } ! // top-left shadow if ((region == NULL) || (XRectInRegion (region, 0, 0, w, s) != RectangleOut) || (XRectInRegion (region, 0, 0, s, h) != RectangleOut)) *************** *** 1151,1157 **** XFillPolygon (dpy, win, top, pt, 6, Complex, CoordModeOrigin); } ! /* bottom-right shadow */ if ((region == NULL) || (XRectInRegion (region, 0, hms, w, s) != RectangleOut) || (XRectInRegion (region, wms, 0, s, h) != RectangleOut)) --- 1151,1157 ---- XFillPolygon (dpy, win, top, pt, 6, Complex, CoordModeOrigin); } ! // bottom-right shadow if ((region == NULL) || (XRectInRegion (region, 0, hms, w, s) != RectangleOut) || (XRectInRegion (region, wms, 0, s, h) != RectangleOut)) *************** *** 1176,1182 **** { ScrollbarWidget sbw = (ScrollbarWidget) w; ! if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if still thumbing */ return; sbw->scrollbar.max = (max > 1.0) ? 1.0 : --- 1176,1182 ---- { ScrollbarWidget sbw = (ScrollbarWidget) w; ! if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if still thumbing return; sbw->scrollbar.max = (max > 1.0) ? 1.0 : *** ../vim-8.1.2379/src/gui_athena.c 2018-11-16 16:21:01.637310049 +0100 --- src/gui_athena.c 2019-12-01 21:58:24.516513399 +0100 *************** *** 34,40 **** # include # include # include ! #endif /* FEAT_GUI_NEXTAW */ #ifndef FEAT_GUI_NEXTAW # include "gui_at_sb.h" --- 34,40 ---- # include # include # include ! #endif // FEAT_GUI_NEXTAW #ifndef FEAT_GUI_NEXTAW # include "gui_at_sb.h" *************** *** 46,54 **** Widget textArea = (Widget)0; #ifdef FEAT_MENU static Widget menuBar = (Widget)0; ! static XtIntervalId timer = 0; /* 0 = expired, otherwise active */ ! /* Used to figure out menu ordering */ static vimmenu_T *a_cur_menu = NULL; static Cardinal athena_calculate_ins_pos(Widget); --- 46,54 ---- Widget textArea = (Widget)0; #ifdef FEAT_MENU static Widget menuBar = (Widget)0; ! static XtIntervalId timer = 0; // 0 = expired, otherwise active ! // Used to figure out menu ordering static vimmenu_T *a_cur_menu = NULL; static Cardinal athena_calculate_ins_pos(Widget); *************** *** 96,102 **** if (sb == NULL) return; ! else if (sb->wp != NULL) /* Left or right scrollbar */ { /* * Careful: need to get scrollbar info out of first (left) scrollbar --- 96,102 ---- if (sb == NULL) return; ! else if (sb->wp != NULL) // Left or right scrollbar { /* * Careful: need to get scrollbar info out of first (left) scrollbar *************** *** 105,111 **** */ sb_info = &sb->wp->w_scrollbars[0]; } ! else /* Bottom scrollbar */ sb_info = sb; value = (long)(*((float *)call_data) * (float)(sb_info->max + 1) + 0.001); --- 105,111 ---- */ sb_info = &sb->wp->w_scrollbars[0]; } ! else // Bottom scrollbar sb_info = sb; value = (long)(*((float *)call_data) * (float)(sb_info->max + 1) + 0.001); *************** *** 134,140 **** if (sb == NULL) return; ! if (sb->wp != NULL) /* Left or right scrollbar */ { /* * Careful: need to get scrollbar info out of first (left) scrollbar --- 134,140 ---- if (sb == NULL) return; ! if (sb->wp != NULL) // Left or right scrollbar { /* * Careful: need to get scrollbar info out of first (left) scrollbar *************** *** 144,150 **** sb_info = &sb->wp->w_scrollbars[0]; if (sb_info->size > 5) ! page = sb_info->size - 2; /* use two lines of context */ else page = sb_info->size; #ifdef FEAT_GUI_NEXTAW --- 144,150 ---- sb_info = &sb->wp->w_scrollbars[0]; if (sb_info->size > 5) ! page = sb_info->size - 2; // use two lines of context else page = sb_info->size; #ifdef FEAT_GUI_NEXTAW *************** *** 177,183 **** } #endif } ! else /* Bottom scrollbar */ { sb_info = sb; #ifdef FEAT_GUI_NEXTAW --- 177,183 ---- } #endif } ! else // Bottom scrollbar { sb_info = sb; #ifdef FEAT_GUI_NEXTAW *************** *** 194,207 **** data = 1; } #endif ! if (data < -1) /* page-width left */ { if (sb->size > 8) data = -(sb->size - 5); else data = -sb->size; } ! else if (data > 1) /* page-width right */ { if (sb->size > 8) data = (sb->size - 5); --- 194,207 ---- data = 1; } #endif ! if (data < -1) // page-width left { if (sb->size > 8) data = -(sb->size - 5); else data = -sb->size; } ! else if (data > 1) // page-width right { if (sb->size > 8) data = (sb->size - 5); *************** *** 216,223 **** else if (value < 0) value = 0; ! /* Update the bottom scrollbar an extra time (why is this needed?? */ ! if (sb->wp == NULL) /* Bottom scrollbar */ gui_mch_set_scrollbar_thumb(sb, value, sb->size, sb->max); gui_drag_scrollbar(sb, value, FALSE); --- 216,223 ---- else if (value < 0) value = 0; ! // Update the bottom scrollbar an extra time (why is this needed?? ! if (sb->wp == NULL) // Bottom scrollbar gui_mch_set_scrollbar_thumb(sb, value, sb->size, sb->max); gui_drag_scrollbar(sb, value, FALSE); *************** *** 235,241 **** */ gui.border_offset = gui.border_width; ! /* The form containing all the other widgets */ vimForm = XtVaCreateManagedWidget("vimForm", formWidgetClass, vimShell, XtNborderWidth, 0, --- 235,241 ---- */ gui.border_offset = gui.border_width; ! // The form containing all the other widgets vimForm = XtVaCreateManagedWidget("vimForm", formWidgetClass, vimShell, XtNborderWidth, 0, *************** *** 243,249 **** gui_athena_scroll_colors(vimForm); #ifdef FEAT_MENU ! /* The top menu bar */ menuBar = XtVaCreateManagedWidget("menuBar", boxWidgetClass, vimForm, XtNresizable, True, --- 243,249 ---- gui_athena_scroll_colors(vimForm); #ifdef FEAT_MENU ! // The top menu bar menuBar = XtVaCreateManagedWidget("menuBar", boxWidgetClass, vimForm, XtNresizable, True, *************** *** 259,266 **** #endif #ifdef FEAT_TOOLBAR ! /* Don't create it Managed, it will be managed when creating the first ! * item. Otherwise an empty toolbar shows up. */ toolBar = XtVaCreateWidget("toolBar", boxWidgetClass, vimForm, XtNresizable, True, --- 259,266 ---- #endif #ifdef FEAT_TOOLBAR ! // Don't create it Managed, it will be managed when creating the first ! // item. Otherwise an empty toolbar shows up. toolBar = XtVaCreateWidget("toolBar", boxWidgetClass, vimForm, XtNresizable, True, *************** *** 276,282 **** gui_athena_menu_colors(toolBar); #endif ! /* The text area. */ textArea = XtVaCreateManagedWidget("textArea", coreWidgetClass, vimForm, XtNresizable, True, --- 276,282 ---- gui_athena_menu_colors(toolBar); #endif ! // The text area. textArea = XtVaCreateManagedWidget("textArea", coreWidgetClass, vimForm, XtNresizable, True, *************** *** 315,321 **** XtNumber(pullAction)); #endif ! /* Pretend we don't have input focus, we will get an event if we do. */ gui.in_focus = FALSE; } --- 315,321 ---- XtNumber(pullAction)); #endif ! // Pretend we don't have input focus, we will get an event if we do. gui.in_focus = FALSE; } *************** *** 352,361 **** to.addr = (XtPointer)&font; to.size = sizeof(XFontStruct *); #endif ! /* Assumption: The menuBar children will use the same font as the ! * pulldown menu items AND they will all be of type ! * XtNfont. ! */ XtVaGetValues(menuBar, XtNchildren, &children, XtNnumChildren, &num_children, NULL); --- 352,360 ---- to.addr = (XtPointer)&font; to.size = sizeof(XFontStruct *); #endif ! // Assumption: The menuBar children will use the same font as the ! // pulldown menu items AND they will all be of type ! // XtNfont. XtVaGetValues(menuBar, XtNchildren, &children, XtNnumChildren, &num_children, NULL); *************** *** 369,375 **** #endif ) == False) return None; ! /* "font" should now contain data */ } else #ifdef FONTSET_ALWAYS --- 368,374 ---- #endif ) == False) return None; ! // "font" should now contain data } else #ifdef FONTSET_ALWAYS *************** *** 449,466 **** static void get_toolbar_pixmap(vimmenu_T *menu, Pixmap *sen) { ! char_u buf[MAXPATHL]; /* buffer storing expanded pathname */ ! char **xpm = NULL; /* xpm array */ ! buf[0] = NUL; /* start with NULL path */ if (menu->iconfile != NULL) { ! /* Use the "icon=" argument. */ gui_find_iconfile(menu->iconfile, buf, "xpm"); createXpmImages(buf, NULL, sen); ! /* If it failed, try using the menu name. */ if (*sen == (Pixmap)0 && gui_find_bitmap(menu->name, buf, "xpm") == OK) createXpmImages(buf, NULL, sen); if (*sen != (Pixmap)0) --- 448,465 ---- static void get_toolbar_pixmap(vimmenu_T *menu, Pixmap *sen) { ! char_u buf[MAXPATHL]; // buffer storing expanded pathname ! char **xpm = NULL; // xpm array ! buf[0] = NUL; // start with NULL path if (menu->iconfile != NULL) { ! // Use the "icon=" argument. gui_find_iconfile(menu->iconfile, buf, "xpm"); createXpmImages(buf, NULL, sen); ! // If it failed, try using the menu name. if (*sen == (Pixmap)0 && gui_find_bitmap(menu->name, buf, "xpm") == OK) createXpmImages(buf, NULL, sen); if (*sen != (Pixmap)0) *************** *** 511,517 **** &color[TOP_SHADOW].pixel, &color[HIGHLIGHT].pixel); ! /* Setup the color substitution table */ attrs.valuemask = XpmColorSymbols; attrs.colorsymbols = color; attrs.numsymbols = 5; --- 510,516 ---- &color[TOP_SHADOW].pixel, &color[HIGHLIGHT].pixel); ! // Setup the color substitution table attrs.valuemask = XpmColorSymbols; attrs.colorsymbols = color; attrs.numsymbols = 5; *************** *** 519,525 **** screenNum = DefaultScreen(gui.dpy); rootWindow = RootWindow(gui.dpy, screenNum); ! /* Create the "sensitive" pixmap */ if (xpm != NULL) status = XpmCreatePixmapFromData(gui.dpy, rootWindow, xpm, &map, &mask, &attrs); --- 518,524 ---- screenNum = DefaultScreen(gui.dpy); rootWindow = RootWindow(gui.dpy, screenNum); ! // Create the "sensitive" pixmap if (xpm != NULL) status = XpmCreatePixmapFromData(gui.dpy, rootWindow, xpm, &map, &mask, &attrs); *************** *** 532,544 **** GC back_gc; GC mask_gc; ! /* Need to create new Pixmaps with the mask applied. */ gcvalues.foreground = color[BACKGROUND].pixel; back_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues); mask_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues); XSetClipMask(gui.dpy, mask_gc, mask); ! /* Create the "sensitive" pixmap. */ *sen = XCreatePixmap(gui.dpy, rootWindow, attrs.width, attrs.height, DefaultDepth(gui.dpy, screenNum)); --- 531,543 ---- GC back_gc; GC mask_gc; ! // Need to create new Pixmaps with the mask applied. gcvalues.foreground = color[BACKGROUND].pixel; back_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues); mask_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues); XSetClipMask(gui.dpy, mask_gc, mask); ! // Create the "sensitive" pixmap. *sen = XCreatePixmap(gui.dpy, rootWindow, attrs.width, attrs.height, DefaultDepth(gui.dpy, screenNum)); *************** *** 567,573 **** Dimension border; int height; ! if (!XtIsManaged(toolBar)) /* nothing to do */ return; XtUnmanageChild(toolBar); XtVaGetValues(toolBar, --- 566,572 ---- Dimension border; int height; ! if (!XtIsManaged(toolBar)) // nothing to do return; XtUnmanageChild(toolBar); XtVaGetValues(toolBar, *************** *** 602,608 **** NULL); XtManageChild(textArea); #ifdef FEAT_TOOLBAR ! /* Give keyboard focus to the textArea instead of the toolbar. */ gui_mch_reset_focus(); #endif } --- 601,607 ---- NULL); XtManageChild(textArea); #ifdef FEAT_TOOLBAR ! // Give keyboard focus to the textArea instead of the toolbar. gui_mch_reset_focus(); #endif } *************** *** 686,692 **** XtUnmanageChild(menuBar); XtVaGetValues(menuBar, XtNborderWidth, &border, NULL); ! /* avoid trouble when there are no menu items, and h is 1 */ height = h - 2 * border; if (height < 0) height = 1; --- 685,691 ---- XtUnmanageChild(menuBar); XtVaGetValues(menuBar, XtNborderWidth, &border, NULL); ! // avoid trouble when there are no menu items, and h is 1 height = h - 2 * border; if (height < 0) height = 1; *************** *** 709,727 **** static Cardinal athena_calculate_ins_pos(Widget widget) { ! /* Assume that if the parent of the vimmenu_T is NULL, then we can get ! * to this menu by traversing "next", starting at "root_menu". ! * ! * This holds true for popup menus, toolbar, and toplevel menu items. ! */ ! /* Popup menus: "id" is NULL. Only submenu_id is valid */ ! /* Menus that are not toplevel: "parent" will be non-NULL, "id" & ! * "submenu_id" will be non-NULL. ! */ ! /* Toplevel menus: "parent" is NULL, id is the widget of the menu item */ WidgetList children; Cardinal num_children = 0; --- 708,724 ---- static Cardinal athena_calculate_ins_pos(Widget widget) { ! // Assume that if the parent of the vimmenu_T is NULL, then we can get ! // to this menu by traversing "next", starting at "root_menu". ! // ! // This holds true for popup menus, toolbar, and toplevel menu items. ! // Popup menus: "id" is NULL. Only submenu_id is valid ! // Menus that are not toplevel: "parent" will be non-NULL, "id" & ! // "submenu_id" will be non-NULL. ! // Toplevel menus: "parent" is NULL, id is the widget of the menu item WidgetList children; Cardinal num_children = 0; *************** *** 793,799 **** gui_athena_menu_colors(menu->submenu_id); gui_athena_menu_font(menu->submenu_id); ! /* Don't update the menu height when it was set at a fixed value */ if (!gui.menu_height_fixed) { /* --- 790,796 ---- gui_athena_menu_colors(menu->submenu_id); gui_athena_menu_font(menu->submenu_id); ! // Don't update the menu height when it was set at a fixed value if (!gui.menu_height_fixed) { /* *************** *** 827,835 **** XtVaSetValues(menu->id, XtNrightBitmap, pullerBitmap, NULL); ! /* If there are other menu items that are not pulldown menus, ! * we need to adjust the right margins of those, too. ! */ { WidgetList children; Cardinal num_children; --- 824,831 ---- XtVaSetValues(menu->id, XtNrightBitmap, pullerBitmap, NULL); ! // If there are other menu items that are not pulldown menus, ! // we need to adjust the right margins of those, too. { WidgetList children; Cardinal num_children; *************** *** 865,875 **** a_cur_menu = NULL; } ! /* Used to determine whether a SimpleMenu has pulldown entries. ! * ! * "id" is the parent of the menu items. ! * Ignore widget "ignore" in the pane. ! */ static Boolean gui_athena_menu_has_submenus(Widget id, Widget ignore) { --- 861,870 ---- a_cur_menu = NULL; } ! // Used to determine whether a SimpleMenu has pulldown entries. ! // ! // "id" is the parent of the menu items. ! // Ignore widget "ignore" in the pane. static Boolean gui_athena_menu_has_submenus(Widget id, Widget ignore) { *************** *** 900,907 **** { XtUnmanageChild(id); XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL); ! /* We should force the widget to recalculate its ! * geometry now. */ XtManageChild(id); } else --- 895,902 ---- { XtUnmanageChild(id); XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL); ! // We should force the widget to recalculate its ! // geometry now. XtManageChild(id); } else *************** *** 929,935 **** if (has_submenu(id)) XtVaSetValues(id, XtNrightBitmap, pullerBitmap, NULL); ! /* Force the widget to recalculate its geometry now. */ if (managed) XtManageChild(id); } --- 924,930 ---- if (has_submenu(id)) XtVaSetValues(id, XtNrightBitmap, pullerBitmap, NULL); ! // Force the widget to recalculate its geometry now. if (managed) XtManageChild(id); } *************** *** 953,962 **** gui_mch_submenu_change(root_menu, FALSE); { ! /* Iterate through the menubar menu items and get the height of ! * each one. The menu bar height is set to the maximum of all ! * the heights. ! */ vimmenu_T *mp; int max_height = 9999; --- 948,956 ---- gui_mch_submenu_change(root_menu, FALSE); { ! // Iterate through the menubar menu items and get the height of ! // each one. The menu bar height is set to the maximum of all ! // the heights. vimmenu_T *mp; int max_height = 9999; *************** *** 975,981 **** } if (max_height != 9999) { ! /* Don't update the menu height when it was set at a fixed value */ if (!gui.menu_height_fixed) { Dimension space, border; --- 969,975 ---- } if (max_height != 9999) { ! // Don't update the menu height when it was set at a fixed value if (!gui.menu_height_fixed) { Dimension space, border; *************** *** 988,999 **** } } } ! /* Now, to simulate the window being resized. Only, this ! * will resize the window to its current state. ! * ! * There has to be a better way, but I do not see one at this time. ! * (David Harrison) ! */ { Position w, h; --- 982,992 ---- } } } ! // Now, to simulate the window being resized. Only, this ! // will resize the window to its current state. ! // ! // There has to be a better way, but I do not see one at this time. ! // (David Harrison) { Position w, h; *************** *** 1048,1054 **** static void gui_mch_submenu_change( vimmenu_T *menu, ! int colors) /* TRUE for colors, FALSE for font */ { vimmenu_T *mp; --- 1041,1047 ---- static void gui_mch_submenu_change( vimmenu_T *menu, ! int colors) // TRUE for colors, FALSE for font { vimmenu_T *mp; *************** *** 1060,1067 **** { gui_athena_menu_colors(mp->id); #ifdef FEAT_TOOLBAR ! /* For a toolbar item: Free the pixmap and allocate a new one, ! * so that the background color is right. */ if (mp->image != (Pixmap)0) { XFreePixmap(gui.dpy, mp->image); --- 1053,1060 ---- { gui_athena_menu_colors(mp->id); #ifdef FEAT_TOOLBAR ! // For a toolbar item: Free the pixmap and allocate a new one, ! // so that the background color is right. if (mp->image != (Pixmap)0) { XFreePixmap(gui.dpy, mp->image); *************** *** 1071,1077 **** } # ifdef FEAT_BEVAL_GUI ! /* If we have a tooltip, then we need to change its colors */ if (mp->tip != NULL) { Arg args[2]; --- 1064,1070 ---- } # ifdef FEAT_BEVAL_GUI ! // If we have a tooltip, then we need to change its colors if (mp->tip != NULL) { Arg args[2]; *************** *** 1089,1097 **** { gui_athena_menu_font(mp->id); #ifdef FEAT_BEVAL_GUI ! /* If we have a tooltip, then we need to change its font */ ! /* Assume XtNinternational == True (in createBalloonEvalWindow) ! */ if (mp->tip != NULL) { Arg args[1]; --- 1082,1089 ---- { gui_athena_menu_font(mp->id); #ifdef FEAT_BEVAL_GUI ! // If we have a tooltip, then we need to change its font ! // Assume XtNinternational == True (in createBalloonEvalWindow) if (mp->tip != NULL) { Arg args[1]; *************** *** 1106,1112 **** if (mp->children != NULL) { ! /* Set the colors/font for the tear off widget */ if (mp->submenu_id != (Widget)0) { if (colors) --- 1098,1104 ---- if (mp->children != NULL) { ! // Set the colors/font for the tear off widget if (mp->submenu_id != (Widget)0) { if (colors) *************** *** 1114,1120 **** else gui_athena_menu_font(mp->submenu_id); } ! /* Set the colors for the children */ gui_mch_submenu_change(mp->children, colors); } } --- 1106,1112 ---- else gui_athena_menu_font(mp->submenu_id); } ! // Set the colors for the children gui_mch_submenu_change(mp->children, colors); } } *************** *** 1171,1188 **** } XtSetArg(args[n], XtNhighlightThickness, 0); n++; type = commandWidgetClass; ! /* TODO: figure out the position in the toolbar? ! * This currently works fine for the default toolbar, but ! * what if we add/remove items during later runtime? ! */ ! ! /* NOTE: "idx" isn't used here. The position is calculated by ! * athena_calculate_ins_pos(). The position it calculates ! * should be equal to "idx". ! */ ! /* TODO: Could we just store "idx" and use that as the child ! * placement? ! */ if (menu->id == NULL) { --- 1163,1177 ---- } XtSetArg(args[n], XtNhighlightThickness, 0); n++; type = commandWidgetClass; ! // TODO: figure out the position in the toolbar? ! // This currently works fine for the default toolbar, but ! // what if we add/remove items during later runtime? ! ! // NOTE: "idx" isn't used here. The position is calculated by ! // athena_calculate_ins_pos(). The position it calculates ! // should be equal to "idx". ! // TODO: Could we just store "idx" and use that as the child ! // placement? if (menu->id == NULL) { *************** *** 1206,1215 **** gui_mch_show_toolbar(TRUE); gui.toolbar_height = gui_mch_compute_toolbar_height(); return; ! } /* toolbar menu item */ # endif ! /* Add menu separator */ if (menu_is_separator(menu->name)) { menu->submenu_id = (Widget)0; --- 1195,1204 ---- gui_mch_show_toolbar(TRUE); gui.toolbar_height = gui_mch_compute_toolbar_height(); return; ! } // toolbar menu item # endif ! // Add menu separator if (menu_is_separator(menu->name)) { menu->submenu_id = (Widget)0; *************** *** 1235,1244 **** if (menu->id == (Widget)0) return; ! /* If there are other "pulldown" items in this pane, then adjust ! * the right margin to accommodate the arrow pixmap, otherwise ! * the right margin will be the same as the left margin. ! */ { Dimension left_margin; --- 1224,1232 ---- if (menu->id == (Widget)0) return; ! // If there are other "pulldown" items in this pane, then adjust ! // the right margin to accommodate the arrow pixmap, otherwise ! // the right margin will be the same as the left margin. { Dimension left_margin; *************** *** 1263,1278 **** void gui_mch_show_toolbar(int showit) { ! Cardinal numChildren; /* how many children toolBar has */ if (toolBar == (Widget)0) return; XtVaGetValues(toolBar, XtNnumChildren, &numChildren, NULL); if (showit && numChildren > 0) { ! /* Assume that we want to show the toolbar if p_toolbar contains valid ! * option settings, therefore p_toolbar must not be NULL. ! */ WidgetList children; XtVaGetValues(toolBar, XtNchildren, &children, NULL); --- 1251,1265 ---- void gui_mch_show_toolbar(int showit) { ! Cardinal numChildren; // how many children toolBar has if (toolBar == (Widget)0) return; XtVaGetValues(toolBar, XtNnumChildren, &numChildren, NULL); if (showit && numChildren > 0) { ! // Assume that we want to show the toolbar if p_toolbar contains valid ! // option settings, therefore p_toolbar must not be NULL. WidgetList children; XtVaGetValues(toolBar, XtNchildren, &children, NULL); *************** *** 1296,1307 **** for (toolbar = root_menu; toolbar; toolbar = toolbar->next) if (menu_is_toolbar(toolbar->dname)) break; ! /* Assumption: toolbar is NULL if there is no toolbar, ! * otherwise it contains the toolbar menu structure. ! * ! * Assumption: "numChildren" == the number of items in the list ! * of items beginning with toolbar->children. ! */ if (toolbar) { for (cur = toolbar->children; cur; cur = cur->next) --- 1283,1293 ---- for (toolbar = root_menu; toolbar; toolbar = toolbar->next) if (menu_is_toolbar(toolbar->dname)) break; ! // Assumption: toolbar is NULL if there is no toolbar, ! // otherwise it contains the toolbar menu structure. ! // ! // Assumption: "numChildren" == the number of items in the list ! // of items beginning with toolbar->children. if (toolbar) { for (cur = toolbar->children; cur; cur = cur->next) *************** *** 1309,1317 **** Arg args[2]; int n = 0; ! /* Enable/Disable tooltip (OK to enable while currently ! * enabled) ! */ if (cur->tip != NULL) (*action)(cur->tip); if (text == 1) --- 1295,1302 ---- Arg args[2]; int n = 0; ! // Enable/Disable tooltip (OK to enable while currently ! // enabled) if (cur->tip != NULL) (*action)(cur->tip); if (text == 1) *************** *** 1387,1398 **** int gui_mch_compute_toolbar_height(void) { ! Dimension height; /* total Toolbar height */ ! Dimension whgt; /* height of each widget */ ! Dimension marginHeight; /* XmNmarginHeight of toolBar */ ! Dimension shadowThickness; /* thickness of Xtparent(toolBar) */ ! WidgetList children; /* list of toolBar's children */ ! Cardinal numChildren; /* how many children toolBar has */ int i; height = 0; --- 1372,1383 ---- int gui_mch_compute_toolbar_height(void) { ! Dimension height; // total Toolbar height ! Dimension whgt; // height of each widget ! Dimension marginHeight; // XmNmarginHeight of toolBar ! Dimension shadowThickness; // thickness of Xtparent(toolBar) ! WidgetList children; // list of toolBar's children ! Cardinal numChildren; // how many children toolBar has int i; height = 0; *************** *** 1438,1444 **** void gui_mch_toggle_tearoffs(int enable UNUSED) { ! /* no tearoff menus */ } void --- 1423,1429 ---- void gui_mch_toggle_tearoffs(int enable UNUSED) { ! // no tearoff menus } void *************** *** 1464,1486 **** { Widget parent; ! /* There is no item for the toolbar. */ if (menu->id == (Widget)0) return; parent = XtParent(menu->id); ! /* When removing the last "pulldown" menu item from a pane, adjust the ! * right margins of the remaining widgets. ! */ if (menu->submenu_id != (Widget)0) { ! /* Go through the menu items in the parent of this item and ! * adjust their margins, if necessary. ! * This takes care of the case when we delete the last menu item in a ! * pane that has a submenu. In this case, there will be no arrow ! * pixmaps shown anymore. ! */ { WidgetList children; Cardinal num_children; --- 1449,1469 ---- { Widget parent; ! // There is no item for the toolbar. if (menu->id == (Widget)0) return; parent = XtParent(menu->id); ! // When removing the last "pulldown" menu item from a pane, adjust the ! // right margins of the remaining widgets. if (menu->submenu_id != (Widget)0) { ! // Go through the menu items in the parent of this item and ! // adjust their margins, if necessary. ! // This takes care of the case when we delete the last menu item in a ! // pane that has a submenu. In this case, there will be no arrow ! // pixmaps shown anymore. { WidgetList children; Cardinal num_children; *************** *** 1515,1525 **** } } } ! /* Please be sure to destroy the parent widget first (i.e. menu->id). ! * ! * This code should be basically identical to that in the file gui_motif.c ! * because they are both Xt based. ! */ if (menu->id != (Widget)0) { Cardinal num_children; --- 1498,1507 ---- } } } ! // Please be sure to destroy the parent widget first (i.e. menu->id). ! // ! // This code should be basically identical to that in the file gui_motif.c ! // because they are both Xt based. if (menu->id != (Widget)0) { Cardinal num_children; *************** *** 1535,1549 **** #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI) if (parent == toolBar && menu->tip != NULL) { ! /* We try to destroy this before the actual menu, because there are ! * callbacks, etc. that will be unregistered during the tooltip ! * destruction. ! * ! * If you call "gui_mch_destroy_beval_area()" after destroying ! * menu->id, then the tooltip's window will have already been ! * deallocated by Xt, and unknown behaviour will ensue (probably ! * a core dump). ! */ gui_mch_destroy_beval_area(menu->tip); menu->tip = NULL; } --- 1517,1530 ---- #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI) if (parent == toolBar && menu->tip != NULL) { ! // We try to destroy this before the actual menu, because there are ! // callbacks, etc. that will be unregistered during the tooltip ! // destruction. ! // ! // If you call "gui_mch_destroy_beval_area()" after destroying ! // menu->id, then the tooltip's window will have already been ! // deallocated by Xt, and unknown behaviour will ensue (probably ! // a core dump). gui_mch_destroy_beval_area(menu->tip); menu->tip = NULL; } *************** *** 1555,1569 **** * will be deleted soon anyway, and it will delete its children like * all good widgets do. */ ! /* NOTE: The cause of the BadValue X Protocol Error is because when the ! * last child is destroyed, it is first unmanaged, thus causing a ! * geometry resize request from the parent Shell widget. ! * Since the Shell widget has no more children, it is resized to have ! * width/height of 0. XConfigureWindow() is then called with the ! * width/height of 0, which generates the BadValue. ! * ! * This happens in phase two of the widget destruction process. ! */ { if (parent != menuBar #ifdef FEAT_TOOLBAR --- 1536,1549 ---- * will be deleted soon anyway, and it will delete its children like * all good widgets do. */ ! // NOTE: The cause of the BadValue X Protocol Error is because when the ! // last child is destroyed, it is first unmanaged, thus causing a ! // geometry resize request from the parent Shell widget. ! // Since the Shell widget has no more children, it is resized to have ! // width/height of 0. XConfigureWindow() is then called with the ! // width/height of 0, which generates the BadValue. ! // ! // This happens in phase two of the widget destruction process. { if (parent != menuBar #ifdef FEAT_TOOLBAR *************** *** 1588,1594 **** #ifdef FEAT_TOOLBAR else if (parent == toolBar) { ! /* When removing last toolbar item, don't display the toolbar. */ XtVaGetValues(toolBar, XtNnumChildren, &num_children, NULL); if (num_children == 0) gui_mch_show_toolbar(FALSE); --- 1568,1574 ---- #ifdef FEAT_TOOLBAR else if (parent == toolBar) { ! // When removing last toolbar item, don't display the toolbar. XtVaGetValues(toolBar, XtNnumChildren, &num_children, NULL); if (num_children == 0) gui_mch_show_toolbar(FALSE); *************** *** 1620,1626 **** XtVaGetValues(w, XtNrightBitmap, &p, NULL); if ((p != None) && (p != XtUnspecifiedPixmap)) { ! /* We are dealing with an item that has a submenu */ popup = get_popup_entry(XtParent(w)); if (popup == (Widget)0) return; --- 1600,1606 ---- XtVaGetValues(w, XtNrightBitmap, &p, NULL); if ((p != None) && (p != XtUnspecifiedPixmap)) { ! // We are dealing with an item that has a submenu popup = get_popup_entry(XtParent(w)); if (popup == (Widget)0) return; *************** *** 1629,1635 **** } } ! /* This routine is used to calculate the position (in screen coordinates) * where a submenu should appear relative to the menu entry that popped it * up. It should appear even with and just slightly to the left of the * rightmost end of the menu entry that caused the popup. --- 1609,1616 ---- } } ! /* ! * This routine is used to calculate the position (in screen coordinates) * where a submenu should appear relative to the menu entry that popped it * up. It should appear even with and just slightly to the left of the * rightmost end of the menu entry that caused the popup. *************** *** 1642,1653 **** XtPointer client_data, XtPointer call_data UNUSED) { ! /* Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass) */ vimmenu_T *menu = (vimmenu_T *)client_data; Dimension width; Position root_x, root_y; ! /* First, popdown any siblings that may have menus popped up */ { vimmenu_T *i; --- 1623,1634 ---- XtPointer client_data, XtPointer call_data UNUSED) { ! // Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass) vimmenu_T *menu = (vimmenu_T *)client_data; Dimension width; Position root_x, root_y; ! // First, popdown any siblings that may have menus popped up { vimmenu_T *i; *************** *** 1660,1667 **** XtVaGetValues(XtParent(w), XtNwidth, &width, NULL); ! /* Assumption: XawSimpleMenuGetActiveEntry(XtParent(w)) == menu->id */ ! /* i.e. This IS the active entry */ XtTranslateCoords(menu->id,width - 5, 0, &root_x, &root_y); XtVaSetValues(w, XtNx, root_x, XtNy, root_y, --- 1641,1648 ---- XtVaGetValues(XtParent(w), XtNwidth, &width, NULL); ! // Assumption: XawSimpleMenuGetActiveEntry(XtParent(w)) == menu->id ! // i.e. This IS the active entry XtTranslateCoords(menu->id,width - 5, 0, &root_x, &root_y); XtVaSetValues(w, XtNx, root_x, XtNy, root_y, *************** *** 1696,1702 **** } } ! /* Used to determine if the given widget has a submenu that can be popped up. */ static Boolean has_submenu(Widget widget) { --- 1677,1685 ---- } } ! /* ! * Used to determine if the given widget has a submenu that can be popped up. ! */ static Boolean has_submenu(Widget widget) { *************** *** 1740,1746 **** { if (timer) { ! /* If the timeout hasn't been triggered, remove it */ XtRemoveTimeOut(timer); } gui_athena_popdown_submenus_action(w,event,args,nargs); --- 1723,1729 ---- { if (timer) { ! // If the timeout hasn't been triggered, remove it XtRemoveTimeOut(timer); } gui_athena_popdown_submenus_action(w,event,args,nargs); *************** *** 1760,1781 **** { Widget menuw; ! /* Get the active entry for the current menu */ if ((menuw = XawSimpleMenuGetActiveEntry(w)) == (Widget)0) return NULL; return submenu_widget(menuw); } ! /* Given the widget that has been determined to have a submenu, return the submenu widget ! * that is to be popped up. */ static Widget submenu_widget(Widget widget) { ! /* Precondition: has_submenu(widget) == True ! * XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True ! */ char_u *pullright_name; Widget popup; --- 1743,1764 ---- { Widget menuw; ! // Get the active entry for the current menu if ((menuw = XawSimpleMenuGetActiveEntry(w)) == (Widget)0) return NULL; return submenu_widget(menuw); } ! /* ! * Given the widget that has been determined to have a submenu, return the ! * submenu widget that is to be popped up. */ static Widget submenu_widget(Widget widget) { ! // Precondition: has_submenu(widget) == True ! // XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True char_u *pullright_name; Widget popup; *************** *** 1785,1792 **** vim_free(pullright_name); return popup; ! /* Postcondition: (popup != NULL) implies ! * (XtIsSubclass(popup,simpleMenuWidgetClass) == True) */ } void --- 1768,1775 ---- vim_free(pullright_name); return popup; ! // Postcondition: (popup != NULL) implies ! // (XtIsSubclass(popup,simpleMenuWidgetClass) == True) } void *************** *** 1799,1805 **** if (menu->submenu_id == (Widget)0) return; ! /* Position the popup menu at the pointer */ if (XQueryPointer(gui.dpy, XtWindow(vimShell), &root, &child, &rootx, &rooty, &winx, &winy, &mask)) { --- 1782,1788 ---- if (menu->submenu_id == (Widget)0) return; ! // Position the popup menu at the pointer if (XQueryPointer(gui.dpy, XtWindow(vimShell), &root, &child, &rootx, &rooty, &winx, &winy, &mask)) { *************** *** 1819,1825 **** XtPopupSpringLoaded(menu->submenu_id); } ! #endif /* FEAT_MENU */ /* * Set the menu and scrollbar colors to their default values. --- 1802,1808 ---- XtPopupSpringLoaded(menu->submenu_id); } ! #endif // FEAT_MENU /* * Set the menu and scrollbar colors to their default values. *************** *** 1866,1872 **** */ if (max == 0) { ! /* So you can't scroll it at all (normally it scrolls past end) */ #ifdef FEAT_GUI_NEXTAW XawScrollbarSetThumb(sb->id, 0.0, 1.0); #else --- 1849,1855 ---- */ if (max == 0) { ! // So you can't scroll it at all (normally it scrolls past end) #ifdef FEAT_GUI_NEXTAW XawScrollbarSetThumb(sb->id, 0.0, 1.0); #else *************** *** 1921,1927 **** void gui_mch_create_scrollbar( scrollbar_T *sb, ! int orient) /* SBAR_VERT or SBAR_HORIZ */ { sb->id = XtVaCreateWidget("scrollBar", #ifdef FEAT_GUI_NEXTAW --- 1904,1910 ---- void gui_mch_create_scrollbar( scrollbar_T *sb, ! int orient) // SBAR_VERT or SBAR_HORIZ { sb->id = XtVaCreateWidget("scrollBar", #ifdef FEAT_GUI_NEXTAW *************** *** 1971,1977 **** XtNbackground, gui.scroll_bg_pixel, NULL); ! /* This is needed for the rectangle below the vertical scrollbars. */ if (sb == &gui.bottom_sbar && vimForm != (Widget)0) gui_athena_scroll_colors(vimForm); } --- 1954,1960 ---- XtNbackground, gui.scroll_bg_pixel, NULL); ! // This is needed for the rectangle below the vertical scrollbars. if (sb == &gui.bottom_sbar && vimForm != (Widget)0) gui_athena_scroll_colors(vimForm); } *************** *** 1992,2008 **** */ char_u * gui_mch_browse( ! int saving UNUSED, /* select file to write */ ! char_u *title, /* title for the window */ ! char_u *dflt, /* default name */ ! char_u *ext UNUSED, /* extension added */ ! char_u *initdir, /* initial directory, NULL for current dir */ ! char_u *filter UNUSED) /* file name filter */ { Position x, y; char_u dirbuf[MAXPATHL]; ! /* Concatenate "initdir" and "dflt". */ if (initdir == NULL || *initdir == NUL) mch_dirname(dirbuf, MAXPATHL); else if (STRLEN(initdir) + 2 < MAXPATHL) --- 1975,1991 ---- */ char_u * gui_mch_browse( ! int saving UNUSED, // select file to write ! char_u *title, // title for the window ! char_u *dflt, // default name ! char_u *ext UNUSED, // extension added ! char_u *initdir, // initial directory, NULL for current dir ! char_u *filter UNUSED) // file name filter { Position x, y; char_u dirbuf[MAXPATHL]; ! // Concatenate "initdir" and "dflt". if (initdir == NULL || *initdir == NUL) mch_dirname(dirbuf, MAXPATHL); else if (STRLEN(initdir) + 2 < MAXPATHL) *************** *** 2016,2022 **** STRCAT(dirbuf, dflt); } ! /* Position the file selector just below the menubar */ XtTranslateCoords(vimShell, (Position)0, (Position) #ifdef FEAT_MENU gui.menu_height --- 1999,2005 ---- STRCAT(dirbuf, dflt); } ! // Position the file selector just below the menubar XtTranslateCoords(vimShell, (Position)0, (Position) #ifdef FEAT_MENU gui.menu_height *************** *** 2111,2123 **** title = (char_u *)_("Vim dialog"); dialogStatus = -1; ! /* if our pointer is currently hidden, then we should show it. */ gui_mch_mousehide(FALSE); ! /* Check 'v' flag in 'guioptions': vertical button placement. */ vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); ! /* The shell is created each time, to make sure it is resized properly */ dialogshell = XtVaCreatePopupShell("dialogShell", transientShellWidgetClass, vimShell, XtNtitle, title, --- 2094,2106 ---- title = (char_u *)_("Vim dialog"); dialogStatus = -1; ! // if our pointer is currently hidden, then we should show it. gui_mch_mousehide(FALSE); ! // Check 'v' flag in 'guioptions': vertical button placement. vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); ! // The shell is created each time, to make sure it is resized properly dialogshell = XtVaCreatePopupShell("dialogShell", transientShellWidgetClass, vimShell, XtNtitle, title, *************** *** 2170,2176 **** XtSetKeyboardFocus(dialog, dialogtextfield); } ! /* make a copy, so that we can insert NULs */ buts = vim_strsave(buttons); if (buts == NULL) return -1; --- 2153,2159 ---- XtSetKeyboardFocus(dialog, dialogtextfield); } ! // make a copy, so that we can insert NULs buts = vim_strsave(buttons); if (buts == NULL) return -1; *************** *** 2213,2219 **** XtRealizeWidget(dialogshell); ! /* Setup for catching the close-window event, don't let it close Vim! */ dialogatom = XInternAtom(gui.dpy, "WM_DELETE_WINDOW", False); XSetWMProtocols(gui.dpy, XtWindow(dialogshell), &dialogatom, 1); XtAddEventHandler(dialogshell, NoEventMask, True, dialog_wm_handler, NULL); --- 2196,2202 ---- XtRealizeWidget(dialogshell); ! // Setup for catching the close-window event, don't let it close Vim! dialogatom = XInternAtom(gui.dpy, "WM_DELETE_WINDOW", False); XSetWMProtocols(gui.dpy, XtWindow(dialogshell), &dialogatom, 1); XtAddEventHandler(dialogshell, NoEventMask, True, dialog_wm_handler, NULL); *************** *** 2236,2243 **** y = 0; XtVaSetValues(dialogshell, XtNx, x, XtNy, y, NULL); ! /* Position the mouse pointer in the dialog, required for when focus ! * follows mouse. */ XWarpPointer(gui.dpy, (Window)0, XtWindow(dialogshell), 0, 0, 0, 0, 20, 40); --- 2219,2226 ---- y = 0; XtVaSetValues(dialogshell, XtNx, x, XtNy, y, NULL); ! // Position the mouse pointer in the dialog, required for when focus ! // follows mouse. XWarpPointer(gui.dpy, (Window)0, XtWindow(dialogshell), 0, 0, 0, 0, 20, 40); *** ../vim-8.1.2379/src/gui_beval.c 2019-07-04 17:35:01.115169990 +0200 --- src/gui_beval.c 2019-12-01 21:59:15.644248491 +0100 *************** *** 12,18 **** #if defined(FEAT_BEVAL_GUI) || defined(PROTO) ! /* on Win32 only get_beval_info() is required */ #if !defined(FEAT_GUI_MSWIN) || defined(PROTO) #ifdef FEAT_GUI_GTK --- 12,18 ---- #if defined(FEAT_BEVAL_GUI) || defined(PROTO) ! // on Win32 only get_beval_info() is required #if !defined(FEAT_GUI_MSWIN) || defined(PROTO) #ifdef FEAT_GUI_GTK *************** *** 32,38 **** # include # include # else ! /* Assume Athena */ # include # ifdef FEAT_GUI_NEXTAW # include --- 32,38 ---- # include # include # else ! // Assume Athena # include # ifdef FEAT_GUI_NEXTAW # include *************** *** 95,101 **** void *clientData) { #ifndef FEAT_GUI_GTK ! char *display_name; /* get from gui.dpy */ int screen_num; char *p; #endif --- 95,101 ---- void *clientData) { #ifndef FEAT_GUI_GTK ! char *display_name; // get from gui.dpy int screen_num; char *p; #endif *************** *** 157,163 **** { cancelBalloon(beval); removeEventHandler(beval); ! /* Children will automatically be destroyed */ # ifdef FEAT_GUI_GTK gtk_widget_destroy(beval->balloonShell); # else --- 157,163 ---- { cancelBalloon(beval); removeEventHandler(beval); ! // Children will automatically be destroyed # ifdef FEAT_GUI_GTK gtk_widget_destroy(beval->balloonShell); # else *************** *** 198,204 **** return current_beval; } #endif ! #endif /* !FEAT_GUI_MSWIN */ #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL) || defined(PROTO) # if !defined(FEAT_GUI_MSWIN) || defined(PROTO) --- 198,204 ---- return current_beval; } #endif ! #endif // !FEAT_GUI_MSWIN #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL) || defined(PROTO) # if !defined(FEAT_GUI_MSWIN) || defined(PROTO) *************** *** 216,223 **** else undrawBalloon(beval); } ! # endif /* !FEAT_GUI_MSWIN */ ! #endif /* FEAT_NETBEANS_INTG || PROTO */ #if !defined(FEAT_GUI_MSWIN) || defined(PROTO) #if defined(FEAT_BEVAL_TIP) || defined(PROTO) --- 216,223 ---- else undrawBalloon(beval); } ! # endif // !FEAT_GUI_MSWIN ! #endif // FEAT_NETBEANS_INTG || PROTO #if !defined(FEAT_GUI_MSWIN) || defined(PROTO) #if defined(FEAT_BEVAL_TIP) || defined(PROTO) *************** *** 344,350 **** break; } ! return FALSE; /* continue emission */ } static gint --- 344,350 ---- break; } ! return FALSE; // continue emission } static gint *************** *** 364,370 **** break; } ! return FALSE; /* continue emission */ } static void --- 364,370 ---- break; } ! return FALSE; // continue emission } static void *************** *** 383,389 **** beval->state = state; cancelBalloon(beval); ! /* Mouse buttons are pressed - no balloon now */ if (!(state & ((int)GDK_BUTTON1_MASK | (int)GDK_BUTTON2_MASK | (int)GDK_BUTTON3_MASK))) { --- 383,389 ---- beval->state = state; cancelBalloon(beval); ! // Mouse buttons are pressed - no balloon now if (!(state & ((int)GDK_BUTTON1_MASK | (int)GDK_BUTTON2_MASK | (int)GDK_BUTTON3_MASK))) { *************** *** 431,438 **** ? (int)GDK_CONTROL_MASK : 0); break; default: ! /* Don't do this for key release, we apparently get these with ! * focus changes in some GTK version. */ if (is_keypress) cancelBalloon(beval); break; --- 431,438 ---- ? (int)GDK_CONTROL_MASK : 0); break; default: ! // Don't do this for key release, we apparently get these with ! // focus changes in some GTK version. if (is_keypress) cancelBalloon(beval); break; *************** *** 455,461 **** */ requestBalloon(beval); ! return FALSE; /* don't call me again */ } # if GTK_CHECK_VERSION(3,0,0) --- 455,461 ---- */ requestBalloon(beval); ! return FALSE; // don't call me again } # if GTK_CHECK_VERSION(3,0,0) *************** *** 499,509 **** &event->area, widget, "tooltip", 0, 0, -1, -1); ! return FALSE; /* continue emission */ } ! # endif /* !GTK_CHECK_VERSION(3,0,0) */ ! #else /* !FEAT_GUI_GTK */ static void addEventHandler(Widget target, BalloonEval *beval) --- 499,509 ---- &event->area, widget, "tooltip", 0, 0, -1, -1); ! return FALSE; // continue emission } ! # endif // !GTK_CHECK_VERSION(3,0,0) ! #else // !FEAT_GUI_GTK static void addEventHandler(Widget target, BalloonEval *beval) *************** *** 551,558 **** static void pointerEvent(BalloonEval *beval, XEvent *event) { ! Position distance; /* a measure of how much the pointer moved */ ! Position delta; /* used to compute distance */ switch (event->type) { --- 551,558 ---- static void pointerEvent(BalloonEval *beval, XEvent *event) { ! Position distance; // a measure of how much the pointer moved ! Position delta; // used to compute distance switch (event->type) { *************** *** 575,581 **** beval->state = event->xmotion.state; if (beval->state & (Button1Mask|Button2Mask|Button3Mask)) { ! /* Mouse buttons are pressed - no balloon now */ cancelBalloon(beval); } else if (beval->state & (Mod1Mask|Mod2Mask|Mod3Mask)) --- 575,581 ---- beval->state = event->xmotion.state; if (beval->state & (Button1Mask|Button2Mask|Button3Mask)) { ! // Mouse buttons are pressed - no balloon now cancelBalloon(beval); } else if (beval->state & (Mod1Mask|Mod2Mask|Mod3Mask)) *************** *** 663,671 **** break; case LeaveNotify: ! /* Ignore LeaveNotify events that are not "normal". ! * Apparently we also get it when somebody else grabs focus. ! * Happens for me every two seconds (some clipboard tool?) */ if (event->xcrossing.mode == NotifyNormal) cancelBalloon(beval); break; --- 663,671 ---- break; case LeaveNotify: ! // Ignore LeaveNotify events that are not "normal". ! // Apparently we also get it when somebody else grabs focus. ! // Happens for me every two seconds (some clipboard tool?) if (event->xcrossing.mode == NotifyNormal) cancelBalloon(beval); break; *************** *** 694,707 **** requestBalloon(beval); } ! #endif /* !FEAT_GUI_GTK */ static void requestBalloon(BalloonEval *beval) { if (beval->showState != ShS_PENDING) { ! /* Determine the beval to display */ if (beval->msgCB != NULL) { beval->showState = ShS_PENDING; --- 694,707 ---- requestBalloon(beval); } ! #endif // !FEAT_GUI_GTK static void requestBalloon(BalloonEval *beval) { if (beval->showState != ShS_PENDING) { ! // Determine the beval to display if (beval->msgCB != NULL) { beval->showState = ShS_PENDING; *************** *** 733,739 **** int uc; PangoAttrList *attr_list; ! /* Convert to UTF-8 if it isn't already */ if (output_conv.vc_type != CONV_NONE) { convbuf = string_convert(&output_conv, text, NULL); --- 733,739 ---- int uc; PangoAttrList *attr_list; ! // Convert to UTF-8 if it isn't already if (output_conv.vc_type != CONV_NONE) { convbuf = string_convert(&output_conv, text, NULL); *************** *** 741,754 **** text = convbuf; } ! /* First let's see how much we need to allocate */ len = 0; for (p = text; *p != NUL; p += charlen) { ! if ((*p & 0x80) == 0) /* be quick for ASCII */ { charlen = 1; ! len += IS_NONPRINTABLE(*p) ? 2 : 1; /* nonprintable: ^X */ } else { --- 741,754 ---- text = convbuf; } ! // First let's see how much we need to allocate len = 0; for (p = text; *p != NUL; p += charlen) { ! if ((*p & 0x80) == 0) // be quick for ASCII { charlen = 1; ! len += IS_NONPRINTABLE(*p) ? 2 : 1; // nonprintable: ^X } else { *************** *** 756,769 **** uc = utf_ptr2char(p); if (charlen != utf_char2len(uc)) ! charlen = 1; /* reject overlong sequences */ ! if (charlen == 1 || uc < 0xa0) /* illegal byte or */ ! len += 4; /* control char: */ else if (!utf_printable(uc)) ! /* Note: we assume here that utf_printable() doesn't ! * care about characters outside the BMP. */ ! len += 6; /* nonprintable: */ else len += charlen; } --- 756,769 ---- uc = utf_ptr2char(p); if (charlen != utf_char2len(uc)) ! charlen = 1; // reject overlong sequences ! if (charlen == 1 || uc < 0xa0) // illegal byte or ! len += 4; // control char: else if (!utf_printable(uc)) ! // Note: we assume here that utf_printable() doesn't ! // care about characters outside the BMP. ! len += 6; // nonprintable: else len += charlen; } *************** *** 772,778 **** attr_list = pango_attr_list_new(); buf = alloc(len + 1); ! /* Now go for the real work */ if (buf != NULL) { attrentry_T *aep; --- 772,778 ---- attr_list = pango_attr_list_new(); buf = alloc(len + 1); ! // Now go for the real work if (buf != NULL) { attrentry_T *aep; *************** *** 787,793 **** GdkColor color = { 0, 0, 0, 0 }; #endif ! /* Look up the RGB values of the SpecialKey foreground color. */ aep = syn_gui_attr2entry(HL_ATTR(HLF_8)); pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR; if (pixel != INVALCOLOR) --- 787,793 ---- GdkColor color = { 0, 0, 0, 0 }; #endif ! // Look up the RGB values of the SpecialKey foreground color. aep = syn_gui_attr2entry(HL_ATTR(HLF_8)); pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR; if (pixel != INVALCOLOR) *************** *** 807,813 **** p = text; while (*p != NUL) { ! /* Be quick for ASCII */ if ((*p & 0x80) == 0 && !IS_NONPRINTABLE(*p)) { *pdest++ = *p++; --- 807,813 ---- p = text; while (*p != NUL) { ! // Be quick for ASCII if ((*p & 0x80) == 0 && !IS_NONPRINTABLE(*p)) { *pdest++ = *p++; *************** *** 818,846 **** uc = utf_ptr2char(p); if (charlen != utf_char2len(uc)) ! charlen = 1; /* reject overlong sequences */ if (charlen == 1 || uc < 0xa0 || !utf_printable(uc)) { int outlen; ! /* Careful: we can't just use transchar_byte() here, ! * since 'encoding' is not necessarily set to "utf-8". */ if (*p & 0x80 && charlen == 1) { ! transchar_hex(pdest, *p); /* */ outlen = 4; } else if (uc >= 0x80) { ! /* Note: we assume here that utf_printable() doesn't ! * care about characters outside the BMP. */ ! transchar_hex(pdest, uc); /* or */ outlen = (uc < 0x100) ? 4 : 6; } else { ! transchar_nonprint(pdest, *p); /* ^X */ outlen = 2; } if (pixel != INVALCOLOR) --- 818,846 ---- uc = utf_ptr2char(p); if (charlen != utf_char2len(uc)) ! charlen = 1; // reject overlong sequences if (charlen == 1 || uc < 0xa0 || !utf_printable(uc)) { int outlen; ! // Careful: we can't just use transchar_byte() here, ! // since 'encoding' is not necessarily set to "utf-8". if (*p & 0x80 && charlen == 1) { ! transchar_hex(pdest, *p); // outlen = 4; } else if (uc >= 0x80) { ! // Note: we assume here that utf_printable() doesn't ! // care about characters outside the BMP. ! transchar_hex(pdest, uc); // or outlen = (uc < 0x100) ? 4 : 6; } else { ! transchar_nonprint(pdest, *p); // ^X outlen = 2; } if (pixel != INVALCOLOR) *************** *** 940,975 **** pango_layout_set_wrap(layout, PANGO_WRAP_WORD); # endif pango_layout_set_width(layout, ! /* try to come up with some reasonable width */ PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width, screen_w / 2, MAX(20, screen_w - 20))); ! /* Calculate the balloon's width and height. */ # if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(beval->balloonShell, &requisition, NULL); # else gtk_widget_size_request(beval->balloonShell, &requisition); # endif ! /* Compute position of the balloon area */ gdk_window_get_origin(gtk_widget_get_window(beval->target), &x, &y); x += beval->x; y += beval->y; ! /* Get out of the way of the mouse pointer */ if (x + x_offset + requisition.width > screen_x + screen_w) y_offset += 15; if (y + y_offset + requisition.height > screen_y + screen_h) y_offset = -requisition.height - EVAL_OFFSET_Y; ! /* Sanitize values */ x = CLAMP(x + x_offset, 0, MAX(0, screen_x + screen_w - requisition.width)); y = CLAMP(y + y_offset, 0, MAX(0, screen_y + screen_h - requisition.height)); ! /* Show the balloon */ # if GTK_CHECK_VERSION(3,0,0) gtk_window_move(GTK_WINDOW(beval->balloonShell), x, y); # else --- 940,975 ---- pango_layout_set_wrap(layout, PANGO_WRAP_WORD); # endif pango_layout_set_width(layout, ! // try to come up with some reasonable width PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width, screen_w / 2, MAX(20, screen_w - 20))); ! // Calculate the balloon's width and height. # if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(beval->balloonShell, &requisition, NULL); # else gtk_widget_size_request(beval->balloonShell, &requisition); # endif ! // Compute position of the balloon area gdk_window_get_origin(gtk_widget_get_window(beval->target), &x, &y); x += beval->x; y += beval->y; ! // Get out of the way of the mouse pointer if (x + x_offset + requisition.width > screen_x + screen_w) y_offset += 15; if (y + y_offset + requisition.height > screen_y + screen_h) y_offset = -requisition.height - EVAL_OFFSET_Y; ! // Sanitize values x = CLAMP(x + x_offset, 0, MAX(0, screen_x + screen_w - requisition.width)); y = CLAMP(y + y_offset, 0, MAX(0, screen_y + screen_h - requisition.height)); ! // Show the balloon # if GTK_CHECK_VERSION(3,0,0) gtk_window_move(GTK_WINDOW(beval->balloonShell), x, y); # else *************** *** 1048,1054 **** gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel); } ! #else /* !FEAT_GUI_GTK */ /* * Draw a balloon. --- 1048,1054 ---- gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel); } ! #else // !FEAT_GUI_GTK /* * Draw a balloon. *************** *** 1063,1077 **** if (beval->msg != NULL) { ! /* Show the Balloon */ ! /* Calculate the label's width and height */ #ifdef FEAT_GUI_MOTIF XmString s; ! /* For the callback function we parse NL characters to create a ! * multi-line label. This doesn't work for all languages, but ! * XmStringCreateLocalized() doesn't do multi-line labels... */ if (beval->msgCB != NULL) s = XmStringCreateLtoR((char *)beval->msg, XmFONTLIST_DEFAULT_TAG); else --- 1063,1077 ---- if (beval->msg != NULL) { ! // Show the Balloon ! // Calculate the label's width and height #ifdef FEAT_GUI_MOTIF XmString s; ! // For the callback function we parse NL characters to create a ! // multi-line label. This doesn't work for all languages, but ! // XmStringCreateLocalized() doesn't do multi-line labels... if (beval->msgCB != NULL) s = XmStringCreateLtoR((char *)beval->msg, XmFONTLIST_DEFAULT_TAG); else *************** *** 1092,1099 **** h += gui.border_offset << 1; XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL); XmStringFree(s); ! #else /* Athena */ ! /* Assume XtNinternational == True */ XFontSet fset; XFontSetExtents *ext; --- 1092,1099 ---- h += gui.border_offset << 1; XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL); XmStringFree(s); ! #else // Athena ! // Assume XtNinternational == True XFontSet fset; XFontSetExtents *ext; *************** *** 1108,1114 **** XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL); #endif ! /* Compute position of the balloon area */ tx = beval->x_root + EVAL_OFFSET_X; ty = beval->y_root + EVAL_OFFSET_Y; if ((tx + w) > beval->screen_width) --- 1108,1114 ---- XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL); #endif ! // Compute position of the balloon area tx = beval->x_root + EVAL_OFFSET_X; ty = beval->y_root + EVAL_OFFSET_Y; if ((tx + w) > beval->screen_width) *************** *** 1121,1133 **** XmNy, ty, NULL); #else ! /* Athena */ XtVaSetValues(beval->balloonShell, XtNx, tx, XtNy, ty, NULL); #endif ! /* Set tooltip colors */ { Arg args[2]; --- 1121,1133 ---- XmNy, ty, NULL); #else ! // Athena XtVaSetValues(beval->balloonShell, XtNx, tx, XtNy, ty, NULL); #endif ! // Set tooltip colors { Arg args[2]; *************** *** 1136,1142 **** args[0].value = gui.tooltip_bg_pixel; args[1].name = XmNforeground; args[1].value = gui.tooltip_fg_pixel; ! #else /* Athena */ args[0].name = XtNbackground; args[0].value = gui.tooltip_bg_pixel; args[1].name = XtNforeground; --- 1136,1142 ---- args[0].value = gui.tooltip_bg_pixel; args[1].name = XmNforeground; args[1].value = gui.tooltip_fg_pixel; ! #else // Athena args[0].name = XtNbackground; args[0].value = gui.tooltip_bg_pixel; args[1].name = XtNforeground; *************** *** 1194,1200 **** beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", overrideShellWidgetClass, gui.dpy, args, n); #else ! /* Athena */ XtSetArg(args[n], XtNallowShellResize, True); n++; beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", overrideShellWidgetClass, gui.dpy, args, n); --- 1194,1200 ---- beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", overrideShellWidgetClass, gui.dpy, args, n); #else ! // Athena XtSetArg(args[n], XtNallowShellResize, True); n++; beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", overrideShellWidgetClass, gui.dpy, args, n); *************** *** 1213,1219 **** beval->balloonLabel = XtCreateManagedWidget("balloonLabel", xmLabelWidgetClass, beval->balloonShell, args, n); } ! #else /* FEAT_GUI_ATHENA */ XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++; XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++; XtSetArg(args[n], XtNinternational, True); n++; --- 1213,1219 ---- beval->balloonLabel = XtCreateManagedWidget("balloonLabel", xmLabelWidgetClass, beval->balloonShell, args, n); } ! #else // FEAT_GUI_ATHENA XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++; XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++; XtSetArg(args[n], XtNinternational, True); n++; *************** *** 1223,1229 **** #endif } ! #endif /* !FEAT_GUI_GTK */ ! #endif /* !FEAT_GUI_MSWIN */ ! #endif /* FEAT_BEVAL_GUI */ --- 1223,1229 ---- #endif } ! #endif // !FEAT_GUI_GTK ! #endif // !FEAT_GUI_MSWIN ! #endif // FEAT_BEVAL_GUI *** ../vim-8.1.2379/src/gui_gtk.c 2019-05-28 23:08:12.064648717 +0200 --- src/gui_gtk.c 2019-12-01 22:02:41.251215542 +0100 *************** *** 37,44 **** # include "gui_gtk_f.h" #endif ! /* GTK defines MAX and MIN, but some system header files as well. Undefine ! * them and don't use them. */ #ifdef MIN # undef MIN #endif --- 37,44 ---- # include "gui_gtk_f.h" #endif ! // GTK defines MAX and MIN, but some system header files as well. Undefine ! // them and don't use them. #ifdef MIN # undef MIN #endif *************** *** 47,53 **** #endif #ifdef FEAT_GUI_GNOME ! /* Gnome redefines _() and N_(). Grrr... */ # ifdef _ # undef _ # endif --- 47,53 ---- #endif #ifdef FEAT_GUI_GNOME ! // Gnome redefines _() and N_(). Grrr... # ifdef _ # undef _ # endif *************** *** 64,70 **** # undef bind_textdomain_codeset # endif # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS) ! # define ENABLE_NLS /* so the texts in the dialog boxes are translated */ # endif # include #endif --- 64,70 ---- # undef bind_textdomain_codeset # endif # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS) ! # define ENABLE_NLS // so the texts in the dialog boxes are translated # endif # include #endif *************** *** 84,90 **** # include #else ! /* define these items to be able to generate prototypes without GTK */ typedef int GtkWidget; # define gpointer int # define guint8 int --- 84,90 ---- # include #else ! // define these items to be able to generate prototypes without GTK typedef int GtkWidget; # define gpointer int # define guint8 int *************** *** 118,137 **** # if GTK_CHECK_VERSION(3,10,0) static const char * const menu_themed_names[] = { ! /* 00 */ "document-new", /* sub. GTK_STOCK_NEW */ ! /* 01 */ "document-open", /* sub. GTK_STOCK_OPEN */ ! /* 02 */ "document-save", /* sub. GTK_STOCK_SAVE */ ! /* 03 */ "edit-undo", /* sub. GTK_STOCK_UNDO */ ! /* 04 */ "edit-redo", /* sub. GTK_STOCK_REDO */ ! /* 05 */ "edit-cut", /* sub. GTK_STOCK_CUT */ ! /* 06 */ "edit-copy", /* sub. GTK_STOCK_COPY */ ! /* 07 */ "edit-paste", /* sub. GTK_STOCK_PASTE */ ! /* 08 */ "document-print", /* sub. GTK_STOCK_PRINT */ ! /* 09 */ "help-browser", /* sub. GTK_STOCK_HELP */ ! /* 10 */ "edit-find", /* sub. GTK_STOCK_FIND */ # if GTK_CHECK_VERSION(3,14,0) ! /* Use the file names in gui_gtk_res.xml, cutting off the extension. ! * Similar changes follow. */ /* 11 */ "stock_vim_save_all", /* 12 */ "stock_vim_session_save", /* 13 */ "stock_vim_session_new", --- 118,137 ---- # if GTK_CHECK_VERSION(3,10,0) static const char * const menu_themed_names[] = { ! /* 00 */ "document-new", // sub. GTK_STOCK_NEW ! /* 01 */ "document-open", // sub. GTK_STOCK_OPEN ! /* 02 */ "document-save", // sub. GTK_STOCK_SAVE ! /* 03 */ "edit-undo", // sub. GTK_STOCK_UNDO ! /* 04 */ "edit-redo", // sub. GTK_STOCK_REDO ! /* 05 */ "edit-cut", // sub. GTK_STOCK_CUT ! /* 06 */ "edit-copy", // sub. GTK_STOCK_COPY ! /* 07 */ "edit-paste", // sub. GTK_STOCK_PASTE ! /* 08 */ "document-print", // sub. GTK_STOCK_PRINT ! /* 09 */ "help-browser", // sub. GTK_STOCK_HELP ! /* 10 */ "edit-find", // sub. GTK_STOCK_FIND # if GTK_CHECK_VERSION(3,14,0) ! // Use the file names in gui_gtk_res.xml, cutting off the extension. ! // Similar changes follow. /* 11 */ "stock_vim_save_all", /* 12 */ "stock_vim_session_save", /* 13 */ "stock_vim_session_new", *************** *** 142,150 **** /* 13 */ "vim-session-new", /* 14 */ "vim-session-load", # endif ! /* 15 */ "system-run", /* sub. GTK_STOCK_EXECUTE */ ! /* 16 */ "edit-find-replace", /* sub. GTK_STOCK_FIND_AND_REPLACE */ ! /* 17 */ "window-close", /* sub. GTK_STOCK_CLOSE, FIXME: fuzzy */ # if GTK_CHECK_VERSION(3,14,0) /* 18 */ "stock_vim_window_maximize", /* 19 */ "stock_vim_window_minimize", --- 142,150 ---- /* 13 */ "vim-session-new", /* 14 */ "vim-session-load", # endif ! /* 15 */ "system-run", // sub. GTK_STOCK_EXECUTE ! /* 16 */ "edit-find-replace", // sub. GTK_STOCK_FIND_AND_REPLACE ! /* 17 */ "window-close", // sub. GTK_STOCK_CLOSE, FIXME: fuzzy # if GTK_CHECK_VERSION(3,14,0) /* 18 */ "stock_vim_window_maximize", /* 19 */ "stock_vim_window_minimize", *************** *** 156,170 **** /* 20 */ "vim-window-split", /* 21 */ "vim-shell", # endif ! /* 22 */ "go-previous", /* sub. GTK_STOCK_GO_BACK */ ! /* 23 */ "go-next", /* sub. GTK_STOCK_GO_FORWARD */ # if GTK_CHECK_VERSION(3,14,0) /* 24 */ "stock_vim_find_help", # else /* 24 */ "vim-find-help", # endif ! /* 25 */ "gtk-convert", /* sub. GTK_STOCK_CONVERT */ ! /* 26 */ "go-jump", /* sub. GTK_STOCK_JUMP_TO */ # if GTK_CHECK_VERSION(3,14,0) /* 27 */ "stock_vim_build_tags", /* 28 */ "stock_vim_window_split_vertical", --- 156,170 ---- /* 20 */ "vim-window-split", /* 21 */ "vim-shell", # endif ! /* 22 */ "go-previous", // sub. GTK_STOCK_GO_BACK ! /* 23 */ "go-next", // sub. GTK_STOCK_GO_FORWARD # if GTK_CHECK_VERSION(3,14,0) /* 24 */ "stock_vim_find_help", # else /* 24 */ "vim-find-help", # endif ! /* 25 */ "gtk-convert", // sub. GTK_STOCK_CONVERT ! /* 26 */ "go-jump", // sub. GTK_STOCK_JUMP_TO # if GTK_CHECK_VERSION(3,14,0) /* 27 */ "stock_vim_build_tags", /* 28 */ "stock_vim_window_split_vertical", *************** *** 176,184 **** /* 29 */ "vim-window-maximize-width", /* 30 */ "vim-window-minimize-width", # endif ! /* 31 */ "application-exit", /* GTK_STOCK_QUIT */ }; ! # else /* !GTK_CHECK_VERSION(3,10,0) */ static const char * const menu_stock_ids[] = { /* 00 */ GTK_STOCK_NEW, --- 176,184 ---- /* 29 */ "vim-window-maximize-width", /* 30 */ "vim-window-minimize-width", # endif ! /* 31 */ "application-exit", // GTK_STOCK_QUIT }; ! # else // !GTK_CHECK_VERSION(3,10,0) static const char * const menu_stock_ids[] = { /* 00 */ GTK_STOCK_NEW, *************** *** 198,204 **** /* 14 */ "vim-session-load", /* 15 */ GTK_STOCK_EXECUTE, /* 16 */ GTK_STOCK_FIND_AND_REPLACE, ! /* 17 */ GTK_STOCK_CLOSE, /* FIXME: fuzzy */ /* 18 */ "vim-window-maximize", /* 19 */ "vim-window-minimize", /* 20 */ "vim-window-split", --- 198,204 ---- /* 14 */ "vim-session-load", /* 15 */ GTK_STOCK_EXECUTE, /* 16 */ GTK_STOCK_FIND_AND_REPLACE, ! /* 17 */ GTK_STOCK_CLOSE, // FIXME: fuzzy /* 18 */ "vim-window-maximize", /* 19 */ "vim-window-minimize", /* 20 */ "vim-window-split", *************** *** 214,220 **** /* 30 */ "vim-window-minimize-width", /* 31 */ GTK_STOCK_QUIT }; ! # endif /* !GTK_CHECK_VERSION(3,10,0) */ # ifdef USE_GRESOURCE # if !GTK_CHECK_VERSION(3,10,0) --- 214,220 ---- /* 30 */ "vim-window-minimize-width", /* 31 */ GTK_STOCK_QUIT }; ! # endif // !GTK_CHECK_VERSION(3,10,0) # ifdef USE_GRESOURCE # if !GTK_CHECK_VERSION(3,10,0) *************** *** 240,246 **** { NULL, NULL } }; # endif ! # endif /* USE_G_RESOURCE */ # ifndef USE_GRESOURCE static void --- 240,246 ---- { NULL, NULL } }; # endif ! # endif // USE_G_RESOURCE # ifndef USE_GRESOURCE static void *************** *** 316,322 **** pixel_size = 48; break; case GTK_ICON_SIZE_INVALID: ! /* FALLTHROUGH */ default: pixel_size = 0; break; --- 316,322 ---- pixel_size = 48; break; case GTK_ICON_SIZE_INVALID: ! // FALLTHROUGH default: pixel_size = 0; break; *************** *** 337,343 **** image = gtk_image_new_from_icon_name("image-missing", icon_size); return image; ! # else /* !GTK_CHECK_VERSION(3,10,0) */ GtkIconSet *icon_set; GtkIconSource *icon_source; --- 337,343 ---- image = gtk_image_new_from_icon_name("image-missing", icon_size); return image; ! # else // !GTK_CHECK_VERSION(3,10,0) GtkIconSet *icon_set; GtkIconSource *icon_source; *************** *** 358,364 **** gtk_icon_set_unref(icon_set); return image; ! # endif /* !GTK_CHECK_VERSION(3,10,0) */ } static GtkWidget * --- 358,364 ---- gtk_icon_set_unref(icon_set); return image; ! # endif // !GTK_CHECK_VERSION(3,10,0) } static GtkWidget * *************** *** 367,382 **** GtkWidget *image = NULL; char_u buf[MAXPATHL]; ! /* First use a specified "icon=" argument. */ if (menu->iconfile != NULL && lookup_menu_iconfile(menu->iconfile, buf)) image = load_menu_iconfile(buf, icon_size); ! /* If not found and not builtin specified try using the menu name. */ if (image == NULL && !menu->icon_builtin && lookup_menu_iconfile(menu->name, buf)) image = load_menu_iconfile(buf, icon_size); ! /* Still not found? Then use a builtin icon, a blank one as fallback. */ if (image == NULL) { # if GTK_CHECK_VERSION(3,10,0) --- 367,382 ---- GtkWidget *image = NULL; char_u buf[MAXPATHL]; ! // First use a specified "icon=" argument. if (menu->iconfile != NULL && lookup_menu_iconfile(menu->iconfile, buf)) image = load_menu_iconfile(buf, icon_size); ! // If not found and not builtin specified try using the menu name. if (image == NULL && !menu->icon_builtin && lookup_menu_iconfile(menu->name, buf)) image = load_menu_iconfile(buf, icon_size); ! // Still not found? Then use a builtin icon, a blank one as fallback. if (image == NULL) { # if GTK_CHECK_VERSION(3,10,0) *************** *** 410,424 **** GdkEventFocus *event UNUSED, gpointer data UNUSED) { ! /* When we're in a GtkPlug, we don't have window focus events, only widget ! * focus. To emulate stand-alone gvim, if a button gets focus (e.g., ! * into GtkPlug) immediately pass it to mainwin. */ if (gtk_socket_id != 0) gtk_widget_grab_focus(gui.drawarea); return TRUE; } ! #endif /* FEAT_TOOLBAR */ #if defined(FEAT_TOOLBAR) || defined(PROTO) --- 410,424 ---- GdkEventFocus *event UNUSED, gpointer data UNUSED) { ! // When we're in a GtkPlug, we don't have window focus events, only widget ! // focus. To emulate stand-alone gvim, if a button gets focus (e.g., ! // into GtkPlug) immediately pass it to mainwin. if (gtk_socket_id != 0) gtk_widget_grab_focus(gui.drawarea); return TRUE; } ! #endif // FEAT_TOOLBAR #if defined(FEAT_TOOLBAR) || defined(PROTO) *************** *** 450,456 **** gtk_icon_factory_add_default(factory); g_object_unref(factory); ! # else /* defined(USE_GRESOURCE) */ const char * const path_prefix = "/org/vim/gui/icon"; # if GTK_CHECK_VERSION(3,14,0) GdkScreen *screen = NULL; --- 450,456 ---- gtk_icon_factory_add_default(factory); g_object_unref(factory); ! # else // defined(USE_GRESOURCE) const char * const path_prefix = "/org/vim/gui/icon"; # if GTK_CHECK_VERSION(3,14,0) GdkScreen *screen = NULL; *************** *** 478,495 **** gdk_pixbuf_get_height(pixbuf)); if (size > 16) { ! /* An icon theme is supposed to provide fixed-size ! * image files for each size, e.g., 16, 22, 24, ... ! * Naturally, in contrast to GtkIconSet, GtkIconTheme ! * won't prepare size variants for us out of a single ! * fixed-size image. ! * ! * Currently, Vim provides 24x24 images only while the ! * icon size on the menu and the toolbar is set to 16x16 ! * by default. ! * ! * Resize them by ourselves until we have our own fully ! * fledged icon theme. */ GdkPixbuf *src = pixbuf; pixbuf = gdk_pixbuf_scale_simple(src, 16, 16, --- 478,495 ---- gdk_pixbuf_get_height(pixbuf)); if (size > 16) { ! // An icon theme is supposed to provide fixed-size ! // image files for each size, e.g., 16, 22, 24, ... ! // Naturally, in contrast to GtkIconSet, GtkIconTheme ! // won't prepare size variants for us out of a single ! // fixed-size image. ! // ! // Currently, Vim provides 24x24 images only while the ! // icon size on the menu and the toolbar is set to 16x16 ! // by default. ! // ! // Resize them by ourselves until we have our own fully ! // fledged icon theme. GdkPixbuf *src = pixbuf; pixbuf = gdk_pixbuf_scale_simple(src, 16, 16, *************** *** 503,509 **** g_object_unref(pixbuf); } } ! # else /* !GTK_CHECK_VERSION(3,0.0) */ GtkIconFactory * const factory = gtk_icon_factory_new(); IconNames *names; --- 503,509 ---- g_object_unref(pixbuf); } } ! # else // !GTK_CHECK_VERSION(3,0.0) GtkIconFactory * const factory = gtk_icon_factory_new(); IconNames *names; *************** *** 525,535 **** gtk_icon_factory_add_default(factory); g_object_unref(factory); ! # endif /* !GTK_CHECK_VERSION(3,0,0) */ ! # endif /* defined(USE_GRESOURCE) */ } ! #endif /* FEAT_TOOLBAR */ #if defined(FEAT_MENU) || defined(PROTO) --- 525,535 ---- gtk_icon_factory_add_default(factory); g_object_unref(factory); ! # endif // !GTK_CHECK_VERSION(3,0,0) ! # endif // defined(USE_GRESOURCE) } ! #endif // FEAT_TOOLBAR #if defined(FEAT_MENU) || defined(PROTO) *************** *** 597,605 **** char_u *text; int use_mnemonic; ! /* It would be neat to have image menu items, but that would require major ! * changes to Vim's menu system. Not to mention that all the translations ! * had to be updated. */ menu->id = gtk_menu_item_new(); # if GTK_CHECK_VERSION(3,2,0) box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20); --- 597,605 ---- char_u *text; int use_mnemonic; ! // It would be neat to have image menu items, but that would require major ! // changes to Vim's menu system. Not to mention that all the translations ! // had to be updated. menu->id = gtk_menu_item_new(); # if GTK_CHECK_VERSION(3,2,0) box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20); *************** *** 653,659 **** menu_item_new(menu, parent_widget); # if !GTK_CHECK_VERSION(3,4,0) ! /* since the tearoff should always appear first, increment idx */ if (parent != NULL && !menu_is_popup(parent->name)) ++idx; # endif --- 653,659 ---- menu_item_new(menu, parent_widget); # if !GTK_CHECK_VERSION(3,4,0) ! // since the tearoff should always appear first, increment idx if (parent != NULL && !menu_is_popup(parent->name)) ++idx; # endif *************** *** 722,729 **** text = CONVERT_TO_UTF8(menu->dname); tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); if (tooltip != NULL && !utf_valid_string(tooltip, NULL)) ! /* Invalid text, can happen when 'encoding' is changed. Avoid ! * a nasty GTK error message, skip the tooltip. */ CONVERT_TO_UTF8_FREE(tooltip); # if GTK_CHECK_VERSION(3,0,0) --- 722,729 ---- text = CONVERT_TO_UTF8(menu->dname); tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); if (tooltip != NULL && !utf_valid_string(tooltip, NULL)) ! // Invalid text, can happen when 'encoding' is changed. Avoid ! // a nasty GTK error message, skip the tooltip. CONVERT_TO_UTF8_FREE(tooltip); # if GTK_CHECK_VERSION(3,0,0) *************** *** 764,785 **** } } else ! # endif /* FEAT_TOOLBAR */ { ! /* No parent, must be a non-menubar menu */ if (parent == NULL || parent->submenu_id == NULL) return; # if !GTK_CHECK_VERSION(3,4,0) ! /* Make place for the possible tearoff handle item. Not in the popup ! * menu, it doesn't have a tearoff item. */ if (!menu_is_popup(parent->name)) ++idx; # endif if (menu_is_separator(menu->name)) { ! /* Separator: Just add it */ # if GTK_CHECK_VERSION(3,0,0) menu->id = gtk_separator_menu_item_new(); # else --- 764,785 ---- } } else ! # endif // FEAT_TOOLBAR { ! // No parent, must be a non-menubar menu if (parent == NULL || parent->submenu_id == NULL) return; # if !GTK_CHECK_VERSION(3,4,0) ! // Make place for the possible tearoff handle item. Not in the popup ! // menu, it doesn't have a tearoff item. if (!menu_is_popup(parent->name)) ++idx; # endif if (menu_is_separator(menu->name)) { ! // Separator: Just add it # if GTK_CHECK_VERSION(3,0,0) menu->id = gtk_separator_menu_item_new(); # else *************** *** 793,799 **** return; } ! /* Add textual menu item. */ menu_item_new(menu, parent->submenu_id); gtk_widget_show(menu->id); gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id), --- 793,799 ---- return; } ! // Add textual menu item. menu_item_new(menu, parent->submenu_id); gtk_widget_show(menu->id); gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id), *************** *** 804,810 **** G_CALLBACK(menu_item_activate), menu); } } ! #endif /* FEAT_MENU */ void --- 804,810 ---- G_CALLBACK(menu_item_activate), menu); } } ! #endif // FEAT_MENU void *************** *** 859,865 **** void gui_mch_toggle_tearoffs(int enable UNUSED) { ! /* Do nothing */ } # else void --- 859,865 ---- void gui_mch_toggle_tearoffs(int enable UNUSED) { ! // Do nothing } # else void *************** *** 868,874 **** recurse_tearoffs(root_menu, enable); } # endif ! #endif /* FEAT_MENU */ #if defined(FEAT_TOOLBAR) static int --- 868,874 ---- recurse_tearoffs(root_menu, enable); } # endif ! #endif // FEAT_MENU #if defined(FEAT_TOOLBAR) static int *************** *** 885,891 **** return idx; } ! #endif /* FEAT_TOOLBAR */ #if defined(FEAT_TOOLBAR) || defined(PROTO) --- 885,891 ---- return idx; } ! #endif // FEAT_TOOLBAR #if defined(FEAT_TOOLBAR) || defined(PROTO) *************** *** 900,916 **** tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); if (tooltip != NULL && utf_valid_string(tooltip, NULL)) # if GTK_CHECK_VERSION(3,0,0) ! /* Only set the tooltip when it's valid utf-8. */ gtk_widget_set_tooltip_text(menu->id, (const gchar *)tooltip); # else ! /* Only set the tooltip when it's valid utf-8. */ gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips, menu->id, (const char *)tooltip, NULL); # endif CONVERT_TO_UTF8_FREE(tooltip); } } ! #endif /* FEAT_TOOLBAR */ #if defined(FEAT_MENU) || defined(PROTO) --- 900,916 ---- tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); if (tooltip != NULL && utf_valid_string(tooltip, NULL)) # if GTK_CHECK_VERSION(3,0,0) ! // Only set the tooltip when it's valid utf-8. gtk_widget_set_tooltip_text(menu->id, (const gchar *)tooltip); # else ! // Only set the tooltip when it's valid utf-8. gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips, menu->id, (const char *)tooltip, NULL); # endif CONVERT_TO_UTF8_FREE(tooltip); } } ! #endif // FEAT_TOOLBAR #if defined(FEAT_MENU) || defined(PROTO) *************** *** 920,932 **** void gui_mch_destroy_menu(vimmenu_T *menu) { ! /* Don't let gtk_container_remove automatically destroy menu->id. */ if (menu->id != NULL) g_object_ref(menu->id); ! /* Workaround for a spurious gtk warning in Ubuntu: "Trying to remove ! * a child that doesn't believe we're its parent." ! * Remove widget from gui.menubar before destroying it. */ if (menu->id != NULL && gui.menubar != NULL && gtk_widget_get_parent(menu->id) == gui.menubar) gtk_container_remove(GTK_CONTAINER(gui.menubar), menu->id); --- 920,932 ---- void gui_mch_destroy_menu(vimmenu_T *menu) { ! // Don't let gtk_container_remove automatically destroy menu->id. if (menu->id != NULL) g_object_ref(menu->id); ! // Workaround for a spurious gtk warning in Ubuntu: "Trying to remove ! // a child that doesn't believe we're its parent." ! // Remove widget from gui.menubar before destroying it. if (menu->id != NULL && gui.menubar != NULL && gtk_widget_get_parent(menu->id) == gui.menubar) gtk_container_remove(GTK_CONTAINER(gui.menubar), menu->id); *************** *** 953,959 **** gtk_widget_destroy(menu->id); } else ! # endif /* FEAT_TOOLBAR */ { if (menu->submenu_id != NULL) gtk_widget_destroy(menu->submenu_id); --- 953,959 ---- gtk_widget_destroy(menu->id); } else ! # endif // FEAT_TOOLBAR { if (menu->submenu_id != NULL) gtk_widget_destroy(menu->submenu_id); *************** *** 967,973 **** menu->submenu_id = NULL; menu->id = NULL; } ! #endif /* FEAT_MENU */ /* --- 967,973 ---- menu->submenu_id = NULL; menu->id = NULL; } ! #endif // FEAT_MENU /* *************** *** 1019,1025 **** int dragging = FALSE; #ifdef FEAT_XIM ! /* cancel any preediting */ if (im_is_preediting()) xim_reset(); #endif --- 1019,1025 ---- int dragging = FALSE; #ifdef FEAT_XIM ! // cancel any preediting if (im_is_preediting()) xim_reset(); #endif *************** *** 1048,1079 **** int width; int height; ! /* vertical scrollbar: need to set "dragging" properly in case ! * there are closed folds. */ gdk_window_get_pointer(sb->id->window, &x, &y, &state); gdk_window_get_size(sb->id->window, &width, &height); if (x >= 0 && x < width && y >= 0 && y < height) { if (y < width) { ! /* up arrow: move one (closed fold) line up */ dragging = FALSE; value = sb->wp->w_topline - 2; } else if (y > height - width) { ! /* down arrow: move one (closed fold) line down */ dragging = FALSE; value = sb->wp->w_topline; } } } } ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ gui_drag_scrollbar(sb, value, dragging); } ! /* SBAR_VERT or SBAR_HORIZ */ void gui_mch_create_scrollbar(scrollbar_T *sb, int orient) { --- 1048,1079 ---- int width; int height; ! // vertical scrollbar: need to set "dragging" properly in case ! // there are closed folds. gdk_window_get_pointer(sb->id->window, &x, &y, &state); gdk_window_get_size(sb->id->window, &width, &height); if (x >= 0 && x < width && y >= 0 && y < height) { if (y < width) { ! // up arrow: move one (closed fold) line up dragging = FALSE; value = sb->wp->w_topline - 2; } else if (y > height - width) { ! // down arrow: move one (closed fold) line down dragging = FALSE; value = sb->wp->w_topline; } } } } ! #endif // !GTK_CHECK_VERSION(3,0,0) gui_drag_scrollbar(sb, value, dragging); } ! // SBAR_VERT or SBAR_HORIZ void gui_mch_create_scrollbar(scrollbar_T *sb, int orient) { *************** *** 1191,1215 **** title = CONVERT_TO_UTF8(title); ! /* GTK has a bug, it only works with an absolute path. */ if (initdir == NULL || *initdir == NUL) mch_dirname(dirbuf, MAXPATHL); else if (vim_FullName(initdir, dirbuf, MAXPATHL - 2, FALSE) == FAIL) dirbuf[0] = NUL; ! /* Always need a trailing slash for a directory. */ add_pathsep(dirbuf); ! /* If our pointer is currently hidden, then we should show it. */ gui_mch_mousehide(FALSE); ! /* Hack: The GTK file dialog warns when it can't access a new file, this ! * makes it shut up. http://bugzilla.gnome.org/show_bug.cgi?id=664587 */ log_handler = g_log_set_handler(domain, G_LOG_LEVEL_WARNING, recent_func_log_func, NULL); #ifdef USE_FILE_CHOOSER ! /* We create the dialog each time, so that the button text can be "Open" ! * or "Save" according to the action. */ fc = gtk_file_chooser_dialog_new((const gchar *)title, GTK_WINDOW(gui.mainwin), saving ? GTK_FILE_CHOOSER_ACTION_SAVE --- 1191,1215 ---- title = CONVERT_TO_UTF8(title); ! // GTK has a bug, it only works with an absolute path. if (initdir == NULL || *initdir == NUL) mch_dirname(dirbuf, MAXPATHL); else if (vim_FullName(initdir, dirbuf, MAXPATHL - 2, FALSE) == FAIL) dirbuf[0] = NUL; ! // Always need a trailing slash for a directory. add_pathsep(dirbuf); ! // If our pointer is currently hidden, then we should show it. gui_mch_mousehide(FALSE); ! // Hack: The GTK file dialog warns when it can't access a new file, this ! // makes it shut up. http://bugzilla.gnome.org/show_bug.cgi?id=664587 log_handler = g_log_set_handler(domain, G_LOG_LEVEL_WARNING, recent_func_log_func, NULL); #ifdef USE_FILE_CHOOSER ! // We create the dialog each time, so that the button text can be "Open" ! // or "Save" according to the action. fc = gtk_file_chooser_dialog_new((const gchar *)title, GTK_WINDOW(gui.mainwin), saving ? GTK_FILE_CHOOSER_ACTION_SAVE *************** *** 1278,1288 **** } gtk_widget_destroy(GTK_WIDGET(fc)); ! #else /* !USE_FILE_CHOOSER */ if (gui.filedlg == NULL) { ! GtkFileSelection *fs; /* shortcut */ gui.filedlg = gtk_file_selection_new((const gchar *)title); gtk_window_set_modal(GTK_WINDOW(gui.filedlg), TRUE); --- 1278,1288 ---- } gtk_widget_destroy(GTK_WIDGET(fc)); ! #else // !USE_FILE_CHOOSER if (gui.filedlg == NULL) { ! GtkFileSelection *fs; // shortcut gui.filedlg = gtk_file_selection_new((const gchar *)title); gtk_window_set_modal(GTK_WINDOW(gui.filedlg), TRUE); *************** *** 1296,1302 **** "clicked", GTK_SIGNAL_FUNC(browse_ok_cb), &gui); gtk_signal_connect(GTK_OBJECT(fs->cancel_button), "clicked", GTK_SIGNAL_FUNC(browse_cancel_cb), &gui); ! /* gtk_signal_connect() doesn't work for destroy, it causes a hang */ gtk_signal_connect_object(GTK_OBJECT(gui.filedlg), "destroy", GTK_SIGNAL_FUNC(browse_destroy_cb), GTK_OBJECT(gui.filedlg)); --- 1296,1302 ---- "clicked", GTK_SIGNAL_FUNC(browse_ok_cb), &gui); gtk_signal_connect(GTK_OBJECT(fs->cancel_button), "clicked", GTK_SIGNAL_FUNC(browse_cancel_cb), &gui); ! // gtk_signal_connect() doesn't work for destroy, it causes a hang gtk_signal_connect_object(GTK_OBJECT(gui.filedlg), "destroy", GTK_SIGNAL_FUNC(browse_destroy_cb), GTK_OBJECT(gui.filedlg)); *************** *** 1304,1310 **** else gtk_window_set_title(GTK_WINDOW(gui.filedlg), (const gchar *)title); ! /* Concatenate "initdir" and "dflt". */ if (dflt != NULL && *dflt != NUL && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL) STRCAT(dirbuf, dflt); --- 1304,1310 ---- else gtk_window_set_title(GTK_WINDOW(gui.filedlg), (const gchar *)title); ! // Concatenate "initdir" and "dflt". if (dflt != NULL && *dflt != NUL && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL) STRCAT(dirbuf, dflt); *************** *** 1314,1327 **** gtk_widget_show(gui.filedlg); gtk_main(); ! #endif /* !USE_FILE_CHOOSER */ g_log_remove_handler(domain, log_handler); CONVERT_TO_UTF8_FREE(title); if (gui.browse_fname == NULL) return NULL; ! /* shorten the file name if possible */ return vim_strsave(shorten_fname1(gui.browse_fname)); } --- 1314,1327 ---- gtk_widget_show(gui.filedlg); gtk_main(); ! #endif // !USE_FILE_CHOOSER g_log_remove_handler(domain, log_handler); CONVERT_TO_UTF8_FREE(title); if (gui.browse_fname == NULL) return NULL; ! // shorten the file name if possible return vim_strsave(shorten_fname1(gui.browse_fname)); } *************** *** 1337,1346 **** char_u *title, char_u *initdir) { ! # if defined(GTK_FILE_CHOOSER) /* Only in GTK 2.4 and later. */ char_u dirbuf[MAXPATHL]; char_u *p; ! GtkWidget *dirdlg; /* file selection dialog */ char_u *dirname = NULL; title = CONVERT_TO_UTF8(title); --- 1337,1346 ---- char_u *title, char_u *initdir) { ! # if defined(GTK_FILE_CHOOSER) // Only in GTK 2.4 and later. char_u dirbuf[MAXPATHL]; char_u *p; ! GtkWidget *dirdlg; // file selection dialog char_u *dirname = NULL; title = CONVERT_TO_UTF8(title); *************** *** 1360,1381 **** CONVERT_TO_UTF8_FREE(title); ! /* if our pointer is currently hidden, then we should show it. */ gui_mch_mousehide(FALSE); ! /* GTK appears to insist on an absolute path. */ if (initdir == NULL || *initdir == NUL || vim_FullName(initdir, dirbuf, MAXPATHL - 10, FALSE) == FAIL) mch_dirname(dirbuf, MAXPATHL - 10); ! /* Always need a trailing slash for a directory. ! * Also add a dummy file name, so that we get to the directory. */ add_pathsep(dirbuf); STRCAT(dirbuf, "@zd(*&1|"); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dirdlg), (const gchar *)dirbuf); ! /* Run the dialog. */ if (gtk_dialog_run(GTK_DIALOG(dirdlg)) == GTK_RESPONSE_ACCEPT) dirname = (char_u *)gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dirdlg)); --- 1360,1381 ---- CONVERT_TO_UTF8_FREE(title); ! // if our pointer is currently hidden, then we should show it. gui_mch_mousehide(FALSE); ! // GTK appears to insist on an absolute path. if (initdir == NULL || *initdir == NUL || vim_FullName(initdir, dirbuf, MAXPATHL - 10, FALSE) == FAIL) mch_dirname(dirbuf, MAXPATHL - 10); ! // Always need a trailing slash for a directory. ! // Also add a dummy file name, so that we get to the directory. add_pathsep(dirbuf); STRCAT(dirbuf, "@zd(*&1|"); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dirdlg), (const gchar *)dirbuf); ! // Run the dialog. if (gtk_dialog_run(GTK_DIALOG(dirdlg)) == GTK_RESPONSE_ACCEPT) dirname = (char_u *)gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dirdlg)); *************** *** 1383,1401 **** if (dirname == NULL) return NULL; ! /* shorten the file name if possible */ p = vim_strsave(shorten_fname1(dirname)); g_free(dirname); return p; ! # else /* !defined(GTK_FILE_CHOOSER) */ ! /* For GTK 2.2 and earlier: fall back to ordinary file selector. */ return gui_mch_browse(0, title, NULL, NULL, initdir, NULL); ! # endif /* !defined(GTK_FILE_CHOOSER) */ } ! #endif /* FEAT_BROWSE */ #if defined(FEAT_GUI_DIALOG) || defined(PROTO) --- 1383,1401 ---- if (dirname == NULL) return NULL; ! // shorten the file name if possible p = vim_strsave(shorten_fname1(dirname)); g_free(dirname); return p; ! # else // !defined(GTK_FILE_CHOOSER) ! // For GTK 2.2 and earlier: fall back to ordinary file selector. return gui_mch_browse(0, title, NULL, NULL, initdir, NULL); ! # endif // !defined(GTK_FILE_CHOOSER) } ! #endif // FEAT_BROWSE #if defined(FEAT_GUI_DIALOG) || defined(PROTO) *************** *** 1470,1476 **** else MB_PTR_ADV(p); } ! array[count] = NULL; /* currently not relied upon, but doesn't hurt */ } *n_buttons = count; --- 1470,1476 ---- else MB_PTR_ADV(p); } ! array[count] = NULL; // currently not relied upon, but doesn't hurt } *n_buttons = count; *************** *** 1546,1567 **** dialog_add_buttons(GtkDialog *dialog, char_u *button_string) { char **ok; ! char **ync; /* "yes no cancel" */ char **buttons; int n_buttons = 0; int idx; ! button_string = vim_strsave(button_string); /* must be writable */ if (button_string == NULL) return; ! /* Check 'v' flag in 'guioptions': vertical button placement. */ if (vim_strchr(p_go, GO_VERTICAL) != NULL) { # if GTK_CHECK_VERSION(3,0,0) ! /* Add GTK+ 3 code if necessary. */ ! /* N.B. GTK+ 3 doesn't allow you to access vbox and action_area via ! * the C API. */ # else GtkWidget *vbutton_box; --- 1546,1567 ---- dialog_add_buttons(GtkDialog *dialog, char_u *button_string) { char **ok; ! char **ync; // "yes no cancel" char **buttons; int n_buttons = 0; int idx; ! button_string = vim_strsave(button_string); // must be writable if (button_string == NULL) return; ! // Check 'v' flag in 'guioptions': vertical button placement. if (vim_strchr(p_go, GO_VERTICAL) != NULL) { # if GTK_CHECK_VERSION(3,0,0) ! // Add GTK+ 3 code if necessary. ! // N.B. GTK+ 3 doesn't allow you to access vbox and action_area via ! // the C API. # else GtkWidget *vbutton_box; *************** *** 1569,1575 **** gtk_widget_show(vbutton_box); gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbutton_box, TRUE, FALSE, 0); ! /* Overrule the "action_area" value, hopefully this works... */ GTK_DIALOG(dialog)->action_area = vbutton_box; # endif } --- 1569,1575 ---- gtk_widget_show(vbutton_box); gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbutton_box, TRUE, FALSE, 0); ! // Overrule the "action_area" value, hopefully this works... GTK_DIALOG(dialog)->action_area = vbutton_box; # endif } *************** *** 1604,1610 **** * since anyone can create their own dialogs using Vim functions. * Thus we have to check for those too. */ ! if (ok != NULL && ync != NULL) /* almost impossible to fail */ { # if GTK_CHECK_VERSION(3,10,0) if (button_equal(label, ok[0])) label = _("OK"); --- 1604,1610 ---- * since anyone can create their own dialogs using Vim functions. * Thus we have to check for those too. */ ! if (ok != NULL && ync != NULL) // almost impossible to fail { # if GTK_CHECK_VERSION(3,10,0) if (button_equal(label, ok[0])) label = _("OK"); *************** *** 1649,1657 **** */ typedef struct _DialogInfo { ! int ignore_enter; /* no default button, ignore "Enter" */ ! int noalt; /* accept accelerators without Alt */ ! GtkDialog *dialog; /* Widget of the dialog */ } DialogInfo; static gboolean --- 1649,1657 ---- */ typedef struct _DialogInfo { ! int ignore_enter; // no default button, ignore "Enter" ! int noalt; // accept accelerators without Alt ! GtkDialog *dialog; // Widget of the dialog } DialogInfo; static gboolean *************** *** 1659,1672 **** { DialogInfo *di = (DialogInfo *)data; ! /* Ignore hitting Enter (or Space) when there is no default button. */ if (di->ignore_enter && (event->keyval == GDK_Return || event->keyval == ' ')) return TRUE; ! else /* A different key was pressed, return to normal behavior */ di->ignore_enter = FALSE; ! /* Close the dialog when hitting "Esc". */ if (event->keyval == GDK_Escape) { gtk_dialog_response(di->dialog, GTK_RESPONSE_REJECT); --- 1659,1672 ---- { DialogInfo *di = (DialogInfo *)data; ! // Ignore hitting Enter (or Space) when there is no default button. if (di->ignore_enter && (event->keyval == GDK_Return || event->keyval == ' ')) return TRUE; ! else // A different key was pressed, return to normal behavior di->ignore_enter = FALSE; ! // Close the dialog when hitting "Esc". if (event->keyval == GDK_Escape) { gtk_dialog_response(di->dialog, GTK_RESPONSE_REJECT); *************** *** 1681,1696 **** gtk_window_get_mnemonic_modifier(GTK_WINDOW(widget))); } ! return FALSE; /* continue emission */ } int ! gui_mch_dialog(int type, /* type of dialog */ ! char_u *title, /* title of dialog */ ! char_u *message, /* message text */ ! char_u *buttons, /* names of buttons */ ! int def_but, /* default button */ ! char_u *textfield, /* text for textfield or NULL */ int ex_cmd UNUSED) { GtkWidget *dialog; --- 1681,1696 ---- gtk_window_get_mnemonic_modifier(GTK_WINDOW(widget))); } ! return FALSE; // continue emission } int ! gui_mch_dialog(int type, // type of dialog ! char_u *title, // title of dialog ! char_u *message, // message text ! char_u *buttons, // names of buttons ! int def_but, // default button ! char_u *textfield, // text for textfield or NULL int ex_cmd UNUSED) { GtkWidget *dialog; *************** *** 1710,1716 **** entry = gtk_entry_new(); gtk_widget_show(entry); ! /* Make Enter work like pressing OK. */ gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); text = CONVERT_TO_UTF8(textfield); --- 1710,1716 ---- entry = gtk_entry_new(); gtk_widget_show(entry); ! // Make Enter work like pressing OK. gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); text = CONVERT_TO_UTF8(textfield); *************** *** 1748,1755 **** else dialoginfo.noalt = TRUE; ! /* Allow activation of mnemonic accelerators without pressing when ! * there is no textfield. Handle pressing Esc. */ g_signal_connect(G_OBJECT(dialog), "key-press-event", G_CALLBACK(&dialog_key_press_event_cb), &dialoginfo); --- 1748,1755 ---- else dialoginfo.noalt = TRUE; ! // Allow activation of mnemonic accelerators without pressing when ! // there is no textfield. Handle pressing Esc. g_signal_connect(G_OBJECT(dialog), "key-press-event", G_CALLBACK(&dialog_key_press_event_cb), &dialoginfo); *************** *** 1759,1776 **** dialoginfo.ignore_enter = FALSE; } else ! /* No default button, ignore pressing Enter. */ dialoginfo.ignore_enter = TRUE; ! /* Show the mouse pointer if it's currently hidden. */ gui_mch_mousehide(FALSE); response = gtk_dialog_run(GTK_DIALOG(dialog)); ! /* GTK_RESPONSE_NONE means the dialog was programmatically destroyed. */ if (response != GTK_RESPONSE_NONE) { ! if (response == GTK_RESPONSE_ACCEPT) /* Enter pressed */ response = def_but; if (textfield != NULL) { --- 1759,1776 ---- dialoginfo.ignore_enter = FALSE; } else ! // No default button, ignore pressing Enter. dialoginfo.ignore_enter = TRUE; ! // Show the mouse pointer if it's currently hidden. gui_mch_mousehide(FALSE); response = gtk_dialog_run(GTK_DIALOG(dialog)); ! // GTK_RESPONSE_NONE means the dialog was programmatically destroyed. if (response != GTK_RESPONSE_NONE) { ! if (response == GTK_RESPONSE_ACCEPT) // Enter pressed response = def_but; if (textfield != NULL) { *************** *** 1787,1793 **** return response > 0 ? response : 0; } ! #endif /* FEAT_GUI_DIALOG */ #if defined(FEAT_MENU) || defined(PROTO) --- 1787,1793 ---- return response > 0 ? response : 0; } ! #endif // FEAT_GUI_DIALOG #if defined(FEAT_MENU) || defined(PROTO) *************** *** 1828,1843 **** "vim-has-im-menu", GINT_TO_POINTER(TRUE)); } # endif ! # endif /* FEAT_XIM */ # if GTK_CHECK_VERSION(3,22,2) { GdkEventButton trigger; ! /* A pseudo event to have gtk_menu_popup_at_pointer() work. Since the ! * function calculates the popup menu position on the basis of the ! * actual pointer position when it is invoked, the fields x, y, x_root ! * and y_root are set to zero for convenience. */ trigger.type = GDK_BUTTON_PRESS; trigger.window = gtk_widget_get_window(gui.drawarea); trigger.send_event = FALSE; --- 1828,1843 ---- "vim-has-im-menu", GINT_TO_POINTER(TRUE)); } # endif ! # endif // FEAT_XIM # if GTK_CHECK_VERSION(3,22,2) { GdkEventButton trigger; ! // A pseudo event to have gtk_menu_popup_at_pointer() work. Since the ! // function calculates the popup menu position on the basis of the ! // actual pointer position when it is invoked, the fields x, y, x_root ! // and y_root are set to zero for convenience. trigger.type = GDK_BUTTON_PRESS; trigger.window = gtk_widget_get_window(gui.drawarea); trigger.send_event = FALSE; *************** *** 1862,1869 **** #endif } ! /* Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to ! * popup_menu_position_func(). */ static int popup_mouse_pos; /* --- 1862,1869 ---- #endif } ! // Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to ! // popup_menu_position_func(). static int popup_mouse_pos; /* *************** *** 1892,1898 **** else if (curwin != NULL && gui.drawarea != NULL && gtk_widget_get_window(gui.drawarea) != NULL) { ! /* Find the cursor position in the current window */ *x += FILL_X(curwin->w_wincol + curwin->w_wcol + 1) + 1; *y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1; } --- 1892,1898 ---- else if (curwin != NULL && gui.drawarea != NULL && gtk_widget_get_window(gui.drawarea) != NULL) { ! // Find the cursor position in the current window *x += FILL_X(curwin->w_wincol + curwin->w_wcol + 1) + 1; *y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1; } *************** *** 1913,1923 **** GdkWindow * const win = gtk_widget_get_window(gui.drawarea); GdkEventButton trigger; ! /* A pseudo event to have gtk_menu_popup_at_*() functions work. Since ! * the position where the menu pops up is automatically adjusted by ! * the functions, none of the fields x, y, x_root and y_root has to be ! * set to a specific value here; therefore, they are set to zero for ! * convenience.*/ trigger.type = GDK_BUTTON_PRESS; trigger.window = win; trigger.send_event = FALSE; --- 1913,1923 ---- GdkWindow * const win = gtk_widget_get_window(gui.drawarea); GdkEventButton trigger; ! // A pseudo event to have gtk_menu_popup_at_*() functions work. Since ! // the position where the menu pops up is automatically adjusted by ! // the functions, none of the fields x, y, x_root and y_root has to be ! // set to a specific value here; therefore, they are set to zero for ! // convenience. trigger.type = GDK_BUTTON_PRESS; trigger.window = win; trigger.send_event = FALSE; *************** *** 1961,1967 **** } } ! #endif /* FEAT_MENU */ /* --- 1961,1967 ---- } } ! #endif // FEAT_MENU /* *************** *** 1970,1985 **** typedef struct _SharedFindReplace { ! GtkWidget *dialog; /* the main dialog widget */ ! GtkWidget *wword; /* 'Whole word only' check button */ ! GtkWidget *mcase; /* 'Match case' check button */ ! GtkWidget *up; /* search direction 'Up' radio button */ ! GtkWidget *down; /* search direction 'Down' radio button */ ! GtkWidget *what; /* 'Find what' entry text widget */ ! GtkWidget *with; /* 'Replace with' entry text widget */ ! GtkWidget *find; /* 'Find Next' action button */ ! GtkWidget *replace; /* 'Replace With' action button */ ! GtkWidget *all; /* 'Replace All' action button */ } SharedFindReplace; static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; --- 1970,1985 ---- typedef struct _SharedFindReplace { ! GtkWidget *dialog; // the main dialog widget ! GtkWidget *wword; // 'Whole word only' check button ! GtkWidget *mcase; // 'Match case' check button ! GtkWidget *up; // search direction 'Up' radio button ! GtkWidget *down; // search direction 'Down' radio button ! GtkWidget *what; // 'Find what' entry text widget ! GtkWidget *with; // 'Replace with' entry text widget ! GtkWidget *find; // 'Find Next' action button ! GtkWidget *replace; // 'Replace With' action button ! GtkWidget *all; // 'Replace All' action button } SharedFindReplace; static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; *************** *** 1991,2003 **** GdkEventKey *event, SharedFindReplace *frdp) { ! /* If the user is holding one of the key modifiers we will just bail out, ! * thus preserving the possibility of normal focus traversal. ! */ if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) return FALSE; ! /* the Escape key synthesizes a cancellation action */ if (event->keyval == GDK_Escape) { gtk_widget_hide(frdp->dialog); --- 1991,2002 ---- GdkEventKey *event, SharedFindReplace *frdp) { ! // If the user is holding one of the key modifiers we will just bail out, ! // thus preserving the possibility of normal focus traversal. if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) return FALSE; ! // the Escape key synthesizes a cancellation action if (event->keyval == GDK_Escape) { gtk_widget_hide(frdp->dialog); *************** *** 2005,2013 **** return TRUE; } ! /* It would be delightful if it where possible to do search history ! * operations on the K_UP and K_DOWN keys here. ! */ return FALSE; } --- 2004,2011 ---- return TRUE; } ! // It would be delightful if it where possible to do search history ! // operations on the K_UP and K_DOWN keys here. return FALSE; } *************** *** 2093,2115 **** g_return_val_if_fail(GTK_IS_ENTRY(entry) == TRUE, 0); #if GTK_CHECK_VERSION(2,18,0) ! /* 2.18 introduced a new object GtkEntryBuffer to handle text data for ! * GtkEntry instead of letting each instance of the latter have its own ! * storage for that. The code below is almost identical to the ! * implementation of gtk_entry_get_text_length() for the versions >= 2.18. ! */ return gtk_entry_buffer_get_length(gtk_entry_get_buffer(entry)); #elif GTK_CHECK_VERSION(2,14,0) ! /* 2.14 introduced a new function to avoid memory management bugs which can ! * happen when gtk_entry_get_text() is used without due care and attention. ! */ return gtk_entry_get_text_length(entry); #else ! /* gtk_entry_get_text() returns the pointer to the storage allocated ! * internally by the widget. Accordingly, use the one with great care: ! * Don't free it nor modify the contents it points to; call the function ! * every time you need the pointer since its value may have been changed ! * by the widget. */ return g_utf8_strlen(gtk_entry_get_text(entry), -1); #endif } --- 2091,2111 ---- g_return_val_if_fail(GTK_IS_ENTRY(entry) == TRUE, 0); #if GTK_CHECK_VERSION(2,18,0) ! // 2.18 introduced a new object GtkEntryBuffer to handle text data for ! // GtkEntry instead of letting each instance of the latter have its own ! // storage for that. The code below is almost identical to the ! // implementation of gtk_entry_get_text_length() for the versions >= 2.18. return gtk_entry_buffer_get_length(gtk_entry_get_buffer(entry)); #elif GTK_CHECK_VERSION(2,14,0) ! // 2.14 introduced a new function to avoid memory management bugs which can ! // happen when gtk_entry_get_text() is used without due care and attention. return gtk_entry_get_text_length(entry); #else ! // gtk_entry_get_text() returns the pointer to the storage allocated ! // internally by the widget. Accordingly, use the one with great care: ! // Don't free it nor modify the contents it points to; call the function ! // every time you need the pointer since its value may have been changed ! // by the widget. return g_utf8_strlen(gtk_entry_get_text(entry), -1); #endif } *************** *** 2117,2123 **** static void find_replace_dialog_create(char_u *arg, int do_replace) { ! GtkWidget *hbox; /* main top down box */ GtkWidget *actionarea; GtkWidget *table; GtkWidget *tmp; --- 2113,2119 ---- static void find_replace_dialog_create(char_u *arg, int do_replace) { ! GtkWidget *hbox; // main top down box GtkWidget *actionarea; GtkWidget *table; GtkWidget *tmp; *************** *** 2132,2138 **** frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); ! /* Get the search string to use. */ entry_text = get_find_dialog_text(arg, &wword, &mcase); if (entry_text != NULL && output_conv.vc_type != CONV_NONE) --- 2128,2134 ---- frdp = (do_replace) ? (&repl_widgets) : (&find_widgets); ! // Get the search string to use. entry_text = get_find_dialog_text(arg, &wword, &mcase); if (entry_text != NULL && output_conv.vc_type != CONV_NONE) *************** *** 2157,2165 **** } gtk_window_present(GTK_WINDOW(frdp->dialog)); ! /* For :promptfind dialog, always give keyboard focus to 'what' entry. ! * For :promptrepl dialog, give it to 'with' entry if 'what' has an ! * non-empty entry; otherwise, to 'what' entry. */ gtk_widget_grab_focus(frdp->what); if (do_replace && entry_get_text_length(GTK_ENTRY(frdp->what)) > 0) gtk_widget_grab_focus(frdp->with); --- 2153,2161 ---- } gtk_window_present(GTK_WINDOW(frdp->dialog)); ! // For :promptfind dialog, always give keyboard focus to 'what' entry. ! // For :promptrepl dialog, give it to 'with' entry if 'what' has an ! // non-empty entry; otherwise, to 'what' entry. gtk_widget_grab_focus(frdp->what); if (do_replace && entry_get_text_length(GTK_ENTRY(frdp->what)) > 0) gtk_widget_grab_focus(frdp->with); *************** *** 2170,2176 **** frdp->dialog = gtk_dialog_new(); #if GTK_CHECK_VERSION(3,0,0) ! /* Nothing equivalent to gtk_dialog_set_has_separator() in GTK+ 3. */ #else gtk_dialog_set_has_separator(GTK_DIALOG(frdp->dialog), FALSE); #endif --- 2166,2172 ---- frdp->dialog = gtk_dialog_new(); #if GTK_CHECK_VERSION(3,0,0) ! // Nothing equivalent to gtk_dialog_set_has_separator() in GTK+ 3. #else gtk_dialog_set_has_separator(GTK_DIALOG(frdp->dialog), FALSE); #endif *************** *** 2323,2329 **** GINT_TO_POINTER(FRD_FINDNEXT)); } ! /* whole word only button */ frdp->wword = gtk_check_button_new_with_label(CONV(_("Match whole word only"))); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword), (gboolean)wword); --- 2319,2325 ---- GINT_TO_POINTER(FRD_FINDNEXT)); } ! // whole word only button frdp->wword = gtk_check_button_new_with_label(CONV(_("Match whole word only"))); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword), (gboolean)wword); *************** *** 2342,2348 **** GTK_FILL, GTK_EXPAND, 2, 2); #endif ! /* match case button */ frdp->mcase = gtk_check_button_new_with_label(CONV(_("Match case"))); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase), (gboolean)mcase); --- 2338,2344 ---- GTK_FILL, GTK_EXPAND, 2, 2); #endif ! // match case button frdp->mcase = gtk_check_button_new_with_label(CONV(_("Match case"))); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase), (gboolean)mcase); *************** *** 2385,2391 **** gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); gtk_container_add(GTK_CONTAINER(tmp), vbox); ! /* 'Up' and 'Down' buttons */ frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up"))); gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0); frdp->down = gtk_radio_button_new_with_label( --- 2381,2387 ---- gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); gtk_container_add(GTK_CONTAINER(tmp), vbox); ! // 'Up' and 'Down' buttons frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up"))); gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0); frdp->down = gtk_radio_button_new_with_label( *************** *** 2395,2401 **** gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); ! /* vbox to hold the action buttons */ #if GTK_CHECK_VERSION(3,2,0) actionarea = gtk_button_box_new(GTK_ORIENTATION_VERTICAL); #else --- 2391,2397 ---- gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0); ! // vbox to hold the action buttons #if GTK_CHECK_VERSION(3,2,0) actionarea = gtk_button_box_new(GTK_ORIENTATION_VERTICAL); #else *************** *** 2404,2410 **** gtk_container_set_border_width(GTK_CONTAINER(actionarea), 2); gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); ! /* 'Find Next' button */ #if GTK_CHECK_VERSION(3,10,0) frdp->find = create_image_button(NULL, _("Find Next")); #else --- 2400,2406 ---- gtk_container_set_border_width(GTK_CONTAINER(actionarea), 2); gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0); ! // 'Find Next' button #if GTK_CHECK_VERSION(3,10,0) frdp->find = create_image_button(NULL, _("Find Next")); #else *************** *** 2423,2429 **** if (do_replace) { ! /* 'Replace' button */ #if GTK_CHECK_VERSION(3,10,0) frdp->replace = create_image_button(NULL, _("Replace")); #else --- 2419,2425 ---- if (do_replace) { ! // 'Replace' button #if GTK_CHECK_VERSION(3,10,0) frdp->replace = create_image_button(NULL, _("Replace")); #else *************** *** 2436,2442 **** G_CALLBACK(find_replace_cb), GINT_TO_POINTER(FRD_REPLACE)); ! /* 'Replace All' button */ #if GTK_CHECK_VERSION(3,10,0) frdp->all = create_image_button(NULL, _("Replace All")); #else --- 2432,2438 ---- G_CALLBACK(find_replace_cb), GINT_TO_POINTER(FRD_REPLACE)); ! // 'Replace All' button #if GTK_CHECK_VERSION(3,10,0) frdp->all = create_image_button(NULL, _("Replace All")); #else *************** *** 2450,2456 **** GINT_TO_POINTER(FRD_REPLACEALL)); } ! /* 'Cancel' button */ #if GTK_CHECK_VERSION(3,10,0) tmp = gtk_button_new_with_mnemonic(_("_Close")); #else --- 2446,2452 ---- GINT_TO_POINTER(FRD_REPLACEALL)); } ! // 'Cancel' button #if GTK_CHECK_VERSION(3,10,0) tmp = gtk_button_new_with_mnemonic(_("_Close")); #else *************** *** 2472,2478 **** #endif gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10); ! /* Suppress automatic show of the unused action area */ #if GTK_CHECK_VERSION(3,0,0) # if !GTK_CHECK_VERSION(3,12,0) gtk_widget_hide(gtk_dialog_get_action_area(GTK_DIALOG(frdp->dialog))); --- 2468,2474 ---- #endif gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10); ! // Suppress automatic show of the unused action area #if GTK_CHECK_VERSION(3,0,0) # if !GTK_CHECK_VERSION(3,12,0) gtk_widget_hide(gtk_dialog_get_action_area(GTK_DIALOG(frdp->dialog))); *************** *** 2514,2522 **** gboolean direction_down; SharedFindReplace *sfr; ! flags = (int)(long)data; /* avoid a lint warning here */ ! /* Get the search/replace strings from the dialog */ if (flags == FRD_FINDNEXT) { repl_text = NULL; --- 2510,2518 ---- gboolean direction_down; SharedFindReplace *sfr; ! flags = (int)(long)data; // avoid a lint warning here ! // Get the search/replace strings from the dialog if (flags == FRD_FINDNEXT) { repl_text = NULL; *************** *** 2543,2549 **** CONVERT_FROM_UTF8_FREE(find_text); } ! /* our usual callback function */ static void entry_activate_cb(GtkWidget *widget UNUSED, gpointer data) { --- 2539,2547 ---- CONVERT_FROM_UTF8_FREE(find_text); } ! /* ! * our usual callback function ! */ static void entry_activate_cb(GtkWidget *widget UNUSED, gpointer data) { *************** *** 2568,2574 **** entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); if (!entry_text) ! return; /* shouldn't happen */ nonempty = (entry_text[0] != '\0'); --- 2566,2572 ---- entry_text = gtk_entry_get_text(GTK_ENTRY(entry)); if (!entry_text) ! return; // shouldn't happen nonempty = (entry_text[0] != '\0'); *************** *** 2589,2596 **** void ex_helpfind(exarg_T *eap UNUSED) { ! /* This will fail when menus are not loaded. Well, it's only for ! * backwards compatibility anyway. */ do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp"); } --- 2587,2594 ---- void ex_helpfind(exarg_T *eap UNUSED) { ! // This will fail when menus are not loaded. Well, it's only for ! // backwards compatibility anyway. do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp"); } *************** *** 2601,2607 **** const gchar *message UNUSED, gpointer user_data UNUSED) { ! /* We just want to suppress the warnings. */ ! /* http://bugzilla.gnome.org/show_bug.cgi?id=664587 */ } #endif --- 2599,2605 ---- const gchar *message UNUSED, gpointer user_data UNUSED) { ! // We just want to suppress the warnings. ! // http://bugzilla.gnome.org/show_bug.cgi?id=664587 } #endif *** ../vim-8.1.2379/src/gui_gtk_f.c 2019-04-27 22:06:33.352200698 +0200 --- src/gui_gtk_f.c 2019-12-01 22:03:07.903084801 +0100 *************** *** 26,33 **** */ #include "vim.h" ! #include /* without this it compiles, but gives errors at ! runtime! */ #include "gui_gtk_f.h" #if !GTK_CHECK_VERSION(3,0,0) # include --- 26,33 ---- */ #include "vim.h" ! #include // without this it compiles, but gives errors at ! // runtime! #include "gui_gtk_f.h" #if !GTK_CHECK_VERSION(3,0,0) # include *************** *** 44,51 **** { GtkWidget *widget; GdkWindow *window; ! gint x; /* relative subwidget x position */ ! gint y; /* relative subwidget y position */ gint mapped; }; --- 44,51 ---- { GtkWidget *widget; GdkWindow *window; ! gint x; // relative subwidget x position ! gint y; // relative subwidget y position gint mapped; }; *************** *** 101,108 **** static GtkWidgetClass *parent_class = NULL; #endif ! /* Public interface ! */ GtkWidget * gtk_form_new(void) --- 101,107 ---- static GtkWidgetClass *parent_class = NULL; #endif ! // Public interface GtkWidget * gtk_form_new(void) *************** *** 128,134 **** g_return_if_fail(GTK_IS_FORM(form)); ! /* LINTED: avoid warning: conversion to 'unsigned long' */ child = g_new(GtkFormChild, 1); if (child == NULL) return; --- 127,133 ---- g_return_if_fail(GTK_IS_FORM(form)); ! // LINTED: avoid warning: conversion to 'unsigned long' child = g_new(GtkFormChild, 1); if (child == NULL) return; *************** *** 147,157 **** form->children = g_list_append(form->children, child); ! /* child->window must be created and attached to the widget _before_ ! * it has been realized, or else things will break with GTK2. Note ! * that gtk_widget_set_parent() realizes the widget if it's visible ! * and its parent is mapped. ! */ if (gtk_widget_get_realized(GTK_WIDGET(form))) gtk_form_attach_child_window(form, child); --- 146,155 ---- form->children = g_list_append(form->children, child); ! // child->window must be created and attached to the widget _before_ ! // it has been realized, or else things will break with GTK2. Note ! // that gtk_widget_set_parent() realizes the widget if it's visible ! // and its parent is mapped. if (gtk_widget_get_realized(GTK_WIDGET(form))) gtk_form_attach_child_window(form, child); *************** *** 212,219 **** } } ! /* Basic Object handling procedures ! */ #if GTK_CHECK_VERSION(3,0,0) G_DEFINE_TYPE(GtkForm, gtk_form, GTK_TYPE_CONTAINER) #else --- 210,216 ---- } } ! // Basic Object handling procedures #if GTK_CHECK_VERSION(3,0,0) G_DEFINE_TYPE(GtkForm, gtk_form, GTK_TYPE_CONTAINER) #else *************** *** 237,243 **** } return form_type; } ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ static void gtk_form_class_init(GtkFormClass *klass) --- 234,240 ---- } return form_type; } ! #endif // !GTK_CHECK_VERSION(3,0,0) static void gtk_form_class_init(GtkFormClass *klass) *************** *** 364,377 **** } ! /* After reading the documentation at ! * http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html ! * I think it should be possible to remove this function when compiling ! * against gtk-2.0. It doesn't seem to cause problems, though. ! * ! * Well, I reckon at least the gdk_window_show(form->bin_window) ! * is necessary. GtkForm is anything but a usual container widget. ! */ static void gtk_form_map(GtkWidget *widget) { --- 361,373 ---- } ! // After reading the documentation at ! // http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html ! // I think it should be possible to remove this function when compiling ! // against gtk-2.0. It doesn't seem to cause problems, though. ! // ! // Well, I reckon at least the gdk_window_show(form->bin_window) ! // is necessary. GtkForm is anything but a usual container widget. static void gtk_form_map(GtkWidget *widget) { *************** *** 480,486 **** *minimal_height = requisition.height; *natural_height = requisition.height; } ! #endif /* GTK_CHECK_VERSION(3,0,0) */ static void gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) --- 476,482 ---- *minimal_height = requisition.height; *natural_height = requisition.height; } ! #endif // GTK_CHECK_VERSION(3,0,0) static void gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) *************** *** 559,574 **** if (!gtk_widget_get_has_window(formchild->widget) && gtk_cairo_should_draw_window(cr, formchild->window)) { ! /* To get gtk_widget_draw() to work, it is required to call ! * gtk_widget_size_allocate() in advance with a well-posed ! * allocation for a given child widget in order to set a ! * certain private GtkWidget variable, called ! * widget->priv->alloc_need, to the proper value; otherwise, ! * gtk_widget_draw() fails and the relevant scrollbar won't ! * appear on the screen. ! * ! * Calling gtk_form_position_child() like this is one of ways ! * to make sure of that. */ gtk_form_position_child(form, formchild, TRUE); gtk_form_render_background(formchild->widget, cr); --- 555,570 ---- if (!gtk_widget_get_has_window(formchild->widget) && gtk_cairo_should_draw_window(cr, formchild->window)) { ! // To get gtk_widget_draw() to work, it is required to call ! // gtk_widget_size_allocate() in advance with a well-posed ! // allocation for a given child widget in order to set a ! // certain private GtkWidget variable, called ! // widget->priv->alloc_need, to the proper value; otherwise, ! // gtk_widget_draw() fails and the relevant scrollbar won't ! // appear on the screen. ! // ! // Calling gtk_form_position_child() like this is one of ways ! // to make sure of that. gtk_form_position_child(form, formchild, TRUE); gtk_form_render_background(formchild->widget, cr); *************** *** 577,583 **** return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr); } ! #else /* !GTK_CHECK_VERSION(3,0,0) */ static gint gtk_form_expose(GtkWidget *widget, GdkEventExpose *event) { --- 573,579 ---- return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr); } ! #else // !GTK_CHECK_VERSION(3,0,0) static gint gtk_form_expose(GtkWidget *widget, GdkEventExpose *event) { *************** *** 598,613 **** return FALSE; } ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ ! /* Container method ! */ static void gtk_form_remove(GtkContainer *container, GtkWidget *widget) { GList *tmp_list; GtkForm *form; ! GtkFormChild *child = NULL; /* init for gcc */ g_return_if_fail(GTK_IS_FORM(container)); --- 594,608 ---- return FALSE; } ! #endif // !GTK_CHECK_VERSION(3,0,0) ! // Container method static void gtk_form_remove(GtkContainer *container, GtkWidget *widget) { GList *tmp_list; GtkForm *form; ! GtkFormChild *child = NULL; // init for gcc g_return_if_fail(GTK_IS_FORM(container)); *************** *** 634,642 **** g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), FUNC2GENERIC(>k_form_child_unmap), child); ! /* FIXME: This will cause problems for reparenting NO_WINDOW ! * widgets out of a GtkForm ! */ gdk_window_set_user_data(child->window, NULL); gdk_window_destroy(child->window); } --- 629,636 ---- g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), FUNC2GENERIC(>k_form_child_unmap), child); ! // FIXME: This will cause problems for reparenting NO_WINDOW ! // widgets out of a GtkForm gdk_window_set_user_data(child->window, NULL); gdk_window_destroy(child->window); } *************** *** 676,689 **** } } ! /* Operations on children ! */ static void gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) { if (child->window != NULL) ! return; /* been there, done that */ if (!gtk_widget_get_has_window(child->widget)) { --- 670,682 ---- } } ! // Operations on children static void gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) { if (child->window != NULL) ! return; // been there, done that if (!gtk_widget_get_has_window(child->widget)) { *** ../vim-8.1.2379/src/gui_gtk_x11.c 2019-11-21 17:13:12.624361334 +0100 --- src/gui_gtk_x11.c 2019-12-01 22:07:57.277698589 +0100 *************** *** 31,37 **** #endif #ifdef FEAT_GUI_GNOME ! /* Gnome redefines _() and N_(). Grrr... */ # ifdef _ # undef _ # endif --- 31,37 ---- #endif #ifdef FEAT_GUI_GNOME ! // Gnome redefines _() and N_(). Grrr... # ifdef _ # undef _ # endif *************** *** 48,63 **** # undef bind_textdomain_codeset # endif # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS) ! # define ENABLE_NLS /* so the texts in the dialog boxes are translated */ # endif # include # include "version.h" ! /* missing prototype in bonobo-dock-item.h */ extern void bonobo_dock_item_set_behavior(BonoboDockItem *dock_item, BonoboDockItemBehavior beh); #endif #if !defined(FEAT_GUI_GTK) && defined(PROTO) ! /* When generating prototypes we don't want syntax errors. */ # define GdkAtom int # define GdkEventExpose int # define GdkEventFocus int --- 48,63 ---- # undef bind_textdomain_codeset # endif # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS) ! # define ENABLE_NLS // so the texts in the dialog boxes are translated # endif # include # include "version.h" ! // missing prototype in bonobo-dock-item.h extern void bonobo_dock_item_set_behavior(BonoboDockItem *dock_item, BonoboDockItemBehavior beh); #endif #if !defined(FEAT_GUI_GTK) && defined(PROTO) ! // When generating prototypes we don't want syntax errors. # define GdkAtom int # define GdkEventExpose int # define GdkEventFocus int *************** *** 105,111 **** #define GET_X_ATOM(atom) gdk_x11_atom_to_xatom_for_display( \ gtk_widget_get_display(gui.mainwin), atom) ! /* Selection type distinguishers */ enum { TARGET_TYPE_NONE, --- 105,111 ---- #define GET_X_ATOM(atom) gdk_x11_atom_to_xatom_for_display( \ gtk_widget_get_display(gui.mainwin), atom) ! // Selection type distinguishers enum { TARGET_TYPE_NONE, *************** *** 177,184 **** */ static GdkAtom html_atom = GDK_NONE; static GdkAtom utf8_string_atom = GDK_NONE; ! static GdkAtom vim_atom = GDK_NONE; /* Vim's own special selection format */ ! static GdkAtom vimenc_atom = GDK_NONE; /* Vim's extended selection format */ /* * Keycodes recognized by vim. --- 177,184 ---- */ static GdkAtom html_atom = GDK_NONE; static GdkAtom utf8_string_atom = GDK_NONE; ! static GdkAtom vim_atom = GDK_NONE; // Vim's own special selection format ! static GdkAtom vimenc_atom = GDK_NONE; // Vim's extended selection format /* * Keycodes recognized by vim. *************** *** 218,224 **** {GDK_F19, 'F', '9'}, {GDK_F20, 'F', 'A'}, {GDK_F21, 'F', 'B'}, ! {GDK_Pause, 'F', 'B'}, /* Pause == F21 according to netbeans.txt */ {GDK_F22, 'F', 'C'}, {GDK_F23, 'F', 'D'}, {GDK_F24, 'F', 'E'}, --- 218,224 ---- {GDK_F19, 'F', '9'}, {GDK_F20, 'F', 'A'}, {GDK_F21, 'F', 'B'}, ! {GDK_Pause, 'F', 'B'}, // Pause == F21 according to netbeans.txt {GDK_F22, 'F', 'C'}, {GDK_F23, 'F', 'D'}, {GDK_F24, 'F', 'E'}, *************** *** 249,255 **** {GDK_Prior, 'k', 'P'}, {GDK_Next, 'k', 'N'}, {GDK_Print, '%', '9'}, ! /* Keypad keys: */ {GDK_KP_Left, 'k', 'l'}, {GDK_KP_Right, 'k', 'r'}, {GDK_KP_Up, 'k', 'u'}, --- 249,255 ---- {GDK_Prior, 'k', 'P'}, {GDK_Next, 'k', 'N'}, {GDK_Print, '%', '9'}, ! // Keypad keys: {GDK_KP_Left, 'k', 'l'}, {GDK_KP_Right, 'k', 'r'}, {GDK_KP_Up, 'k', 'u'}, *************** *** 258,265 **** {GDK_KP_Delete, KS_EXTRA, (char_u)KE_KDEL}, {GDK_KP_Home, 'K', '1'}, {GDK_KP_End, 'K', '4'}, ! {GDK_KP_Prior, 'K', '3'}, /* page up */ ! {GDK_KP_Next, 'K', '5'}, /* page down */ {GDK_KP_Add, 'K', '6'}, {GDK_KP_Subtract, 'K', '7'}, --- 258,265 ---- {GDK_KP_Delete, KS_EXTRA, (char_u)KE_KDEL}, {GDK_KP_Home, 'K', '1'}, {GDK_KP_End, 'K', '4'}, ! {GDK_KP_Prior, 'K', '3'}, // page up ! {GDK_KP_Next, 'K', '5'}, // page down {GDK_KP_Add, 'K', '6'}, {GDK_KP_Subtract, 'K', '7'}, *************** *** 279,285 **** {GDK_KP_8, 'K', 'K'}, {GDK_KP_9, 'K', 'L'}, ! /* End of list marker: */ {0, 0, 0} }; --- 279,285 ---- {GDK_KP_8, 'K', 'K'}, {GDK_KP_9, 'K', 'L'}, ! // End of list marker: {0, 0, 0} }; *************** *** 295,308 **** #define ARG_ICONIC 7 #define ARG_ROLE 8 #define ARG_NETBEANS 9 ! #define ARG_XRM 10 /* ignored */ ! #define ARG_MENUFONT 11 /* ignored */ #define ARG_INDEX_MASK 0x00ff ! #define ARG_HAS_VALUE 0x0100 /* a value is expected after the argument */ ! #define ARG_NEEDS_GUI 0x0200 /* need to initialize the GUI for this */ ! #define ARG_FOR_GTK 0x0400 /* argument is handled by GTK+ or GNOME */ ! #define ARG_COMPAT_LONG 0x0800 /* accept -foo but substitute with --foo */ ! #define ARG_KEEP 0x1000 /* don't remove argument from argv[] */ /* * This table holds all the X GUI command line options allowed. This includes --- 295,308 ---- #define ARG_ICONIC 7 #define ARG_ROLE 8 #define ARG_NETBEANS 9 ! #define ARG_XRM 10 // ignored ! #define ARG_MENUFONT 11 // ignored #define ARG_INDEX_MASK 0x00ff ! #define ARG_HAS_VALUE 0x0100 // a value is expected after the argument ! #define ARG_NEEDS_GUI 0x0200 // need to initialize the GUI for this ! #define ARG_FOR_GTK 0x0400 // argument is handled by GTK+ or GNOME ! #define ARG_COMPAT_LONG 0x0800 // accept -foo but substitute with --foo ! #define ARG_KEEP 0x1000 // don't remove argument from argv[] /* * This table holds all the X GUI command line options allowed. This includes *************** *** 320,326 **** static const cmdline_option_T cmdline_options[] = { ! /* We handle these options ourselves */ {"-fn", ARG_FONT|ARG_HAS_VALUE}, {"-font", ARG_FONT|ARG_HAS_VALUE}, {"-geom", ARG_GEOMETRY|ARG_HAS_VALUE}, --- 320,326 ---- static const cmdline_option_T cmdline_options[] = { ! // We handle these options ourselves {"-fn", ARG_FONT|ARG_HAS_VALUE}, {"-font", ARG_FONT|ARG_HAS_VALUE}, {"-geom", ARG_GEOMETRY|ARG_HAS_VALUE}, *************** *** 336,347 **** {"-iconic", ARG_ICONIC}, {"--role", ARG_ROLE|ARG_HAS_VALUE}, #ifdef FEAT_NETBEANS_INTG ! {"-nb", ARG_NETBEANS}, /* non-standard value format */ ! {"-xrm", ARG_XRM|ARG_HAS_VALUE}, /* not implemented */ ! {"-mf", ARG_MENUFONT|ARG_HAS_VALUE}, /* not implemented */ ! {"-menufont", ARG_MENUFONT|ARG_HAS_VALUE}, /* not implemented */ #endif ! /* Arguments handled by GTK (and GNOME) internally. */ {"--g-fatal-warnings", ARG_FOR_GTK}, {"--gdk-debug", ARG_FOR_GTK|ARG_HAS_VALUE}, {"--gdk-no-debug", ARG_FOR_GTK|ARG_HAS_VALUE}, --- 336,347 ---- {"-iconic", ARG_ICONIC}, {"--role", ARG_ROLE|ARG_HAS_VALUE}, #ifdef FEAT_NETBEANS_INTG ! {"-nb", ARG_NETBEANS}, // non-standard value format ! {"-xrm", ARG_XRM|ARG_HAS_VALUE}, // not implemented ! {"-mf", ARG_MENUFONT|ARG_HAS_VALUE}, // not implemented ! {"-menufont", ARG_MENUFONT|ARG_HAS_VALUE}, // not implemented #endif ! // Arguments handled by GTK (and GNOME) internally. {"--g-fatal-warnings", ARG_FOR_GTK}, {"--gdk-debug", ARG_FOR_GTK|ARG_HAS_VALUE}, {"--gdk-no-debug", ARG_FOR_GTK|ARG_HAS_VALUE}, *************** *** 369,375 **** {"-?", ARG_FOR_GTK|ARG_NEEDS_GUI}, {"--help", ARG_FOR_GTK|ARG_NEEDS_GUI|ARG_KEEP}, {"--usage", ARG_FOR_GTK|ARG_NEEDS_GUI}, ! # if 0 /* conflicts with Vim's own --version argument */ {"--version", ARG_FOR_GTK|ARG_NEEDS_GUI}, # endif {"--disable-crash-dialog", ARG_FOR_GTK}, --- 369,375 ---- {"-?", ARG_FOR_GTK|ARG_NEEDS_GUI}, {"--help", ARG_FOR_GTK|ARG_NEEDS_GUI|ARG_KEEP}, {"--usage", ARG_FOR_GTK|ARG_NEEDS_GUI}, ! # if 0 // conflicts with Vim's own --version argument {"--version", ARG_FOR_GTK|ARG_NEEDS_GUI}, # endif {"--disable-crash-dialog", ARG_FOR_GTK}, *************** *** 441,454 **** while (i < *argc) { ! /* Don't waste CPU cycles on non-option arguments. */ if (argv[i][0] != '-' && argv[i][0] != '+') { ++i; continue; } ! /* Look for argv[i] in cmdline_options[] table. */ for (option = &cmdline_options[0]; option->name != NULL; ++option) { len = strlen(option->name); --- 441,454 ---- while (i < *argc) { ! // Don't waste CPU cycles on non-option arguments. if (argv[i][0] != '-' && argv[i][0] != '+') { ++i; continue; } ! // Look for argv[i] in cmdline_options[] table. for (option = &cmdline_options[0]; option->name != NULL; ++option) { len = strlen(option->name); *************** *** 457,467 **** { if (argv[i][len] == '\0') break; ! /* allow --foo=bar style */ if (argv[i][len] == '=' && (option->flags & ARG_HAS_VALUE)) break; #ifdef FEAT_NETBEANS_INTG ! /* darn, -nb has non-standard syntax */ if (vim_strchr((char_u *)":=", argv[i][len]) != NULL && (option->flags & ARG_INDEX_MASK) == ARG_NETBEANS) break; --- 457,467 ---- { if (argv[i][len] == '\0') break; ! // allow --foo=bar style if (argv[i][len] == '=' && (option->flags & ARG_HAS_VALUE)) break; #ifdef FEAT_NETBEANS_INTG ! // darn, -nb has non-standard syntax if (vim_strchr((char_u *)":=", argv[i][len]) != NULL && (option->flags & ARG_INDEX_MASK) == ARG_NETBEANS) break; *************** *** 470,482 **** else if ((option->flags & ARG_COMPAT_LONG) && strcmp(argv[i], option->name + 1) == 0) { ! /* Replace the standard X arguments "-name" and "-display" ! * with their GNU-style long option counterparts. */ argv[i] = (char *)option->name; break; } } ! if (option->name == NULL) /* no match */ { ++i; continue; --- 470,482 ---- else if ((option->flags & ARG_COMPAT_LONG) && strcmp(argv[i], option->name + 1) == 0) { ! // Replace the standard X arguments "-name" and "-display" ! // with their GNU-style long option counterparts. argv[i] = (char *)option->name; break; } } ! if (option->name == NULL) // no match { ++i; continue; *************** *** 484,499 **** if (option->flags & ARG_FOR_GTK) { ! /* Move the argument into gui_argv, which ! * will later be passed to gtk_init_check() */ gui_argv[gui_argc++] = argv[i]; } else { char *value = NULL; ! /* Extract the option's value if there is one. ! * Accept both "--foo bar" and "--foo=bar" style. */ if (option->flags & ARG_HAS_VALUE) { if (argv[i][len] == '=') --- 484,499 ---- if (option->flags & ARG_FOR_GTK) { ! // Move the argument into gui_argv, which ! // will later be passed to gtk_init_check() gui_argv[gui_argc++] = argv[i]; } else { char *value = NULL; ! // Extract the option's value if there is one. ! // Accept both "--foo bar" and "--foo=bar" style. if (option->flags & ARG_HAS_VALUE) { if (argv[i][len] == '=') *************** *** 502,508 **** value = argv[i + 1]; } ! /* Check for options handled by Vim itself */ switch (option->flags & ARG_INDEX_MASK) { case ARG_REVERSE: --- 502,508 ---- value = argv[i + 1]; } ! // Check for options handled by Vim itself switch (option->flags & ARG_INDEX_MASK) { case ARG_REVERSE: *************** *** 528,538 **** found_iconic_arg = TRUE; break; case ARG_ROLE: ! role_argument = value; /* used later in gui_mch_open() */ break; #ifdef FEAT_NETBEANS_INTG case ARG_NETBEANS: ! gui.dofork = FALSE; /* don't fork() when starting GUI */ netbeansArg = argv[i]; break; #endif --- 528,538 ---- found_iconic_arg = TRUE; break; case ARG_ROLE: ! role_argument = value; // used later in gui_mch_open() break; #ifdef FEAT_NETBEANS_INTG case ARG_NETBEANS: ! gui.dofork = FALSE; // don't fork() when starting GUI netbeansArg = argv[i]; break; #endif *************** *** 541,549 **** } } ! /* These arguments make gnome_program_init() print a message and exit. ! * Must start the GUI for this, otherwise ":gui" will exit later! ! * Only when the GUI can start. */ if ((option->flags & ARG_NEEDS_GUI) && gui_mch_early_init_check(FALSE) == OK) gui.starting = TRUE; --- 541,549 ---- } } ! // These arguments make gnome_program_init() print a message and exit. ! // Must start the GUI for this, otherwise ":gui" will exit later! ! // Only when the GUI can start. if ((option->flags & ARG_NEEDS_GUI) && gui_mch_early_init_check(FALSE) == OK) gui.starting = TRUE; *************** *** 552,563 **** ++i; else { ! /* Remove the flag from the argument vector. */ if (--*argc > i) { int n_strip = 1; ! /* Move the argument's value as well, if there is one. */ if ((option->flags & ARG_HAS_VALUE) && argv[i][len] != '=' && strcmp(argv[i + 1], "--") != 0) --- 552,563 ---- ++i; else { ! // Remove the flag from the argument vector. if (--*argc > i) { int n_strip = 1; ! // Move the argument's value as well, if there is one. if ((option->flags & ARG_HAS_VALUE) && argv[i][len] != '=' && strcmp(argv[i + 1], "--") != 0) *************** *** 612,618 **** gui.visibility != GDK_VISIBILITY_UNOBSCURED); return FALSE; } ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ /* * Redraw the corresponding portions of the screen. --- 612,618 ---- gui.visibility != GDK_VISIBILITY_UNOBSCURED); return FALSE; } ! #endif // !GTK_CHECK_VERSION(3,0,0) /* * Redraw the corresponding portions of the screen. *************** *** 626,632 **** static void gui_gtk3_redraw(int x, int y, int width, int height) { ! /* Range checks are left to gui_redraw_block() */ gui_redraw_block(Y_2_ROW(y), X_2_COL(x), Y_2_ROW(y + height - 1), X_2_COL(x + width - 1), GUI_MON_NOCLEAR); --- 626,632 ---- static void gui_gtk3_redraw(int x, int y, int width, int height) { ! // Range checks are left to gui_redraw_block() gui_redraw_block(Y_2_ROW(y), X_2_COL(x), Y_2_ROW(y + height - 1), X_2_COL(x + width - 1), GUI_MON_NOCLEAR); *************** *** 663,678 **** cairo_t *cr, gpointer user_data UNUSED) { ! /* Skip this when the GUI isn't set up yet, will redraw later. */ if (gui.starting) return FALSE; ! out_flush(); /* make sure all output has been processed */ ! /* for GTK+ 3, may induce other draw events. */ cairo_set_source_surface(cr, gui.surface, 0, 0); ! /* Draw the window without the cursor. */ gui.by_signal = TRUE; { cairo_rectangle_list_t *list = NULL; --- 663,678 ---- cairo_t *cr, gpointer user_data UNUSED) { ! // Skip this when the GUI isn't set up yet, will redraw later. if (gui.starting) return FALSE; ! out_flush(); // make sure all output has been processed ! // for GTK+ 3, may induce other draw events. cairo_set_source_surface(cr, gui.surface, 0, 0); ! // Draw the window without the cursor. gui.by_signal = TRUE; { cairo_rectangle_list_t *list = NULL; *************** *** 682,689 **** { int i; ! /* First clear all the blocks and then redraw them. Just in case ! * some blocks overlap. */ for (i = 0; i < list->num_rectangles; i++) { const cairo_rectangle_t rect = list->rectangles[i]; --- 682,689 ---- { int i; ! // First clear all the blocks and then redraw them. Just in case ! // some blocks overlap. for (i = 0; i < list->num_rectangles; i++) { const cairo_rectangle_t rect = list->rectangles[i]; *************** *** 720,746 **** } gui.by_signal = FALSE; ! /* Add the cursor to the window if necessary.*/ if (gui_gtk3_should_draw_cursor() && blink_mode) gui_gtk3_update_cursor(cr); return FALSE; } ! #else /* !GTK_CHECK_VERSION(3,0,0) */ static gint expose_event(GtkWidget *widget UNUSED, GdkEventExpose *event, gpointer data UNUSED) { ! /* Skip this when the GUI isn't set up yet, will redraw later. */ if (gui.starting) return FALSE; ! out_flush(); /* make sure all output has been processed */ gui_redraw(event->area.x, event->area.y, event->area.width, event->area.height); ! /* Clear the border areas if needed */ if (event->area.x < FILL_X(0)) gdk_window_clear_area(gui.drawarea->window, 0, 0, FILL_X(0), 0); if (event->area.y < FILL_Y(0)) --- 720,746 ---- } gui.by_signal = FALSE; ! // Add the cursor to the window if necessary. if (gui_gtk3_should_draw_cursor() && blink_mode) gui_gtk3_update_cursor(cr); return FALSE; } ! #else // !GTK_CHECK_VERSION(3,0,0) static gint expose_event(GtkWidget *widget UNUSED, GdkEventExpose *event, gpointer data UNUSED) { ! // Skip this when the GUI isn't set up yet, will redraw later. if (gui.starting) return FALSE; ! out_flush(); // make sure all output has been processed gui_redraw(event->area.x, event->area.y, event->area.width, event->area.height); ! // Clear the border areas if needed if (event->area.x < FILL_X(0)) gdk_window_clear_area(gui.drawarea->window, 0, 0, FILL_X(0), 0); if (event->area.y < FILL_Y(0)) *************** *** 753,759 **** return FALSE; } ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ #ifdef FEAT_CLIENTSERVER /* --- 753,759 ---- return FALSE; } ! #endif // !GTK_CHECK_VERSION(3,0,0) #ifdef FEAT_CLIENTSERVER /* *************** *** 771,777 **** { XEvent xev; ! /* Translate to XLib */ xev.xproperty.type = PropertyNotify; xev.xproperty.atom = commProperty; xev.xproperty.window = commWindow; --- 771,777 ---- { XEvent xev; ! // Translate to XLib xev.xproperty.type = PropertyNotify; xev.xproperty.atom = commProperty; xev.xproperty.window = commWindow; *************** *** 781,787 **** } return FALSE; } ! #endif /* defined(FEAT_CLIENTSERVER) */ /* * Handle changes to the "Xft/DPI" setting --- 781,787 ---- } return FALSE; } ! #endif // defined(FEAT_CLIENTSERVER) /* * Handle changes to the "Xft/DPI" setting *************** *** 826,834 **** } ! /**************************************************************************** ! * Focus handlers: ! */ /* --- 826,833 ---- } ! ///////////////////////////////////////////////////////////////////////////// ! // Focus handlers: /* *************** *** 931,937 **** } gui_mch_flush(); ! return FALSE; /* don't happen again */ } /* --- 930,936 ---- } gui_mch_flush(); ! return FALSE; // don't happen again } /* *************** *** 946,952 **** timeout_remove(blink_timer); blink_timer = 0; } ! /* Only switch blinking on if none of the times is zero */ if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) { blink_timer = timeout_add(blink_waittime, blink_cb, NULL); --- 945,951 ---- timeout_remove(blink_timer); blink_timer = 0; } ! // Only switch blinking on if none of the times is zero if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) { blink_timer = timeout_add(blink_waittime, blink_cb, NULL); *************** *** 964,970 **** if (blink_state == BLINK_NONE) gui_mch_start_blink(); ! /* make sure keyboard input goes there */ if (gtk_socket_id == 0 || !gtk_widget_has_focus(gui.drawarea)) gtk_widget_grab_focus(gui.drawarea); --- 963,969 ---- if (blink_state == BLINK_NONE) gui_mch_start_blink(); ! // make sure keyboard input goes there if (gtk_socket_id == 0 || !gtk_widget_has_focus(gui.drawarea)) gtk_widget_grab_focus(gui.drawarea); *************** *** 992,999 **** if (blink_state == BLINK_NONE) gui_mch_start_blink(); ! /* make sure keyboard input goes to the draw area (if this is focus for a ! * window) */ if (widget != gui.drawarea) gtk_widget_grab_focus(gui.drawarea); --- 991,998 ---- if (blink_state == BLINK_NONE) gui_mch_start_blink(); ! // make sure keyboard input goes to the draw area (if this is focus for a ! // window) if (widget != gui.drawarea) gtk_widget_grab_focus(gui.drawarea); *************** *** 1032,1044 **** uc = gdk_keyval_to_unicode(keyval); if (uc != 0) { ! /* Check for CTRL-foo */ if ((state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80) { ! /* These mappings look arbitrary at the first glance, but in fact ! * resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my ! * machine. The only difference is BS vs. DEL for CTRL-8 (makes ! * more sense and is consistent with usual terminal behaviour). */ if (uc >= '@') string[0] = uc & 0x1F; else if (uc == '2') --- 1031,1043 ---- uc = gdk_keyval_to_unicode(keyval); if (uc != 0) { ! // Check for CTRL-foo if ((state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80) { ! // These mappings look arbitrary at the first glance, but in fact ! // resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my ! // machine. The only difference is BS vs. DEL for CTRL-8 (makes ! // more sense and is consistent with usual terminal behaviour). if (uc >= '@') string[0] = uc & 0x1F; else if (uc == '2') *************** *** 1055,1070 **** } else { ! /* Translate a normal key to UTF-8. This doesn't work for dead ! * keys of course, you _have_ to use an input method for that. */ len = utf_char2bytes((int)uc, string); } } else { ! /* Translate keys which are represented by ASCII control codes in Vim. ! * There are only a few of those; most control keys are translated to ! * special terminal-like control sequences. */ len = 1; switch (keyval) { --- 1054,1069 ---- } else { ! // Translate a normal key to UTF-8. This doesn't work for dead ! // keys of course, you _have_ to use an input method for that. len = utf_char2bytes((int)uc, string); } } else { ! // Translate keys which are represented by ASCII control codes in Vim. ! // There are only a few of those; most control keys are translated to ! // special terminal-like control sequences. len = 1; switch (keyval) { *************** *** 1134,1141 **** GdkEventKey *event, gpointer data UNUSED) { ! /* For GTK+ 2 we know for sure how large the string might get. ! * (That is, up to 6 bytes + NUL + CSI escapes + safety measure.) */ char_u string[32], string2[32]; guint key_sym; int len; --- 1133,1140 ---- GdkEventKey *event, gpointer data UNUSED) { ! // For GTK+ 2 we know for sure how large the string might get. ! // (That is, up to 6 bytes + NUL + CSI escapes + safety measure.) char_u string[32], string2[32]; guint key_sym; int len; *************** *** 1172,1179 **** { len = keyval_to_string(key_sym, state, string2); ! /* Careful: convert_input() doesn't handle the NUL character. ! * No need to convert pure ASCII anyway, thus the len > 1 check. */ if (len > 1 && input_conv.vc_type != CONV_NONE) len = convert_input(string2, len, sizeof(string2)); --- 1171,1178 ---- { len = keyval_to_string(key_sym, state, string2); ! // Careful: convert_input() doesn't handle the NUL character. ! // No need to convert pure ASCII anyway, thus the len > 1 check. if (len > 1 && input_conv.vc_type != CONV_NONE) len = convert_input(string2, len, sizeof(string2)); *************** *** 1184,1190 **** *d++ = s[i]; if (d[-1] == CSI && d + 2 < string + sizeof(string)) { ! /* Turn CSI into K_CSI. */ *d++ = KS_EXTRA; *d++ = (int)KE_CSI; } --- 1183,1189 ---- *d++ = s[i]; if (d[-1] == CSI && d + 2 < string + sizeof(string)) { ! // Turn CSI into K_CSI. *d++ = KS_EXTRA; *d++ = (int)KE_CSI; } *************** *** 1192,1198 **** len = d - string; } ! /* Shift-Tab results in Left_Tab, but we want */ if (key_sym == GDK_ISO_Left_Tab) { key_sym = GDK_Tab; --- 1191,1197 ---- len = d - string; } ! // Shift-Tab results in Left_Tab, but we want if (key_sym == GDK_ISO_Left_Tab) { key_sym = GDK_Tab; *************** *** 1200,1223 **** } #ifdef FEAT_MENU ! /* If there is a menu and 'wak' is "yes", or 'wak' is "menu" and the key ! * is a menu shortcut, we ignore everything with the ALT modifier. */ if ((state & GDK_MOD1_MASK) && gui.menu_is_active && (*p_wak == 'y' || (*p_wak == 'm' && len == 1 && gui_is_menu_shortcut(string[0])))) ! /* For GTK2 we return false to signify that we haven't handled the ! * keypress, so that gtk will handle the mnemonic or accelerator. */ return FALSE; #endif ! /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character ! * that already has the 8th bit set. ! * Don't do this for , that should become K_S_TAB with ALT. ! * Don't do this for double-byte encodings, it turns the char into a lead ! * byte. */ if (len == 1 && ((state & GDK_MOD1_MASK) #if GTK_CHECK_VERSION(2,10,0) --- 1199,1222 ---- } #ifdef FEAT_MENU ! // If there is a menu and 'wak' is "yes", or 'wak' is "menu" and the key ! // is a menu shortcut, we ignore everything with the ALT modifier. if ((state & GDK_MOD1_MASK) && gui.menu_is_active && (*p_wak == 'y' || (*p_wak == 'm' && len == 1 && gui_is_menu_shortcut(string[0])))) ! // For GTK2 we return false to signify that we haven't handled the ! // keypress, so that gtk will handle the mnemonic or accelerator. return FALSE; #endif ! // Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character ! // that already has the 8th bit set. ! // Don't do this for , that should become K_S_TAB with ALT. ! // Don't do this for double-byte encodings, it turns the char into a lead ! // byte. if (len == 1 && ((state & GDK_MOD1_MASK) #if GTK_CHECK_VERSION(2,10,0) *************** *** 1231,1238 **** ) { string[0] |= 0x80; ! state &= ~GDK_MOD1_MASK; /* don't use it again */ ! if (enc_utf8) /* convert to utf-8 */ { string[1] = string[0] & 0xbf; string[0] = ((unsigned)string[0] >> 6) + 0xc0; --- 1230,1237 ---- ) { string[0] |= 0x80; ! state &= ~GDK_MOD1_MASK; // don't use it again ! if (enc_utf8) // convert to utf-8 { string[1] = string[0] & 0xbf; string[0] = ((unsigned)string[0] >> 6) + 0xc0; *************** *** 1247,1254 **** } } ! /* Check for special keys. Also do this when len == 1 (key has an ASCII ! * value) to detect backspace, delete and keypad keys. */ if (len == 0 || len == 1) { for (i = 0; special_keys[i].key_sym != 0; i++) --- 1246,1253 ---- } } ! // Check for special keys. Also do this when len == 1 (key has an ASCII ! // value) to detect backspace, delete and keypad keys. if (len == 0 || len == 1) { for (i = 0; special_keys[i].key_sym != 0; i++) *************** *** 1264,1274 **** } } ! if (len == 0) /* Unrecognized key */ return TRUE; ! /* Special keys (and a few others) may have modifiers. Also when using a ! * double-byte encoding (can't set the 8th bit). */ if (len == -3 || key_sym == GDK_space || key_sym == GDK_Tab || key_sym == GDK_Return || key_sym == GDK_Linefeed || key_sym == GDK_Escape || key_sym == GDK_KP_Tab --- 1263,1273 ---- } } ! if (len == 0) // Unrecognized key return TRUE; ! // Special keys (and a few others) may have modifiers. Also when using a ! // double-byte encoding (can't set the 8th bit). if (len == -3 || key_sym == GDK_space || key_sym == GDK_Tab || key_sym == GDK_Return || key_sym == GDK_Linefeed || key_sym == GDK_Escape || key_sym == GDK_KP_Tab *************** *** 1324,1330 **** add_to_input_buf(string, len); ! /* blank out the pointer if necessary */ if (p_mh) gui_mch_mousehide(TRUE); --- 1323,1329 ---- add_to_input_buf(string, len); ! // blank out the pointer if necessary if (p_mh) gui_mch_mousehide(TRUE); *************** *** 1356,1367 **** #endif ! /**************************************************************************** ! * Selection handlers: ! */ ! /* Remember when clip_lose_selection was called from here, we must not call ! * gtk_selection_owner_set() then. */ static int in_selection_clear_event = FALSE; static gint --- 1355,1365 ---- #endif ! ///////////////////////////////////////////////////////////////////////////// ! // Selection handlers: ! // Remember when clip_lose_selection was called from here, we must not call ! // gtk_selection_owner_set() then. static int in_selection_clear_event = FALSE; static gint *************** *** 1379,1387 **** return TRUE; } ! #define RS_NONE 0 /* selection_received_cb() not called yet */ ! #define RS_OK 1 /* selection_received_cb() called and OK */ ! #define RS_FAIL 2 /* selection_received_cb() called and failed */ static int received_selection = RS_NONE; static void --- 1377,1385 ---- return TRUE; } ! #define RS_NONE 0 // selection_received_cb() not called yet ! #define RS_OK 1 // selection_received_cb() called and OK ! #define RS_FAIL 2 // selection_received_cb() called and failed static int received_selection = RS_NONE; static void *************** *** 1408,1414 **** if (text == NULL || len <= 0) { received_selection = RS_FAIL; ! /* clip_free_selection(cbd); ??? */ return; } --- 1406,1412 ---- if (text == NULL || len <= 0) { received_selection = RS_FAIL; ! // clip_free_selection(cbd); ??? return; } *************** *** 1430,1437 **** text += STRLEN(text) + 1; len -= text - enc; ! /* If the encoding of the text is different from 'encoding', attempt ! * converting it. */ conv.vc_type = CONV_NONE; convert_setup(&conv, enc, p_enc); if (conv.vc_type != CONV_NONE) --- 1428,1435 ---- text += STRLEN(text) + 1; len -= text - enc; ! // If the encoding of the text is different from 'encoding', attempt ! // converting it. conv.vc_type = CONV_NONE; convert_setup(&conv, enc, p_enc); if (conv.vc_type != CONV_NONE) *************** *** 1443,1450 **** } } ! /* gtk_selection_data_get_text() handles all the nasty details ! * and targets and encodings etc. This rocks so hard. */ else { tmpbuf_utf8 = gtk_selection_data_get_text(data); --- 1441,1448 ---- } } ! // gtk_selection_data_get_text() handles all the nasty details ! // and targets and encodings etc. This rocks so hard. else { tmpbuf_utf8 = gtk_selection_data_get_text(data); *************** *** 1464,1470 **** { vimconv_T conv; ! /* UTF-16, we get this for HTML */ conv.vc_type = CONV_NONE; convert_setup_ext(&conv, (char_u *)"utf-16le", FALSE, p_enc, TRUE); --- 1462,1468 ---- { vimconv_T conv; ! // UTF-16, we get this for HTML conv.vc_type = CONV_NONE; convert_setup_ext(&conv, (char_u *)"utf-16le", FALSE, p_enc, TRUE); *************** *** 1480,1486 **** } } ! /* Chop off any trailing NUL bytes. OpenOffice sends these. */ while (len > 0 && text[len - 1] == NUL) --len; --- 1478,1484 ---- } } ! // Chop off any trailing NUL bytes. OpenOffice sends these. while (len > 0 && text[len - 1] == NUL) --len; *************** *** 1516,1522 **** cbd = &clip_star; if (!cbd->owned) ! return; /* Shouldn't ever happen */ if (info != (guint)TARGET_STRING && (!clip_html || info != (guint)TARGET_HTML) --- 1514,1520 ---- cbd = &clip_star; if (!cbd->owned) ! return; // Shouldn't ever happen if (info != (guint)TARGET_STRING && (!clip_html || info != (guint)TARGET_HTML) *************** *** 1527,1541 **** && info != (guint)TARGET_TEXT) return; ! /* get the selection from the '*'/'+' register */ clip_get_selection(cbd); motion_type = clip_convert_selection(&string, &tmplen, cbd); if (motion_type < 0 || string == NULL) return; ! /* Due to int arguments we can't handle more than G_MAXINT. Also ! * reserve one extra byte for NUL or the motion type; just in case. ! * (Not that pasting 2G of text is ever going to work, but... ;-) */ length = MIN(tmplen, (long_u)(G_MAXINT - 1)); if (info == (guint)TARGET_VIM) --- 1525,1539 ---- && info != (guint)TARGET_TEXT) return; ! // get the selection from the '*'/'+' register clip_get_selection(cbd); motion_type = clip_convert_selection(&string, &tmplen, cbd); if (motion_type < 0 || string == NULL) return; ! // Due to int arguments we can't handle more than G_MAXINT. Also ! // reserve one extra byte for NUL or the motion type; just in case. ! // (Not that pasting 2G of text is ever going to work, but... ;-) length = MIN(tmplen, (long_u)(G_MAXINT - 1)); if (info == (guint)TARGET_VIM) *************** *** 1546,1552 **** tmpbuf[0] = motion_type; mch_memmove(tmpbuf + 1, string, (size_t)length); } ! /* For our own format, the first byte contains the motion type */ ++length; vim_free(string); string = tmpbuf; --- 1544,1550 ---- tmpbuf[0] = motion_type; mch_memmove(tmpbuf + 1, string, (size_t)length); } ! // For our own format, the first byte contains the motion type ++length; vim_free(string); string = tmpbuf; *************** *** 1557,1563 **** { vimconv_T conv; ! /* Since we get utf-16, we probably should set it as well. */ conv.vc_type = CONV_NONE; convert_setup_ext(&conv, p_enc, TRUE, (char_u *)"utf-16le", FALSE); if (conv.vc_type != CONV_NONE) --- 1555,1561 ---- { vimconv_T conv; ! // Since we get utf-16, we probably should set it as well. conv.vc_type = CONV_NONE; convert_setup_ext(&conv, p_enc, TRUE, (char_u *)"utf-16le", FALSE); if (conv.vc_type != CONV_NONE) *************** *** 1568,1574 **** string = tmpbuf; } ! /* Prepend the BOM: "fffe" */ if (string != NULL) { tmpbuf = alloc(length + 2); --- 1566,1572 ---- string = tmpbuf; } ! // Prepend the BOM: "fffe" if (string != NULL) { tmpbuf = alloc(length + 2); *************** *** 1583,1592 **** } #if !GTK_CHECK_VERSION(3,0,0) ! /* Looks redundant even for GTK2 because these values are ! * overwritten by gtk_selection_data_set() that follows. */ selection_data->type = selection_data->target; ! selection_data->format = 16; /* 16 bits per char */ #endif gtk_selection_data_set(selection_data, html_atom, 16, string, length); --- 1581,1590 ---- } #if !GTK_CHECK_VERSION(3,0,0) ! // Looks redundant even for GTK2 because these values are ! // overwritten by gtk_selection_data_set() that follows. selection_data->type = selection_data->target; ! selection_data->format = 16; // 16 bits per char #endif gtk_selection_data_set(selection_data, html_atom, 16, string, length); *************** *** 1598,1604 **** { int l = STRLEN(p_enc); ! /* contents: motion_type 'encoding' NUL text */ tmpbuf = alloc(length + l + 2); if (tmpbuf != NULL) { --- 1596,1602 ---- { int l = STRLEN(p_enc); ! // contents: motion_type 'encoding' NUL text tmpbuf = alloc(length + l + 2); if (tmpbuf != NULL) { *************** *** 1612,1619 **** type = vimenc_atom; } ! /* gtk_selection_data_set_text() handles everything for us. This is ! * so easy and simple and cool, it'd be insane not to use it. */ else { if (output_conv.vc_type != CONV_NONE) --- 1610,1617 ---- type = vimenc_atom; } ! // gtk_selection_data_set_text() handles everything for us. This is ! // so easy and simple and cool, it'd be insane not to use it. else { if (output_conv.vc_type != CONV_NONE) *************** *** 1624,1630 **** return; string = tmpbuf; } ! /* Validate the string to avoid runtime warnings */ if (g_utf8_validate((const char *)string, (gssize)length, NULL)) { gtk_selection_data_set_text(selection_data, --- 1622,1628 ---- return; string = tmpbuf; } ! // Validate the string to avoid runtime warnings if (g_utf8_validate((const char *)string, (gssize)length, NULL)) { gtk_selection_data_set_text(selection_data, *************** *** 1637,1646 **** if (string != NULL) { #if !GTK_CHECK_VERSION(3,0,0) ! /* Looks redundant even for GTK2 because these values are ! * overwritten by gtk_selection_data_set() that follows. */ selection_data->type = selection_data->target; ! selection_data->format = 8; /* 8 bits per char */ #endif gtk_selection_data_set(selection_data, type, 8, string, length); vim_free(string); --- 1635,1644 ---- if (string != NULL) { #if !GTK_CHECK_VERSION(3,0,0) ! // Looks redundant even for GTK2 because these values are ! // overwritten by gtk_selection_data_set() that follows. selection_data->type = selection_data->target; ! selection_data->format = 8; // 8 bits per char #endif gtk_selection_data_set(selection_data, type, 8, string, length); vim_free(string); *************** *** 1657,1663 **** { char_u *p; ! /* Guess that when $DISPLAY isn't set the GUI can't start. */ p = mch_getenv((char_u *)"DISPLAY"); if (p == NULL || *p == NUL) { --- 1655,1661 ---- { char_u *p; ! // Guess that when $DISPLAY isn't set the GUI can't start. p = mch_getenv((char_u *)"DISPLAY"); if (p == NULL || *p == NUL) { *************** *** 1682,1697 **** if (!res_registered) { ! /* Call this function in the GUI process; otherwise, the resources ! * won't be available. Don't call it twice. */ res_registered = TRUE; gui_gtk_register_resource(); } #endif #if GTK_CHECK_VERSION(3,10,0) ! /* Vim currently assumes that Gtk means X11, so it cannot use native Gtk ! * support for other backends such as Wayland. */ gdk_set_allowed_backends ("x11"); #endif --- 1680,1695 ---- if (!res_registered) { ! // Call this function in the GUI process; otherwise, the resources ! // won't be available. Don't call it twice. res_registered = TRUE; gui_gtk_register_resource(); } #endif #if GTK_CHECK_VERSION(3,10,0) ! // Vim currently assumes that Gtk means X11, so it cannot use native Gtk ! // support for other backends such as Wayland. gdk_set_allowed_backends ("x11"); #endif *************** *** 1700,1711 **** using_gnome = 1; #endif ! /* This defaults to argv[0], but we want it to match the name of the ! * shipped gvim.desktop so that Vim's windows can be associated with this ! * file. */ g_set_prgname("gvim"); ! /* Don't use gtk_init() or gnome_init(), it exits on failure. */ if (!gtk_init_check(&gui_argc, &gui_argv)) { gui.dying = TRUE; --- 1698,1709 ---- using_gnome = 1; #endif ! // This defaults to argv[0], but we want it to match the name of the ! // shipped gvim.desktop so that Vim's windows can be associated with this ! // file. g_set_prgname("gvim"); ! // Don't use gtk_init() or gnome_init(), it exits on failure. if (!gtk_init_check(&gui_argc, &gui_argv)) { gui.dying = TRUE; *************** *** 1716,1724 **** return OK; } ! /**************************************************************************** ! * Mouse handling callbacks ! */ static guint mouse_click_timer = 0; --- 1714,1721 ---- return OK; } ! ///////////////////////////////////////////////////////////////////////////// ! // Mouse handling callbacks static guint mouse_click_timer = 0; *************** *** 1730,1740 **** static timeout_cb_type mouse_click_timer_cb(gpointer data) { ! /* we don't use this information currently */ int *timed_out = (int *) data; *timed_out = TRUE; ! return FALSE; /* don't happen again */ } static guint motion_repeat_timer = 0; --- 1727,1737 ---- static timeout_cb_type mouse_click_timer_cb(gpointer data) { ! // we don't use this information currently int *timed_out = (int *) data; *timed_out = TRUE; ! return FALSE; // don't happen again } static guint motion_repeat_timer = 0; *************** *** 1753,1773 **** GDK_BUTTON5_MASK)) ? MOUSE_DRAG : ' '; ! /* If our pointer is currently hidden, then we should show it. */ gui_mch_mousehide(FALSE); ! /* Just moving the rodent above the drawing area without any button ! * being pressed. */ if (button != MOUSE_DRAG) { gui_mouse_moved(x, y); return; } ! /* translate modifier coding between the main engine and GTK */ vim_modifiers = modifiers_gdk2mouse(state); ! /* inform the editor engine about the occurrence of this event */ gui_send_mouse_event(button, x, y, FALSE, vim_modifiers); /* --- 1750,1770 ---- GDK_BUTTON5_MASK)) ? MOUSE_DRAG : ' '; ! // If our pointer is currently hidden, then we should show it. gui_mch_mousehide(FALSE); ! // Just moving the rodent above the drawing area without any button ! // being pressed. if (button != MOUSE_DRAG) { gui_mouse_moved(x, y); return; } ! // translate modifier coding between the main engine and GTK vim_modifiers = modifiers_gdk2mouse(state); ! // inform the editor engine about the occurrence of this event gui_send_mouse_event(button, x, y, FALSE, vim_modifiers); /* *************** *** 1785,1810 **** int offshoot; int delay = 10; ! /* Calculate the maximal distance of the cursor from the drawing area. ! * (offshoot can't become negative here!). ! */ dx = x < 0 ? -x : x - allocation.width; dy = y < 0 ? -y : y - allocation.height; offshoot = dx > dy ? dx : dy; ! /* Make a linearly decaying timer delay with a threshold of 5 at a ! * distance of 127 pixels from the main window. ! * ! * One could think endlessly about the most ergonomic variant here. ! * For example it could make sense to calculate the distance from the ! * drags start instead... ! * ! * Maybe a parabolic interpolation would suite us better here too... ! */ if (offshoot > 127) { ! /* 5 appears to be somehow near to my perceptual limits :-). */ delay = 5; } else --- 1782,1805 ---- int offshoot; int delay = 10; ! // Calculate the maximal distance of the cursor from the drawing area. ! // (offshoot can't become negative here!). dx = x < 0 ? -x : x - allocation.width; dy = y < 0 ? -y : y - allocation.height; offshoot = dx > dy ? dx : dy; ! // Make a linearly decaying timer delay with a threshold of 5 at a ! // distance of 127 pixels from the main window. ! // ! // One could think endlessly about the most ergonomic variant here. ! // For example it could make sense to calculate the distance from the ! // drags start instead... ! // ! // Maybe a parabolic interpolation would suite us better here too... if (offshoot > 127) { ! // 5 appears to be somehow near to my perceptual limits :-). delay = 5; } else *************** *** 1812,1818 **** delay = (130 * (127 - offshoot)) / 127 + 5; } ! /* shoot again */ if (!motion_repeat_timer) motion_repeat_timer = timeout_add(delay, motion_repeat_timer_cb, NULL); --- 1807,1813 ---- delay = (130 * (127 - offshoot)) / 127 + 5; } ! // shoot again if (!motion_repeat_timer) motion_repeat_timer = timeout_add(delay, motion_repeat_timer_cb, NULL); *************** *** 1855,1861 **** return gdk_device_get_window_at_position(dev, x, y); } # endif ! #else /* !GTK_CHECK_VERSION(3,0,0) */ # define gui_gtk_get_pointer(wid, x, y, s) \ gdk_window_get_pointer((wid)->window, x, y, s) # define gui_gtk_window_at_position(wid, x, y) gdk_window_at_pointer(x, y) --- 1850,1856 ---- return gdk_device_get_window_at_position(dev, x, y); } # endif ! #else // !GTK_CHECK_VERSION(3,0,0) # define gui_gtk_get_pointer(wid, x, y, s) \ gdk_window_get_pointer((wid)->window, x, y, s) # define gui_gtk_window_at_position(wid, x, y) gdk_window_at_pointer(x, y) *************** *** 1881,1888 **** return FALSE; } ! /* If there already is a mouse click in the input buffer, wait another ! * time (otherwise we would create a backlog of clicks) */ if (vim_used_in_input_buf() > 10) return TRUE; --- 1876,1883 ---- return FALSE; } ! // If there already is a mouse click in the input buffer, wait another ! // time (otherwise we would create a backlog of clicks) if (vim_used_in_input_buf() > 10) return TRUE; *************** *** 1900,1907 **** motion_repeat_offset = !motion_repeat_offset; process_motion_notify(x, y, state); ! /* Don't happen again. We will get reinstalled in the synthetic event ! * if needed -- thus repeating should still work. */ return FALSE; } --- 1895,1902 ---- motion_repeat_offset = !motion_repeat_offset; process_motion_notify(x, y, state); ! // Don't happen again. We will get reinstalled in the synthetic event ! // if needed -- thus repeating should still work. return FALSE; } *************** *** 1925,1931 **** (GdkModifierType)event->state); } ! return TRUE; /* handled */ } --- 1920,1926 ---- (GdkModifierType)event->state); } ! return TRUE; // handled } *************** *** 1946,1952 **** gui.event_time = event->time; ! /* Make sure we have focus now we've been selected */ if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget)) gtk_widget_grab_focus(widget); --- 1941,1947 ---- gui.event_time = event->time; ! // Make sure we have focus now we've been selected if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget)) gtk_widget_grab_focus(widget); *************** *** 1960,1966 **** x = event->x; y = event->y; ! /* Handle multiple clicks */ if (!mouse_timed_out && mouse_click_timer) { timeout_remove(mouse_click_timer); --- 1955,1961 ---- x = event->x; y = event->y; ! // Handle multiple clicks if (!mouse_timed_out && mouse_click_timer) { timeout_remove(mouse_click_timer); *************** *** 1974,1992 **** switch (event->button) { ! /* Keep in sync with gui_x11.c. ! * Buttons 4-7 are handled in scroll_event() */ case 1: button = MOUSE_LEFT; break; case 2: button = MOUSE_MIDDLE; break; case 3: button = MOUSE_RIGHT; break; case 8: button = MOUSE_X1; break; case 9: button = MOUSE_X2; break; default: ! return FALSE; /* Unknown button */ } #ifdef FEAT_XIM ! /* cancel any preediting */ if (im_is_preediting()) xim_reset(); #endif --- 1969,1987 ---- switch (event->button) { ! // Keep in sync with gui_x11.c. ! // Buttons 4-7 are handled in scroll_event() case 1: button = MOUSE_LEFT; break; case 2: button = MOUSE_MIDDLE; break; case 3: button = MOUSE_RIGHT; break; case 8: button = MOUSE_X1; break; case 9: button = MOUSE_X2; break; default: ! return FALSE; // Unknown button } #ifdef FEAT_XIM ! // cancel any preediting if (im_is_preediting()) xim_reset(); #endif *************** *** 2026,2037 **** case GDK_SCROLL_RIGHT: button = MOUSE_6; break; ! default: /* This shouldn't happen */ return FALSE; } # ifdef FEAT_XIM ! /* cancel any preediting */ if (im_is_preediting()) xim_reset(); # endif --- 2021,2032 ---- case GDK_SCROLL_RIGHT: button = MOUSE_6; break; ! default: // This shouldn't happen return FALSE; } # ifdef FEAT_XIM ! // cancel any preediting if (im_is_preediting()) xim_reset(); # endif *************** *** 2055,2063 **** gui.event_time = event->time; ! /* Remove any motion "machine gun" timers used for automatic further ! extension of allocation areas if outside of the applications window ! area .*/ if (motion_repeat_timer) { timeout_remove(motion_repeat_timer); --- 2050,2058 ---- gui.event_time = event->time; ! // Remove any motion "machine gun" timers used for automatic further ! // extension of allocation areas if outside of the applications window ! // area . if (motion_repeat_timer) { timeout_remove(motion_repeat_timer); *************** *** 2076,2084 **** #ifdef FEAT_DND ! /**************************************************************************** ! * Drag aNd Drop support handlers. ! */ /* * Count how many items there may be and separate them with a NUL. --- 2071,2078 ---- #ifdef FEAT_DND ! ///////////////////////////////////////////////////////////////////////////// ! // Drag aNd Drop support handlers. /* * Count how many items there may be and separate them with a NUL. *************** *** 2113,2119 **** } if (p > out && p[-1] != NUL) { ! *p = NUL; /* last item didn't have \r or \n */ ++count; } return count; --- 2107,2113 ---- } if (p > out && p[-1] != NUL) { ! *p = NUL; // last item didn't have \r or \n ++count; } return count; *************** *** 2183,2189 **** { int_u modifiers; ! gtk_drag_finish(context, TRUE, FALSE, time_); /* accept */ modifiers = modifiers_gdk2mouse(state); --- 2177,2183 ---- { int_u modifiers; ! gtk_drag_finish(context, TRUE, FALSE, time_); // accept modifiers = modifiers_gdk2mouse(state); *************** *** 2216,2222 **** } dnd_yank_drag_data(text, (long)len); ! gtk_drag_finish(context, TRUE, FALSE, time_); /* accept */ vim_free(tmpbuf); dropkey[2] = modifiers_gdk2vim(state); --- 2210,2216 ---- } dnd_yank_drag_data(text, (long)len); ! gtk_drag_finish(context, TRUE, FALSE, time_); // accept vim_free(tmpbuf); dropkey[2] = modifiers_gdk2vim(state); *************** *** 2242,2248 **** { GdkModifierType state; ! /* Guard against trash */ const guchar * const data_data = gtk_selection_data_get_data(data); const gint data_length = gtk_selection_data_get_length(data); const gint data_format = gtk_selection_data_get_format(data); --- 2236,2242 ---- { GdkModifierType state; ! // Guard against trash const guchar * const data_data = gtk_selection_data_get_data(data); const gint data_length = gtk_selection_data_get_length(data); const gint data_format = gtk_selection_data_get_format(data); *************** *** 2256,2273 **** return; } ! /* Get the current modifier state for proper distinguishment between ! * different operations later. */ gui_gtk_get_pointer(widget, NULL, NULL, &state); ! /* Not sure about the role of "text/plain" here... */ if (info == (guint)TARGET_TEXT_URI_LIST) drag_handle_uri_list(context, data, time_, state, x, y); else drag_handle_text(context, data, time_, state); } ! #endif /* FEAT_DND */ #if defined(USE_GNOME_SESSION) --- 2250,2267 ---- return; } ! // Get the current modifier state for proper distinguishment between ! // different operations later. gui_gtk_get_pointer(widget, NULL, NULL, &state); ! // Not sure about the role of "text/plain" here... if (info == (guint)TARGET_TEXT_URI_LIST) drag_handle_uri_list(context, data, time_, state, x, y); else drag_handle_text(context, data, time_, state); } ! #endif // FEAT_DND #if defined(USE_GNOME_SESSION) *************** *** 2301,2307 **** exiting = FALSE; cmdmod = save_cmdmod; ! setcursor(); /* position the cursor */ out_flush(); /* * If the user hit the [Cancel] button the whole shutdown --- 2295,2301 ---- exiting = FALSE; cmdmod = save_cmdmod; ! setcursor(); // position the cursor out_flush(); /* * If the user hit the [Cancel] button the whole shutdown *************** *** 2329,2354 **** unsigned int len; gboolean success; ! /* Always request an interaction if possible. check_changed_any() ! * won't actually show a dialog unless any buffers have been modified. ! * There doesn't seem to be an obvious way to check that without ! * automatically firing the dialog. Anyway, it works just fine. */ if (interact_style == GNOME_INTERACT_ANY) gnome_client_request_interaction(client, GNOME_DIALOG_NORMAL, &sm_client_check_changed_any, NULL); out_flush(); ! ml_sync_all(FALSE, FALSE); /* preserve all swap files */ ! /* The path is unique for each session save. We do neither know nor care ! * which session script will actually be used later. This decision is in ! * the domain of the session manager. */ session_file = gnome_config_get_real_path( gnome_client_get_config_prefix(client)); len = strlen(session_file); if (len > 0 && session_file[len-1] == G_DIR_SEPARATOR) ! --len; /* get rid of the superfluous trailing '/' */ session_file = g_renew(char, session_file, len + sizeof(suffix)); memcpy(session_file + len, suffix, sizeof(suffix)); --- 2323,2348 ---- unsigned int len; gboolean success; ! // Always request an interaction if possible. check_changed_any() ! // won't actually show a dialog unless any buffers have been modified. ! // There doesn't seem to be an obvious way to check that without ! // automatically firing the dialog. Anyway, it works just fine. if (interact_style == GNOME_INTERACT_ANY) gnome_client_request_interaction(client, GNOME_DIALOG_NORMAL, &sm_client_check_changed_any, NULL); out_flush(); ! ml_sync_all(FALSE, FALSE); // preserve all swap files ! // The path is unique for each session save. We do neither know nor care ! // which session script will actually be used later. This decision is in ! // the domain of the session manager. session_file = gnome_config_get_real_path( gnome_client_get_config_prefix(client)); len = strlen(session_file); if (len > 0 && session_file[len-1] == G_DIR_SEPARATOR) ! --len; // get rid of the superfluous trailing '/' session_file = g_renew(char, session_file, len + sizeof(suffix)); memcpy(session_file + len, suffix, sizeof(suffix)); *************** *** 2360,2369 **** const char *argv[8]; int i; ! /* Tell the session manager how to wipe out the stored session data. ! * This isn't as dangerous as it looks, don't worry :) session_file ! * is a unique absolute filename. Usually it'll be something like ! * `/home/user/.gnome2/vim-XXXXXX-session.vim'. */ i = 0; argv[i++] = "rm"; argv[i++] = session_file; --- 2354,2363 ---- const char *argv[8]; int i; ! // Tell the session manager how to wipe out the stored session data. ! // This isn't as dangerous as it looks, don't worry :) session_file ! // is a unique absolute filename. Usually it'll be something like ! // `/home/user/.gnome2/vim-XXXXXX-session.vim'. i = 0; argv[i++] = "rm"; argv[i++] = session_file; *************** *** 2371,2381 **** gnome_client_set_discard_command(client, i, (char **)argv); ! /* Tell the session manager how to restore the just saved session. ! * This is easily done thanks to Vim's -S option. Pass the -f flag ! * since there's no need to fork -- it might even cause confusion. ! * Also pass the window role to give the WM something to match on. ! * The role is set in gui_mch_open(), thus should _never_ be NULL. */ i = 0; argv[i++] = restart_command; argv[i++] = "-f"; --- 2365,2375 ---- gnome_client_set_discard_command(client, i, (char **)argv); ! // Tell the session manager how to restore the just saved session. ! // This is easily done thanks to Vim's -S option. Pass the -f flag ! // since there's no need to fork -- it might even cause confusion. ! // Also pass the window role to give the WM something to match on. ! // The role is set in gui_mch_open(), thus should _never_ be NULL. i = 0; argv[i++] = restart_command; argv[i++] = "-f"; *************** *** 2403,2409 **** static void sm_client_die(GnomeClient *client UNUSED, gpointer data UNUSED) { ! /* Don't write messages to the GUI anymore */ full_screen = FALSE; vim_strncpy(IObuff, (char_u *) --- 2397,2403 ---- static void sm_client_die(GnomeClient *client UNUSED, gpointer data UNUSED) { ! // Don't write messages to the GUI anymore full_screen = FALSE; vim_strncpy(IObuff, (char_u *) *************** *** 2424,2431 **** if (client != NULL) { ! /* Must use the deprecated gtk_signal_connect() for compatibility ! * with GNOME 1. Arrgh, zombies! */ gtk_signal_connect(GTK_OBJECT(client), "save_yourself", GTK_SIGNAL_FUNC(&sm_client_save_yourself), NULL); gtk_signal_connect(GTK_OBJECT(client), "die", --- 2418,2425 ---- if (client != NULL) { ! // Must use the deprecated gtk_signal_connect() for compatibility ! // with GNOME 1. Arrgh, zombies! gtk_signal_connect(GTK_OBJECT(client), "save_yourself", GTK_SIGNAL_FUNC(&sm_client_save_yourself), NULL); gtk_signal_connect(GTK_OBJECT(client), "die", *************** *** 2447,2463 **** { if (condition == G_IO_IN) { ! /* Do stuff; maybe close connection */ if (xsmp_handle_requests() == FAIL) g_io_channel_unref((GIOChannel *)data); return TRUE; } ! /* Error */ g_io_channel_unref((GIOChannel *)data); xsmp_close(); return TRUE; } ! # endif /* USE_XSMP */ /* * Setup the WM_PROTOCOLS to indicate we want the WM_SAVE_YOURSELF event. --- 2441,2457 ---- { if (condition == G_IO_IN) { ! // Do stuff; maybe close connection if (xsmp_handle_requests() == FAIL) g_io_channel_unref((GIOChannel *)data); return TRUE; } ! // Error g_io_channel_unref((GIOChannel *)data); xsmp_close(); return TRUE; } ! # endif // USE_XSMP /* * Setup the WM_PROTOCOLS to indicate we want the WM_SAVE_YOURSELF event. *************** *** 2485,2493 **** else # endif { ! /* Fall back to old method */ ! /* first get the existing value */ GdkWindow * const mainwin_win = gtk_widget_get_window(gui.mainwin); if (XGetWMProtocols(GDK_WINDOW_XDISPLAY(mainwin_win), --- 2479,2487 ---- else # endif { ! // Fall back to old method ! // first get the existing value GdkWindow * const mainwin_win = gtk_widget_get_window(gui.mainwin); if (XGetWMProtocols(GDK_WINDOW_XDISPLAY(mainwin_win), *************** *** 2500,2513 **** save_yourself_xatom = GET_X_ATOM(save_yourself_atom); ! /* check if WM_SAVE_YOURSELF isn't there yet */ for (i = 0; i < count; ++i) if (existing_atoms[i] == save_yourself_xatom) break; if (i == count) { ! /* allocate an Atoms array which is one item longer */ new_atoms = ALLOC_MULT(Atom, count + 1); if (new_atoms != NULL) { --- 2494,2507 ---- save_yourself_xatom = GET_X_ATOM(save_yourself_atom); ! // check if WM_SAVE_YOURSELF isn't there yet for (i = 0; i < count; ++i) if (existing_atoms[i] == save_yourself_xatom) break; if (i == count) { ! // allocate an Atoms array which is one item longer new_atoms = ALLOC_MULT(Atom, count + 1); if (new_atoms != NULL) { *************** *** 2553,2559 **** == GET_X_ATOM(save_yourself_atom)) { out_flush(); ! ml_sync_all(FALSE, FALSE); /* preserve all swap files */ /* * Set the window's WM_COMMAND property, to let the window manager * know we are done saving ourselves. We don't want to be --- 2547,2553 ---- == GET_X_ATOM(save_yourself_atom)) { out_flush(); ! ml_sync_all(FALSE, FALSE); // preserve all swap files /* * Set the window's WM_COMMAND property, to let the window manager * know we are done saving ourselves. We don't want to be *************** *** 2576,2587 **** static void mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED) { ! /* If you get an error message here, you still need to unpack the runtime ! * archive! */ #ifdef magick # undef magick #endif ! /* A bit hackish, but avoids casting later and allows optimization */ # define static static const #define magick vim32x32 #include "../runtime/vim32x32.xpm" --- 2570,2581 ---- static void mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED) { ! // If you get an error message here, you still need to unpack the runtime ! // archive! #ifdef magick # undef magick #endif ! // A bit hackish, but avoids casting later and allows optimization # define static static const #define magick vim32x32 #include "../runtime/vim32x32.xpm" *************** *** 2596,2602 **** GdkWindow * const mainwin_win = gtk_widget_get_window(gui.mainwin); ! /* When started with "--echo-wid" argument, write window ID on stdout. */ if (echo_wid_arg) { printf("WID: %ld\n", (long)GDK_WINDOW_XID(mainwin_win)); --- 2590,2596 ---- GdkWindow * const mainwin_win = gtk_widget_get_window(gui.mainwin); ! // When started with "--echo-wid" argument, write window ID on stdout. if (echo_wid_arg) { printf("WID: %ld\n", (long)GDK_WINDOW_XID(mainwin_win)); *************** *** 2621,2632 **** } #if !defined(USE_GNOME_SESSION) ! /* Register a handler for WM_SAVE_YOURSELF with GDK's low-level X I/F */ gdk_window_add_filter(NULL, &global_event_filter, NULL); #endif ! /* Setup to indicate to the window manager that we want to catch the ! * WM_SAVE_YOURSELF event. For GNOME, this connects to the session ! * manager instead. */ #if defined(USE_GNOME_SESSION) if (using_gnome) #endif --- 2615,2626 ---- } #if !defined(USE_GNOME_SESSION) ! // Register a handler for WM_SAVE_YOURSELF with GDK's low-level X I/F gdk_window_add_filter(NULL, &global_event_filter, NULL); #endif ! // Setup to indicate to the window manager that we want to catch the ! // WM_SAVE_YOURSELF event. For GNOME, this connects to the session ! // manager instead. #if defined(USE_GNOME_SESSION) if (using_gnome) #endif *************** *** 2635,2641 **** #ifdef FEAT_CLIENTSERVER if (serverName == NULL && serverDelayedStartName != NULL) { ! /* This is a :gui command in a plain vim with no previous server */ commWindow = GDK_WINDOW_XID(mainwin_win); (void)serverRegisterName(GDK_WINDOW_XDISPLAY(mainwin_win), --- 2629,2635 ---- #ifdef FEAT_CLIENTSERVER if (serverName == NULL && serverDelayedStartName != NULL) { ! // This is a :gui command in a plain vim with no previous server commWindow = GDK_WINDOW_XID(mainwin_win); (void)serverRegisterName(GDK_WINDOW_XDISPLAY(mainwin_win), *************** *** 2684,2691 **** root_window = gtk_widget_get_root_window(gui.mainwin); #endif ! /* Create a pseudo blank pointer, which is in fact one pixel by one pixel ! * in size. */ #if GTK_CHECK_VERSION(3,0,0) { cairo_surface_t *surf; --- 2678,2685 ---- root_window = gtk_widget_get_root_window(gui.mainwin); #endif ! // Create a pseudo blank pointer, which is in fact one pixel by one pixel ! // in size. #if GTK_CHECK_VERSION(3,0,0) { cairo_surface_t *surf; *************** *** 2792,2798 **** if (gui.pointer_hidden) gdk_window_set_cursor(gtk_widget_get_window(widget), gui.blank_pointer); ! /* get the actual size of the scrollbars, if they are realized */ sbar = firstwin->w_scrollbars[SBAR_LEFT].id; if (!sbar || (!gui.which_scrollbars[SBAR_LEFT] && firstwin->w_scrollbars[SBAR_RIGHT].id)) --- 2786,2792 ---- if (gui.pointer_hidden) gdk_window_set_cursor(gtk_widget_get_window(widget), gui.blank_pointer); ! // get the actual size of the scrollbars, if they are realized sbar = firstwin->w_scrollbars[SBAR_LEFT].id; if (!sbar || (!gui.which_scrollbars[SBAR_LEFT] && firstwin->w_scrollbars[SBAR_RIGHT].id)) *************** *** 2812,2818 **** static void drawarea_unrealize_cb(GtkWidget *widget UNUSED, gpointer data UNUSED) { ! /* Don't write messages to the GUI anymore */ full_screen = FALSE; #ifdef FEAT_XIM --- 2806,2812 ---- static void drawarea_unrealize_cb(GtkWidget *widget UNUSED, gpointer data UNUSED) { ! // Don't write messages to the GUI anymore full_screen = FALSE; #ifdef FEAT_XIM *************** *** 2877,2906 **** && event->width >= 1 && event->height >= 1, TRUE); # if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) ! /* As of 3.22.2, GdkWindows have started distributing configure events to ! * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0). ! * ! * As can be seen from the implementation of move_native_children() and ! * configure_native_child() in gdkwindow.c, those functions actually ! * propagate configure events to every child, failing to distinguish ! * "native" one from non-native one. ! * ! * Naturally, configure events propagated to here like that are fallacious ! * and, as a matter of fact, they trigger a geometric collapse of ! * gui.drawarea in fullscreen and maximized modes. ! * ! * To filter out such nuisance events, we are making use of the fact that ! * the field send_event of such GdkEventConfigures is set to FALSE in ! * configure_native_child(). ! * ! * Obviously, this is a terrible hack making GVim depend on GTK's ! * implementation details. Therefore, watch out any relevant internal ! * changes happening in GTK in the feature (sigh). ! */ ! /* Follow-up ! * After a few weeks later, the GdkWindow change mentioned above was ! * reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155). ! * The corresponding official release is 3.22.4. */ if (event->send_event == FALSE) return TRUE; # endif --- 2871,2900 ---- && event->width >= 1 && event->height >= 1, TRUE); # if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) ! // As of 3.22.2, GdkWindows have started distributing configure events to ! // their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0). ! // ! // As can be seen from the implementation of move_native_children() and ! // configure_native_child() in gdkwindow.c, those functions actually ! // propagate configure events to every child, failing to distinguish ! // "native" one from non-native one. ! // ! // Naturally, configure events propagated to here like that are fallacious ! // and, as a matter of fact, they trigger a geometric collapse of ! // gui.drawarea in fullscreen and maximized modes. ! // ! // To filter out such nuisance events, we are making use of the fact that ! // the field send_event of such GdkEventConfigures is set to FALSE in ! // configure_native_child(). ! // ! // Obviously, this is a terrible hack making GVim depend on GTK's ! // implementation details. Therefore, watch out any relevant internal ! // changes happening in GTK in the feature (sigh). ! // ! // Follow-up ! // After a few weeks later, the GdkWindow change mentioned above was ! // reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155). ! // The corresponding official release is 3.22.4. if (event->send_event == FALSE) return TRUE; # endif *************** *** 2953,2960 **** parent = gtk_widget_get_parent(widget); if (G_TYPE_FROM_INSTANCE(parent) == BONOBO_TYPE_DOCK_ITEM) { ! /* Only menu & toolbar are dock items. Could tabline be? ! * Seem to be only the 2 defined in GNOME */ widget = parent; dockitem = BONOBO_DOCK_ITEM(widget); --- 2947,2954 ---- parent = gtk_widget_get_parent(widget); if (G_TYPE_FROM_INSTANCE(parent) == BONOBO_TYPE_DOCK_ITEM) { ! // Only menu & toolbar are dock items. Could tabline be? ! // Seem to be only the 2 defined in GNOME widget = parent; dockitem = BONOBO_DOCK_ITEM(widget); *************** *** 2993,2999 **** { int width = 0; ! #ifdef FEAT_GUI_GNOME /* these are never vertical without GNOME */ # ifdef FEAT_MENU width += get_item_dimensions(gui.menubar, GTK_ORIENTATION_VERTICAL); # endif --- 2987,2993 ---- { int width = 0; ! #ifdef FEAT_GUI_GNOME // these are never vertical without GNOME # ifdef FEAT_MENU width += get_item_dimensions(gui.menubar, GTK_ORIENTATION_VERTICAL); # endif *************** *** 3028,3039 **** return height; } ! /* This controls whether we can set the real window hints at ! * start-up when in a GtkPlug. ! * 0 = normal processing (default) ! * 1 = init. hints set, no-one's tried to reset since last check ! * 2 = init. hints set, attempt made to change hints ! */ static int init_window_hints_state = 0; static void --- 3022,3032 ---- return height; } ! // This controls whether we can set the real window hints at ! // start-up when in a GtkPlug. ! // 0 = normal processing (default) ! // 1 = init. hints set, no-one's tried to reset since last check ! // 2 = init. hints set, attempt made to change hints static int init_window_hints_state = 0; static void *************** *** 3051,3069 **** int min_width; int min_height; ! /* At start-up, don't try to set the hints until the initial ! * values have been used (those that dictate our initial size) ! * Let forced (i.e., correct) values through always. ! */ if (!(force_width && force_height) && init_window_hints_state > 0) { ! /* Don't do it! */ init_window_hints_state = 2; return; } ! /* This also needs to be done when the main window isn't there yet, ! * otherwise the hints don't work. */ width = gui_get_base_width(); height = gui_get_base_height(); # ifdef FEAT_MENU --- 3044,3061 ---- int min_width; int min_height; ! // At start-up, don't try to set the hints until the initial ! // values have been used (those that dictate our initial size) ! // Let forced (i.e., correct) values through always. if (!(force_width && force_height) && init_window_hints_state > 0) { ! // Don't do it! init_window_hints_state = 2; return; } ! // This also needs to be done when the main window isn't there yet, ! // otherwise the hints don't work. width = gui_get_base_width(); height = gui_get_base_height(); # ifdef FEAT_MENU *************** *** 3072,3083 **** width += get_menu_tool_width(); height += get_menu_tool_height(); ! /* GtkSockets use GtkPlug's [gui,mainwin] min-size hints to determine ! * their actual widget size. When we set our size ourselves (e.g., ! * 'set columns=' or init. -geom) we briefly set the min. to the size ! * we wish to be instead of the legitimate minimum so that we actually ! * resize correctly. ! */ if (force_width && force_height) { min_width = force_width; --- 3064,3074 ---- width += get_menu_tool_width(); height += get_menu_tool_height(); ! // GtkSockets use GtkPlug's [gui,mainwin] min-size hints to determine ! // their actual widget size. When we set our size ourselves (e.g., ! // 'set columns=' or init. -geom) we briefly set the min. to the size ! // we wish to be instead of the legitimate minimum so that we actually ! // resize correctly. if (force_width && force_height) { min_width = force_width; *************** *** 3089,3095 **** min_height = height + MIN_LINES * gui.char_height; } ! /* Avoid an expose event when the size didn't change. */ if (width != old_width || height != old_height || min_width != old_min_width --- 3080,3086 ---- min_height = height + MIN_LINES * gui.char_height; } ! // Avoid an expose event when the size didn't change. if (width != old_width || height != old_height || min_width != old_min_width *************** *** 3108,3116 **** geometry.min_height = min_height; geometry_mask = GDK_HINT_BASE_SIZE|GDK_HINT_RESIZE_INC |GDK_HINT_MIN_SIZE; ! /* Using gui.formwin as geometry widget doesn't work as expected ! * with GTK+ 2 -- dunno why. Presumably all the resizing hacks ! * in Vim confuse GTK+. */ gtk_window_set_geometry_hints(GTK_WINDOW(gui.mainwin), gui.mainwin, &geometry, geometry_mask); old_width = width; --- 3099,3107 ---- geometry.min_height = min_height; geometry_mask = GDK_HINT_BASE_SIZE|GDK_HINT_RESIZE_INC |GDK_HINT_MIN_SIZE; ! // Using gui.formwin as geometry widget doesn't work as expected ! // with GTK+ 2 -- dunno why. Presumably all the resizing hacks ! // in Vim confuse GTK+. gtk_window_set_geometry_hints(GTK_WINDOW(gui.mainwin), gui.mainwin, &geometry, geometry_mask); old_width = width; *************** *** 3133,3139 **** g_object_set(gtk_settings, "gtk-application-prefer-dark-theme", (gboolean)dark, NULL); # endif } ! #endif /* FEAT_GUI_DARKTHEME */ #ifdef FEAT_TOOLBAR --- 3124,3130 ---- g_object_set(gtk_settings, "gtk-application-prefer-dark-theme", (gboolean)dark, NULL); # endif } ! #endif // FEAT_GUI_DARKTHEME #ifdef FEAT_TOOLBAR *************** *** 3160,3166 **** gtk_image_set_from_icon_name(image, icon_name, icon_size); } # else ! /* User-defined icons are stored in a GtkIconSet */ if (gtk_image_get_storage_type(image) == GTK_IMAGE_ICON_SET) { GtkIconSet *icon_set; --- 3151,3157 ---- gtk_image_set_from_icon_name(image, icon_name, icon_size); } # else ! // User-defined icons are stored in a GtkIconSet if (gtk_image_get_storage_type(image) == GTK_IMAGE_ICON_SET) { GtkIconSet *icon_set; *************** *** 3220,3226 **** if (size == GTK_ICON_SIZE_INVALID) { ! /* Let global user preferences decide the icon size. */ gtk_toolbar_unset_icon_size(toolbar); size = gtk_toolbar_get_icon_size(toolbar); } --- 3211,3217 ---- if (size == GTK_ICON_SIZE_INVALID) { ! // Let global user preferences decide the icon size. gtk_toolbar_unset_icon_size(toolbar); size = gtk_toolbar_get_icon_size(toolbar); } *************** *** 3233,3239 **** gtk_toolbar_set_icon_size(toolbar, size); } ! #endif /* FEAT_TOOLBAR */ #if defined(FEAT_GUI_TABLINE) || defined(PROTO) static int ignore_tabline_evt = FALSE; --- 3224,3230 ---- gtk_toolbar_set_icon_size(toolbar, size); } ! #endif // FEAT_TOOLBAR #if defined(FEAT_GUI_TABLINE) || defined(PROTO) static int ignore_tabline_evt = FALSE; *************** *** 3241,3247 **** # if !GTK_CHECK_VERSION(3,0,0) static GtkTooltips *tabline_tooltip; # endif ! static int clicked_page; /* page clicked in tab line */ /* * Handle selecting an item in the tab line popup menu. --- 3232,3238 ---- # if !GTK_CHECK_VERSION(3,0,0) static GtkTooltips *tabline_tooltip; # endif ! static int clicked_page; // page clicked in tab line /* * Handle selecting an item in the tab line popup menu. *************** *** 3249,3255 **** static void tabline_menu_handler(GtkMenuItem *item UNUSED, gpointer user_data) { ! /* Add the string cmd into input buffer */ send_tabline_menu_event(clicked_page, (int)(long)user_data); } --- 3240,3246 ---- static void tabline_menu_handler(GtkMenuItem *item UNUSED, gpointer user_data) { ! // Add the string cmd into input buffer send_tabline_menu_event(clicked_page, (int)(long)user_data); } *************** *** 3289,3295 **** static gboolean on_tabline_menu(GtkWidget *widget, GdkEvent *event) { ! /* Was this button press event ? */ if (event->type == GDK_BUTTON_PRESS) { GdkEventButton *bevent = (GdkEventButton *)event; --- 3280,3286 ---- static gboolean on_tabline_menu(GtkWidget *widget, GdkEvent *event) { ! // Was this button press event ? if (event->type == GDK_BUTTON_PRESS) { GdkEventButton *bevent = (GdkEventButton *)event; *************** *** 3298,3305 **** GtkWidget *tabwidget; GdkWindow *tabwin; ! /* When ignoring events return TRUE so that the selected page doesn't ! * change. */ if (hold_gui_events # ifdef FEAT_CMDWIN || cmdwin_type != 0 --- 3289,3296 ---- GtkWidget *tabwidget; GdkWindow *tabwin; ! // When ignoring events return TRUE so that the selected page doesn't ! // change. if (hold_gui_events # ifdef FEAT_CMDWIN || cmdwin_type != 0 *************** *** 3313,3319 **** clicked_page = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tabwidget), "tab_num")); ! /* If the event was generated for 3rd button popup the menu. */ if (bevent->button == 3) { # if GTK_CHECK_VERSION(3,22,2) --- 3304,3310 ---- clicked_page = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tabwidget), "tab_num")); ! // If the event was generated for 3rd button popup the menu. if (bevent->button == 3) { # if GTK_CHECK_VERSION(3,22,2) *************** *** 3322,3342 **** gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL, bevent->button, bevent->time); # endif ! /* We handled the event. */ return TRUE; } else if (bevent->button == 1) { if (clicked_page == 0) { ! /* Click after all tabs moves to next tab page. When "x" is ! * small guess it's the left button. */ send_tabline_event(x < 50 ? -1 : 0); } } } ! /* We didn't handle the event. */ return FALSE; } --- 3313,3333 ---- gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL, bevent->button, bevent->time); # endif ! // We handled the event. return TRUE; } else if (bevent->button == 1) { if (clicked_page == 0) { ! // Click after all tabs moves to next tab page. When "x" is ! // small guess it's the left button. send_tabline_event(x < 50 ? -1 : 0); } } } ! // We didn't handle the event. return FALSE; } *************** *** 3386,3392 **** if (!showit != !gtk_notebook_get_show_tabs(GTK_NOTEBOOK(gui.tabline))) { ! /* Note: this may cause a resize event */ gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gui.tabline), showit); update_window_manager_hints(0, 0); if (showit) --- 3377,3383 ---- if (!showit != !gtk_notebook_get_show_tabs(GTK_NOTEBOOK(gui.tabline))) { ! // Note: this may cause a resize event gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gui.tabline), showit); update_window_manager_hints(0, 0); if (showit) *************** *** 3426,3432 **** ignore_tabline_evt = TRUE; ! /* Add a label for each tab page. They all contain the same text area. */ for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) { if (tp == curtab) --- 3417,3423 ---- ignore_tabline_evt = TRUE; ! // Add a label for each tab page. They all contain the same text area. for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) { if (tp == curtab) *************** *** 3437,3443 **** page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr); if (page == NULL) { ! /* Add notebook page */ # if GTK_CHECK_VERSION(3,2,0) page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(page), FALSE); --- 3428,3434 ---- page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr); if (page == NULL) { ! // Add notebook page # if GTK_CHECK_VERSION(3,2,0) page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(page), FALSE); *************** *** 3484,3497 **** CONVERT_TO_UTF8_FREE(labeltext); } ! /* Remove any old labels. */ while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr) != NULL) gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), nr); if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx) gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), curtabidx); ! /* Make sure everything is in place before drawing text. */ gui_mch_update(); ignore_tabline_evt = FALSE; --- 3475,3488 ---- CONVERT_TO_UTF8_FREE(labeltext); } ! // Remove any old labels. while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr) != NULL) gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), nr); if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx) gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), curtabidx); ! // Make sure everything is in place before drawing text. gui_mch_update(); ignore_tabline_evt = FALSE; *************** *** 3512,3518 **** ignore_tabline_evt = FALSE; } ! #endif /* FEAT_GUI_TABLINE */ /* * Add selection targets for PRIMARY and CLIPBOARD selections. --- 3503,3509 ---- ignore_tabline_evt = FALSE; } ! #endif // FEAT_GUI_TABLINE /* * Add selection targets for PRIMARY and CLIPBOARD selections. *************** *** 3526,3534 **** for (i = 0; i < (int)N_SELECTION_TARGETS; ++i) { ! /* OpenOffice tries to use TARGET_HTML and fails when we don't ! * return something, instead of trying another target. Therefore only ! * offer TARGET_HTML when it works. */ if (!clip_html && selection_targets[i].info == TARGET_HTML) n_targets--; else --- 3517,3525 ---- for (i = 0; i < (int)N_SELECTION_TARGETS; ++i) { ! // OpenOffice tries to use TARGET_HTML and fails when we don't ! // return something, instead of trying another target. Therefore only ! // offer TARGET_HTML when it works. if (!clip_html && selection_targets[i].info == TARGET_HTML) n_targets--; else *************** *** 3580,3588 **** GtkWidget *vbox; #ifdef FEAT_GUI_GNOME ! /* Initialize the GNOME libraries. gnome_program_init()/gnome_init() ! * exits on failure, but that's a non-issue because we already called ! * gtk_init_check() in gui_mch_init_check(). */ if (using_gnome) { gnome_program_init(VIMPACKAGE, VIM_VERSION_SHORT, --- 3571,3579 ---- GtkWidget *vbox; #ifdef FEAT_GUI_GNOME ! // Initialize the GNOME libraries. gnome_program_init()/gnome_init() ! // exits on failure, but that's a non-issue because we already called ! // gtk_init_check() in gui_mch_init_check(). if (using_gnome) { gnome_program_init(VIMPACKAGE, VIM_VERSION_SHORT, *************** *** 3591,3598 **** { char *p = setlocale(LC_NUMERIC, NULL); ! /* Make sure strtod() uses a decimal point, not a comma. Gnome ! * init may change it. */ if (p == NULL || strcmp(p, "C") != 0) setlocale(LC_NUMERIC, "C"); } --- 3582,3589 ---- { char *p = setlocale(LC_NUMERIC, NULL); ! // Make sure strtod() uses a decimal point, not a comma. Gnome ! // init may change it. if (p == NULL || strcmp(p, "C") != 0) setlocale(LC_NUMERIC, "C"); } *************** *** 3602,3608 **** VIM_CLEAR(gui_argv); #if GLIB_CHECK_VERSION(2,1,3) ! /* Set the human-readable application name */ g_set_application_name("Vim"); #endif /* --- 3593,3599 ---- VIM_CLEAR(gui_argv); #if GLIB_CHECK_VERSION(2,1,3) ! // Set the human-readable application name g_set_application_name("Vim"); #endif /* *************** *** 3615,3629 **** #ifdef FEAT_TOOLBAR gui_gtk_register_stock_icons(); #endif ! /* FIXME: Need to install the classic icons and a gtkrc.classic file. ! * The hard part is deciding install locations and the Makefile magic. */ #if !GTK_CHECK_VERSION(3,0,0) # if 0 gtk_rc_parse("gtkrc"); # endif #endif ! /* Initialize values */ gui.border_width = 2; gui.scrollbar_width = SB_DEFAULT_WIDTH; gui.scrollbar_height = SB_DEFAULT_WIDTH; --- 3606,3620 ---- #ifdef FEAT_TOOLBAR gui_gtk_register_stock_icons(); #endif ! // FIXME: Need to install the classic icons and a gtkrc.classic file. ! // The hard part is deciding install locations and the Makefile magic. #if !GTK_CHECK_VERSION(3,0,0) # if 0 gtk_rc_parse("gtkrc"); # endif #endif ! // Initialize values gui.border_width = 2; gui.scrollbar_width = SB_DEFAULT_WIDTH; gui.scrollbar_height = SB_DEFAULT_WIDTH; *************** *** 3632,3650 **** gui.bgcolor = g_new(GdkRGBA, 1); gui.spcolor = g_new(GdkRGBA, 1); #else ! /* LINTED: avoid warning: conversion to 'unsigned long' */ gui.fgcolor = g_new0(GdkColor, 1); ! /* LINTED: avoid warning: conversion to 'unsigned long' */ gui.bgcolor = g_new0(GdkColor, 1); ! /* LINTED: avoid warning: conversion to 'unsigned long' */ gui.spcolor = g_new0(GdkColor, 1); #endif ! /* Initialise atoms */ html_atom = gdk_atom_intern("text/html", FALSE); utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE); ! /* Set default foreground and background colors. */ gui.norm_pixel = gui.def_norm_pixel; gui.back_pixel = gui.def_back_pixel; --- 3623,3641 ---- gui.bgcolor = g_new(GdkRGBA, 1); gui.spcolor = g_new(GdkRGBA, 1); #else ! // LINTED: avoid warning: conversion to 'unsigned long' gui.fgcolor = g_new0(GdkColor, 1); ! // LINTED: avoid warning: conversion to 'unsigned long' gui.bgcolor = g_new0(GdkColor, 1); ! // LINTED: avoid warning: conversion to 'unsigned long' gui.spcolor = g_new0(GdkColor, 1); #endif ! // Initialise atoms html_atom = gdk_atom_intern("text/html", FALSE); utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE); ! // Set default foreground and background colors. gui.norm_pixel = gui.def_norm_pixel; gui.back_pixel = gui.def_back_pixel; *************** *** 3652,3658 **** { GtkWidget *plug; ! /* Use GtkSocket from another app. */ plug = gtk_plug_new_for_display(gdk_display_get_default(), gtk_socket_id); if (plug != NULL && gtk_plug_get_socket_window(GTK_PLUG(plug)) != NULL) --- 3643,3649 ---- { GtkWidget *plug; ! // Use GtkSocket from another app. plug = gtk_plug_new_for_display(gdk_display_get_default(), gtk_socket_id); if (plug != NULL && gtk_plug_get_socket_window(GTK_PLUG(plug)) != NULL) *************** *** 3663,3669 **** { g_warning("Connection to GTK+ socket (ID %u) failed", (unsigned int)gtk_socket_id); ! /* Pretend we never wanted it if it failed (get own window) */ gtk_socket_id = 0; } } --- 3654,3660 ---- { g_warning("Connection to GTK+ socket (ID %u) failed", (unsigned int)gtk_socket_id); ! // Pretend we never wanted it if it failed (get own window) gtk_socket_id = 0; } } *************** *** 3675,3681 **** { gui.mainwin = gnome_app_new("Vim", NULL); # ifdef USE_XSMP ! /* Use the GNOME save-yourself functionality now. */ xsmp_close(); # endif } --- 3666,3672 ---- { gui.mainwin = gnome_app_new("Vim", NULL); # ifdef USE_XSMP ! // Use the GNOME save-yourself functionality now. xsmp_close(); # endif } *************** *** 3686,3692 **** gtk_widget_set_name(gui.mainwin, "vim-main-window"); ! /* Create the PangoContext used for drawing all text. */ gui.text_context = gtk_widget_create_pango_context(gui.mainwin); pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR); --- 3677,3683 ---- gtk_widget_set_name(gui.mainwin, "vim-main-window"); ! // Create the PangoContext used for drawing all text. gui.text_context = gtk_widget_create_pango_context(gui.mainwin); pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR); *************** *** 3705,3711 **** gui.accel_group = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(gui.mainwin), gui.accel_group); ! /* A vertical box holds the menubar, toolbar and main text window. */ #if GTK_CHECK_VERSION(3,2,0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE); --- 3696,3702 ---- gui.accel_group = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(gui.mainwin), gui.accel_group); ! // A vertical box holds the menubar, toolbar and main text window. #if GTK_CHECK_VERSION(3,2,0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE); *************** *** 3717,3723 **** if (using_gnome) { # if defined(FEAT_MENU) ! /* automagically restore menubar/toolbar placement */ gnome_app_enable_layout_config(GNOME_APP(gui.mainwin), TRUE); # endif gnome_app_set_contents(GNOME_APP(gui.mainwin), vbox); --- 3708,3714 ---- if (using_gnome) { # if defined(FEAT_MENU) ! // automagically restore menubar/toolbar placement gnome_app_enable_layout_config(GNOME_APP(gui.mainwin), TRUE); # endif gnome_app_set_contents(GNOME_APP(gui.mainwin), vbox); *************** *** 3736,3742 **** gui.menubar = gtk_menu_bar_new(); gtk_widget_set_name(gui.menubar, "vim-menubar"); ! /* Avoid that GTK takes away from us. */ { GtkSettings *gtk_settings; --- 3727,3733 ---- gui.menubar = gtk_menu_bar_new(); gtk_widget_set_name(gui.menubar, "vim-menubar"); ! // Avoid that GTK takes away from us. { GtkSettings *gtk_settings; *************** *** 3753,3783 **** gnome_app_set_menus(GNOME_APP(gui.mainwin), GTK_MENU_BAR(gui.menubar)); dockitem = gnome_app_get_dock_item_by_name(GNOME_APP(gui.mainwin), GNOME_APP_MENUBAR_NAME); ! /* We don't want the menu to float. */ bonobo_dock_item_set_behavior(dockitem, bonobo_dock_item_get_behavior(dockitem) | BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING); gui.menubar_h = GTK_WIDGET(dockitem); } else ! # endif /* FEAT_GUI_GNOME */ { ! /* Always show the menubar, otherwise doesn't work. It may be ! * disabled in gui_init() later. */ gtk_widget_show(gui.menubar); gtk_box_pack_start(GTK_BOX(vbox), gui.menubar, FALSE, FALSE, 0); } ! #endif /* FEAT_MENU */ #ifdef FEAT_TOOLBAR /* * Create the toolbar and handle */ ! /* some aesthetics on the toolbar */ # ifdef USE_GTK3 ! /* TODO: Add GTK+ 3 code here using GtkCssProvider if necessary. */ ! /* N.B. Since the default value of GtkToolbar::button-relief is ! * GTK_RELIEF_NONE, there's no need to specify that, probably. */ # else gtk_rc_parse_string( "style \"vim-toolbar-style\" {\n" --- 3744,3774 ---- gnome_app_set_menus(GNOME_APP(gui.mainwin), GTK_MENU_BAR(gui.menubar)); dockitem = gnome_app_get_dock_item_by_name(GNOME_APP(gui.mainwin), GNOME_APP_MENUBAR_NAME); ! // We don't want the menu to float. bonobo_dock_item_set_behavior(dockitem, bonobo_dock_item_get_behavior(dockitem) | BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING); gui.menubar_h = GTK_WIDGET(dockitem); } else ! # endif // FEAT_GUI_GNOME { ! // Always show the menubar, otherwise doesn't work. It may be ! // disabled in gui_init() later. gtk_widget_show(gui.menubar); gtk_box_pack_start(GTK_BOX(vbox), gui.menubar, FALSE, FALSE, 0); } ! #endif // FEAT_MENU #ifdef FEAT_TOOLBAR /* * Create the toolbar and handle */ ! // some aesthetics on the toolbar # ifdef USE_GTK3 ! // TODO: Add GTK+ 3 code here using GtkCssProvider if necessary. ! // N.B. Since the default value of GtkToolbar::button-relief is ! // GTK_RELIEF_NONE, there's no need to specify that, probably. # else gtk_rc_parse_string( "style \"vim-toolbar-style\" {\n" *************** *** 3798,3819 **** dockitem = gnome_app_get_dock_item_by_name(GNOME_APP(gui.mainwin), GNOME_APP_TOOLBAR_NAME); gui.toolbar_h = GTK_WIDGET(dockitem); ! /* When the toolbar is floating it gets stuck. So long as that isn't ! * fixed let's disallow floating. */ bonobo_dock_item_set_behavior(dockitem, bonobo_dock_item_get_behavior(dockitem) | BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING); gtk_container_set_border_width(GTK_CONTAINER(gui.toolbar), 0); } else ! # endif /* FEAT_GUI_GNOME */ { if (vim_strchr(p_go, GO_TOOLBAR) != NULL && (toolbar_flags & (TOOLBAR_TEXT | TOOLBAR_ICONS))) gtk_widget_show(gui.toolbar); gtk_box_pack_start(GTK_BOX(vbox), gui.toolbar, FALSE, FALSE, 0); } ! #endif /* FEAT_TOOLBAR */ #ifdef FEAT_GUI_TABLINE /* --- 3789,3810 ---- dockitem = gnome_app_get_dock_item_by_name(GNOME_APP(gui.mainwin), GNOME_APP_TOOLBAR_NAME); gui.toolbar_h = GTK_WIDGET(dockitem); ! // When the toolbar is floating it gets stuck. So long as that isn't ! // fixed let's disallow floating. bonobo_dock_item_set_behavior(dockitem, bonobo_dock_item_get_behavior(dockitem) | BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING); gtk_container_set_border_width(GTK_CONTAINER(gui.toolbar), 0); } else ! # endif // FEAT_GUI_GNOME { if (vim_strchr(p_go, GO_TOOLBAR) != NULL && (toolbar_flags & (TOOLBAR_TEXT | TOOLBAR_ICONS))) gtk_widget_show(gui.toolbar); gtk_box_pack_start(GTK_BOX(vbox), gui.toolbar, FALSE, FALSE, 0); } ! #endif // FEAT_TOOLBAR #ifdef FEAT_GUI_TABLINE /* *************** *** 3838,3844 **** { GtkWidget *page, *label, *event_box; ! /* Add the first tab. */ # if GTK_CHECK_VERSION(3,2,0) page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(page), FALSE); --- 3829,3835 ---- { GtkWidget *page, *label, *event_box; ! // Add the first tab. # if GTK_CHECK_VERSION(3,2,0) page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(page), FALSE); *************** *** 3869,3879 **** G_CALLBACK(on_tab_reordered), NULL); # endif ! /* Create a popup menu for the tab line and connect it. */ tabline_menu = create_tabline_menu(); g_signal_connect_swapped(G_OBJECT(gui.tabline), "button-press-event", G_CALLBACK(on_tabline_menu), G_OBJECT(tabline_menu)); ! #endif /* FEAT_GUI_TABLINE */ gui.formwin = gtk_form_new(); gtk_container_set_border_width(GTK_CONTAINER(gui.formwin), 0); --- 3860,3870 ---- G_CALLBACK(on_tab_reordered), NULL); # endif ! // Create a popup menu for the tab line and connect it. tabline_menu = create_tabline_menu(); g_signal_connect_swapped(G_OBJECT(gui.tabline), "button-press-event", G_CALLBACK(on_tabline_menu), G_OBJECT(tabline_menu)); ! #endif // FEAT_GUI_TABLINE gui.formwin = gtk_form_new(); gtk_container_set_border_width(GTK_CONTAINER(gui.formwin), 0); *************** *** 3890,3896 **** gui.by_signal = FALSE; #endif ! /* Determine which events we will filter. */ gtk_widget_set_events(gui.drawarea, GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK | --- 3881,3887 ---- gui.by_signal = FALSE; #endif ! // Determine which events we will filter. gtk_widget_set_events(gui.drawarea, GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK | *************** *** 3908,3922 **** gtk_widget_show(gui.formwin); gtk_box_pack_start(GTK_BOX(vbox), gui.formwin, TRUE, TRUE, 0); ! /* For GtkSockets, key-presses must go to the focus widget (drawarea) ! * and not the window. */ g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) : G_OBJECT(gui.drawarea), "key-press-event", G_CALLBACK(key_press_event), NULL); #if defined(FEAT_XIM) || GTK_CHECK_VERSION(3,0,0) ! /* Also forward key release events for the benefit of GTK+ 2 input ! * modules. Try CTRL-SHIFT-xdigits to enter a Unicode code point. */ g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) : G_OBJECT(gui.drawarea), "key-release-event", --- 3899,3913 ---- gtk_widget_show(gui.formwin); gtk_box_pack_start(GTK_BOX(vbox), gui.formwin, TRUE, TRUE, 0); ! // For GtkSockets, key-presses must go to the focus widget (drawarea) ! // and not the window. g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) : G_OBJECT(gui.drawarea), "key-press-event", G_CALLBACK(key_press_event), NULL); #if defined(FEAT_XIM) || GTK_CHECK_VERSION(3,0,0) ! // Also forward key release events for the benefit of GTK+ 2 input ! // modules. Try CTRL-SHIFT-xdigits to enter a Unicode code point. g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin) : G_OBJECT(gui.drawarea), "key-release-event", *************** *** 3948,3954 **** #endif if (gtk_socket_id != 0) ! /* make sure keyboard input can go to the drawarea */ gtk_widget_set_can_focus(gui.drawarea, TRUE); /* --- 3939,3945 ---- #endif if (gtk_socket_id != 0) ! // make sure keyboard input can go to the drawarea gtk_widget_set_can_focus(gui.drawarea, TRUE); /* *************** *** 3986,3995 **** G_CALLBACK(enter_notify_event), NULL); } ! /* Real windows can get focus ... GtkPlug, being a mere container can't, ! * only its widgets. Arguably, this could be common code and we not use ! * the window focus at all, but let's be safe. ! */ if (gtk_socket_id == 0) { g_signal_connect(G_OBJECT(gui.mainwin), "focus-out-event", --- 3977,3985 ---- G_CALLBACK(enter_notify_event), NULL); } ! // Real windows can get focus ... GtkPlug, being a mere container can't, ! // only its widgets. Arguably, this could be common code and we not use ! // the window focus at all, but let's be safe. if (gtk_socket_id == 0) { g_signal_connect(G_OBJECT(gui.mainwin), "focus-out-event", *************** *** 4008,4014 **** G_CALLBACK(focus_out_event), NULL); g_signal_connect(G_OBJECT(gui.tabline), "focus-in-event", G_CALLBACK(focus_in_event), NULL); ! #endif /* FEAT_GUI_TABLINE */ } g_signal_connect(G_OBJECT(gui.drawarea), "motion-notify-event", --- 3998,4004 ---- G_CALLBACK(focus_out_event), NULL); g_signal_connect(G_OBJECT(gui.tabline), "focus-in-event", G_CALLBACK(focus_in_event), NULL); ! #endif // FEAT_GUI_TABLINE } g_signal_connect(G_OBJECT(gui.drawarea), "motion-notify-event", *************** *** 4033,4039 **** g_signal_connect(G_OBJECT(gui.drawarea), "selection-get", G_CALLBACK(selection_get_cb), NULL); ! /* Pretend we don't have input focus, we will get an event if we do. */ gui.in_focus = FALSE; // Handle changes to the "Xft/DPI" setting. --- 4023,4029 ---- g_signal_connect(G_OBJECT(gui.drawarea), "selection-get", G_CALLBACK(selection_get_cb), NULL); ! // Pretend we don't have input focus, we will get an event if we do. gui.in_focus = FALSE; // Handle changes to the "Xft/DPI" setting. *************** *** 4086,4092 **** const GdkRGBA rgba = color_to_rgba(color); cairo_set_source_rgba(cr, rgba.red, rgba.green, rgba.blue, rgba.alpha); } ! #endif /* GTK_CHECK_VERSION(3,0,0) */ /* * Called when the foreground or background color has been changed. --- 4076,4082 ---- const GdkRGBA rgba = color_to_rgba(color); cairo_set_source_rgba(cr, rgba.red, rgba.green, rgba.blue, rgba.alpha); } ! #endif // GTK_CHECK_VERSION(3,0,0) /* * Called when the foreground or background color has been changed. *************** *** 4120,4126 **** g_free(css); g_object_unref(provider); ! #elif GTK_CHECK_VERSION(3,4,0) /* !GTK_CHECK_VERSION(3,22,2) */ GdkRGBA rgba; rgba = color_to_rgba(gui.back_pixel); --- 4110,4116 ---- g_free(css); g_object_unref(provider); ! #elif GTK_CHECK_VERSION(3,4,0) // !GTK_CHECK_VERSION(3,22,2) GdkRGBA rgba; rgba = color_to_rgba(gui.back_pixel); *************** *** 4135,4146 **** else gdk_window_set_background_rgba(da_win, &rgba); } ! #else /* !GTK_CHECK_VERSION(3,4,0) */ GdkColor color = { 0, 0, 0, 0 }; color.pixel = gui.back_pixel; gdk_window_set_background(da_win, &color); ! #endif /* !GTK_CHECK_VERSION(3,22,2) */ } } --- 4125,4136 ---- else gdk_window_set_background_rgba(da_win, &rgba); } ! #else // !GTK_CHECK_VERSION(3,4,0) GdkColor color = { 0, 0, 0, 0 }; color.pixel = gui.back_pixel; gdk_window_set_background(da_win, &color); ! #endif // !GTK_CHECK_VERSION(3,22,2) } } *************** *** 4155,4189 **** int usable_height = event->height; #if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) ! /* As of 3.22.2, GdkWindows have started distributing configure events to ! * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0). ! * ! * As can be seen from the implementation of move_native_children() and ! * configure_native_child() in gdkwindow.c, those functions actually ! * propagate configure events to every child, failing to distinguish ! * "native" one from non-native one. ! * ! * Naturally, configure events propagated to here like that are fallacious ! * and, as a matter of fact, they trigger a geometric collapse of ! * gui.formwin. ! * ! * To filter out such fallacious events, check if the given event is the ! * one that was sent out to the right place. Ignore it if not. ! */ ! /* Follow-up ! * After a few weeks later, the GdkWindow change mentioned above was ! * reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155). ! * The corresponding official release is 3.22.4. */ if (event->window != gtk_widget_get_window(gui.formwin)) return TRUE; #endif ! /* When in a GtkPlug, we can't guarantee valid heights (as a round ! * no. of char-heights), so we have to manually sanitise them. ! * Widths seem to sort themselves out, don't ask me why. ! */ if (gtk_socket_id != 0) ! usable_height -= (gui.char_height - (gui.char_height/2)); /* sic. */ gtk_form_freeze(GTK_FORM(gui.formwin)); gui_resize_shell(event->width, usable_height); --- 4145,4178 ---- int usable_height = event->height; #if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) ! // As of 3.22.2, GdkWindows have started distributing configure events to ! // their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0). ! // ! // As can be seen from the implementation of move_native_children() and ! // configure_native_child() in gdkwindow.c, those functions actually ! // propagate configure events to every child, failing to distinguish ! // "native" one from non-native one. ! // ! // Naturally, configure events propagated to here like that are fallacious ! // and, as a matter of fact, they trigger a geometric collapse of ! // gui.formwin. ! // ! // To filter out such fallacious events, check if the given event is the ! // one that was sent out to the right place. Ignore it if not. ! // ! // Follow-up ! // After a few weeks later, the GdkWindow change mentioned above was ! // reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155). ! // The corresponding official release is 3.22.4. if (event->window != gtk_widget_get_window(gui.formwin)) return TRUE; #endif ! // When in a GtkPlug, we can't guarantee valid heights (as a round ! // no. of char-heights), so we have to manually sanitise them. ! // Widths seem to sort themselves out, don't ask me why. if (gtk_socket_id != 0) ! usable_height -= (gui.char_height - (gui.char_height/2)); // sic. gtk_form_freeze(GTK_FORM(gui.formwin)); gui_resize_shell(event->width, usable_height); *************** *** 4200,4212 **** static void mainwin_destroy_cb(GObject *object UNUSED, gpointer data UNUSED) { ! /* Don't write messages to the GUI anymore */ full_screen = FALSE; gui.mainwin = NULL; gui.drawarea = NULL; ! if (!exiting) /* only do anything if the destroy was unexpected */ { vim_strncpy(IObuff, (char_u *)_("Vim: Main window unexpectedly destroyed\n"), --- 4189,4201 ---- static void mainwin_destroy_cb(GObject *object UNUSED, gpointer data UNUSED) { ! // Don't write messages to the GUI anymore full_screen = FALSE; gui.mainwin = NULL; gui.drawarea = NULL; ! if (!exiting) // only do anything if the destroy was unexpected { vim_strncpy(IObuff, (char_u *)_("Vim: Main window unexpectedly destroyed\n"), *************** *** 4236,4248 **** { if (init_window_hints_state == 1) { ! /* Safe to use normal hints now */ init_window_hints_state = 0; update_window_manager_hints(0, 0); ! return FALSE; /* stop timer */ } ! /* Keep on trying */ init_window_hints_state = 1; return TRUE; } --- 4225,4237 ---- { if (init_window_hints_state == 1) { ! // Safe to use normal hints now init_window_hints_state = 0; update_window_manager_hints(0, 0); ! return FALSE; // stop timer } ! // Keep on trying init_window_hints_state = 1; return TRUE; } *************** *** 4271,4277 **** { char *role; ! /* Invent a unique-enough ID string for the role */ role = g_strdup_printf("vim-%u-%u-%u", (unsigned)mch_get_pid(), (unsigned)g_random_int(), --- 4260,4266 ---- { char *role; ! // Invent a unique-enough ID string for the role role = g_strdup_printf("vim-%u-%u-%u", (unsigned)mch_get_pid(), (unsigned)g_random_int(), *************** *** 4284,4290 **** if (gui_win_x != -1 && gui_win_y != -1) gtk_window_move(GTK_WINDOW(gui.mainwin), gui_win_x, gui_win_y); ! /* Determine user specified geometry, if present. */ if (gui.geom != NULL) { int mask; --- 4273,4279 ---- if (gui_win_x != -1 && gui_win_y != -1) gtk_window_move(GTK_WINDOW(gui.mainwin), gui_win_x, gui_win_y); ! // Determine user specified geometry, if present. if (gui.geom != NULL) { int mask; *************** *** 4324,4334 **** } VIM_CLEAR(gui.geom); ! /* From now until everyone's stopped trying to set the window hints ! * to their correct minimum values, stop them being set as we need ! * them to remain at our required size for the parent GtkSocket to ! * give us the right initial size. ! */ if (gtk_socket_id != 0 && (mask & WidthValue || mask & HeightValue)) { update_window_manager_hints(pixel_width, pixel_height); --- 4313,4322 ---- } VIM_CLEAR(gui.geom); ! // From now until everyone's stopped trying to set the window hints ! // to their correct minimum values, stop them being set as we need ! // them to remain at our required size for the parent GtkSocket to ! // give us the right initial size. if (gtk_socket_id != 0 && (mask & WidthValue || mask & HeightValue)) { update_window_manager_hints(pixel_width, pixel_height); *************** *** 4339,4346 **** pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width); pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height); ! /* For GTK2 changing the size of the form widget doesn't cause window ! * resizing. */ if (gtk_socket_id == 0) gtk_window_resize(GTK_WINDOW(gui.mainwin), pixel_width, pixel_height); update_window_manager_hints(0, 0); --- 4327,4334 ---- pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width); pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height); ! // For GTK2 changing the size of the form widget doesn't cause window ! // resizing. if (gtk_socket_id == 0) gtk_window_resize(GTK_WINDOW(gui.mainwin), pixel_width, pixel_height); update_window_manager_hints(0, 0); *************** *** 4366,4381 **** gui.def_back_pixel = bg_pixel; } ! /* Get the colors from the "Normal" and "Menu" group (set in syntax.c or ! * in a vimrc file) */ set_normal_colors(); ! /* Check that none of the colors are the same as the background color */ gui_check_colors(); ! /* Get the colors for the highlight groups (gui_check_colors() might have ! * changed them). */ ! highlight_gui_started(); /* re-init colors and fonts */ g_signal_connect(G_OBJECT(gui.mainwin), "destroy", G_CALLBACK(mainwin_destroy_cb), NULL); --- 4354,4369 ---- gui.def_back_pixel = bg_pixel; } ! // Get the colors from the "Normal" and "Menu" group (set in syntax.c or ! // in a vimrc file) set_normal_colors(); ! // Check that none of the colors are the same as the background color gui_check_colors(); ! // Get the colors for the highlight groups (gui_check_colors() might have ! // changed them). ! highlight_gui_started(); // re-init colors and fonts g_signal_connect(G_OBJECT(gui.mainwin), "destroy", G_CALLBACK(mainwin_destroy_cb), NULL); *************** *** 4394,4408 **** G_CALLBACK(form_configure_event), NULL); #ifdef FEAT_DND ! /* Set up for receiving DND items. */ gui_gtk_set_dnd_targets(); g_signal_connect(G_OBJECT(gui.drawarea), "drag-data-received", G_CALLBACK(drag_data_received_cb), NULL); #endif ! /* With GTK+ 2, we need to iconify the window before calling show() ! * to avoid mapping the window for a short time. */ if (found_iconic_arg && gtk_socket_id == 0) gui_mch_iconify(); --- 4382,4396 ---- G_CALLBACK(form_configure_event), NULL); #ifdef FEAT_DND ! // Set up for receiving DND items. gui_gtk_set_dnd_targets(); g_signal_connect(G_OBJECT(gui.drawarea), "drag-data-received", G_CALLBACK(drag_data_received_cb), NULL); #endif ! // With GTK+ 2, we need to iconify the window before calling show() ! // to avoid mapping the window for a short time. if (found_iconic_arg && gtk_socket_id == 0) gui_mch_iconify(); *************** *** 4510,4519 **** } resize_idle_installed = FALSE; ! return FALSE; /* don't call me again */ } # endif ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ /* * Return TRUE if the main window is maximized. --- 4498,4507 ---- } resize_idle_installed = FALSE; ! return FALSE; // don't call me again } # endif ! #endif // !GTK_CHECK_VERSION(3,0,0) /* * Return TRUE if the main window is maximized. *************** *** 4561,4576 **** int base_width UNUSED, int base_height UNUSED, int direction UNUSED) { ! /* give GTK+ a chance to put all widget's into place */ gui_mch_update(); ! /* this will cause the proper resizement to happen too */ if (gtk_socket_id == 0) update_window_manager_hints(0, 0); ! /* With GTK+ 2, changing the size of the form widget doesn't resize ! * the window. So let's do it the other way around and resize the ! * main window instead. */ width += get_menu_tool_width(); height += get_menu_tool_height(); --- 4549,4564 ---- int base_width UNUSED, int base_height UNUSED, int direction UNUSED) { ! // give GTK+ a chance to put all widget's into place gui_mch_update(); ! // this will cause the proper resizement to happen too if (gtk_socket_id == 0) update_window_manager_hints(0, 0); ! // With GTK+ 2, changing the size of the form widget doesn't resize ! // the window. So let's do it the other way around and resize the ! // main window instead. width += get_menu_tool_width(); height += get_menu_tool_height(); *************** *** 4588,4594 **** resize_idle_installed = TRUE; } # endif ! # endif /* !GTK_CHECK_VERSION(3,0,0) */ /* * Wait until all events are processed to prevent a crash because the * real size of the drawing area doesn't reflect Vim's internal ideas. --- 4576,4582 ---- resize_idle_installed = TRUE; } # endif ! # endif // !GTK_CHECK_VERSION(3,0,0) /* * Wait until all events are processed to prevent a crash because the * real size of the drawing area doesn't reflect Vim's internal ideas. *************** *** 4643,4650 **** gui_gtk_get_screen_geom_of_win(gui.mainwin, &x, &y, screen_w, screen_h); ! /* Subtract 'guiheadroom' from the height to allow some room for the ! * window manager (task list and window title bar). */ *screen_h -= p_ghr; /* --- 4631,4638 ---- gui_gtk_get_screen_geom_of_win(gui.mainwin, &x, &y, screen_w, screen_h); ! // Subtract 'guiheadroom' from the height to allow some room for the ! // window manager (task list and window title bar). *screen_h -= p_ghr; /* *************** *** 4669,4675 **** if (output_conv.vc_type != CONV_NONE) vim_free(title); } ! #endif /* FEAT_TITLE */ #if defined(FEAT_MENU) || defined(PROTO) void --- 4657,4663 ---- if (output_conv.vc_type != CONV_NONE) vim_free(title); } ! #endif // FEAT_TITLE #if defined(FEAT_MENU) || defined(PROTO) void *************** *** 4684,4690 **** # endif widget = gui.menubar; ! /* Do not disable the menu while starting up, otherwise F10 doesn't work. */ if (!showit != !gtk_widget_get_visible(widget) && !gui.starting) { if (showit) --- 4672,4678 ---- # endif widget = gui.menubar; ! // Do not disable the menu while starting up, otherwise F10 doesn't work. if (!showit != !gtk_widget_get_visible(widget) && !gui.starting) { if (showit) *************** *** 4695,4701 **** update_window_manager_hints(0, 0); } } ! #endif /* FEAT_MENU */ #if defined(FEAT_TOOLBAR) || defined(PROTO) void --- 4683,4689 ---- update_window_manager_hints(0, 0); } } ! #endif // FEAT_MENU #if defined(FEAT_TOOLBAR) || defined(PROTO) void *************** *** 4726,4732 **** update_window_manager_hints(0, 0); } } ! #endif /* FEAT_TOOLBAR */ /* * Check if a given font is a CJK font. This is done in a very crude manner. It --- 4714,4720 ---- update_window_manager_hints(0, 0); } } ! #endif // FEAT_TOOLBAR /* * Check if a given font is a CJK font. This is done in a very crude manner. It *************** *** 4790,4800 **** gui.char_height = (ascent + descent + PANGO_SCALE - 1) / PANGO_SCALE + p_linespace; ! /* LINTED: avoid warning: bitwise operation on signed value */ gui.char_ascent = PANGO_PIXELS(ascent + p_linespace * PANGO_SCALE / 2); ! /* A not-positive value of char_height may crash Vim. Only happens ! * if 'linespace' is negative (which does make sense sometimes). */ gui.char_ascent = MAX(gui.char_ascent, 0); gui.char_height = MAX(gui.char_height, gui.char_ascent + 1); --- 4778,4788 ---- gui.char_height = (ascent + descent + PANGO_SCALE - 1) / PANGO_SCALE + p_linespace; ! // LINTED: avoid warning: bitwise operation on signed value gui.char_ascent = PANGO_PIXELS(ascent + p_linespace * PANGO_SCALE / 2); ! // A not-positive value of char_height may crash Vim. Only happens ! // if 'linespace' is negative (which does make sense sometimes). gui.char_ascent = MAX(gui.char_ascent, 0); gui.char_height = MAX(gui.char_height, gui.char_ascent + 1); *************** *** 4802,4808 **** } #if GTK_CHECK_VERSION(3,0,0) ! /* Callback function used in gui_mch_font_dialog() */ static gboolean font_filter(const PangoFontFamily *family, const PangoFontFace *face UNUSED, --- 4790,4796 ---- } #if GTK_CHECK_VERSION(3,0,0) ! // Callback function used in gui_mch_font_dialog() static gboolean font_filter(const PangoFontFamily *family, const PangoFontFace *face UNUSED, *************** *** 4847,4854 **** else oldname = oldval; ! /* Annoying bug in GTK (or Pango): if the font name does not include a ! * size, zero is used. Use default point size ten. */ if (!vim_isdigit(oldname[STRLEN(oldname) - 1])) { char_u *p = vim_strnsave(oldname, STRLEN(oldname) + 3); --- 4835,4842 ---- else oldname = oldval; ! // Annoying bug in GTK (or Pango): if the font name does not include a ! // size, zero is used. Use default point size ten. if (!vim_isdigit(oldname[STRLEN(oldname) - 1])) { char_u *p = vim_strnsave(oldname, STRLEN(oldname) + 3); *************** *** 4898,4905 **** { char_u *p; ! /* Apparently some font names include a comma, need to escape ! * that, because in 'guifont' it separates names. */ p = vim_strsave_escaped((char_u *)name, (char_u *)","); g_free(name); if (p != NULL && input_conv.vc_type != CONV_NONE) --- 4886,4893 ---- { char_u *p; ! // Apparently some font names include a comma, need to escape ! // that, because in 'guifont' it separates names. p = vim_strsave_escaped((char_u *)name, (char_u *)","); g_free(name); if (p != NULL && input_conv.vc_type != CONV_NONE) *************** *** 4985,4992 **** gui.ascii_glyphs = NULL; gui.ascii_font = NULL; ! /* For safety, fill in question marks for the control characters. ! * Put a space between characters to avoid shaping. */ for (i = 0; i < 128; ++i) { if (i >= 32 && i < 127) --- 4973,4980 ---- gui.ascii_glyphs = NULL; gui.ascii_font = NULL; ! // For safety, fill in question marks for the control characters. ! // Put a space between characters to avoid shaping. for (i = 0; i < 128; ++i) { if (i >= 32 && i < 127) *************** *** 5000,5006 **** item_list = pango_itemize(gui.text_context, (const char *)ascii_chars, 0, sizeof(ascii_chars), attr_list, NULL); ! if (item_list != NULL && item_list->next == NULL) /* play safe */ { PangoItem *item; int width; --- 4988,4994 ---- item_list = pango_itemize(gui.text_context, (const char *)ascii_chars, 0, sizeof(ascii_chars), attr_list, NULL); ! if (item_list != NULL && item_list->next == NULL) // play safe { PangoItem *item; int width; *************** *** 5008,5014 **** item = (PangoItem *)item_list->data; width = gui.char_width * PANGO_SCALE; ! /* Remember the shape engine used for ASCII. */ default_shape_engine = item->analysis.shape_engine; gui.ascii_font = item->analysis.font; --- 4996,5002 ---- item = (PangoItem *)item_list->data; width = gui.char_width * PANGO_SCALE; ! // Remember the shape engine used for ASCII. default_shape_engine = item->analysis.shape_engine; gui.ascii_font = item->analysis.font; *************** *** 5047,5054 **** PangoLayout *layout; int width; ! /* If font_name is NULL, this means to use the default, which should ! * be present on all proper Pango/fontconfig installations. */ if (font_name == NULL) font_name = (char_u *)DEFAULT_FONT; --- 5035,5042 ---- PangoLayout *layout; int width; ! // If font_name is NULL, this means to use the default, which should ! // be present on all proper Pango/fontconfig installations. if (font_name == NULL) font_name = (char_u *)DEFAULT_FONT; *************** *** 5088,5117 **** { int cjk_width; ! /* Measure the text extent of U+4E00 and U+4E8C */ pango_layout_set_text(layout, "\344\270\200\344\272\214", -1); pango_layout_get_size(layout, &cjk_width, NULL); ! if (width == cjk_width) /* Xft not patched */ width /= 2; } g_object_unref(layout); gui.char_width = (width / 2 + PANGO_SCALE - 1) / PANGO_SCALE; ! /* A zero width may cause a crash. Happens for semi-invalid fontsets. */ if (gui.char_width <= 0) gui.char_width = 8; gui_mch_adjust_charheight(); ! /* Set the fontname, which will be used for information purposes */ hl_set_font_name(font_name); get_styled_font_variants(); ascii_glyph_table_init(); ! /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */ if (gui.wide_font != NULL && pango_font_description_equal(gui.norm_font, gui.wide_font)) { --- 5076,5105 ---- { int cjk_width; ! // Measure the text extent of U+4E00 and U+4E8C pango_layout_set_text(layout, "\344\270\200\344\272\214", -1); pango_layout_get_size(layout, &cjk_width, NULL); ! if (width == cjk_width) // Xft not patched width /= 2; } g_object_unref(layout); gui.char_width = (width / 2 + PANGO_SCALE - 1) / PANGO_SCALE; ! // A zero width may cause a crash. Happens for semi-invalid fontsets. if (gui.char_width <= 0) gui.char_width = 8; gui_mch_adjust_charheight(); ! // Set the fontname, which will be used for information purposes hl_set_font_name(font_name); get_styled_font_variants(); ascii_glyph_table_init(); ! // Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. if (gui.wide_font != NULL && pango_font_description_equal(gui.norm_font, gui.wide_font)) { *************** *** 5121,5133 **** if (gui_mch_maximized()) { ! /* Update lines and columns in accordance with the new font, keep the ! * window maximized. */ gui_mch_newfont(); } else { ! /* Preserve the logical dimensions of the screen. */ update_window_manager_hints(0, 0); } --- 5109,5121 ---- if (gui_mch_maximized()) { ! // Update lines and columns in accordance with the new font, keep the ! // window maximized. gui_mch_newfont(); } else { ! // Preserve the logical dimensions of the screen. update_window_manager_hints(0, 0); } *************** *** 5143,5149 **** { PangoFontDescription *font; ! /* can't do this when GUI is not running */ if (!gui.in_use || name == NULL) return NULL; --- 5131,5137 ---- { PangoFontDescription *font; ! // can't do this when GUI is not running if (!gui.in_use || name == NULL) return NULL; *************** *** 5167,5173 **** { PangoFont *real_font; ! /* pango_context_load_font() bails out if no font size is set */ if (pango_font_description_get_size(font) <= 0) pango_font_description_set_size(font, 10 * PANGO_SCALE); --- 5155,5161 ---- { PangoFont *real_font; ! // pango_context_load_font() bails out if no font size is set if (pango_font_description_get_size(font) <= 0) pango_font_description_set_size(font, 10 * PANGO_SCALE); *************** *** 5235,5241 **** { guicolor_T color = INVALCOLOR; ! if (!gui.in_use) /* can't do this when GUI not running */ return color; if (name != NULL) --- 5223,5229 ---- { guicolor_T color = INVALCOLOR; ! if (!gui.in_use) // can't do this when GUI not running return color; if (name != NULL) *************** *** 5345,5351 **** if (uc >= 0x80 && utf_char2cells(uc) == 2) start = p; } ! else if (uc < 0x80 /* optimization shortcut */ || (utf_char2cells(uc) != 2 && !utf_iscomposing(uc))) { INSERT_PANGO_ATTR(pango_attr_font_desc_new(gui.wide_font), --- 5333,5339 ---- if (uc >= 0x80 && utf_char2cells(uc) == 2) start = p; } ! else if (uc < 0x80 // optimization shortcut || (utf_char2cells(uc) != 2 && !utf_iscomposing(uc))) { INSERT_PANGO_ATTR(pango_attr_font_desc_new(gui.wide_font), *************** *** 5366,5374 **** int *last_glyph_rbearing) { char_u *p; ! int next; /* glyph start index of next cluster */ ! int start, end; /* string segment of current cluster */ ! int width; /* real cluster width in Pango units */ int uc; int cellcount = 0; --- 5354,5362 ---- int *last_glyph_rbearing) { char_u *p; ! int next; // glyph start index of next cluster ! int start, end; // string segment of current cluster ! int width; // real cluster width in Pango units int uc; int cellcount = 0; *************** *** 5456,5463 **** - (gui.char_height - p_linespace) * PANGO_SCALE; } else ! /* If the accent width is smaller than the cluster width, position it ! * in the middle. */ glyph->geometry.x_offset = -width + MAX(0, width - ink_rect.width) / 2; } --- 5444,5451 ---- - (gui.char_height - p_linespace) * PANGO_SCALE; } else ! // If the accent width is smaller than the cluster width, position it ! // in the middle. glyph->geometry.x_offset = -width + MAX(0, width - ink_rect.width) / 2; } *************** *** 5512,5518 **** glyphs); #endif ! /* redraw the contents with an offset of 1 to emulate bold */ if ((flags & DRAW_BOLD) && !gui.font_can_bold) #if GTK_CHECK_VERSION(3,0,0) { --- 5500,5506 ---- glyphs); #endif ! // redraw the contents with an offset of 1 to emulate bold if ((flags & DRAW_BOLD) && !gui.font_can_bold) #if GTK_CHECK_VERSION(3,0,0) { *************** *** 5548,5554 **** static const int val[8] = {1, 0, 0, 0, 1, 2, 2, 2 }; int y = FILL_Y(row + 1) - 1; ! /* Undercurl: draw curl at the bottom of the character cell. */ if (flags & DRAW_UNDERC) { #if GTK_CHECK_VERSION(3,0,0) --- 5536,5542 ---- static const int val[8] = {1, 0, 0, 0, 1, 2, 2, 2 }; int y = FILL_Y(row + 1) - 1; ! // Undercurl: draw curl at the bottom of the character cell. if (flags & DRAW_UNDERC) { #if GTK_CHECK_VERSION(3,0,0) *************** *** 5574,5580 **** #endif } ! /* Draw a strikethrough line */ if (flags & DRAW_STRIKE) { #if GTK_CHECK_VERSION(3,0,0) --- 5562,5568 ---- #endif } ! // Draw a strikethrough line if (flags & DRAW_STRIKE) { #if GTK_CHECK_VERSION(3,0,0) *************** *** 5595,5605 **** #endif } ! /* Underline: draw a line at the bottom of the character cell. */ if (flags & DRAW_UNDERL) { ! /* When p_linespace is 0, overwrite the bottom row of pixels. ! * Otherwise put the line just below the character. */ if (p_linespace > 1) y -= p_linespace - 1; #if GTK_CHECK_VERSION(3,0,0) --- 5583,5593 ---- #endif } ! // Underline: draw a line at the bottom of the character cell. if (flags & DRAW_UNDERL) { ! // When p_linespace is 0, overwrite the bottom row of pixels. ! // Otherwise put the line just below the character. if (p_linespace > 1) y -= p_linespace - 1; #if GTK_CHECK_VERSION(3,0,0) *************** *** 5622,5632 **** int gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags) { ! GdkRectangle area; /* area for clip mask */ ! PangoGlyphString *glyphs; /* glyphs of current item */ ! int column_offset = 0; /* column offset in cells */ int i; ! char_u *conv_buf = NULL; /* result of UTF-8 conversion */ char_u *new_conv_buf; int convlen; char_u *sp, *bp; --- 5610,5620 ---- int gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags) { ! GdkRectangle area; // area for clip mask ! PangoGlyphString *glyphs; // glyphs of current item ! int column_offset = 0; // column offset in cells int i; ! char_u *conv_buf = NULL; // result of UTF-8 conversion char_u *new_conv_buf; int convlen; char_u *sp, *bp; *************** *** 5650,5658 **** conv_buf = string_convert(&output_conv, s, &convlen); g_return_val_if_fail(conv_buf != NULL, len); ! /* Correct for differences in char width: some chars are ! * double-wide in 'encoding' but single-wide in utf-8. Add a space to ! * compensate for that. */ for (sp = s, bp = conv_buf; sp < s + len && bp < conv_buf + convlen; ) { plen = utf_ptr2len(bp); --- 5638,5646 ---- conv_buf = string_convert(&output_conv, s, &convlen); g_return_val_if_fail(conv_buf != NULL, len); ! // Correct for differences in char width: some chars are ! // double-wide in 'encoding' but single-wide in utf-8. Add a space to ! // compensate for that. for (sp = s, bp = conv_buf; sp < s + len && bp < conv_buf + convlen; ) { plen = utf_ptr2len(bp); *************** *** 5737,5762 **** GList *item_list; int cluster_width; int last_glyph_rbearing; ! int cells = 0; /* cells occupied by current cluster */ ! /* Safety check: pango crashes when invoked with invalid utf-8 ! * characters. */ if (!utf_valid_string(s, s + len)) { column_offset = len; goto skipitall; } ! /* original width of the current cluster */ cluster_width = PANGO_SCALE * gui.char_width; ! /* right bearing of the last non-composing glyph */ last_glyph_rbearing = PANGO_SCALE * gui.char_width; attr_list = pango_attr_list_new(); ! /* If 'guifontwide' is set then use that for double-width characters. ! * Otherwise just go with 'guifont' and let Pango do its thing. */ if (gui.wide_font != NULL) apply_wide_font_attr(s, len, attr_list); --- 5725,5750 ---- GList *item_list; int cluster_width; int last_glyph_rbearing; ! int cells = 0; // cells occupied by current cluster ! // Safety check: pango crashes when invoked with invalid utf-8 ! // characters. if (!utf_valid_string(s, s + len)) { column_offset = len; goto skipitall; } ! // original width of the current cluster cluster_width = PANGO_SCALE * gui.char_width; ! // right bearing of the last non-composing glyph last_glyph_rbearing = PANGO_SCALE * gui.char_width; attr_list = pango_attr_list_new(); ! // If 'guifontwide' is set then use that for double-width characters. ! // Otherwise just go with 'guifont' and let Pango do its thing. if (gui.wide_font != NULL) apply_wide_font_attr(s, len, attr_list); *************** *** 5778,5784 **** while (item_list != NULL) { PangoItem *item; ! int item_cells = 0; /* item length in cells */ item = (PangoItem *)item_list->data; item_list = g_list_delete_link(item_list, item_list); --- 5766,5772 ---- while (item_list != NULL) { PangoItem *item; ! int item_cells = 0; // item length in cells item = (PangoItem *)item_list->data; item_list = g_list_delete_link(item_list, item_list); *************** *** 5796,5803 **** */ item->analysis.level = (item->analysis.level + 1) & (~1U); ! /* HACK: Overrule the shape engine, we don't want shaping to be ! * done, because drawing the cursor would change the display. */ item->analysis.shape_engine = default_shape_engine; #ifdef HAVE_PANGO_SHAPE_FULL --- 5784,5791 ---- */ item->analysis.level = (item->analysis.level + 1) & (~1U); ! // HACK: Overrule the shape engine, we don't want shaping to be ! // done, because drawing the cursor would change the display. item->analysis.shape_engine = default_shape_engine; #ifdef HAVE_PANGO_SHAPE_FULL *************** *** 5841,5850 **** } else { ! /* If there are only combining characters in the ! * cluster, we cannot just change the width of the ! * previous glyph since there is none. Therefore ! * some guesswork is needed. */ setup_zero_width_cluster(item, glyph, cells, cluster_width, last_glyph_rbearing); --- 5829,5838 ---- } else { ! // If there are only combining characters in the ! // cluster, we cannot just change the width of the ! // previous glyph since there is none. Therefore ! // some guesswork is needed. setup_zero_width_cluster(item, glyph, cells, cluster_width, last_glyph_rbearing); *************** *** 5857,5872 **** { int width; ! /* There is a previous glyph, so we deal with combining ! * characters the canonical way. ! * In some circumstances Pango uses a positive x_offset, ! * then use the width of the previous glyph for this one ! * and set the previous width to zero. ! * Otherwise we get a negative x_offset, Pango has already ! * positioned the combining char, keep the widths as they ! * are. ! * For both adjust the x_offset to position the glyph in ! * the middle. */ if (glyph->geometry.x_offset >= 0) { glyphs->glyphs[i].geometry.width = --- 5845,5860 ---- { int width; ! // There is a previous glyph, so we deal with combining ! // characters the canonical way. ! // In some circumstances Pango uses a positive x_offset, ! // then use the width of the previous glyph for this one ! // and set the previous width to zero. ! // Otherwise we get a negative x_offset, Pango has already ! // positioned the combining char, keep the widths as they ! // are. ! // For both adjust the x_offset to position the glyph in ! // the middle. if (glyph->geometry.x_offset >= 0) { glyphs->glyphs[i].geometry.width = *************** *** 5877,5889 **** glyph->geometry.x_offset += MAX(0, width - cluster_width) / 2; } ! else /* i == 0 "cannot happen" */ { glyph->geometry.width = 0; } } ! /*** Aaaaand action! ***/ #if GTK_CHECK_VERSION(3,0,0) draw_glyph_string(row, col + column_offset, item_cells, flags, item->analysis.font, glyphs, --- 5865,5877 ---- glyph->geometry.x_offset += MAX(0, width - cluster_width) / 2; } ! else // i == 0 "cannot happen" { glyph->geometry.width = 0; } } ! //// Aaaaand action! ** #if GTK_CHECK_VERSION(3,0,0) draw_glyph_string(row, col + column_offset, item_cells, flags, item->analysis.font, glyphs, *************** *** 5902,5908 **** } skipitall: ! /* Draw underline and undercurl. */ #if GTK_CHECK_VERSION(3,0,0) draw_under(flags, row, col, column_offset, cr); #else --- 5890,5896 ---- } skipitall: ! // Draw underline and undercurl. #if GTK_CHECK_VERSION(3,0,0) draw_under(flags, row, col, column_offset, cr); #else *************** *** 5990,5996 **** gui_mch_flash(int msec) { #if GTK_CHECK_VERSION(3,0,0) ! /* TODO Replace GdkGC with Cairo */ (void)msec; #else GdkGCValues values; --- 5978,5984 ---- gui_mch_flash(int msec) { #if GTK_CHECK_VERSION(3,0,0) ! // TODO Replace GdkGC with Cairo (void)msec; #else GdkGCValues values; *************** *** 6023,6029 **** FILL_Y((int)Rows) + gui.border_offset); gui_mch_flush(); ! ui_delay((long)msec, TRUE); /* wait so many msec */ gdk_draw_rectangle(gui.drawarea->window, invert_gc, TRUE, --- 6011,6017 ---- FILL_Y((int)Rows) + gui.border_offset); gui_mch_flush(); ! ui_delay((long)msec, TRUE); // wait so many msec gdk_draw_rectangle(gui.drawarea->window, invert_gc, TRUE, *************** *** 6051,6057 **** # if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,2) cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); # else ! /* Give an implementation for older cairo versions if necessary. */ # endif gdk_cairo_rectangle(cr, &rect); cairo_fill(cr); --- 6039,6045 ---- # if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,2) cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); # else ! // Give an implementation for older cairo versions if necessary. # endif gdk_cairo_rectangle(cr, &rect); cairo_fill(cr); *************** *** 6173,6179 **** gui.fgcolor->alpha); cairo_rectangle(cr, # ifdef FEAT_RIGHTLEFT ! /* vertical line should be on the right of current point */ CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : # endif FILL_X(gui.col), FILL_Y(gui.row) + gui.char_height - h, --- 6161,6167 ---- gui.fgcolor->alpha); cairo_rectangle(cr, # ifdef FEAT_RIGHTLEFT ! // vertical line should be on the right of current point CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : # endif FILL_X(gui.col), FILL_Y(gui.row) + gui.char_height - h, *************** *** 6181,6198 **** cairo_fill(cr); cairo_destroy(cr); } ! #else /* !GTK_CHECK_VERSION(3,0,0) */ gdk_gc_set_foreground(gui.text_gc, gui.fgcolor); gdk_draw_rectangle(gui.drawarea->window, gui.text_gc, TRUE, # ifdef FEAT_RIGHTLEFT ! /* vertical line should be on the right of current point */ CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : # endif FILL_X(gui.col), FILL_Y(gui.row) + gui.char_height - h, w, h); ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ } --- 6169,6186 ---- cairo_fill(cr); cairo_destroy(cr); } ! #else // !GTK_CHECK_VERSION(3,0,0) gdk_gc_set_foreground(gui.text_gc, gui.fgcolor); gdk_draw_rectangle(gui.drawarea->window, gui.text_gc, TRUE, # ifdef FEAT_RIGHTLEFT ! // vertical line should be on the right of current point CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : # endif FILL_X(gui.col), FILL_Y(gui.row) + gui.char_height - h, w, h); ! #endif // !GTK_CHECK_VERSION(3,0,0) } *************** *** 6214,6235 **** { int *timed_out = (int *) data; ! /* Just inform the caller about the occurrence of it */ *timed_out = TRUE; ! return FALSE; /* don't happen again */ } #ifdef FEAT_JOB_CHANNEL static timeout_cb_type channel_poll_cb(gpointer data UNUSED) { ! /* Using an event handler for a channel that may be disconnected does ! * not work, it hangs. Instead poll for messages. */ channel_handle_events(TRUE); parse_queued_messages(); ! return TRUE; /* repeat */ } #endif --- 6202,6223 ---- { int *timed_out = (int *) data; ! // Just inform the caller about the occurrence of it *timed_out = TRUE; ! return FALSE; // don't happen again } #ifdef FEAT_JOB_CHANNEL static timeout_cb_type channel_poll_cb(gpointer data UNUSED) { ! // Using an event handler for a channel that may be disconnected does ! // not work, it hangs. Instead poll for messages. channel_handle_events(TRUE); parse_queued_messages(); ! return TRUE; // repeat } #endif *************** *** 6264,6271 **** timer = 0; #ifdef FEAT_JOB_CHANNEL ! /* If there is a channel with the keep_open flag we need to poll for input ! * on them. */ if (channel_any_keep_open()) channel_timer = timeout_add(20, channel_poll_cb, NULL); #endif --- 6252,6259 ---- timer = 0; #ifdef FEAT_JOB_CHANNEL ! // If there is a channel with the keep_open flag we need to poll for input ! // on them. if (channel_any_keep_open()) channel_timer = timeout_add(20, channel_poll_cb, NULL); #endif *************** *** 6274,6280 **** do { ! /* Stop or start blinking when focus changes */ if (gui.in_focus != focus) { if (gui.in_focus) --- 6262,6268 ---- do { ! // Stop or start blinking when focus changes if (gui.in_focus != focus) { if (gui.in_focus) *************** *** 6291,6297 **** parse_queued_messages(); # ifdef FEAT_TIMERS if (did_add_timer) ! /* Need to recompute the waiting time. */ goto theend; # endif #endif --- 6279,6285 ---- parse_queued_messages(); # ifdef FEAT_TIMERS if (did_add_timer) ! // Need to recompute the waiting time. goto theend; # endif #endif *************** *** 6304,6310 **** if (!input_available()) g_main_context_iteration(NULL, TRUE); ! /* Got char, return immediately */ if (input_available()) { retval = OK; --- 6292,6298 ---- if (!input_available()) g_main_context_iteration(NULL, TRUE); ! // Got char, return immediately if (input_available()) { retval = OK; *************** *** 6329,6340 **** } ! /**************************************************************************** ! * Output drawing routines. ! ****************************************************************************/ ! /* Flush any output to the screen */ void gui_mch_flush(void) { --- 6317,6328 ---- } ! ///////////////////////////////////////////////////////////////////////////// ! // Output drawing routines. ! // ! // Flush any output to the screen void gui_mch_flush(void) { *************** *** 6373,6380 **** #if GTK_CHECK_VERSION(3,0,0) { ! /* Add one pixel to the far right column in case a double-stroked ! * bold glyph may sit there. */ const GdkRectangle rect = { FILL_X(col1), FILL_Y(row1), (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1), --- 6361,6368 ---- #if GTK_CHECK_VERSION(3,0,0) { ! // Add one pixel to the far right column in case a double-stroked ! // bold glyph may sit there. const GdkRectangle rect = { FILL_X(col1), FILL_Y(row1), (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1), *************** *** 6398,6414 **** if (!gui.by_signal) gdk_window_invalidate_rect(win, &rect, FALSE); } ! #else /* !GTK_CHECK_VERSION(3,0,0) */ gdk_gc_set_foreground(gui.text_gc, &color); ! /* Clear one extra pixel at the far right, for when bold characters have ! * spilled over to the window border. */ gdk_draw_rectangle(gui.drawarea->window, gui.text_gc, TRUE, FILL_X(col1), FILL_Y(row1), (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1), (row2 - row1 + 1) * gui.char_height); ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ } #if GTK_CHECK_VERSION(3,0,0) --- 6386,6402 ---- if (!gui.by_signal) gdk_window_invalidate_rect(win, &rect, FALSE); } ! #else // !GTK_CHECK_VERSION(3,0,0) gdk_gc_set_foreground(gui.text_gc, &color); ! // Clear one extra pixel at the far right, for when bold characters have ! // spilled over to the window border. gdk_draw_rectangle(gui.drawarea->window, gui.text_gc, TRUE, FILL_X(col1), FILL_Y(row1), (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1), (row2 - row1 + 1) * gui.char_height); ! #endif // !GTK_CHECK_VERSION(3,0,0) } #if GTK_CHECK_VERSION(3,0,0) *************** *** 6459,6477 **** if (gui.visibility != GDK_VISIBILITY_PARTIAL) return; ! /* Avoid redrawing the cursor while scrolling or it'll end up where ! * we don't want it to be. I'm not sure if it's correct to call ! * gui_dont_update_cursor() at this point but it works as a quick ! * fix for now. */ gui_dont_update_cursor(TRUE); do { ! /* Wait to check whether the scroll worked or not. */ event = gdk_event_get_graphics_expose(gui.drawarea->window); if (event == NULL) ! break; /* received NoExpose event */ gui_redraw(event->expose.area.x, event->expose.area.y, event->expose.area.width, event->expose.area.height); --- 6447,6465 ---- if (gui.visibility != GDK_VISIBILITY_PARTIAL) return; ! // Avoid redrawing the cursor while scrolling or it'll end up where ! // we don't want it to be. I'm not sure if it's correct to call ! // gui_dont_update_cursor() at this point but it works as a quick ! // fix for now. gui_dont_update_cursor(TRUE); do { ! // Wait to check whether the scroll worked or not. event = gdk_event_get_graphics_expose(gui.drawarea->window); if (event == NULL) ! break; // received NoExpose event gui_redraw(event->expose.area.x, event->expose.area.y, event->expose.area.width, event->expose.area.height); *************** *** 6479,6489 **** expose_count = event->expose.count; gdk_event_free(event); } ! while (expose_count > 0); /* more events follow */ gui_can_update_cursor(); } ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ #if GTK_CHECK_VERSION(3,0,0) static void --- 6467,6477 ---- expose_count = event->expose.count; gdk_event_free(event); } ! while (expose_count > 0); // more events follow gui_can_update_cursor(); } ! #endif // !GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0) static void *************** *** 6533,6544 **** gui.char_width * ncols + 1, gui.char_height * nrows); #else if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED) ! return; /* Can't see the window */ gdk_gc_set_foreground(gui.text_gc, gui.fgcolor); gdk_gc_set_background(gui.text_gc, gui.bgcolor); ! /* copy one extra pixel, for when bold has spilled over */ gdk_window_copy_area(gui.drawarea->window, gui.text_gc, FILL_X(gui.scroll_region_left), FILL_Y(row), gui.drawarea->window, --- 6521,6532 ---- gui.char_width * ncols + 1, gui.char_height * nrows); #else if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED) ! return; // Can't see the window gdk_gc_set_foreground(gui.text_gc, gui.fgcolor); gdk_gc_set_background(gui.text_gc, gui.bgcolor); ! // copy one extra pixel, for when bold has spilled over gdk_window_copy_area(gui.drawarea->window, gui.text_gc, FILL_X(gui.scroll_region_left), FILL_Y(row), gui.drawarea->window, *************** *** 6552,6558 **** gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right); check_copy_area(); ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ } /* --- 6540,6546 ---- gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right); check_copy_area(); ! #endif // !GTK_CHECK_VERSION(3,0,0) } /* *************** *** 6583,6594 **** gui.char_width * ncols + 1, gui.char_height * nrows); #else if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED) ! return; /* Can't see the window */ gdk_gc_set_foreground(gui.text_gc, gui.fgcolor); gdk_gc_set_background(gui.text_gc, gui.bgcolor); ! /* copy one extra pixel, for when bold has spilled over */ gdk_window_copy_area(gui.drawarea->window, gui.text_gc, FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines), gui.drawarea->window, --- 6571,6582 ---- gui.char_width * ncols + 1, gui.char_height * nrows); #else if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED) ! return; // Can't see the window gdk_gc_set_foreground(gui.text_gc, gui.fgcolor); gdk_gc_set_background(gui.text_gc, gui.bgcolor); ! // copy one extra pixel, for when bold has spilled over gdk_window_copy_area(gui.drawarea->window, gui.text_gc, FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines), gui.drawarea->window, *************** *** 6600,6606 **** gui_clear_block(row, gui.scroll_region_left, row + num_lines - 1, gui.scroll_region_right); check_copy_area(); ! #endif /* !GTK_CHECK_VERSION(3,0,0) */ } /* --- 6588,6594 ---- gui_clear_block(row, gui.scroll_region_left, row + num_lines - 1, gui.scroll_region_right); check_copy_area(); ! #endif // !GTK_CHECK_VERSION(3,0,0) } /* *************** *** 6624,6641 **** cbd->gtk_sel_atom, target, (guint32)GDK_CURRENT_TIME); ! /* Hack: Wait up to three seconds for the selection. A hang was ! * noticed here when using the netrw plugin combined with ":gui" ! * during the FocusGained event. */ start = time(NULL); while (received_selection == RS_NONE && time(NULL) < start + 3) ! g_main_context_iteration(NULL, TRUE); /* wait for selection_received_cb */ if (received_selection != RS_FAIL) return; } ! /* Final fallback position - use the X CUT_BUFFER0 store */ yank_cut_buffer0(GDK_WINDOW_XDISPLAY(gtk_widget_get_window(gui.mainwin)), cbd); } --- 6612,6629 ---- cbd->gtk_sel_atom, target, (guint32)GDK_CURRENT_TIME); ! // Hack: Wait up to three seconds for the selection. A hang was ! // noticed here when using the netrw plugin combined with ":gui" ! // during the FocusGained event. start = time(NULL); while (received_selection == RS_NONE && time(NULL) < start + 3) ! g_main_context_iteration(NULL, TRUE); // wait for selection_received_cb if (received_selection != RS_FAIL) return; } ! // Final fallback position - use the X CUT_BUFFER0 store yank_cut_buffer0(GDK_WINDOW_XDISPLAY(gtk_widget_get_window(gui.mainwin)), cbd); } *************** *** 6699,6705 **** grey = TRUE; gui_mch_menu_hidden(menu, FALSE); ! /* Be clever about bitfields versus true booleans here! */ if (!gtk_widget_get_sensitive(menu->id) == !grey) { gtk_widget_set_sensitive(menu->id, !grey); --- 6687,6693 ---- grey = TRUE; gui_mch_menu_hidden(menu, FALSE); ! // Be clever about bitfields versus true booleans here! if (!gtk_widget_get_sensitive(menu->id) == !grey) { gtk_widget_set_sensitive(menu->id, !grey); *************** *** 6740,6749 **** void gui_mch_draw_menubar(void) { ! /* just make sure that the visual changes get effect immediately */ gui_mch_update(); } ! #endif /* FEAT_MENU */ /* * Scrollbar stuff. --- 6728,6737 ---- void gui_mch_draw_menubar(void) { ! // just make sure that the visual changes get effect immediately gui_mch_update(); } ! #endif // FEAT_MENU /* * Scrollbar stuff. *************** *** 6792,6800 **** void gui_mch_setmouse(int x, int y) { ! /* Sorry for the Xlib call, but we can't avoid it, since there is no ! * internal GDK mechanism present to accomplish this. (and for good ! * reason...) */ XWarpPointer(GDK_WINDOW_XDISPLAY(gtk_widget_get_window(gui.drawarea)), (Window)0, GDK_WINDOW_XID(gtk_widget_get_window(gui.drawarea)), 0, 0, 0U, 0U, x, y); --- 6780,6788 ---- void gui_mch_setmouse(int x, int y) { ! // Sorry for the Xlib call, but we can't avoid it, since there is no ! // internal GDK mechanism present to accomplish this. (and for good ! // reason...) XWarpPointer(GDK_WINDOW_XDISPLAY(gtk_widget_get_window(gui.drawarea)), (Window)0, GDK_WINDOW_XID(gtk_widget_get_window(gui.drawarea)), 0, 0, 0U, 0U, x, y); *************** *** 6802,6809 **** #ifdef FEAT_MOUSESHAPE ! /* The last set mouse pointer shape is remembered, to be used when it goes ! * from hidden to not hidden. */ static int last_shape = 0; #endif --- 6790,6797 ---- #ifdef FEAT_MOUSESHAPE ! // The last set mouse pointer shape is remembered, to be used when it goes ! // from hidden to not hidden. static int last_shape = 0; #endif *************** *** 6835,6861 **** #if defined(FEAT_MOUSESHAPE) || defined(PROTO) ! /* Table for shape IDs. Keep in sync with the mshape_names[] table in ! * misc2.c! */ static const int mshape_ids[] = { ! GDK_LEFT_PTR, /* arrow */ ! GDK_CURSOR_IS_PIXMAP, /* blank */ ! GDK_XTERM, /* beam */ ! GDK_SB_V_DOUBLE_ARROW, /* updown */ ! GDK_SIZING, /* udsizing */ ! GDK_SB_H_DOUBLE_ARROW, /* leftright */ ! GDK_SIZING, /* lrsizing */ ! GDK_WATCH, /* busy */ ! GDK_X_CURSOR, /* no */ ! GDK_CROSSHAIR, /* crosshair */ ! GDK_HAND1, /* hand1 */ ! GDK_HAND2, /* hand2 */ ! GDK_PENCIL, /* pencil */ ! GDK_QUESTION_ARROW, /* question */ ! GDK_RIGHT_PTR, /* right-arrow */ ! GDK_CENTER_PTR, /* up-arrow */ ! GDK_LEFT_PTR /* last one */ }; void --- 6823,6849 ---- #if defined(FEAT_MOUSESHAPE) || defined(PROTO) ! // Table for shape IDs. Keep in sync with the mshape_names[] table in ! // misc2.c! static const int mshape_ids[] = { ! GDK_LEFT_PTR, // arrow ! GDK_CURSOR_IS_PIXMAP, // blank ! GDK_XTERM, // beam ! GDK_SB_V_DOUBLE_ARROW, // updown ! GDK_SIZING, // udsizing ! GDK_SB_H_DOUBLE_ARROW, // leftright ! GDK_SIZING, // lrsizing ! GDK_WATCH, // busy ! GDK_X_CURSOR, // no ! GDK_CROSSHAIR, // crosshair ! GDK_HAND1, // hand1 ! GDK_HAND2, // hand2 ! GDK_PENCIL, // pencil ! GDK_QUESTION_ARROW, // question ! GDK_RIGHT_PTR, // right-arrow ! GDK_CENTER_PTR, // up-arrow ! GDK_LEFT_PTR // last one }; void *************** *** 6878,6884 **** if (id >= GDK_LAST_CURSOR) id = GDK_LEFT_PTR; else ! id &= ~1; /* they are always even (why?) */ } else if (shape < (int)(sizeof(mshape_ids) / sizeof(int))) id = mshape_ids[shape]; --- 6866,6872 ---- if (id >= GDK_LAST_CURSOR) id = GDK_LEFT_PTR; else ! id &= ~1; // they are always even (why?) } else if (shape < (int)(sizeof(mshape_ids) / sizeof(int))) id = mshape_ids[shape]; *************** *** 6890,6902 **** # if GTK_CHECK_VERSION(3,0,0) g_object_unref(G_OBJECT(c)); # else ! gdk_cursor_destroy(c); /* Unref, actually. Bloody GTK+ 1. */ # endif } if (shape != MSHAPE_HIDE) last_shape = shape; } ! #endif /* FEAT_MOUSESHAPE */ #if defined(FEAT_SIGN_ICONS) || defined(PROTO) --- 6878,6890 ---- # if GTK_CHECK_VERSION(3,0,0) g_object_unref(G_OBJECT(c)); # else ! gdk_cursor_destroy(c); // Unref, actually. Bloody GTK+ 1. # endif } if (shape != MSHAPE_HIDE) last_shape = shape; } ! #endif // FEAT_MOUSESHAPE #if defined(FEAT_SIGN_ICONS) || defined(PROTO) *************** *** 6945,6959 **** int w = width; int h = height; ! /* Keep the original aspect ratio */ aspect = (double)height / (double)width; width = (double)SIGN_WIDTH * SIGN_ASPECT / aspect; width = MIN(width, SIGN_WIDTH); if (((double)(MAX(height, SIGN_HEIGHT)) / (double)(MIN(height, SIGN_HEIGHT))) < 1.15) { ! /* Change the aspect ratio by at most 15% to fill the ! * available space completely. */ height = (double)SIGN_HEIGHT * SIGN_ASPECT / aspect; height = MIN(height, SIGN_HEIGHT); } --- 6933,6947 ---- int w = width; int h = height; ! // Keep the original aspect ratio aspect = (double)height / (double)width; width = (double)SIGN_WIDTH * SIGN_ASPECT / aspect; width = MIN(width, SIGN_WIDTH); if (((double)(MAX(height, SIGN_HEIGHT)) / (double)(MIN(height, SIGN_HEIGHT))) < 1.15) { ! // Change the aspect ratio by at most 15% to fill the ! // available space completely. height = (double)SIGN_HEIGHT * SIGN_ASPECT / aspect; height = MIN(height, SIGN_HEIGHT); } *************** *** 6962,6985 **** if (w == width && h == height) { ! /* no change in dimensions; don't decrease reference counter ! * (below) */ need_scale = FALSE; } else { ! /* This doesn't seem to be worth caching, and doing so would ! * complicate the code quite a bit. */ sign = gdk_pixbuf_scale_simple(sign, width, height, GDK_INTERP_BILINEAR); if (sign == NULL) ! return; /* out of memory */ } } ! /* The origin is the upper-left corner of the pixmap. Therefore ! * these offset may become negative if the pixmap is smaller than ! * the 2x1 cells reserved for the sign icon. */ xoffset = (width - SIGN_WIDTH) / 2; yoffset = (height - SIGN_HEIGHT) / 2; --- 6950,6973 ---- if (w == width && h == height) { ! // no change in dimensions; don't decrease reference counter ! // (below) need_scale = FALSE; } else { ! // This doesn't seem to be worth caching, and doing so would ! // complicate the code quite a bit. sign = gdk_pixbuf_scale_simple(sign, width, height, GDK_INTERP_BILINEAR); if (sign == NULL) ! return; // out of memory } } ! // The origin is the upper-left corner of the pixmap. Therefore ! // these offset may become negative if the pixmap is smaller than ! // the 2x1 cells reserved for the sign icon. xoffset = (width - SIGN_WIDTH) / 2; yoffset = (height - SIGN_HEIGHT) / 2; *************** *** 7027,7033 **** FILL_X(col), FILL_Y(col), width, height); } ! # else /* !GTK_CHECK_VERSION(3,0,0) */ gdk_gc_set_foreground(gui.text_gc, gui.bgcolor); gdk_draw_rectangle(gui.drawarea->window, --- 7015,7021 ---- FILL_X(col), FILL_Y(col), width, height); } ! # else // !GTK_CHECK_VERSION(3,0,0) gdk_gc_set_foreground(gui.text_gc, gui.bgcolor); gdk_draw_rectangle(gui.drawarea->window, *************** *** 7050,7056 **** 127, GDK_RGB_DITHER_NORMAL, 0, 0); ! # endif /* !GTK_CHECK_VERSION(3,0,0) */ if (need_scale) g_object_unref(sign); } --- 7038,7044 ---- 127, GDK_RGB_DITHER_NORMAL, 0, 0); ! # endif // !GTK_CHECK_VERSION(3,0,0) if (need_scale) g_object_unref(sign); } *************** *** 7077,7084 **** if (message != NULL) { ! /* The error message is already translated and will be more ! * descriptive than anything we could possibly do ourselves. */ semsg("E255: %s", message); if (input_conv.vc_type != CONV_NONE) --- 7065,7072 ---- if (message != NULL) { ! // The error message is already translated and will be more ! // descriptive than anything we could possibly do ourselves. semsg("E255: %s", message); if (input_conv.vc_type != CONV_NONE) *************** *** 7097,7100 **** g_object_unref(sign); } ! #endif /* FEAT_SIGN_ICONS */ --- 7085,7088 ---- g_object_unref(sign); } ! #endif // FEAT_SIGN_ICONS *** ../vim-8.1.2379/src/version.c 2019-12-01 21:41:24.485837808 +0100 --- src/version.c 2019-12-01 22:08:09.377641691 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 2380, /**/ -- An error has occurred. Hit any user to continue. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///