comparison src/gui_x11.c @ 18788:e1f4e9d78a6a v8.1.2383

patch 8.1.2383: using old C style comments Commit: https://github.com/vim/vim/commit/734a867ffe198886da7365b618be67ab8ed9d9f6 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 2 22:49:38 2019 +0100 patch 8.1.2383: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate.
author Bram Moolenaar <Bram@vim.org>
date Mon, 02 Dec 2019 23:00:04 +0100
parents df141c730008
children aadd1cae2ff5
comparison
equal deleted inserted replaced
18787:06ed2fe62dce 18788:e1f4e9d78a6a
55 #endif 55 #endif
56 56
57 #define VIM_NAME "vim" 57 #define VIM_NAME "vim"
58 #define VIM_CLASS "Vim" 58 #define VIM_CLASS "Vim"
59 59
60 /* Default resource values */ 60 // Default resource values
61 #define DFLT_FONT "7x13" 61 #define DFLT_FONT "7x13"
62 #ifdef FONTSET_ALWAYS 62 #ifdef FONTSET_ALWAYS
63 # define DFLT_MENU_FONT XtDefaultFontSet 63 # define DFLT_MENU_FONT XtDefaultFontSet
64 #else 64 #else
65 # define DFLT_MENU_FONT XtDefaultFont 65 # define DFLT_MENU_FONT XtDefaultFont
72 # define DFLT_SCROLL_BG_COLOR "gray60" 72 # define DFLT_SCROLL_BG_COLOR "gray60"
73 # define DFLT_SCROLL_FG_COLOR "gray77" 73 # define DFLT_SCROLL_FG_COLOR "gray77"
74 # define DFLT_TOOLTIP_BG_COLOR "#ffff91" 74 # define DFLT_TOOLTIP_BG_COLOR "#ffff91"
75 # define DFLT_TOOLTIP_FG_COLOR "#000000" 75 # define DFLT_TOOLTIP_FG_COLOR "#000000"
76 #else 76 #else
77 /* use the default (CDE) colors */ 77 // use the default (CDE) colors
78 # define DFLT_MENU_BG_COLOR "" 78 # define DFLT_MENU_BG_COLOR ""
79 # define DFLT_MENU_FG_COLOR "" 79 # define DFLT_MENU_FG_COLOR ""
80 # define DFLT_SCROLL_BG_COLOR "" 80 # define DFLT_SCROLL_BG_COLOR ""
81 # define DFLT_SCROLL_FG_COLOR "" 81 # define DFLT_SCROLL_FG_COLOR ""
82 # define DFLT_TOOLTIP_BG_COLOR "#ffff91" 82 # define DFLT_TOOLTIP_BG_COLOR "#ffff91"
83 # define DFLT_TOOLTIP_FG_COLOR "#000000" 83 # define DFLT_TOOLTIP_FG_COLOR "#000000"
84 #endif 84 #endif
85 85
86 Widget vimShell = (Widget)0; 86 Widget vimShell = (Widget)0;
87 87
88 static Atom wm_atoms[2]; /* Window Manager Atoms */ 88 static Atom wm_atoms[2]; // Window Manager Atoms
89 #define DELETE_WINDOW_IDX 0 /* index in wm_atoms[] for WM_DELETE_WINDOW */ 89 #define DELETE_WINDOW_IDX 0 // index in wm_atoms[] for WM_DELETE_WINDOW
90 #define SAVE_YOURSELF_IDX 1 /* index in wm_atoms[] for WM_SAVE_YOURSELF */ 90 #define SAVE_YOURSELF_IDX 1 // index in wm_atoms[] for WM_SAVE_YOURSELF
91 91
92 #ifdef FEAT_XFONTSET 92 #ifdef FEAT_XFONTSET
93 /* 93 /*
94 * We either draw with a fontset (when current_fontset != NULL) or with a 94 * We either draw with a fontset (when current_fontset != NULL) or with a
95 * normal font (current_fontset == NULL, use gui.text_gc and gui.back_gc). 95 * normal font (current_fontset == NULL, use gui.text_gc and gui.back_gc).
196 196
197 {XK_F31, 'F', 'L'}, 197 {XK_F31, 'F', 'L'},
198 {XK_F32, 'F', 'M'}, 198 {XK_F32, 'F', 'M'},
199 {XK_F33, 'F', 'N'}, 199 {XK_F33, 'F', 'N'},
200 {XK_F34, 'F', 'O'}, 200 {XK_F34, 'F', 'O'},
201 {XK_F35, 'F', 'P'}, /* keysymdef.h defines up to F35 */ 201 {XK_F35, 'F', 'P'}, // keysymdef.h defines up to F35
202 #ifdef SunXK_F36 202 #ifdef SunXK_F36
203 {SunXK_F36, 'F', 'Q'}, 203 {SunXK_F36, 'F', 'Q'},
204 {SunXK_F37, 'F', 'R'}, 204 {SunXK_F37, 'F', 'R'},
205 #endif 205 #endif
206 206
213 {XK_End, '@', '7'}, 213 {XK_End, '@', '7'},
214 {XK_Prior, 'k', 'P'}, 214 {XK_Prior, 'k', 'P'},
215 {XK_Next, 'k', 'N'}, 215 {XK_Next, 'k', 'N'},
216 {XK_Print, '%', '9'}, 216 {XK_Print, '%', '9'},
217 217
218 /* Keypad keys: */ 218 // Keypad keys:
219 #ifdef XK_KP_Left 219 #ifdef XK_KP_Left
220 {XK_KP_Left, 'k', 'l'}, 220 {XK_KP_Left, 'k', 'l'},
221 {XK_KP_Right, 'k', 'r'}, 221 {XK_KP_Right, 'k', 'r'},
222 {XK_KP_Up, 'k', 'u'}, 222 {XK_KP_Up, 'k', 'u'},
223 {XK_KP_Down, 'k', 'd'}, 223 {XK_KP_Down, 'k', 'd'},
245 {XK_KP_7, 'K', 'J'}, 245 {XK_KP_7, 'K', 'J'},
246 {XK_KP_8, 'K', 'K'}, 246 {XK_KP_8, 'K', 'K'},
247 {XK_KP_9, 'K', 'L'}, 247 {XK_KP_9, 'K', 'L'},
248 #endif 248 #endif
249 249
250 /* End of list marker: */ 250 // End of list marker:
251 {(KeySym)0, 0, 0} 251 {(KeySym)0, 0, 0}
252 }; 252 };
253 253
254 #define XtNboldFont "boldFont" 254 #define XtNboldFont "boldFont"
255 #define XtCBoldFont "BoldFont" 255 #define XtCBoldFont "BoldFont"
265 #define XtCMenuFont "MenuFont" 265 #define XtCMenuFont "MenuFont"
266 #define XtNmenuFontSet "menuFontSet" 266 #define XtNmenuFontSet "menuFontSet"
267 #define XtCMenuFontSet "MenuFontSet" 267 #define XtCMenuFontSet "MenuFontSet"
268 268
269 269
270 /* Resources for setting the foreground and background colors of menus */ 270 // Resources for setting the foreground and background colors of menus
271 #define XtNmenuBackground "menuBackground" 271 #define XtNmenuBackground "menuBackground"
272 #define XtCMenuBackground "MenuBackground" 272 #define XtCMenuBackground "MenuBackground"
273 #define XtNmenuForeground "menuForeground" 273 #define XtNmenuForeground "menuForeground"
274 #define XtCMenuForeground "MenuForeground" 274 #define XtCMenuForeground "MenuForeground"
275 275
276 /* Resources for setting the foreground and background colors of scrollbars */ 276 // Resources for setting the foreground and background colors of scrollbars
277 #define XtNscrollBackground "scrollBackground" 277 #define XtNscrollBackground "scrollBackground"
278 #define XtCScrollBackground "ScrollBackground" 278 #define XtCScrollBackground "ScrollBackground"
279 #define XtNscrollForeground "scrollForeground" 279 #define XtNscrollForeground "scrollForeground"
280 #define XtCScrollForeground "ScrollForeground" 280 #define XtCScrollForeground "ScrollForeground"
281 281
282 /* Resources for setting the foreground and background colors of tooltip */ 282 // Resources for setting the foreground and background colors of tooltip
283 #define XtNtooltipBackground "tooltipBackground" 283 #define XtNtooltipBackground "tooltipBackground"
284 #define XtCTooltipBackground "TooltipBackground" 284 #define XtCTooltipBackground "TooltipBackground"
285 #define XtNtooltipForeground "tooltipForeground" 285 #define XtNtooltipForeground "tooltipForeground"
286 #define XtCTooltipForeground "TooltipForeground" 286 #define XtCTooltipForeground "TooltipForeground"
287 #define XtNtooltipFont "tooltipFont" 287 #define XtNtooltipFont "tooltipFont"
381 XtOffsetOf(gui_T, scrollbar_width), 381 XtOffsetOf(gui_T, scrollbar_width),
382 XtRImmediate, 382 XtRImmediate,
383 (XtPointer)SB_DEFAULT_WIDTH 383 (XtPointer)SB_DEFAULT_WIDTH
384 }, 384 },
385 #ifdef FEAT_MENU 385 #ifdef FEAT_MENU
386 # ifdef FEAT_GUI_ATHENA /* with Motif the height is always computed */ 386 # ifdef FEAT_GUI_ATHENA // with Motif the height is always computed
387 { 387 {
388 XtNmenuHeight, 388 XtNmenuHeight,
389 XtCMenuHeight, 389 XtCMenuHeight,
390 XtRInt, 390 XtRInt,
391 sizeof(int), 391 sizeof(int),
392 XtOffsetOf(gui_T, menu_height), 392 XtOffsetOf(gui_T, menu_height),
393 XtRImmediate, 393 XtRImmediate,
394 (XtPointer)MENU_DEFAULT_HEIGHT /* Should figure out at run time */ 394 (XtPointer)MENU_DEFAULT_HEIGHT // Should figure out at run time
395 }, 395 },
396 # endif 396 # endif
397 { 397 {
398 # ifdef FONTSET_ALWAYS 398 # ifdef FONTSET_ALWAYS
399 XtNmenuFontSet, 399 XtNmenuFontSet,
471 sizeof(char *), 471 sizeof(char *),
472 XtOffsetOf(gui_T, rsrc_tooltip_font_name), 472 XtOffsetOf(gui_T, rsrc_tooltip_font_name),
473 XtRString, 473 XtRString,
474 DFLT_TOOLTIP_FONT 474 DFLT_TOOLTIP_FONT
475 }, 475 },
476 /* This one may not be really needed? */ 476 // This one may not be really needed?
477 { 477 {
478 "balloonEvalFontSet", 478 "balloonEvalFontSet",
479 XtCFontSet, 479 XtCFontSet,
480 XtRFontSet, 480 XtRFontSet,
481 sizeof(XFontSet), 481 sizeof(XFontSet),
482 XtOffsetOf(gui_T, tooltip_fontset), 482 XtOffsetOf(gui_T, tooltip_fontset),
483 XtRImmediate, 483 XtRImmediate,
484 (XtPointer)NOFONTSET 484 (XtPointer)NOFONTSET
485 }, 485 },
486 #endif /* FEAT_BEVAL_GUI */ 486 #endif // FEAT_BEVAL_GUI
487 #ifdef FEAT_XIM 487 #ifdef FEAT_XIM
488 { 488 {
489 "preeditType", 489 "preeditType",
490 "PreeditType", 490 "PreeditType",
491 XtRString, 491 XtRString,
501 sizeof(char*), 501 sizeof(char*),
502 XtOffsetOf(gui_T, rsrc_input_method), 502 XtOffsetOf(gui_T, rsrc_input_method),
503 XtRString, 503 XtRString,
504 NULL 504 NULL
505 }, 505 },
506 #endif /* FEAT_XIM */ 506 #endif // FEAT_XIM
507 }; 507 };
508 508
509 /* 509 /*
510 * This table holds all the X GUI command line options allowed. This includes 510 * This table holds all the X GUI command line options allowed. This includes
511 * the standard ones so that we can skip them when vim is started without the 511 * the standard ones so that we can skip them when vim is started without the
512 * GUI (but the GUI might start up later). 512 * GUI (but the GUI might start up later).
513 * When changing this, also update doc/vim_gui.txt and the usage message!!! 513 * When changing this, also update doc/vim_gui.txt and the usage message!!!
514 */ 514 */
515 static XrmOptionDescRec cmdline_options[] = 515 static XrmOptionDescRec cmdline_options[] =
516 { 516 {
517 /* We handle these options ourselves */ 517 // We handle these options ourselves
518 {"-bg", ".background", XrmoptionSepArg, NULL}, 518 {"-bg", ".background", XrmoptionSepArg, NULL},
519 {"-background", ".background", XrmoptionSepArg, NULL}, 519 {"-background", ".background", XrmoptionSepArg, NULL},
520 {"-fg", ".foreground", XrmoptionSepArg, NULL}, 520 {"-fg", ".foreground", XrmoptionSepArg, NULL},
521 {"-foreground", ".foreground", XrmoptionSepArg, NULL}, 521 {"-foreground", ".foreground", XrmoptionSepArg, NULL},
522 {"-fn", ".font", XrmoptionSepArg, NULL}, 522 {"-fn", ".font", XrmoptionSepArg, NULL},
570 XtPointer client_data, 570 XtPointer client_data,
571 XtIntervalId *interval_id UNUSED) 571 XtIntervalId *interval_id UNUSED)
572 { 572 {
573 XtIntervalId *channel_timer = (XtIntervalId *)client_data; 573 XtIntervalId *channel_timer = (XtIntervalId *)client_data;
574 574
575 /* Using an event handler for a channel that may be disconnected does 575 // Using an event handler for a channel that may be disconnected does
576 * not work, it hangs. Instead poll for messages. */ 576 // not work, it hangs. Instead poll for messages.
577 channel_handle_events(TRUE); 577 channel_handle_events(TRUE);
578 parse_queued_messages(); 578 parse_queued_messages();
579 579
580 /* repeat */ 580 // repeat
581 *channel_timer = XtAppAddTimeOut(app_context, (long_u)20, 581 *channel_timer = XtAppAddTimeOut(app_context, (long_u)20,
582 channel_poll_cb, client_data); 582 channel_poll_cb, client_data);
583 } 583 }
584 #endif 584 #endif
585 585
600 * to receive an event to tell us whether it worked or not. 600 * to receive an event to tell us whether it worked or not.
601 */ 601 */
602 XSetGraphicsExposures(gui.dpy, gui.text_gc, 602 XSetGraphicsExposures(gui.dpy, gui.text_gc,
603 gui.visibility != VisibilityUnobscured); 603 gui.visibility != VisibilityUnobscured);
604 604
605 /* This is needed for when redrawing is slow. */ 605 // This is needed for when redrawing is slow.
606 gui_mch_update(); 606 gui_mch_update();
607 } 607 }
608 608
609 static void 609 static void
610 gui_x11_expose_cb( 610 gui_x11_expose_cb(
617 int new_x; 617 int new_x;
618 618
619 if (event->type != Expose) 619 if (event->type != Expose)
620 return; 620 return;
621 621
622 out_flush(); /* make sure all output has been processed */ 622 out_flush(); // make sure all output has been processed
623 623
624 gevent = (XExposeEvent *)event; 624 gevent = (XExposeEvent *)event;
625 gui_redraw(gevent->x, gevent->y, gevent->width, gevent->height); 625 gui_redraw(gevent->x, gevent->y, gevent->width, gevent->height);
626 626
627 new_x = FILL_X(0); 627 new_x = FILL_X(0);
628 628
629 /* Clear the border areas if needed */ 629 // Clear the border areas if needed
630 if (gevent->x < new_x) 630 if (gevent->x < new_x)
631 XClearArea(gui.dpy, gui.wid, 0, 0, new_x, 0, False); 631 XClearArea(gui.dpy, gui.wid, 0, 0, new_x, 0, False);
632 if (gevent->y < FILL_Y(0)) 632 if (gevent->y < FILL_Y(0))
633 XClearArea(gui.dpy, gui.wid, 0, 0, 0, FILL_Y(0), False); 633 XClearArea(gui.dpy, gui.wid, 0, 0, 0, FILL_Y(0), False);
634 if (gevent->x > FILL_X(Columns)) 634 if (gevent->x > FILL_X(Columns))
635 XClearArea(gui.dpy, gui.wid, FILL_X((int)Columns), 0, 0, 0, False); 635 XClearArea(gui.dpy, gui.wid, FILL_X((int)Columns), 0, 0, 0, False);
636 if (gevent->y > FILL_Y(Rows)) 636 if (gevent->y > FILL_Y(Rows))
637 XClearArea(gui.dpy, gui.wid, 0, FILL_Y((int)Rows), 0, 0, False); 637 XClearArea(gui.dpy, gui.wid, 0, FILL_Y((int)Rows), 0, 0, False);
638 638
639 /* This is needed for when redrawing is slow. */ 639 // This is needed for when redrawing is slow.
640 gui_mch_update(); 640 gui_mch_update();
641 } 641 }
642 642
643 #if (defined(FEAT_NETBEANS_INTG) && defined(FEAT_GUI_MOTIF)) || defined(PROTO) 643 #if (defined(FEAT_NETBEANS_INTG) && defined(FEAT_GUI_MOTIF)) || defined(PROTO)
644 /* 644 /*
781 781
782 #ifdef FEAT_XIM 782 #ifdef FEAT_XIM
783 if (xic) 783 if (xic)
784 { 784 {
785 # ifdef USE_UTF8LOOKUP 785 # ifdef USE_UTF8LOOKUP
786 /* XFree86 4.0.2 or newer: Be able to get UTF-8 characters even when 786 // XFree86 4.0.2 or newer: Be able to get UTF-8 characters even when
787 * the locale isn't utf-8. */ 787 // the locale isn't utf-8.
788 if (enc_utf8) 788 if (enc_utf8)
789 len = Xutf8LookupString(xic, ev_press, (char *)string, 789 len = Xutf8LookupString(xic, ev_press, (char *)string,
790 sizeof(string_shortbuf), &key_sym, &status); 790 sizeof(string_shortbuf), &key_sym, &status);
791 else 791 else
792 # endif 792 # endif
795 if (status == XBufferOverflow) 795 if (status == XBufferOverflow)
796 { 796 {
797 string = (char_u *)XtMalloc(len + 1); 797 string = (char_u *)XtMalloc(len + 1);
798 string_alloced = True; 798 string_alloced = True;
799 # ifdef USE_UTF8LOOKUP 799 # ifdef USE_UTF8LOOKUP
800 /* XFree86 4.0.2 or newer: Be able to get UTF-8 characters even 800 // XFree86 4.0.2 or newer: Be able to get UTF-8 characters even
801 * when the locale isn't utf-8. */ 801 // when the locale isn't utf-8.
802 if (enc_utf8) 802 if (enc_utf8)
803 len = Xutf8LookupString(xic, ev_press, (char *)string, 803 len = Xutf8LookupString(xic, ev_press, (char *)string,
804 len, &key_sym, &status); 804 len, &key_sym, &status);
805 else 805 else
806 # endif 806 # endif
808 len, &key_sym, &status); 808 len, &key_sym, &status);
809 } 809 }
810 if (status == XLookupNone || status == XLookupChars) 810 if (status == XLookupNone || status == XLookupChars)
811 key_sym = XK_VoidSymbol; 811 key_sym = XK_VoidSymbol;
812 812
813 /* Do conversion from 'termencoding' to 'encoding'. When using 813 // Do conversion from 'termencoding' to 'encoding'. When using
814 * Xutf8LookupString() it has already been done. */ 814 // Xutf8LookupString() it has already been done.
815 if (len > 0 && input_conv.vc_type != CONV_NONE 815 if (len > 0 && input_conv.vc_type != CONV_NONE
816 # ifdef USE_UTF8LOOKUP 816 # ifdef USE_UTF8LOOKUP
817 && !enc_utf8 817 && !enc_utf8
818 # endif 818 # endif
819 ) 819 )
820 { 820 {
821 int maxlen = len * 4 + 40; /* guessed */ 821 int maxlen = len * 4 + 40; // guessed
822 char_u *p = (char_u *)XtMalloc(maxlen); 822 char_u *p = (char_u *)XtMalloc(maxlen);
823 823
824 mch_memmove(p, string, len); 824 mch_memmove(p, string, len);
825 if (string_alloced) 825 if (string_alloced)
826 XtFree((char *)string); 826 XtFree((char *)string);
827 string = p; 827 string = p;
828 string_alloced = True; 828 string_alloced = True;
829 len = convert_input(p, len, maxlen); 829 len = convert_input(p, len, maxlen);
830 } 830 }
831 831
832 /* Translate CSI to K_CSI, otherwise it could be recognized as the 832 // Translate CSI to K_CSI, otherwise it could be recognized as the
833 * start of a special key. */ 833 // start of a special key.
834 for (i = 0; i < len; ++i) 834 for (i = 0; i < len; ++i)
835 if (string[i] == CSI) 835 if (string[i] == CSI)
836 { 836 {
837 char_u *p = (char_u *)XtMalloc(len + 3); 837 char_u *p = (char_u *)XtMalloc(len + 3);
838 838
862 if (key_sym == SunXK_F36 || key_sym == SunXK_F37) 862 if (key_sym == SunXK_F36 || key_sym == SunXK_F37)
863 len = 0; 863 len = 0;
864 #endif 864 #endif
865 865
866 if (key_sym == XK_space) 866 if (key_sym == XK_space)
867 string[0] = ' '; /* Otherwise Ctrl-Space doesn't work */ 867 string[0] = ' '; // Otherwise Ctrl-Space doesn't work
868 868
869 /* 869 /*
870 * Only on some machines ^_ requires Ctrl+Shift+minus. For consistency, 870 * Only on some machines ^_ requires Ctrl+Shift+minus. For consistency,
871 * allow just Ctrl+minus too. 871 * allow just Ctrl+minus too.
872 */ 872 */
873 if (key_sym == XK_minus && (ev_press->state & ControlMask)) 873 if (key_sym == XK_minus && (ev_press->state & ControlMask))
874 string[0] = Ctrl__; 874 string[0] = Ctrl__;
875 875
876 #ifdef XK_ISO_Left_Tab 876 #ifdef XK_ISO_Left_Tab
877 /* why do we get XK_ISO_Left_Tab instead of XK_Tab for shift-tab? */ 877 // why do we get XK_ISO_Left_Tab instead of XK_Tab for shift-tab?
878 if (key_sym == XK_ISO_Left_Tab) 878 if (key_sym == XK_ISO_Left_Tab)
879 { 879 {
880 key_sym = XK_Tab; 880 key_sym = XK_Tab;
881 string[0] = TAB; 881 string[0] = TAB;
882 len = 1; 882 len = 1;
883 } 883 }
884 #endif 884 #endif
885 885
886 /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character 886 // Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character
887 * that already has the 8th bit set. And not when using a double-byte 887 // that already has the 8th bit set. And not when using a double-byte
888 * encoding, setting the 8th bit may make it the lead byte of a 888 // encoding, setting the 8th bit may make it the lead byte of a
889 * double-byte character. */ 889 // double-byte character.
890 if (len == 1 890 if (len == 1
891 && (ev_press->state & Mod1Mask) 891 && (ev_press->state & Mod1Mask)
892 && !(key_sym == XK_BackSpace || key_sym == XK_Delete) 892 && !(key_sym == XK_BackSpace || key_sym == XK_Delete)
893 && (string[0] & 0x80) == 0 893 && (string[0] & 0x80) == 0
894 && !enc_dbcs) 894 && !enc_dbcs)
895 { 895 {
896 #if defined(FEAT_MENU) && defined(FEAT_GUI_MOTIF) 896 #if defined(FEAT_MENU) && defined(FEAT_GUI_MOTIF)
897 /* Ignore ALT keys when they are used for the menu only */ 897 // Ignore ALT keys when they are used for the menu only
898 if (gui.menu_is_active 898 if (gui.menu_is_active
899 && (p_wak[0] == 'y' 899 && (p_wak[0] == 'y'
900 || (p_wak[0] == 'm' && gui_is_menu_shortcut(string[0])))) 900 || (p_wak[0] == 'm' && gui_is_menu_shortcut(string[0]))))
901 goto theend; 901 goto theend;
902 #endif 902 #endif
909 */ 909 */
910 ev_press->state &= ~Mod1Mask; 910 ev_press->state &= ~Mod1Mask;
911 len2 = XLookupString(ev_press, (char *)string2, sizeof(string2), 911 len2 = XLookupString(ev_press, (char *)string2, sizeof(string2),
912 &key_sym2, NULL); 912 &key_sym2, NULL);
913 if (key_sym2 == XK_space) 913 if (key_sym2 == XK_space)
914 string2[0] = ' '; /* Otherwise Meta-Ctrl-Space doesn't work */ 914 string2[0] = ' '; // Otherwise Meta-Ctrl-Space doesn't work
915 if ( len2 == 1 915 if ( len2 == 1
916 && string[0] == string2[0] 916 && string[0] == string2[0]
917 && !(key_sym == XK_Tab && (ev_press->state & ShiftMask))) 917 && !(key_sym == XK_Tab && (ev_press->state & ShiftMask)))
918 { 918 {
919 string[0] |= 0x80; 919 string[0] |= 0x80;
920 if (enc_utf8) /* convert to utf-8 */ 920 if (enc_utf8) // convert to utf-8
921 { 921 {
922 string[1] = string[0] & 0xbf; 922 string[1] = string[0] & 0xbf;
923 string[0] = ((unsigned)string[0] >> 6) + 0xc0; 923 string[0] = ((unsigned)string[0] >> 6) + 0xc0;
924 if (string[1] == CSI) 924 if (string[1] == CSI)
925 { 925 {
940 string[1] = KS_EXTRA; 940 string[1] = KS_EXTRA;
941 string[2] = (int)KE_CSI; 941 string[2] = (int)KE_CSI;
942 len = -3; 942 len = -3;
943 } 943 }
944 944
945 /* Check for special keys. Also do this when len == 1 (key has an ASCII 945 // Check for special keys. Also do this when len == 1 (key has an ASCII
946 * value) to detect backspace, delete and keypad keys. */ 946 // value) to detect backspace, delete and keypad keys.
947 if (len == 0 || len == 1) 947 if (len == 0 || len == 1)
948 { 948 {
949 for (i = 0; special_keys[i].key_sym != (KeySym)0; i++) 949 for (i = 0; special_keys[i].key_sym != (KeySym)0; i++)
950 { 950 {
951 if (special_keys[i].key_sym == key_sym) 951 if (special_keys[i].key_sym == key_sym)
957 break; 957 break;
958 } 958 }
959 } 959 }
960 } 960 }
961 961
962 /* Unrecognised key is ignored. */ 962 // Unrecognised key is ignored.
963 if (len == 0) 963 if (len == 0)
964 goto theend; 964 goto theend;
965 965
966 /* Special keys (and a few others) may have modifiers. Also when using a 966 // Special keys (and a few others) may have modifiers. Also when using a
967 * double-byte encoding (can't set the 8th bit). */ 967 // double-byte encoding (can't set the 8th bit).
968 if (len == -3 || key_sym == XK_space || key_sym == XK_Tab 968 if (len == -3 || key_sym == XK_space || key_sym == XK_Tab
969 || key_sym == XK_Return || key_sym == XK_Linefeed 969 || key_sym == XK_Return || key_sym == XK_Linefeed
970 || key_sym == XK_Escape 970 || key_sym == XK_Escape
971 || (enc_dbcs && len == 1 && (ev_press->state & Mod1Mask))) 971 || (enc_dbcs && len == 1 && (ev_press->state & Mod1Mask)))
972 { 972 {
1038 if ((be = gui_mch_currently_showing_beval()) != NULL) 1038 if ((be = gui_mch_currently_showing_beval()) != NULL)
1039 gui_mch_unpost_balloon(be); 1039 gui_mch_unpost_balloon(be);
1040 } 1040 }
1041 #endif 1041 #endif
1042 theend: 1042 theend:
1043 {} /* some compilers need a statement here */ 1043 {} // some compilers need a statement here
1044 #ifdef FEAT_XIM 1044 #ifdef FEAT_XIM
1045 if (string_alloced) 1045 if (string_alloced)
1046 XtFree((char *)string); 1046 XtFree((char *)string);
1047 #endif 1047 #endif
1048 } 1048 }
1063 int_u x_modifiers; 1063 int_u x_modifiers;
1064 int_u vim_modifiers; 1064 int_u vim_modifiers;
1065 1065
1066 if (event->type == MotionNotify) 1066 if (event->type == MotionNotify)
1067 { 1067 {
1068 /* Get the latest position, avoids lagging behind on a drag. */ 1068 // Get the latest position, avoids lagging behind on a drag.
1069 x = event->xmotion.x; 1069 x = event->xmotion.x;
1070 y = event->xmotion.y; 1070 y = event->xmotion.y;
1071 x_modifiers = event->xmotion.state; 1071 x_modifiers = event->xmotion.state;
1072 button = (x_modifiers & (Button1Mask | Button2Mask | Button3Mask)) 1072 button = (x_modifiers & (Button1Mask | Button2Mask | Button3Mask))
1073 ? MOUSE_DRAG : ' '; 1073 ? MOUSE_DRAG : ' ';
1075 /* 1075 /*
1076 * if our pointer is currently hidden, then we should show it. 1076 * if our pointer is currently hidden, then we should show it.
1077 */ 1077 */
1078 gui_mch_mousehide(FALSE); 1078 gui_mch_mousehide(FALSE);
1079 1079
1080 if (button != MOUSE_DRAG) /* just moving the rodent */ 1080 if (button != MOUSE_DRAG) // just moving the rodent
1081 { 1081 {
1082 #ifdef FEAT_MENU 1082 #ifdef FEAT_MENU
1083 if (dud) /* moved in vimForm */ 1083 if (dud) // moved in vimForm
1084 y -= gui.menu_height; 1084 y -= gui.menu_height;
1085 #endif 1085 #endif
1086 gui_mouse_moved(x, y); 1086 gui_mouse_moved(x, y);
1087 return; 1087 return;
1088 } 1088 }
1091 { 1091 {
1092 x = event->xbutton.x; 1092 x = event->xbutton.x;
1093 y = event->xbutton.y; 1093 y = event->xbutton.y;
1094 if (event->type == ButtonPress) 1094 if (event->type == ButtonPress)
1095 { 1095 {
1096 /* Handle multiple clicks */ 1096 // Handle multiple clicks
1097 if (!timed_out) 1097 if (!timed_out)
1098 { 1098 {
1099 XtRemoveTimeOut(timer); 1099 XtRemoveTimeOut(timer);
1100 repeated_click = TRUE; 1100 repeated_click = TRUE;
1101 } 1101 }
1102 timed_out = FALSE; 1102 timed_out = FALSE;
1103 timer = XtAppAddTimeOut(app_context, (long_u)p_mouset, 1103 timer = XtAppAddTimeOut(app_context, (long_u)p_mouset,
1104 gui_x11_timer_cb, &timed_out); 1104 gui_x11_timer_cb, &timed_out);
1105 switch (event->xbutton.button) 1105 switch (event->xbutton.button)
1106 { 1106 {
1107 /* keep in sync with gui_gtk_x11.c */ 1107 // keep in sync with gui_gtk_x11.c
1108 case Button1: button = MOUSE_LEFT; break; 1108 case Button1: button = MOUSE_LEFT; break;
1109 case Button2: button = MOUSE_MIDDLE; break; 1109 case Button2: button = MOUSE_MIDDLE; break;
1110 case Button3: button = MOUSE_RIGHT; break; 1110 case Button3: button = MOUSE_RIGHT; break;
1111 case Button4: button = MOUSE_4; break; 1111 case Button4: button = MOUSE_4; break;
1112 case Button5: button = MOUSE_5; break; 1112 case Button5: button = MOUSE_5; break;
1113 case 6: button = MOUSE_7; break; 1113 case 6: button = MOUSE_7; break;
1114 case 7: button = MOUSE_6; break; 1114 case 7: button = MOUSE_6; break;
1115 case 8: button = MOUSE_X1; break; 1115 case 8: button = MOUSE_X1; break;
1116 case 9: button = MOUSE_X2; break; 1116 case 9: button = MOUSE_X2; break;
1117 default: 1117 default:
1118 return; /* Unknown button */ 1118 return; // Unknown button
1119 } 1119 }
1120 } 1120 }
1121 else if (event->type == ButtonRelease) 1121 else if (event->type == ButtonRelease)
1122 button = MOUSE_RELEASE; 1122 button = MOUSE_RELEASE;
1123 else 1123 else
1124 return; /* Unknown mouse event type */ 1124 return; // Unknown mouse event type
1125 1125
1126 x_modifiers = event->xbutton.state; 1126 x_modifiers = event->xbutton.state;
1127 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) 1127 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
1128 last_mouse_event = event->xbutton; 1128 last_mouse_event = event->xbutton;
1129 #endif 1129 #endif
1132 vim_modifiers = 0x0; 1132 vim_modifiers = 0x0;
1133 if (x_modifiers & ShiftMask) 1133 if (x_modifiers & ShiftMask)
1134 vim_modifiers |= MOUSE_SHIFT; 1134 vim_modifiers |= MOUSE_SHIFT;
1135 if (x_modifiers & ControlMask) 1135 if (x_modifiers & ControlMask)
1136 vim_modifiers |= MOUSE_CTRL; 1136 vim_modifiers |= MOUSE_CTRL;
1137 if (x_modifiers & Mod1Mask) /* Alt or Meta key */ 1137 if (x_modifiers & Mod1Mask) // Alt or Meta key
1138 vim_modifiers |= MOUSE_ALT; 1138 vim_modifiers |= MOUSE_ALT;
1139 1139
1140 gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers); 1140 gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers);
1141 } 1141 }
1142 1142
1164 return; 1164 return;
1165 gui_argv[gui_argc++] = argv[0]; 1165 gui_argv[gui_argc++] = argv[0];
1166 arg = 1; 1166 arg = 1;
1167 while (arg < *argc) 1167 while (arg < *argc)
1168 { 1168 {
1169 /* Look for argv[arg] in cmdline_options[] table */ 1169 // Look for argv[arg] in cmdline_options[] table
1170 for (i = 0; i < (int)XtNumber(cmdline_options); i++) 1170 for (i = 0; i < (int)XtNumber(cmdline_options); i++)
1171 if (strcmp(argv[arg], cmdline_options[i].option) == 0) 1171 if (strcmp(argv[arg], cmdline_options[i].option) == 0)
1172 break; 1172 break;
1173 1173
1174 if (i < (int)XtNumber(cmdline_options)) 1174 if (i < (int)XtNumber(cmdline_options))
1175 { 1175 {
1176 /* Remember finding "-rv" or "-reverse" */ 1176 // Remember finding "-rv" or "-reverse"
1177 if (strcmp("-rv", argv[arg]) == 0 1177 if (strcmp("-rv", argv[arg]) == 0
1178 || strcmp("-reverse", argv[arg]) == 0) 1178 || strcmp("-reverse", argv[arg]) == 0)
1179 found_reverse_arg = TRUE; 1179 found_reverse_arg = TRUE;
1180 else if ((strcmp("-fn", argv[arg]) == 0 1180 else if ((strcmp("-fn", argv[arg]) == 0
1181 || strcmp("-font", argv[arg]) == 0) 1181 || strcmp("-font", argv[arg]) == 0)
1182 && arg + 1 < *argc) 1182 && arg + 1 < *argc)
1183 font_argument = argv[arg + 1]; 1183 font_argument = argv[arg + 1];
1184 1184
1185 /* Found match in table, so move it into gui_argv */ 1185 // Found match in table, so move it into gui_argv
1186 gui_argv[gui_argc++] = argv[arg]; 1186 gui_argv[gui_argc++] = argv[arg];
1187 if (--*argc > arg) 1187 if (--*argc > arg)
1188 { 1188 {
1189 mch_memmove(&argv[arg], &argv[arg + 1], (*argc - arg) 1189 mch_memmove(&argv[arg], &argv[arg + 1], (*argc - arg)
1190 * sizeof(char *)); 1190 * sizeof(char *));
1191 if (cmdline_options[i].argKind != XrmoptionNoArg) 1191 if (cmdline_options[i].argKind != XrmoptionNoArg)
1192 { 1192 {
1193 /* Move the options argument as well */ 1193 // Move the options argument as well
1194 gui_argv[gui_argc++] = argv[arg]; 1194 gui_argv[gui_argc++] = argv[arg];
1195 if (--*argc > arg) 1195 if (--*argc > arg)
1196 mch_memmove(&argv[arg], &argv[arg + 1], (*argc - arg) 1196 mch_memmove(&argv[arg], &argv[arg + 1], (*argc - arg)
1197 * sizeof(char *)); 1197 * sizeof(char *));
1198 } 1198 }
1201 } 1201 }
1202 else 1202 else
1203 #ifdef FEAT_NETBEANS_INTG 1203 #ifdef FEAT_NETBEANS_INTG
1204 if (strncmp("-nb", argv[arg], 3) == 0) 1204 if (strncmp("-nb", argv[arg], 3) == 0)
1205 { 1205 {
1206 gui.dofork = FALSE; /* don't fork() when starting GUI */ 1206 gui.dofork = FALSE; // don't fork() when starting GUI
1207 netbeansArg = argv[arg]; 1207 netbeansArg = argv[arg];
1208 mch_memmove(&argv[arg], &argv[arg + 1], 1208 mch_memmove(&argv[arg], &argv[arg + 1],
1209 (--*argc - arg) * sizeof(char *)); 1209 (--*argc - arg) * sizeof(char *));
1210 argv[*argc] = NULL; 1210 argv[*argc] = NULL;
1211 } 1211 }
1241 cmdline_options, XtNumber(cmdline_options), 1241 cmdline_options, XtNumber(cmdline_options),
1242 CARDINAL &gui_argc, gui_argv); 1242 CARDINAL &gui_argc, gui_argv);
1243 1243
1244 # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) 1244 # if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
1245 { 1245 {
1246 /* The call to XtOpenDisplay() may have set the locale from the 1246 // The call to XtOpenDisplay() may have set the locale from the
1247 * environment. Set LC_NUMERIC to "C" to make sure that strtod() uses a 1247 // environment. Set LC_NUMERIC to "C" to make sure that strtod() uses a
1248 * decimal point, not a comma. */ 1248 // decimal point, not a comma.
1249 char *p = setlocale(LC_NUMERIC, NULL); 1249 char *p = setlocale(LC_NUMERIC, NULL);
1250 1250
1251 if (p == NULL || strcmp(p, "C") != 0) 1251 if (p == NULL || strcmp(p, "C") != 0)
1252 setlocale(LC_NUMERIC, "C"); 1252 setlocale(LC_NUMERIC, "C");
1253 } 1253 }
1291 XGCValues gc_vals; 1291 XGCValues gc_vals;
1292 int x, y, mask; 1292 int x, y, mask;
1293 unsigned w, h; 1293 unsigned w, h;
1294 1294
1295 #if 0 1295 #if 0
1296 /* Uncomment this to enable synchronous mode for debugging */ 1296 // Uncomment this to enable synchronous mode for debugging
1297 XSynchronize(gui.dpy, True); 1297 XSynchronize(gui.dpy, True);
1298 #endif 1298 #endif
1299 1299
1300 vimShell = XtVaAppCreateShell(VIM_NAME, VIM_CLASS, 1300 vimShell = XtVaAppCreateShell(VIM_NAME, VIM_CLASS,
1301 applicationShellWidgetClass, gui.dpy, NULL); 1301 applicationShellWidgetClass, gui.dpy, NULL);
1310 1310
1311 /* 1311 /*
1312 * Get the colors ourselves. Using the automatic conversion doesn't 1312 * Get the colors ourselves. Using the automatic conversion doesn't
1313 * handle looking for approximate colors. 1313 * handle looking for approximate colors.
1314 */ 1314 */
1315 /* NOTE: These next few lines are an exact duplicate of gui_athena.c's 1315 // NOTE: These next few lines are an exact duplicate of gui_athena.c's
1316 * gui_mch_def_colors(). Why? 1316 // gui_mch_def_colors(). Why?
1317 */
1318 gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name); 1317 gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name);
1319 gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name); 1318 gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name);
1320 gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name); 1319 gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name);
1321 gui.scroll_bg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_bg_name); 1320 gui.scroll_bg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_bg_name);
1322 #ifdef FEAT_BEVAL_GUI 1321 #ifdef FEAT_BEVAL_GUI
1323 gui.tooltip_fg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_fg_name); 1322 gui.tooltip_fg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_fg_name);
1324 gui.tooltip_bg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_bg_name); 1323 gui.tooltip_bg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_bg_name);
1325 #endif 1324 #endif
1326 1325
1327 #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA) 1326 #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA)
1328 /* If the menu height was set, don't change it at runtime */ 1327 // If the menu height was set, don't change it at runtime
1329 if (gui.menu_height != MENU_DEFAULT_HEIGHT) 1328 if (gui.menu_height != MENU_DEFAULT_HEIGHT)
1330 gui.menu_height_fixed = TRUE; 1329 gui.menu_height_fixed = TRUE;
1331 #endif 1330 #endif
1332 1331
1333 /* Set default foreground and background colours */ 1332 // Set default foreground and background colours
1334 gui.norm_pixel = gui.def_norm_pixel; 1333 gui.norm_pixel = gui.def_norm_pixel;
1335 gui.back_pixel = gui.def_back_pixel; 1334 gui.back_pixel = gui.def_back_pixel;
1336 1335
1337 /* Check if reverse video needs to be applied (on Sun it's done by X) */ 1336 // Check if reverse video needs to be applied (on Sun it's done by X)
1338 if (gui.rsrc_rev_video && gui_get_lightness(gui.back_pixel) 1337 if (gui.rsrc_rev_video && gui_get_lightness(gui.back_pixel)
1339 > gui_get_lightness(gui.norm_pixel)) 1338 > gui_get_lightness(gui.norm_pixel))
1340 { 1339 {
1341 gui.norm_pixel = gui.def_back_pixel; 1340 gui.norm_pixel = gui.def_back_pixel;
1342 gui.back_pixel = gui.def_norm_pixel; 1341 gui.back_pixel = gui.def_norm_pixel;
1343 gui.def_norm_pixel = gui.norm_pixel; 1342 gui.def_norm_pixel = gui.norm_pixel;
1344 gui.def_back_pixel = gui.back_pixel; 1343 gui.def_back_pixel = gui.back_pixel;
1345 } 1344 }
1346 1345
1347 /* Get the colors from the "Normal", "Tooltip", "Scrollbar" and "Menu" 1346 // Get the colors from the "Normal", "Tooltip", "Scrollbar" and "Menu"
1348 * group (set in syntax.c or in a vimrc file) */ 1347 // group (set in syntax.c or in a vimrc file)
1349 set_normal_colors(); 1348 set_normal_colors();
1350 1349
1351 /* 1350 /*
1352 * Check that none of the colors are the same as the background color 1351 * Check that none of the colors are the same as the background color
1353 */ 1352 */
1375 x11_setup_atoms(gui.dpy); 1374 x11_setup_atoms(gui.dpy);
1376 1375
1377 if (gui_win_x != -1 && gui_win_y != -1) 1376 if (gui_win_x != -1 && gui_win_y != -1)
1378 gui_mch_set_winpos(gui_win_x, gui_win_y); 1377 gui_mch_set_winpos(gui_win_x, gui_win_y);
1379 1378
1380 /* Now adapt the supplied(?) geometry-settings */ 1379 // Now adapt the supplied(?) geometry-settings
1381 /* Added by Kjetil Jacobsen <kjetilja@stud.cs.uit.no> */ 1380 // Added by Kjetil Jacobsen <kjetilja@stud.cs.uit.no>
1382 if (gui.geom != NULL && *gui.geom != NUL) 1381 if (gui.geom != NULL && *gui.geom != NUL)
1383 { 1382 {
1384 mask = XParseGeometry((char *)gui.geom, &x, &y, &w, &h); 1383 mask = XParseGeometry((char *)gui.geom, &x, &y, &w, &h);
1385 if (mask & WidthValue) 1384 if (mask & WidthValue)
1386 Columns = w; 1385 Columns = w;
1425 (char *)vim_mask_icon_bits, 1424 (char *)vim_mask_icon_bits,
1426 vim_mask_icon_width, 1425 vim_mask_icon_width,
1427 vim_mask_icon_height)); 1426 vim_mask_icon_height));
1428 XtSetValues(vimShell, arg, (Cardinal)2); 1427 XtSetValues(vimShell, arg, (Cardinal)2);
1429 #else 1428 #else
1430 /* Use Pixmaps, looking much nicer. */ 1429 // Use Pixmaps, looking much nicer.
1431 1430
1432 /* If you get an error message here, you still need to unpack the runtime 1431 // If you get an error message here, you still need to unpack the runtime
1433 * archive! */ 1432 // archive!
1434 # ifdef magick 1433 # ifdef magick
1435 # undef magick 1434 # undef magick
1436 # endif 1435 # endif
1437 # define magick vim32x32 1436 # define magick vim32x32
1438 # include "../runtime/vim32x32.xpm" 1437 # include "../runtime/vim32x32.xpm"
1479 cmap = DefaultColormap(dsp, DefaultScreen(dsp)); 1478 cmap = DefaultColormap(dsp, DefaultScreen(dsp));
1480 XtVaSetValues(vimShell, XtNcolormap, cmap, NULL); 1479 XtVaSetValues(vimShell, XtNcolormap, cmap, NULL);
1481 1480
1482 attr.valuemask = 0L; 1481 attr.valuemask = 0L;
1483 attr.valuemask = XpmCloseness | XpmReturnPixels | XpmColormap | XpmDepth; 1482 attr.valuemask = XpmCloseness | XpmReturnPixels | XpmColormap | XpmDepth;
1484 attr.closeness = 65535; /* accuracy isn't crucial */ 1483 attr.closeness = 65535; // accuracy isn't crucial
1485 attr.colormap = cmap; 1484 attr.colormap = cmap;
1486 attr.depth = DefaultDepthOfScreen(scr); 1485 attr.depth = DefaultDepthOfScreen(scr);
1487 1486
1488 if (!icon) 1487 if (!icon)
1489 { 1488 {
1509 #ifdef FEAT_MENU 1508 #ifdef FEAT_MENU
1510 gui_init_menu_font(); 1509 gui_init_menu_font();
1511 #endif 1510 #endif
1512 1511
1513 #ifdef USE_XSMP 1512 #ifdef USE_XSMP
1514 /* Attach listener on ICE connection */ 1513 // Attach listener on ICE connection
1515 if (-1 != xsmp_icefd) 1514 if (-1 != xsmp_icefd)
1516 _xsmp_xtinputid = XtAppAddInput(app_context, xsmp_icefd, 1515 _xsmp_xtinputid = XtAppAddInput(app_context, xsmp_icefd,
1517 (XtPointer)XtInputReadMask, local_xsmp_handle_requests, NULL); 1516 (XtPointer)XtInputReadMask, local_xsmp_handle_requests, NULL);
1518 #endif 1517 #endif
1519 1518
1567 * Open the GUI window which was created by a call to gui_mch_init(). 1566 * Open the GUI window which was created by a call to gui_mch_init().
1568 */ 1567 */
1569 int 1568 int
1570 gui_mch_open(void) 1569 gui_mch_open(void)
1571 { 1570 {
1572 /* Actually open the window */ 1571 // Actually open the window
1573 XtRealizeWidget(vimShell); 1572 XtRealizeWidget(vimShell);
1574 XtManageChild(XtNameToWidget(vimShell, "*vimForm")); 1573 XtManageChild(XtNameToWidget(vimShell, "*vimForm"));
1575 1574
1576 gui.wid = gui_x11_get_wid(); 1575 gui.wid = gui_x11_get_wid();
1577 gui.blank_pointer = gui_x11_create_blank_mouse(); 1576 gui.blank_pointer = gui_x11_create_blank_mouse();
1597 #endif 1596 #endif
1598 1597
1599 #ifdef FEAT_CLIENTSERVER 1598 #ifdef FEAT_CLIENTSERVER
1600 if (serverName == NULL && serverDelayedStartName != NULL) 1599 if (serverName == NULL && serverDelayedStartName != NULL)
1601 { 1600 {
1602 /* This is a :gui command in a plain vim with no previous server */ 1601 // This is a :gui command in a plain vim with no previous server
1603 commWindow = XtWindow(vimShell); 1602 commWindow = XtWindow(vimShell);
1604 (void)serverRegisterName(gui.dpy, serverDelayedStartName); 1603 (void)serverRegisterName(gui.dpy, serverDelayedStartName);
1605 } 1604 }
1606 else 1605 else
1607 { 1606 {
1616 gui_x11_send_event_handler, NULL); 1615 gui_x11_send_event_handler, NULL);
1617 #endif 1616 #endif
1618 1617
1619 1618
1620 #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA) 1619 #if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA)
1621 /* The Athena GUI needs this again after opening the window */ 1620 // The Athena GUI needs this again after opening the window
1622 gui_position_menu(); 1621 gui_position_menu();
1623 # ifdef FEAT_TOOLBAR 1622 # ifdef FEAT_TOOLBAR
1624 gui_mch_set_toolbar_pos(0, gui.menu_height, gui.menu_width, 1623 gui_mch_set_toolbar_pos(0, gui.menu_height, gui.menu_width,
1625 gui.toolbar_height); 1624 gui.toolbar_height);
1626 # endif 1625 # endif
1627 #endif 1626 #endif
1628 1627
1629 /* Get the colors for the highlight groups (gui_check_colors() might have 1628 // Get the colors for the highlight groups (gui_check_colors() might have
1630 * changed them) */ 1629 // changed them)
1631 highlight_gui_started(); /* re-init colors and fonts */ 1630 highlight_gui_started(); // re-init colors and fonts
1632 1631
1633 #ifdef FEAT_XIM 1632 #ifdef FEAT_XIM
1634 xim_init(); 1633 xim_init();
1635 #endif 1634 #endif
1636 1635
1651 to.addr = (XtPointer)&gui.tooltip_fontset; 1650 to.addr = (XtPointer)&gui.tooltip_fontset;
1652 to.size = sizeof(XFontSet); 1651 to.size = sizeof(XFontSet);
1653 1652
1654 if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontSet, &to) == False) 1653 if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontSet, &to) == False)
1655 { 1654 {
1656 /* Failed. What to do? */ 1655 // Failed. What to do?
1657 } 1656 }
1658 } 1657 }
1659 #endif 1658 #endif
1660 1659
1661 #if defined(FEAT_MENU) || defined(PROTO) 1660 #if defined(FEAT_MENU) || defined(PROTO)
1662 /* Convert the menu font/fontset name to an XFontStruct/XFontset */ 1661 // Convert the menu font/fontset name to an XFontStruct/XFontset
1663 void 1662 void
1664 gui_init_menu_font(void) 1663 gui_init_menu_font(void)
1665 { 1664 {
1666 XrmValue from, to; 1665 XrmValue from, to;
1667 1666
1671 to.addr = (XtPointer)&gui.menu_fontset; 1670 to.addr = (XtPointer)&gui.menu_fontset;
1672 to.size = sizeof(GuiFontset); 1671 to.size = sizeof(GuiFontset);
1673 1672
1674 if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontSet, &to) == False) 1673 if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontSet, &to) == False)
1675 { 1674 {
1676 /* Failed. What to do? */ 1675 // Failed. What to do?
1677 } 1676 }
1678 #else 1677 #else
1679 from.addr = (char *)gui.rsrc_menu_font_name; 1678 from.addr = (char *)gui.rsrc_menu_font_name;
1680 from.size = strlen(from.addr); 1679 from.size = strlen(from.addr);
1681 to.addr = (XtPointer)&gui.menu_font; 1680 to.addr = (XtPointer)&gui.menu_font;
1682 to.size = sizeof(GuiFont); 1681 to.size = sizeof(GuiFont);
1683 1682
1684 if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontStruct, &to) == False) 1683 if (XtConvertAndStore(vimShell, XtRString, &from, XtRFontStruct, &to) == False)
1685 { 1684 {
1686 /* Failed. What to do? */ 1685 // Failed. What to do?
1687 } 1686 }
1688 #endif 1687 #endif
1689 } 1688 }
1690 #endif 1689 #endif
1691 1690
1692 void 1691 void
1693 gui_mch_exit(int rc UNUSED) 1692 gui_mch_exit(int rc UNUSED)
1694 { 1693 {
1695 #if 0 1694 #if 0
1696 /* Lesstif gives an error message here, and so does Solaris. The man page 1695 // Lesstif gives an error message here, and so does Solaris. The man page
1697 * says that this isn't needed when exiting, so just skip it. */ 1696 // says that this isn't needed when exiting, so just skip it.
1698 XtCloseDisplay(gui.dpy); 1697 XtCloseDisplay(gui.dpy);
1699 #endif 1698 #endif
1700 VIM_CLEAR(gui_argv); 1699 VIM_CLEAR(gui_argv);
1701 } 1700 }
1702 1701
1786 #ifdef FEAT_XFONTSET 1785 #ifdef FEAT_XFONTSET
1787 XFontSet fontset = NULL; 1786 XFontSet fontset = NULL;
1788 #endif 1787 #endif
1789 1788
1790 #ifdef FEAT_GUI_MOTIF 1789 #ifdef FEAT_GUI_MOTIF
1791 /* A font name equal "*" is indicating, that we should activate the font 1790 // A font name equal "*" is indicating, that we should activate the font
1792 * selection dialogue to get a new font name. So let us do it here. */ 1791 // selection dialogue to get a new font name. So let us do it here.
1793 if (font_name != NULL && STRCMP(font_name, "*") == 0) 1792 if (font_name != NULL && STRCMP(font_name, "*") == 0)
1794 font_name = gui_xm_select_font(hl_get_font_name()); 1793 font_name = gui_xm_select_font(hl_get_font_name());
1795 #endif 1794 #endif
1796 1795
1797 #ifdef FEAT_XFONTSET 1796 #ifdef FEAT_XFONTSET
1798 if (do_fontset) 1797 if (do_fontset)
1799 { 1798 {
1800 /* If 'guifontset' is set, VIM treats all font specifications as if 1799 // If 'guifontset' is set, VIM treats all font specifications as if
1801 * they were fontsets, and 'guifontset' becomes the default. */ 1800 // they were fontsets, and 'guifontset' becomes the default.
1802 if (font_name != NULL) 1801 if (font_name != NULL)
1803 { 1802 {
1804 fontset = (XFontSet)gui_mch_get_fontset(font_name, FALSE, TRUE); 1803 fontset = (XFontSet)gui_mch_get_fontset(font_name, FALSE, TRUE);
1805 if (fontset == NULL) 1804 if (fontset == NULL)
1806 return FAIL; 1805 return FAIL;
1874 gui.boldital_font = gui_mch_get_font(gui.rsrc_boldital_font_name, 1873 gui.boldital_font = gui_mch_get_font(gui.rsrc_boldital_font_name,
1875 FALSE); 1874 FALSE);
1876 } 1875 }
1877 else 1876 else
1878 { 1877 {
1879 /* When not using the font specified by the resources, also don't use 1878 // When not using the font specified by the resources, also don't use
1880 * the bold/italic fonts, otherwise setting 'guifont' will look very 1879 // the bold/italic fonts, otherwise setting 'guifont' will look very
1881 * strange. */ 1880 // strange.
1882 if (gui.bold_font != NOFONT) 1881 if (gui.bold_font != NOFONT)
1883 { 1882 {
1884 XFreeFont(gui.dpy, (XFontStruct *)gui.bold_font); 1883 XFreeFont(gui.dpy, (XFontStruct *)gui.bold_font);
1885 gui.bold_font = NOFONT; 1884 gui.bold_font = NOFONT;
1886 } 1885 }
1909 GuiFont 1908 GuiFont
1910 gui_mch_get_font(char_u *name, int giveErrorIfMissing) 1909 gui_mch_get_font(char_u *name, int giveErrorIfMissing)
1911 { 1910 {
1912 XFontStruct *font; 1911 XFontStruct *font;
1913 1912
1914 if (!gui.in_use || name == NULL) /* can't do this when GUI not running */ 1913 if (!gui.in_use || name == NULL) // can't do this when GUI not running
1915 return NOFONT; 1914 return NOFONT;
1916 1915
1917 font = XLoadQueryFont(gui.dpy, (char *)name); 1916 font = XLoadQueryFont(gui.dpy, (char *)name);
1918 1917
1919 if (font == NULL) 1918 if (font == NULL)
1959 { 1958 {
1960 char_u *ret = NULL; 1959 char_u *ret = NULL;
1961 1960
1962 if (name != NULL && font == NULL) 1961 if (name != NULL && font == NULL)
1963 { 1962 {
1964 /* In this case, there's no way other than doing this. */ 1963 // In this case, there's no way other than doing this.
1965 ret = vim_strsave(name); 1964 ret = vim_strsave(name);
1966 } 1965 }
1967 else if (font != NULL) 1966 else if (font != NULL)
1968 { 1967 {
1969 /* In this case, try to retrieve the XLFD corresponding to 'font'->fid; 1968 // In this case, try to retrieve the XLFD corresponding to 'font'->fid;
1970 * if failed, use 'name' unless it's NULL. */ 1969 // if failed, use 'name' unless it's NULL.
1971 unsigned long value = 0L; 1970 unsigned long value = 0L;
1972 1971
1973 if (XGetFontProperty(font, XA_FONT, &value)) 1972 if (XGetFontProperty(font, XA_FONT, &value))
1974 { 1973 {
1975 char *xa_font_name = NULL; 1974 char *xa_font_name = NULL;
2139 semsg(_("E252: Fontset name: %s"), base_name); 2138 semsg(_("E252: Fontset name: %s"), base_name);
2140 semsg(_("Font '%s' is not fixed-width"), font_name[i]); 2139 semsg(_("Font '%s' is not fixed-width"), font_name[i]);
2141 return FAIL; 2140 return FAIL;
2142 } 2141 }
2143 } 2142 }
2144 /* scan base font width */ 2143 // scan base font width
2145 min_width = 32767; 2144 min_width = 32767;
2146 for (i = 0; i < fn; i++) 2145 for (i = 0; i < fn; i++)
2147 { 2146 {
2148 if (xfs[i]->max_bounds.width<min_width) 2147 if (xfs[i]->max_bounds.width<min_width)
2149 { 2148 {
2164 (int)xfs[min_font_idx]->max_bounds.width); 2163 (int)xfs[min_font_idx]->max_bounds.width);
2165 semsg(_("Font%d width: %d"), i, (int)xfs[i]->max_bounds.width); 2164 semsg(_("Font%d width: %d"), i, (int)xfs[i]->max_bounds.width);
2166 return FAIL; 2165 return FAIL;
2167 } 2166 }
2168 } 2167 }
2169 /* it seems ok. Good Luck!! */ 2168 // it seems ok. Good Luck!!
2170 return OK; 2169 return OK;
2171 } 2170 }
2172 2171
2173 static int 2172 static int
2174 fontset_width(XFontSet fs) 2173 fontset_width(XFontSet fs)
2200 extents = XExtentsOfFontSet(fs); 2199 extents = XExtentsOfFontSet(fs);
2201 return extents->max_ink_extent.height; 2200 return extents->max_ink_extent.height;
2202 } 2201 }
2203 #endif 2202 #endif
2204 2203
2205 /* NOT USED YET 2204 #if 0
2205 // NOT USED YET
2206 static int 2206 static int
2207 fontset_descent(XFontSet fs) 2207 fontset_descent(XFontSet fs)
2208 { 2208 {
2209 XFontSetExtents *extents; 2209 XFontSetExtents *extents;
2210 2210
2211 extents = XExtentsOfFontSet (fs); 2211 extents = XExtentsOfFontSet (fs);
2212 return extents->max_logical_extent.height + extents->max_logical_extent.y; 2212 return extents->max_logical_extent.height + extents->max_logical_extent.y;
2213 } 2213 }
2214 */ 2214 #endif
2215 2215
2216 static int 2216 static int
2217 fontset_ascent(XFontSet fs) 2217 fontset_ascent(XFontSet fs)
2218 { 2218 {
2219 XFontSetExtents *extents; 2219 XFontSetExtents *extents;
2220 2220
2221 extents = XExtentsOfFontSet(fs); 2221 extents = XExtentsOfFontSet(fs);
2222 return -extents->max_logical_extent.y; 2222 return -extents->max_logical_extent.y;
2223 } 2223 }
2224 2224
2225 #endif /* FEAT_XFONTSET */ 2225 #endif // FEAT_XFONTSET
2226 2226
2227 /* 2227 /*
2228 * Return the Pixel value (color) for the given color name. 2228 * Return the Pixel value (color) for the given color name.
2229 * Return INVALCOLOR for error. 2229 * Return INVALCOLOR for error.
2230 */ 2230 */
2231 guicolor_T 2231 guicolor_T
2232 gui_mch_get_color(char_u *name) 2232 gui_mch_get_color(char_u *name)
2233 { 2233 {
2234 guicolor_T requested; 2234 guicolor_T requested;
2235 2235
2236 /* can't do this when GUI not running */ 2236 // can't do this when GUI not running
2237 if (!gui.in_use || name == NULL || *name == NUL) 2237 if (!gui.in_use || name == NULL || *name == NUL)
2238 return INVALCOLOR; 2238 return INVALCOLOR;
2239 2239
2240 requested = gui_get_color_cmn(name); 2240 requested = gui_get_color_cmn(name);
2241 if (requested == INVALCOLOR) 2241 if (requested == INVALCOLOR)
2255 gui_mch_get_rgb_color(int r, int g, int b) 2255 gui_mch_get_rgb_color(int r, int g, int b)
2256 { 2256 {
2257 XColor available; 2257 XColor available;
2258 Colormap colormap; 2258 Colormap colormap;
2259 2259
2260 /* Using XParseColor() is very slow, put rgb in XColor directly. 2260 #if 0
2261 // Using XParseColor() is very slow, put rgb in XColor directly.
2261 2262
2262 char spec[8]; // space enough to hold "#RRGGBB" 2263 char spec[8]; // space enough to hold "#RRGGBB"
2263 vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b); 2264 vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b);
2264 if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0 2265 if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0
2265 && XAllocColor(gui.dpy, colormap, &available) != 0) 2266 && XAllocColor(gui.dpy, colormap, &available) != 0)
2266 return (guicolor_T)available.pixel; 2267 return (guicolor_T)available.pixel;
2267 */ 2268 #endif
2268 colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy)); 2269 colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy));
2269 vim_memset(&available, 0, sizeof(XColor)); 2270 vim_memset(&available, 0, sizeof(XColor));
2270 available.red = r << 8; 2271 available.red = r << 8;
2271 available.green = g << 8; 2272 available.green = g << 8;
2272 available.blue = b << 8; 2273 available.blue = b << 8;
2360 int wlen = 0; 2361 int wlen = 0;
2361 int c; 2362 int c;
2362 2363
2363 if (enc_utf8) 2364 if (enc_utf8)
2364 { 2365 {
2365 /* Convert UTF-8 byte sequence to 16 bit characters for the X 2366 // Convert UTF-8 byte sequence to 16 bit characters for the X
2366 * functions. Need a buffer for the 16 bit characters. Keep it 2367 // functions. Need a buffer for the 16 bit characters. Keep it
2367 * between calls, because allocating it each time is slow. */ 2368 // between calls, because allocating it each time is slow.
2368 if (buflen < len) 2369 if (buflen < len)
2369 { 2370 {
2370 XtFree((char *)buf); 2371 XtFree((char *)buf);
2371 buf = (void *)XtMalloc(len * (sizeof(XChar2b) < sizeof(wchar_t) 2372 buf = (void *)XtMalloc(len * (sizeof(XChar2b) < sizeof(wchar_t)
2372 ? sizeof(wchar_t) : sizeof(XChar2b))); 2373 ? sizeof(wchar_t) : sizeof(XChar2b)));
2380 #ifdef FEAT_XFONTSET 2381 #ifdef FEAT_XFONTSET
2381 if (current_fontset != NULL) 2382 if (current_fontset != NULL)
2382 { 2383 {
2383 # ifdef SMALL_WCHAR_T 2384 # ifdef SMALL_WCHAR_T
2384 if (c >= 0x10000) 2385 if (c >= 0x10000)
2385 c = 0xbf; /* show chars > 0xffff as ? */ 2386 c = 0xbf; // show chars > 0xffff as ?
2386 # endif 2387 # endif
2387 ((wchar_t *)buf)[wlen] = c; 2388 ((wchar_t *)buf)[wlen] = c;
2388 } 2389 }
2389 else 2390 else
2390 #endif 2391 #endif
2391 { 2392 {
2392 if (c >= 0x10000) 2393 if (c >= 0x10000)
2393 c = 0xbf; /* show chars > 0xffff as ? */ 2394 c = 0xbf; // show chars > 0xffff as ?
2394 ((XChar2b *)buf)[wlen].byte1 = (unsigned)c >> 8; 2395 ((XChar2b *)buf)[wlen].byte1 = (unsigned)c >> 8;
2395 ((XChar2b *)buf)[wlen].byte2 = c; 2396 ((XChar2b *)buf)[wlen].byte2 = c;
2396 } 2397 }
2397 ++wlen; 2398 ++wlen;
2398 cells += utf_char2cells(c); 2399 cells += utf_char2cells(c);
2410 } 2411 }
2411 2412
2412 #ifdef FEAT_XFONTSET 2413 #ifdef FEAT_XFONTSET
2413 if (current_fontset != NULL) 2414 if (current_fontset != NULL)
2414 { 2415 {
2415 /* Setup a clip rectangle to avoid spilling over in the next or 2416 // Setup a clip rectangle to avoid spilling over in the next or
2416 * previous line. This is apparently needed for some fonts which are 2417 // previous line. This is apparently needed for some fonts which are
2417 * used in a fontset. */ 2418 // used in a fontset.
2418 XRectangle clip; 2419 XRectangle clip;
2419 2420
2420 clip.x = 0; 2421 clip.x = 0;
2421 clip.y = 0; 2422 clip.y = 0;
2422 clip.height = gui.char_height; 2423 clip.height = gui.char_height;
2453 XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col), 2454 XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
2454 TEXT_Y(row), (char *)s, len); 2455 TEXT_Y(row), (char *)s, len);
2455 } 2456 }
2456 else 2457 else
2457 { 2458 {
2458 /* XmbDrawImageString has bug, don't use it for fontset. */ 2459 // XmbDrawImageString has bug, don't use it for fontset.
2459 if (enc_utf8) 2460 if (enc_utf8)
2460 XDrawImageString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col), 2461 XDrawImageString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
2461 TEXT_Y(row), buf, wlen); 2462 TEXT_Y(row), buf, wlen);
2462 else 2463 else
2463 XDrawImageString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col), 2464 XDrawImageString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col),
2464 TEXT_Y(row), (char *)s, len); 2465 TEXT_Y(row), (char *)s, len);
2465 } 2466 }
2466 2467
2467 /* Bold trick: draw the text again with a one-pixel offset. */ 2468 // Bold trick: draw the text again with a one-pixel offset.
2468 if (flags & DRAW_BOLD) 2469 if (flags & DRAW_BOLD)
2469 { 2470 {
2470 if (enc_utf8) 2471 if (enc_utf8)
2471 XDrawString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col) + 1, 2472 XDrawString16(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col) + 1,
2472 TEXT_Y(row), buf, wlen); 2473 TEXT_Y(row), buf, wlen);
2473 else 2474 else
2474 XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col) + 1, 2475 XDrawString(gui.dpy, gui.wid, gui.text_gc, TEXT_X(col) + 1,
2475 TEXT_Y(row), (char *)s, len); 2476 TEXT_Y(row), (char *)s, len);
2476 } 2477 }
2477 2478
2478 /* Undercurl: draw curl at the bottom of the character cell. */ 2479 // Undercurl: draw curl at the bottom of the character cell.
2479 if (flags & DRAW_UNDERC) 2480 if (flags & DRAW_UNDERC)
2480 draw_curl(row, col, cells); 2481 draw_curl(row, col, cells);
2481 2482
2482 /* Underline: draw a line at the bottom of the character cell. */ 2483 // Underline: draw a line at the bottom of the character cell.
2483 if (flags & DRAW_UNDERL) 2484 if (flags & DRAW_UNDERL)
2484 { 2485 {
2485 int y = FILL_Y(row + 1) - 1; 2486 int y = FILL_Y(row + 1) - 1;
2486 2487
2487 /* When p_linespace is 0, overwrite the bottom row of pixels. 2488 // When p_linespace is 0, overwrite the bottom row of pixels.
2488 * Otherwise put the line just below the character. */ 2489 // Otherwise put the line just below the character.
2489 if (p_linespace > 1) 2490 if (p_linespace > 1)
2490 y -= p_linespace - 1; 2491 y -= p_linespace - 1;
2491 XDrawLine(gui.dpy, gui.wid, gui.text_gc, FILL_X(col), 2492 XDrawLine(gui.dpy, gui.wid, gui.text_gc, FILL_X(col),
2492 y, FILL_X(col + cells) - 1, y); 2493 y, FILL_X(col + cells) - 1, y);
2493 } 2494 }
2541 } 2542 }
2542 2543
2543 void 2544 void
2544 gui_mch_flash(int msec) 2545 gui_mch_flash(int msec)
2545 { 2546 {
2546 /* Do a visual beep by reversing the foreground and background colors */ 2547 // Do a visual beep by reversing the foreground and background colors
2547 XFillRectangle(gui.dpy, gui.wid, gui.invert_gc, 0, 0, 2548 XFillRectangle(gui.dpy, gui.wid, gui.invert_gc, 0, 0,
2548 FILL_X((int)Columns) + gui.border_offset, 2549 FILL_X((int)Columns) + gui.border_offset,
2549 FILL_Y((int)Rows) + gui.border_offset); 2550 FILL_Y((int)Rows) + gui.border_offset);
2550 XSync(gui.dpy, False); 2551 XSync(gui.dpy, False);
2551 ui_delay((long)msec, TRUE); /* wait for a few msec */ 2552 ui_delay((long)msec, TRUE); // wait for a few msec
2552 XFillRectangle(gui.dpy, gui.wid, gui.invert_gc, 0, 0, 2553 XFillRectangle(gui.dpy, gui.wid, gui.invert_gc, 0, 0,
2553 FILL_X((int)Columns) + gui.border_offset, 2554 FILL_X((int)Columns) + gui.border_offset,
2554 FILL_Y((int)Rows) + gui.border_offset); 2555 FILL_Y((int)Rows) + gui.border_offset);
2555 } 2556 }
2556 2557
2612 { 2613 {
2613 gui_mch_set_fg_color(color); 2614 gui_mch_set_fg_color(color);
2614 2615
2615 XFillRectangle(gui.dpy, gui.wid, gui.text_gc, 2616 XFillRectangle(gui.dpy, gui.wid, gui.text_gc,
2616 #ifdef FEAT_RIGHTLEFT 2617 #ifdef FEAT_RIGHTLEFT
2617 /* vertical line should be on the right of current point */ 2618 // vertical line should be on the right of current point
2618 CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : 2619 CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w :
2619 #endif 2620 #endif
2620 FILL_X(gui.col), 2621 FILL_X(gui.col),
2621 FILL_Y(gui.row) + gui.char_height - h, 2622 FILL_Y(gui.row) + gui.char_height - h,
2622 w, h); 2623 w, h);
2675 if (wtime >= 0) 2676 if (wtime >= 0)
2676 timer = XtAppAddTimeOut(app_context, 2677 timer = XtAppAddTimeOut(app_context,
2677 (long_u)(wtime == 0 ? 1L : wtime), 2678 (long_u)(wtime == 0 ? 1L : wtime),
2678 gui_x11_timer_cb, &timed_out); 2679 gui_x11_timer_cb, &timed_out);
2679 #ifdef FEAT_JOB_CHANNEL 2680 #ifdef FEAT_JOB_CHANNEL
2680 /* If there is a channel with the keep_open flag we need to poll for input 2681 // If there is a channel with the keep_open flag we need to poll for input
2681 * on them. */ 2682 // on them.
2682 if (channel_any_keep_open()) 2683 if (channel_any_keep_open())
2683 channel_timer = XtAppAddTimeOut(app_context, (long_u)20, 2684 channel_timer = XtAppAddTimeOut(app_context, (long_u)20,
2684 channel_poll_cb, (XtPointer)&channel_timer); 2685 channel_poll_cb, (XtPointer)&channel_timer);
2685 #endif 2686 #endif
2686 2687
2687 focus = gui.in_focus; 2688 focus = gui.in_focus;
2688 desired = (XtIMAll); 2689 desired = (XtIMAll);
2689 while (!timed_out) 2690 while (!timed_out)
2690 { 2691 {
2691 /* Stop or start blinking when focus changes */ 2692 // Stop or start blinking when focus changes
2692 if (gui.in_focus != focus) 2693 if (gui.in_focus != focus)
2693 { 2694 {
2694 if (gui.in_focus) 2695 if (gui.in_focus)
2695 gui_mch_start_blink(); 2696 gui_mch_start_blink();
2696 else 2697 else
2703 did_add_timer = FALSE; 2704 did_add_timer = FALSE;
2704 # endif 2705 # endif
2705 parse_queued_messages(); 2706 parse_queued_messages();
2706 # ifdef FEAT_TIMERS 2707 # ifdef FEAT_TIMERS
2707 if (did_add_timer) 2708 if (did_add_timer)
2708 /* Need to recompute the waiting time. */ 2709 // Need to recompute the waiting time.
2709 break; 2710 break;
2710 # endif 2711 # endif
2711 #endif 2712 #endif
2712 2713
2713 /* 2714 /*
2739 2740
2740 /* 2741 /*
2741 * Output routines. 2742 * Output routines.
2742 */ 2743 */
2743 2744
2744 /* Flush any output to the screen */ 2745 /*
2746 * Flush any output to the screen
2747 */
2745 void 2748 void
2746 gui_mch_flush(void) 2749 gui_mch_flush(void)
2747 { 2750 {
2748 XFlush(gui.dpy); 2751 XFlush(gui.dpy);
2749 } 2752 }
2761 { 2764 {
2762 int x; 2765 int x;
2763 2766
2764 x = FILL_X(col1); 2767 x = FILL_X(col1);
2765 2768
2766 /* Clear one extra pixel at the far right, for when bold characters have 2769 // Clear one extra pixel at the far right, for when bold characters have
2767 * spilled over to the next column. */ 2770 // spilled over to the next column.
2768 XFillRectangle(gui.dpy, gui.wid, gui.back_gc, x, FILL_Y(row1), 2771 XFillRectangle(gui.dpy, gui.wid, gui.back_gc, x, FILL_Y(row1),
2769 (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1), 2772 (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1),
2770 (row2 - row1 + 1) * gui.char_height); 2773 (row2 - row1 + 1) * gui.char_height);
2771 } 2774 }
2772 2775
2782 */ 2785 */
2783 void 2786 void
2784 gui_mch_delete_lines(int row, int num_lines) 2787 gui_mch_delete_lines(int row, int num_lines)
2785 { 2788 {
2786 if (gui.visibility == VisibilityFullyObscured) 2789 if (gui.visibility == VisibilityFullyObscured)
2787 return; /* Can't see the window */ 2790 return; // Can't see the window
2788 2791
2789 /* copy one extra pixel at the far right, for when bold has spilled 2792 // copy one extra pixel at the far right, for when bold has spilled
2790 * over */ 2793 // over
2791 XCopyArea(gui.dpy, gui.wid, gui.wid, gui.text_gc, 2794 XCopyArea(gui.dpy, gui.wid, gui.wid, gui.text_gc,
2792 FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines), 2795 FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines),
2793 gui.char_width * (gui.scroll_region_right - gui.scroll_region_left + 1) 2796 gui.char_width * (gui.scroll_region_right - gui.scroll_region_left + 1)
2794 + (gui.scroll_region_right == Columns - 1), 2797 + (gui.scroll_region_right == Columns - 1),
2795 gui.char_height * (gui.scroll_region_bot - row - num_lines + 1), 2798 gui.char_height * (gui.scroll_region_bot - row - num_lines + 1),
2807 */ 2810 */
2808 void 2811 void
2809 gui_mch_insert_lines(int row, int num_lines) 2812 gui_mch_insert_lines(int row, int num_lines)
2810 { 2813 {
2811 if (gui.visibility == VisibilityFullyObscured) 2814 if (gui.visibility == VisibilityFullyObscured)
2812 return; /* Can't see the window */ 2815 return; // Can't see the window
2813 2816
2814 /* copy one extra pixel at the far right, for when bold has spilled 2817 // copy one extra pixel at the far right, for when bold has spilled
2815 * over */ 2818 // over
2816 XCopyArea(gui.dpy, gui.wid, gui.wid, gui.text_gc, 2819 XCopyArea(gui.dpy, gui.wid, gui.wid, gui.text_gc,
2817 FILL_X(gui.scroll_region_left), FILL_Y(row), 2820 FILL_X(gui.scroll_region_left), FILL_Y(row),
2818 gui.char_width * (gui.scroll_region_right - gui.scroll_region_left + 1) 2821 gui.char_width * (gui.scroll_region_right - gui.scroll_region_left + 1)
2819 + (gui.scroll_region_right == Columns - 1), 2822 + (gui.scroll_region_right == Columns - 1),
2820 gui.char_height * (gui.scroll_region_bot - row - num_lines + 1), 2823 gui.char_height * (gui.scroll_region_bot - row - num_lines + 1),
2837 if (gui.visibility != VisibilityPartiallyObscured) 2840 if (gui.visibility != VisibilityPartiallyObscured)
2838 return; 2841 return;
2839 2842
2840 XFlush(gui.dpy); 2843 XFlush(gui.dpy);
2841 2844
2842 /* Wait to check whether the scroll worked or not */ 2845 // Wait to check whether the scroll worked or not
2843 for (;;) 2846 for (;;)
2844 { 2847 {
2845 if (XCheckTypedEvent(gui.dpy, NoExpose, &event)) 2848 if (XCheckTypedEvent(gui.dpy, NoExpose, &event))
2846 return; /* The scroll worked. */ 2849 return; // The scroll worked.
2847 2850
2848 if (XCheckTypedEvent(gui.dpy, GraphicsExpose, &event)) 2851 if (XCheckTypedEvent(gui.dpy, GraphicsExpose, &event))
2849 { 2852 {
2850 gevent = (XGraphicsExposeEvent *)&event; 2853 gevent = (XGraphicsExposeEvent *)&event;
2851 gui_redraw(gevent->x, gevent->y, gevent->width, gevent->height); 2854 gui_redraw(gevent->x, gevent->y, gevent->width, gevent->height);
2852 if (gevent->count == 0) 2855 if (gevent->count == 0)
2853 return; /* This was the last expose event */ 2856 return; // This was the last expose event
2854 } 2857 }
2855 XSync(gui.dpy, False); 2858 XSync(gui.dpy, False);
2856 } 2859 }
2857 } 2860 }
2858 2861
2929 * This is called after setting all the menus to grey/hidden or not. 2932 * This is called after setting all the menus to grey/hidden or not.
2930 */ 2933 */
2931 void 2934 void
2932 gui_mch_draw_menubar(void) 2935 gui_mch_draw_menubar(void)
2933 { 2936 {
2934 /* Nothing to do in X */ 2937 // Nothing to do in X
2935 } 2938 }
2936 2939
2937 void 2940 void
2938 gui_x11_menu_cb( 2941 gui_x11_menu_cb(
2939 Widget w UNUSED, 2942 Widget w UNUSED,
2941 XtPointer call_data UNUSED) 2944 XtPointer call_data UNUSED)
2942 { 2945 {
2943 gui_menu_cb((vimmenu_T *)client_data); 2946 gui_menu_cb((vimmenu_T *)client_data);
2944 } 2947 }
2945 2948
2946 #endif /* FEAT_MENU */ 2949 #endif // FEAT_MENU
2947 2950
2948 2951
2949 2952
2950 /* 2953 /*
2951 * Function called when window closed. Works like ":qa". 2954 * Function called when window closed. Works like ":qa".
2971 */ 2974 */
2972 if ((Atom)((XClientMessageEvent *)event)->data.l[0] == 2975 if ((Atom)((XClientMessageEvent *)event)->data.l[0] ==
2973 wm_atoms[SAVE_YOURSELF_IDX]) 2976 wm_atoms[SAVE_YOURSELF_IDX])
2974 { 2977 {
2975 out_flush(); 2978 out_flush();
2976 ml_sync_all(FALSE, FALSE); /* preserve all swap files */ 2979 ml_sync_all(FALSE, FALSE); // preserve all swap files
2977 2980
2978 /* Set the window's WM_COMMAND property, to let the window manager 2981 // Set the window's WM_COMMAND property, to let the window manager
2979 * know we are done saving ourselves. We don't want to be restarted, 2982 // know we are done saving ourselves. We don't want to be restarted,
2980 * thus set argv to NULL. */ 2983 // thus set argv to NULL.
2981 XSetCommand(gui.dpy, XtWindow(vimShell), NULL, 0); 2984 XSetCommand(gui.dpy, XtWindow(vimShell), NULL, 0);
2982 return; 2985 return;
2983 } 2986 }
2984 2987
2985 if ((Atom)((XClientMessageEvent *)event)->data.l[0] != 2988 if ((Atom)((XClientMessageEvent *)event)->data.l[0] !=
3091 void 3094 void
3092 gui_mch_start_blink(void) 3095 gui_mch_start_blink(void)
3093 { 3096 {
3094 if (blink_timer != (XtIntervalId)0) 3097 if (blink_timer != (XtIntervalId)0)
3095 XtRemoveTimeOut(blink_timer); 3098 XtRemoveTimeOut(blink_timer);
3096 /* Only switch blinking on if none of the times is zero */ 3099 // Only switch blinking on if none of the times is zero
3097 if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) 3100 if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus)
3098 { 3101 {
3099 blink_timer = XtAppAddTimeOut(app_context, blink_waittime, 3102 blink_timer = XtAppAddTimeOut(app_context, blink_waittime,
3100 gui_x11_blink_cb, NULL); 3103 gui_x11_blink_cb, NULL);
3101 blink_state = BLINK_ON; 3104 blink_state = BLINK_ON;
3156 XtAddEventHandler(vimForm, KeyPressMask, FALSE, gui_x11_key_hit_cb, 3159 XtAddEventHandler(vimForm, KeyPressMask, FALSE, gui_x11_key_hit_cb,
3157 (XtPointer)0); 3160 (XtPointer)0);
3158 XtAddEventHandler(textArea, KeyPressMask, FALSE, gui_x11_key_hit_cb, 3161 XtAddEventHandler(textArea, KeyPressMask, FALSE, gui_x11_key_hit_cb,
3159 (XtPointer)0); 3162 (XtPointer)0);
3160 3163
3161 /* get pointer moved events from scrollbar, needed for 'mousefocus' */ 3164 // get pointer moved events from scrollbar, needed for 'mousefocus'
3162 XtAddEventHandler(vimForm, PointerMotionMask, 3165 XtAddEventHandler(vimForm, PointerMotionMask,
3163 FALSE, gui_x11_mouse_cb, (XtPointer)1); 3166 FALSE, gui_x11_mouse_cb, (XtPointer)1);
3164 XtAddEventHandler(textArea, ButtonPressMask | ButtonReleaseMask | 3167 XtAddEventHandler(textArea, ButtonPressMask | ButtonReleaseMask |
3165 ButtonMotionMask | PointerMotionMask, 3168 ButtonMotionMask | PointerMotionMask,
3166 FALSE, gui_x11_mouse_cb, (XtPointer)0); 3169 FALSE, gui_x11_mouse_cb, (XtPointer)0);
3201 } 3204 }
3202 #endif 3205 #endif
3203 3206
3204 #if defined(FEAT_SIGN_ICONS) || defined(PROTO) 3207 #if defined(FEAT_SIGN_ICONS) || defined(PROTO)
3205 3208
3206 /* Signs are currently always 2 chars wide. Hopefully the font is big enough 3209 // Signs are currently always 2 chars wide. Hopefully the font is big enough
3207 * to provide room for the bitmap! */ 3210 // to provide room for the bitmap!
3208 # define SIGN_WIDTH (gui.char_width * 2) 3211 # define SIGN_WIDTH (gui.char_width * 2)
3209 3212
3210 void 3213 void
3211 gui_mch_drawsign(int row, int col, int typenr) 3214 gui_mch_drawsign(int row, int col, int typenr)
3212 { 3215 {
3250 attrs.colorsymbols[1].pixel = gui.norm_pixel; 3253 attrs.colorsymbols[1].pixel = gui.norm_pixel;
3251 status = XpmReadFileToImage(gui.dpy, (char *)signfile, 3254 status = XpmReadFileToImage(gui.dpy, (char *)signfile,
3252 &sign, NULL, &attrs); 3255 &sign, NULL, &attrs);
3253 if (status == 0) 3256 if (status == 0)
3254 { 3257 {
3255 /* Sign width is fixed at two columns now. 3258 // Sign width is fixed at two columns now.
3256 if (sign->width > gui.sign_width) 3259 // if (sign->width > gui.sign_width)
3257 gui.sign_width = sign->width + 8; */ 3260 // gui.sign_width = sign->width + 8;
3258 } 3261 }
3259 else 3262 else
3260 emsg(_(e_signdata)); 3263 emsg(_(e_signdata));
3261 } 3264 }
3262 3265
3270 } 3273 }
3271 #endif 3274 #endif
3272 3275
3273 3276
3274 #ifdef FEAT_MOUSESHAPE 3277 #ifdef FEAT_MOUSESHAPE
3275 /* The last set mouse pointer shape is remembered, to be used when it goes 3278 // The last set mouse pointer shape is remembered, to be used when it goes
3276 * from hidden to not hidden. */ 3279 // from hidden to not hidden.
3277 static int last_shape = 0; 3280 static int last_shape = 0;
3278 #endif 3281 #endif
3279 3282
3280 /* 3283 /*
3281 * Use the blank mouse pointer or not. 3284 * Use the blank mouse pointer or not.
3282 */ 3285 */
3283 void 3286 void
3284 gui_mch_mousehide( 3287 gui_mch_mousehide(
3285 int hide) /* TRUE = use blank ptr, FALSE = use parent ptr */ 3288 int hide) // TRUE = use blank ptr, FALSE = use parent ptr
3286 { 3289 {
3287 if (gui.pointer_hidden != hide) 3290 if (gui.pointer_hidden != hide)
3288 { 3291 {
3289 gui.pointer_hidden = hide; 3292 gui.pointer_hidden = hide;
3290 if (hide) 3293 if (hide)
3298 } 3301 }
3299 } 3302 }
3300 3303
3301 #if defined(FEAT_MOUSESHAPE) || defined(PROTO) 3304 #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
3302 3305
3303 /* Table for shape IDs. Keep in sync with the mshape_names[] table in 3306 // Table for shape IDs. Keep in sync with the mshape_names[] table in
3304 * misc2.c! */ 3307 // misc2.c!
3305 static int mshape_ids[] = 3308 static int mshape_ids[] =
3306 { 3309 {
3307 XC_left_ptr, /* arrow */ 3310 XC_left_ptr, // arrow
3308 0, /* blank */ 3311 0, // blank
3309 XC_xterm, /* beam */ 3312 XC_xterm, // beam
3310 XC_sb_v_double_arrow, /* updown */ 3313 XC_sb_v_double_arrow, // updown
3311 XC_sizing, /* udsizing */ 3314 XC_sizing, // udsizing
3312 XC_sb_h_double_arrow, /* leftright */ 3315 XC_sb_h_double_arrow, // leftright
3313 XC_sizing, /* lrsizing */ 3316 XC_sizing, // lrsizing
3314 XC_watch, /* busy */ 3317 XC_watch, // busy
3315 XC_X_cursor, /* no */ 3318 XC_X_cursor, // no
3316 XC_crosshair, /* crosshair */ 3319 XC_crosshair, // crosshair
3317 XC_hand1, /* hand1 */ 3320 XC_hand1, // hand1
3318 XC_hand2, /* hand2 */ 3321 XC_hand2, // hand2
3319 XC_pencil, /* pencil */ 3322 XC_pencil, // pencil
3320 XC_question_arrow, /* question */ 3323 XC_question_arrow, // question
3321 XC_right_ptr, /* right-arrow */ 3324 XC_right_ptr, // right-arrow
3322 XC_center_ptr, /* up-arrow */ 3325 XC_center_ptr, // up-arrow
3323 XC_left_ptr /* last one */ 3326 XC_left_ptr // last one
3324 }; 3327 };
3325 3328
3326 void 3329 void
3327 mch_set_mouse_shape(int shape) 3330 mch_set_mouse_shape(int shape)
3328 { 3331 {
3339 { 3342 {
3340 id = shape - MSHAPE_NUMBERED; 3343 id = shape - MSHAPE_NUMBERED;
3341 if (id >= XC_num_glyphs) 3344 if (id >= XC_num_glyphs)
3342 id = XC_left_ptr; 3345 id = XC_left_ptr;
3343 else 3346 else
3344 id &= ~1; /* they are always even (why?) */ 3347 id &= ~1; // they are always even (why?)
3345 } 3348 }
3346 else 3349 else
3347 id = mshape_ids[shape]; 3350 id = mshape_ids[shape];
3348 3351
3349 XDefineCursor(gui.dpy, gui.wid, XCreateFontCursor(gui.dpy, id)); 3352 XDefineCursor(gui.dpy, gui.wid, XCreateFontCursor(gui.dpy, id));
3363 gui_mch_menu_set_tip(vimmenu_T *menu) 3366 gui_mch_menu_set_tip(vimmenu_T *menu)
3364 { 3367 {
3365 if (menu->id != NULL && menu->parent != NULL 3368 if (menu->id != NULL && menu->parent != NULL
3366 && menu_is_toolbar(menu->parent->name)) 3369 && menu_is_toolbar(menu->parent->name))
3367 { 3370 {
3368 /* Always destroy and create the balloon, in case the string was 3371 // Always destroy and create the balloon, in case the string was
3369 * changed. */ 3372 // changed.
3370 if (menu->tip != NULL) 3373 if (menu->tip != NULL)
3371 { 3374 {
3372 gui_mch_destroy_beval_area(menu->tip); 3375 gui_mch_destroy_beval_area(menu->tip);
3373 menu->tip = NULL; 3376 menu->tip = NULL;
3374 } 3377 }