xref: /vim-8.2.3635/src/gui.h (revision 9bf703d4)
1edf3f97aSBram Moolenaar /* vi:set ts=8 sts=4 sw=4 noet:
2071d4279SBram Moolenaar  *
3071d4279SBram Moolenaar  * VIM - Vi IMproved		by Bram Moolenaar
4071d4279SBram Moolenaar  *				Motif support by Robert Webb
5071d4279SBram Moolenaar  *
6071d4279SBram Moolenaar  * Do ":help uganda"  in Vim to read copying and usage conditions.
7071d4279SBram Moolenaar  * Do ":help credits" in Vim to see a list of people who contributed.
8071d4279SBram Moolenaar  */
9071d4279SBram Moolenaar 
10071d4279SBram Moolenaar #ifdef FEAT_GUI_MOTIF
11071d4279SBram Moolenaar # include <Xm/Xm.h>
12071d4279SBram Moolenaar #endif
13071d4279SBram Moolenaar 
14071d4279SBram Moolenaar #ifdef FEAT_GUI_ATHENA
15071d4279SBram Moolenaar # include <X11/Intrinsic.h>
16071d4279SBram Moolenaar # include <X11/StringDefs.h>
17071d4279SBram Moolenaar #endif
18071d4279SBram Moolenaar 
19071d4279SBram Moolenaar #ifdef FEAT_GUI_GTK
20*9bf703d4SBram Moolenaar # ifdef VMS // undef MIN and MAX because Intrinsic.h redefines them anyway
21f193fffdSBram Moolenaar #  ifdef MAX
22f193fffdSBram Moolenaar #   undef MAX
23f193fffdSBram Moolenaar #  endif
24f193fffdSBram Moolenaar #  ifdef MIN
25f193fffdSBram Moolenaar #   undef MIN
26f193fffdSBram Moolenaar #  endif
27f193fffdSBram Moolenaar # endif
28071d4279SBram Moolenaar # include <X11/Intrinsic.h>
29071d4279SBram Moolenaar # include <gtk/gtk.h>
30071d4279SBram Moolenaar #endif
31071d4279SBram Moolenaar 
32b7ed8399SBram Moolenaar // Needed when generating prototypes, since FEAT_GUI is always defined then.
33b7ed8399SBram Moolenaar #if defined(FEAT_XCLIPBOARD) && !defined(FEAT_GUI_MOTIF) \
34b7ed8399SBram Moolenaar 	&& !defined(FEAT_GUI_ATHENA) && !defined(FEAT_GUI_GTK)
35b7ed8399SBram Moolenaar # include <X11/Intrinsic.h>
36b7ed8399SBram Moolenaar #endif
37b7ed8399SBram Moolenaar 
38071d4279SBram Moolenaar #ifdef FEAT_GUI_MAC
39071d4279SBram Moolenaar # include <Types.h>
40071d4279SBram Moolenaar /*# include <Memory.h>*/
41071d4279SBram Moolenaar # include <Quickdraw.h>
42071d4279SBram Moolenaar # include <Fonts.h>
43071d4279SBram Moolenaar # include <Events.h>
44071d4279SBram Moolenaar # include <Menus.h>
45071d4279SBram Moolenaar # if !(defined (TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON))
46071d4279SBram Moolenaar #  include <Windows.h>
47071d4279SBram Moolenaar # endif
48071d4279SBram Moolenaar # include <Controls.h>
49071d4279SBram Moolenaar /*# include <TextEdit.h>*/
50071d4279SBram Moolenaar # include <Dialogs.h>
51071d4279SBram Moolenaar # include <OSUtils.h>
52071d4279SBram Moolenaar /*
53071d4279SBram Moolenaar # include <ToolUtils.h>
54071d4279SBram Moolenaar # include <SegLoad.h>*/
55071d4279SBram Moolenaar #endif
56071d4279SBram Moolenaar 
57071d4279SBram Moolenaar #ifdef FEAT_GUI_PHOTON
58071d4279SBram Moolenaar # include <Ph.h>
59071d4279SBram Moolenaar # include <Pt.h>
60071d4279SBram Moolenaar # include "photon/PxProto.h"
61071d4279SBram Moolenaar #endif
62071d4279SBram Moolenaar 
63071d4279SBram Moolenaar /*
64b5dd424dSBram Moolenaar  * On some systems scrolling needs to be done right away instead of in the
65b5dd424dSBram Moolenaar  * main loop.
66b5dd424dSBram Moolenaar  */
670eda7ac7SBram Moolenaar #if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_GTK)
68071d4279SBram Moolenaar # define USE_ON_FLY_SCROLL
69071d4279SBram Moolenaar #endif
70071d4279SBram Moolenaar 
71071d4279SBram Moolenaar /*
72071d4279SBram Moolenaar  * GUIs that support dropping files on a running Vim.
73071d4279SBram Moolenaar  */
7492d147beSBram Moolenaar #if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \
7592d147beSBram Moolenaar 	|| defined(FEAT_GUI_MSWIN) \
7692d147beSBram Moolenaar 	|| defined(FEAT_GUI_MAC)
77071d4279SBram Moolenaar # define HAVE_DROP_FILE
78071d4279SBram Moolenaar #endif
79071d4279SBram Moolenaar 
80071d4279SBram Moolenaar /*
81071d4279SBram Moolenaar  * This define makes menus always use a fontset.
82071d4279SBram Moolenaar  * We're not sure if this code always works, thus it can be disabled.
83071d4279SBram Moolenaar  */
84071d4279SBram Moolenaar #ifdef FEAT_XFONTSET
85071d4279SBram Moolenaar # define FONTSET_ALWAYS
86071d4279SBram Moolenaar #endif
87071d4279SBram Moolenaar 
88071d4279SBram Moolenaar /*
89071d4279SBram Moolenaar  * These macros convert between character row/column and pixel coordinates.
90071d4279SBram Moolenaar  * TEXT_X   - Convert character column into X pixel coord for drawing strings.
91071d4279SBram Moolenaar  * TEXT_Y   - Convert character row into Y pixel coord for drawing strings.
92071d4279SBram Moolenaar  * FILL_X   - Convert character column into X pixel coord for filling the area
93071d4279SBram Moolenaar  *		under the character.
94071d4279SBram Moolenaar  * FILL_Y   - Convert character row into Y pixel coord for filling the area
95071d4279SBram Moolenaar  *		under the character.
96071d4279SBram Moolenaar  * X_2_COL  - Convert X pixel coord into character column.
97071d4279SBram Moolenaar  * Y_2_ROW  - Convert Y pixel coord into character row.
98071d4279SBram Moolenaar  */
994f97475dSBram Moolenaar #ifdef FEAT_GUI_MSWIN
100071d4279SBram Moolenaar # define TEXT_X(col)	((col) * gui.char_width)
101071d4279SBram Moolenaar # define TEXT_Y(row)	((row) * gui.char_height + gui.char_ascent)
102071d4279SBram Moolenaar # define FILL_X(col)	((col) * gui.char_width)
103071d4279SBram Moolenaar # define FILL_Y(row)	((row) * gui.char_height)
104071d4279SBram Moolenaar # define X_2_COL(x)	((x) / gui.char_width)
105071d4279SBram Moolenaar # define Y_2_ROW(y)	((y) / gui.char_height)
106071d4279SBram Moolenaar #else
107071d4279SBram Moolenaar # define TEXT_X(col)	((col) * gui.char_width  + gui.border_offset)
108071d4279SBram Moolenaar # define FILL_X(col)	((col) * gui.char_width  + gui.border_offset)
109071d4279SBram Moolenaar # define X_2_COL(x)	(((x) - gui.border_offset) / gui.char_width)
110071d4279SBram Moolenaar # define TEXT_Y(row)	((row) * gui.char_height + gui.char_ascent \
111071d4279SBram Moolenaar 							+ gui.border_offset)
112071d4279SBram Moolenaar # define FILL_Y(row)	((row) * gui.char_height + gui.border_offset)
113071d4279SBram Moolenaar # define Y_2_ROW(y)	(((y) - gui.border_offset) / gui.char_height)
114071d4279SBram Moolenaar #endif
115071d4279SBram Moolenaar 
116*9bf703d4SBram Moolenaar // Indices for arrays of scrollbars
117071d4279SBram Moolenaar #define SBAR_NONE	    -1
118071d4279SBram Moolenaar #define SBAR_LEFT	    0
119071d4279SBram Moolenaar #define SBAR_RIGHT	    1
120071d4279SBram Moolenaar #define SBAR_BOTTOM	    2
121071d4279SBram Moolenaar 
122*9bf703d4SBram Moolenaar // Orientations for scrollbars
123071d4279SBram Moolenaar #define SBAR_VERT	    0
124071d4279SBram Moolenaar #define SBAR_HORIZ	    1
125071d4279SBram Moolenaar 
126*9bf703d4SBram Moolenaar // Default size of scrollbar
127071d4279SBram Moolenaar #define SB_DEFAULT_WIDTH    16
128071d4279SBram Moolenaar 
129*9bf703d4SBram Moolenaar // Default height of the menu bar
130*9bf703d4SBram Moolenaar #define MENU_DEFAULT_HEIGHT 1		// figure it out at runtime
131071d4279SBram Moolenaar 
132*9bf703d4SBram Moolenaar // Flags for gui_mch_outstr_nowrap()
133*9bf703d4SBram Moolenaar #define GUI_MON_WRAP_CURSOR	0x01	// wrap cursor at end of line
134*9bf703d4SBram Moolenaar #define GUI_MON_INVERT		0x02	// invert the characters
135*9bf703d4SBram Moolenaar #define GUI_MON_IS_CURSOR	0x04	// drawing cursor
136*9bf703d4SBram Moolenaar #define GUI_MON_TRS_CURSOR	0x08	// drawing transparent cursor
137*9bf703d4SBram Moolenaar #define GUI_MON_NOCLEAR		0x10	// don't clear selection
138071d4279SBram Moolenaar 
139*9bf703d4SBram Moolenaar // Flags for gui_mch_draw_string()
140*9bf703d4SBram Moolenaar #define DRAW_TRANSP		0x01	// draw with transparent bg
141*9bf703d4SBram Moolenaar #define DRAW_BOLD		0x02	// draw bold text
142*9bf703d4SBram Moolenaar #define DRAW_UNDERL		0x04	// draw underline text
143*9bf703d4SBram Moolenaar #define DRAW_UNDERC		0x08	// draw undercurl text
144e60acc18SBram Moolenaar #if defined(FEAT_GUI_GTK)
145*9bf703d4SBram Moolenaar # define DRAW_ITALIC		0x10	// draw italic text
146071d4279SBram Moolenaar #endif
147*9bf703d4SBram Moolenaar #define DRAW_CURSOR		0x20	// drawing block cursor (win32)
148*9bf703d4SBram Moolenaar #define DRAW_STRIKE		0x40	// strikethrough
149071d4279SBram Moolenaar 
150*9bf703d4SBram Moolenaar // For our own tearoff menu item
151071d4279SBram Moolenaar #define TEAR_STRING		"-->Detach"
152*9bf703d4SBram Moolenaar #define TEAR_LEN		(9)	// length of above string
153071d4279SBram Moolenaar 
154*9bf703d4SBram Moolenaar // for the toolbar
155071d4279SBram Moolenaar #define TOOLBAR_BUTTON_HEIGHT	18
156071d4279SBram Moolenaar #define TOOLBAR_BUTTON_WIDTH	18
157*9bf703d4SBram Moolenaar #define TOOLBAR_BORDER_HEIGHT	12  // room above+below buttons for MSWindows
158071d4279SBram Moolenaar 
1593991dab8SBram Moolenaar #ifdef FEAT_GUI_MSWIN
1602e2a2815SBram Moolenaar # define TABLINE_HEIGHT 22
1613991dab8SBram Moolenaar #endif
162910f66f9SBram Moolenaar #ifdef FEAT_GUI_MOTIF
163910f66f9SBram Moolenaar # define TABLINE_HEIGHT 30
164910f66f9SBram Moolenaar #endif
1653991dab8SBram Moolenaar 
1669372a11cSBram Moolenaar #if defined(NO_CONSOLE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
167*9bf703d4SBram Moolenaar # define NO_CONSOLE_INPUT	// use no_console_input() to check if there
168*9bf703d4SBram Moolenaar 				// is no console input possible
169071d4279SBram Moolenaar #endif
170071d4279SBram Moolenaar 
171071d4279SBram Moolenaar typedef struct GuiScrollbar
172071d4279SBram Moolenaar {
173*9bf703d4SBram Moolenaar     long	ident;		// Unique identifier for each scrollbar
174*9bf703d4SBram Moolenaar     win_T	*wp;		// Scrollbar's window, NULL for bottom
175*9bf703d4SBram Moolenaar     int		type;		// one of SBAR_{LEFT,RIGHT,BOTTOM}
176*9bf703d4SBram Moolenaar     long	value;		// Represents top line number visible
177071d4279SBram Moolenaar #ifdef FEAT_GUI_ATHENA
178*9bf703d4SBram Moolenaar     int		pixval;		// pixel count of value
179071d4279SBram Moolenaar #endif
180*9bf703d4SBram Moolenaar     long	size;		// Size of scrollbar thumb
181*9bf703d4SBram Moolenaar     long	max;		// Number of lines in buffer
182071d4279SBram Moolenaar 
183*9bf703d4SBram Moolenaar     // Values measured in characters:
184*9bf703d4SBram Moolenaar     int		top;		// Top of scroll bar (chars from row 0)
185*9bf703d4SBram Moolenaar     int		height;		// Current height of scroll bar in rows
186*9bf703d4SBram Moolenaar     int		width;		// Current width of scroll bar in cols
187*9bf703d4SBram Moolenaar     int		status_height;	// Height of status line
188071d4279SBram Moolenaar #ifdef FEAT_GUI_X11
189*9bf703d4SBram Moolenaar     Widget	id;		// Id of real scroll bar
190071d4279SBram Moolenaar #endif
191071d4279SBram Moolenaar #ifdef FEAT_GUI_GTK
192*9bf703d4SBram Moolenaar     GtkWidget *id;		// Id of real scroll bar
193*9bf703d4SBram Moolenaar     unsigned long handler_id;   // Id of "value_changed" signal handler
194071d4279SBram Moolenaar #endif
195071d4279SBram Moolenaar 
196071d4279SBram Moolenaar #ifdef FEAT_GUI_MSWIN
197*9bf703d4SBram Moolenaar     HWND	id;		// Id of real scroll bar
198*9bf703d4SBram Moolenaar     int		scroll_shift;	// The scrollbar stuff can handle only up to
199*9bf703d4SBram Moolenaar 				// 32767 lines.  When the file is longer,
200*9bf703d4SBram Moolenaar 				// scroll_shift is set to the number of shifts
201*9bf703d4SBram Moolenaar 				// to reduce the count.
202071d4279SBram Moolenaar #endif
203071d4279SBram Moolenaar #ifdef FEAT_GUI_MAC
204*9bf703d4SBram Moolenaar     ControlHandle id;		// A handle to the scrollbar
205071d4279SBram Moolenaar #endif
206071d4279SBram Moolenaar #ifdef FEAT_GUI_PHOTON
207071d4279SBram Moolenaar     PtWidget_t	*id;
208071d4279SBram Moolenaar #endif
209071d4279SBram Moolenaar } scrollbar_T;
210071d4279SBram Moolenaar 
211*9bf703d4SBram Moolenaar typedef long	    guicolor_T;	// handle for a GUI color; for X11 this should
212*9bf703d4SBram Moolenaar 				// be "Pixel", but that's an unsigned and we
213*9bf703d4SBram Moolenaar 				// need a signed value
214*9bf703d4SBram Moolenaar #define INVALCOLOR (guicolor_T)-11111	// number for invalid color; on 32 bit
215*9bf703d4SBram Moolenaar 				   // displays there is a tiny chance this is an
216*9bf703d4SBram Moolenaar 				   // actual color
217*9bf703d4SBram Moolenaar #define CTERMCOLOR (guicolor_T)-11110	// only used for cterm.bg_rgb and
218*9bf703d4SBram Moolenaar 					// cterm.fg_rgb: use cterm color
219071d4279SBram Moolenaar 
220071d4279SBram Moolenaar #ifdef FEAT_GUI_GTK
221*9bf703d4SBram Moolenaar   typedef PangoFontDescription	*GuiFont;       // handle for a GUI font
222*9bf703d4SBram Moolenaar   typedef PangoFontDescription  *GuiFontset;    // handle for a GUI fontset
223071d4279SBram Moolenaar # define NOFONT		(GuiFont)NULL
224071d4279SBram Moolenaar # define NOFONTSET	(GuiFontset)NULL
225071d4279SBram Moolenaar #else
226071d4279SBram Moolenaar # ifdef FEAT_GUI_PHOTON
227071d4279SBram Moolenaar   typedef char		*GuiFont;
228071d4279SBram Moolenaar   typedef char		*GuiFontset;
229071d4279SBram Moolenaar #  define NOFONT	(GuiFont)NULL
230071d4279SBram Moolenaar #  define NOFONTSET	(GuiFontset)NULL
231071d4279SBram Moolenaar # else
232071d4279SBram Moolenaar #  ifdef FEAT_GUI_X11
233*9bf703d4SBram Moolenaar   typedef XFontStruct	*GuiFont;	// handle for a GUI font
234*9bf703d4SBram Moolenaar   typedef XFontSet	GuiFontset;	// handle for a GUI fontset
235071d4279SBram Moolenaar #   define NOFONT	(GuiFont)0
236071d4279SBram Moolenaar #   define NOFONTSET	(GuiFontset)0
237071d4279SBram Moolenaar #  else
238*9bf703d4SBram Moolenaar   typedef long_u	GuiFont;	// handle for a GUI font
239*9bf703d4SBram Moolenaar   typedef long_u	GuiFontset;	// handle for a GUI fontset
240071d4279SBram Moolenaar #   define NOFONT	(GuiFont)0
241071d4279SBram Moolenaar #   define NOFONTSET	(GuiFontset)0
242071d4279SBram Moolenaar #  endif
243071d4279SBram Moolenaar # endif
244071d4279SBram Moolenaar #endif
245071d4279SBram Moolenaar 
246afde13b6SBram Moolenaar #ifdef VIMDLL
247afde13b6SBram Moolenaar // Use spawn when GUI is starting.
248afde13b6SBram Moolenaar # define GUI_MAY_SPAWN
249afde13b6SBram Moolenaar 
250afde13b6SBram Moolenaar // Uncomment the next definition if you want to use the `:gui` command on
251afde13b6SBram Moolenaar // Windows.  It uses `:mksession` to inherit the session from vim.exe to
252afde13b6SBram Moolenaar // gvim.exe.  So, it doesn't work perfectly. (EXPERIMENTAL)
253afde13b6SBram Moolenaar //# define EXPERIMENTAL_GUI_CMD
254afde13b6SBram Moolenaar #endif
255afde13b6SBram Moolenaar 
256071d4279SBram Moolenaar typedef struct Gui
257071d4279SBram Moolenaar {
258*9bf703d4SBram Moolenaar     int		in_focus;	    // Vim has input focus
259*9bf703d4SBram Moolenaar     int		in_use;		    // Is the GUI being used?
260*9bf703d4SBram Moolenaar     int		starting;	    // GUI will start in a little while
261*9bf703d4SBram Moolenaar     int		shell_created;	    // Has the shell been created yet?
262*9bf703d4SBram Moolenaar     int		dying;		    // Is vim dying? Then output to terminal
263*9bf703d4SBram Moolenaar     int		dofork;		    // Use fork() when GUI is starting
264afde13b6SBram Moolenaar #ifdef GUI_MAY_SPAWN
265*9bf703d4SBram Moolenaar     int		dospawn;	    // Use spawn() when GUI is starting
266afde13b6SBram Moolenaar #endif
267*9bf703d4SBram Moolenaar     int		dragged_sb;	    // Which scrollbar being dragged, if any?
268*9bf703d4SBram Moolenaar     win_T	*dragged_wp;	    // Which WIN's sb being dragged, if any?
269*9bf703d4SBram Moolenaar     int		pointer_hidden;	    // Is the mouse pointer hidden?
270*9bf703d4SBram Moolenaar     int		col;		    // Current cursor column in GUI display
271*9bf703d4SBram Moolenaar     int		row;		    // Current cursor row in GUI display
272*9bf703d4SBram Moolenaar     int		cursor_col;	    // Physical cursor column in GUI display
273*9bf703d4SBram Moolenaar     int		cursor_row;	    // Physical cursor row in GUI display
274*9bf703d4SBram Moolenaar     char	cursor_is_valid;    // There is a cursor at cursor_row/col
275*9bf703d4SBram Moolenaar     int		num_cols;	    // Number of columns
276*9bf703d4SBram Moolenaar     int		num_rows;	    // Number of rows
277*9bf703d4SBram Moolenaar     int		scroll_region_top;  // Top (first) line of scroll region
278*9bf703d4SBram Moolenaar     int		scroll_region_bot;  // Bottom (last) line of scroll region
279*9bf703d4SBram Moolenaar     int		scroll_region_left;  // Left (first) column of scroll region
280*9bf703d4SBram Moolenaar     int		scroll_region_right;  // Right (last) col. of scroll region
281*9bf703d4SBram Moolenaar     int		highlight_mask;	    // Highlight attribute mask
282*9bf703d4SBram Moolenaar     int		scrollbar_width;    // Width of vertical scrollbars
283*9bf703d4SBram Moolenaar     int		scrollbar_height;   // Height of horizontal scrollbar
284*9bf703d4SBram Moolenaar     int		left_sbar_x;	    // Calculated x coord for left scrollbar
285*9bf703d4SBram Moolenaar     int		right_sbar_x;	    // Calculated x coord for right scrollbar
286071d4279SBram Moolenaar 
287071d4279SBram Moolenaar #ifdef FEAT_MENU
288071d4279SBram Moolenaar # ifndef FEAT_GUI_GTK
289*9bf703d4SBram Moolenaar     int		menu_height;	    // Height of the menu bar
290*9bf703d4SBram Moolenaar     int		menu_width;	    // Width of the menu bar
291071d4279SBram Moolenaar # endif
292*9bf703d4SBram Moolenaar     char	menu_is_active;	    // TRUE if menu is present
293071d4279SBram Moolenaar # ifdef FEAT_GUI_ATHENA
294*9bf703d4SBram Moolenaar     char	menu_height_fixed;  // TRUE if menu height fixed
295071d4279SBram Moolenaar # endif
296071d4279SBram Moolenaar #endif
297071d4279SBram Moolenaar 
298*9bf703d4SBram Moolenaar     scrollbar_T bottom_sbar;	    // Bottom scrollbar
299*9bf703d4SBram Moolenaar     int		which_scrollbars[3];// Which scrollbar boxes are active?
300*9bf703d4SBram Moolenaar     int		prev_wrap;	    // For updating the horizontal scrollbar
301*9bf703d4SBram Moolenaar     int		char_width;	    // Width of char cell in pixels
302*9bf703d4SBram Moolenaar     int		char_height;	    // Height of char cell in pixels, includes
303*9bf703d4SBram Moolenaar 				    // 'linespace'
304*9bf703d4SBram Moolenaar     int		char_ascent;	    // Ascent of char in pixels
305*9bf703d4SBram Moolenaar     int		border_width;	    // Width of our border around text area
306*9bf703d4SBram Moolenaar     int		border_offset;	    // Total pixel offset for all borders
307071d4279SBram Moolenaar 
308*9bf703d4SBram Moolenaar     GuiFont	norm_font;	    // Normal font
3090eda7ac7SBram Moolenaar #ifndef FEAT_GUI_GTK
310*9bf703d4SBram Moolenaar     GuiFont	bold_font;	    // Bold font
311*9bf703d4SBram Moolenaar     GuiFont	ital_font;	    // Italic font
312*9bf703d4SBram Moolenaar     GuiFont	boldital_font;	    // Bold-Italic font
313071d4279SBram Moolenaar #else
314*9bf703d4SBram Moolenaar     int		font_can_bold;	    // Whether norm_font supports bold weight.
315*9bf703d4SBram Moolenaar 				    // The styled font variants are not used.
316071d4279SBram Moolenaar #endif
317071d4279SBram Moolenaar 
3180eda7ac7SBram Moolenaar #if defined(FEAT_MENU) && !defined(FEAT_GUI_GTK)
319071d4279SBram Moolenaar # ifdef FONTSET_ALWAYS
320*9bf703d4SBram Moolenaar     GuiFontset	menu_fontset;	    // set of fonts for multi-byte chars
321071d4279SBram Moolenaar # else
322*9bf703d4SBram Moolenaar     GuiFont	menu_font;	    // menu item font
323071d4279SBram Moolenaar # endif
324071d4279SBram Moolenaar #endif
325*9bf703d4SBram Moolenaar     GuiFont	wide_font;	    // Normal 'guifontwide' font
326db250526SBram Moolenaar #ifndef FEAT_GUI_GTK
327*9bf703d4SBram Moolenaar     GuiFont	wide_bold_font;	    // Bold 'guifontwide' font
328*9bf703d4SBram Moolenaar     GuiFont	wide_ital_font;	    // Italic 'guifontwide' font
329*9bf703d4SBram Moolenaar     GuiFont	wide_boldital_font; // Bold-Italic 'guifontwide' font
330db250526SBram Moolenaar #endif
331071d4279SBram Moolenaar #ifdef FEAT_XFONTSET
332*9bf703d4SBram Moolenaar     GuiFontset	fontset;	    // set of fonts for multi-byte chars
333071d4279SBram Moolenaar #endif
334*9bf703d4SBram Moolenaar     guicolor_T	back_pixel;	    // Color of background
335*9bf703d4SBram Moolenaar     guicolor_T	norm_pixel;	    // Color of normal text
336*9bf703d4SBram Moolenaar     guicolor_T	def_back_pixel;	    // default Color of background
337*9bf703d4SBram Moolenaar     guicolor_T	def_norm_pixel;	    // default Color of normal text
338071d4279SBram Moolenaar 
339071d4279SBram Moolenaar #ifdef FEAT_GUI_X11
340*9bf703d4SBram Moolenaar     char	*rsrc_menu_fg_name;	// Color of menu & dialog foreground
341*9bf703d4SBram Moolenaar     guicolor_T	menu_fg_pixel;		// Same in Pixel format
342*9bf703d4SBram Moolenaar     char	*rsrc_menu_bg_name;	// Color of menu & dialog background
343*9bf703d4SBram Moolenaar     guicolor_T	menu_bg_pixel;		// Same in Pixel format
344*9bf703d4SBram Moolenaar     char	*rsrc_scroll_fg_name;	// Color of scrollbar foreground
345*9bf703d4SBram Moolenaar     guicolor_T	scroll_fg_pixel;	// Same in Pixel format
346*9bf703d4SBram Moolenaar     char	*rsrc_scroll_bg_name;	// Color of scrollbar background
347*9bf703d4SBram Moolenaar     guicolor_T	scroll_bg_pixel;	// Same in Pixel format
348071d4279SBram Moolenaar 
349071d4279SBram Moolenaar # ifdef FEAT_GUI_MOTIF
350*9bf703d4SBram Moolenaar     guicolor_T	menu_def_fg_pixel;  // Default menu foreground
351*9bf703d4SBram Moolenaar     guicolor_T	menu_def_bg_pixel;  // Default menu background
352*9bf703d4SBram Moolenaar     guicolor_T	scroll_def_fg_pixel;  // Default scrollbar foreground
353*9bf703d4SBram Moolenaar     guicolor_T	scroll_def_bg_pixel;  // Default scrollbar background
354071d4279SBram Moolenaar # endif
355*9bf703d4SBram Moolenaar     Display	*dpy;		    // X display
356*9bf703d4SBram Moolenaar     Window	wid;		    // Window id of text area
357*9bf703d4SBram Moolenaar     int		visibility;	    // Is shell partially/fully obscured?
358071d4279SBram Moolenaar     GC		text_gc;
359071d4279SBram Moolenaar     GC		back_gc;
360071d4279SBram Moolenaar     GC		invert_gc;
361*9bf703d4SBram Moolenaar     Cursor	blank_pointer;	    // Blank pointer
362071d4279SBram Moolenaar 
363*9bf703d4SBram Moolenaar     // X Resources
364*9bf703d4SBram Moolenaar     char_u	*rsrc_font_name;    // Resource font name, used if 'guifont'
365*9bf703d4SBram Moolenaar 				    // not set
366*9bf703d4SBram Moolenaar     char_u	*rsrc_bold_font_name; // Resource bold font name
367*9bf703d4SBram Moolenaar     char_u	*rsrc_ital_font_name; // Resource italic font name
368*9bf703d4SBram Moolenaar     char_u	*rsrc_boldital_font_name;  // Resource bold-italic font name
369*9bf703d4SBram Moolenaar     char_u	*rsrc_menu_font_name;    // Resource menu Font name
370*9bf703d4SBram Moolenaar     Bool	rsrc_rev_video;	    // Use reverse video?
371071d4279SBram Moolenaar 
372*9bf703d4SBram Moolenaar     char_u	*geom;		    // Geometry, eg "80x24"
373*9bf703d4SBram Moolenaar     Bool	color_approx;	    // Some color was approximated
374071d4279SBram Moolenaar #endif
375071d4279SBram Moolenaar 
376071d4279SBram Moolenaar #ifdef FEAT_GUI_GTK
3779892189dSBram Moolenaar # ifndef USE_GTK3
378*9bf703d4SBram Moolenaar     int		visibility;	    // Is shell partially/fully obscured?
3799892189dSBram Moolenaar # endif
380*9bf703d4SBram Moolenaar     GdkCursor	*blank_pointer;	    // Blank pointer
381071d4279SBram Moolenaar 
382*9bf703d4SBram Moolenaar     // X Resources
383*9bf703d4SBram Moolenaar     char_u	*geom;		    // Geometry, eg "80x24"
384071d4279SBram Moolenaar 
385*9bf703d4SBram Moolenaar     GtkWidget	*mainwin;	    // top level GTK window
386*9bf703d4SBram Moolenaar     GtkWidget	*formwin;	    // manages all the windows below
387*9bf703d4SBram Moolenaar     GtkWidget	*drawarea;	    // the "text" area
388071d4279SBram Moolenaar # ifdef FEAT_MENU
389*9bf703d4SBram Moolenaar     GtkWidget	*menubar;	    // menubar
390071d4279SBram Moolenaar # endif
391071d4279SBram Moolenaar # ifdef FEAT_TOOLBAR
392*9bf703d4SBram Moolenaar     GtkWidget	*toolbar;	    // toolbar
393071d4279SBram Moolenaar # endif
394071d4279SBram Moolenaar # ifdef FEAT_GUI_GNOME
395*9bf703d4SBram Moolenaar     GtkWidget	*menubar_h;	    // menubar handle
396*9bf703d4SBram Moolenaar     GtkWidget	*toolbar_h;	    // toolbar handle
397071d4279SBram Moolenaar # endif
39836edf068SBram Moolenaar # ifdef USE_GTK3
399*9bf703d4SBram Moolenaar     GdkRGBA	*fgcolor;	    // GDK-styled foreground color
400*9bf703d4SBram Moolenaar     GdkRGBA	*bgcolor;	    // GDK-styled background color
401*9bf703d4SBram Moolenaar     GdkRGBA	*spcolor;	    // GDK-styled special color
40236edf068SBram Moolenaar # else
403*9bf703d4SBram Moolenaar     GdkColor	*fgcolor;	    // GDK-styled foreground color
404*9bf703d4SBram Moolenaar     GdkColor	*bgcolor;	    // GDK-styled background color
405*9bf703d4SBram Moolenaar     GdkColor	*spcolor;	    // GDK-styled special color
40636edf068SBram Moolenaar # endif
4079892189dSBram Moolenaar # ifdef USE_GTK3
408*9bf703d4SBram Moolenaar     cairo_surface_t *surface;       // drawarea surface
409*9bf703d4SBram Moolenaar     gboolean	     by_signal;     // cause of draw operation
4109892189dSBram Moolenaar # else
411*9bf703d4SBram Moolenaar     GdkGC	*text_gc;	    // cached GC for normal text
4129892189dSBram Moolenaar # endif
413*9bf703d4SBram Moolenaar     PangoContext     *text_context; // the context used for all text
414*9bf703d4SBram Moolenaar     PangoFont	     *ascii_font;   // cached font for ASCII strings
415*9bf703d4SBram Moolenaar     PangoGlyphString *ascii_glyphs; // cached code point -> glyph map
416362e1a30SBram Moolenaar # ifdef FEAT_GUI_TABLINE
417*9bf703d4SBram Moolenaar     GtkWidget	*tabline;	    // tab pages line handle
418071d4279SBram Moolenaar # endif
419071d4279SBram Moolenaar 
420071d4279SBram Moolenaar     GtkAccelGroup *accel_group;
421*9bf703d4SBram Moolenaar     GtkWidget	*filedlg;	    // file selection dialog
422*9bf703d4SBram Moolenaar     char_u	*browse_fname;	    // file name from filedlg
42320892c1eSBram Moolenaar 
42420892c1eSBram Moolenaar     guint32	event_time;
425*9bf703d4SBram Moolenaar #endif	// FEAT_GUI_GTK
426071d4279SBram Moolenaar 
427551dbcc9SBram Moolenaar #if defined(FEAT_GUI_TABLINE) \
4284f97475dSBram Moolenaar 	&& (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) \
42979ee315bSBram Moolenaar 		|| defined(FEAT_GUI_MAC))
430551dbcc9SBram Moolenaar     int		tabline_height;
431551dbcc9SBram Moolenaar #endif
432551dbcc9SBram Moolenaar 
433071d4279SBram Moolenaar #ifdef FEAT_FOOTER
434*9bf703d4SBram Moolenaar     int		footer_height;	    // height of the message footer
435071d4279SBram Moolenaar #endif
436071d4279SBram Moolenaar 
437071d4279SBram Moolenaar #if defined(FEAT_TOOLBAR) \
438071d4279SBram Moolenaar 	&& (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF))
439*9bf703d4SBram Moolenaar     int		toolbar_height;	    // height of the toolbar
440071d4279SBram Moolenaar #endif
441071d4279SBram Moolenaar 
442071d4279SBram Moolenaar #ifdef FEAT_BEVAL_TIP
443*9bf703d4SBram Moolenaar     // Tooltip properties; also used for balloon evaluation
444*9bf703d4SBram Moolenaar     char_u	*rsrc_tooltip_font_name; // tooltip font name
445*9bf703d4SBram Moolenaar     char	*rsrc_tooltip_fg_name;	// tooltip foreground color name
446*9bf703d4SBram Moolenaar     char	*rsrc_tooltip_bg_name;	// tooltip background color name
447*9bf703d4SBram Moolenaar     guicolor_T	tooltip_fg_pixel;	// tooltip foreground color
448*9bf703d4SBram Moolenaar     guicolor_T	tooltip_bg_pixel;	// tooltip background color
449*9bf703d4SBram Moolenaar     XFontSet	tooltip_fontset;	// tooltip fontset
450071d4279SBram Moolenaar #endif
451071d4279SBram Moolenaar 
452071d4279SBram Moolenaar #ifdef FEAT_GUI_MSWIN
453*9bf703d4SBram Moolenaar     GuiFont	currFont;	    // Current font
454*9bf703d4SBram Moolenaar     guicolor_T	currFgColor;	    // Current foreground text color
455*9bf703d4SBram Moolenaar     guicolor_T	currBgColor;	    // Current background text color
456*9bf703d4SBram Moolenaar     guicolor_T	currSpColor;	    // Current special text color
457071d4279SBram Moolenaar #endif
458071d4279SBram Moolenaar 
459071d4279SBram Moolenaar #ifdef FEAT_GUI_MAC
460071d4279SBram Moolenaar     WindowPtr	VimWindow;
461*9bf703d4SBram Moolenaar     MenuHandle	MacOSHelpMenu;	    // Help menu provided by the MacOS
462*9bf703d4SBram Moolenaar     int		MacOSHelpItems;	    // Nr of help-items supplied by MacOS
463*9bf703d4SBram Moolenaar     WindowPtr	wid;		    // Window id of text area
464*9bf703d4SBram Moolenaar     int		visibility;	    // Is window partially/fully obscured?
465071d4279SBram Moolenaar #endif
466071d4279SBram Moolenaar 
467071d4279SBram Moolenaar #ifdef FEAT_GUI_PHOTON
468*9bf703d4SBram Moolenaar     PtWidget_t	*vimWindow;		// PtWindow
469*9bf703d4SBram Moolenaar     PtWidget_t	*vimTextArea;		// PtRaw
470*9bf703d4SBram Moolenaar     PtWidget_t	*vimContainer;		// PtPanel
471071d4279SBram Moolenaar # if defined(FEAT_MENU) || defined(FEAT_TOOLBAR)
472071d4279SBram Moolenaar     PtWidget_t	*vimToolBarGroup;
473071d4279SBram Moolenaar # endif
474071d4279SBram Moolenaar # ifdef FEAT_MENU
475071d4279SBram Moolenaar     PtWidget_t	*vimMenuBar;
476071d4279SBram Moolenaar # endif
477071d4279SBram Moolenaar # ifdef FEAT_TOOLBAR
478071d4279SBram Moolenaar     PtWidget_t	*vimToolBar;
479071d4279SBram Moolenaar     int		toolbar_height;
480071d4279SBram Moolenaar # endif
481071d4279SBram Moolenaar     PhEvent_t	*event_buffer;
482071d4279SBram Moolenaar #endif
483071d4279SBram Moolenaar 
484071d4279SBram Moolenaar #ifdef FEAT_XIM
485071d4279SBram Moolenaar     char	*rsrc_input_method;
486071d4279SBram Moolenaar     char	*rsrc_preedit_type_name;
487071d4279SBram Moolenaar #endif
488071d4279SBram Moolenaar } gui_T;
489071d4279SBram Moolenaar 
490*9bf703d4SBram Moolenaar extern gui_T gui;			// this is defined in gui.c
491071d4279SBram Moolenaar 
492*9bf703d4SBram Moolenaar // definitions of available window positionings for gui_*_position_in_parent()
493071d4279SBram Moolenaar typedef enum
494071d4279SBram Moolenaar {
495071d4279SBram Moolenaar     VW_POS_MOUSE,
496071d4279SBram Moolenaar     VW_POS_CENTER,
497071d4279SBram Moolenaar     VW_POS_TOP_CENTER
4988348ea62SBram Moolenaar } gui_win_pos_T;
499071d4279SBram Moolenaar 
5007171abeaSBram Moolenaar #ifdef FIND_REPLACE_DIALOG
501071d4279SBram Moolenaar /*
502071d4279SBram Moolenaar  * Flags used to distinguish the different contexts in which the
503071d4279SBram Moolenaar  * find/replace callback may be called.
504071d4279SBram Moolenaar  */
505*9bf703d4SBram Moolenaar # define FRD_FINDNEXT	1	// Find next in find dialog
506*9bf703d4SBram Moolenaar # define FRD_R_FINDNEXT	2	// Find next in repl dialog
507*9bf703d4SBram Moolenaar # define FRD_REPLACE	3	// Replace once
508*9bf703d4SBram Moolenaar # define FRD_REPLACEALL	4	// Replace remaining matches
509*9bf703d4SBram Moolenaar # define FRD_UNDO	5	// Undo replaced text
510*9bf703d4SBram Moolenaar # define FRD_TYPE_MASK   7	// Mask for the callback type
511*9bf703d4SBram Moolenaar // Flags which change the way searching is done.
512*9bf703d4SBram Moolenaar # define FRD_WHOLE_WORD	0x08	// match whole word only
513*9bf703d4SBram Moolenaar # define FRD_MATCH_CASE	0x10	// match case
514071d4279SBram Moolenaar #endif
515c1e37901SBram Moolenaar 
5160eda7ac7SBram Moolenaar #ifdef FEAT_GUI_GTK
517c1e37901SBram Moolenaar /*
518c1e37901SBram Moolenaar  * Convenience macros to convert from 'encoding' to 'termencoding' and
519c1e37901SBram Moolenaar  * vice versa.	If no conversion is necessary the passed-in pointer is
520c1e37901SBram Moolenaar  * returned as is, without allocating any memory.  Thus additional _FREE()
521c1e37901SBram Moolenaar  * macros are provided.  The _FREE() macros also set the pointer to NULL,
522c1e37901SBram Moolenaar  * in order to avoid bugs due to illegal memory access only happening if
523c1e37901SBram Moolenaar  * 'encoding' != utf-8...
524c1e37901SBram Moolenaar  *
525c1e37901SBram Moolenaar  * Defining these macros as pure expressions looks a bit tricky but
526c1e37901SBram Moolenaar  * avoids depending on the context of the macro expansion.  One of the
527c1e37901SBram Moolenaar  * rare occasions where the comma operator comes in handy :)
528c1e37901SBram Moolenaar  *
529c1e37901SBram Moolenaar  * Note: Do NOT keep the result around when handling control back to
530c1e37901SBram Moolenaar  * the main Vim!  The user could change 'encoding' at any time.
531c1e37901SBram Moolenaar  */
532c1e37901SBram Moolenaar # define CONVERT_TO_UTF8(String)				\
533c1e37901SBram Moolenaar     ((output_conv.vc_type == CONV_NONE || (String) == NULL)	\
534c1e37901SBram Moolenaar 	    ? (String)						\
535c1e37901SBram Moolenaar 	    : string_convert(&output_conv, (String), NULL))
536c1e37901SBram Moolenaar 
537c1e37901SBram Moolenaar # define CONVERT_TO_UTF8_FREE(String)				\
538c1e37901SBram Moolenaar     ((String) = ((output_conv.vc_type == CONV_NONE)		\
539c1e37901SBram Moolenaar 			? (char_u *)NULL			\
540c1e37901SBram Moolenaar 			: (vim_free(String), (char_u *)NULL)))
541c1e37901SBram Moolenaar 
542c1e37901SBram Moolenaar # define CONVERT_FROM_UTF8(String)				\
543c1e37901SBram Moolenaar     ((input_conv.vc_type == CONV_NONE || (String) == NULL)	\
544c1e37901SBram Moolenaar 	    ? (String)						\
545c1e37901SBram Moolenaar 	    : string_convert(&input_conv, (String), NULL))
546c1e37901SBram Moolenaar 
547c1e37901SBram Moolenaar # define CONVERT_FROM_UTF8_FREE(String)				\
548c1e37901SBram Moolenaar     ((String) = ((input_conv.vc_type == CONV_NONE)		\
549c1e37901SBram Moolenaar 			? (char_u *)NULL			\
550c1e37901SBram Moolenaar 			: (vim_free(String), (char_u *)NULL)))
551c1e37901SBram Moolenaar 
552c1e37901SBram Moolenaar #else
553c1e37901SBram Moolenaar # define CONVERT_TO_UTF8(String) (String)
554c1e37901SBram Moolenaar # define CONVERT_TO_UTF8_FREE(String) ((String) = (char_u *)NULL)
555c1e37901SBram Moolenaar # define CONVERT_FROM_UTF8(String) (String)
556c1e37901SBram Moolenaar # define CONVERT_FROM_UTF8_FREE(String) ((String) = (char_u *)NULL)
557*9bf703d4SBram Moolenaar #endif // FEAT_GUI_GTK
558d47d8374SBram Moolenaar 
559d47d8374SBram Moolenaar #ifdef FEAT_GUI_GTK
560d47d8374SBram Moolenaar /*
561d47d8374SBram Moolenaar  * The second parameter of g_signal_handlers_disconnect_by_func() is supposed
562d47d8374SBram Moolenaar  * to be a function pointer which was passed to g_signal_connect_*() somewhere
563d47d8374SBram Moolenaar  * previously, and hence it must be of type GCallback, i.e., void (*)(void).
564d47d8374SBram Moolenaar  *
565d47d8374SBram Moolenaar  * Meanwhile, g_signal_handlers_disconnect_by_func() is a macro calling
566d47d8374SBram Moolenaar  * g_signal_handlers_disconnect_matched(), and the second parameter of the
567d47d8374SBram Moolenaar  * former is to be passed to the sixth parameter of the latter the type of
568d47d8374SBram Moolenaar  * which, however, is declared as void * in the function signature.
569d47d8374SBram Moolenaar  *
570d47d8374SBram Moolenaar  * While the ISO C Standard does not require that function pointers be
571d47d8374SBram Moolenaar  * interconvertible to void *, widely-used compilers such as gcc and clang
572d47d8374SBram Moolenaar  * do such conversion implicitly and automatically on some platforms without
573d47d8374SBram Moolenaar  * issuing any warning.
574d47d8374SBram Moolenaar  *
575d47d8374SBram Moolenaar  * For Solaris Studio, that is not the case.  An explicit type cast is needed
576d47d8374SBram Moolenaar  * to suppress warnings on that particular conversion.
577d47d8374SBram Moolenaar  */
578d47d8374SBram Moolenaar # if defined(__SUNPRO_C) && defined(USE_GTK3)
579d47d8374SBram Moolenaar #  define FUNC2GENERIC(func) (void *)(func)
580d47d8374SBram Moolenaar # else
581d47d8374SBram Moolenaar #  define FUNC2GENERIC(func) G_CALLBACK(func)
582d47d8374SBram Moolenaar # endif
583*9bf703d4SBram Moolenaar #endif // FEAT_GUI_GTK
584b0b98d52SBram Moolenaar 
585b0b98d52SBram Moolenaar #if defined(UNIX) && !defined(FEAT_GUI_MAC)
586b0b98d52SBram Moolenaar # define GUI_MAY_FORK
587b0b98d52SBram Moolenaar #endif
588