diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-12-01 22:11:18 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-12-01 22:11:18 +0100 |
commit | 306139005c31ea7e6f892dd119beba3c94dcb982 (patch) | |
tree | 8b256dbe178f2b314831b64b17d67560e2a54043 /src/gui_gtk_x11.c | |
parent | 217e1b8359447f5550dcb0d1ee43380a90c253c5 (diff) |
patch 8.1.2380: using old C style commentsv8.1.2380
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
Diffstat (limited to 'src/gui_gtk_x11.c')
-rw-r--r-- | src/gui_gtk_x11.c | 1166 |
1 files changed, 577 insertions, 589 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 9c41ffbc40..ef930a5664 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -31,7 +31,7 @@ #endif #ifdef FEAT_GUI_GNOME -/* Gnome redefines _() and N_(). Grrr... */ +// Gnome redefines _() and N_(). Grrr... # ifdef _ # undef _ # endif @@ -48,16 +48,16 @@ # undef bind_textdomain_codeset # endif # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS) -# define ENABLE_NLS /* so the texts in the dialog boxes are translated */ +# define ENABLE_NLS // so the texts in the dialog boxes are translated # endif # include <gnome.h> # include "version.h" -/* missing prototype in bonobo-dock-item.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. */ +// When generating prototypes we don't want syntax errors. # define GdkAtom int # define GdkEventExpose int # define GdkEventFocus int @@ -105,7 +105,7 @@ extern void bonobo_dock_item_set_behavior(BonoboDockItem *dock_item, BonoboDockI #define GET_X_ATOM(atom) gdk_x11_atom_to_xatom_for_display( \ gtk_widget_get_display(gui.mainwin), atom) -/* Selection type distinguishers */ +// Selection type distinguishers enum { TARGET_TYPE_NONE, @@ -177,8 +177,8 @@ static GdkAtom save_yourself_atom = GDK_NONE; */ 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 */ +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,7 +218,7 @@ const special_keys[] = {GDK_F19, 'F', '9'}, {GDK_F20, 'F', 'A'}, {GDK_F21, 'F', 'B'}, - {GDK_Pause, 'F', 'B'}, /* Pause == F21 according to netbeans.txt */ + {GDK_Pause, 'F', 'B'}, // Pause == F21 according to netbeans.txt {GDK_F22, 'F', 'C'}, {GDK_F23, 'F', 'D'}, {GDK_F24, 'F', 'E'}, @@ -249,7 +249,7 @@ const special_keys[] = {GDK_Prior, 'k', 'P'}, {GDK_Next, 'k', 'N'}, {GDK_Print, '%', '9'}, - /* Keypad keys: */ + // Keypad keys: {GDK_KP_Left, 'k', 'l'}, {GDK_KP_Right, 'k', 'r'}, {GDK_KP_Up, 'k', 'u'}, @@ -258,8 +258,8 @@ const special_keys[] = {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_Prior, 'K', '3'}, // page up + {GDK_KP_Next, 'K', '5'}, // page down {GDK_KP_Add, 'K', '6'}, {GDK_KP_Subtract, 'K', '7'}, @@ -279,7 +279,7 @@ const special_keys[] = {GDK_KP_8, 'K', 'K'}, {GDK_KP_9, 'K', 'L'}, - /* End of list marker: */ + // End of list marker: {0, 0, 0} }; @@ -295,14 +295,14 @@ const special_keys[] = #define ARG_ICONIC 7 #define ARG_ROLE 8 #define ARG_NETBEANS 9 -#define ARG_XRM 10 /* ignored */ -#define ARG_MENUFONT 11 /* ignored */ +#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[] */ +#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,7 +320,7 @@ cmdline_option_T; static const cmdline_option_T cmdline_options[] = { - /* We handle these options ourselves */ + // We handle these options ourselves {"-fn", ARG_FONT|ARG_HAS_VALUE}, {"-font", ARG_FONT|ARG_HAS_VALUE}, {"-geom", ARG_GEOMETRY|ARG_HAS_VALUE}, @@ -336,12 +336,12 @@ static const cmdline_option_T cmdline_options[] = {"-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 */ + {"-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. */ + // 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,7 +369,7 @@ static const cmdline_option_T cmdline_options[] = {"-?", 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 */ +# if 0 // conflicts with Vim's own --version argument {"--version", ARG_FOR_GTK|ARG_NEEDS_GUI}, # endif {"--disable-crash-dialog", ARG_FOR_GTK}, @@ -441,14 +441,14 @@ gui_mch_prepare(int *argc, char **argv) while (i < *argc) { - /* Don't waste CPU cycles on non-option arguments. */ + // 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. */ + // Look for argv[i] in cmdline_options[] table. for (option = &cmdline_options[0]; option->name != NULL; ++option) { len = strlen(option->name); @@ -457,11 +457,11 @@ gui_mch_prepare(int *argc, char **argv) { if (argv[i][len] == '\0') break; - /* allow --foo=bar style */ + // allow --foo=bar style if (argv[i][len] == '=' && (option->flags & ARG_HAS_VALUE)) break; #ifdef FEAT_NETBEANS_INTG - /* darn, -nb has non-standard syntax */ + // darn, -nb has non-standard syntax if (vim_strchr((char_u *)":=", argv[i][len]) != NULL && (option->flags & ARG_INDEX_MASK) == ARG_NETBEANS) break; @@ -470,13 +470,13 @@ gui_mch_prepare(int *argc, char **argv) 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. */ + // 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 */ + if (option->name == NULL) // no match { ++i; continue; @@ -484,16 +484,16 @@ gui_mch_prepare(int *argc, char **argv) if (option->flags & ARG_FOR_GTK) { - /* Move the argument into gui_argv, which - * will later be passed to gtk_init_check() */ + // 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. */ + // 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,7 +502,7 @@ gui_mch_prepare(int *argc, char **argv) value = argv[i + 1]; } - /* Check for options handled by Vim itself */ + // Check for options handled by Vim itself switch (option->flags & ARG_INDEX_MASK) { case ARG_REVERSE: @@ -528,11 +528,11 @@ gui_mch_prepare(int *argc, char **argv) found_iconic_arg = TRUE; break; case ARG_ROLE: - role_argument = value; /* used later in gui_mch_open() */ + 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 */ + gui.dofork = FALSE; // don't fork() when starting GUI netbeansArg = argv[i]; break; #endif @@ -541,9 +541,9 @@ gui_mch_prepare(int *argc, char **argv) } } - /* 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. */ + // 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,12 +552,12 @@ gui_mch_prepare(int *argc, char **argv) ++i; else { - /* Remove the flag from the argument vector. */ + // 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. */ + // 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,7 +612,7 @@ visibility_event(GtkWidget *widget UNUSED, gui.visibility != GDK_VISIBILITY_UNOBSCURED); return FALSE; } -#endif /* !GTK_CHECK_VERSION(3,0,0) */ +#endif // !GTK_CHECK_VERSION(3,0,0) /* * Redraw the corresponding portions of the screen. @@ -626,7 +626,7 @@ static gboolean gui_gtk_is_blink_on(void); static void gui_gtk3_redraw(int x, int y, int width, int height) { - /* Range checks are left to gui_redraw_block() */ + // 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,16 +663,16 @@ draw_event(GtkWidget *widget UNUSED, cairo_t *cr, gpointer user_data UNUSED) { - /* Skip this when the GUI isn't set up yet, will redraw later. */ + // 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. */ + 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. */ + // Draw the window without the cursor. gui.by_signal = TRUE; { cairo_rectangle_list_t *list = NULL; @@ -682,8 +682,8 @@ draw_event(GtkWidget *widget UNUSED, { int i; - /* First clear all the blocks and then redraw them. Just in case - * some blocks overlap. */ + // 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,27 +720,27 @@ draw_event(GtkWidget *widget UNUSED, } gui.by_signal = FALSE; - /* Add the cursor to the window if necessary.*/ + // 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) */ +#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. */ + // 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 */ + 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 */ + // 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,7 +753,7 @@ expose_event(GtkWidget *widget UNUSED, return FALSE; } -#endif /* !GTK_CHECK_VERSION(3,0,0) */ +#endif // !GTK_CHECK_VERSION(3,0,0) #ifdef FEAT_CLIENTSERVER /* @@ -771,7 +771,7 @@ property_event(GtkWidget *widget, { XEvent xev; - /* Translate to XLib */ + // Translate to XLib xev.xproperty.type = PropertyNotify; xev.xproperty.atom = commProperty; xev.xproperty.window = commWindow; @@ -781,7 +781,7 @@ property_event(GtkWidget *widget, } return FALSE; } -#endif /* defined(FEAT_CLIENTSERVER) */ +#endif // defined(FEAT_CLIENTSERVER) /* * Handle changes to the "Xft/DPI" setting @@ -826,9 +826,8 @@ timeout_remove(guint timer) } -/**************************************************************************** - * Focus handlers: - */ +///////////////////////////////////////////////////////////////////////////// +// Focus handlers: /* @@ -931,7 +930,7 @@ blink_cb(gpointer data UNUSED) } gui_mch_flush(); - return FALSE; /* don't happen again */ + return FALSE; // don't happen again } /* @@ -946,7 +945,7 @@ gui_mch_start_blink(void) timeout_remove(blink_timer); blink_timer = 0; } - /* Only switch blinking on if none of the times is zero */ + // 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,7 +963,7 @@ enter_notify_event(GtkWidget *widget UNUSED, if (blink_state == BLINK_NONE) gui_mch_start_blink(); - /* make sure keyboard input goes there */ + // make sure keyboard input goes there if (gtk_socket_id == 0 || !gtk_widget_has_focus(gui.drawarea)) gtk_widget_grab_focus(gui.drawarea); @@ -992,8 +991,8 @@ focus_in_event(GtkWidget *widget, 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) */ + // 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,13 +1031,13 @@ keyval_to_string(unsigned int keyval, unsigned int state, char_u *string) uc = gdk_keyval_to_unicode(keyval); if (uc != 0) { - /* Check for CTRL-foo */ + // 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). */ + // 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,16 +1054,16 @@ keyval_to_string(unsigned int keyval, unsigned int state, char_u *string) } 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. */ + // 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. */ + // 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,8 +1133,8 @@ key_press_event(GtkWidget *widget UNUSED, 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.) */ + // 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,8 +1171,8 @@ key_press_event(GtkWidget *widget UNUSED, { 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. */ + // 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,7 +1183,7 @@ key_press_event(GtkWidget *widget UNUSED, *d++ = s[i]; if (d[-1] == CSI && d + 2 < string + sizeof(string)) { - /* Turn CSI into K_CSI. */ + // Turn CSI into K_CSI. *d++ = KS_EXTRA; *d++ = (int)KE_CSI; } @@ -1192,7 +1191,7 @@ key_press_event(GtkWidget *widget UNUSED, len = d - string; } - /* Shift-Tab results in Left_Tab, but we want <S-Tab> */ + // Shift-Tab results in Left_Tab, but we want <S-Tab> if (key_sym == GDK_ISO_Left_Tab) { key_sym = GDK_Tab; @@ -1200,24 +1199,24 @@ key_press_event(GtkWidget *widget UNUSED, } #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 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. */ + // 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 <S-M-Tab>, that should become K_S_TAB with ALT. - * Don't do this for double-byte encodings, it turns the char into a lead - * byte. */ + // 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 <S-M-Tab>, 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,8 +1230,8 @@ key_press_event(GtkWidget *widget UNUSED, ) { string[0] |= 0x80; - state &= ~GDK_MOD1_MASK; /* don't use it again */ - if (enc_utf8) /* convert to utf-8 */ + 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,8 +1246,8 @@ key_press_event(GtkWidget *widget UNUSED, } } - /* Check for special keys. Also do this when len == 1 (key has an ASCII - * value) to detect backspace, delete and keypad keys. */ + // 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,11 +1263,11 @@ key_press_event(GtkWidget *widget UNUSED, } } - if (len == 0) /* Unrecognized key */ + 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). */ + // 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,7 +1323,7 @@ key_press_event(GtkWidget *widget UNUSED, add_to_input_buf(string, len); - /* blank out the pointer if necessary */ + // blank out the pointer if necessary if (p_mh) gui_mch_mousehide(TRUE); @@ -1356,12 +1355,11 @@ key_release_event(GtkWidget *widget UNUSED, #endif -/**************************************************************************** - * Selection handlers: - */ +///////////////////////////////////////////////////////////////////////////// +// Selection handlers: -/* Remember when clip_lose_selection was called from here, we must not call - * gtk_selection_owner_set() then. */ +// 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,9 +1377,9 @@ selection_clear_event(GtkWidget *widget UNUSED, 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 */ +#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,7 +1406,7 @@ selection_received_cb(GtkWidget *widget UNUSED, if (text == NULL || len <= 0) { received_selection = RS_FAIL; - /* clip_free_selection(cbd); ??? */ + // clip_free_selection(cbd); ??? return; } @@ -1430,8 +1428,8 @@ selection_received_cb(GtkWidget *widget UNUSED, text += STRLEN(text) + 1; len -= text - enc; - /* If the encoding of the text is different from 'encoding', attempt - * converting it. */ + // 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,8 +1441,8 @@ selection_received_cb(GtkWidget *widget UNUSED, } } - /* gtk_selection_data_get_text() handles all the nasty details - * and targets and encodings etc. This rocks so hard. */ + // 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,7 +1462,7 @@ selection_received_cb(GtkWidget *widget UNUSED, { vimconv_T conv; - /* UTF-16, we get this for HTML */ + // 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,7 +1478,7 @@ selection_received_cb(GtkWidget *widget UNUSED, } } - /* Chop off any trailing NUL bytes. OpenOffice sends these. */ + // Chop off any trailing NUL bytes. OpenOffice sends these. while (len > 0 && text[len - 1] == NUL) --len; @@ -1516,7 +1514,7 @@ selection_get_cb(GtkWidget *widget UNUSED, cbd = &clip_star; if (!cbd->owned) - return; /* Shouldn't ever happen */ + return; // Shouldn't ever happen if (info != (guint)TARGET_STRING && (!clip_html || info != (guint)TARGET_HTML) @@ -1527,15 +1525,15 @@ selection_get_cb(GtkWidget *widget UNUSED, && info != (guint)TARGET_TEXT) return; - /* get the selection from the '*'/'+' register */ + // 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... ;-) */ + // 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,7 +1544,7 @@ selection_get_cb(GtkWidget *widget UNUSED, tmpbuf[0] = motion_type; mch_memmove(tmpbuf + 1, string, (size_t)length); } - /* For our own format, the first byte contains the motion type */ + // For our own format, the first byte contains the motion type ++length; vim_free(string); string = tmpbuf; @@ -1557,7 +1555,7 @@ selection_get_cb(GtkWidget *widget UNUSED, { vimconv_T conv; - /* Since we get utf-16, we probably should set it as well. */ + // 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,7 +1566,7 @@ selection_get_cb(GtkWidget *widget UNUSED, string = tmpbuf; } - /* Prepend the BOM: "fffe" */ + // Prepend the BOM: "fffe" if (string != NULL) { tmpbuf = alloc(length + 2); @@ -1583,10 +1581,10 @@ selection_get_cb(GtkWidget *widget UNUSED, } #if !GTK_CHECK_VERSION(3,0,0) - /* Looks redundant even for GTK2 because these values are - * overwritten by gtk_selection_data_set() that follows. */ + // 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 */ + selection_data->format = 16; // 16 bits per char #endif gtk_selection_data_set(selection_data, html_atom, 16, string, length); @@ -1598,7 +1596,7 @@ selection_get_cb(GtkWidget *widget UNUSED, { int l = STRLEN(p_enc); - /* contents: motion_type 'encoding' NUL text */ + // contents: motion_type 'encoding' NUL text tmpbuf = alloc(length + l + 2); if (tmpbuf != NULL) { @@ -1612,8 +1610,8 @@ selection_get_cb(GtkWidget *widget UNUSED, 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. */ + // 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,7 +1622,7 @@ selection_get_cb(GtkWidget *widget UNUSED, return; string = tmpbuf; } - /* Validate the string to avoid runtime warnings */ + // 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,10 +1635,10 @@ selection_get_cb(GtkWidget *widget UNUSED, 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. */ + // 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 */ + selection_data->format = 8; // 8 bits per char #endif gtk_selection_data_set(selection_data, type, 8, string, length); vim_free(string); @@ -1657,7 +1655,7 @@ gui_mch_early_init_check(int give_message) { char_u *p; - /* Guess that when $DISPLAY isn't set the GUI can't start. */ + // Guess that when $DISPLAY isn't set the GUI can't start. p = mch_getenv((char_u *)"DISPLAY"); if (p == NULL || *p == NUL) { @@ -1682,16 +1680,16 @@ gui_mch_init_check(void) if (!res_registered) { - /* Call this function in the GUI process; otherwise, the resources - * won't be available. Don't call it twice. */ + // 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. */ + // 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,12 +1698,12 @@ gui_mch_init_check(void) 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. */ + // 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. */ + // Don't use gtk_init() or gnome_init(), it exits on failure. if (!gtk_init_check(&gui_argc, &gui_argv)) { gui.dying = TRUE; @@ -1716,9 +1714,8 @@ gui_mch_init_check(void) return OK; } -/**************************************************************************** - * Mouse handling callbacks - */ +///////////////////////////////////////////////////////////////////////////// +// Mouse handling callbacks static guint mouse_click_timer = 0; @@ -1730,11 +1727,11 @@ static int mouse_timed_out = TRUE; static timeout_cb_type mouse_click_timer_cb(gpointer data) { - /* we don't use this information currently */ + // we don't use this information currently int *timed_out = (int *) data; *timed_out = TRUE; - return FALSE; /* don't happen again */ + return FALSE; // don't happen again } static guint motion_repeat_timer = 0; @@ -1753,21 +1750,21 @@ process_motion_notify(int x, int y, GdkModifierType state) GDK_BUTTON5_MASK)) ? MOUSE_DRAG : ' '; - /* If our pointer is currently hidden, then we should show it. */ + // 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. */ + // 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 */ + // translate modifier coding between the main engine and GTK vim_modifiers = modifiers_gdk2mouse(state); - /* inform the editor engine about the occurrence of this event */ + // inform the editor engine about the occurrence of this event gui_send_mouse_event(button, x, y, FALSE, vim_modifiers); /* @@ -1785,26 +1782,24 @@ process_motion_notify(int x, int y, GdkModifierType state) int offshoot; int delay = 10; - /* Calculate the maximal distance of the cursor from the drawing area. - * (offshoot can't become negative here!). - */ + // 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... - */ + // 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 :-). */ + // 5 appears to be somehow near to my perceptual limits :-). delay = 5; } else @@ -1812,7 +1807,7 @@ process_motion_notify(int x, int y, GdkModifierType state) delay = (130 * (127 - offshoot)) / 127 + 5; } - /* shoot again */ + // shoot again if (!motion_repeat_timer) motion_repeat_timer = timeout_add(delay, motion_repeat_timer_cb, NULL); @@ -1855,7 +1850,7 @@ gui_gtk_window_at_position(GtkWidget *widget, return gdk_device_get_window_at_position(dev, x, y); } # endif -#else /* !GTK_CHECK_VERSION(3,0,0) */ +#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,8 +1876,8 @@ motion_repeat_timer_cb(gpointer data UNUSED) 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 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,8 +1895,8 @@ motion_repeat_timer_cb(gpointer data UNUSED) 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. */ + // Don't happen again. We will get reinstalled in the synthetic event + // if needed -- thus repeating should still work. return FALSE; } @@ -1925,7 +1920,7 @@ motion_notify_event(GtkWidget *widget, (GdkModifierType)event->state); } - return TRUE; /* handled */ + return TRUE; // handled } @@ -1946,7 +1941,7 @@ button_press_event(GtkWidget *widget, gui.event_time = event->time; - /* Make sure we have focus now we've been selected */ + // 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,7 +1955,7 @@ button_press_event(GtkWidget *widget, x = event->x; y = event->y; - /* Handle multiple clicks */ + // Handle multiple clicks if (!mouse_timed_out && mouse_click_timer) { timeout_remove(mouse_click_timer); @@ -1974,19 +1969,19 @@ button_press_event(GtkWidget *widget, switch (event->button) { - /* Keep in sync with gui_x11.c. - * Buttons 4-7 are handled in scroll_event() */ + // 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_MIDDL |