Mercurial > vim
annotate src/gui_photon.c @ 27006:686fa1164724 v8.2.4032
patch 8.2.4032: ATTRIBUTE_NORETURN is not needed
Commit: https://github.com/vim/vim/commit/e12406526a24768e6121450112eb2f9f92445ac5
Author: ichizok <gclient.gaap@gmail.com>
Date: Fri Jan 7 20:01:07 2022 +0000
patch 8.2.4032: ATTRIBUTE_NORETURN is not needed
Problem: ATTRIBUTE_NORETURN is not needed.
Solution: Use NORETURN(). (Ozaki Kiichi, closes https://github.com/vim/vim/issues/9487)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 07 Jan 2022 21:15:03 +0100 |
parents | bce848ec8b1b |
children | e5ee2ffd826a |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9939
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * Photon GUI support by Julian Kinraid | |
5 * | |
6 * Do ":help uganda" in Vim to read copying and usage conditions. | |
7 * Do ":help credits" in Vim to see a list of people who contributed. | |
8 * | |
9 * | |
10 * Clipboard support is in os_qnx.c | |
11 * PhAttach() is called in os_qnx.c:qnx_init() | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
16 // cproto fails on missing include files |
3927 | 17 #ifndef PROTO |
18 # ifdef FEAT_TOOLBAR | |
19 # include <photon/PxImage.h> | |
20 # endif | |
7 | 21 #endif |
22 | |
23 #if !defined(__QNX__) | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
24 // Used when generating prototypes. |
7 | 25 # define PgColor_t int |
26 # define PhEvent_t int | |
27 # define PhPoint_t int | |
28 # define PtWidget_t int | |
29 # define Pg_BLACK 0 | |
30 # define PtCallbackF_t int | |
31 # define PtCallbackInfo_t int | |
32 # define PhTile_t int | |
33 # define PtWidget_t int | |
34 # define PhImage_t int | |
35 #endif | |
36 | |
2980 | 37 #define RGB(r, g, b) PgRGB(r, g, b) |
38 | |
39 #define EVENT_BUFFER_SIZE sizeof(PhEvent_t) + 1000 | |
7 | 40 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
41 // Some defines for gui_mch_mousehide() |
7 | 42 #define MOUSE_HIDE TRUE |
43 #define MOUSE_SHOW FALSE | |
44 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
45 // Optional support for using a PtPanelGroup widget, needs work |
7 | 46 #undef USE_PANEL_GROUP |
47 | |
48 #ifdef USE_PANEL_GROUP | |
49 static char *empty_title = " "; | |
50 static char **panel_titles = NULL; | |
51 static ushort_t num_panels = 0; | |
52 static short pg_margin_left, pg_margin_right, pg_margin_top, pg_margin_bottom; | |
53 #endif | |
54 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
55 #define GUI_PH_MARGIN 4 // Size of the bevel |
7 | 56 |
57 #define GUI_PH_MOUSE_TYPE Ph_CURSOR_INSERT | |
58 static PgColor_t gui_ph_mouse_color = Pg_BLACK; | |
59 | |
60 static PhPoint_t gui_ph_raw_offset; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
61 static PtWidget_t *gui_ph_timer_cursor; // handle cursor blinking |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
62 static PtWidget_t *gui_ph_timer_timeout; // used in gui_mch_wait_for_chars |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
63 static short is_timeout; // Has the timeout occurred? |
7 | 64 |
65 /* | |
66 * This is set inside the mouse callback for a right mouse | |
67 * button click, and used for the popup menus | |
68 */ | |
69 static PhPoint_t abs_mouse; | |
70 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
71 // Try and avoid redraws while a resize is in progress |
7 | 72 static int is_ignore_draw = FALSE; |
73 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
74 // Used for converting to/from utf-8 and other charsets |
7 | 75 static struct PxTransCtrl *charset_translate; |
76 | |
77 /* | |
78 * Cursor blink functions. | |
79 * | |
80 * This is a simple state machine: | |
81 * BLINK_NONE not blinking at all | |
82 * BLINK_OFF blinking, cursor is not shown | |
83 * BLINK_ON blinking, cursor is shown | |
84 */ | |
85 static enum { | |
86 BLINK_NONE, | |
87 BLINK_OFF, | |
88 BLINK_ON | |
89 } blink_state = BLINK_NONE; | |
90 | |
91 static long_u blink_waittime = 700; | |
92 static long_u blink_ontime = 400; | |
93 static long_u blink_offtime = 250; | |
94 | |
95 static struct | |
96 { | |
97 int key_sym; | |
98 char_u vim_code0; | |
99 char_u vim_code1; | |
100 } special_keys[] = | |
101 { | |
102 {Pk_Up, 'k', 'u'}, | |
103 {Pk_Down, 'k', 'd'}, | |
104 {Pk_Left, 'k', 'l'}, | |
105 {Pk_Right, 'k', 'r'}, | |
106 | |
107 {Pk_F1, 'k', '1'}, | |
108 {Pk_F2, 'k', '2'}, | |
109 {Pk_F3, 'k', '3'}, | |
110 {Pk_F4, 'k', '4'}, | |
111 {Pk_F5, 'k', '5'}, | |
112 {Pk_F6, 'k', '6'}, | |
113 {Pk_F7, 'k', '7'}, | |
114 {Pk_F8, 'k', '8'}, | |
115 {Pk_F9, 'k', '9'}, | |
116 {Pk_F10, 'k', ';'}, | |
117 | |
118 {Pk_F11, 'F', '1'}, | |
119 {Pk_F12, 'F', '2'}, | |
120 {Pk_F13, 'F', '3'}, | |
121 {Pk_F14, 'F', '4'}, | |
122 {Pk_F15, 'F', '5'}, | |
123 {Pk_F16, 'F', '6'}, | |
124 {Pk_F17, 'F', '7'}, | |
125 {Pk_F18, 'F', '8'}, | |
126 {Pk_F19, 'F', '9'}, | |
127 {Pk_F20, 'F', 'A'}, | |
128 | |
129 {Pk_F21, 'F', 'B'}, | |
130 {Pk_F22, 'F', 'C'}, | |
131 {Pk_F23, 'F', 'D'}, | |
132 {Pk_F24, 'F', 'E'}, | |
133 {Pk_F25, 'F', 'F'}, | |
134 {Pk_F26, 'F', 'G'}, | |
135 {Pk_F27, 'F', 'H'}, | |
136 {Pk_F28, 'F', 'I'}, | |
137 {Pk_F29, 'F', 'J'}, | |
138 | |
139 {Pk_F30, 'F', 'K'}, | |
140 {Pk_F31, 'F', 'L'}, | |
141 {Pk_F32, 'F', 'M'}, | |
142 {Pk_F33, 'F', 'N'}, | |
143 {Pk_F34, 'F', 'O'}, | |
144 {Pk_F35, 'F', 'P'}, | |
145 | |
146 {Pk_Help, '%', '1'}, | |
147 {Pk_BackSpace, 'k', 'b'}, | |
148 {Pk_Insert, 'k', 'I'}, | |
149 {Pk_Delete, 'k', 'D'}, | |
150 {Pk_Home, 'k', 'h'}, | |
151 {Pk_End, '@', '7'}, | |
152 {Pk_Prior, 'k', 'P'}, | |
153 {Pk_Next, 'k', 'N'}, | |
154 {Pk_Print, '%', '9'}, | |
155 | |
156 {Pk_KP_Add, 'K', '6'}, | |
157 {Pk_KP_Subtract,'K', '7'}, | |
158 {Pk_KP_Divide, 'K', '8'}, | |
159 {Pk_KP_Multiply,'K', '9'}, | |
160 {Pk_KP_Enter, 'K', 'A'}, | |
161 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
162 {Pk_KP_0, KS_EXTRA, KE_KINS}, // Insert |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
163 {Pk_KP_Decimal, KS_EXTRA, KE_KDEL}, // Delete |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
164 |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
165 {Pk_KP_4, 'k', 'l'}, // Left |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
166 {Pk_KP_6, 'k', 'r'}, // Right |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
167 {Pk_KP_8, 'k', 'u'}, // Up |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
168 {Pk_KP_2, 'k', 'd'}, // Down |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
169 |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
170 {Pk_KP_7, 'K', '1'}, // Home |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
171 {Pk_KP_1, 'K', '4'}, // End |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
172 |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
173 {Pk_KP_9, 'K', '3'}, // Page Up |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
174 {Pk_KP_3, 'K', '5'}, // Page Down |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
175 |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
176 {Pk_KP_5, '&', '8'}, // Undo |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
177 |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
178 // Keys that we want to be able to use any modifier with: |
7 | 179 {Pk_Return, CAR, NUL}, |
180 {Pk_space, ' ', NUL}, | |
181 {Pk_Tab, TAB, NUL}, | |
182 {Pk_Escape, ESC, NUL}, | |
183 {NL, NL, NUL}, | |
184 {CAR, CAR, NUL}, | |
185 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
186 // End of list marker: |
7 | 187 {0, 0, 0} |
188 }; | |
189 | |
190 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
191 //////////////////////////////////////////////////////////////////////////// |
7 | 192 |
193 static PtCallbackF_t gui_ph_handle_timer_cursor; | |
194 static PtCallbackF_t gui_ph_handle_timer_timeout; | |
195 | |
196 static PtCallbackF_t gui_ph_handle_window_cb; | |
197 | |
198 static PtCallbackF_t gui_ph_handle_scrollbar; | |
199 static PtCallbackF_t gui_ph_handle_keyboard; | |
200 static PtCallbackF_t gui_ph_handle_mouse; | |
201 static PtCallbackF_t gui_ph_handle_pulldown_menu; | |
202 static PtCallbackF_t gui_ph_handle_menu; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
203 static PtCallbackF_t gui_ph_handle_focus; // focus change of text area |
7 | 204 |
205 static PtCallbackF_t gui_ph_handle_menu_resize; | |
206 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
207 // When a menu is unrealized, give focus back to vimTextArea |
7 | 208 static PtCallbackF_t gui_ph_handle_menu_unrealized; |
209 | |
210 #ifdef USE_PANEL_GROUP | |
2980 | 211 static void gui_ph_get_panelgroup_margins(short*, short*, short*, short*); |
7 | 212 #endif |
213 | |
2980 | 214 static void gui_ph_draw_start(void); |
215 static void gui_ph_draw_end(void); | |
7 | 216 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
217 // Set the text for the balloon |
2980 | 218 static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window, |
7 | 219 PtWidget_t *widget, |
220 int position, | |
221 char *text, | |
222 char *font, | |
223 PgColor_t fill_color, | |
2980 | 224 PgColor_t text_color); |
7 | 225 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
226 //////////////////////////////////////////////////////////////////////////// |
7 | 227 |
2980 | 228 static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window, |
7 | 229 PtWidget_t *widget, |
230 int position, | |
231 char *text, | |
232 char *font, | |
233 PgColor_t fill_color, | |
2980 | 234 PgColor_t text_color) |
7 | 235 { |
236 PtArg_t arg; | |
237 vimmenu_T *menu; | |
238 char_u *tooltip; | |
239 | |
2980 | 240 PtSetArg(&arg, Pt_ARG_POINTER, &menu, 0); |
241 PtGetResources(widget, 1, &arg); | |
7 | 242 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
243 // Override the text and position |
7 | 244 |
245 tooltip = text; | |
2980 | 246 if (menu != NULL) |
7 | 247 { |
248 int index = MENU_INDEX_TIP; | |
2980 | 249 if (menu->strings[ index ] != NULL) |
7 | 250 tooltip = menu->strings[ index ]; |
251 } | |
252 | |
2980 | 253 return PtInflateBalloon( |
7 | 254 window, |
255 widget, | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
256 // Don't put the balloon at the bottom, |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
257 // it gets drawn over by gfx done in the PtRaw |
7 | 258 Pt_BALLOON_TOP, |
259 tooltip, | |
260 font, | |
261 fill_color, | |
2980 | 262 text_color); |
7 | 263 } |
264 | |
265 static void | |
2980 | 266 gui_ph_resize_container(void) |
7 | 267 { |
268 PhArea_t area; | |
269 | |
2980 | 270 PtWidgetArea(gui.vimWindow, &area); |
271 PtWidgetPos (gui.vimContainer, &area.pos); | |
272 | |
273 PtSetResource(gui.vimContainer, Pt_ARG_AREA, &area, 0); | |
7 | 274 } |
275 | |
276 static int | |
277 gui_ph_handle_menu_resize( | |
278 PtWidget_t *widget, | |
279 void *other, | |
2980 | 280 PtCallbackInfo_t *info) |
7 | 281 { |
282 PtContainerCallback_t *sizes = info->cbdata; | |
283 PtWidget_t *container; | |
284 PhPoint_t below_menu; | |
285 int_u height; | |
286 | |
287 height = sizes->new_dim.h; | |
288 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
289 // Because vim treats the toolbar and menubar separately, |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
290 // and here they're lumped together into a PtToolbarGroup, |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
291 // we only need either menu_height or toolbar_height set at once |
2980 | 292 if (gui.menu_is_active) |
7 | 293 { |
294 gui.menu_height = height; | |
295 gui.toolbar_height = 0; | |
296 } | |
297 #ifdef FEAT_TOOLBAR | |
298 else | |
299 gui.toolbar_height = height; | |
300 #endif | |
301 | |
302 below_menu.x = 0; | |
303 below_menu.y = height; | |
304 | |
305 #ifdef USE_PANEL_GROUP | |
306 container = gui.vimPanelGroup; | |
307 #else | |
308 container = gui.vimContainer; | |
309 #endif | |
310 | |
2980 | 311 PtSetResource(container, Pt_ARG_POS, &below_menu, 0); |
7 | 312 |
313 gui_ph_resize_container(); | |
314 | |
315 #ifdef USE_PANEL_GROUP | |
316 gui_ph_get_panelgroup_margins( | |
317 &pg_margin_top, &pg_margin_bottom, | |
2980 | 318 &pg_margin_left, &pg_margin_right); |
7 | 319 #endif |
2980 | 320 return Pt_CONTINUE; |
7 | 321 } |
322 | |
323 /* | |
324 * Pt_ARG_TIMER_REPEAT isn't used because the on & off times | |
325 * are different | |
326 */ | |
327 static int | |
328 gui_ph_handle_timer_cursor( | |
329 PtWidget_t *widget, | |
330 void *data, | |
2980 | 331 PtCallbackInfo_t *info) |
7 | 332 { |
2980 | 333 if (blink_state == BLINK_ON) |
7 | 334 { |
335 gui_undraw_cursor(); | |
336 blink_state = BLINK_OFF; | |
2980 | 337 PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, |
338 blink_offtime, 0); | |
7 | 339 } |
340 else | |
341 { | |
342 gui_update_cursor(TRUE, FALSE); | |
343 blink_state = BLINK_ON; | |
2980 | 344 PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, |
345 blink_ontime, 0); | |
7 | 346 } |
2980 | 347 return Pt_CONTINUE; |
7 | 348 } |
349 | |
350 static int | |
351 gui_ph_handle_timer_timeout(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) | |
352 { | |
353 is_timeout = TRUE; | |
354 | |
2980 | 355 return Pt_CONTINUE; |
7 | 356 } |
357 | |
358 static int | |
2998 | 359 gui_ph_handle_window_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 360 { |
361 PhWindowEvent_t *we = info->cbdata; | |
362 ushort_t *width, *height; | |
363 | |
2998 | 364 switch (we->event_f) { |
7 | 365 case Ph_WM_CLOSE: |
366 gui_shell_closed(); | |
367 break; | |
368 | |
369 case Ph_WM_FOCUS: | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
370 // Just in case it's hidden and needs to be shown |
2998 | 371 gui_mch_mousehide(MOUSE_SHOW); |
372 | |
373 if (we->event_state == Ph_WM_EVSTATE_FOCUS) | |
7 | 374 { |
375 gui_focus_change(TRUE); | |
376 gui_mch_start_blink(); | |
377 } | |
378 else | |
379 { | |
380 gui_focus_change(FALSE); | |
13152
f4c3a7f410f4
patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
381 gui_mch_stop_blink(TRUE); |
7 | 382 } |
383 break; | |
384 | |
385 case Ph_WM_RESIZE: | |
2998 | 386 PtGetResource(gui.vimWindow, Pt_ARG_WIDTH, &width, 0); |
387 PtGetResource(gui.vimWindow, Pt_ARG_HEIGHT, &height, 0); | |
7 | 388 #ifdef USE_PANEL_GROUP |
389 width -= (pg_margin_left + pg_margin_right); | |
390 height -= (pg_margin_top + pg_margin_bottom); | |
391 #endif | |
2998 | 392 gui_resize_shell(*width, *height); |
393 gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH); | |
7 | 394 is_ignore_draw = FALSE; |
2998 | 395 PtEndFlux(gui.vimContainer); |
396 PtContainerRelease(gui.vimContainer); | |
7 | 397 break; |
398 | |
399 default: | |
400 break; | |
401 } | |
402 | |
2980 | 403 return Pt_CONTINUE; |
7 | 404 } |
405 | |
406 static int | |
2998 | 407 gui_ph_handle_scrollbar(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 408 { |
409 PtScrollbarCallback_t *scroll; | |
410 scrollbar_T *sb; | |
411 int value, dragging = FALSE; | |
412 | |
413 scroll = info->cbdata; | |
414 | |
415 sb = (scrollbar_T *) data; | |
2998 | 416 if (sb != NULL) |
7 | 417 { |
418 value = scroll->position; | |
2998 | 419 switch (scroll->action) |
7 | 420 { |
421 case Pt_SCROLL_DRAGGED: | |
422 dragging = TRUE; | |
423 break; | |
424 | |
425 case Pt_SCROLL_SET: | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
426 // FIXME: return straight away here? |
2980 | 427 return Pt_CONTINUE; |
7 | 428 break; |
429 } | |
430 | |
431 gui_drag_scrollbar(sb, value, dragging); | |
432 } | |
2980 | 433 return Pt_CONTINUE; |
7 | 434 } |
435 | |
436 static int | |
2998 | 437 gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 438 { |
439 PhKeyEvent_t *key; | |
440 unsigned char string[6]; | |
441 int len, i; | |
442 int ch, modifiers; | |
443 | |
2998 | 444 key = PhGetData(info->event); |
7 | 445 |
446 ch = modifiers = len = 0; | |
447 | |
2998 | 448 if (p_mh) |
449 gui_mch_mousehide(MOUSE_HIDE); | |
7 | 450 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
451 // We're a good lil photon program, aren't we? yes we are, yeess wee arrr |
2998 | 452 if (key->key_flags & Pk_KF_Compose) |
2980 | 453 return Pt_CONTINUE; |
7 | 454 |
2998 | 455 if ((key->key_flags & Pk_KF_Cap_Valid) && |
456 PkIsKeyDown(key->key_flags)) | |
7 | 457 { |
458 #ifdef FEAT_MENU | |
459 /* | |
460 * Only show the menu if the Alt key is down, and the Shift & Ctrl | |
461 * keys aren't down, as well as the other conditions | |
462 */ | |
2998 | 463 if (((key->key_mods & Pk_KM_Alt) && |
464 !(key->key_mods & Pk_KM_Shift) && | |
465 !(key->key_mods & Pk_KM_Ctrl)) && | |
7 | 466 gui.menu_is_active && |
2998 | 467 (*p_wak == 'y' || |
468 (*p_wak == 'm' && | |
469 gui_is_menu_shortcut(key->key_cap)))) | |
7 | 470 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
471 // Fallthrough and let photon look for the hotkey |
2980 | 472 return Pt_CONTINUE; |
7 | 473 } |
474 #endif | |
475 | |
3076 | 476 for (i = 0; special_keys[i].key_sym != 0; i++) |
7 | 477 { |
2998 | 478 if (special_keys[i].key_sym == key->key_cap) |
7 | 479 { |
480 len = 0; | |
2998 | 481 if (special_keys[i].vim_code1 == NUL) |
7 | 482 ch = special_keys[i].vim_code0; |
483 else | |
484 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
485 // Detect if a keypad number key has been pressed |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
486 // and change the key if Num Lock is on |
2998 | 487 if (key->key_cap >= Pk_KP_Enter && key->key_cap <= Pk_KP_9 |
488 && (key->key_mods & Pk_KM_Num_Lock)) | |
7 | 489 { |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
490 // FIXME: For now, just map the key to an ascii value |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
491 // (see <photon/PkKeyDef.h>) |
7 | 492 ch = key->key_cap - 0xf080; |
493 } | |
494 else | |
2998 | 495 ch = TO_SPECIAL(special_keys[i].vim_code0, |
496 special_keys[i].vim_code1); | |
7 | 497 } |
498 break; | |
499 } | |
500 } | |
501 | |
2998 | 502 if (key->key_mods & Pk_KM_Ctrl) |
7 | 503 modifiers |= MOD_MASK_CTRL; |
2998 | 504 if (key->key_mods & Pk_KM_Alt) |
7 | 505 modifiers |= MOD_MASK_ALT; |
2998 | 506 if (key->key_mods & Pk_KM_Shift) |
7 | 507 modifiers |= MOD_MASK_SHIFT; |
508 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
509 // Is this not a special key? |
2998 | 510 if (special_keys[i].key_sym == 0) |
7 | 511 { |
2998 | 512 ch = PhTo8859_1(key); |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
513 if (ch == -1 || (enc_utf8 && ch > 127)) |
7 | 514 { |
2998 | 515 len = PhKeyToMb(string, key); |
516 if (len > 0) | |
7 | 517 { |
518 static char buf[6]; | |
519 int src_taken, dst_made; | |
2998 | 520 if (enc_utf8 != TRUE) |
7 | 521 { |
522 PxTranslateFromUTF( | |
523 charset_translate, | |
524 string, | |
525 len, | |
526 &src_taken, | |
527 buf, | |
528 6, | |
3054 | 529 &dst_made); |
530 | |
531 add_to_input_buf(buf, dst_made); | |
7 | 532 } |
533 else | |
534 { | |
3054 | 535 add_to_input_buf(string, len); |
7 | 536 } |
537 | |
2980 | 538 return Pt_CONSUME; |
7 | 539 } |
540 len = 0; | |
541 ch = key->key_cap; | |
3054 | 542 if (ch < 0xff) |
7 | 543 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
544 // FIXME: is this the right thing to do? |
3054 | 545 if (modifiers & MOD_MASK_CTRL) |
7 | 546 { |
547 modifiers &= ~MOD_MASK_CTRL; | |
548 | |
3054 | 549 if ((ch >= 'a' && ch <= 'z') || |
7 | 550 ch == '[' || |
551 ch == ']' || | |
3054 | 552 ch == '\\') |
553 ch = Ctrl_chr(ch); | |
554 else if (ch == '2') | |
7 | 555 ch = NUL; |
3054 | 556 else if (ch == '6') |
7 | 557 ch = 0x1e; |
3054 | 558 else if (ch == '-') |
7 | 559 ch = 0x1f; |
560 else | |
561 modifiers |= MOD_MASK_CTRL; | |
562 } | |
563 | |
3054 | 564 if (modifiers & MOD_MASK_ALT) |
7 | 565 { |
3054 | 566 ch = Meta(ch); |
7 | 567 modifiers &= ~MOD_MASK_ALT; |
568 } | |
569 } | |
570 else | |
571 { | |
2980 | 572 return Pt_CONTINUE; |
7 | 573 } |
574 } | |
575 else | |
576 modifiers &= ~MOD_MASK_SHIFT; | |
577 } | |
578 | |
3054 | 579 ch = simplify_key(ch, &modifiers); |
580 if (modifiers) | |
7 | 581 { |
582 string[ len++ ] = CSI; | |
583 string[ len++ ] = KS_MODIFIER; | |
584 string[ len++ ] = modifiers; | |
585 } | |
586 | |
3054 | 587 if (IS_SPECIAL(ch)) |
7 | 588 { |
589 string[ len++ ] = CSI; | |
3054 | 590 string[ len++ ] = K_SECOND(ch); |
591 string[ len++ ] = K_THIRD(ch); | |
7 | 592 } |
593 else | |
594 { | |
595 string[ len++ ] = ch; | |
596 } | |
597 | |
21570
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
598 // Check if the key interrupts. |
7 | 599 { |
21570
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
600 int int_ch = check_for_interrupt(ch, modifiers); |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
601 |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
602 if (int_ch != NUL) |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
603 { |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
604 ch = int_ch; |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
605 string[0] = ch; |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
606 len = 1; |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
607 trash_input_buf(); |
f260c1411833
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Bram Moolenaar <Bram@vim.org>
parents:
21355
diff
changeset
|
608 } |
7 | 609 } |
610 | |
611 if (len == 1 && string[0] == CSI) | |
612 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
613 // Turn CSI into K_CSI. |
7 | 614 string[ len++ ] = KS_EXTRA; |
615 string[ len++ ] = KE_CSI; | |
616 } | |
617 | |
3054 | 618 if (len > 0) |
7 | 619 { |
3054 | 620 add_to_input_buf(string, len); |
2980 | 621 return Pt_CONSUME; |
7 | 622 } |
623 } | |
624 | |
2980 | 625 return Pt_CONTINUE; |
7 | 626 } |
627 | |
628 static int | |
3054 | 629 gui_ph_handle_mouse(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 630 { |
631 PhPointerEvent_t *pointer; | |
632 PhRect_t *pos; | |
633 int button = 0, repeated_click, modifiers = 0x0; | |
634 short mouse_x, mouse_y; | |
635 | |
3054 | 636 pointer = PhGetData(info->event); |
637 pos = PhGetRects(info->event); | |
638 | |
639 gui_mch_mousehide(MOUSE_SHOW); | |
7 | 640 |
641 /* | |
642 * Coordinates need to be relative to the base window, | |
643 * not relative to the vimTextArea widget | |
644 */ | |
645 mouse_x = pos->ul.x + gui.border_width; | |
646 mouse_y = pos->ul.y + gui.border_width; | |
647 | |
3054 | 648 if (info->event->type == Ph_EV_PTR_MOTION_NOBUTTON) |
7 | 649 { |
3054 | 650 gui_mouse_moved(mouse_x, mouse_y); |
2980 | 651 return Pt_CONTINUE; |
7 | 652 } |
653 | |
3054 | 654 if (pointer->key_mods & Pk_KM_Shift) |
7 | 655 modifiers |= MOUSE_SHIFT; |
3054 | 656 if (pointer->key_mods & Pk_KM_Ctrl) |
7 | 657 modifiers |= MOUSE_CTRL; |
3054 | 658 if (pointer->key_mods & Pk_KM_Alt) |
7 | 659 modifiers |= MOUSE_ALT; |
660 | |
661 /* | |
662 * FIXME More than one button may be involved, but for | |
663 * now just deal with one | |
664 */ | |
3054 | 665 if (pointer->buttons & Ph_BUTTON_SELECT) |
7 | 666 button = MOUSE_LEFT; |
667 | |
3054 | 668 if (pointer->buttons & Ph_BUTTON_MENU) |
7 | 669 { |
670 button = MOUSE_RIGHT; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
671 // Need the absolute coordinates for the popup menu |
7 | 672 abs_mouse.x = pointer->pos.x; |
673 abs_mouse.y = pointer->pos.y; | |
674 } | |
675 | |
3054 | 676 if (pointer->buttons & Ph_BUTTON_ADJUST) |
7 | 677 button = MOUSE_MIDDLE; |
678 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
679 // Catch a real release (not phantom or other releases |
3054 | 680 if (info->event->type == Ph_EV_BUT_RELEASE) |
7 | 681 button = MOUSE_RELEASE; |
682 | |
3054 | 683 if (info->event->type & Ph_EV_PTR_MOTION_BUTTON) |
7 | 684 button = MOUSE_DRAG; |
685 | |
686 #if 0 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
687 // Vim doesn't use button repeats |
3054 | 688 if (info->event->type & Ph_EV_BUT_REPEAT) |
7 | 689 button = MOUSE_DRAG; |
690 #endif | |
691 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
692 // Don't do anything if it is one of the phantom mouse release events |
3054 | 693 if ((button != MOUSE_RELEASE) || |
694 (info->event->subtype == Ph_EV_RELEASE_REAL)) | |
7 | 695 { |
696 repeated_click = (pointer->click_count >= 2) ? TRUE : FALSE; | |
697 | |
3054 | 698 gui_send_mouse_event(button , mouse_x, mouse_y, repeated_click, modifiers); |
7 | 699 } |
700 | |
2980 | 701 return Pt_CONTINUE; |
7 | 702 } |
703 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
704 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
705 * Handle a focus change of the PtRaw widget |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
706 */ |
7 | 707 static int |
3054 | 708 gui_ph_handle_focus(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 709 { |
3054 | 710 if (info->reason == Pt_CB_LOST_FOCUS) |
7 | 711 { |
3054 | 712 PtRemoveEventHandler(gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, |
713 gui_ph_handle_mouse, NULL); | |
714 | |
715 gui_mch_mousehide(MOUSE_SHOW); | |
7 | 716 } |
717 else | |
718 { | |
3054 | 719 PtAddEventHandler(gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, |
720 gui_ph_handle_mouse, NULL); | |
7 | 721 } |
2980 | 722 return Pt_CONTINUE; |
7 | 723 } |
724 | |
725 static void | |
3054 | 726 gui_ph_handle_raw_draw(PtWidget_t *widget, PhTile_t *damage) |
7 | 727 { |
728 PhRect_t *r; | |
729 PhPoint_t offset; | |
730 PhPoint_t translation; | |
731 | |
3054 | 732 if (is_ignore_draw == TRUE) |
7 | 733 return; |
734 | |
3054 | 735 PtSuperClassDraw(PtBasic, widget, damage); |
736 PgGetTranslation(&translation); | |
7 | 737 PgClearTranslation(); |
738 | |
739 #if 0 | |
740 /* | |
1214 | 741 * This causes some weird problems, with drawing being done from |
7 | 742 * within this raw drawing function (rather than just simple clearing |
743 * and text drawing done by gui_redraw) | |
744 * | |
745 * The main problem is when PhBlit is used, and the cursor appearing | |
746 * in places where it shouldn't | |
747 */ | |
748 out_flush(); | |
749 #endif | |
750 | |
3054 | 751 PtWidgetOffset(widget, &offset); |
752 PhTranslatePoint(&offset, PtWidgetPos(gui.vimTextArea, NULL)); | |
7 | 753 |
754 #if 1 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
755 // Redraw individual damage regions |
3054 | 756 if (damage->next != NULL) |
7 | 757 damage = damage->next; |
758 | |
3076 | 759 while (damage != NULL) |
7 | 760 { |
761 r = &damage->rect; | |
762 gui_redraw( | |
763 r->ul.x - offset.x, r->ul.y - offset.y, | |
764 r->lr.x - r->ul.x + 1, | |
3054 | 765 r->lr.y - r->ul.y + 1); |
7 | 766 damage = damage->next; |
767 } | |
768 #else | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
769 // Redraw the rectangle that covers all the damaged regions |
7 | 770 r = &damage->rect; |
771 gui_redraw( | |
772 r->ul.x - offset.x, r->ul.y - offset.y, | |
773 r->lr.x - r->ul.x + 1, | |
3054 | 774 r->lr.y - r->ul.y + 1); |
7 | 775 #endif |
776 | |
3054 | 777 PgSetTranslation(&translation, 0); |
7 | 778 } |
779 | |
780 static int | |
781 gui_ph_handle_pulldown_menu( | |
782 PtWidget_t *widget, | |
783 void *data, | |
3054 | 784 PtCallbackInfo_t *info) |
7 | 785 { |
3054 | 786 if (data != NULL) |
7 | 787 { |
788 vimmenu_T *menu = (vimmenu_T *) data; | |
789 | |
3054 | 790 PtPositionMenu(menu->submenu_id, NULL); |
791 PtRealizeWidget(menu->submenu_id); | |
7 | 792 } |
793 | |
2980 | 794 return Pt_CONTINUE; |
7 | 795 } |
796 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
797 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
798 * This is used for pulldown/popup menus and also toolbar buttons |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
799 */ |
7 | 800 static int |
3076 | 801 gui_ph_handle_menu(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 802 { |
3076 | 803 if (data != NULL) |
7 | 804 { |
805 vimmenu_T *menu = (vimmenu_T *) data; | |
3076 | 806 gui_menu_cb(menu); |
7 | 807 } |
2980 | 808 return Pt_CONTINUE; |
7 | 809 } |
810 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
811 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
812 * Stop focus from disappearing into the menubar... |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
813 */ |
7 | 814 static int |
815 gui_ph_handle_menu_unrealized( | |
816 PtWidget_t *widget, | |
817 void *data, | |
3076 | 818 PtCallbackInfo_t *info) |
7 | 819 { |
3076 | 820 PtGiveFocus(gui.vimTextArea, NULL); |
2980 | 821 return Pt_CONTINUE; |
7 | 822 } |
823 | |
824 static int | |
825 gui_ph_handle_window_open( | |
826 PtWidget_t *widget, | |
827 void *data, | |
3076 | 828 PtCallbackInfo_t *info) |
7 | 829 { |
3076 | 830 gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH); |
2980 | 831 return Pt_CONTINUE; |
7 | 832 } |
833 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
834 //////////////////////////////////////////////////////////////////////////// |
7 | 835 |
836 #define DRAW_START gui_ph_draw_start() | |
837 #define DRAW_END gui_ph_draw_end() | |
838 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
839 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
840 * TODO: Set a clipping rect? |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
841 */ |
7 | 842 static void |
3076 | 843 gui_ph_draw_start(void) |
7 | 844 { |
1922 | 845 PhGC_t *gc; |
846 | |
847 gc = PgGetGC(); | |
3076 | 848 PgSetRegion(PtWidgetRid(PtFindDisjoint(gui.vimTextArea))); |
849 PgClearClippingsCx(gc); | |
850 PgClearTranslationCx(gc); | |
851 | |
852 PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset); | |
853 PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL)); | |
854 | |
855 PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE); | |
7 | 856 } |
857 | |
858 static void | |
3076 | 859 gui_ph_draw_end(void) |
7 | 860 { |
861 gui_ph_raw_offset.x = -gui_ph_raw_offset.x; | |
862 gui_ph_raw_offset.y = -gui_ph_raw_offset.y; | |
3076 | 863 PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE); |
7 | 864 } |
865 | |
866 #ifdef USE_PANEL_GROUP | |
867 static vimmenu_T * | |
3076 | 868 gui_ph_find_buffer_item(char_u *name) |
7 | 869 { |
870 vimmenu_T *top_level = root_menu; | |
871 vimmenu_T *items = NULL; | |
872 | |
3076 | 873 while (top_level != NULL && |
874 (STRCMP(top_level->dname, "Buffers") != 0)) | |
7 | 875 top_level = top_level->next; |
876 | |
3076 | 877 if (top_level != NULL) |
7 | 878 { |
879 items = top_level->children; | |
880 | |
3076 | 881 while (items != NULL && |
882 (STRCMP(items->dname, name) != 0)) | |
7 | 883 items = items->next; |
884 } | |
2980 | 885 return items; |
7 | 886 } |
887 | |
888 static void | |
3076 | 889 gui_ph_pg_set_buffer_num(int_u buf_num) |
7 | 890 { |
891 int i; | |
892 char search[16]; | |
893 char *mark; | |
894 | |
3076 | 895 if (gui.vimTextArea == NULL || buf_num == 0) |
7 | 896 return; |
897 | |
898 search[0] = '('; | |
3076 | 899 ultoa(buf_num, &search[1], 10); |
900 STRCAT(search, ")"); | |
901 | |
902 for (i = 0; i < num_panels; i++) | |
7 | 903 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
904 // find the last "(" in the panel title and see if the buffer |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
905 // number in the title matches the one we're looking for |
3076 | 906 mark = STRRCHR(panel_titles[ i ], '('); |
907 if (mark != NULL && STRCMP(mark, search) == 0) | |
7 | 908 { |
3076 | 909 PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX, |
910 i, 0); | |
7 | 911 } |
912 } | |
913 } | |
914 | |
915 static int | |
916 gui_ph_handle_pg_change( | |
917 PtWidget_t *widget, | |
918 void *data, | |
3076 | 919 PtCallbackInfo_t *info) |
7 | 920 { |
921 vimmenu_T *menu; | |
922 PtPanelGroupCallback_t *panel; | |
923 | |
3076 | 924 if (info->event != NULL) |
7 | 925 { |
926 panel = info->cbdata; | |
3076 | 927 if (panel->new_panel != NULL) |
7 | 928 { |
3076 | 929 menu = gui_ph_find_buffer_item(panel->new_panel); |
930 if (menu) | |
931 gui_menu_cb(menu); | |
7 | 932 } |
933 } | |
2980 | 934 return Pt_CONTINUE; |
7 | 935 } |
936 | |
937 static void | |
938 gui_ph_get_panelgroup_margins( | |
939 short *top, | |
940 short *bottom, | |
941 short *left, | |
3076 | 942 short *right) |
7 | 943 { |
944 unsigned short abs_raw_x, abs_raw_y, abs_panel_x, abs_panel_y; | |
945 const unsigned short *margin_top, *margin_bottom; | |
946 const unsigned short *margin_left, *margin_right; | |
947 | |
3076 | 948 PtGetAbsPosition(gui.vimTextArea, &abs_raw_x, &abs_raw_y); |
949 PtGetAbsPosition(gui.vimPanelGroup, &abs_panel_x, &abs_panel_y); | |
950 | |
951 PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0); | |
952 PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0); | |
7 | 953 |
954 abs_raw_x -= abs_panel_x; | |
955 abs_raw_y -= abs_panel_y; | |
956 | |
957 *top = abs_raw_y; | |
958 *bottom = *margin_bottom; | |
959 | |
960 *left = abs_raw_x; | |
961 *right = *margin_right; | |
962 } | |
963 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
964 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
965 * Used for the tabs for PtPanelGroup |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
966 */ |
7 | 967 static int |
3076 | 968 gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent) |
7 | 969 { |
970 char *mark; | |
971 | |
3076 | 972 if (STRCMP(parent->dname, "Buffers") == 0) |
7 | 973 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
974 // Look for '(' digits ')' |
3076 | 975 mark = vim_strchr(menu->dname, '('); |
976 if (mark != NULL) | |
7 | 977 { |
978 mark++; | |
3076 | 979 while (isdigit(*mark)) |
7 | 980 mark++; |
981 | |
3076 | 982 if (*mark == ')') |
2980 | 983 return TRUE; |
7 | 984 } |
985 } | |
2980 | 986 return FALSE; |
7 | 987 } |
988 | |
989 static void | |
3076 | 990 gui_ph_pg_add_buffer(char *name) |
7 | 991 { |
992 char **new_titles = NULL; | |
993 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
994 new_titles = ALLOC_MULT(char *, (num_panels + 1)); |
3076 | 995 if (new_titles != NULL) |
7 | 996 { |
3076 | 997 if (num_panels > 0) |
998 memcpy(new_titles, panel_titles, num_panels * sizeof(char **)); | |
7 | 999 |
1000 new_titles[ num_panels++ ] = name; | |
1001 | |
3076 | 1002 PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, |
1003 num_panels); | |
1004 | |
1005 vim_free(panel_titles); | |
7 | 1006 panel_titles = new_titles; |
1007 } | |
1008 } | |
1009 | |
1010 static void | |
3076 | 1011 gui_ph_pg_remove_buffer(char *name) |
7 | 1012 { |
1013 int i; | |
1014 char **new_titles = NULL; | |
1015 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1016 // If there is only 1 panel, we just use the temporary place holder |
3076 | 1017 if (num_panels > 1) |
7 | 1018 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1019 new_titles = ALLOC_MULT(char *, num_panels - 1); |
3076 | 1020 if (new_titles != NULL) |
7 | 1021 { |
1022 char **s = new_titles; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1023 // Copy all the titles except the one we're removing |
3076 | 1024 for (i = 0; i < num_panels; i++) |
7 | 1025 { |
3076 | 1026 if (STRCMP(panel_titles[ i ], name) != 0) |
7 | 1027 *s++ = panel_titles[ i ]; |
1028 } | |
1029 num_panels--; | |
1030 | |
3076 | 1031 PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, |
1032 num_panels); | |
1033 | |
1034 vim_free(panel_titles); | |
7 | 1035 panel_titles = new_titles; |
1036 } | |
1037 } | |
1038 else | |
1039 { | |
1040 num_panels--; | |
3076 | 1041 PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title, |
1042 1); | |
1043 | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13152
diff
changeset
|
1044 VIM_CLEAR(panel_titles); |
7 | 1045 } |
1046 } | |
1047 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1048 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1049 * When a buffer item is deleted from the buffer menu |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1050 */ |
7 | 1051 static int |
1052 gui_ph_handle_buffer_remove( | |
1053 PtWidget_t *widget, | |
1054 void *data, | |
3076 | 1055 PtCallbackInfo_t *info) |
7 | 1056 { |
1057 vimmenu_T *menu; | |
1058 | |
3076 | 1059 if (data != NULL) |
7 | 1060 { |
1061 menu = (vimmenu_T *) data; | |
3076 | 1062 gui_ph_pg_remove_buffer(menu->dname); |
7 | 1063 } |
1064 | |
2980 | 1065 return Pt_CONTINUE; |
7 | 1066 } |
1067 #endif | |
1068 | |
1069 static int | |
3076 | 1070 gui_ph_pane_resize(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 1071 { |
3076 | 1072 if (PtWidgetIsRealized(widget)) |
7 | 1073 { |
1074 is_ignore_draw = TRUE; | |
3076 | 1075 PtStartFlux(gui.vimContainer); |
1076 PtContainerHold(gui.vimContainer); | |
7 | 1077 } |
1078 | |
2980 | 1079 return Pt_CONTINUE; |
7 | 1080 } |
1081 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1082 //////////////////////////////////////////////////////////////////////////// |
7 | 1083 |
1084 void | |
3076 | 1085 gui_ph_encoding_changed(int new_encoding) |
7 | 1086 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1087 // Default encoding is latin1 |
7 | 1088 char *charset = "latin1"; |
1089 int i; | |
1090 | |
1091 struct { | |
1092 int encoding; | |
1093 char *name; | |
1094 } charsets[] = { | |
1095 { DBCS_JPN, "SHIFT_JIS" }, | |
1096 { DBCS_KOR, "csEUCKR" }, | |
1097 { DBCS_CHT, "big5" }, | |
1098 { DBCS_CHS, "gb" } | |
1099 }; | |
1100 | |
3076 | 1101 for (i = 0; i < ARRAY_LENGTH(charsets); i++) |
7 | 1102 { |
3076 | 1103 if (new_encoding == charsets[ i ].encoding) |
7 | 1104 charset = charsets[ i ].name; |
1105 } | |
1106 | |
3076 | 1107 charset_translate = PxTranslateSet(charset_translate, charset); |
7 | 1108 } |
1109 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1110 //////////////////////////////////////////////////////////////////////////// |
7 | 1111 |
1112 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
1113 gui_mch_prepare(int *argc, char **argv) |
7 | 1114 { |
3076 | 1115 PtInit(NULL); |
7 | 1116 } |
1117 | |
1118 int | |
1119 gui_mch_init(void) | |
1120 { | |
1121 PtArg_t args[10]; | |
1122 int flags = 0, n = 0; | |
1123 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1124 PhDim_t window_size = {100, 100}; // Arbitrary values |
7 | 1125 PhPoint_t pos = {0, 0}; |
1126 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1127 gui.event_buffer = alloc(EVENT_BUFFER_SIZE); |
3076 | 1128 if (gui.event_buffer == NULL) |
2980 | 1129 return FAIL; |
7 | 1130 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1131 // Get a translation so we can convert from ISO Latin-1 to UTF |
3076 | 1132 charset_translate = PxTranslateSet(NULL, "latin1"); |
7 | 1133 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1134 // The +2 is for the 1 pixel dark line on each side |
7 | 1135 gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2; |
1136 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1137 // Handle close events ourselves |
3076 | 1138 PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE); |
1139 PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, | |
1140 Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS); | |
1141 PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0); | |
1142 gui.vimWindow = PtCreateWidget(PtWindow, NULL, n, args); | |
1143 if (gui.vimWindow == NULL) | |
2980 | 1144 return FAIL; |
7 | 1145 |
3076 | 1146 PtAddCallback(gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL); |
1147 PtAddCallback(gui.vimWindow, Pt_CB_WINDOW_OPENING, | |
1148 gui_ph_handle_window_open, NULL); | |
7 | 1149 |
1150 n = 0; | |
3076 | 1151 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, Pt_IS_ANCHORED); |
1152 PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0); | |
1153 PtSetArg(&args[ n++ ], Pt_ARG_POS, &pos, 0); | |
7 | 1154 |
1155 #ifdef USE_PANEL_GROUP | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1156 // Put in a temporary place holder title |
3076 | 1157 PtSetArg(&args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1); |
1158 | |
1159 gui.vimPanelGroup = PtCreateWidget(PtPanelGroup, gui.vimWindow, n, args); | |
1160 if (gui.vimPanelGroup == NULL) | |
2980 | 1161 return FAIL; |
7 | 1162 |
3076 | 1163 PtAddCallback(gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING, |
1164 gui_ph_handle_pg_change, NULL); | |
7 | 1165 #else |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1166 // Turn off all edge decorations |
3076 | 1167 PtSetArg(&args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL); |
1168 PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0); | |
1169 PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0); | |
1170 PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0); | |
1171 PtSetArg(&args[ n++ ], Pt_ARG_CONTAINER_FLAGS, Pt_TRUE, Pt_AUTO_EXTENT); | |
1172 | |
1173 gui.vimContainer = PtCreateWidget(PtPane, gui.vimWindow, n, args); | |
1174 if (gui.vimContainer == NULL) | |
2980 | 1175 return FAIL; |
7 | 1176 |
3076 | 1177 PtAddCallback(gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL); |
7 | 1178 #endif |
1179 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1180 // Size for the text area is set in gui_mch_set_text_area_pos |
7 | 1181 n = 0; |
1182 | |
3076 | 1183 PtSetArg(&args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1); |
1184 PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, GUI_PH_MARGIN, 0); | |
7 | 1185 /* |
1186 * Using focus render also causes the whole widget to be redrawn | |
1187 * whenever it changes focus, which is very annoying :p | |
1188 */ | |
3076 | 1189 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, |
1190 Pt_GETS_FOCUS | Pt_HIGHLIGHTED); | |
7 | 1191 #ifndef FEAT_MOUSESHAPE |
3076 | 1192 PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_TYPE, GUI_PH_MOUSE_TYPE, 0); |
1193 PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_COLOR, gui_ph_mouse_color, 0); | |
7 | 1194 #endif |
1195 | |
3076 | 1196 gui.vimTextArea = PtCreateWidget(PtRaw, Pt_DFLT_PARENT, n, args); |
1197 if (gui.vimTextArea == NULL) | |
2980 | 1198 return FAIL; |
7 | 1199 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1200 // TODO: use PtAddEventHandlers instead? |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1201 // Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway |
3076 | 1202 PtAddEventHandler(gui.vimTextArea, |
7 | 1203 Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON, |
3076 | 1204 gui_ph_handle_mouse, NULL); |
1205 PtAddEventHandler(gui.vimTextArea, Ph_EV_KEY, | |
1206 gui_ph_handle_keyboard, NULL); | |
1207 PtAddCallback(gui.vimTextArea, Pt_CB_GOT_FOCUS, | |
1208 gui_ph_handle_focus, NULL); | |
1209 PtAddCallback(gui.vimTextArea, Pt_CB_LOST_FOCUS, | |
1210 gui_ph_handle_focus, NULL); | |
7 | 1211 |
1212 /* | |
1213 * Now that the text area widget has been created, set up the colours, | |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
18788
diff
changeset
|
1214 * which will call PtSetResource from gui_mch_new_colors |
7 | 1215 */ |
1216 | |
1217 /* | |
1218 * Create the two timers, not as accurate as using the kernel timer | |
1219 * functions, but good enough | |
1220 */ | |
3076 | 1221 gui_ph_timer_cursor = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL); |
1222 if (gui_ph_timer_cursor == NULL) | |
2980 | 1223 return FAIL; |
7 | 1224 |
3076 | 1225 gui_ph_timer_timeout = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL); |
1226 if (gui_ph_timer_timeout == NULL) | |
2980 | 1227 return FAIL; |
7 | 1228 |
3076 | 1229 PtAddCallback(gui_ph_timer_cursor, Pt_CB_TIMER_ACTIVATE, |
7 | 1230 gui_ph_handle_timer_cursor, NULL); |
3076 | 1231 PtAddCallback(gui_ph_timer_timeout, Pt_CB_TIMER_ACTIVATE, |
7 | 1232 gui_ph_handle_timer_timeout, NULL); |
1233 | |
1234 #ifdef FEAT_MENU | |
1235 n = 0; | |
3076 | 1236 PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); |
1237 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT, | |
1238 Pt_IS_ANCHORED); | |
1239 gui.vimToolBarGroup = PtCreateWidget(PtToolbarGroup, gui.vimWindow, | |
1240 n, args); | |
1241 if (gui.vimToolBarGroup == NULL) | |
2980 | 1242 return FAIL; |
7 | 1243 |
3076 | 1244 PtAddCallback(gui.vimToolBarGroup, Pt_CB_RESIZE, |
1245 gui_ph_handle_menu_resize, NULL); | |
7 | 1246 |
1247 n = 0; | |
1248 flags = 0; | |
3076 | 1249 PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); |
1250 if (! vim_strchr(p_go, GO_MENUS)) | |
7 | 1251 { |
1252 flags |= Pt_DELAY_REALIZE; | |
3076 | 1253 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags); |
7 | 1254 } |
3076 | 1255 gui.vimMenuBar = PtCreateWidget(PtMenuBar, gui.vimToolBarGroup, n, args); |
1256 if (gui.vimMenuBar == NULL) | |
2980 | 1257 return FAIL; |
7 | 1258 |
1259 # ifdef FEAT_TOOLBAR | |
1260 n = 0; | |
1261 | |
3076 | 1262 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, |
1263 Pt_ANCHOR_LEFT_RIGHT |Pt_TOP_ANCHORED_TOP, Pt_IS_ANCHORED); | |
1264 PtSetArg(&args[ n++ ], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, | |
1265 Pt_RESIZE_Y_AS_REQUIRED); | |
1266 PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); | |
7 | 1267 |
1268 flags = Pt_GETS_FOCUS; | |
3076 | 1269 if (! vim_strchr(p_go, GO_TOOLBAR)) |
7 | 1270 flags |= Pt_DELAY_REALIZE; |
1271 | |
3076 | 1272 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags); |
1273 | |
1274 gui.vimToolBar = PtCreateWidget(PtToolbar, gui.vimToolBarGroup, n, args); | |
1275 if (gui.vimToolBar == NULL) | |
2980 | 1276 return FAIL; |
7 | 1277 |
1278 /* | |
1279 * Size for the toolbar is fetched in gui_mch_show_toolbar, after | |
1280 * the buttons have been added and the toolbar has resized it's height | |
1281 * for the buttons to fit | |
1282 */ | |
1283 # endif | |
1284 | |
1285 #endif | |
1286 | |
2980 | 1287 return OK; |
7 | 1288 } |
1289 | |
1290 int | |
1291 gui_mch_init_check(void) | |
1292 { | |
2980 | 1293 return (is_photon_available == TRUE) ? OK : FAIL; |
7 | 1294 } |
1295 | |
1296 int | |
1297 gui_mch_open(void) | |
1298 { | |
1299 gui.norm_pixel = Pg_BLACK; | |
1300 gui.back_pixel = Pg_WHITE; | |
1301 | |
1302 set_normal_colors(); | |
1303 | |
1304 gui_check_colors(); | |
1305 gui.def_norm_pixel = gui.norm_pixel; | |
1306 gui.def_back_pixel = gui.back_pixel; | |
1307 | |
1308 highlight_gui_started(); | |
1309 | |
1310 if (gui_win_x != -1 && gui_win_y != -1) | |
1311 gui_mch_set_winpos(gui_win_x, gui_win_y); | |
1312 | |
3076 | 1313 return (PtRealizeWidget(gui.vimWindow) == 0) ? OK : FAIL; |
7 | 1314 } |
1315 | |
1316 void | |
1317 gui_mch_exit(int rc) | |
1318 { | |
3076 | 1319 PtDestroyWidget(gui.vimWindow); |
1320 | |
1321 PxTranslateSet(charset_translate, NULL); | |
1322 | |
1323 vim_free(gui.event_buffer); | |
7 | 1324 |
1325 #ifdef USE_PANEL_GROUPS | |
3076 | 1326 vim_free(panel_titles); |
7 | 1327 #endif |
1328 } | |
1329 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1330 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1331 // events |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1332 |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1333 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1334 * When no events are available, photon will call this function, working is |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1335 * set to FALSE, and the gui_mch_update loop will exit. |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1336 */ |
7 | 1337 static int |
3076 | 1338 exit_gui_mch_update(void *data) |
7 | 1339 { |
1340 *(int *)data = FALSE; | |
2980 | 1341 return Pt_END; |
7 | 1342 } |
1343 | |
1344 void | |
1345 gui_mch_update(void) | |
1346 { | |
1347 int working = TRUE; | |
1348 | |
3076 | 1349 PtAppAddWorkProc(NULL, exit_gui_mch_update, &working); |
1350 while ((working == TRUE) && !vim_is_input_buf_full()) | |
7 | 1351 PtProcessEvent(); |
1352 } | |
1353 | |
1354 int | |
1355 gui_mch_wait_for_chars(int wtime) | |
1356 { | |
1357 is_timeout = FALSE; | |
1358 | |
15665
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
15595
diff
changeset
|
1359 if (wtime >= 0) |
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
15595
diff
changeset
|
1360 PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, |
31367ce5aac7
patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents:
15595
diff
changeset
|
1361 wtime == 0 ? 1 : wtime, 0); |
3076 | 1362 |
1363 while (1) | |
7 | 1364 { |
1365 PtProcessEvent(); | |
3076 | 1366 if (input_available()) |
7 | 1367 { |
3076 | 1368 PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0); |
2980 | 1369 return OK; |
7 | 1370 } |
3076 | 1371 else if (is_timeout == TRUE) |
2980 | 1372 return FAIL; |
7 | 1373 } |
1374 } | |
1375 | |
3076 | 1376 #if defined(FEAT_BROWSE) || defined(PROTO) |
7 | 1377 /* |
1378 * Put up a file requester. | |
1379 * Returns the selected name in allocated memory, or NULL for Cancel. | |
1380 * saving, select file to write | |
1381 * title title for the window | |
1382 * default_name default name (well duh!) | |
1383 * ext not used (extension added) | |
1384 * initdir initial directory, NULL for current dir | |
1385 * filter not used (file name filter) | |
1386 */ | |
1387 char_u * | |
1388 gui_mch_browse( | |
1389 int saving, | |
1390 char_u *title, | |
1391 char_u *default_name, | |
1392 char_u *ext, | |
1393 char_u *initdir, | |
1394 char_u *filter) | |
1395 { | |
1396 PtFileSelectionInfo_t file; | |
1397 int flags; | |
1398 char_u *default_path; | |
1399 char_u *open_text = NULL; | |
1400 | |
1401 flags = 0; | |
3076 | 1402 memset(&file, 0, sizeof(file)); |
1403 | |
1404 default_path = alloc(MAXPATHL + 1 + NAME_MAX + 1); | |
1405 if (default_path != NULL) | |
7 | 1406 { |
3076 | 1407 if (saving == TRUE) |
7 | 1408 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1409 // Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway |
7 | 1410 flags |= Pt_FSR_NO_FCHECK; |
1411 open_text = "&Save"; | |
1412 } | |
1413 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1414 // combine the directory and filename into a single path |
3076 | 1415 if (initdir == NULL || *initdir == NUL) |
7 | 1416 { |
3076 | 1417 mch_dirname(default_path, MAXPATHL); |
7 | 1418 initdir = default_path; |
1419 } | |
1420 else | |
1421 { | |
3076 | 1422 STRCPY(default_path, initdir); |
7 | 1423 initdir = default_path; |
1424 } | |
1425 | |
3076 | 1426 if (default_name != NULL) |
7 | 1427 { |
3076 | 1428 if (default_path[ STRLEN(default_path) - 1 ] != '/') |
1429 STRCAT(default_path, "/"); | |
1430 | |
1431 STRCAT(default_path, default_name); | |
7 | 1432 } |
1433 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1434 // TODO: add a filter? |
7 | 1435 PtFileSelection( |
1436 gui.vimWindow, | |
1437 NULL, | |
1438 title, | |
1439 default_path, | |
1440 NULL, | |
1441 open_text, | |
1442 NULL, | |
1443 NULL, | |
1444 &file, | |
3076 | 1445 flags); |
1446 | |
1447 vim_free(default_path); | |
1448 | |
1449 if (file.ret == Pt_FSDIALOG_BTN1) | |
2980 | 1450 return vim_strsave(file.path); |
7 | 1451 } |
2980 | 1452 return NULL; |
7 | 1453 } |
1454 #endif | |
1455 | |
3076 | 1456 #if defined(FEAT_GUI_DIALOG) || defined(PROTO) |
7 | 1457 static PtWidget_t *gui_ph_dialog_text = NULL; |
1458 | |
1459 static int | |
3076 | 1460 gui_ph_dialog_close(int button, void *data) |
7 | 1461 { |
1462 PtModalCtrl_t *modal_ctrl = data; | |
1463 char_u *dialog_text, *vim_text; | |
1464 | |
3076 | 1465 if (gui_ph_dialog_text != NULL) |
7 | 1466 { |
3076 | 1467 PtGetResource(gui_ph_dialog_text, Pt_ARG_TEXT_STRING, &dialog_text, 0); |
1468 PtGetResource(gui_ph_dialog_text, Pt_ARG_POINTER, &vim_text, 0); | |
1469 STRNCPY(vim_text, dialog_text, IOSIZE - 1); | |
7 | 1470 } |
1471 | |
3076 | 1472 PtModalUnblock(modal_ctrl, (void *) button); |
7 | 1473 |
2980 | 1474 return Pt_TRUE; |
7 | 1475 } |
1476 | |
1477 static int | |
3076 | 1478 gui_ph_dialog_text_enter(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 1479 { |
3076 | 1480 if (info->reason_subtype == Pt_EDIT_ACTIVATE) |
1481 gui_ph_dialog_close(1, data); | |
2980 | 1482 return Pt_CONTINUE; |
7 | 1483 } |
1484 | |
1485 static int | |
3076 | 1486 gui_ph_dialog_esc(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
7 | 1487 { |
1488 PhKeyEvent_t *key; | |
1489 | |
3076 | 1490 key = PhGetData(info->event); |
1491 if ((key->key_flags & Pk_KF_Cap_Valid) && (key->key_cap == Pk_Escape)) | |
7 | 1492 { |
3076 | 1493 gui_ph_dialog_close(0, data); |
2980 | 1494 return Pt_CONSUME; |
7 | 1495 } |
2980 | 1496 return Pt_PROCESS; |
7 | 1497 } |
1498 | |
1499 int | |
1500 gui_mch_dialog( | |
1501 int type, | |
1502 char_u *title, | |
1503 char_u *message, | |
1504 char_u *buttons, | |
1505 int default_button, | |
2684 | 1506 char_u *textfield, |
1507 int ex_cmd) | |
7 | 1508 { |
1509 char_u *str; | |
1510 char_u **button_array; | |
1511 char_u *buttons_copy; | |
1512 | |
1513 int button_count; | |
1514 int i, len; | |
1515 int dialog_result = -1; | |
1516 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1517 // FIXME: the vertical option in guioptions is blatantly ignored |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1518 // FIXME: so is the type |
7 | 1519 |
1520 button_count = len = i = 0; | |
1521 | |
3076 | 1522 if (buttons == NULL || *buttons == NUL) |
2980 | 1523 return -1; |
7 | 1524 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1525 // There is one less separator than buttons, so bump up the button count |
7 | 1526 button_count = 1; |
1527 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1528 // Count string length and number of separators |
3076 | 1529 for (str = buttons; *str; str++) |
7 | 1530 { |
1531 len++; | |
3076 | 1532 if (*str == DLG_BUTTON_SEP) |
7 | 1533 button_count++; |
1534 } | |
1535 | |
3076 | 1536 if (title == NULL) |
7 | 1537 title = "Vim"; |
1538 | |
3076 | 1539 buttons_copy = alloc(len + 1); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
1540 button_array = ALLOC_MULT(char_u *, button_count); |
3076 | 1541 if (buttons_copy != NULL && button_array != NULL) |
7 | 1542 { |
3076 | 1543 STRCPY(buttons_copy, buttons); |
7 | 1544 |
1545 /* | |
1546 * Convert DLG_BUTTON_SEP into NUL's and fill in | |
1547 * button_array with the pointer to each NUL terminated string | |
1548 */ | |
1549 str = buttons_copy; | |
3076 | 1550 for (i = 0; i < button_count; i++) |
7 | 1551 { |
1552 button_array[ i ] = str; | |
3076 | 1553 for (; *str; str++) |
7 | 1554 { |
3076 | 1555 if (*str == DLG_BUTTON_SEP) |
7 | 1556 { |
1557 *str++ = NUL; | |
1558 break; | |
1559 } | |
1560 } | |
1561 } | |
1562 #ifndef FEAT_GUI_TEXTDIALOG | |
1563 dialog_result = PtAlert( | |
1564 gui.vimWindow, NULL, | |
1565 title, | |
1566 NULL, | |
1567 message, NULL, | |
1568 button_count, (const char **) button_array, NULL, | |
3076 | 1569 default_button, 0, Pt_MODAL); |
7 | 1570 #else |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1571 // Writing the dialog ourselves lets us add extra features, like |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1572 // trapping the escape key and returning 0 to vim |
7 | 1573 { |
1574 int n; | |
1575 PtArg_t args[5]; | |
1576 PtWidget_t *dialog, *pane; | |
1577 PtModalCtrl_t modal_ctrl; | |
1578 PtDialogInfo_t di; | |
1579 | |
3076 | 1580 memset(&di, 0, sizeof(di)); |
1581 memset(&modal_ctrl, 0, sizeof(modal_ctrl)); | |
7 | 1582 |
1583 n = 0; | |
3076 | 1584 PtSetArg(&args[n++], Pt_ARG_GROUP_ROWS_COLS, 0, 0); |
1585 PtSetArg(&args[n++], Pt_ARG_WIDTH, 350, 0); | |
1586 PtSetArg(&args[n++], Pt_ARG_GROUP_ORIENTATION, | |
1587 Pt_GROUP_VERTICAL, 0); | |
1588 PtSetArg(&args[n++], Pt_ARG_GROUP_FLAGS, | |
1589 Pt_TRUE, Pt_GROUP_NO_KEYS | Pt_GROUP_STRETCH_HORIZONTAL); | |
1590 PtSetArg(&args[n++], Pt_ARG_CONTAINER_FLAGS, Pt_FALSE, Pt_TRUE); | |
1591 pane = PtCreateWidget(PtGroup, NULL, n, args); | |
7 | 1592 |
1593 n = 0; | |
3076 | 1594 PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, message, 0); |
1595 PtCreateWidget(PtLabel, pane, n, args); | |
1596 | |
1597 if (textfield != NULL) | |
7 | 1598 { |
1599 n = 0; | |
3076 | 1600 PtSetArg(&args[n++], Pt_ARG_MAX_LENGTH, IOSIZE - 1, 0); |
1601 PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, textfield, 0); | |
1602 PtSetArg(&args[n++], Pt_ARG_POINTER, textfield, 0); | |
1603 gui_ph_dialog_text = PtCreateWidget(PtText, pane, n, args); | |
1604 PtAddCallback(gui_ph_dialog_text, Pt_CB_ACTIVATE, | |
1605 gui_ph_dialog_text_enter, &modal_ctrl); | |
7 | 1606 } |
1607 | |
1608 di.parent = gui.vimWindow; | |
1609 di.pane = pane; | |
1610 di.title = title; | |
1611 di.buttons = (const char **) button_array; | |
1612 di.nbtns = button_count; | |
1613 di.def_btn = default_button; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1614 // This is just to give the dialog the close button. |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1615 // We check for the Escape key ourselves and return 0 |
7 | 1616 di.esc_btn = button_count; |
1617 di.callback = gui_ph_dialog_close; | |
1618 di.data = &modal_ctrl; | |
1619 | |
3076 | 1620 dialog = PtCreateDialog(&di); |
1621 PtAddFilterCallback(dialog, Ph_EV_KEY, | |
1622 gui_ph_dialog_esc, &modal_ctrl); | |
1623 | |
1624 if (gui_ph_dialog_text != NULL) | |
1625 PtGiveFocus(gui_ph_dialog_text, NULL); | |
7 | 1626 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1627 // Open dialog, block the vim window and wait for the dialog to close |
3076 | 1628 PtRealizeWidget(dialog); |
1629 PtMakeModal(dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR); | |
1630 dialog_result = (int) PtModalBlock(&modal_ctrl, 0); | |
1631 | |
1632 PtDestroyWidget(dialog); | |
7 | 1633 gui_ph_dialog_text = NULL; |
1634 } | |
1635 #endif | |
1636 } | |
1637 | |
3076 | 1638 vim_free(button_array); |
1639 vim_free(buttons_copy); | |
7 | 1640 |
2980 | 1641 return dialog_result; |
7 | 1642 } |
1643 #endif | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1644 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1645 // window size/position/state |
7 | 1646 |
1647 int | |
1648 gui_mch_get_winpos(int *x, int *y) | |
1649 { | |
1650 PhPoint_t *pos; | |
1651 | |
3076 | 1652 pos = PtWidgetPos(gui.vimWindow, NULL); |
7 | 1653 |
1654 *x = pos->x; | |
1655 *y = pos->y; | |
1656 | |
2980 | 1657 return OK; |
7 | 1658 } |
1659 | |
1660 void | |
1661 gui_mch_set_winpos(int x, int y) | |
1662 { | |
1663 PhPoint_t pos = { x, y }; | |
1664 | |
3076 | 1665 PtSetResource(gui.vimWindow, Pt_ARG_POS, &pos, 0); |
7 | 1666 } |
1667 | |
1668 void | |
1669 gui_mch_set_shellsize(int width, int height, | |
812 | 1670 int min_width, int min_height, int base_width, int base_height, |
1671 int direction) | |
7 | 1672 { |
1673 PhDim_t window_size = { width, height }; | |
1674 PhDim_t min_size = { min_width, min_height }; | |
1675 | |
1676 #ifdef USE_PANEL_GROUP | |
1677 window_size.w += pg_margin_left + pg_margin_right; | |
1678 window_size.h += pg_margin_top + pg_margin_bottom; | |
1679 #endif | |
1680 | |
3076 | 1681 PtSetResource(gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0); |
1682 PtSetResource(gui.vimWindow, Pt_ARG_DIM, &window_size, 0); | |
1683 | |
1684 if (! PtWidgetIsRealized(gui.vimWindow)) | |
7 | 1685 gui_ph_resize_container(); |
1686 } | |
1687 | |
1688 /* | |
1689 * Return the amount of screen space that hasn't been allocated (such as | |
1690 * by the shelf). | |
1691 */ | |
1692 void | |
1693 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h) | |
1694 { | |
1695 PhRect_t console; | |
1696 | |
3076 | 1697 PhWindowQueryVisible(Ph_QUERY_WORKSPACE, 0, |
1698 PhInputGroup(NULL), &console); | |
7 | 1699 |
1700 *screen_w = console.lr.x - console.ul.x + 1; | |
1701 *screen_h = console.lr.y - console.ul.y + 1; | |
1702 } | |
1703 | |
1704 void | |
1705 gui_mch_iconify(void) | |
1706 { | |
1707 PhWindowEvent_t event; | |
1708 | |
3076 | 1709 memset(&event, 0, sizeof (event)); |
7 | 1710 event.event_f = Ph_WM_HIDE; |
1711 event.event_state = Ph_WM_EVSTATE_HIDE; | |
3076 | 1712 event.rid = PtWidgetRid(gui.vimWindow); |
1713 PtForwardWindowEvent(&event); | |
7 | 1714 } |
1715 | |
1716 #if defined(FEAT_EVAL) || defined(PROTO) | |
1717 /* | |
1718 * Bring the Vim window to the foreground. | |
1719 */ | |
1720 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
1721 gui_mch_set_foreground(void) |
7 | 1722 { |
1723 PhWindowEvent_t event; | |
1724 | |
3076 | 1725 memset(&event, 0, sizeof (event)); |
7 | 1726 event.event_f = Ph_WM_TOFRONT; |
1727 event.event_state = Ph_WM_EVSTATE_FFRONT; | |
3076 | 1728 event.rid = PtWidgetRid(gui.vimWindow); |
1729 PtForwardWindowEvent(&event); | |
7 | 1730 } |
1731 #endif | |
1732 | |
1733 void | |
1734 gui_mch_settitle(char_u *title, char_u *icon) | |
1735 { | |
1736 #ifdef USE_PANEL_GROUP | |
3076 | 1737 gui_ph_pg_set_buffer_num(curwin->w_buffer->b_fnum); |
7 | 1738 #endif |
3076 | 1739 PtSetResource(gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0); |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1740 // Not sure what to do with the icon text, set balloon text somehow? |
7 | 1741 } |
1742 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1743 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1744 // Scrollbar |
7 | 1745 |
1746 void | |
1747 gui_mch_set_scrollbar_thumb(scrollbar_T *sb, int val, int size, int max) | |
1748 { | |
1749 int n = 0; | |
1750 PtArg_t args[3]; | |
1751 | |
3076 | 1752 PtSetArg(&args[ n++ ], Pt_ARG_MAXIMUM, max, 0); |
1753 PtSetArg(&args[ n++ ], Pt_ARG_SLIDER_SIZE, size, 0); | |
1754 PtSetArg(&args[ n++ ], Pt_ARG_GAUGE_VALUE, val, 0); | |
1755 PtSetResources(sb->id, n, args); | |
7 | 1756 } |
1757 | |
1758 void | |
1759 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h) | |
1760 { | |
1761 PhArea_t area = {{ x, y }, { w, h }}; | |
1762 | |
3076 | 1763 PtSetResource(sb->id, Pt_ARG_AREA, &area, 0); |
7 | 1764 } |
1765 | |
21355
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1766 int |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1767 gui_mch_get_scrollbar_xpadding(void) |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1768 { |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1769 // TODO: Calculate the padding for adjust scrollbar position when the |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1770 // Window is maximized. |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1771 return 0; |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1772 } |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1773 |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1774 int |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1775 gui_mch_get_scrollbar_ypadding(void) |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1776 { |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1777 // TODO: Calculate the padding for adjust scrollbar position when the |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1778 // Window is maximized. |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1779 return 0; |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1780 } |
fcccc29bd386
patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1781 |
7 | 1782 void |
1783 gui_mch_create_scrollbar(scrollbar_T *sb, int orient) | |
1784 { | |
1785 int n = 0; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1786 // int anchor_flags = 0; |
7 | 1787 PtArg_t args[4]; |
1788 | |
1789 /* | |
1790 * Stop the scrollbar from being realized when the parent | |
1791 * is realized, so it can be explicitly realized by vim. | |
1792 * | |
1793 * Also, don't let the scrollbar get focus | |
1794 */ | |
3076 | 1795 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, |
1796 Pt_DELAY_REALIZE | Pt_GETS_FOCUS); | |
1797 PtSetArg(&args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0); | |
7 | 1798 #if 0 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1799 // Don't need this anchoring for the scrollbars |
3076 | 1800 if (orient == SBAR_HORIZ) |
7 | 1801 { |
1802 anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | | |
1803 Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT; | |
1804 } | |
1805 else | |
1806 { | |
1807 anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP; | |
3076 | 1808 if (sb->wp != NULL) |
7 | 1809 { |
3076 | 1810 if (sb == &sb->wp->w_scrollbars[ SBAR_LEFT ]) |
7 | 1811 anchor_flags |= Pt_LEFT_ANCHORED_LEFT; |
1812 else | |
1813 anchor_flags |= Pt_RIGHT_ANCHORED_RIGHT; | |
1814 } | |
1815 } | |
3076 | 1816 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, anchor_flags, Pt_IS_ANCHORED); |
7 | 1817 #endif |
3076 | 1818 PtSetArg(&args[ n++ ], Pt_ARG_ORIENTATION, |
1819 (orient == SBAR_HORIZ) ? Pt_HORIZONTAL : Pt_VERTICAL, 0); | |
7 | 1820 #ifdef USE_PANEL_GROUP |
3076 | 1821 sb->id = PtCreateWidget(PtScrollbar, gui.vimPanelGroup, n, args); |
7 | 1822 #else |
3076 | 1823 sb->id = PtCreateWidget(PtScrollbar, gui.vimContainer, n, args); |
7 | 1824 #endif |
1825 | |
3076 | 1826 PtAddCallback(sb->id, Pt_CB_SCROLLBAR_MOVE, gui_ph_handle_scrollbar, sb); |
7 | 1827 } |
1828 | |
1829 void | |
1830 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) | |
1831 { | |
3076 | 1832 if (flag != 0) |
1833 PtRealizeWidget(sb->id); | |
7 | 1834 else |
3076 | 1835 PtUnrealizeWidget(sb->id); |
7 | 1836 } |
1837 | |
1838 void | |
1839 gui_mch_destroy_scrollbar(scrollbar_T *sb) | |
1840 { | |
3076 | 1841 PtDestroyWidget(sb->id); |
7 | 1842 sb->id = NULL; |
1843 } | |
1844 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1845 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1846 // Mouse functions |
7 | 1847 |
1848 #if defined(FEAT_MOUSESHAPE) || defined(PROTO) | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1849 // The last set mouse pointer shape is remembered, to be used when it goes |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1850 // from hidden to not hidden. |
7 | 1851 static int last_shape = 0; |
1852 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1853 // Table for shape IDs. Keep in sync with the mshape_names[] table in |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1854 // misc2.c! |
7 | 1855 static int mshape_ids[] = |
1856 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1857 Ph_CURSOR_POINTER, // arrow |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1858 Ph_CURSOR_NONE, // blank |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1859 Ph_CURSOR_INSERT, // beam |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1860 Ph_CURSOR_DRAG_VERTICAL, // updown |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1861 Ph_CURSOR_DRAG_VERTICAL, // udsizing |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1862 Ph_CURSOR_DRAG_HORIZONTAL, // leftright |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1863 Ph_CURSOR_DRAG_HORIZONTAL, // lrsizing |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1864 Ph_CURSOR_WAIT, // busy |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1865 Ph_CURSOR_DONT, // no |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1866 Ph_CURSOR_CROSSHAIR, // crosshair |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1867 Ph_CURSOR_FINGER, // hand1 |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1868 Ph_CURSOR_FINGER, // hand2 |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1869 Ph_CURSOR_FINGER, // pencil |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1870 Ph_CURSOR_QUESTION_POINT, // question |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1871 Ph_CURSOR_POINTER, // right-arrow |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1872 Ph_CURSOR_POINTER, // up-arrow |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1873 Ph_CURSOR_POINTER // last one |
7 | 1874 }; |
1875 | |
1876 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
1877 mch_set_mouse_shape(int shape) |
7 | 1878 { |
1879 int id; | |
1880 | |
1881 if (!gui.in_use) | |
1882 return; | |
1883 | |
1884 if (shape == MSHAPE_HIDE || gui.pointer_hidden) | |
3076 | 1885 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, |
1886 0); | |
7 | 1887 else |
1888 { | |
1889 if (shape >= MSHAPE_NUMBERED) | |
1890 id = Ph_CURSOR_POINTER; | |
1891 else | |
1892 id = mshape_ids[shape]; | |
1893 | |
3076 | 1894 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, id, 0); |
7 | 1895 } |
1896 if (shape != MSHAPE_HIDE) | |
1897 last_shape = shape; | |
1898 } | |
1899 #endif | |
1900 | |
1901 void | |
1902 gui_mch_mousehide(int hide) | |
1903 { | |
3076 | 1904 if (gui.pointer_hidden != hide) |
7 | 1905 { |
1906 gui.pointer_hidden = hide; | |
1907 #ifdef FEAT_MOUSESHAPE | |
3076 | 1908 if (hide) |
1909 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, | |
1910 Ph_CURSOR_NONE, 0); | |
7 | 1911 else |
3076 | 1912 mch_set_mouse_shape(last_shape); |
7 | 1913 #else |
3076 | 1914 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, |
1915 (hide == MOUSE_SHOW) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE, | |
1916 0); | |
7 | 1917 #endif |
1918 } | |
1919 } | |
1920 | |
95 | 1921 void |
87 | 1922 gui_mch_getmouse(int *x, int *y) |
7 | 1923 { |
1924 PhCursorInfo_t info; | |
87 | 1925 short ix, iy; |
7 | 1926 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1927 // FIXME: does this return the correct position, |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1928 // with respect to the border? |
3076 | 1929 PhQueryCursor(PhInputGroup(NULL), &info); |
1930 PtGetAbsPosition(gui.vimTextArea , &ix, &iy); | |
87 | 1931 |
1932 *x = info.pos.x - ix; | |
1933 *y = info.pos.y - iy; | |
7 | 1934 } |
1935 | |
1936 void | |
1937 gui_mch_setmouse(int x, int y) | |
1938 { | |
1939 short abs_x, abs_y; | |
1940 | |
3076 | 1941 PtGetAbsPosition(gui.vimTextArea, &abs_x, &abs_y); |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1942 // Add the border offset? |
3076 | 1943 PhMoveCursorAbs(PhInputGroup(NULL), abs_x + x, abs_y + y); |
7 | 1944 } |
1945 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1946 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1947 // Colours |
7 | 1948 |
1949 /* | |
1950 * Return the RGB value of a pixel as a long. | |
1951 */ | |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9428
diff
changeset
|
1952 guicolor_T |
7 | 1953 gui_mch_get_rgb(guicolor_T pixel) |
1954 { | |
9939
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9428
diff
changeset
|
1955 return (guicolor_T)(PgRGB(PgRedValue(pixel), |
ccb6461b82df
commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents:
9428
diff
changeset
|
1956 PgGreenValue(pixel), PgBlueValue(pixel))); |
7 | 1957 } |
1958 | |
1959 void | |
1960 gui_mch_new_colors(void) | |
1961 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1962 #if 0 // Don't bother changing the cursor colour |
7 | 1963 short color_diff; |
1964 | |
1965 /* | |
1966 * If there isn't enough difference between the background colour and | |
1967 * the mouse pointer colour then change the mouse pointer colour | |
1968 */ | |
1969 color_diff = gui_get_lightness(gui_ph_mouse_color) | |
1970 - gui_get_lightness(gui.back_pixel); | |
1971 | |
3076 | 1972 if (abs(color_diff) < 64) |
7 | 1973 { |
1974 short r, g, b; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1975 // not a great algorithm... |
3076 | 1976 r = PgRedValue(gui_ph_mouse_color) ^ 255; |
1977 g = PgGreenValue(gui_ph_mouse_color) ^ 255; | |
1978 b = PgBlueValue(gui_ph_mouse_color) ^ 255; | |
7 | 1979 |
1980 #ifndef FEAT_MOUSESHAPE | |
3076 | 1981 gui_ph_mouse_color = PgRGB(r, g, b); |
1982 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_COLOR, | |
1983 gui_ph_mouse_color, 0); | |
7 | 1984 #endif |
1985 } | |
1986 #endif | |
1987 | |
3076 | 1988 PtSetResource(gui.vimTextArea, Pt_ARG_FILL_COLOR, gui.back_pixel, 0); |
7 | 1989 } |
1990 | |
1991 /* | |
1214 | 1992 * This should be split out into a separate file, |
7 | 1993 * every port does basically the same thing. |
1994 * | |
1995 * This is the gui_w32.c version (i think..) | |
1996 * Return INVALCOLOR when failed. | |
1997 */ | |
1998 | |
1999 guicolor_T | |
2000 gui_mch_get_color(char_u *name) | |
2001 { | |
9013
22c29a515b53
commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
2002 return gui_get_color_cmn(name); |
7 | 2003 } |
2004 | |
11745
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2005 guicolor_T |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2006 gui_mch_get_rgb_color(int r, int g, int b) |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2007 { |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2008 return gui_get_rgb_color_cmn(r, g, b); |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2009 } |
5a5709918a98
patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2010 |
7 | 2011 void |
2012 gui_mch_set_fg_color(guicolor_T color) | |
2013 { | |
3076 | 2014 PgSetTextColor(color); |
7 | 2015 } |
2016 | |
2017 void | |
2018 gui_mch_set_bg_color(guicolor_T color) | |
2019 { | |
3076 | 2020 PgSetFillColor(color); |
7 | 2021 } |
2022 | |
2023 void | |
205 | 2024 gui_mch_set_sp_color(guicolor_T color) |
2025 { | |
2026 } | |
2027 | |
2028 void | |
7 | 2029 gui_mch_invert_rectangle(int row, int col, int nr, int nc) |
2030 { | |
2031 PhRect_t rect; | |
2032 | |
3076 | 2033 rect.ul.x = FILL_X(col); |
2034 rect.ul.y = FILL_Y(row); | |
7 | 2035 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2036 // FIXME: This has an off by one pixel problem |
7 | 2037 rect.lr.x = rect.ul.x + nc * gui.char_width; |
2038 rect.lr.y = rect.ul.y + nr * gui.char_height; | |
3076 | 2039 if (nc > 0) |
7 | 2040 rect.lr.x -= 1; |
3076 | 2041 if (nr > 0) |
7 | 2042 rect.lr.y -= 1; |
2043 | |
2044 DRAW_START; | |
3076 | 2045 PgSetDrawMode(Pg_DrawModeDSTINVERT); |
2046 PgDrawRect(&rect, Pg_DRAW_FILL); | |
2047 PgSetDrawMode(Pg_DrawModeSRCCOPY); | |
7 | 2048 DRAW_END; |
2049 } | |
2050 | |
2051 void | |
2052 gui_mch_clear_block(int row1, int col1, int row2, int col2) | |
2053 { | |
2054 PhRect_t block = { | |
3076 | 2055 { FILL_X(col1), FILL_Y(row1) }, |
2056 { FILL_X(col2 + 1) - 1, FILL_Y(row2 + 1) - 1} | |
7 | 2057 }; |
2058 | |
2059 DRAW_START; | |
3076 | 2060 gui_mch_set_bg_color(gui.back_pixel); |
2061 PgDrawRect(&block, Pg_DRAW_FILL); | |
7 | 2062 DRAW_END; |
2063 } | |
2064 | |
2065 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
2066 gui_mch_clear_all(void) |
7 | 2067 { |
2068 PhRect_t text_rect = { | |
2069 { gui.border_width, gui.border_width }, | |
2070 { Columns * gui.char_width + gui.border_width - 1 , | |
2071 Rows * gui.char_height + gui.border_width - 1 } | |
2072 }; | |
2073 | |
3076 | 2074 if (is_ignore_draw == TRUE) |
7 | 2075 return; |
2076 | |
2077 DRAW_START; | |
3076 | 2078 gui_mch_set_bg_color(gui.back_pixel); |
2079 PgDrawRect(&text_rect, Pg_DRAW_FILL); | |
7 | 2080 DRAW_END; |
2081 } | |
2082 | |
2083 void | |
2084 gui_mch_delete_lines(int row, int num_lines) | |
2085 { | |
2086 PhRect_t rect; | |
2087 PhPoint_t delta; | |
2088 | |
3076 | 2089 rect.ul.x = FILL_X(gui.scroll_region_left); |
2090 rect.ul.y = FILL_Y(row + num_lines); | |
2091 | |
2092 rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1; | |
2093 rect.lr.y = FILL_Y(gui.scroll_region_bot + 1) - 1; | |
2094 | |
2095 PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset); | |
2096 PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL)); | |
2097 PhTranslateRect(&rect, &gui_ph_raw_offset); | |
7 | 2098 |
2099 delta.x = 0; | |
2100 delta.y = -num_lines * gui.char_height; | |
2101 | |
2102 PgFlush(); | |
2103 | |
3076 | 2104 PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)), &rect, &delta); |
7 | 2105 |
2106 gui_clear_block( | |
2107 gui.scroll_region_bot - num_lines + 1, | |
2108 gui.scroll_region_left, | |
2109 gui.scroll_region_bot, | |
3076 | 2110 gui.scroll_region_right); |
7 | 2111 } |
2112 | |
2113 void | |
2114 gui_mch_insert_lines(int row, int num_lines) | |
2115 { | |
2116 PhRect_t rect; | |
2117 PhPoint_t delta; | |
2118 | |
3076 | 2119 rect.ul.x = FILL_X(gui.scroll_region_left); |
2120 rect.ul.y = FILL_Y(row); | |
2121 | |
2122 rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1; | |
2123 rect.lr.y = FILL_Y(gui.scroll_region_bot - num_lines + 1) - 1; | |
2124 | |
2125 PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset); | |
2126 PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL)); | |
2127 PhTranslateRect(&rect, &gui_ph_raw_offset); | |
7 | 2128 |
2129 delta.x = 0; | |
2130 delta.y = num_lines * gui.char_height; | |
2131 | |
2132 PgFlush(); | |
2133 | |
3076 | 2134 PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)) , &rect, &delta); |
2135 | |
2136 gui_clear_block(row, gui.scroll_region_left, | |
2137 row + num_lines - 1, gui.scroll_region_right); | |
7 | 2138 } |
2139 | |
2140 void | |
2141 gui_mch_draw_string(int row, int col, char_u *s, int len, int flags) | |
2142 { | |
2143 static char *utf8_buffer = NULL; | |
2144 static int utf8_len = 0; | |
2145 | |
3076 | 2146 PhPoint_t pos = { TEXT_X(col), TEXT_Y(row) }; |
7 | 2147 PhRect_t rect; |
2148 | |
3076 | 2149 if (is_ignore_draw == TRUE) |
7 | 2150 return; |
2151 | |
2152 DRAW_START; | |
2153 | |
3076 | 2154 if (!(flags & DRAW_TRANSP)) |
7 | 2155 { |
2156 PgDrawIRect( | |
3076 | 2157 FILL_X(col), FILL_Y(row), |
2158 FILL_X(col + len) - 1, FILL_Y(row + 1) - 1, | |
2159 Pg_DRAW_FILL); | |
7 | 2160 } |
2161 | |
3076 | 2162 if (flags & DRAW_UNDERL) |
2163 PgSetUnderline(gui.norm_pixel, Pg_TRANSPARENT, 0); | |
2164 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2165 if (charset_translate != NULL && enc_utf8 == 0) |
7 | 2166 { |
2167 int src_taken, dst_made; | |
2168 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2169 // Use a static buffer to avoid large amounts of de/allocations |
3076 | 2170 if (utf8_len < len) |
7 | 2171 { |
3076 | 2172 utf8_buffer = realloc(utf8_buffer, len * MB_LEN_MAX); |
7 | 2173 utf8_len = len; |
2174 } | |
2175 | |
2176 PxTranslateToUTF( | |
2177 charset_translate, | |
2178 s, | |
2179 len, | |
2180 &src_taken, | |
2181 utf8_buffer, | |
2182 utf8_len, | |
3076 | 2183 &dst_made); |
7 | 2184 s = utf8_buffer; |
2185 len = dst_made; | |
2186 } | |
2187 | |
3076 | 2188 PgDrawText(s, len, &pos, 0); |
2189 | |
2190 if (flags & DRAW_BOLD) | |
7 | 2191 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2192 // FIXME: try and only calculate these values once... |
3076 | 2193 rect.ul.x = FILL_X(col) + 1; |
2194 rect.ul.y = FILL_Y(row); | |
2195 rect.lr.x = FILL_X(col + len) - 1; | |
2196 rect.lr.y = FILL_Y(row + 1) - 1; | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2197 // PgSetUserClip(NULL) causes the scrollbar to not redraw... |
7 | 2198 #if 0 |
2199 pos.x++; | |
2200 | |
3076 | 2201 PgSetUserClip(&rect); |
2202 PgDrawText(s, len, &pos, 0); | |
2203 PgSetUserClip(NULL); | |
7 | 2204 #else |
3076 | 2205 rect.lr.y -= (p_linespace + 1) / 2; |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2206 // XXX: DrawTextArea doesn't work with phditto |
3076 | 2207 PgDrawTextArea(s, len, &rect, Pg_TEXT_BOTTOM); |
7 | 2208 #endif |
2209 } | |
2210 | |
3076 | 2211 if (flags & DRAW_UNDERL) |
2212 PgSetUnderline(Pg_TRANSPARENT, Pg_TRANSPARENT, 0); | |
7 | 2213 |
2214 DRAW_END; | |
2215 } | |
2216 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2217 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2218 // Cursor |
7 | 2219 |
2220 void | |
2221 gui_mch_draw_hollow_cursor(guicolor_T color) | |
2222 { | |
2223 PhRect_t r; | |
2224 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2225 // FIXME: Double width characters |
7 | 2226 |
3076 | 2227 r.ul.x = FILL_X(gui.col); |
2228 r.ul.y = FILL_Y(gui.row); | |
7 | 2229 r.lr.x = r.ul.x + gui.char_width - 1; |
2230 r.lr.y = r.ul.y + gui.char_height - 1; | |
2231 | |
2232 DRAW_START; | |
3076 | 2233 PgSetStrokeColor(color); |
2234 PgDrawRect(&r, Pg_DRAW_STROKE); | |
7 | 2235 DRAW_END; |
2236 } | |
2237 | |
2238 void | |
2239 gui_mch_draw_part_cursor(int w, int h, guicolor_T color) | |
2240 { | |
2241 PhRect_t r; | |
2242 | |
3076 | 2243 r.ul.x = FILL_X(gui.col); |
2244 r.ul.y = FILL_Y(gui.row) + gui.char_height - h; | |
7 | 2245 r.lr.x = r.ul.x + w - 1; |
2246 r.lr.y = r.ul.y + h - 1; | |
2247 | |
2248 DRAW_START; | |
3076 | 2249 gui_mch_set_bg_color(color); |
2250 PgDrawRect(&r, Pg_DRAW_FILL); | |
7 | 2251 DRAW_END; |
2252 } | |
2253 | |
9213
bb86514cad15
commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents:
9013
diff
changeset
|
2254 int |
bb86514cad15
commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents:
9013
diff
changeset
|
2255 gui_mch_is_blinking(void) |
bb86514cad15
commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents:
9013
diff
changeset
|
2256 { |
bb86514cad15
commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents:
9013
diff
changeset
|
2257 return blink_state != BLINK_NONE; |
bb86514cad15
commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents:
9013
diff
changeset
|
2258 } |
bb86514cad15
commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents:
9013
diff
changeset
|
2259 |
9428
0c7f47088e55
commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents:
9213
diff
changeset
|
2260 int |
0c7f47088e55
commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents:
9213
diff
changeset
|
2261 gui_mch_is_blink_off(void) |
0c7f47088e55
commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents:
9213
diff
changeset
|
2262 { |
0c7f47088e55
commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents:
9213
diff
changeset
|
2263 return blink_state == BLINK_OFF; |
0c7f47088e55
commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents:
9213
diff
changeset
|
2264 } |
0c7f47088e55
commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents:
9213
diff
changeset
|
2265 |
7 | 2266 void |
2267 gui_mch_set_blinking(long wait, long on, long off) | |
2268 { | |
2269 blink_waittime = wait; | |
2270 blink_ontime = on; | |
2271 blink_offtime = off; | |
2272 } | |
2273 | |
2274 void | |
2275 gui_mch_start_blink(void) | |
2276 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2277 // Only turn on the timer on if none of the times are zero |
3076 | 2278 if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) |
7 | 2279 { |
3076 | 2280 PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, |
2281 blink_waittime, 0); | |
7 | 2282 blink_state = BLINK_ON; |
2283 gui_update_cursor(TRUE, FALSE); | |
2284 } | |
2285 } | |
2286 | |
2287 void | |
13152
f4c3a7f410f4
patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
2288 gui_mch_stop_blink(int may_call_gui_update_cursor) |
7 | 2289 { |
3076 | 2290 PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0); |
2291 | |
13152
f4c3a7f410f4
patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents:
11745
diff
changeset
|
2292 if (blink_state == BLINK_OFF && may_call_gui_update_cursor) |
7 | 2293 gui_update_cursor(TRUE, FALSE); |
2294 | |
2295 blink_state = BLINK_NONE; | |
2296 } | |
2297 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2298 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2299 // miscellaneous functions |
7 | 2300 |
2301 void | |
2302 gui_mch_beep(void) | |
2303 { | |
2304 PtBeep(); | |
2305 } | |
2306 | |
2307 void | |
2308 gui_mch_flash(int msec) | |
2309 { | |
3076 | 2310 PgSetFillXORColor(Pg_BLACK, Pg_WHITE); |
2311 PgSetDrawMode(Pg_DRAWMODE_XOR); | |
7 | 2312 gui_mch_clear_all(); |
2313 gui_mch_flush(); | |
2314 | |
3076 | 2315 ui_delay((long) msec, TRUE); |
7 | 2316 |
2317 gui_mch_clear_all(); | |
3076 | 2318 PgSetDrawMode(Pg_DRAWMODE_OPAQUE); |
7 | 2319 gui_mch_flush(); |
2320 } | |
2321 | |
2322 void | |
2323 gui_mch_flush(void) | |
2324 { | |
2325 PgFlush(); | |
2326 } | |
2327 | |
2328 void | |
2329 gui_mch_set_text_area_pos(int x, int y, int w, int h) | |
2330 { | |
2331 PhArea_t area = {{x, y}, {w, h}}; | |
2332 | |
3076 | 2333 PtSetResource(gui.vimTextArea, Pt_ARG_AREA, &area, 0); |
7 | 2334 } |
2335 | |
2336 int | |
2337 gui_mch_haskey(char_u *name) | |
2338 { | |
2339 int i; | |
2340 | |
2341 for (i = 0; special_keys[i].key_sym != 0; i++) | |
2342 if (name[0] == special_keys[i].vim_code0 && | |
2343 name[1] == special_keys[i].vim_code1) | |
2980 | 2344 return OK; |
2345 return FAIL; | |
7 | 2346 } |
2347 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2348 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2349 // Menu |
7 | 2350 |
2351 #ifdef FEAT_TOOLBAR | |
2352 #include "toolbar.phi" | |
2353 | |
2354 static PhImage_t *gui_ph_toolbar_images[] = { | |
2355 &tb_new_phi, | |
2356 &tb_open_phi, | |
2357 &tb_save_phi, | |
2358 &tb_undo_phi, | |
2359 &tb_redo_phi, | |
2360 &tb_cut_phi, | |
2361 &tb_copy_phi, | |
2362 &tb_paste_phi, | |
2363 &tb_print_phi, | |
2364 &tb_help_phi, | |
2365 &tb_find_phi, | |
2366 &tb_save_all_phi, | |
2367 &tb_save_session_phi, | |
2368 &tb_new_session_phi, | |
2369 &tb_load_session_phi, | |
2370 &tb_macro_phi, | |
2371 &tb_replace_phi, | |
2372 &tb_close_phi, | |
2373 &tb_maximize_phi, | |
2374 &tb_minimize_phi, | |
2375 &tb_split_phi, | |
2376 &tb_shell_phi, | |
2377 &tb_find_prev_phi, | |
2378 &tb_find_next_phi, | |
2379 &tb_find_help_phi, | |
2380 &tb_make_phi, | |
2381 &tb_jump_phi, | |
2382 &tb_ctags_phi, | |
2383 &tb_vsplit_phi, | |
2384 &tb_maxwidth_phi, | |
2385 &tb_minwidth_phi | |
2386 }; | |
2387 | |
2388 static PhImage_t * | |
3076 | 2389 gui_ph_toolbar_load_icon(char_u *iconfile) |
7 | 2390 { |
2391 static PhImage_t external_icon; | |
2392 PhImage_t *temp_phi = NULL; | |
2393 | |
3076 | 2394 temp_phi = PxLoadImage(iconfile, NULL); |
2395 if (temp_phi != NULL) | |
7 | 2396 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2397 // The label widget will free the image/palette/etc. for us when |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2398 // it's destroyed |
7 | 2399 temp_phi->flags |= Ph_RELEASE_IMAGE_ALL; |
3076 | 2400 memcpy(&external_icon, temp_phi, sizeof(external_icon)); |
2401 free(temp_phi); | |
7 | 2402 |
2403 temp_phi = &external_icon; | |
2404 } | |
2980 | 2405 return temp_phi; |
7 | 2406 } |
2407 | |
2408 /* | |
2409 * This returns either a builtin icon image, an external image or NULL | |
2410 * if it can't find either. The caller can't and doesn't need to try and | |
2411 * free() the returned image, and it can't store the image pointer. | |
2412 * (When setting the Pt_ARG_LABEL_IMAGE resource, the contents of the | |
2413 * PhImage_t are copied, and the original PhImage_t aren't needed anymore). | |
2414 */ | |
2415 static PhImage_t * | |
3076 | 2416 gui_ph_toolbar_find_icon(vimmenu_T *menu) |
7 | 2417 { |
2418 char_u full_pathname[ MAXPATHL + 1 ]; | |
2419 PhImage_t *icon = NULL; | |
2420 | |
3076 | 2421 if (menu->icon_builtin == FALSE) |
7 | 2422 { |
3076 | 2423 if (menu->iconfile != NULL) |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2424 // TODO: use gui_find_iconfile() |
3076 | 2425 icon = gui_ph_toolbar_load_icon(menu->iconfile); |
7 | 2426 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2427 // TODO: Restrict loading to just .png? Search for any format? |
3076 | 2428 if ((icon == NULL) && |
2429 ((gui_find_bitmap(menu->name, full_pathname, "gif") == OK) || | |
2430 (gui_find_bitmap(menu->name, full_pathname, "png") == OK))) | |
2431 icon = gui_ph_toolbar_load_icon(full_pathname); | |
2432 | |
2433 if (icon != NULL) | |
2980 | 2434 return icon; |
7 | 2435 } |
2436 | |
3076 | 2437 if (menu->iconidx >= 0 && |
2438 (menu->iconidx < ARRAY_LENGTH(gui_ph_toolbar_images))) | |
2980 | 2439 return gui_ph_toolbar_images[menu->iconidx]; |
7 | 2440 |
2980 | 2441 return NULL; |
7 | 2442 } |
2443 #endif | |
2444 | |
3076 | 2445 #if defined(FEAT_MENU) || defined(PROTO) |
7 | 2446 void |
2447 gui_mch_enable_menu(int flag) | |
2448 { | |
3076 | 2449 if (flag != 0) |
2450 PtRealizeWidget(gui.vimMenuBar); | |
7 | 2451 else |
3076 | 2452 PtUnrealizeWidget(gui.vimMenuBar); |
7 | 2453 } |
2454 | |
2455 void | |
2456 gui_mch_set_menu_pos(int x, int y, int w, int h) | |
2457 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2458 // Nothing |
7 | 2459 } |
2460 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2461 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2462 * Change the position of a menu button in the parent |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2463 */ |
7 | 2464 static void |
3076 | 2465 gui_ph_position_menu(PtWidget_t *widget, int priority) |
7 | 2466 { |
2467 PtWidget_t *traverse; | |
2468 vimmenu_T *menu; | |
2469 | |
3076 | 2470 traverse = PtWidgetChildBack(PtWidgetParent(widget)); |
7 | 2471 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2472 // Iterate through the list of widgets in traverse, until |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2473 // we find the position we want to insert our widget into |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2474 // TODO: traverse from front to back, possible speedup? |
3076 | 2475 while (traverse != NULL) |
7 | 2476 { |
3076 | 2477 PtGetResource(traverse, Pt_ARG_POINTER, &menu, 0); |
2478 | |
2479 if (menu != NULL && | |
7 | 2480 priority < menu->priority && |
3076 | 2481 widget != traverse) |
7 | 2482 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2483 // Insert the widget before the current traverse widget |
3076 | 2484 PtWidgetInsert(widget, traverse, 1); |
7 | 2485 return; |
2486 } | |
2487 | |
3076 | 2488 traverse = PtWidgetBrotherInFront(traverse); |
7 | 2489 } |
2490 } | |
2491 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2492 /* |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2493 * the index is ignored because it's not useful for our purposes |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2494 */ |
7 | 2495 void |
2496 gui_mch_add_menu(vimmenu_T *menu, int index) | |
2497 { | |
2498 vimmenu_T *parent = menu->parent; | |
2499 char_u *accel_key; | |
2500 char_u mnemonic_str[MB_LEN_MAX]; | |
2501 int n; | |
2502 PtArg_t args[5]; | |
2503 | |
2504 menu->submenu_id = menu->id = NULL; | |
2505 | |
3076 | 2506 if (menu_is_menubar(menu->name)) |
7 | 2507 { |
2508 | |
3076 | 2509 accel_key = vim_strchr(menu->name, '&'); |
2510 if (accel_key != NULL) | |
7 | 2511 { |
2512 mnemonic_str[0] = accel_key[1]; | |
2513 mnemonic_str[1] = NUL; | |
2514 } | |
2515 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2516 // Create the menu button |
7 | 2517 n = 0; |
3076 | 2518 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0); |
2519 PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0); | |
2520 if (accel_key != NULL) | |
2521 PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, 0); | |
2522 PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0); | |
2523 | |
2524 if (parent != NULL) | |
2525 PtSetArg(&args[ n++ ], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0); | |
2526 | |
2527 menu->id = PtCreateWidget(PtMenuButton, | |
7 | 2528 (parent == NULL) ? gui.vimMenuBar : parent->submenu_id, |
3076 | 2529 n, args); |
2530 | |
2531 PtAddCallback(menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu); | |
7 | 2532 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2533 // Create the actual menu |
7 | 2534 n = 0; |
3076 | 2535 if (parent != NULL) |
2536 PtSetArg(&args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD); | |
2537 | |
2538 menu->submenu_id = PtCreateWidget(PtMenu, menu->id, n, args); | |
2539 | |
2540 if (parent == NULL) | |
7 | 2541 { |
3076 | 2542 PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED, |
2543 gui_ph_handle_menu_unrealized, menu); | |
2544 | |
2545 if (menu->mnemonic != 0) | |
7 | 2546 { |
3076 | 2547 PtAddHotkeyHandler(gui.vimWindow, tolower(menu->mnemonic), |
2548 Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu); | |
7 | 2549 } |
2550 } | |
2551 | |
3076 | 2552 gui_ph_position_menu(menu->id, menu->priority); |
7 | 2553 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2554 // Redraw menubar here instead of gui_mch_draw_menubar |
3076 | 2555 if (gui.menu_is_active) |
2556 PtRealizeWidget(menu->id); | |
7 | 2557 } |
3076 | 2558 else if (menu_is_popup(menu->name)) |
7 | 2559 { |
3076 | 2560 menu->submenu_id = PtCreateWidget(PtMenu, gui.vimWindow, 0, NULL); |
2561 PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED, | |
2562 gui_ph_handle_menu_unrealized, menu); | |
7 | 2563 } |
2564 } | |
2565 | |
2566 void | |
2567 gui_mch_add_menu_item(vimmenu_T *menu, int index) | |
2568 { | |
2569 vimmenu_T *parent = menu->parent; | |
2570 char_u *accel_key; | |
2571 char_u mnemonic_str[MB_LEN_MAX]; | |
2572 int n; | |
2573 PtArg_t args[13]; | |
2574 | |
2575 n = 0; | |
3076 | 2576 PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0); |
7 | 2577 |
2578 #ifdef FEAT_TOOLBAR | |
3076 | 2579 if (menu_is_toolbar(parent->name)) |
7 | 2580 { |
3076 | 2581 if (menu_is_separator(menu->name)) |
7 | 2582 { |
3076 | 2583 PtSetArg(&args[ n++ ], Pt_ARG_SEP_FLAGS, |
2584 Pt_SEP_VERTICAL, Pt_SEP_ORIENTATION); | |
2585 PtSetArg(&args[ n++ ], Pt_ARG_SEP_TYPE, Pt_ETCHED_IN, 0); | |
2586 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, | |
2587 Pt_TRUE, Pt_ANCHOR_TOP_BOTTOM); | |
2588 PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, 2, 0); | |
2589 menu->id = PtCreateWidget(PtSeparator, gui.vimToolBar, n, args); | |
7 | 2590 } |
2591 else | |
2592 { | |
3076 | 2593 if (strstr((const char *) p_toolbar, "text") != NULL) |
7 | 2594 { |
3076 | 2595 PtSetArg(&args[ n++ ], Pt_ARG_BALLOON_POSITION, |
2596 Pt_BALLOON_BOTTOM, 0); | |
2597 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0); | |
2598 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_FONT, "TextFont08", 0); | |
7 | 2599 } |
3076 | 2600 if ((strstr((const char *) p_toolbar, "icons") != NULL) && |
2601 (gui_ph_toolbar_images != NULL)) | |
7 | 2602 { |
3076 | 2603 PtSetArg(&args[ n++ ], Pt_ARG_LABEL_IMAGE, |
2604 gui_ph_toolbar_find_icon(menu), 0); | |
2605 PtSetArg(&args[ n++ ], Pt_ARG_LABEL_TYPE, Pt_TEXT_IMAGE, 0); | |
2606 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_IMAGE_SPACING, 0, 0); | |
7 | 2607 } |
3076 | 2608 if (strstr((const char *) p_toolbar, "tooltips") != NULL) |
7 | 2609 { |
3076 | 2610 PtSetArg(&args[ n++ ], Pt_ARG_LABEL_BALLOON, |
2611 gui_ph_show_tooltip, 0); | |
2612 PtSetArg(&args[ n++ ], Pt_ARG_LABEL_FLAGS, | |
2613 Pt_TRUE, Pt_SHOW_BALLOON); | |
7 | 2614 } |
3076 | 2615 PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 1, 0); |
2616 PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 1, 0); | |
2617 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_FALSE, | |
2618 Pt_HIGHLIGHTED | Pt_GETS_FOCUS); | |
2619 PtSetArg(&args[ n++ ], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0); | |
2620 menu->id = PtCreateWidget(PtButton, gui.vimToolBar, n, args); | |
2621 | |
2622 PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu); | |
7 | 2623 } |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2624 // Update toolbar if it's open |
3076 | 2625 if (PtWidgetIsRealized(gui.vimToolBar)) |
2626 PtRealizeWidget(menu->id); | |
7 | 2627 } |
2628 else | |
2629 #endif | |
3076 | 2630 if (menu_is_separator(menu->name)) |
7 | 2631 { |
3076 | 2632 menu->id = PtCreateWidget(PtSeparator, parent->submenu_id, n, args); |
7 | 2633 } |
2634 else | |
2635 { | |
3076 | 2636 accel_key = vim_strchr(menu->name, '&'); |
2637 if (accel_key != NULL) | |
7 | 2638 { |
2639 mnemonic_str[0] = accel_key[1]; | |
2640 mnemonic_str[1] = NUL; | |
2641 } | |
2642 | |
3076 | 2643 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0); |
2644 if (accel_key != NULL) | |
2645 PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, | |
2646 0); | |
2647 | |
2648 PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0); | |
2649 | |
2650 menu->id = PtCreateWidget(PtMenuButton, parent->submenu_id, n, args); | |
2651 | |
2652 PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu); | |
7 | 2653 |
2654 #ifdef USE_PANEL_GROUP | |
3076 | 2655 if (gui_ph_is_buffer_item(menu, parent) == TRUE) |
7 | 2656 { |
3076 | 2657 PtAddCallback(menu->id, Pt_CB_DESTROYED, |
2658 gui_ph_handle_buffer_remove, menu); | |
2659 gui_ph_pg_add_buffer(menu->dname); | |
7 | 2660 } |
2661 #endif | |
2662 } | |
2663 | |
3076 | 2664 gui_ph_position_menu(menu->id, menu->priority); |
7 | 2665 } |
2666 | |
2667 void | |
2668 gui_mch_destroy_menu(vimmenu_T *menu) | |
2669 { | |
3076 | 2670 if (menu->submenu_id != NULL) |
2671 PtDestroyWidget(menu->submenu_id); | |
2672 if (menu->id != NULL) | |
2673 PtDestroyWidget(menu->id); | |
7 | 2674 |
2675 menu->submenu_id = NULL; | |
2676 menu->id = NULL; | |
2677 } | |
2678 | |
2679 void | |
2680 gui_mch_menu_grey(vimmenu_T *menu, int grey) | |
2681 { | |
2682 long flags, mask, fields; | |
2683 | |
3076 | 2684 if (menu->id == NULL) |
7 | 2685 return; |
2686 | |
3076 | 2687 flags = PtWidgetFlags(menu->id); |
2688 if (PtWidgetIsClass(menu->id, PtMenuButton) && | |
2689 PtWidgetIsClass(PtWidgetParent(menu->id), PtMenu)) | |
7 | 2690 { |
2691 fields = Pt_FALSE; | |
2692 mask = Pt_SELECTABLE | Pt_HIGHLIGHTED; | |
2693 } | |
2694 else | |
2695 { | |
2696 fields = Pt_TRUE; | |
2697 mask = Pt_BLOCKED | Pt_GHOST; | |
2698 } | |
2699 | |
3076 | 2700 if (! grey) |
7 | 2701 fields = ~fields; |
2702 | |
3076 | 2703 PtSetResource(menu->id, Pt_ARG_FLAGS, fields, |
2704 mask); | |
7 | 2705 } |
2706 | |
2707 void | |
2708 gui_mch_menu_hidden(vimmenu_T *menu, int hidden) | |
2709 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2710 // TODO: [un]realize the widget? |
7 | 2711 } |
2712 | |
2713 void | |
2714 gui_mch_draw_menubar(void) | |
2715 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2716 // The only time a redraw is needed is when a menu button |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2717 // is added to the menubar, and that is detected and the bar |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2718 // redrawn in gui_mch_add_menu_item |
7 | 2719 } |
2720 | |
2721 void | |
2722 gui_mch_show_popupmenu(vimmenu_T *menu) | |
2723 { | |
3076 | 2724 PtSetResource(menu->submenu_id, Pt_ARG_POS, &abs_mouse, 0); |
2725 PtRealizeWidget(menu->submenu_id); | |
7 | 2726 } |
2727 | |
2728 void | |
2729 gui_mch_toggle_tearoffs(int enable) | |
2730 { | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2731 // No tearoffs yet |
7 | 2732 } |
2733 | |
2734 #endif | |
2735 | |
3076 | 2736 #if defined(FEAT_TOOLBAR) || defined(PROTO) |
7 | 2737 void |
2738 gui_mch_show_toolbar(int showit) | |
2739 { | |
3076 | 2740 if (showit) |
2741 PtRealizeWidget(gui.vimToolBar); | |
7 | 2742 else |
3076 | 2743 PtUnrealizeWidget(gui.vimToolBar); |
7 | 2744 } |
2745 #endif | |
2746 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2747 //////////////////////////////////////////////////////////////////////////// |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2748 // Fonts |
7 | 2749 |
2750 static GuiFont | |
2751 gui_ph_get_font( | |
2752 char_u *font_name, | |
2753 int_u font_flags, | |
2754 int_u font_size, | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2755 // Check whether the resulting font has the font flags and size that |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2756 // was asked for |
7 | 2757 int_u enforce |
2758 ) | |
2759 { | |
2760 char_u *font_tag; | |
2761 FontQueryInfo info; | |
2762 int_u style; | |
2763 | |
3076 | 2764 font_tag = alloc(MAX_FONT_TAG); |
2765 if (font_tag != NULL) | |
7 | 2766 { |
3076 | 2767 if (PfGenerateFontName(font_name, font_flags, font_size, |
2768 font_tag) != NULL) | |
7 | 2769 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2770 // Enforce some limits on the font used |
7 | 2771 style = PHFONT_INFO_FIXED; |
2772 | |
3076 | 2773 if (enforce & PF_STYLE_BOLD) |
7 | 2774 style |= PHFONT_INFO_BOLD; |
3076 | 2775 if (enforce & PF_STYLE_ANTIALIAS) |
7 | 2776 style |= PHFONT_INFO_ALIAS; |
3076 | 2777 if (enforce & PF_STYLE_ITALIC) |
7 | 2778 style |= PHFONT_INFO_ITALIC; |
2779 | |
3076 | 2780 PfQueryFontInfo(font_tag, &info); |
2781 | |
2782 if (info.size == 0) | |
7 | 2783 font_size = 0; |
2784 | |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2785 // Make sure font size matches, and that the font style |
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2786 // at least has the bits we're checking for |
3076 | 2787 if (font_size == info.size && |
2788 style == (info.style & style)) | |
2980 | 2789 return (GuiFont)font_tag; |
7 | 2790 } |
3076 | 2791 vim_free(font_tag); |
7 | 2792 } |
2980 | 2793 return NULL; |
7 | 2794 } |
2795 | |
2796 /* | |
2797 * Split up the vim font name | |
2798 * | |
2799 * vim_font is in the form of | |
2800 * <name>:s<height>:a:b:i | |
2801 * | |
2802 * a = antialias | |
2803 * b = bold | |
2804 * i = italic | |
2805 * | |
2806 */ | |
2807 | |
2808 static int | |
2809 gui_ph_parse_font_name( | |
2810 char_u *vim_font, | |
2811 char_u **font_name, | |
2812 int_u *font_flags, | |
3076 | 2813 int_u *font_size) |
7 | 2814 { |
2815 char_u *mark; | |
2816 int_u name_len, size; | |
2817 | |
3076 | 2818 mark = vim_strchr(vim_font, ':'); |
2819 if (mark == NULL) | |
2820 name_len = STRLEN(vim_font); | |
7 | 2821 else |
3076 | 2822 name_len = (int_u) (mark - vim_font); |
2823 | |
2824 *font_name = vim_strnsave(vim_font, name_len); | |
2998 | 2825 if (*font_name != NULL) |
7 | 2826 { |
2998 | 2827 if (mark != NULL) |
7 | 2828 { |
2998 | 2829 while (*mark != NUL && *mark++ == ':') |
7 | 2830 { |
2998 | 2831 switch (tolower(*mark++)) |
7 | 2832 { |
2833 case 'a': *font_flags |= PF_STYLE_ANTIALIAS; break; | |
2834 case 'b': *font_flags |= PF_STYLE_BOLD; break; | |
2835 case 'i': *font_flags |= PF_STYLE_ITALIC; break; | |
2836 | |
2837 case 's': | |
3076 | 2838 size = getdigits(&mark); |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2839 // Restrict the size to some vague limits |
2998 | 2840 if (size < 1 || size > 100) |
7 | 2841 size = 8; |
2842 | |
2843 *font_size = size; | |
2844 break; | |
2845 | |
2846 default: | |
2847 break; | |
2848 } | |
2849 } | |
2850 } | |
2980 | 2851 return TRUE; |
7 | 2852 } |
2980 | 2853 return FALSE; |
7 | 2854 } |
2855 | |
2856 int | |
2857 gui_mch_init_font(char_u *vim_font_name, int fontset) | |
2858 { | |
2859 char_u *font_tag; | |
2860 char_u *font_name = NULL; | |
2861 int_u font_flags = 0; | |
2862 int_u font_size = 12; | |
2863 | |
2864 FontQueryInfo info; | |
2865 PhRect_t extent; | |
2866 | |
2998 | 2867 if (vim_font_name == NULL) |
7 | 2868 { |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2869 // Default font |
1922 | 2870 vim_font_name = "PC Terminal"; |
7 | 2871 } |
2872 | |
3076 | 2873 if (STRCMP(vim_font_name, "*") == 0) |
7 | 2874 { |
3076 | 2875 font_tag = PtFontSelection(gui.vimWindow, NULL, NULL, |
2876 "pcterm12", -1, PHFONT_FIXED, NULL); | |
7 | 2877 |
2998 | 2878 if (font_tag == NULL) |
2980 | 2879 return FAIL; |
7 | 2880 |
3076 | 2881 gui_mch_free_font(gui.norm_font); |
7 | 2882 gui.norm_font = font_tag; |
2883 | |
3076 | 2884 PfQueryFontInfo(font_tag, &info); |
2885 font_name = vim_strsave(info.font); | |
7 | 2886 } |
2887 else | |
2888 { | |
3076 | 2889 if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags, |
2890 &font_size) == FALSE) | |
2980 | 2891 return FAIL; |
7 | 2892 |
3076 | 2893 font_tag = gui_ph_get_font(font_name, font_flags, font_size, 0); |
2998 | 2894 if (font_tag == NULL) |
7 | 2895 { |
3076 | 2896 vim_free(font_name); |
2980 | 2897 return FAIL; |
7 | 2898 } |
37 | 2899 |
3076 | 2900 gui_mch_free_font(gui.norm_font); |
7 | 2901 gui.norm_font = font_tag; |
2902 } | |
2903 | |
3076 | 2904 gui_mch_free_font(gui.bold_font); |
2905 gui.bold_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_BOLD, | |
2906 font_size, PF_STYLE_BOLD); | |
2907 | |
2908 gui_mch_free_font(gui.ital_font); | |
2909 gui.ital_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_ITALIC, | |
2910 font_size, PF_STYLE_ITALIC); | |
7 | 2911 |
18788
e1f4e9d78a6a
patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2912 // This extent was brought to you by the letter 'g' |
3076 | 2913 PfExtentText(&extent, NULL, font_tag, "g", 1); |
7 | 2914 |
2915 gui.char_width = extent.lr.x - extent.ul.x + 1; | |
2916 gui.char_height = (- extent.ul.y) + extent.lr.y + 1; | |
2917 gui.char_ascent = - extent.ul.y; | |
2918 | |
3076 | 2919 vim_free(font_name); |
2980 | 2920 return OK; |
7 | 2921 } |
2922 | |
444 | 2923 /* |
2924 * Adjust gui.char_height (after 'linespace' was changed). | |
2925 */ | |
7 | 2926 int |
444 | 2927 gui_mch_adjust_charheight(void) |
7 | 2928 { |
2929 FontQueryInfo info; | |
2930 | |
3076 | 2931 PfQueryFontInfo(gui.norm_font, &info); |
7 | 2932 |
2933 gui.char_height = - info.ascender + info.descender + p_linespace; | |
2934 gui.char_ascent = - info.ascender + p_linespace / 2; | |
2935 | |
2980 | 2936 return OK; |
7 | 2937 } |
2938 | |
2939 GuiFont | |
2940 gui_mch_get_font(char_u *vim_font_name, int report_error) | |
2941 { | |
2942 char_u *font_name; | |
2943 char_u *font_tag; | |
2944 int_u font_size = 12; | |
2945 int_u font_flags = 0; | |
2946 | |
3076 | 2947 if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags, |
2948 &font_size) != FALSE) | |
7 | 2949 { |
3076 | 2950 font_tag = gui_ph_get_font(font_name, font_flags, font_size, -1); |
2951 vim_free(font_name); | |
7 | 2952 |
2998 | 2953 if (font_tag != NULL) |
2980 | 2954 return (GuiFont)font_tag; |
7 | 2955 } |
2956 | |
2998 | 2957 if (report_error) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
2958 semsg(e_unknown_font_str, vim_font_name); |
7 | 2959 |
2980 | 2960 return FAIL; |
7 | 2961 } |
2962 | |
44 | 2963 #if defined(FEAT_EVAL) || defined(PROTO) |
37 | 2964 /* |
2965 * Return the name of font "font" in allocated memory. | |
2966 * Don't know how to get the actual name, thus use the provided name. | |
2967 */ | |
2968 char_u * | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
2969 gui_mch_get_fontname(GuiFont font, char_u *name) |
37 | 2970 { |
2971 if (name == NULL) | |
2972 return NULL; | |
2973 return vim_strsave(name); | |
2974 } | |
44 | 2975 #endif |
37 | 2976 |
7 | 2977 void |
2978 gui_mch_set_font(GuiFont font) | |
2979 { | |
3076 | 2980 PgSetFont(font); |
7 | 2981 } |
2982 | |
2983 void | |
2984 gui_mch_free_font(GuiFont font) | |
2985 { | |
3076 | 2986 vim_free(font); |
7 | 2987 } |
2988 |