2016-08-29 22:49:24 +02:00
|
|
|
/* vi:set ts=8 sts=4 sw=4 noet:
|
2004-06-13 20:20:40 +00:00
|
|
|
*
|
|
|
|
* VIM - Vi IMproved by Bram Moolenaar
|
|
|
|
* Motif support by Robert Webb
|
|
|
|
*
|
|
|
|
* Do ":help uganda" in Vim to read copying and usage conditions.
|
|
|
|
* Do ":help credits" in Vim to see a list of people who contributed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef FEAT_GUI_MOTIF
|
|
|
|
# include <Xm/Xm.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FEAT_GUI_GTK
|
2023-12-05 16:04:23 +01:00
|
|
|
# ifdef VMS
|
2020-12-30 13:14:45 +01:00
|
|
|
# include "gui_gtk_vms.h"
|
2023-12-05 16:04:23 +01:00
|
|
|
# endif
|
2004-06-13 20:20:40 +00:00
|
|
|
# include <X11/Intrinsic.h>
|
patch 9.0.1960: Make CI checks more strict
Problem: Make CI checks more strict
Solution: Add -Wstrict-prototypes -Wmissing-prototypes to CI,
fix uncovered problems
Add -Wstrict-prototypes -Wmissing-prototypes warnings check to CI
Add two new warnings to CI, silence some Perl related build-warnings:
- `strict-prototypes` helps prevent declaring a function with an empty
argument list, e.g. `int func()`. In C++, that's equivalent to `int
func(void)`, but in C, that means a function that can take any number
of arguments which is rarely what we want.
- `missing-prototypes` makes sure we use `static` for file-only internal
functions. Non-static functions should have been declared on a
prototype file.
- Add `no-compound-token-split-by-macro` to the perl cflags, since it
throws out a bunch of perl-related warnings that make the CI log
unnecessary verbose and hard to read. This seems to happen only with
clang 12 and above.
When applying those changes, it already uncovered a few warnings, so fix
up the code as well (fix prototypes, make the code static, remove
shadowed var declaration)
GTK header needs to have #pragma warning suppressiong because GTK2
headers will warn on `-Wstrict-prototypes`, and it's included by gui.h
and so we can't just turn off the warning in a couple files.
closes: #13223
closes: #13226
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-30 12:28:50 +02:00
|
|
|
# pragma GCC diagnostic push
|
|
|
|
# pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
2004-06-13 20:20:40 +00:00
|
|
|
# include <gtk/gtk.h>
|
patch 9.0.1960: Make CI checks more strict
Problem: Make CI checks more strict
Solution: Add -Wstrict-prototypes -Wmissing-prototypes to CI,
fix uncovered problems
Add -Wstrict-prototypes -Wmissing-prototypes warnings check to CI
Add two new warnings to CI, silence some Perl related build-warnings:
- `strict-prototypes` helps prevent declaring a function with an empty
argument list, e.g. `int func()`. In C++, that's equivalent to `int
func(void)`, but in C, that means a function that can take any number
of arguments which is rarely what we want.
- `missing-prototypes` makes sure we use `static` for file-only internal
functions. Non-static functions should have been declared on a
prototype file.
- Add `no-compound-token-split-by-macro` to the perl cflags, since it
throws out a bunch of perl-related warnings that make the CI log
unnecessary verbose and hard to read. This seems to happen only with
clang 12 and above.
When applying those changes, it already uncovered a few warnings, so fix
up the code as well (fix prototypes, make the code static, remove
shadowed var declaration)
GTK header needs to have #pragma warning suppressiong because GTK2
headers will warn on `-Wstrict-prototypes`, and it's included by gui.h
and so we can't just turn off the warning in a couple files.
closes: #13223
closes: #13226
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-30 12:28:50 +02:00
|
|
|
# pragma GCC diagnostic pop
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2020-02-26 16:16:53 +01:00
|
|
|
#ifdef FEAT_GUI_HAIKU
|
|
|
|
# include "gui_haiku.h"
|
|
|
|
#endif
|
|
|
|
|
2019-07-04 21:24:34 +02:00
|
|
|
// Needed when generating prototypes, since FEAT_GUI is always defined then.
|
|
|
|
#if defined(FEAT_XCLIPBOARD) && !defined(FEAT_GUI_MOTIF) \
|
2022-04-03 18:02:37 +01:00
|
|
|
&& !defined(FEAT_GUI_GTK)
|
2019-07-04 21:24:34 +02:00
|
|
|
# include <X11/Intrinsic.h>
|
|
|
|
#endif
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
#ifdef FEAT_GUI_PHOTON
|
|
|
|
# include <Ph.h>
|
|
|
|
# include <Pt.h>
|
|
|
|
# include "photon/PxProto.h"
|
|
|
|
#endif
|
|
|
|
|
2007-05-06 12:28:24 +00:00
|
|
|
/*
|
|
|
|
* On some systems scrolling needs to be done right away instead of in the
|
|
|
|
* main loop.
|
|
|
|
*/
|
2020-08-11 21:58:20 +02:00
|
|
|
#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)
|
2004-06-13 20:20:40 +00:00
|
|
|
# define USE_ON_FLY_SCROLL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GUIs that support dropping files on a running Vim.
|
|
|
|
*/
|
2018-07-29 17:35:23 +02:00
|
|
|
#if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \
|
|
|
|
|| defined(FEAT_GUI_MSWIN) \
|
2020-02-26 16:16:53 +01:00
|
|
|
|| defined(FEAT_GUI_HAIKU)
|
2004-06-13 20:20:40 +00:00
|
|
|
# define HAVE_DROP_FILE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This define makes menus always use a fontset.
|
|
|
|
* We're not sure if this code always works, thus it can be disabled.
|
|
|
|
*/
|
|
|
|
#ifdef FEAT_XFONTSET
|
|
|
|
# define FONTSET_ALWAYS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These macros convert between character row/column and pixel coordinates.
|
|
|
|
* TEXT_X - Convert character column into X pixel coord for drawing strings.
|
|
|
|
* TEXT_Y - Convert character row into Y pixel coord for drawing strings.
|
|
|
|
* FILL_X - Convert character column into X pixel coord for filling the area
|
|
|
|
* under the character.
|
|
|
|
* FILL_Y - Convert character row into Y pixel coord for filling the area
|
|
|
|
* under the character.
|
|
|
|
* X_2_COL - Convert X pixel coord into character column.
|
|
|
|
* Y_2_ROW - Convert Y pixel coord into character row.
|
|
|
|
*/
|
2019-02-17 17:44:42 +01:00
|
|
|
#ifdef FEAT_GUI_MSWIN
|
2004-06-13 20:20:40 +00:00
|
|
|
# define TEXT_X(col) ((col) * gui.char_width)
|
|
|
|
# define TEXT_Y(row) ((row) * gui.char_height + gui.char_ascent)
|
|
|
|
# define FILL_X(col) ((col) * gui.char_width)
|
|
|
|
# define FILL_Y(row) ((row) * gui.char_height)
|
|
|
|
# define X_2_COL(x) ((x) / gui.char_width)
|
|
|
|
# define Y_2_ROW(y) ((y) / gui.char_height)
|
|
|
|
#else
|
|
|
|
# define TEXT_X(col) ((col) * gui.char_width + gui.border_offset)
|
|
|
|
# define FILL_X(col) ((col) * gui.char_width + gui.border_offset)
|
|
|
|
# define X_2_COL(x) (((x) - gui.border_offset) / gui.char_width)
|
|
|
|
# define TEXT_Y(row) ((row) * gui.char_height + gui.char_ascent \
|
|
|
|
+ gui.border_offset)
|
|
|
|
# define FILL_Y(row) ((row) * gui.char_height + gui.border_offset)
|
|
|
|
# define Y_2_ROW(y) (((y) - gui.border_offset) / gui.char_height)
|
|
|
|
#endif
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// Indices for arrays of scrollbars
|
2022-03-27 20:05:17 +01:00
|
|
|
#define SBAR_NONE (-1)
|
2004-06-13 20:20:40 +00:00
|
|
|
#define SBAR_LEFT 0
|
|
|
|
#define SBAR_RIGHT 1
|
|
|
|
#define SBAR_BOTTOM 2
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// Orientations for scrollbars
|
2004-06-13 20:20:40 +00:00
|
|
|
#define SBAR_VERT 0
|
|
|
|
#define SBAR_HORIZ 1
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// Default size of scrollbar
|
2004-06-13 20:20:40 +00:00
|
|
|
#define SB_DEFAULT_WIDTH 16
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// Default height of the menu bar
|
|
|
|
#define MENU_DEFAULT_HEIGHT 1 // figure it out at runtime
|
|
|
|
|
|
|
|
// Flags for gui_mch_outstr_nowrap()
|
|
|
|
#define GUI_MON_WRAP_CURSOR 0x01 // wrap cursor at end of line
|
|
|
|
#define GUI_MON_INVERT 0x02 // invert the characters
|
|
|
|
#define GUI_MON_IS_CURSOR 0x04 // drawing cursor
|
|
|
|
#define GUI_MON_TRS_CURSOR 0x08 // drawing transparent cursor
|
|
|
|
#define GUI_MON_NOCLEAR 0x10 // don't clear selection
|
|
|
|
|
|
|
|
// Flags for gui_mch_draw_string()
|
|
|
|
#define DRAW_TRANSP 0x01 // draw with transparent bg
|
|
|
|
#define DRAW_BOLD 0x02 // draw bold text
|
|
|
|
#define DRAW_UNDERL 0x04 // draw underline text
|
|
|
|
#define DRAW_UNDERC 0x08 // draw undercurl text
|
2011-05-10 16:41:25 +02:00
|
|
|
#if defined(FEAT_GUI_GTK)
|
2019-11-30 19:44:38 +01:00
|
|
|
# define DRAW_ITALIC 0x10 // draw italic text
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
2019-11-30 19:44:38 +01:00
|
|
|
#define DRAW_CURSOR 0x20 // drawing block cursor (win32)
|
|
|
|
#define DRAW_STRIKE 0x40 // strikethrough
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// For our own tearoff menu item
|
2004-06-13 20:20:40 +00:00
|
|
|
#define TEAR_STRING "-->Detach"
|
2019-11-30 19:44:38 +01:00
|
|
|
#define TEAR_LEN (9) // length of above string
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// for the toolbar
|
2016-02-20 22:17:05 +01:00
|
|
|
#define TOOLBAR_BUTTON_HEIGHT 18
|
|
|
|
#define TOOLBAR_BUTTON_WIDTH 18
|
2019-11-30 19:44:38 +01:00
|
|
|
#define TOOLBAR_BORDER_HEIGHT 12 // room above+below buttons for MSWindows
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2006-03-27 17:01:56 +00:00
|
|
|
#ifdef FEAT_GUI_MSWIN
|
2006-03-27 20:55:21 +00:00
|
|
|
# define TABLINE_HEIGHT 22
|
2006-03-27 17:01:56 +00:00
|
|
|
#endif
|
2006-04-05 20:41:53 +00:00
|
|
|
#ifdef FEAT_GUI_MOTIF
|
|
|
|
# define TABLINE_HEIGHT 30
|
|
|
|
#endif
|
2006-03-27 17:01:56 +00:00
|
|
|
|
2005-12-06 19:59:18 +00:00
|
|
|
#if defined(NO_CONSOLE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
|
2019-11-30 19:44:38 +01:00
|
|
|
# define NO_CONSOLE_INPUT // use no_console_input() to check if there
|
|
|
|
// is no console input possible
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct GuiScrollbar
|
|
|
|
{
|
2019-11-30 19:44:38 +01:00
|
|
|
long ident; // Unique identifier for each scrollbar
|
|
|
|
win_T *wp; // Scrollbar's window, NULL for bottom
|
|
|
|
int type; // one of SBAR_{LEFT,RIGHT,BOTTOM}
|
|
|
|
long value; // Represents top line number visible
|
|
|
|
long size; // Size of scrollbar thumb
|
|
|
|
long max; // Number of lines in buffer
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// Values measured in characters:
|
|
|
|
int top; // Top of scroll bar (chars from row 0)
|
|
|
|
int height; // Current height of scroll bar in rows
|
|
|
|
int width; // Current width of scroll bar in cols
|
|
|
|
int status_height; // Height of status line
|
2004-06-13 20:20:40 +00:00
|
|
|
#ifdef FEAT_GUI_X11
|
2019-11-30 19:44:38 +01:00
|
|
|
Widget id; // Id of real scroll bar
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
#ifdef FEAT_GUI_GTK
|
2019-11-30 19:44:38 +01:00
|
|
|
GtkWidget *id; // Id of real scroll bar
|
|
|
|
unsigned long handler_id; // Id of "value_changed" signal handler
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FEAT_GUI_MSWIN
|
2019-11-30 19:44:38 +01:00
|
|
|
HWND id; // Id of real scroll bar
|
|
|
|
int scroll_shift; // The scrollbar stuff can handle only up to
|
|
|
|
// 32767 lines. When the file is longer,
|
|
|
|
// scroll_shift is set to the number of shifts
|
|
|
|
// to reduce the count.
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
2020-02-26 16:16:53 +01:00
|
|
|
|
2024-01-12 17:31:07 +01:00
|
|
|
#ifdef FEAT_GUI_HAIKU
|
2020-02-26 16:16:53 +01:00
|
|
|
VimScrollBar *id; // Pointer to real scroll bar
|
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
#ifdef FEAT_GUI_PHOTON
|
|
|
|
PtWidget_t *id;
|
|
|
|
#endif
|
|
|
|
} scrollbar_T;
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
typedef long guicolor_T; // handle for a GUI color; for X11 this should
|
|
|
|
// be "Pixel", but that's an unsigned and we
|
|
|
|
// need a signed value
|
2022-03-27 20:05:17 +01:00
|
|
|
#define INVALCOLOR ((guicolor_T)-11111) // number for invalid color; on 32 bit
|
2019-11-30 19:44:38 +01:00
|
|
|
// displays there is a tiny chance this is an
|
|
|
|
// actual color
|
2022-03-27 20:05:17 +01:00
|
|
|
#define CTERMCOLOR ((guicolor_T)-11110) // only used for cterm.bg_rgb and
|
2019-11-30 19:44:38 +01:00
|
|
|
// cterm.fg_rgb: use cterm color
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
#ifdef FEAT_GUI_GTK
|
2019-11-30 19:44:38 +01:00
|
|
|
typedef PangoFontDescription *GuiFont; // handle for a GUI font
|
|
|
|
typedef PangoFontDescription *GuiFontset; // handle for a GUI fontset
|
2004-06-13 20:20:40 +00:00
|
|
|
# define NOFONT (GuiFont)NULL
|
|
|
|
# define NOFONTSET (GuiFontset)NULL
|
|
|
|
#else
|
|
|
|
# ifdef FEAT_GUI_PHOTON
|
|
|
|
typedef char *GuiFont;
|
|
|
|
typedef char *GuiFontset;
|
|
|
|
# define NOFONT (GuiFont)NULL
|
|
|
|
# define NOFONTSET (GuiFontset)NULL
|
|
|
|
# else
|
|
|
|
# ifdef FEAT_GUI_X11
|
2019-11-30 19:44:38 +01:00
|
|
|
typedef XFontStruct *GuiFont; // handle for a GUI font
|
|
|
|
typedef XFontSet GuiFontset; // handle for a GUI fontset
|
2004-06-13 20:20:40 +00:00
|
|
|
# define NOFONT (GuiFont)0
|
|
|
|
# define NOFONTSET (GuiFontset)0
|
|
|
|
# else
|
2019-11-30 19:44:38 +01:00
|
|
|
typedef long_u GuiFont; // handle for a GUI font
|
|
|
|
typedef long_u GuiFontset; // handle for a GUI fontset
|
2004-06-13 20:20:40 +00:00
|
|
|
# define NOFONT (GuiFont)0
|
|
|
|
# define NOFONTSET (GuiFontset)0
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2019-04-28 19:46:49 +02:00
|
|
|
#ifdef VIMDLL
|
|
|
|
// Use spawn when GUI is starting.
|
|
|
|
# define GUI_MAY_SPAWN
|
|
|
|
|
|
|
|
// Uncomment the next definition if you want to use the `:gui` command on
|
|
|
|
// Windows. It uses `:mksession` to inherit the session from vim.exe to
|
|
|
|
// gvim.exe. So, it doesn't work perfectly. (EXPERIMENTAL)
|
|
|
|
//# define EXPERIMENTAL_GUI_CMD
|
|
|
|
#endif
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
typedef struct Gui
|
|
|
|
{
|
2019-11-30 19:44:38 +01:00
|
|
|
int in_focus; // Vim has input focus
|
|
|
|
int in_use; // Is the GUI being used?
|
|
|
|
int starting; // GUI will start in a little while
|
|
|
|
int shell_created; // Has the shell been created yet?
|
|
|
|
int dying; // Is vim dying? Then output to terminal
|
|
|
|
int dofork; // Use fork() when GUI is starting
|
2019-04-28 19:46:49 +02:00
|
|
|
#ifdef GUI_MAY_SPAWN
|
2019-11-30 19:44:38 +01:00
|
|
|
int dospawn; // Use spawn() when GUI is starting
|
|
|
|
#endif
|
|
|
|
int dragged_sb; // Which scrollbar being dragged, if any?
|
|
|
|
win_T *dragged_wp; // Which WIN's sb being dragged, if any?
|
|
|
|
int pointer_hidden; // Is the mouse pointer hidden?
|
|
|
|
int col; // Current cursor column in GUI display
|
|
|
|
int row; // Current cursor row in GUI display
|
|
|
|
int cursor_col; // Physical cursor column in GUI display
|
|
|
|
int cursor_row; // Physical cursor row in GUI display
|
|
|
|
char cursor_is_valid; // There is a cursor at cursor_row/col
|
|
|
|
int num_cols; // Number of columns
|
|
|
|
int num_rows; // Number of rows
|
|
|
|
int scroll_region_top; // Top (first) line of scroll region
|
|
|
|
int scroll_region_bot; // Bottom (last) line of scroll region
|
|
|
|
int scroll_region_left; // Left (first) column of scroll region
|
|
|
|
int scroll_region_right; // Right (last) col. of scroll region
|
|
|
|
int highlight_mask; // Highlight attribute mask
|
|
|
|
int scrollbar_width; // Width of vertical scrollbars
|
|
|
|
int scrollbar_height; // Height of horizontal scrollbar
|
|
|
|
int left_sbar_x; // Calculated x coord for left scrollbar
|
|
|
|
int right_sbar_x; // Calculated x coord for right scrollbar
|
2024-01-29 20:54:28 +01:00
|
|
|
int force_redraw; // Force a redraw even e.g. not resized
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
#ifdef FEAT_MENU
|
|
|
|
# ifndef FEAT_GUI_GTK
|
2019-11-30 19:44:38 +01:00
|
|
|
int menu_height; // Height of the menu bar
|
|
|
|
int menu_width; // Width of the menu bar
|
2004-06-13 20:20:40 +00:00
|
|
|
# endif
|
2019-11-30 19:44:38 +01:00
|
|
|
char menu_is_active; // TRUE if menu is present
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
scrollbar_T bottom_sbar; // Bottom scrollbar
|
|
|
|
int which_scrollbars[3];// Which scrollbar boxes are active?
|
|
|
|
int prev_wrap; // For updating the horizontal scrollbar
|
|
|
|
int char_width; // Width of char cell in pixels
|
|
|
|
int char_height; // Height of char cell in pixels, includes
|
|
|
|
// 'linespace'
|
|
|
|
int char_ascent; // Ascent of char in pixels
|
|
|
|
int border_width; // Width of our border around text area
|
|
|
|
int border_offset; // Total pixel offset for all borders
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
GuiFont norm_font; // Normal font
|
2010-06-26 05:38:18 +02:00
|
|
|
#ifndef FEAT_GUI_GTK
|
2019-11-30 19:44:38 +01:00
|
|
|
GuiFont bold_font; // Bold font
|
|
|
|
GuiFont ital_font; // Italic font
|
|
|
|
GuiFont boldital_font; // Bold-Italic font
|
2004-06-13 20:20:40 +00:00
|
|
|
#else
|
2019-11-30 19:44:38 +01:00
|
|
|
int font_can_bold; // Whether norm_font supports bold weight.
|
|
|
|
// The styled font variants are not used.
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2010-06-26 05:38:18 +02:00
|
|
|
#if defined(FEAT_MENU) && !defined(FEAT_GUI_GTK)
|
2004-06-13 20:20:40 +00:00
|
|
|
# ifdef FONTSET_ALWAYS
|
2019-11-30 19:44:38 +01:00
|
|
|
GuiFontset menu_fontset; // set of fonts for multi-byte chars
|
2004-06-13 20:20:40 +00:00
|
|
|
# else
|
2019-11-30 19:44:38 +01:00
|
|
|
GuiFont menu_font; // menu item font
|
2004-06-13 20:20:40 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
2019-11-30 19:44:38 +01:00
|
|
|
GuiFont wide_font; // Normal 'guifontwide' font
|
2019-01-24 17:18:42 +01:00
|
|
|
#ifndef FEAT_GUI_GTK
|
2019-11-30 19:44:38 +01:00
|
|
|
GuiFont wide_bold_font; // Bold 'guifontwide' font
|
|
|
|
GuiFont wide_ital_font; // Italic 'guifontwide' font
|
|
|
|
GuiFont wide_boldital_font; // Bold-Italic 'guifontwide' font
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
#ifdef FEAT_XFONTSET
|
2019-11-30 19:44:38 +01:00
|
|
|
GuiFontset fontset; // set of fonts for multi-byte chars
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
2019-11-30 19:44:38 +01:00
|
|
|
guicolor_T back_pixel; // Color of background
|
|
|
|
guicolor_T norm_pixel; // Color of normal text
|
|
|
|
guicolor_T def_back_pixel; // default Color of background
|
|
|
|
guicolor_T def_norm_pixel; // default Color of normal text
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
#ifdef FEAT_GUI_X11
|
2019-11-30 19:44:38 +01:00
|
|
|
char *rsrc_menu_fg_name; // Color of menu & dialog foreground
|
|
|
|
guicolor_T menu_fg_pixel; // Same in Pixel format
|
|
|
|
char *rsrc_menu_bg_name; // Color of menu & dialog background
|
|
|
|
guicolor_T menu_bg_pixel; // Same in Pixel format
|
|
|
|
char *rsrc_scroll_fg_name; // Color of scrollbar foreground
|
|
|
|
guicolor_T scroll_fg_pixel; // Same in Pixel format
|
|
|
|
char *rsrc_scroll_bg_name; // Color of scrollbar background
|
|
|
|
guicolor_T scroll_bg_pixel; // Same in Pixel format
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
Display *dpy; // X display
|
|
|
|
Window wid; // Window id of text area
|
|
|
|
int visibility; // Is shell partially/fully obscured?
|
2004-06-13 20:20:40 +00:00
|
|
|
GC text_gc;
|
|
|
|
GC back_gc;
|
|
|
|
GC invert_gc;
|
2019-11-30 19:44:38 +01:00
|
|
|
Cursor blank_pointer; // Blank pointer
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// X Resources
|
|
|
|
char_u *rsrc_font_name; // Resource font name, used if 'guifont'
|
|
|
|
// not set
|
|
|
|
char_u *rsrc_bold_font_name; // Resource bold font name
|
|
|
|
char_u *rsrc_ital_font_name; // Resource italic font name
|
|
|
|
char_u *rsrc_boldital_font_name; // Resource bold-italic font name
|
|
|
|
char_u *rsrc_menu_font_name; // Resource menu Font name
|
|
|
|
Bool rsrc_rev_video; // Use reverse video?
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
char_u *geom; // Geometry, eg "80x24"
|
|
|
|
Bool color_approx; // Some color was approximated
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FEAT_GUI_GTK
|
2016-02-23 17:14:37 +01:00
|
|
|
# ifndef USE_GTK3
|
2019-11-30 19:44:38 +01:00
|
|
|
int visibility; // Is shell partially/fully obscured?
|
2016-02-23 17:14:37 +01:00
|
|
|
# endif
|
2019-11-30 19:44:38 +01:00
|
|
|
GdkCursor *blank_pointer; // Blank pointer
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// X Resources
|
|
|
|
char_u *geom; // Geometry, eg "80x24"
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
GtkWidget *mainwin; // top level GTK window
|
|
|
|
GtkWidget *formwin; // manages all the windows below
|
|
|
|
GtkWidget *drawarea; // the "text" area
|
2004-06-13 20:20:40 +00:00
|
|
|
# ifdef FEAT_MENU
|
2019-11-30 19:44:38 +01:00
|
|
|
GtkWidget *menubar; // menubar
|
2004-06-13 20:20:40 +00:00
|
|
|
# endif
|
|
|
|
# ifdef FEAT_TOOLBAR
|
2019-11-30 19:44:38 +01:00
|
|
|
GtkWidget *toolbar; // toolbar
|
2004-06-13 20:20:40 +00:00
|
|
|
# endif
|
|
|
|
# ifdef FEAT_GUI_GNOME
|
2019-11-30 19:44:38 +01:00
|
|
|
GtkWidget *menubar_h; // menubar handle
|
|
|
|
GtkWidget *toolbar_h; // toolbar handle
|
2004-06-13 20:20:40 +00:00
|
|
|
# endif
|
2016-07-21 22:10:12 +02:00
|
|
|
# ifdef USE_GTK3
|
2019-11-30 19:44:38 +01:00
|
|
|
GdkRGBA *fgcolor; // GDK-styled foreground color
|
|
|
|
GdkRGBA *bgcolor; // GDK-styled background color
|
|
|
|
GdkRGBA *spcolor; // GDK-styled special color
|
2016-07-21 22:10:12 +02:00
|
|
|
# else
|
2019-11-30 19:44:38 +01:00
|
|
|
GdkColor *fgcolor; // GDK-styled foreground color
|
|
|
|
GdkColor *bgcolor; // GDK-styled background color
|
|
|
|
GdkColor *spcolor; // GDK-styled special color
|
2016-07-21 22:10:12 +02:00
|
|
|
# endif
|
2016-02-23 17:14:37 +01:00
|
|
|
# ifdef USE_GTK3
|
2019-11-30 19:44:38 +01:00
|
|
|
cairo_surface_t *surface; // drawarea surface
|
2016-02-23 17:14:37 +01:00
|
|
|
# else
|
2019-11-30 19:44:38 +01:00
|
|
|
GdkGC *text_gc; // cached GC for normal text
|
2016-02-23 17:14:37 +01:00
|
|
|
# endif
|
2019-11-30 19:44:38 +01:00
|
|
|
PangoContext *text_context; // the context used for all text
|
|
|
|
PangoFont *ascii_font; // cached font for ASCII strings
|
|
|
|
PangoGlyphString *ascii_glyphs; // cached code point -> glyph map
|
2006-03-06 23:29:24 +00:00
|
|
|
# ifdef FEAT_GUI_TABLINE
|
2019-11-30 19:44:38 +01:00
|
|
|
GtkWidget *tabline; // tab pages line handle
|
2004-06-13 20:20:40 +00:00
|
|
|
# endif
|
|
|
|
|
|
|
|
GtkAccelGroup *accel_group;
|
2019-11-30 19:44:38 +01:00
|
|
|
GtkWidget *filedlg; // file selection dialog
|
|
|
|
char_u *browse_fname; // file name from filedlg
|
2011-06-26 04:49:00 +02:00
|
|
|
|
|
|
|
guint32 event_time;
|
2024-02-24 14:26:52 +01:00
|
|
|
#endif // FEAT_GUI_GTK
|
2021-10-16 20:52:05 +01:00
|
|
|
|
2024-02-24 14:26:52 +01:00
|
|
|
#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)
|
2021-10-16 20:52:05 +01:00
|
|
|
char_u ligatures_map[256]; // ascii map for characters 0-255, value is
|
|
|
|
// 1 if in 'guiligatures'
|
2024-02-24 14:26:52 +01:00
|
|
|
#endif
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2006-04-25 22:13:59 +00:00
|
|
|
#if defined(FEAT_GUI_TABLINE) \
|
2019-02-17 17:44:42 +01:00
|
|
|
&& (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) \
|
2020-08-11 21:58:20 +02:00
|
|
|
|| defined(FEAT_GUI_HAIKU))
|
2006-04-25 22:13:59 +00:00
|
|
|
int tabline_height;
|
|
|
|
#endif
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
#if defined(FEAT_TOOLBAR) \
|
2022-04-03 18:02:37 +01:00
|
|
|
&& (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_HAIKU) || defined(FEAT_GUI_MSWIN))
|
2019-11-30 19:44:38 +01:00
|
|
|
int toolbar_height; // height of the toolbar
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FEAT_BEVAL_TIP
|
2019-11-30 19:44:38 +01:00
|
|
|
// Tooltip properties; also used for balloon evaluation
|
|
|
|
char_u *rsrc_tooltip_font_name; // tooltip font name
|
|
|
|
char *rsrc_tooltip_fg_name; // tooltip foreground color name
|
|
|
|
char *rsrc_tooltip_bg_name; // tooltip background color name
|
|
|
|
guicolor_T tooltip_fg_pixel; // tooltip foreground color
|
|
|
|
guicolor_T tooltip_bg_pixel; // tooltip background color
|
|
|
|
XFontSet tooltip_fontset; // tooltip fontset
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FEAT_GUI_MSWIN
|
2019-11-30 19:44:38 +01:00
|
|
|
GuiFont currFont; // Current font
|
|
|
|
guicolor_T currFgColor; // Current foreground text color
|
|
|
|
guicolor_T currBgColor; // Current background text color
|
|
|
|
guicolor_T currSpColor; // Current special text color
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
|
|
|
|
2020-02-26 16:16:53 +01:00
|
|
|
#ifdef FEAT_GUI_HAIKU
|
|
|
|
VimApp *vimApp;
|
|
|
|
VimWindow *vimWindow;
|
|
|
|
VimFormView *vimForm;
|
|
|
|
VimTextAreaView *vimTextArea;
|
|
|
|
int vdcmp; // Vim Direct Communication Message Port
|
|
|
|
#endif
|
|
|
|
|
2004-06-13 20:20:40 +00:00
|
|
|
#ifdef FEAT_GUI_PHOTON
|
2019-11-30 19:44:38 +01:00
|
|
|
PtWidget_t *vimWindow; // PtWindow
|
|
|
|
PtWidget_t *vimTextArea; // PtRaw
|
|
|
|
PtWidget_t *vimContainer; // PtPanel
|
2004-06-13 20:20:40 +00:00
|
|
|
# if defined(FEAT_MENU) || defined(FEAT_TOOLBAR)
|
|
|
|
PtWidget_t *vimToolBarGroup;
|
|
|
|
# endif
|
|
|
|
# ifdef FEAT_MENU
|
|
|
|
PtWidget_t *vimMenuBar;
|
|
|
|
# endif
|
|
|
|
# ifdef FEAT_TOOLBAR
|
|
|
|
PtWidget_t *vimToolBar;
|
|
|
|
int toolbar_height;
|
|
|
|
# endif
|
|
|
|
PhEvent_t *event_buffer;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FEAT_XIM
|
|
|
|
char *rsrc_input_method;
|
|
|
|
char *rsrc_preedit_type_name;
|
|
|
|
#endif
|
|
|
|
} gui_T;
|
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
extern gui_T gui; // this is defined in gui.c
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2019-11-30 19:44:38 +01:00
|
|
|
// definitions of available window positionings for gui_*_position_in_parent()
|
2004-06-13 20:20:40 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
VW_POS_MOUSE,
|
|
|
|
VW_POS_CENTER,
|
|
|
|
VW_POS_TOP_CENTER
|
2005-06-14 22:05:40 +00:00
|
|
|
} gui_win_pos_T;
|
2004-06-13 20:20:40 +00:00
|
|
|
|
2004-10-11 10:06:20 +00:00
|
|
|
#ifdef FIND_REPLACE_DIALOG
|
2004-06-13 20:20:40 +00:00
|
|
|
/*
|
|
|
|
* Flags used to distinguish the different contexts in which the
|
|
|
|
* find/replace callback may be called.
|
|
|
|
*/
|
2019-11-30 19:44:38 +01:00
|
|
|
# define FRD_FINDNEXT 1 // Find next in find dialog
|
|
|
|
# define FRD_R_FINDNEXT 2 // Find next in repl dialog
|
|
|
|
# define FRD_REPLACE 3 // Replace once
|
|
|
|
# define FRD_REPLACEALL 4 // Replace remaining matches
|
|
|
|
# define FRD_UNDO 5 // Undo replaced text
|
|
|
|
# define FRD_TYPE_MASK 7 // Mask for the callback type
|
|
|
|
// Flags which change the way searching is done.
|
|
|
|
# define FRD_WHOLE_WORD 0x08 // match whole word only
|
|
|
|
# define FRD_MATCH_CASE 0x10 // match case
|
2004-06-13 20:20:40 +00:00
|
|
|
#endif
|
2006-04-18 21:55:01 +00:00
|
|
|
|
2010-06-26 05:38:18 +02:00
|
|
|
#ifdef FEAT_GUI_GTK
|
2006-04-18 21:55:01 +00:00
|
|
|
/*
|
|
|
|
* Convenience macros to convert from 'encoding' to 'termencoding' and
|
|
|
|
* vice versa. If no conversion is necessary the passed-in pointer is
|
|
|
|
* returned as is, without allocating any memory. Thus additional _FREE()
|
|
|
|
* macros are provided. The _FREE() macros also set the pointer to NULL,
|
|
|
|
* in order to avoid bugs due to illegal memory access only happening if
|
|
|
|
* 'encoding' != utf-8...
|
|
|
|
*
|
|
|
|
* Defining these macros as pure expressions looks a bit tricky but
|
|
|
|
* avoids depending on the context of the macro expansion. One of the
|
|
|
|
* rare occasions where the comma operator comes in handy :)
|
|
|
|
*
|
|
|
|
* Note: Do NOT keep the result around when handling control back to
|
|
|
|
* the main Vim! The user could change 'encoding' at any time.
|
|
|
|
*/
|
|
|
|
# define CONVERT_TO_UTF8(String) \
|
|
|
|
((output_conv.vc_type == CONV_NONE || (String) == NULL) \
|
|
|
|
? (String) \
|
|
|
|
: string_convert(&output_conv, (String), NULL))
|
|
|
|
|
|
|
|
# define CONVERT_TO_UTF8_FREE(String) \
|
|
|
|
((String) = ((output_conv.vc_type == CONV_NONE) \
|
|
|
|
? (char_u *)NULL \
|
|
|
|
: (vim_free(String), (char_u *)NULL)))
|
|
|
|
|
|
|
|
# define CONVERT_FROM_UTF8(String) \
|
|
|
|
((input_conv.vc_type == CONV_NONE || (String) == NULL) \
|
|
|
|
? (String) \
|
|
|
|
: string_convert(&input_conv, (String), NULL))
|
|
|
|
|
|
|
|
# define CONVERT_FROM_UTF8_FREE(String) \
|
|
|
|
((String) = ((input_conv.vc_type == CONV_NONE) \
|
|
|
|
? (char_u *)NULL \
|
|
|
|
: (vim_free(String), (char_u *)NULL)))
|
|
|
|
|
|
|
|
#else
|
|
|
|
# define CONVERT_TO_UTF8(String) (String)
|
|
|
|
# define CONVERT_TO_UTF8_FREE(String) ((String) = (char_u *)NULL)
|
|
|
|
# define CONVERT_FROM_UTF8(String) (String)
|
|
|
|
# define CONVERT_FROM_UTF8_FREE(String) ((String) = (char_u *)NULL)
|
2019-11-30 19:44:38 +01:00
|
|
|
#endif // FEAT_GUI_GTK
|
2016-09-09 22:13:24 +02:00
|
|
|
|
|
|
|
#ifdef FEAT_GUI_GTK
|
|
|
|
/*
|
|
|
|
* The second parameter of g_signal_handlers_disconnect_by_func() is supposed
|
|
|
|
* to be a function pointer which was passed to g_signal_connect_*() somewhere
|
|
|
|
* previously, and hence it must be of type GCallback, i.e., void (*)(void).
|
|
|
|
*
|
|
|
|
* Meanwhile, g_signal_handlers_disconnect_by_func() is a macro calling
|
|
|
|
* g_signal_handlers_disconnect_matched(), and the second parameter of the
|
|
|
|
* former is to be passed to the sixth parameter of the latter the type of
|
|
|
|
* which, however, is declared as void * in the function signature.
|
|
|
|
*
|
|
|
|
* While the ISO C Standard does not require that function pointers be
|
|
|
|
* interconvertible to void *, widely-used compilers such as gcc and clang
|
|
|
|
* do such conversion implicitly and automatically on some platforms without
|
|
|
|
* issuing any warning.
|
|
|
|
*
|
|
|
|
* For Solaris Studio, that is not the case. An explicit type cast is needed
|
|
|
|
* to suppress warnings on that particular conversion.
|
|
|
|
*/
|
|
|
|
# if defined(__SUNPRO_C) && defined(USE_GTK3)
|
|
|
|
# define FUNC2GENERIC(func) (void *)(func)
|
|
|
|
# else
|
|
|
|
# define FUNC2GENERIC(func) G_CALLBACK(func)
|
|
|
|
# endif
|
2019-11-30 19:44:38 +01:00
|
|
|
#endif // FEAT_GUI_GTK
|
2018-05-05 21:01:00 +02:00
|
|
|
|
2020-08-11 21:58:20 +02:00
|
|
|
#if defined(UNIX)
|
2018-05-05 21:01:00 +02:00
|
|
|
# define GUI_MAY_FORK
|
|
|
|
#endif
|