]>
Commit | Line | Data |
---|---|---|
59ab3540 AM |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.310 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.310 | |
11 | Problem: Code not following Vim style. | |
12 | Solution: Fix the style. (Elias Diem) | |
13 | Files: src/gui_photon.c | |
14 | ||
15 | ||
16 | *** ../vim-7.3.309/src/gui_photon.c 2011-09-07 19:08:57.000000000 +0200 | |
17 | --- src/gui_photon.c 2011-09-14 16:01:55.000000000 +0200 | |
18 | *************** | |
19 | *** 477,483 **** | |
20 | } | |
21 | #endif | |
22 | ||
23 | ! for(i = 0; special_keys[i].key_sym != 0; i++) | |
24 | { | |
25 | if (special_keys[i].key_sym == key->key_cap) | |
26 | { | |
27 | --- 477,483 ---- | |
28 | } | |
29 | #endif | |
30 | ||
31 | ! for (i = 0; special_keys[i].key_sym != 0; i++) | |
32 | { | |
33 | if (special_keys[i].key_sym == key->key_cap) | |
34 | { | |
35 | *************** | |
36 | *** 758,764 **** | |
37 | if (damage->next != NULL) | |
38 | damage = damage->next; | |
39 | ||
40 | ! while(damage != NULL) | |
41 | { | |
42 | r = &damage->rect; | |
43 | gui_redraw( | |
44 | --- 758,764 ---- | |
45 | if (damage->next != NULL) | |
46 | damage = damage->next; | |
47 | ||
48 | ! while (damage != NULL) | |
49 | { | |
50 | r = &damage->rect; | |
51 | gui_redraw( | |
52 | *************** | |
53 | *** 798,809 **** | |
54 | ||
55 | /* This is used for pulldown/popup menus and also toolbar buttons */ | |
56 | static int | |
57 | ! gui_ph_handle_menu( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) | |
58 | { | |
59 | ! if( data != NULL ) | |
60 | { | |
61 | vimmenu_T *menu = (vimmenu_T *) data; | |
62 | ! gui_menu_cb( menu ); | |
63 | } | |
64 | return Pt_CONTINUE; | |
65 | } | |
66 | --- 798,809 ---- | |
67 | ||
68 | /* This is used for pulldown/popup menus and also toolbar buttons */ | |
69 | static int | |
70 | ! gui_ph_handle_menu(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) | |
71 | { | |
72 | ! if (data != NULL) | |
73 | { | |
74 | vimmenu_T *menu = (vimmenu_T *) data; | |
75 | ! gui_menu_cb(menu); | |
76 | } | |
77 | return Pt_CONTINUE; | |
78 | } | |
79 | *************** | |
80 | *** 813,821 **** | |
81 | gui_ph_handle_menu_unrealized( | |
82 | PtWidget_t *widget, | |
83 | void *data, | |
84 | ! PtCallbackInfo_t *info ) | |
85 | { | |
86 | ! PtGiveFocus( gui.vimTextArea, NULL ); | |
87 | return Pt_CONTINUE; | |
88 | } | |
89 | ||
90 | --- 813,821 ---- | |
91 | gui_ph_handle_menu_unrealized( | |
92 | PtWidget_t *widget, | |
93 | void *data, | |
94 | ! PtCallbackInfo_t *info) | |
95 | { | |
96 | ! PtGiveFocus(gui.vimTextArea, NULL); | |
97 | return Pt_CONTINUE; | |
98 | } | |
99 | ||
100 | *************** | |
101 | *** 823,831 **** | |
102 | gui_ph_handle_window_open( | |
103 | PtWidget_t *widget, | |
104 | void *data, | |
105 | ! PtCallbackInfo_t *info ) | |
106 | { | |
107 | ! gui_set_shellsize( FALSE, TRUE, RESIZE_BOTH ); | |
108 | return Pt_CONTINUE; | |
109 | } | |
110 | ||
111 | --- 823,831 ---- | |
112 | gui_ph_handle_window_open( | |
113 | PtWidget_t *widget, | |
114 | void *data, | |
115 | ! PtCallbackInfo_t *info) | |
116 | { | |
117 | ! gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH); | |
118 | return Pt_CONTINUE; | |
119 | } | |
120 | ||
121 | *************** | |
122 | *** 836,909 **** | |
123 | ||
124 | /* TODO: Set a clipping rect? */ | |
125 | static void | |
126 | ! gui_ph_draw_start( void ) | |
127 | { | |
128 | PhGC_t *gc; | |
129 | ||
130 | gc = PgGetGC(); | |
131 | ! PgSetRegion( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) ); | |
132 | ! PgClearClippingsCx( gc ); | |
133 | ! PgClearTranslationCx( gc ); | |
134 | ||
135 | ! PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset ); | |
136 | ! PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos( gui.vimTextArea, NULL ) ); | |
137 | ||
138 | ! PgSetTranslation( &gui_ph_raw_offset, Pg_RELATIVE ); | |
139 | } | |
140 | ||
141 | static void | |
142 | ! gui_ph_draw_end( void ) | |
143 | { | |
144 | gui_ph_raw_offset.x = -gui_ph_raw_offset.x; | |
145 | gui_ph_raw_offset.y = -gui_ph_raw_offset.y; | |
146 | ! PgSetTranslation( &gui_ph_raw_offset, Pg_RELATIVE ); | |
147 | } | |
148 | ||
149 | #ifdef USE_PANEL_GROUP | |
150 | static vimmenu_T * | |
151 | ! gui_ph_find_buffer_item( char_u *name ) | |
152 | { | |
153 | vimmenu_T *top_level = root_menu; | |
154 | vimmenu_T *items = NULL; | |
155 | ||
156 | ! while( top_level != NULL && | |
157 | ! ( STRCMP( top_level->dname, "Buffers" ) != 0 ) ) | |
158 | top_level = top_level->next; | |
159 | ||
160 | ! if( top_level != NULL ) | |
161 | { | |
162 | items = top_level->children; | |
163 | ||
164 | ! while( items != NULL && | |
165 | ! ( STRCMP( items->dname, name ) != 0 ) ) | |
166 | items = items->next; | |
167 | } | |
168 | return items; | |
169 | } | |
170 | ||
171 | static void | |
172 | ! gui_ph_pg_set_buffer_num( int_u buf_num ) | |
173 | { | |
174 | int i; | |
175 | char search[16]; | |
176 | char *mark; | |
177 | ||
178 | ! if( gui.vimTextArea == NULL || buf_num == 0 ) | |
179 | return; | |
180 | ||
181 | search[0] = '('; | |
182 | ! ultoa( buf_num, &search[1], 10 ); | |
183 | ! STRCAT( search, ")" ); | |
184 | ||
185 | ! for( i = 0; i < num_panels; i++ ) | |
186 | { | |
187 | /* find the last "(" in the panel title and see if the buffer | |
188 | * number in the title matches the one we're looking for */ | |
189 | ! mark = STRRCHR( panel_titles[ i ], '(' ); | |
190 | ! if( mark != NULL && STRCMP( mark, search ) == 0 ) | |
191 | { | |
192 | ! PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX, | |
193 | ! i, 0 ); | |
194 | } | |
195 | } | |
196 | } | |
197 | --- 836,909 ---- | |
198 | ||
199 | /* TODO: Set a clipping rect? */ | |
200 | static void | |
201 | ! gui_ph_draw_start(void) | |
202 | { | |
203 | PhGC_t *gc; | |
204 | ||
205 | gc = PgGetGC(); | |
206 | ! PgSetRegion(PtWidgetRid(PtFindDisjoint(gui.vimTextArea))); | |
207 | ! PgClearClippingsCx(gc); | |
208 | ! PgClearTranslationCx(gc); | |
209 | ||
210 | ! PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset); | |
211 | ! PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL)); | |
212 | ||
213 | ! PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE); | |
214 | } | |
215 | ||
216 | static void | |
217 | ! gui_ph_draw_end(void) | |
218 | { | |
219 | gui_ph_raw_offset.x = -gui_ph_raw_offset.x; | |
220 | gui_ph_raw_offset.y = -gui_ph_raw_offset.y; | |
221 | ! PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE); | |
222 | } | |
223 | ||
224 | #ifdef USE_PANEL_GROUP | |
225 | static vimmenu_T * | |
226 | ! gui_ph_find_buffer_item(char_u *name) | |
227 | { | |
228 | vimmenu_T *top_level = root_menu; | |
229 | vimmenu_T *items = NULL; | |
230 | ||
231 | ! while (top_level != NULL && | |
232 | ! (STRCMP(top_level->dname, "Buffers") != 0)) | |
233 | top_level = top_level->next; | |
234 | ||
235 | ! if (top_level != NULL) | |
236 | { | |
237 | items = top_level->children; | |
238 | ||
239 | ! while (items != NULL && | |
240 | ! (STRCMP(items->dname, name) != 0)) | |
241 | items = items->next; | |
242 | } | |
243 | return items; | |
244 | } | |
245 | ||
246 | static void | |
247 | ! gui_ph_pg_set_buffer_num(int_u buf_num) | |
248 | { | |
249 | int i; | |
250 | char search[16]; | |
251 | char *mark; | |
252 | ||
253 | ! if (gui.vimTextArea == NULL || buf_num == 0) | |
254 | return; | |
255 | ||
256 | search[0] = '('; | |
257 | ! ultoa(buf_num, &search[1], 10); | |
258 | ! STRCAT(search, ")"); | |
259 | ||
260 | ! for (i = 0; i < num_panels; i++) | |
261 | { | |
262 | /* find the last "(" in the panel title and see if the buffer | |
263 | * number in the title matches the one we're looking for */ | |
264 | ! mark = STRRCHR(panel_titles[ i ], '('); | |
265 | ! if (mark != NULL && STRCMP(mark, search) == 0) | |
266 | { | |
267 | ! PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX, | |
268 | ! i, 0); | |
269 | } | |
270 | } | |
271 | } | |
272 | *************** | |
273 | *** 912,930 **** | |
274 | gui_ph_handle_pg_change( | |
275 | PtWidget_t *widget, | |
276 | void *data, | |
277 | ! PtCallbackInfo_t *info ) | |
278 | { | |
279 | vimmenu_T *menu; | |
280 | PtPanelGroupCallback_t *panel; | |
281 | ||
282 | ! if( info->event != NULL ) | |
283 | { | |
284 | panel = info->cbdata; | |
285 | ! if( panel->new_panel != NULL ) | |
286 | { | |
287 | ! menu = gui_ph_find_buffer_item( panel->new_panel ); | |
288 | ! if( menu ) | |
289 | ! gui_menu_cb( menu ); | |
290 | } | |
291 | } | |
292 | return Pt_CONTINUE; | |
293 | --- 912,930 ---- | |
294 | gui_ph_handle_pg_change( | |
295 | PtWidget_t *widget, | |
296 | void *data, | |
297 | ! PtCallbackInfo_t *info) | |
298 | { | |
299 | vimmenu_T *menu; | |
300 | PtPanelGroupCallback_t *panel; | |
301 | ||
302 | ! if (info->event != NULL) | |
303 | { | |
304 | panel = info->cbdata; | |
305 | ! if (panel->new_panel != NULL) | |
306 | { | |
307 | ! menu = gui_ph_find_buffer_item(panel->new_panel); | |
308 | ! if (menu) | |
309 | ! gui_menu_cb(menu); | |
310 | } | |
311 | } | |
312 | return Pt_CONTINUE; | |
313 | *************** | |
314 | *** 935,951 **** | |
315 | short *top, | |
316 | short *bottom, | |
317 | short *left, | |
318 | ! short *right ) | |
319 | { | |
320 | unsigned short abs_raw_x, abs_raw_y, abs_panel_x, abs_panel_y; | |
321 | const unsigned short *margin_top, *margin_bottom; | |
322 | const unsigned short *margin_left, *margin_right; | |
323 | ||
324 | ! PtGetAbsPosition( gui.vimTextArea, &abs_raw_x, &abs_raw_y ); | |
325 | ! PtGetAbsPosition( gui.vimPanelGroup, &abs_panel_x, &abs_panel_y ); | |
326 | ||
327 | ! PtGetResource( gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0 ); | |
328 | ! PtGetResource( gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0 ); | |
329 | ||
330 | abs_raw_x -= abs_panel_x; | |
331 | abs_raw_y -= abs_panel_y; | |
332 | --- 935,951 ---- | |
333 | short *top, | |
334 | short *bottom, | |
335 | short *left, | |
336 | ! short *right) | |
337 | { | |
338 | unsigned short abs_raw_x, abs_raw_y, abs_panel_x, abs_panel_y; | |
339 | const unsigned short *margin_top, *margin_bottom; | |
340 | const unsigned short *margin_left, *margin_right; | |
341 | ||
342 | ! PtGetAbsPosition(gui.vimTextArea, &abs_raw_x, &abs_raw_y); | |
343 | ! PtGetAbsPosition(gui.vimPanelGroup, &abs_panel_x, &abs_panel_y); | |
344 | ||
345 | ! PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0); | |
346 | ! PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0); | |
347 | ||
348 | abs_raw_x -= abs_panel_x; | |
349 | abs_raw_y -= abs_panel_y; | |
350 | *************** | |
351 | *** 959,979 **** | |
352 | ||
353 | /* Used for the tabs for PtPanelGroup */ | |
354 | static int | |
355 | ! gui_ph_is_buffer_item( vimmenu_T *menu, vimmenu_T *parent ) | |
356 | { | |
357 | char *mark; | |
358 | ||
359 | ! if( STRCMP( parent->dname, "Buffers" ) == 0 ) | |
360 | { | |
361 | /* Look for '(' digits ')' */ | |
362 | ! mark = vim_strchr( menu->dname, '(' ); | |
363 | ! if( mark != NULL ) | |
364 | { | |
365 | mark++; | |
366 | ! while( isdigit( *mark ) ) | |
367 | mark++; | |
368 | ||
369 | ! if( *mark == ')' ) | |
370 | return TRUE; | |
371 | } | |
372 | } | |
373 | --- 959,979 ---- | |
374 | ||
375 | /* Used for the tabs for PtPanelGroup */ | |
376 | static int | |
377 | ! gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent) | |
378 | { | |
379 | char *mark; | |
380 | ||
381 | ! if (STRCMP(parent->dname, "Buffers") == 0) | |
382 | { | |
383 | /* Look for '(' digits ')' */ | |
384 | ! mark = vim_strchr(menu->dname, '('); | |
385 | ! if (mark != NULL) | |
386 | { | |
387 | mark++; | |
388 | ! while (isdigit(*mark)) | |
389 | mark++; | |
390 | ||
391 | ! if (*mark == ')') | |
392 | return TRUE; | |
393 | } | |
394 | } | |
395 | *************** | |
396 | *** 981,1043 **** | |
397 | } | |
398 | ||
399 | static void | |
400 | ! gui_ph_pg_add_buffer(char *name ) | |
401 | { | |
402 | char **new_titles = NULL; | |
403 | ||
404 | ! new_titles = (char **) alloc( ( num_panels + 1 ) * sizeof( char ** ) ); | |
405 | ! if( new_titles != NULL ) | |
406 | { | |
407 | ! if( num_panels > 0 ) | |
408 | ! memcpy( new_titles, panel_titles, num_panels * sizeof( char ** ) ); | |
409 | ||
410 | new_titles[ num_panels++ ] = name; | |
411 | ||
412 | ! PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, | |
413 | ! num_panels ); | |
414 | ||
415 | ! vim_free( panel_titles ); | |
416 | panel_titles = new_titles; | |
417 | } | |
418 | } | |
419 | ||
420 | static void | |
421 | ! gui_ph_pg_remove_buffer( char *name ) | |
422 | { | |
423 | int i; | |
424 | char **new_titles = NULL; | |
425 | ||
426 | /* If there is only 1 panel, we just use the temporary place holder */ | |
427 | ! if( num_panels > 1 ) | |
428 | { | |
429 | ! new_titles = (char **) alloc( ( num_panels - 1 ) * sizeof( char ** ) ); | |
430 | ! if( new_titles != NULL ) | |
431 | { | |
432 | char **s = new_titles; | |
433 | /* Copy all the titles except the one we're removing */ | |
434 | ! for( i = 0; i < num_panels; i++ ) | |
435 | { | |
436 | ! if( STRCMP( panel_titles[ i ], name ) != 0 ) | |
437 | { | |
438 | *s++ = panel_titles[ i ]; | |
439 | } | |
440 | } | |
441 | num_panels--; | |
442 | ||
443 | ! PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, | |
444 | ! num_panels ); | |
445 | ||
446 | ! vim_free( panel_titles ); | |
447 | panel_titles = new_titles; | |
448 | } | |
449 | } | |
450 | else | |
451 | { | |
452 | num_panels--; | |
453 | ! PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title, | |
454 | ! 1 ); | |
455 | ||
456 | ! vim_free( panel_titles ); | |
457 | panel_titles = NULL; | |
458 | } | |
459 | } | |
460 | --- 981,1043 ---- | |
461 | } | |
462 | ||
463 | static void | |
464 | ! gui_ph_pg_add_buffer(char *name) | |
465 | { | |
466 | char **new_titles = NULL; | |
467 | ||
468 | ! new_titles = (char **) alloc((num_panels + 1) * sizeof(char **)); | |
469 | ! if (new_titles != NULL) | |
470 | { | |
471 | ! if (num_panels > 0) | |
472 | ! memcpy(new_titles, panel_titles, num_panels * sizeof(char **)); | |
473 | ||
474 | new_titles[ num_panels++ ] = name; | |
475 | ||
476 | ! PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, | |
477 | ! num_panels); | |
478 | ||
479 | ! vim_free(panel_titles); | |
480 | panel_titles = new_titles; | |
481 | } | |
482 | } | |
483 | ||
484 | static void | |
485 | ! gui_ph_pg_remove_buffer(char *name) | |
486 | { | |
487 | int i; | |
488 | char **new_titles = NULL; | |
489 | ||
490 | /* If there is only 1 panel, we just use the temporary place holder */ | |
491 | ! if (num_panels > 1) | |
492 | { | |
493 | ! new_titles = (char **) alloc((num_panels - 1) * sizeof(char **)); | |
494 | ! if (new_titles != NULL) | |
495 | { | |
496 | char **s = new_titles; | |
497 | /* Copy all the titles except the one we're removing */ | |
498 | ! for (i = 0; i < num_panels; i++) | |
499 | { | |
500 | ! if (STRCMP(panel_titles[ i ], name) != 0) | |
501 | { | |
502 | *s++ = panel_titles[ i ]; | |
503 | } | |
504 | } | |
505 | num_panels--; | |
506 | ||
507 | ! PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, | |
508 | ! num_panels); | |
509 | ||
510 | ! vim_free(panel_titles); | |
511 | panel_titles = new_titles; | |
512 | } | |
513 | } | |
514 | else | |
515 | { | |
516 | num_panels--; | |
517 | ! PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title, | |
518 | ! 1); | |
519 | ||
520 | ! vim_free(panel_titles); | |
521 | panel_titles = NULL; | |
522 | } | |
523 | } | |
524 | *************** | |
525 | *** 1047,1060 **** | |
526 | gui_ph_handle_buffer_remove( | |
527 | PtWidget_t *widget, | |
528 | void *data, | |
529 | ! PtCallbackInfo_t *info ) | |
530 | { | |
531 | vimmenu_T *menu; | |
532 | ||
533 | ! if( data != NULL ) | |
534 | { | |
535 | menu = (vimmenu_T *) data; | |
536 | ! gui_ph_pg_remove_buffer( menu->dname ); | |
537 | } | |
538 | ||
539 | return Pt_CONTINUE; | |
540 | --- 1047,1060 ---- | |
541 | gui_ph_handle_buffer_remove( | |
542 | PtWidget_t *widget, | |
543 | void *data, | |
544 | ! PtCallbackInfo_t *info) | |
545 | { | |
546 | vimmenu_T *menu; | |
547 | ||
548 | ! if (data != NULL) | |
549 | { | |
550 | menu = (vimmenu_T *) data; | |
551 | ! gui_ph_pg_remove_buffer(menu->dname); | |
552 | } | |
553 | ||
554 | return Pt_CONTINUE; | |
555 | *************** | |
556 | *** 1062,1074 **** | |
557 | #endif | |
558 | ||
559 | static int | |
560 | ! gui_ph_pane_resize( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) | |
561 | { | |
562 | ! if( PtWidgetIsRealized( widget ) ) | |
563 | { | |
564 | is_ignore_draw = TRUE; | |
565 | ! PtStartFlux( gui.vimContainer ); | |
566 | ! PtContainerHold( gui.vimContainer ); | |
567 | } | |
568 | ||
569 | return Pt_CONTINUE; | |
570 | --- 1062,1074 ---- | |
571 | #endif | |
572 | ||
573 | static int | |
574 | ! gui_ph_pane_resize(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) | |
575 | { | |
576 | ! if (PtWidgetIsRealized(widget)) | |
577 | { | |
578 | is_ignore_draw = TRUE; | |
579 | ! PtStartFlux(gui.vimContainer); | |
580 | ! PtContainerHold(gui.vimContainer); | |
581 | } | |
582 | ||
583 | return Pt_CONTINUE; | |
584 | *************** | |
585 | *** 1078,1084 **** | |
586 | ||
587 | #ifdef FEAT_MBYTE | |
588 | void | |
589 | ! gui_ph_encoding_changed( int new_encoding ) | |
590 | { | |
591 | /* Default encoding is latin1 */ | |
592 | char *charset = "latin1"; | |
593 | --- 1078,1084 ---- | |
594 | ||
595 | #ifdef FEAT_MBYTE | |
596 | void | |
597 | ! gui_ph_encoding_changed(int new_encoding) | |
598 | { | |
599 | /* Default encoding is latin1 */ | |
600 | char *charset = "latin1"; | |
601 | *************** | |
602 | *** 1094,1106 **** | |
603 | { DBCS_CHS, "gb" } | |
604 | }; | |
605 | ||
606 | ! for( i = 0; i < ARRAY_LENGTH( charsets ); i++ ) | |
607 | { | |
608 | ! if( new_encoding == charsets[ i ].encoding ) | |
609 | charset = charsets[ i ].name; | |
610 | } | |
611 | ||
612 | ! charset_translate = PxTranslateSet( charset_translate, charset ); | |
613 | } | |
614 | #endif | |
615 | ||
616 | --- 1094,1106 ---- | |
617 | { DBCS_CHS, "gb" } | |
618 | }; | |
619 | ||
620 | ! for (i = 0; i < ARRAY_LENGTH(charsets); i++) | |
621 | { | |
622 | ! if (new_encoding == charsets[ i ].encoding) | |
623 | charset = charsets[ i ].name; | |
624 | } | |
625 | ||
626 | ! charset_translate = PxTranslateSet(charset_translate, charset); | |
627 | } | |
628 | #endif | |
629 | ||
630 | *************** | |
631 | *** 1112,1118 **** | |
632 | int *argc; | |
633 | char **argv; | |
634 | { | |
635 | ! PtInit( NULL ); | |
636 | } | |
637 | ||
638 | int | |
639 | --- 1112,1118 ---- | |
640 | int *argc; | |
641 | char **argv; | |
642 | { | |
643 | ! PtInit(NULL); | |
644 | } | |
645 | ||
646 | int | |
647 | *************** | |
648 | *** 1124,1213 **** | |
649 | PhDim_t window_size = {100, 100}; /* Arbitrary values */ | |
650 | PhPoint_t pos = {0, 0}; | |
651 | ||
652 | ! gui.event_buffer = (PhEvent_t *) alloc( EVENT_BUFFER_SIZE ); | |
653 | ! if( gui.event_buffer == NULL ) | |
654 | return FAIL; | |
655 | ||
656 | /* Get a translation so we can convert from ISO Latin-1 to UTF */ | |
657 | ! charset_translate = PxTranslateSet( NULL, "latin1" ); | |
658 | ||
659 | /* The +2 is for the 1 pixel dark line on each side */ | |
660 | gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2; | |
661 | ||
662 | /* Handle close events ourselves */ | |
663 | ! PtSetArg( &args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE ); | |
664 | ! PtSetArg( &args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, | |
665 | ! Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS ); | |
666 | ! PtSetArg( &args[ n++ ], Pt_ARG_DIM, &window_size, 0 ); | |
667 | ! gui.vimWindow = PtCreateWidget( PtWindow, NULL, n, args ); | |
668 | ! if( gui.vimWindow == NULL ) | |
669 | return FAIL; | |
670 | ||
671 | ! PtAddCallback( gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL ); | |
672 | ! PtAddCallback( gui.vimWindow, Pt_CB_WINDOW_OPENING, | |
673 | ! gui_ph_handle_window_open, NULL ); | |
674 | ||
675 | n = 0; | |
676 | ! PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, Pt_IS_ANCHORED ); | |
677 | ! PtSetArg( &args[ n++ ], Pt_ARG_DIM, &window_size, 0 ); | |
678 | ! PtSetArg( &args[ n++ ], Pt_ARG_POS, &pos, 0 ); | |
679 | ||
680 | #ifdef USE_PANEL_GROUP | |
681 | /* Put in a temprary place holder title */ | |
682 | ! PtSetArg( &args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1 ); | |
683 | ||
684 | ! gui.vimPanelGroup = PtCreateWidget( PtPanelGroup, gui.vimWindow, n, args ); | |
685 | ! if( gui.vimPanelGroup == NULL ) | |
686 | return FAIL; | |
687 | ||
688 | ! PtAddCallback( gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING, | |
689 | ! gui_ph_handle_pg_change, NULL ); | |
690 | #else | |
691 | /* Turn off all edge decorations */ | |
692 | ! PtSetArg( &args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL ); | |
693 | ! PtSetArg( &args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0 ); | |
694 | ! PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0 ); | |
695 | ! PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0 ); | |
696 | ! PtSetArg( &args[ n++ ], Pt_ARG_CONTAINER_FLAGS, Pt_TRUE, Pt_AUTO_EXTENT ); | |
697 | ||
698 | ! gui.vimContainer = PtCreateWidget( PtPane, gui.vimWindow, n, args ); | |
699 | ! if( gui.vimContainer == NULL ) | |
700 | return FAIL; | |
701 | ||
702 | ! PtAddCallback( gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL ); | |
703 | #endif | |
704 | ||
705 | /* Size for the text area is set in gui_mch_set_text_area_pos */ | |
706 | n = 0; | |
707 | ||
708 | ! PtSetArg( &args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1 ); | |
709 | ! PtSetArg( &args[ n++ ], Pt_ARG_BEVEL_WIDTH, GUI_PH_MARGIN, 0 ); | |
710 | /* | |
711 | * Using focus render also causes the whole widget to be redrawn | |
712 | * whenever it changes focus, which is very annoying :p | |
713 | */ | |
714 | ! PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, | |
715 | ! Pt_GETS_FOCUS | Pt_HIGHLIGHTED ); | |
716 | #ifndef FEAT_MOUSESHAPE | |
717 | ! PtSetArg( &args[ n++ ], Pt_ARG_CURSOR_TYPE, GUI_PH_MOUSE_TYPE, 0 ); | |
718 | ! PtSetArg( &args[ n++ ], Pt_ARG_CURSOR_COLOR, gui_ph_mouse_color, 0 ); | |
719 | #endif | |
720 | ||
721 | ! gui.vimTextArea = PtCreateWidget( PtRaw, Pt_DFLT_PARENT, n, args ); | |
722 | ! if( gui.vimTextArea == NULL) | |
723 | return FAIL; | |
724 | ||
725 | /* TODO: use PtAddEventHandlers instead? */ | |
726 | /* Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway */ | |
727 | ! PtAddEventHandler( gui.vimTextArea, | |
728 | Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON, | |
729 | ! gui_ph_handle_mouse, NULL ); | |
730 | ! PtAddEventHandler( gui.vimTextArea, Ph_EV_KEY, | |
731 | ! gui_ph_handle_keyboard, NULL ); | |
732 | ! PtAddCallback( gui.vimTextArea, Pt_CB_GOT_FOCUS, | |
733 | ! gui_ph_handle_focus, NULL ); | |
734 | ! PtAddCallback( gui.vimTextArea, Pt_CB_LOST_FOCUS, | |
735 | ! gui_ph_handle_focus, NULL ); | |
736 | ||
737 | /* | |
738 | * Now that the text area widget has been created, set up the colours, | |
739 | --- 1124,1213 ---- | |
740 | PhDim_t window_size = {100, 100}; /* Arbitrary values */ | |
741 | PhPoint_t pos = {0, 0}; | |
742 | ||
743 | ! gui.event_buffer = (PhEvent_t *) alloc(EVENT_BUFFER_SIZE); | |
744 | ! if (gui.event_buffer == NULL) | |
745 | return FAIL; | |
746 | ||
747 | /* Get a translation so we can convert from ISO Latin-1 to UTF */ | |
748 | ! charset_translate = PxTranslateSet(NULL, "latin1"); | |
749 | ||
750 | /* The +2 is for the 1 pixel dark line on each side */ | |
751 | gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2; | |
752 | ||
753 | /* Handle close events ourselves */ | |
754 | ! PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE); | |
755 | ! PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, | |
756 | ! Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS); | |
757 | ! PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0); | |
758 | ! gui.vimWindow = PtCreateWidget(PtWindow, NULL, n, args); | |
759 | ! if (gui.vimWindow == NULL) | |
760 | return FAIL; | |
761 | ||
762 | ! PtAddCallback(gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL); | |
763 | ! PtAddCallback(gui.vimWindow, Pt_CB_WINDOW_OPENING, | |
764 | ! gui_ph_handle_window_open, NULL); | |
765 | ||
766 | n = 0; | |
767 | ! PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, Pt_IS_ANCHORED); | |
768 | ! PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0); | |
769 | ! PtSetArg(&args[ n++ ], Pt_ARG_POS, &pos, 0); | |
770 | ||
771 | #ifdef USE_PANEL_GROUP | |
772 | /* Put in a temprary place holder title */ | |
773 | ! PtSetArg(&args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1); | |
774 | ||
775 | ! gui.vimPanelGroup = PtCreateWidget(PtPanelGroup, gui.vimWindow, n, args); | |
776 | ! if (gui.vimPanelGroup == NULL) | |
777 | return FAIL; | |
778 | ||
779 | ! PtAddCallback(gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING, | |
780 | ! gui_ph_handle_pg_change, NULL); | |
781 | #else | |
782 | /* Turn off all edge decorations */ | |
783 | ! PtSetArg(&args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL); | |
784 | ! PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0); | |
785 | ! PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0); | |
786 | ! PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0); | |
787 | ! PtSetArg(&args[ n++ ], Pt_ARG_CONTAINER_FLAGS, Pt_TRUE, Pt_AUTO_EXTENT); | |
788 | ||
789 | ! gui.vimContainer = PtCreateWidget(PtPane, gui.vimWindow, n, args); | |
790 | ! if (gui.vimContainer == NULL) | |
791 | return FAIL; | |
792 | ||
793 | ! PtAddCallback(gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL); | |
794 | #endif | |
795 | ||
796 | /* Size for the text area is set in gui_mch_set_text_area_pos */ | |
797 | n = 0; | |
798 | ||
799 | ! PtSetArg(&args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1); | |
800 | ! PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, GUI_PH_MARGIN, 0); | |
801 | /* | |
802 | * Using focus render also causes the whole widget to be redrawn | |
803 | * whenever it changes focus, which is very annoying :p | |
804 | */ | |
805 | ! PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, | |
806 | ! Pt_GETS_FOCUS | Pt_HIGHLIGHTED); | |
807 | #ifndef FEAT_MOUSESHAPE | |
808 | ! PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_TYPE, GUI_PH_MOUSE_TYPE, 0); | |
809 | ! PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_COLOR, gui_ph_mouse_color, 0); | |
810 | #endif | |
811 | ||
812 | ! gui.vimTextArea = PtCreateWidget(PtRaw, Pt_DFLT_PARENT, n, args); | |
813 | ! if (gui.vimTextArea == NULL) | |
814 | return FAIL; | |
815 | ||
816 | /* TODO: use PtAddEventHandlers instead? */ | |
817 | /* Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway */ | |
818 | ! PtAddEventHandler(gui.vimTextArea, | |
819 | Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON, | |
820 | ! gui_ph_handle_mouse, NULL); | |
821 | ! PtAddEventHandler(gui.vimTextArea, Ph_EV_KEY, | |
822 | ! gui_ph_handle_keyboard, NULL); | |
823 | ! PtAddCallback(gui.vimTextArea, Pt_CB_GOT_FOCUS, | |
824 | ! gui_ph_handle_focus, NULL); | |
825 | ! PtAddCallback(gui.vimTextArea, Pt_CB_LOST_FOCUS, | |
826 | ! gui_ph_handle_focus, NULL); | |
827 | ||
828 | /* | |
829 | * Now that the text area widget has been created, set up the colours, | |
830 | *************** | |
831 | *** 1218,1278 **** | |
832 | * Create the two timers, not as accurate as using the kernel timer | |
833 | * functions, but good enough | |
834 | */ | |
835 | ! gui_ph_timer_cursor = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL ); | |
836 | ! if( gui_ph_timer_cursor == NULL ) | |
837 | return FAIL; | |
838 | ||
839 | ! gui_ph_timer_timeout = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL ); | |
840 | ! if( gui_ph_timer_timeout == NULL ) | |
841 | return FAIL; | |
842 | ||
843 | ! PtAddCallback( gui_ph_timer_cursor, Pt_CB_TIMER_ACTIVATE, | |
844 | gui_ph_handle_timer_cursor, NULL); | |
845 | ! PtAddCallback( gui_ph_timer_timeout, Pt_CB_TIMER_ACTIVATE, | |
846 | gui_ph_handle_timer_timeout, NULL); | |
847 | ||
848 | #ifdef FEAT_MENU | |
849 | n = 0; | |
850 | ! PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 ); | |
851 | ! PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT, | |
852 | ! Pt_IS_ANCHORED ); | |
853 | ! gui.vimToolBarGroup = PtCreateWidget( PtToolbarGroup, gui.vimWindow, | |
854 | ! n, args ); | |
855 | ! if( gui.vimToolBarGroup == NULL ) | |
856 | return FAIL; | |
857 | ||
858 | ! PtAddCallback( gui.vimToolBarGroup, Pt_CB_RESIZE, | |
859 | ! gui_ph_handle_menu_resize, NULL ); | |
860 | ||
861 | n = 0; | |
862 | flags = 0; | |
863 | ! PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 ); | |
864 | ! if( ! vim_strchr( p_go, GO_MENUS ) ) | |
865 | { | |
866 | flags |= Pt_DELAY_REALIZE; | |
867 | ! PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags ); | |
868 | } | |
869 | ! gui.vimMenuBar = PtCreateWidget( PtMenuBar, gui.vimToolBarGroup, n, args ); | |
870 | ! if( gui.vimMenuBar == NULL ) | |
871 | return FAIL; | |
872 | ||
873 | # ifdef FEAT_TOOLBAR | |
874 | n = 0; | |
875 | ||
876 | ! PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, | |
877 | ! Pt_ANCHOR_LEFT_RIGHT |Pt_TOP_ANCHORED_TOP, Pt_IS_ANCHORED ); | |
878 | ! PtSetArg( &args[ n++ ], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, | |
879 | ! Pt_RESIZE_Y_AS_REQUIRED ); | |
880 | ! PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 ); | |
881 | ||
882 | flags = Pt_GETS_FOCUS; | |
883 | ! if( ! vim_strchr( p_go, GO_TOOLBAR ) ) | |
884 | flags |= Pt_DELAY_REALIZE; | |
885 | ||
886 | ! PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags ); | |
887 | ||
888 | ! gui.vimToolBar = PtCreateWidget( PtToolbar, gui.vimToolBarGroup, n, args ); | |
889 | ! if( gui.vimToolBar == NULL ) | |
890 | return FAIL; | |
891 | ||
892 | /* | |
893 | --- 1218,1278 ---- | |
894 | * Create the two timers, not as accurate as using the kernel timer | |
895 | * functions, but good enough | |
896 | */ | |
897 | ! gui_ph_timer_cursor = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL); | |
898 | ! if (gui_ph_timer_cursor == NULL) | |
899 | return FAIL; | |
900 | ||
901 | ! gui_ph_timer_timeout = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL); | |
902 | ! if (gui_ph_timer_timeout == NULL) | |
903 | return FAIL; | |
904 | ||
905 | ! PtAddCallback(gui_ph_timer_cursor, Pt_CB_TIMER_ACTIVATE, | |
906 | gui_ph_handle_timer_cursor, NULL); | |
907 | ! PtAddCallback(gui_ph_timer_timeout, Pt_CB_TIMER_ACTIVATE, | |
908 | gui_ph_handle_timer_timeout, NULL); | |
909 | ||
910 | #ifdef FEAT_MENU | |
911 | n = 0; | |
912 | ! PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); | |
913 | ! PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT, | |
914 | ! Pt_IS_ANCHORED); | |
915 | ! gui.vimToolBarGroup = PtCreateWidget(PtToolbarGroup, gui.vimWindow, | |
916 | ! n, args); | |
917 | ! if (gui.vimToolBarGroup == NULL) | |
918 | return FAIL; | |
919 | ||
920 | ! PtAddCallback(gui.vimToolBarGroup, Pt_CB_RESIZE, | |
921 | ! gui_ph_handle_menu_resize, NULL); | |
922 | ||
923 | n = 0; | |
924 | flags = 0; | |
925 | ! PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); | |
926 | ! if (! vim_strchr(p_go, GO_MENUS)) | |
927 | { | |
928 | flags |= Pt_DELAY_REALIZE; | |
929 | ! PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags); | |
930 | } | |
931 | ! gui.vimMenuBar = PtCreateWidget(PtMenuBar, gui.vimToolBarGroup, n, args); | |
932 | ! if (gui.vimMenuBar == NULL) | |
933 | return FAIL; | |
934 | ||
935 | # ifdef FEAT_TOOLBAR | |
936 | n = 0; | |
937 | ||
938 | ! PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, | |
939 | ! Pt_ANCHOR_LEFT_RIGHT |Pt_TOP_ANCHORED_TOP, Pt_IS_ANCHORED); | |
940 | ! PtSetArg(&args[ n++ ], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, | |
941 | ! Pt_RESIZE_Y_AS_REQUIRED); | |
942 | ! PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); | |
943 | ||
944 | flags = Pt_GETS_FOCUS; | |
945 | ! if (! vim_strchr(p_go, GO_TOOLBAR)) | |
946 | flags |= Pt_DELAY_REALIZE; | |
947 | ||
948 | ! PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags); | |
949 | ||
950 | ! gui.vimToolBar = PtCreateWidget(PtToolbar, gui.vimToolBarGroup, n, args); | |
951 | ! if (gui.vimToolBar == NULL) | |
952 | return FAIL; | |
953 | ||
954 | /* | |
955 | *************** | |
956 | *** 1310,1329 **** | |
957 | if (gui_win_x != -1 && gui_win_y != -1) | |
958 | gui_mch_set_winpos(gui_win_x, gui_win_y); | |
959 | ||
960 | ! return (PtRealizeWidget( gui.vimWindow ) == 0) ? OK : FAIL; | |
961 | } | |
962 | ||
963 | void | |
964 | gui_mch_exit(int rc) | |
965 | { | |
966 | ! PtDestroyWidget( gui.vimWindow ); | |
967 | ||
968 | ! PxTranslateSet( charset_translate, NULL ); | |
969 | ||
970 | ! vim_free( gui.event_buffer ); | |
971 | ||
972 | #ifdef USE_PANEL_GROUPS | |
973 | ! vim_free( panel_titles ); | |
974 | #endif | |
975 | } | |
976 | ||
977 | --- 1310,1329 ---- | |
978 | if (gui_win_x != -1 && gui_win_y != -1) | |
979 | gui_mch_set_winpos(gui_win_x, gui_win_y); | |
980 | ||
981 | ! return (PtRealizeWidget(gui.vimWindow) == 0) ? OK : FAIL; | |
982 | } | |
983 | ||
984 | void | |
985 | gui_mch_exit(int rc) | |
986 | { | |
987 | ! PtDestroyWidget(gui.vimWindow); | |
988 | ||
989 | ! PxTranslateSet(charset_translate, NULL); | |
990 | ||
991 | ! vim_free(gui.event_buffer); | |
992 | ||
993 | #ifdef USE_PANEL_GROUPS | |
994 | ! vim_free(panel_titles); | |
995 | #endif | |
996 | } | |
997 | ||
998 | *************** | |
999 | *** 1333,1339 **** | |
1000 | /* When no events are available, photon will call this function, working is | |
1001 | * set to FALSE, and the gui_mch_update loop will exit. */ | |
1002 | static int | |
1003 | ! exit_gui_mch_update( void *data ) | |
1004 | { | |
1005 | *(int *)data = FALSE; | |
1006 | return Pt_END; | |
1007 | --- 1333,1339 ---- | |
1008 | /* When no events are available, photon will call this function, working is | |
1009 | * set to FALSE, and the gui_mch_update loop will exit. */ | |
1010 | static int | |
1011 | ! exit_gui_mch_update(void *data) | |
1012 | { | |
1013 | *(int *)data = FALSE; | |
1014 | return Pt_END; | |
1015 | *************** | |
1016 | *** 1344,1351 **** | |
1017 | { | |
1018 | int working = TRUE; | |
1019 | ||
1020 | ! PtAppAddWorkProc( NULL, exit_gui_mch_update, &working ); | |
1021 | ! while( ( working == TRUE ) && !vim_is_input_buf_full()) | |
1022 | { | |
1023 | PtProcessEvent(); | |
1024 | } | |
1025 | --- 1344,1351 ---- | |
1026 | { | |
1027 | int working = TRUE; | |
1028 | ||
1029 | ! PtAppAddWorkProc(NULL, exit_gui_mch_update, &working); | |
1030 | ! while ((working == TRUE) && !vim_is_input_buf_full()) | |
1031 | { | |
1032 | PtProcessEvent(); | |
1033 | } | |
1034 | *************** | |
1035 | *** 1356,1378 **** | |
1036 | { | |
1037 | is_timeout = FALSE; | |
1038 | ||
1039 | ! if( wtime > 0 ) | |
1040 | ! PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, wtime, 0 ); | |
1041 | ||
1042 | ! while( 1 ) | |
1043 | { | |
1044 | PtProcessEvent(); | |
1045 | ! if( input_available() ) | |
1046 | { | |
1047 | ! PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0 ); | |
1048 | return OK; | |
1049 | } | |
1050 | ! else if( is_timeout == TRUE ) | |
1051 | return FAIL; | |
1052 | } | |
1053 | } | |
1054 | ||
1055 | ! #if defined( FEAT_BROWSE ) || defined( PROTO ) | |
1056 | /* | |
1057 | * Put up a file requester. | |
1058 | * Returns the selected name in allocated memory, or NULL for Cancel. | |
1059 | --- 1356,1378 ---- | |
1060 | { | |
1061 | is_timeout = FALSE; | |
1062 | ||
1063 | ! if (wtime > 0) | |
1064 | ! PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, wtime, 0); | |
1065 | ||
1066 | ! while (1) | |
1067 | { | |
1068 | PtProcessEvent(); | |
1069 | ! if (input_available()) | |
1070 | { | |
1071 | ! PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0); | |
1072 | return OK; | |
1073 | } | |
1074 | ! else if (is_timeout == TRUE) | |
1075 | return FAIL; | |
1076 | } | |
1077 | } | |
1078 | ||
1079 | ! #if defined(FEAT_BROWSE) || defined(PROTO) | |
1080 | /* | |
1081 | * Put up a file requester. | |
1082 | * Returns the selected name in allocated memory, or NULL for Cancel. | |
1083 | *************** | |
1084 | *** 1398,1409 **** | |
1085 | char_u *open_text = NULL; | |
1086 | ||
1087 | flags = 0; | |
1088 | ! memset( &file, 0, sizeof( file ) ); | |
1089 | ||
1090 | ! default_path = alloc( MAXPATHL + 1 + NAME_MAX + 1 ); | |
1091 | ! if( default_path != NULL ) | |
1092 | { | |
1093 | ! if( saving == TRUE ) | |
1094 | { | |
1095 | /* Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway */ | |
1096 | flags |= Pt_FSR_NO_FCHECK; | |
1097 | --- 1398,1409 ---- | |
1098 | char_u *open_text = NULL; | |
1099 | ||
1100 | flags = 0; | |
1101 | ! memset(&file, 0, sizeof(file)); | |
1102 | ||
1103 | ! default_path = alloc(MAXPATHL + 1 + NAME_MAX + 1); | |
1104 | ! if (default_path != NULL) | |
1105 | { | |
1106 | ! if (saving == TRUE) | |
1107 | { | |
1108 | /* Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway */ | |
1109 | flags |= Pt_FSR_NO_FCHECK; | |
1110 | *************** | |
1111 | *** 1411,1433 **** | |
1112 | } | |
1113 | ||
1114 | /* combine the directory and filename into a single path */ | |
1115 | ! if( initdir == NULL || *initdir == NUL ) | |
1116 | { | |
1117 | ! mch_dirname( default_path, MAXPATHL ); | |
1118 | initdir = default_path; | |
1119 | } | |
1120 | else | |
1121 | { | |
1122 | ! STRCPY( default_path, initdir ); | |
1123 | initdir = default_path; | |
1124 | } | |
1125 | ||
1126 | ! if( default_name != NULL ) | |
1127 | { | |
1128 | ! if( default_path[ STRLEN( default_path ) - 1 ] != '/' ) | |
1129 | ! STRCAT( default_path, "/" ); | |
1130 | ||
1131 | ! STRCAT( default_path, default_name ); | |
1132 | } | |
1133 | ||
1134 | /* TODO: add a filter? */ | |
1135 | --- 1411,1433 ---- | |
1136 | } | |
1137 | ||
1138 | /* combine the directory and filename into a single path */ | |
1139 | ! if (initdir == NULL || *initdir == NUL) | |
1140 | { | |
1141 | ! mch_dirname(default_path, MAXPATHL); | |
1142 | initdir = default_path; | |
1143 | } | |
1144 | else | |
1145 | { | |
1146 | ! STRCPY(default_path, initdir); | |
1147 | initdir = default_path; | |
1148 | } | |
1149 | ||
1150 | ! if (default_name != NULL) | |
1151 | { | |
1152 | ! if (default_path[ STRLEN(default_path) - 1 ] != '/') | |
1153 | ! STRCAT(default_path, "/"); | |
1154 | ||
1155 | ! STRCAT(default_path, default_name); | |
1156 | } | |
1157 | ||
1158 | /* TODO: add a filter? */ | |
1159 | *************** | |
1160 | *** 1441,1495 **** | |
1161 | NULL, | |
1162 | NULL, | |
1163 | &file, | |
1164 | ! flags ); | |
1165 | ||
1166 | ! vim_free( default_path ); | |
1167 | ||
1168 | ! if( file.ret == Pt_FSDIALOG_BTN1 ) | |
1169 | return vim_strsave(file.path); | |
1170 | } | |
1171 | return NULL; | |
1172 | } | |
1173 | #endif | |
1174 | ||
1175 | ! #if defined( FEAT_GUI_DIALOG ) || defined( PROTO ) | |
1176 | static PtWidget_t *gui_ph_dialog_text = NULL; | |
1177 | ||
1178 | static int | |
1179 | ! gui_ph_dialog_close( int button, void *data ) | |
1180 | { | |
1181 | PtModalCtrl_t *modal_ctrl = data; | |
1182 | char_u *dialog_text, *vim_text; | |
1183 | ||
1184 | ! if( gui_ph_dialog_text != NULL ) | |
1185 | { | |
1186 | ! PtGetResource( gui_ph_dialog_text, Pt_ARG_TEXT_STRING, &dialog_text, 0 ); | |
1187 | ! PtGetResource( gui_ph_dialog_text, Pt_ARG_POINTER, &vim_text, 0 ); | |
1188 | ! STRNCPY( vim_text, dialog_text, IOSIZE - 1 ); | |
1189 | } | |
1190 | ||
1191 | ! PtModalUnblock( modal_ctrl, (void *) button ); | |
1192 | ||
1193 | return Pt_TRUE; | |
1194 | } | |
1195 | ||
1196 | static int | |
1197 | ! gui_ph_dialog_text_enter( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) | |
1198 | { | |
1199 | ! if( info->reason_subtype == Pt_EDIT_ACTIVATE ) | |
1200 | ! gui_ph_dialog_close( 1, data ); | |
1201 | return Pt_CONTINUE; | |
1202 | } | |
1203 | ||
1204 | static int | |
1205 | ! gui_ph_dialog_esc( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) | |
1206 | { | |
1207 | PhKeyEvent_t *key; | |
1208 | ||
1209 | ! key = PhGetData( info->event ); | |
1210 | ! if( ( key->key_flags & Pk_KF_Cap_Valid ) && ( key->key_cap == Pk_Escape ) ) | |
1211 | { | |
1212 | ! gui_ph_dialog_close( 0, data ); | |
1213 | return Pt_CONSUME; | |
1214 | } | |
1215 | return Pt_PROCESS; | |
1216 | --- 1441,1495 ---- | |
1217 | NULL, | |
1218 | NULL, | |
1219 | &file, | |
1220 | ! flags); | |
1221 | ||
1222 | ! vim_free(default_path); | |
1223 | ||
1224 | ! if (file.ret == Pt_FSDIALOG_BTN1) | |
1225 | return vim_strsave(file.path); | |
1226 | } | |
1227 | return NULL; | |
1228 | } | |
1229 | #endif | |
1230 | ||
1231 | ! #if defined(FEAT_GUI_DIALOG) || defined(PROTO) | |
1232 | static PtWidget_t *gui_ph_dialog_text = NULL; | |
1233 | ||
1234 | static int | |
1235 | ! gui_ph_dialog_close(int button, void *data) | |
1236 | { | |
1237 | PtModalCtrl_t *modal_ctrl = data; | |
1238 | char_u *dialog_text, *vim_text; | |
1239 | ||
1240 | ! if (gui_ph_dialog_text != NULL) | |
1241 | { | |
1242 | ! PtGetResource(gui_ph_dialog_text, Pt_ARG_TEXT_STRING, &dialog_text, 0); | |
1243 | ! PtGetResource(gui_ph_dialog_text, Pt_ARG_POINTER, &vim_text, 0); | |
1244 | ! STRNCPY(vim_text, dialog_text, IOSIZE - 1); | |
1245 | } | |
1246 | ||
1247 | ! PtModalUnblock(modal_ctrl, (void *) button); | |
1248 | ||
1249 | return Pt_TRUE; | |
1250 | } | |
1251 | ||
1252 | static int | |
1253 | ! gui_ph_dialog_text_enter(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) | |
1254 | { | |
1255 | ! if (info->reason_subtype == Pt_EDIT_ACTIVATE) | |
1256 | ! gui_ph_dialog_close(1, data); | |
1257 | return Pt_CONTINUE; | |
1258 | } | |
1259 | ||
1260 | static int | |
1261 | ! gui_ph_dialog_esc(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) | |
1262 | { | |
1263 | PhKeyEvent_t *key; | |
1264 | ||
1265 | ! key = PhGetData(info->event); | |
1266 | ! if ((key->key_flags & Pk_KF_Cap_Valid) && (key->key_cap == Pk_Escape)) | |
1267 | { | |
1268 | ! gui_ph_dialog_close(0, data); | |
1269 | return Pt_CONSUME; | |
1270 | } | |
1271 | return Pt_PROCESS; | |
1272 | *************** | |
1273 | *** 1518,1557 **** | |
1274 | ||
1275 | button_count = len = i = 0; | |
1276 | ||
1277 | ! if( buttons == NULL || *buttons == NUL ) | |
1278 | return -1; | |
1279 | ||
1280 | /* There is one less separator than buttons, so bump up the button count */ | |
1281 | button_count = 1; | |
1282 | ||
1283 | /* Count string length and number of seperators */ | |
1284 | ! for( str = buttons; *str; str++ ) | |
1285 | { | |
1286 | len++; | |
1287 | ! if( *str == DLG_BUTTON_SEP ) | |
1288 | button_count++; | |
1289 | } | |
1290 | ||
1291 | ! if ( title == NULL ) | |
1292 | title = "Vim"; | |
1293 | ||
1294 | ! buttons_copy = alloc( len + 1 ); | |
1295 | ! button_array = (char_u **) alloc( button_count * sizeof( char_u * ) ); | |
1296 | ! if( buttons_copy != NULL && button_array != NULL ) | |
1297 | { | |
1298 | ! STRCPY( buttons_copy, buttons ); | |
1299 | ||
1300 | /* | |
1301 | * Convert DLG_BUTTON_SEP into NUL's and fill in | |
1302 | * button_array with the pointer to each NUL terminated string | |
1303 | */ | |
1304 | str = buttons_copy; | |
1305 | ! for( i = 0; i < button_count; i++ ) | |
1306 | { | |
1307 | button_array[ i ] = str; | |
1308 | ! for( ; *str; str++ ) | |
1309 | { | |
1310 | ! if( *str == DLG_BUTTON_SEP ) | |
1311 | { | |
1312 | *str++ = NUL; | |
1313 | break; | |
1314 | --- 1518,1557 ---- | |
1315 | ||
1316 | button_count = len = i = 0; | |
1317 | ||
1318 | ! if (buttons == NULL || *buttons == NUL) | |
1319 | return -1; | |
1320 | ||
1321 | /* There is one less separator than buttons, so bump up the button count */ | |
1322 | button_count = 1; | |
1323 | ||
1324 | /* Count string length and number of seperators */ | |
1325 | ! for (str = buttons; *str; str++) | |
1326 | { | |
1327 | len++; | |
1328 | ! if (*str == DLG_BUTTON_SEP) | |
1329 | button_count++; | |
1330 | } | |
1331 | ||
1332 | ! if (title == NULL) | |
1333 | title = "Vim"; | |
1334 | ||
1335 | ! buttons_copy = alloc(len + 1); | |
1336 | ! button_array = (char_u **) alloc(button_count * sizeof(char_u *)); | |
1337 | ! if (buttons_copy != NULL && button_array != NULL) | |
1338 | { | |
1339 | ! STRCPY(buttons_copy, buttons); | |
1340 | ||
1341 | /* | |
1342 | * Convert DLG_BUTTON_SEP into NUL's and fill in | |
1343 | * button_array with the pointer to each NUL terminated string | |
1344 | */ | |
1345 | str = buttons_copy; | |
1346 | ! for (i = 0; i < button_count; i++) | |
1347 | { | |
1348 | button_array[ i ] = str; | |
1349 | ! for (; *str; str++) | |
1350 | { | |
1351 | ! if (*str == DLG_BUTTON_SEP) | |
1352 | { | |
1353 | *str++ = NUL; | |
1354 | break; | |
1355 | *************** | |
1356 | *** 1565,1571 **** | |
1357 | NULL, | |
1358 | message, NULL, | |
1359 | button_count, (const char **) button_array, NULL, | |
1360 | ! default_button, 0, Pt_MODAL ); | |
1361 | #else | |
1362 | /* Writing the dialog ourselves lets us add extra features, like | |
1363 | * trapping the escape key and returning 0 to vim */ | |
1364 | --- 1565,1571 ---- | |
1365 | NULL, | |
1366 | message, NULL, | |
1367 | button_count, (const char **) button_array, NULL, | |
1368 | ! default_button, 0, Pt_MODAL); | |
1369 | #else | |
1370 | /* Writing the dialog ourselves lets us add extra features, like | |
1371 | * trapping the escape key and returning 0 to vim */ | |
1372 | *************** | |
1373 | *** 1576,1607 **** | |
1374 | PtModalCtrl_t modal_ctrl; | |
1375 | PtDialogInfo_t di; | |
1376 | ||
1377 | ! memset( &di, 0, sizeof( di ) ); | |
1378 | ! memset( &modal_ctrl, 0, sizeof( modal_ctrl ) ); | |
1379 | ||
1380 | n = 0; | |
1381 | ! PtSetArg( &args[n++], Pt_ARG_GROUP_ROWS_COLS, 0, 0 ); | |
1382 | ! PtSetArg( &args[n++], Pt_ARG_WIDTH, 350, 0 ); | |
1383 | ! PtSetArg( &args[n++], Pt_ARG_GROUP_ORIENTATION, | |
1384 | ! Pt_GROUP_VERTICAL, 0 ); | |
1385 | ! PtSetArg( &args[n++], Pt_ARG_GROUP_FLAGS, | |
1386 | ! Pt_TRUE, Pt_GROUP_NO_KEYS | Pt_GROUP_STRETCH_HORIZONTAL ); | |
1387 | ! PtSetArg( &args[n++], Pt_ARG_CONTAINER_FLAGS, Pt_FALSE, Pt_TRUE ); | |
1388 | ! pane = PtCreateWidget( PtGroup, NULL, n, args ); | |
1389 | ||
1390 | n = 0; | |
1391 | ! PtSetArg( &args[n++], Pt_ARG_TEXT_STRING, message, 0 ); | |
1392 | ! PtCreateWidget( PtLabel, pane, n, args ); | |
1393 | ||
1394 | ! if( textfield != NULL ) | |
1395 | { | |
1396 | n = 0; | |
1397 | ! PtSetArg( &args[n++], Pt_ARG_MAX_LENGTH, IOSIZE - 1, 0 ); | |
1398 | ! PtSetArg( &args[n++], Pt_ARG_TEXT_STRING, textfield, 0 ); | |
1399 | ! PtSetArg( &args[n++], Pt_ARG_POINTER, textfield, 0 ); | |
1400 | ! gui_ph_dialog_text = PtCreateWidget( PtText, pane, n, args ); | |
1401 | ! PtAddCallback( gui_ph_dialog_text, Pt_CB_ACTIVATE, | |
1402 | ! gui_ph_dialog_text_enter, &modal_ctrl ); | |
1403 | } | |
1404 | ||
1405 | di.parent = gui.vimWindow; | |
1406 | --- 1576,1607 ---- | |
1407 | PtModalCtrl_t modal_ctrl; | |
1408 | PtDialogInfo_t di; | |
1409 | ||
1410 | ! memset(&di, 0, sizeof(di)); | |
1411 | ! memset(&modal_ctrl, 0, sizeof(modal_ctrl)); | |
1412 | ||
1413 | n = 0; | |
1414 | ! PtSetArg(&args[n++], Pt_ARG_GROUP_ROWS_COLS, 0, 0); | |
1415 | ! PtSetArg(&args[n++], Pt_ARG_WIDTH, 350, 0); | |
1416 | ! PtSetArg(&args[n++], Pt_ARG_GROUP_ORIENTATION, | |
1417 | ! Pt_GROUP_VERTICAL, 0); | |
1418 | ! PtSetArg(&args[n++], Pt_ARG_GROUP_FLAGS, | |
1419 | ! Pt_TRUE, Pt_GROUP_NO_KEYS | Pt_GROUP_STRETCH_HORIZONTAL); | |
1420 | ! PtSetArg(&args[n++], Pt_ARG_CONTAINER_FLAGS, Pt_FALSE, Pt_TRUE); | |
1421 | ! pane = PtCreateWidget(PtGroup, NULL, n, args); | |
1422 | ||
1423 | n = 0; | |
1424 | ! PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, message, 0); | |
1425 | ! PtCreateWidget(PtLabel, pane, n, args); | |
1426 | ||
1427 | ! if (textfield != NULL) | |
1428 | { | |
1429 | n = 0; | |
1430 | ! PtSetArg(&args[n++], Pt_ARG_MAX_LENGTH, IOSIZE - 1, 0); | |
1431 | ! PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, textfield, 0); | |
1432 | ! PtSetArg(&args[n++], Pt_ARG_POINTER, textfield, 0); | |
1433 | ! gui_ph_dialog_text = PtCreateWidget(PtText, pane, n, args); | |
1434 | ! PtAddCallback(gui_ph_dialog_text, Pt_CB_ACTIVATE, | |
1435 | ! gui_ph_dialog_text_enter, &modal_ctrl); | |
1436 | } | |
1437 | ||
1438 | di.parent = gui.vimWindow; | |
1439 | *************** | |
1440 | *** 1616,1641 **** | |
1441 | di.callback = gui_ph_dialog_close; | |
1442 | di.data = &modal_ctrl; | |
1443 | ||
1444 | ! dialog = PtCreateDialog( &di ); | |
1445 | ! PtAddFilterCallback( dialog, Ph_EV_KEY, | |
1446 | ! gui_ph_dialog_esc, &modal_ctrl ); | |
1447 | ||
1448 | ! if( gui_ph_dialog_text != NULL ) | |
1449 | ! PtGiveFocus( gui_ph_dialog_text, NULL ); | |
1450 | ||
1451 | /* Open dialog, block the vim window and wait for the dialog to close */ | |
1452 | ! PtRealizeWidget( dialog ); | |
1453 | ! PtMakeModal( dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR ); | |
1454 | ! dialog_result = (int) PtModalBlock( &modal_ctrl, 0 ); | |
1455 | ||
1456 | ! PtDestroyWidget( dialog ); | |
1457 | gui_ph_dialog_text = NULL; | |
1458 | } | |
1459 | #endif | |
1460 | } | |
1461 | ||
1462 | ! vim_free( button_array ); | |
1463 | ! vim_free( buttons_copy ); | |
1464 | ||
1465 | return dialog_result; | |
1466 | } | |
1467 | --- 1616,1641 ---- | |
1468 | di.callback = gui_ph_dialog_close; | |
1469 | di.data = &modal_ctrl; | |
1470 | ||
1471 | ! dialog = PtCreateDialog(&di); | |
1472 | ! PtAddFilterCallback(dialog, Ph_EV_KEY, | |
1473 | ! gui_ph_dialog_esc, &modal_ctrl); | |
1474 | ||
1475 | ! if (gui_ph_dialog_text != NULL) | |
1476 | ! PtGiveFocus(gui_ph_dialog_text, NULL); | |
1477 | ||
1478 | /* Open dialog, block the vim window and wait for the dialog to close */ | |
1479 | ! PtRealizeWidget(dialog); | |
1480 | ! PtMakeModal(dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR); | |
1481 | ! dialog_result = (int) PtModalBlock(&modal_ctrl, 0); | |
1482 | ||
1483 | ! PtDestroyWidget(dialog); | |
1484 | gui_ph_dialog_text = NULL; | |
1485 | } | |
1486 | #endif | |
1487 | } | |
1488 | ||
1489 | ! vim_free(button_array); | |
1490 | ! vim_free(buttons_copy); | |
1491 | ||
1492 | return dialog_result; | |
1493 | } | |
1494 | *************** | |
1495 | *** 1648,1654 **** | |
1496 | { | |
1497 | PhPoint_t *pos; | |
1498 | ||
1499 | ! pos = PtWidgetPos( gui.vimWindow, NULL ); | |
1500 | ||
1501 | *x = pos->x; | |
1502 | *y = pos->y; | |
1503 | --- 1648,1654 ---- | |
1504 | { | |
1505 | PhPoint_t *pos; | |
1506 | ||
1507 | ! pos = PtWidgetPos(gui.vimWindow, NULL); | |
1508 | ||
1509 | *x = pos->x; | |
1510 | *y = pos->y; | |
1511 | *************** | |
1512 | *** 1661,1667 **** | |
1513 | { | |
1514 | PhPoint_t pos = { x, y }; | |
1515 | ||
1516 | ! PtSetResource( gui.vimWindow, Pt_ARG_POS, &pos, 0 ); | |
1517 | } | |
1518 | ||
1519 | void | |
1520 | --- 1661,1667 ---- | |
1521 | { | |
1522 | PhPoint_t pos = { x, y }; | |
1523 | ||
1524 | ! PtSetResource(gui.vimWindow, Pt_ARG_POS, &pos, 0); | |
1525 | } | |
1526 | ||
1527 | void | |
1528 | *************** | |
1529 | *** 1677,1686 **** | |
1530 | window_size.h += pg_margin_top + pg_margin_bottom; | |
1531 | #endif | |
1532 | ||
1533 | ! PtSetResource( gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0 ); | |
1534 | ! PtSetResource( gui.vimWindow, Pt_ARG_DIM, &window_size, 0 ); | |
1535 | ||
1536 | ! if( ! PtWidgetIsRealized( gui.vimWindow ) ) | |
1537 | gui_ph_resize_container(); | |
1538 | } | |
1539 | ||
1540 | --- 1677,1686 ---- | |
1541 | window_size.h += pg_margin_top + pg_margin_bottom; | |
1542 | #endif | |
1543 | ||
1544 | ! PtSetResource(gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0); | |
1545 | ! PtSetResource(gui.vimWindow, Pt_ARG_DIM, &window_size, 0); | |
1546 | ||
1547 | ! if (! PtWidgetIsRealized(gui.vimWindow)) | |
1548 | gui_ph_resize_container(); | |
1549 | } | |
1550 | ||
1551 | *************** | |
1552 | *** 1693,1700 **** | |
1553 | { | |
1554 | PhRect_t console; | |
1555 | ||
1556 | ! PhWindowQueryVisible( Ph_QUERY_WORKSPACE, 0, | |
1557 | ! PhInputGroup( NULL ), &console ); | |
1558 | ||
1559 | *screen_w = console.lr.x - console.ul.x + 1; | |
1560 | *screen_h = console.lr.y - console.ul.y + 1; | |
1561 | --- 1693,1700 ---- | |
1562 | { | |
1563 | PhRect_t console; | |
1564 | ||
1565 | ! PhWindowQueryVisible(Ph_QUERY_WORKSPACE, 0, | |
1566 | ! PhInputGroup(NULL), &console); | |
1567 | ||
1568 | *screen_w = console.lr.x - console.ul.x + 1; | |
1569 | *screen_h = console.lr.y - console.ul.y + 1; | |
1570 | *************** | |
1571 | *** 1705,1715 **** | |
1572 | { | |
1573 | PhWindowEvent_t event; | |
1574 | ||
1575 | ! memset( &event, 0, sizeof (event) ); | |
1576 | event.event_f = Ph_WM_HIDE; | |
1577 | event.event_state = Ph_WM_EVSTATE_HIDE; | |
1578 | ! event.rid = PtWidgetRid( gui.vimWindow ); | |
1579 | ! PtForwardWindowEvent( &event ); | |
1580 | } | |
1581 | ||
1582 | #if defined(FEAT_EVAL) || defined(PROTO) | |
1583 | --- 1705,1715 ---- | |
1584 | { | |
1585 | PhWindowEvent_t event; | |
1586 | ||
1587 | ! memset(&event, 0, sizeof (event)); | |
1588 | event.event_f = Ph_WM_HIDE; | |
1589 | event.event_state = Ph_WM_EVSTATE_HIDE; | |
1590 | ! event.rid = PtWidgetRid(gui.vimWindow); | |
1591 | ! PtForwardWindowEvent(&event); | |
1592 | } | |
1593 | ||
1594 | #if defined(FEAT_EVAL) || defined(PROTO) | |
1595 | *************** | |
1596 | *** 1721,1731 **** | |
1597 | { | |
1598 | PhWindowEvent_t event; | |
1599 | ||
1600 | ! memset( &event, 0, sizeof (event) ); | |
1601 | event.event_f = Ph_WM_TOFRONT; | |
1602 | event.event_state = Ph_WM_EVSTATE_FFRONT; | |
1603 | ! event.rid = PtWidgetRid( gui.vimWindow ); | |
1604 | ! PtForwardWindowEvent( &event ); | |
1605 | } | |
1606 | #endif | |
1607 | ||
1608 | --- 1721,1731 ---- | |
1609 | { | |
1610 | PhWindowEvent_t event; | |
1611 | ||
1612 | ! memset(&event, 0, sizeof (event)); | |
1613 | event.event_f = Ph_WM_TOFRONT; | |
1614 | event.event_state = Ph_WM_EVSTATE_FFRONT; | |
1615 | ! event.rid = PtWidgetRid(gui.vimWindow); | |
1616 | ! PtForwardWindowEvent(&event); | |
1617 | } | |
1618 | #endif | |
1619 | ||
1620 | *************** | |
1621 | *** 1733,1741 **** | |
1622 | gui_mch_settitle(char_u *title, char_u *icon) | |
1623 | { | |
1624 | #ifdef USE_PANEL_GROUP | |
1625 | ! gui_ph_pg_set_buffer_num( curwin->w_buffer->b_fnum ); | |
1626 | #endif | |
1627 | ! PtSetResource( gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0 ); | |
1628 | /* Not sure what to do with the icon text, set balloon text somehow? */ | |
1629 | } | |
1630 | ||
1631 | --- 1733,1741 ---- | |
1632 | gui_mch_settitle(char_u *title, char_u *icon) | |
1633 | { | |
1634 | #ifdef USE_PANEL_GROUP | |
1635 | ! gui_ph_pg_set_buffer_num(curwin->w_buffer->b_fnum); | |
1636 | #endif | |
1637 | ! PtSetResource(gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0); | |
1638 | /* Not sure what to do with the icon text, set balloon text somehow? */ | |
1639 | } | |
1640 | ||
1641 | *************** | |
1642 | *** 1748,1757 **** | |
1643 | int n = 0; | |
1644 | PtArg_t args[3]; | |
1645 | ||
1646 | ! PtSetArg( &args[ n++ ], Pt_ARG_MAXIMUM, max, 0 ); | |
1647 | ! PtSetArg( &args[ n++ ], Pt_ARG_SLIDER_SIZE, size, 0 ); | |
1648 | ! PtSetArg( &args[ n++ ], Pt_ARG_GAUGE_VALUE, val, 0 ); | |
1649 | ! PtSetResources( sb->id, n, args ); | |
1650 | } | |
1651 | ||
1652 | void | |
1653 | --- 1748,1757 ---- | |
1654 | int n = 0; | |
1655 | PtArg_t args[3]; | |
1656 | ||
1657 | ! PtSetArg(&args[ n++ ], Pt_ARG_MAXIMUM, max, 0); | |
1658 | ! PtSetArg(&args[ n++ ], Pt_ARG_SLIDER_SIZE, size, 0); | |
1659 | ! PtSetArg(&args[ n++ ], Pt_ARG_GAUGE_VALUE, val, 0); | |
1660 | ! PtSetResources(sb->id, n, args); | |
1661 | } | |
1662 | ||
1663 | void | |
1664 | *************** | |
1665 | *** 1759,1765 **** | |
1666 | { | |
1667 | PhArea_t area = {{ x, y }, { w, h }}; | |
1668 | ||
1669 | ! PtSetResource( sb->id, Pt_ARG_AREA, &area, 0 ); | |
1670 | } | |
1671 | ||
1672 | void | |
1673 | --- 1759,1765 ---- | |
1674 | { | |
1675 | PhArea_t area = {{ x, y }, { w, h }}; | |
1676 | ||
1677 | ! PtSetResource(sb->id, Pt_ARG_AREA, &area, 0); | |
1678 | } | |
1679 | ||
1680 | void | |
1681 | *************** | |
1682 | *** 1775,1786 **** | |
1683 | * | |
1684 | * Also, don't let the scrollbar get focus | |
1685 | */ | |
1686 | ! PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, | |
1687 | ! Pt_DELAY_REALIZE | Pt_GETS_FOCUS ); | |
1688 | ! PtSetArg( &args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0); | |
1689 | #if 0 | |
1690 | /* Don't need this anchoring for the scrollbars */ | |
1691 | ! if( orient == SBAR_HORIZ ) | |
1692 | { | |
1693 | anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | | |
1694 | Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT; | |
1695 | --- 1775,1786 ---- | |
1696 | * | |
1697 | * Also, don't let the scrollbar get focus | |
1698 | */ | |
1699 | ! PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, | |
1700 | ! Pt_DELAY_REALIZE | Pt_GETS_FOCUS); | |
1701 | ! PtSetArg(&args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0); | |
1702 | #if 0 | |
1703 | /* Don't need this anchoring for the scrollbars */ | |
1704 | ! if (orient == SBAR_HORIZ) | |
1705 | { | |
1706 | anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | | |
1707 | Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT; | |
1708 | *************** | |
1709 | *** 1788,1827 **** | |
1710 | else | |
1711 | { | |
1712 | anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP; | |
1713 | ! if( sb->wp != NULL ) | |
1714 | { | |
1715 | ! if( sb == &sb->wp->w_scrollbars[ SBAR_LEFT ] ) | |
1716 | anchor_flags |= Pt_LEFT_ANCHORED_LEFT; | |
1717 | else | |
1718 | anchor_flags |= Pt_RIGHT_ANCHORED_RIGHT; | |
1719 | } | |
1720 | } | |
1721 | ! PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, anchor_flags, Pt_IS_ANCHORED ); | |
1722 | #endif | |
1723 | ! PtSetArg( &args[ n++ ], Pt_ARG_ORIENTATION, | |
1724 | ! (orient == SBAR_HORIZ) ? Pt_HORIZONTAL : Pt_VERTICAL, 0 ); | |
1725 | #ifdef USE_PANEL_GROUP | |
1726 | ! sb->id = PtCreateWidget( PtScrollbar, gui.vimPanelGroup, n, args ); | |
1727 | #else | |
1728 | ! sb->id = PtCreateWidget( PtScrollbar, gui.vimContainer, n, args ); | |
1729 | #endif | |
1730 | ||
1731 | ! PtAddCallback( sb->id, Pt_CB_SCROLLBAR_MOVE, gui_ph_handle_scrollbar, sb ); | |
1732 | } | |
1733 | ||
1734 | void | |
1735 | gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) | |
1736 | { | |
1737 | ! if( flag != 0 ) | |
1738 | ! PtRealizeWidget( sb->id ); | |
1739 | else | |
1740 | ! PtUnrealizeWidget( sb->id ); | |
1741 | } | |
1742 | ||
1743 | void | |
1744 | gui_mch_destroy_scrollbar(scrollbar_T *sb) | |
1745 | { | |
1746 | ! PtDestroyWidget( sb->id ); | |
1747 | sb->id = NULL; | |
1748 | } | |
1749 | ||
1750 | --- 1788,1827 ---- | |
1751 | else | |
1752 | { | |
1753 | anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP; | |
1754 | ! if (sb->wp != NULL) | |
1755 | { | |
1756 | ! if (sb == &sb->wp->w_scrollbars[ SBAR_LEFT ]) | |
1757 | anchor_flags |= Pt_LEFT_ANCHORED_LEFT; | |
1758 | else | |
1759 | anchor_flags |= Pt_RIGHT_ANCHORED_RIGHT; | |
1760 | } | |
1761 | } | |
1762 | ! PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, anchor_flags, Pt_IS_ANCHORED); | |
1763 | #endif | |
1764 | ! PtSetArg(&args[ n++ ], Pt_ARG_ORIENTATION, | |
1765 | ! (orient == SBAR_HORIZ) ? Pt_HORIZONTAL : Pt_VERTICAL, 0); | |
1766 | #ifdef USE_PANEL_GROUP | |
1767 | ! sb->id = PtCreateWidget(PtScrollbar, gui.vimPanelGroup, n, args); | |
1768 | #else | |
1769 | ! sb->id = PtCreateWidget(PtScrollbar, gui.vimContainer, n, args); | |
1770 | #endif | |
1771 | ||
1772 | ! PtAddCallback(sb->id, Pt_CB_SCROLLBAR_MOVE, gui_ph_handle_scrollbar, sb); | |
1773 | } | |
1774 | ||
1775 | void | |
1776 | gui_mch_enable_scrollbar(scrollbar_T *sb, int flag) | |
1777 | { | |
1778 | ! if (flag != 0) | |
1779 | ! PtRealizeWidget(sb->id); | |
1780 | else | |
1781 | ! PtUnrealizeWidget(sb->id); | |
1782 | } | |
1783 | ||
1784 | void | |
1785 | gui_mch_destroy_scrollbar(scrollbar_T *sb) | |
1786 | { | |
1787 | ! PtDestroyWidget(sb->id); | |
1788 | sb->id = NULL; | |
1789 | } | |
1790 | ||
1791 | *************** | |
1792 | *** 1866,1873 **** | |
1793 | return; | |
1794 | ||
1795 | if (shape == MSHAPE_HIDE || gui.pointer_hidden) | |
1796 | ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, | |
1797 | ! 0 ); | |
1798 | else | |
1799 | { | |
1800 | if (shape >= MSHAPE_NUMBERED) | |
1801 | --- 1866,1873 ---- | |
1802 | return; | |
1803 | ||
1804 | if (shape == MSHAPE_HIDE || gui.pointer_hidden) | |
1805 | ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, | |
1806 | ! 0); | |
1807 | else | |
1808 | { | |
1809 | if (shape >= MSHAPE_NUMBERED) | |
1810 | *************** | |
1811 | *** 1875,1881 **** | |
1812 | else | |
1813 | id = mshape_ids[shape]; | |
1814 | ||
1815 | ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE, id, 0 ); | |
1816 | } | |
1817 | if (shape != MSHAPE_HIDE) | |
1818 | last_shape = shape; | |
1819 | --- 1875,1881 ---- | |
1820 | else | |
1821 | id = mshape_ids[shape]; | |
1822 | ||
1823 | ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, id, 0); | |
1824 | } | |
1825 | if (shape != MSHAPE_HIDE) | |
1826 | last_shape = shape; | |
1827 | *************** | |
1828 | *** 1885,1903 **** | |
1829 | void | |
1830 | gui_mch_mousehide(int hide) | |
1831 | { | |
1832 | ! if( gui.pointer_hidden != hide ) | |
1833 | { | |
1834 | gui.pointer_hidden = hide; | |
1835 | #ifdef FEAT_MOUSESHAPE | |
1836 | ! if( hide ) | |
1837 | ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE, | |
1838 | ! Ph_CURSOR_NONE, 0 ); | |
1839 | else | |
1840 | ! mch_set_mouse_shape( last_shape ); | |
1841 | #else | |
1842 | ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE, | |
1843 | ! ( hide == MOUSE_SHOW ) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE, | |
1844 | ! 0 ); | |
1845 | #endif | |
1846 | } | |
1847 | } | |
1848 | --- 1885,1903 ---- | |
1849 | void | |
1850 | gui_mch_mousehide(int hide) | |
1851 | { | |
1852 | ! if (gui.pointer_hidden != hide) | |
1853 | { | |
1854 | gui.pointer_hidden = hide; | |
1855 | #ifdef FEAT_MOUSESHAPE | |
1856 | ! if (hide) | |
1857 | ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, | |
1858 | ! Ph_CURSOR_NONE, 0); | |
1859 | else | |
1860 | ! mch_set_mouse_shape(last_shape); | |
1861 | #else | |
1862 | ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, | |
1863 | ! (hide == MOUSE_SHOW) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE, | |
1864 | ! 0); | |
1865 | #endif | |
1866 | } | |
1867 | } | |
1868 | *************** | |
1869 | *** 1910,1917 **** | |
1870 | ||
1871 | /* FIXME: does this return the correct position, | |
1872 | * with respect to the border? */ | |
1873 | ! PhQueryCursor( PhInputGroup( NULL ), &info ); | |
1874 | ! PtGetAbsPosition( gui.vimTextArea , &ix, &iy ); | |
1875 | ||
1876 | *x = info.pos.x - ix; | |
1877 | *y = info.pos.y - iy; | |
1878 | --- 1910,1917 ---- | |
1879 | ||
1880 | /* FIXME: does this return the correct position, | |
1881 | * with respect to the border? */ | |
1882 | ! PhQueryCursor(PhInputGroup(NULL), &info); | |
1883 | ! PtGetAbsPosition(gui.vimTextArea , &ix, &iy); | |
1884 | ||
1885 | *x = info.pos.x - ix; | |
1886 | *y = info.pos.y - iy; | |
1887 | *************** | |
1888 | *** 1922,1930 **** | |
1889 | { | |
1890 | short abs_x, abs_y; | |
1891 | ||
1892 | ! PtGetAbsPosition( gui.vimTextArea, &abs_x, &abs_y ); | |
1893 | /* Add the border offset? */ | |
1894 | ! PhMoveCursorAbs( PhInputGroup( NULL ), abs_x + x, abs_y + y ); | |
1895 | } | |
1896 | ||
1897 | /****************************************************************************/ | |
1898 | --- 1922,1930 ---- | |
1899 | { | |
1900 | short abs_x, abs_y; | |
1901 | ||
1902 | ! PtGetAbsPosition(gui.vimTextArea, &abs_x, &abs_y); | |
1903 | /* Add the border offset? */ | |
1904 | ! PhMoveCursorAbs(PhInputGroup(NULL), abs_x + x, abs_y + y); | |
1905 | } | |
1906 | ||
1907 | /****************************************************************************/ | |
1908 | *************** | |
1909 | *** 1952,1974 **** | |
1910 | color_diff = gui_get_lightness(gui_ph_mouse_color) | |
1911 | - gui_get_lightness(gui.back_pixel); | |
1912 | ||
1913 | ! if( abs( color_diff ) < 64 ) | |
1914 | { | |
1915 | short r, g, b; | |
1916 | /* not a great algorithm... */ | |
1917 | ! r = PgRedValue( gui_ph_mouse_color ) ^ 255; | |
1918 | ! g = PgGreenValue( gui_ph_mouse_color ) ^ 255; | |
1919 | ! b = PgBlueValue( gui_ph_mouse_color ) ^ 255; | |
1920 | ||
1921 | #ifndef FEAT_MOUSESHAPE | |
1922 | ! gui_ph_mouse_color = PgRGB( r, g, b ); | |
1923 | ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_COLOR, | |
1924 | ! gui_ph_mouse_color, 0 ); | |
1925 | #endif | |
1926 | } | |
1927 | #endif | |
1928 | ||
1929 | ! PtSetResource( gui.vimTextArea, Pt_ARG_FILL_COLOR, gui.back_pixel, 0 ); | |
1930 | } | |
1931 | ||
1932 | static int | |
1933 | --- 1952,1974 ---- | |
1934 | color_diff = gui_get_lightness(gui_ph_mouse_color) | |
1935 | - gui_get_lightness(gui.back_pixel); | |
1936 | ||
1937 | ! if (abs(color_diff) < 64) | |
1938 | { | |
1939 | short r, g, b; | |
1940 | /* not a great algorithm... */ | |
1941 | ! r = PgRedValue(gui_ph_mouse_color) ^ 255; | |
1942 | ! g = PgGreenValue(gui_ph_mouse_color) ^ 255; | |
1943 | ! b = PgBlueValue(gui_ph_mouse_color) ^ 255; | |
1944 | ||
1945 | #ifndef FEAT_MOUSESHAPE | |
1946 | ! gui_ph_mouse_color = PgRGB(r, g, b); | |
1947 | ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_COLOR, | |
1948 | ! gui_ph_mouse_color, 0); | |
1949 | #endif | |
1950 | } | |
1951 | #endif | |
1952 | ||
1953 | ! PtSetResource(gui.vimTextArea, Pt_ARG_FILL_COLOR, gui.back_pixel, 0); | |
1954 | } | |
1955 | ||
1956 | static int | |
1957 | *************** | |
1958 | *** 2058,2076 **** | |
1959 | }; | |
1960 | ||
1961 | /* is name #rrggbb format? */ | |
1962 | ! if( name[0] == '#' && STRLEN( name ) == 7 ) | |
1963 | { | |
1964 | ! r = hex_digit( name[1] ) * 16 + hex_digit( name[2] ); | |
1965 | ! g = hex_digit( name[3] ) * 16 + hex_digit( name[4] ); | |
1966 | ! b = hex_digit( name[5] ) * 16 + hex_digit( name[6] ); | |
1967 | ! if( r < 0 || g < 0 || b < 0 ) | |
1968 | return INVALCOLOR; | |
1969 | return RGB(r, g, b); | |
1970 | } | |
1971 | ||
1972 | ! for( i = 0; i < ARRAY_LENGTH( table ); i++ ) | |
1973 | { | |
1974 | ! if( STRICMP( name, table[i].name ) == 0 ) | |
1975 | return table[i].colour; | |
1976 | } | |
1977 | ||
1978 | --- 2058,2076 ---- | |
1979 | }; | |
1980 | ||
1981 | /* is name #rrggbb format? */ | |
1982 | ! if (name[0] == '#' && STRLEN(name) == 7) | |
1983 | { | |
1984 | ! r = hex_digit(name[1]) * 16 + hex_digit(name[2]); | |
1985 | ! g = hex_digit(name[3]) * 16 + hex_digit(name[4]); | |
1986 | ! b = hex_digit(name[5]) * 16 + hex_digit(name[6]); | |
1987 | ! if (r < 0 || g < 0 || b < 0) | |
1988 | return INVALCOLOR; | |
1989 | return RGB(r, g, b); | |
1990 | } | |
1991 | ||
1992 | ! for (i = 0; i < ARRAY_LENGTH(table); i++) | |
1993 | { | |
1994 | ! if (STRICMP(name, table[i].name) == 0) | |
1995 | return table[i].colour; | |
1996 | } | |
1997 | ||
1998 | *************** | |
1999 | *** 2129,2141 **** | |
2000 | void | |
2001 | gui_mch_set_fg_color(guicolor_T color) | |
2002 | { | |
2003 | ! PgSetTextColor( color ); | |
2004 | } | |
2005 | ||
2006 | void | |
2007 | gui_mch_set_bg_color(guicolor_T color) | |
2008 | { | |
2009 | ! PgSetFillColor( color ); | |
2010 | } | |
2011 | ||
2012 | void | |
2013 | --- 2129,2141 ---- | |
2014 | void | |
2015 | gui_mch_set_fg_color(guicolor_T color) | |
2016 | { | |
2017 | ! PgSetTextColor(color); | |
2018 | } | |
2019 | ||
2020 | void | |
2021 | gui_mch_set_bg_color(guicolor_T color) | |
2022 | { | |
2023 | ! PgSetFillColor(color); | |
2024 | } | |
2025 | ||
2026 | void | |
2027 | *************** | |
2028 | *** 2148,2168 **** | |
2029 | { | |
2030 | PhRect_t rect; | |
2031 | ||
2032 | ! rect.ul.x = FILL_X( col ); | |
2033 | ! rect.ul.y = FILL_Y( row ); | |
2034 | ||
2035 | /* FIXME: This has an off by one pixel problem */ | |
2036 | rect.lr.x = rect.ul.x + nc * gui.char_width; | |
2037 | rect.lr.y = rect.ul.y + nr * gui.char_height; | |
2038 | ! if( nc > 0 ) | |
2039 | rect.lr.x -= 1; | |
2040 | ! if( nr > 0 ) | |
2041 | rect.lr.y -= 1; | |
2042 | ||
2043 | DRAW_START; | |
2044 | ! PgSetDrawMode( Pg_DrawModeDSTINVERT ); | |
2045 | ! PgDrawRect( &rect, Pg_DRAW_FILL ); | |
2046 | ! PgSetDrawMode( Pg_DrawModeSRCCOPY ); | |
2047 | DRAW_END; | |
2048 | } | |
2049 | ||
2050 | --- 2148,2168 ---- | |
2051 | { | |
2052 | PhRect_t rect; | |
2053 | ||
2054 | ! rect.ul.x = FILL_X(col); | |
2055 | ! rect.ul.y = FILL_Y(row); | |
2056 | ||
2057 | /* FIXME: This has an off by one pixel problem */ | |
2058 | rect.lr.x = rect.ul.x + nc * gui.char_width; | |
2059 | rect.lr.y = rect.ul.y + nr * gui.char_height; | |
2060 | ! if (nc > 0) | |
2061 | rect.lr.x -= 1; | |
2062 | ! if (nr > 0) | |
2063 | rect.lr.y -= 1; | |
2064 | ||
2065 | DRAW_START; | |
2066 | ! PgSetDrawMode(Pg_DrawModeDSTINVERT); | |
2067 | ! PgDrawRect(&rect, Pg_DRAW_FILL); | |
2068 | ! PgSetDrawMode(Pg_DrawModeSRCCOPY); | |
2069 | DRAW_END; | |
2070 | } | |
2071 | ||
2072 | *************** | |
2073 | *** 2170,2182 **** | |
2074 | gui_mch_clear_block(int row1, int col1, int row2, int col2) | |
2075 | { | |
2076 | PhRect_t block = { | |
2077 | ! { FILL_X( col1 ), FILL_Y( row1 ) }, | |
2078 | ! { FILL_X( col2 + 1 ) - 1, FILL_Y( row2 + 1 ) - 1} | |
2079 | }; | |
2080 | ||
2081 | DRAW_START; | |
2082 | ! gui_mch_set_bg_color( gui.back_pixel ); | |
2083 | ! PgDrawRect( &block, Pg_DRAW_FILL ); | |
2084 | DRAW_END; | |
2085 | } | |
2086 | ||
2087 | --- 2170,2182 ---- | |
2088 | gui_mch_clear_block(int row1, int col1, int row2, int col2) | |
2089 | { | |
2090 | PhRect_t block = { | |
2091 | ! { FILL_X(col1), FILL_Y(row1) }, | |
2092 | ! { FILL_X(col2 + 1) - 1, FILL_Y(row2 + 1) - 1} | |
2093 | }; | |
2094 | ||
2095 | DRAW_START; | |
2096 | ! gui_mch_set_bg_color(gui.back_pixel); | |
2097 | ! PgDrawRect(&block, Pg_DRAW_FILL); | |
2098 | DRAW_END; | |
2099 | } | |
2100 | ||
2101 | *************** | |
2102 | *** 2189,2200 **** | |
2103 | Rows * gui.char_height + gui.border_width - 1 } | |
2104 | }; | |
2105 | ||
2106 | ! if( is_ignore_draw == TRUE ) | |
2107 | return; | |
2108 | ||
2109 | DRAW_START; | |
2110 | ! gui_mch_set_bg_color( gui.back_pixel ); | |
2111 | ! PgDrawRect( &text_rect, Pg_DRAW_FILL ); | |
2112 | DRAW_END; | |
2113 | } | |
2114 | ||
2115 | --- 2189,2200 ---- | |
2116 | Rows * gui.char_height + gui.border_width - 1 } | |
2117 | }; | |
2118 | ||
2119 | ! if (is_ignore_draw == TRUE) | |
2120 | return; | |
2121 | ||
2122 | DRAW_START; | |
2123 | ! gui_mch_set_bg_color(gui.back_pixel); | |
2124 | ! PgDrawRect(&text_rect, Pg_DRAW_FILL); | |
2125 | DRAW_END; | |
2126 | } | |
2127 | ||
2128 | *************** | |
2129 | *** 2204,2231 **** | |
2130 | PhRect_t rect; | |
2131 | PhPoint_t delta; | |
2132 | ||
2133 | ! rect.ul.x = FILL_X( gui.scroll_region_left ); | |
2134 | ! rect.ul.y = FILL_Y( row + num_lines ); | |
2135 | ||
2136 | ! rect.lr.x = FILL_X( gui.scroll_region_right + 1 ) - 1; | |
2137 | ! rect.lr.y = FILL_Y( gui.scroll_region_bot + 1) - 1; | |
2138 | ||
2139 | ! PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset ); | |
2140 | ! PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL)); | |
2141 | ! PhTranslateRect( &rect, &gui_ph_raw_offset ); | |
2142 | ||
2143 | delta.x = 0; | |
2144 | delta.y = -num_lines * gui.char_height; | |
2145 | ||
2146 | PgFlush(); | |
2147 | ||
2148 | ! PhBlit( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ), &rect, &delta ); | |
2149 | ||
2150 | gui_clear_block( | |
2151 | gui.scroll_region_bot - num_lines + 1, | |
2152 | gui.scroll_region_left, | |
2153 | gui.scroll_region_bot, | |
2154 | ! gui.scroll_region_right ); | |
2155 | } | |
2156 | ||
2157 | void | |
2158 | --- 2204,2231 ---- | |
2159 | PhRect_t rect; | |
2160 | PhPoint_t delta; | |
2161 | ||
2162 | ! rect.ul.x = FILL_X(gui.scroll_region_left); | |
2163 | ! rect.ul.y = FILL_Y(row + num_lines); | |
2164 | ||
2165 | ! rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1; | |
2166 | ! rect.lr.y = FILL_Y(gui.scroll_region_bot + 1) - 1; | |
2167 | ||
2168 | ! PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset); | |
2169 | ! PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL)); | |
2170 | ! PhTranslateRect(&rect, &gui_ph_raw_offset); | |
2171 | ||
2172 | delta.x = 0; | |
2173 | delta.y = -num_lines * gui.char_height; | |
2174 | ||
2175 | PgFlush(); | |
2176 | ||
2177 | ! PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)), &rect, &delta); | |
2178 | ||
2179 | gui_clear_block( | |
2180 | gui.scroll_region_bot - num_lines + 1, | |
2181 | gui.scroll_region_left, | |
2182 | gui.scroll_region_bot, | |
2183 | ! gui.scroll_region_right); | |
2184 | } | |
2185 | ||
2186 | void | |
2187 | *************** | |
2188 | *** 2234,2258 **** | |
2189 | PhRect_t rect; | |
2190 | PhPoint_t delta; | |
2191 | ||
2192 | ! rect.ul.x = FILL_X( gui.scroll_region_left ); | |
2193 | ! rect.ul.y = FILL_Y( row ); | |
2194 | ||
2195 | ! rect.lr.x = FILL_X( gui.scroll_region_right + 1 ) - 1; | |
2196 | ! rect.lr.y = FILL_Y( gui.scroll_region_bot - num_lines + 1 ) - 1; | |
2197 | ||
2198 | ! PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset ); | |
2199 | ! PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos( gui.vimTextArea, NULL ) ); | |
2200 | ! PhTranslateRect( &rect, &gui_ph_raw_offset ); | |
2201 | ||
2202 | delta.x = 0; | |
2203 | delta.y = num_lines * gui.char_height; | |
2204 | ||
2205 | PgFlush(); | |
2206 | ||
2207 | ! PhBlit( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) , &rect, &delta ); | |
2208 | ||
2209 | ! gui_clear_block( row, gui.scroll_region_left, | |
2210 | ! row + num_lines - 1, gui.scroll_region_right ); | |
2211 | } | |
2212 | ||
2213 | void | |
2214 | --- 2234,2258 ---- | |
2215 | PhRect_t rect; | |
2216 | PhPoint_t delta; | |
2217 | ||
2218 | ! rect.ul.x = FILL_X(gui.scroll_region_left); | |
2219 | ! rect.ul.y = FILL_Y(row); | |
2220 | ||
2221 | ! rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1; | |
2222 | ! rect.lr.y = FILL_Y(gui.scroll_region_bot - num_lines + 1) - 1; | |
2223 | ||
2224 | ! PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset); | |
2225 | ! PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL)); | |
2226 | ! PhTranslateRect(&rect, &gui_ph_raw_offset); | |
2227 | ||
2228 | delta.x = 0; | |
2229 | delta.y = num_lines * gui.char_height; | |
2230 | ||
2231 | PgFlush(); | |
2232 | ||
2233 | ! PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)) , &rect, &delta); | |
2234 | ||
2235 | ! gui_clear_block(row, gui.scroll_region_left, | |
2236 | ! row + num_lines - 1, gui.scroll_region_right); | |
2237 | } | |
2238 | ||
2239 | void | |
2240 | *************** | |
2241 | *** 2261,2297 **** | |
2242 | static char *utf8_buffer = NULL; | |
2243 | static int utf8_len = 0; | |
2244 | ||
2245 | ! PhPoint_t pos = { TEXT_X( col ), TEXT_Y( row ) }; | |
2246 | PhRect_t rect; | |
2247 | ||
2248 | ! if( is_ignore_draw == TRUE ) | |
2249 | return; | |
2250 | ||
2251 | DRAW_START; | |
2252 | ||
2253 | ! if( !( flags & DRAW_TRANSP ) ) | |
2254 | { | |
2255 | PgDrawIRect( | |
2256 | ! FILL_X( col ), FILL_Y( row ), | |
2257 | ! FILL_X( col + len ) - 1, FILL_Y( row + 1 ) - 1, | |
2258 | ! Pg_DRAW_FILL ); | |
2259 | } | |
2260 | ||
2261 | ! if( flags & DRAW_UNDERL ) | |
2262 | ! PgSetUnderline( gui.norm_pixel, Pg_TRANSPARENT, 0 ); | |
2263 | ||
2264 | ! if( charset_translate != NULL | |
2265 | #ifdef FEAT_MBYTE | |
2266 | && enc_utf8 == 0 | |
2267 | #endif | |
2268 | ! ) | |
2269 | { | |
2270 | int src_taken, dst_made; | |
2271 | ||
2272 | /* Use a static buffer to avoid large amounts of de/allocations */ | |
2273 | ! if( utf8_len < len ) | |
2274 | { | |
2275 | ! utf8_buffer = realloc( utf8_buffer, len * MB_LEN_MAX ); | |
2276 | utf8_len = len; | |
2277 | } | |
2278 | ||
2279 | --- 2261,2297 ---- | |
2280 | static char *utf8_buffer = NULL; | |
2281 | static int utf8_len = 0; | |
2282 | ||
2283 | ! PhPoint_t pos = { TEXT_X(col), TEXT_Y(row) }; | |
2284 | PhRect_t rect; | |
2285 | ||
2286 | ! if (is_ignore_draw == TRUE) | |
2287 | return; | |
2288 | ||
2289 | DRAW_START; | |
2290 | ||
2291 | ! if (!(flags & DRAW_TRANSP)) | |
2292 | { | |
2293 | PgDrawIRect( | |
2294 | ! FILL_X(col), FILL_Y(row), | |
2295 | ! FILL_X(col + len) - 1, FILL_Y(row + 1) - 1, | |
2296 | ! Pg_DRAW_FILL); | |
2297 | } | |
2298 | ||
2299 | ! if (flags & DRAW_UNDERL) | |
2300 | ! PgSetUnderline(gui.norm_pixel, Pg_TRANSPARENT, 0); | |
2301 | ||
2302 | ! if (charset_translate != NULL | |
2303 | #ifdef FEAT_MBYTE | |
2304 | && enc_utf8 == 0 | |
2305 | #endif | |
2306 | ! ) | |
2307 | { | |
2308 | int src_taken, dst_made; | |
2309 | ||
2310 | /* Use a static buffer to avoid large amounts of de/allocations */ | |
2311 | ! if (utf8_len < len) | |
2312 | { | |
2313 | ! utf8_buffer = realloc(utf8_buffer, len * MB_LEN_MAX); | |
2314 | utf8_len = len; | |
2315 | } | |
2316 | ||
2317 | *************** | |
2318 | *** 2302,2337 **** | |
2319 | &src_taken, | |
2320 | utf8_buffer, | |
2321 | utf8_len, | |
2322 | ! &dst_made ); | |
2323 | s = utf8_buffer; | |
2324 | len = dst_made; | |
2325 | } | |
2326 | ||
2327 | ! PgDrawText( s, len, &pos, 0 ); | |
2328 | ||
2329 | ! if( flags & DRAW_BOLD ) | |
2330 | { | |
2331 | /* FIXME: try and only calculate these values once... */ | |
2332 | ! rect.ul.x = FILL_X( col ) + 1; | |
2333 | ! rect.ul.y = FILL_Y( row ); | |
2334 | ! rect.lr.x = FILL_X( col + len ) - 1; | |
2335 | ! rect.lr.y = FILL_Y( row + 1) - 1; | |
2336 | ! /* PgSetUserClip( NULL ) causes the scrollbar to not redraw... */ | |
2337 | #if 0 | |
2338 | pos.x++; | |
2339 | ||
2340 | ! PgSetUserClip( &rect ); | |
2341 | ! PgDrawText( s, len, &pos, 0 ); | |
2342 | ! PgSetUserClip( NULL ); | |
2343 | #else | |
2344 | ! rect.lr.y -= ( p_linespace + 1 ) / 2; | |
2345 | /* XXX: DrawTextArea doesn't work with phditto */ | |
2346 | ! PgDrawTextArea( s, len, &rect, Pg_TEXT_BOTTOM ); | |
2347 | #endif | |
2348 | } | |
2349 | ||
2350 | ! if( flags & DRAW_UNDERL ) | |
2351 | ! PgSetUnderline( Pg_TRANSPARENT, Pg_TRANSPARENT, 0 ); | |
2352 | ||
2353 | DRAW_END; | |
2354 | } | |
2355 | --- 2302,2337 ---- | |
2356 | &src_taken, | |
2357 | utf8_buffer, | |
2358 | utf8_len, | |
2359 | ! &dst_made); | |
2360 | s = utf8_buffer; | |
2361 | len = dst_made; | |
2362 | } | |
2363 | ||
2364 | ! PgDrawText(s, len, &pos, 0); | |
2365 | ||
2366 | ! if (flags & DRAW_BOLD) | |
2367 | { | |
2368 | /* FIXME: try and only calculate these values once... */ | |
2369 | ! rect.ul.x = FILL_X(col) + 1; | |
2370 | ! rect.ul.y = FILL_Y(row); | |
2371 | ! rect.lr.x = FILL_X(col + len) - 1; | |
2372 | ! rect.lr.y = FILL_Y(row + 1) - 1; | |
2373 | ! /* PgSetUserClip(NULL) causes the scrollbar to not redraw... */ | |
2374 | #if 0 | |
2375 | pos.x++; | |
2376 | ||
2377 | ! PgSetUserClip(&rect); | |
2378 | ! PgDrawText(s, len, &pos, 0); | |
2379 | ! PgSetUserClip(NULL); | |
2380 | #else | |
2381 | ! rect.lr.y -= (p_linespace + 1) / 2; | |
2382 | /* XXX: DrawTextArea doesn't work with phditto */ | |
2383 | ! PgDrawTextArea(s, len, &rect, Pg_TEXT_BOTTOM); | |
2384 | #endif | |
2385 | } | |
2386 | ||
2387 | ! if (flags & DRAW_UNDERL) | |
2388 | ! PgSetUnderline(Pg_TRANSPARENT, Pg_TRANSPARENT, 0); | |
2389 | ||
2390 | DRAW_END; | |
2391 | } | |
2392 | *************** | |
2393 | *** 2346,2359 **** | |
2394 | ||
2395 | /* FIXME: Double width characters */ | |
2396 | ||
2397 | ! r.ul.x = FILL_X( gui.col ); | |
2398 | ! r.ul.y = FILL_Y( gui.row ); | |
2399 | r.lr.x = r.ul.x + gui.char_width - 1; | |
2400 | r.lr.y = r.ul.y + gui.char_height - 1; | |
2401 | ||
2402 | DRAW_START; | |
2403 | ! PgSetStrokeColor( color ); | |
2404 | ! PgDrawRect( &r, Pg_DRAW_STROKE ); | |
2405 | DRAW_END; | |
2406 | } | |
2407 | ||
2408 | --- 2346,2359 ---- | |
2409 | ||
2410 | /* FIXME: Double width characters */ | |
2411 | ||
2412 | ! r.ul.x = FILL_X(gui.col); | |
2413 | ! r.ul.y = FILL_Y(gui.row); | |
2414 | r.lr.x = r.ul.x + gui.char_width - 1; | |
2415 | r.lr.y = r.ul.y + gui.char_height - 1; | |
2416 | ||
2417 | DRAW_START; | |
2418 | ! PgSetStrokeColor(color); | |
2419 | ! PgDrawRect(&r, Pg_DRAW_STROKE); | |
2420 | DRAW_END; | |
2421 | } | |
2422 | ||
2423 | *************** | |
2424 | *** 2362,2375 **** | |
2425 | { | |
2426 | PhRect_t r; | |
2427 | ||
2428 | ! r.ul.x = FILL_X( gui.col ); | |
2429 | ! r.ul.y = FILL_Y( gui.row ) + gui.char_height - h; | |
2430 | r.lr.x = r.ul.x + w - 1; | |
2431 | r.lr.y = r.ul.y + h - 1; | |
2432 | ||
2433 | DRAW_START; | |
2434 | ! gui_mch_set_bg_color( color ); | |
2435 | ! PgDrawRect( &r, Pg_DRAW_FILL ); | |
2436 | DRAW_END; | |
2437 | } | |
2438 | ||
2439 | --- 2362,2375 ---- | |
2440 | { | |
2441 | PhRect_t r; | |
2442 | ||
2443 | ! r.ul.x = FILL_X(gui.col); | |
2444 | ! r.ul.y = FILL_Y(gui.row) + gui.char_height - h; | |
2445 | r.lr.x = r.ul.x + w - 1; | |
2446 | r.lr.y = r.ul.y + h - 1; | |
2447 | ||
2448 | DRAW_START; | |
2449 | ! gui_mch_set_bg_color(color); | |
2450 | ! PgDrawRect(&r, Pg_DRAW_FILL); | |
2451 | DRAW_END; | |
2452 | } | |
2453 | ||
2454 | *************** | |
2455 | *** 2385,2394 **** | |
2456 | gui_mch_start_blink(void) | |
2457 | { | |
2458 | /* Only turn on the timer on if none of the times are zero */ | |
2459 | ! if( blink_waittime && blink_ontime && blink_offtime && gui.in_focus) | |
2460 | { | |
2461 | ! PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, | |
2462 | ! blink_waittime, 0 ); | |
2463 | blink_state = BLINK_ON; | |
2464 | gui_update_cursor(TRUE, FALSE); | |
2465 | } | |
2466 | --- 2385,2394 ---- | |
2467 | gui_mch_start_blink(void) | |
2468 | { | |
2469 | /* Only turn on the timer on if none of the times are zero */ | |
2470 | ! if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) | |
2471 | { | |
2472 | ! PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, | |
2473 | ! blink_waittime, 0); | |
2474 | blink_state = BLINK_ON; | |
2475 | gui_update_cursor(TRUE, FALSE); | |
2476 | } | |
2477 | *************** | |
2478 | *** 2397,2405 **** | |
2479 | void | |
2480 | gui_mch_stop_blink(void) | |
2481 | { | |
2482 | ! PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0 ); | |
2483 | ||
2484 | ! if( blink_state == BLINK_OFF ) | |
2485 | gui_update_cursor(TRUE, FALSE); | |
2486 | ||
2487 | blink_state = BLINK_NONE; | |
2488 | --- 2397,2405 ---- | |
2489 | void | |
2490 | gui_mch_stop_blink(void) | |
2491 | { | |
2492 | ! PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0); | |
2493 | ||
2494 | ! if (blink_state == BLINK_OFF) | |
2495 | gui_update_cursor(TRUE, FALSE); | |
2496 | ||
2497 | blink_state = BLINK_NONE; | |
2498 | *************** | |
2499 | *** 2417,2431 **** | |
2500 | void | |
2501 | gui_mch_flash(int msec) | |
2502 | { | |
2503 | ! PgSetFillXORColor( Pg_BLACK, Pg_WHITE ); | |
2504 | ! PgSetDrawMode( Pg_DRAWMODE_XOR ); | |
2505 | gui_mch_clear_all(); | |
2506 | gui_mch_flush(); | |
2507 | ||
2508 | ! ui_delay( (long) msec, TRUE ); | |
2509 | ||
2510 | gui_mch_clear_all(); | |
2511 | ! PgSetDrawMode( Pg_DRAWMODE_OPAQUE ); | |
2512 | gui_mch_flush(); | |
2513 | } | |
2514 | ||
2515 | --- 2417,2431 ---- | |
2516 | void | |
2517 | gui_mch_flash(int msec) | |
2518 | { | |
2519 | ! PgSetFillXORColor(Pg_BLACK, Pg_WHITE); | |
2520 | ! PgSetDrawMode(Pg_DRAWMODE_XOR); | |
2521 | gui_mch_clear_all(); | |
2522 | gui_mch_flush(); | |
2523 | ||
2524 | ! ui_delay((long) msec, TRUE); | |
2525 | ||
2526 | gui_mch_clear_all(); | |
2527 | ! PgSetDrawMode(Pg_DRAWMODE_OPAQUE); | |
2528 | gui_mch_flush(); | |
2529 | } | |
2530 | ||
2531 | *************** | |
2532 | *** 2440,2446 **** | |
2533 | { | |
2534 | PhArea_t area = {{x, y}, {w, h}}; | |
2535 | ||
2536 | ! PtSetResource( gui.vimTextArea, Pt_ARG_AREA, &area, 0 ); | |
2537 | } | |
2538 | ||
2539 | int | |
2540 | --- 2440,2446 ---- | |
2541 | { | |
2542 | PhArea_t area = {{x, y}, {w, h}}; | |
2543 | ||
2544 | ! PtSetResource(gui.vimTextArea, Pt_ARG_AREA, &area, 0); | |
2545 | } | |
2546 | ||
2547 | int | |
2548 | *************** | |
2549 | *** 2496,2514 **** | |
2550 | }; | |
2551 | ||
2552 | static PhImage_t * | |
2553 | ! gui_ph_toolbar_load_icon( char_u *iconfile ) | |
2554 | { | |
2555 | static PhImage_t external_icon; | |
2556 | PhImage_t *temp_phi = NULL; | |
2557 | ||
2558 | ! temp_phi = PxLoadImage( iconfile, NULL ); | |
2559 | ! if( temp_phi != NULL ) | |
2560 | { | |
2561 | /* The label widget will free the image/palette/etc. for us when | |
2562 | * it's destroyed */ | |
2563 | temp_phi->flags |= Ph_RELEASE_IMAGE_ALL; | |
2564 | ! memcpy( &external_icon, temp_phi, sizeof( external_icon ) ); | |
2565 | ! free( temp_phi ); | |
2566 | ||
2567 | temp_phi = &external_icon; | |
2568 | } | |
2569 | --- 2496,2514 ---- | |
2570 | }; | |
2571 | ||
2572 | static PhImage_t * | |
2573 | ! gui_ph_toolbar_load_icon(char_u *iconfile) | |
2574 | { | |
2575 | static PhImage_t external_icon; | |
2576 | PhImage_t *temp_phi = NULL; | |
2577 | ||
2578 | ! temp_phi = PxLoadImage(iconfile, NULL); | |
2579 | ! if (temp_phi != NULL) | |
2580 | { | |
2581 | /* The label widget will free the image/palette/etc. for us when | |
2582 | * it's destroyed */ | |
2583 | temp_phi->flags |= Ph_RELEASE_IMAGE_ALL; | |
2584 | ! memcpy(&external_icon, temp_phi, sizeof(external_icon)); | |
2585 | ! free(temp_phi); | |
2586 | ||
2587 | temp_phi = &external_icon; | |
2588 | } | |
2589 | *************** | |
2590 | *** 2523,2551 **** | |
2591 | * PhImage_t are copied, and the original PhImage_t aren't needed anymore). | |
2592 | */ | |
2593 | static PhImage_t * | |
2594 | ! gui_ph_toolbar_find_icon( vimmenu_T *menu ) | |
2595 | { | |
2596 | char_u full_pathname[ MAXPATHL + 1 ]; | |
2597 | PhImage_t *icon = NULL; | |
2598 | ||
2599 | ! if( menu->icon_builtin == FALSE ) | |
2600 | { | |
2601 | ! if( menu->iconfile != NULL ) | |
2602 | /* TODO: use gui_find_iconfile() */ | |
2603 | ! icon = gui_ph_toolbar_load_icon( menu->iconfile ); | |
2604 | ||
2605 | /* TODO: Restrict loading to just .png? Search for any format? */ | |
2606 | ! if( ( icon == NULL ) && | |
2607 | ! ( ( gui_find_bitmap( menu->name, full_pathname, "gif" ) == OK ) || | |
2608 | ! ( gui_find_bitmap( menu->name, full_pathname, "png" ) == OK ) ) ) | |
2609 | ! icon = gui_ph_toolbar_load_icon( full_pathname ); | |
2610 | ||
2611 | ! if( icon != NULL ) | |
2612 | return icon; | |
2613 | } | |
2614 | ||
2615 | ! if( menu->iconidx >= 0 && | |
2616 | ! ( menu->iconidx < ARRAY_LENGTH( gui_ph_toolbar_images ) ) ) | |
2617 | { | |
2618 | return gui_ph_toolbar_images[menu->iconidx]; | |
2619 | } | |
2620 | --- 2523,2551 ---- | |
2621 | * PhImage_t are copied, and the original PhImage_t aren't needed anymore). | |
2622 | */ | |
2623 | static PhImage_t * | |
2624 | ! gui_ph_toolbar_find_icon(vimmenu_T *menu) | |
2625 | { | |
2626 | char_u full_pathname[ MAXPATHL + 1 ]; | |
2627 | PhImage_t *icon = NULL; | |
2628 | ||
2629 | ! if (menu->icon_builtin == FALSE) | |
2630 | { | |
2631 | ! if (menu->iconfile != NULL) | |
2632 | /* TODO: use gui_find_iconfile() */ | |
2633 | ! icon = gui_ph_toolbar_load_icon(menu->iconfile); | |
2634 | ||
2635 | /* TODO: Restrict loading to just .png? Search for any format? */ | |
2636 | ! if ((icon == NULL) && | |
2637 | ! ((gui_find_bitmap(menu->name, full_pathname, "gif") == OK) || | |
2638 | ! (gui_find_bitmap(menu->name, full_pathname, "png") == OK))) | |
2639 | ! icon = gui_ph_toolbar_load_icon(full_pathname); | |
2640 | ||
2641 | ! if (icon != NULL) | |
2642 | return icon; | |
2643 | } | |
2644 | ||
2645 | ! if (menu->iconidx >= 0 && | |
2646 | ! (menu->iconidx < ARRAY_LENGTH(gui_ph_toolbar_images))) | |
2647 | { | |
2648 | return gui_ph_toolbar_images[menu->iconidx]; | |
2649 | } | |
2650 | *************** | |
2651 | *** 2554,2567 **** | |
2652 | } | |
2653 | #endif | |
2654 | ||
2655 | ! #if defined( FEAT_MENU ) || defined( PROTO ) | |
2656 | void | |
2657 | gui_mch_enable_menu(int flag) | |
2658 | { | |
2659 | ! if( flag != 0 ) | |
2660 | ! PtRealizeWidget( gui.vimMenuBar ); | |
2661 | else | |
2662 | ! PtUnrealizeWidget( gui.vimMenuBar ); | |
2663 | } | |
2664 | ||
2665 | void | |
2666 | --- 2554,2567 ---- | |
2667 | } | |
2668 | #endif | |
2669 | ||
2670 | ! #if defined(FEAT_MENU) || defined(PROTO) | |
2671 | void | |
2672 | gui_mch_enable_menu(int flag) | |
2673 | { | |
2674 | ! if (flag != 0) | |
2675 | ! PtRealizeWidget(gui.vimMenuBar); | |
2676 | else | |
2677 | ! PtUnrealizeWidget(gui.vimMenuBar); | |
2678 | } | |
2679 | ||
2680 | void | |
2681 | *************** | |
2682 | *** 2572,2601 **** | |
2683 | ||
2684 | /* Change the position of a menu button in the parent */ | |
2685 | static void | |
2686 | ! gui_ph_position_menu( PtWidget_t *widget, int priority ) | |
2687 | { | |
2688 | PtWidget_t *traverse; | |
2689 | vimmenu_T *menu; | |
2690 | ||
2691 | ! traverse = PtWidgetChildBack( PtWidgetParent( widget ) ); | |
2692 | ||
2693 | /* Iterate through the list of widgets in traverse, until | |
2694 | * we find the position we want to insert our widget into */ | |
2695 | /* TODO: traverse from front to back, possible speedup? */ | |
2696 | ! while( traverse != NULL ) | |
2697 | { | |
2698 | ! PtGetResource( traverse, Pt_ARG_POINTER, &menu, 0 ); | |
2699 | ||
2700 | ! if( menu != NULL && | |
2701 | priority < menu->priority && | |
2702 | ! widget != traverse ) | |
2703 | { | |
2704 | /* Insert the widget before the current traverse widget */ | |
2705 | ! PtWidgetInsert( widget, traverse, 1 ); | |
2706 | return; | |
2707 | } | |
2708 | ||
2709 | ! traverse = PtWidgetBrotherInFront( traverse ); | |
2710 | } | |
2711 | } | |
2712 | ||
2713 | --- 2572,2601 ---- | |
2714 | ||
2715 | /* Change the position of a menu button in the parent */ | |
2716 | static void | |
2717 | ! gui_ph_position_menu(PtWidget_t *widget, int priority) | |
2718 | { | |
2719 | PtWidget_t *traverse; | |
2720 | vimmenu_T *menu; | |
2721 | ||
2722 | ! traverse = PtWidgetChildBack(PtWidgetParent(widget)); | |
2723 | ||
2724 | /* Iterate through the list of widgets in traverse, until | |
2725 | * we find the position we want to insert our widget into */ | |
2726 | /* TODO: traverse from front to back, possible speedup? */ | |
2727 | ! while (traverse != NULL) | |
2728 | { | |
2729 | ! PtGetResource(traverse, Pt_ARG_POINTER, &menu, 0); | |
2730 | ||
2731 | ! if (menu != NULL && | |
2732 | priority < menu->priority && | |
2733 | ! widget != traverse) | |
2734 | { | |
2735 | /* Insert the widget before the current traverse widget */ | |
2736 | ! PtWidgetInsert(widget, traverse, 1); | |
2737 | return; | |
2738 | } | |
2739 | ||
2740 | ! traverse = PtWidgetBrotherInFront(traverse); | |
2741 | } | |
2742 | } | |
2743 | ||
2744 | *************** | |
2745 | *** 2611,2621 **** | |
2746 | ||
2747 | menu->submenu_id = menu->id = NULL; | |
2748 | ||
2749 | ! if( menu_is_menubar( menu->name ) ) | |
2750 | { | |
2751 | ||
2752 | ! accel_key = vim_strchr( menu->name, '&' ); | |
2753 | ! if( accel_key != NULL ) | |
2754 | { | |
2755 | mnemonic_str[0] = accel_key[1]; | |
2756 | mnemonic_str[1] = NUL; | |
2757 | --- 2611,2621 ---- | |
2758 | ||
2759 | menu->submenu_id = menu->id = NULL; | |
2760 | ||
2761 | ! if (menu_is_menubar(menu->name)) | |
2762 | { | |
2763 | ||
2764 | ! accel_key = vim_strchr(menu->name, '&'); | |
2765 | ! if (accel_key != NULL) | |
2766 | { | |
2767 | mnemonic_str[0] = accel_key[1]; | |
2768 | mnemonic_str[1] = NUL; | |
2769 | *************** | |
2770 | *** 2623,2673 **** | |
2771 | ||
2772 | /* Create the menu button */ | |
2773 | n = 0; | |
2774 | ! PtSetArg( &args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0 ); | |
2775 | ! PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0 ); | |
2776 | ! if( accel_key != NULL ) | |
2777 | ! PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, 0 ); | |
2778 | ! PtSetArg( &args[ n++ ], Pt_ARG_POINTER, menu, 0 ); | |
2779 | ||
2780 | ! if( parent != NULL ) | |
2781 | ! PtSetArg( &args[ n++ ], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0 ); | |
2782 | ||
2783 | ! menu->id = PtCreateWidget( PtMenuButton, | |
2784 | (parent == NULL) ? gui.vimMenuBar : parent->submenu_id, | |
2785 | ! n, args ); | |
2786 | ||
2787 | ! PtAddCallback( menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu ); | |
2788 | ||
2789 | /* Create the actual menu */ | |
2790 | n = 0; | |
2791 | ! if( parent != NULL ) | |
2792 | ! PtSetArg( &args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD ); | |
2793 | ||
2794 | ! menu->submenu_id = PtCreateWidget( PtMenu, menu->id, n, args ); | |
2795 | ||
2796 | ! if( parent == NULL ) | |
2797 | { | |
2798 | ! PtAddCallback( menu->submenu_id, Pt_CB_UNREALIZED, | |
2799 | ! gui_ph_handle_menu_unrealized, menu ); | |
2800 | ||
2801 | ! if( menu->mnemonic != 0 ) | |
2802 | { | |
2803 | ! PtAddHotkeyHandler( gui.vimWindow, tolower( menu->mnemonic ), | |
2804 | ! Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu ); | |
2805 | } | |
2806 | } | |
2807 | ||
2808 | ! gui_ph_position_menu( menu->id, menu->priority ); | |
2809 | ||
2810 | /* Redraw menubar here instead of gui_mch_draw_menubar */ | |
2811 | ! if( gui.menu_is_active ) | |
2812 | ! PtRealizeWidget( menu->id ); | |
2813 | } | |
2814 | ! else if( menu_is_popup( menu->name ) ) | |
2815 | { | |
2816 | ! menu->submenu_id = PtCreateWidget( PtMenu, gui.vimWindow, 0, NULL ); | |
2817 | ! PtAddCallback( menu->submenu_id, Pt_CB_UNREALIZED, | |
2818 | ! gui_ph_handle_menu_unrealized, menu ); | |
2819 | } | |
2820 | } | |
2821 | ||
2822 | --- 2623,2673 ---- | |
2823 | ||
2824 | /* Create the menu button */ | |
2825 | n = 0; | |
2826 | ! PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0); | |
2827 | ! PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0); | |
2828 | ! if (accel_key != NULL) | |
2829 | ! PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, 0); | |
2830 | ! PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0); | |
2831 | ||
2832 | ! if (parent != NULL) | |
2833 | ! PtSetArg(&args[ n++ ], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0); | |
2834 | ||
2835 | ! menu->id = PtCreateWidget(PtMenuButton, | |
2836 | (parent == NULL) ? gui.vimMenuBar : parent->submenu_id, | |
2837 | ! n, args); | |
2838 | ||
2839 | ! PtAddCallback(menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu); | |
2840 | ||
2841 | /* Create the actual menu */ | |
2842 | n = 0; | |
2843 | ! if (parent != NULL) | |
2844 | ! PtSetArg(&args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD); | |
2845 | ||
2846 | ! menu->submenu_id = PtCreateWidget(PtMenu, menu->id, n, args); | |
2847 | ||
2848 | ! if (parent == NULL) | |
2849 | { | |
2850 | ! PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED, | |
2851 | ! gui_ph_handle_menu_unrealized, menu); | |
2852 | ||
2853 | ! if (menu->mnemonic != 0) | |
2854 | { | |
2855 | ! PtAddHotkeyHandler(gui.vimWindow, tolower(menu->mnemonic), | |
2856 | ! Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu); | |
2857 | } | |
2858 | } | |
2859 | ||
2860 | ! gui_ph_position_menu(menu->id, menu->priority); | |
2861 | ||
2862 | /* Redraw menubar here instead of gui_mch_draw_menubar */ | |
2863 | ! if (gui.menu_is_active) | |
2864 | ! PtRealizeWidget(menu->id); | |
2865 | } | |
2866 | ! else if (menu_is_popup(menu->name)) | |
2867 | { | |
2868 | ! menu->submenu_id = PtCreateWidget(PtMenu, gui.vimWindow, 0, NULL); | |
2869 | ! PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED, | |
2870 | ! gui_ph_handle_menu_unrealized, menu); | |
2871 | } | |
2872 | } | |
2873 | ||
2874 | *************** | |
2875 | *** 2681,2784 **** | |
2876 | PtArg_t args[13]; | |
2877 | ||
2878 | n = 0; | |
2879 | ! PtSetArg( &args[ n++ ], Pt_ARG_POINTER, menu, 0 ); | |
2880 | ||
2881 | #ifdef FEAT_TOOLBAR | |
2882 | ! if( menu_is_toolbar( parent->name ) ) | |
2883 | { | |
2884 | ! if( menu_is_separator( menu->name ) ) | |
2885 | { | |
2886 | ! PtSetArg( &args[ n++ ], Pt_ARG_SEP_FLAGS, | |
2887 | ! Pt_SEP_VERTICAL, Pt_SEP_ORIENTATION ); | |
2888 | ! PtSetArg( &args[ n++ ], Pt_ARG_SEP_TYPE, Pt_ETCHED_IN, 0 ); | |
2889 | ! PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, | |
2890 | ! Pt_TRUE, Pt_ANCHOR_TOP_BOTTOM ); | |
2891 | ! PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, 2, 0 ); | |
2892 | ! menu->id = PtCreateWidget( PtSeparator, gui.vimToolBar, n, args ); | |
2893 | } | |
2894 | else | |
2895 | { | |
2896 | ! if( strstr( (const char *) p_toolbar, "text" ) != NULL ) | |
2897 | { | |
2898 | ! PtSetArg( &args[ n++ ], Pt_ARG_BALLOON_POSITION, | |
2899 | ! Pt_BALLOON_BOTTOM, 0 ); | |
2900 | ! PtSetArg( &args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0 ); | |
2901 | ! PtSetArg( &args[ n++ ], Pt_ARG_TEXT_FONT, "TextFont08", 0 ); | |
2902 | } | |
2903 | ! if( ( strstr( (const char *) p_toolbar, "icons" ) != NULL ) && | |
2904 | ! ( gui_ph_toolbar_images != NULL ) ) | |
2905 | { | |
2906 | ! PtSetArg( &args[ n++ ], Pt_ARG_LABEL_IMAGE, | |
2907 | ! gui_ph_toolbar_find_icon( menu ), 0 ); | |
2908 | ! PtSetArg( &args[ n++ ], Pt_ARG_LABEL_TYPE, Pt_TEXT_IMAGE, 0 ); | |
2909 | ! PtSetArg( &args[ n++ ], Pt_ARG_TEXT_IMAGE_SPACING, 0, 0 ); | |
2910 | } | |
2911 | ! if( strstr( (const char *) p_toolbar, "tooltips" ) != NULL ) | |
2912 | { | |
2913 | ! PtSetArg( &args[ n++ ], Pt_ARG_LABEL_BALLOON, | |
2914 | ! gui_ph_show_tooltip, 0 ); | |
2915 | ! PtSetArg( &args[ n++ ], Pt_ARG_LABEL_FLAGS, | |
2916 | ! Pt_TRUE, Pt_SHOW_BALLOON ); | |
2917 | } | |
2918 | ! PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 1, 0 ); | |
2919 | ! PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_WIDTH, 1, 0 ); | |
2920 | ! PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_FALSE, | |
2921 | ! Pt_HIGHLIGHTED | Pt_GETS_FOCUS ); | |
2922 | ! PtSetArg( &args[ n++ ], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 ); | |
2923 | ! menu->id = PtCreateWidget( PtButton, gui.vimToolBar, n, args ); | |
2924 | ||
2925 | ! PtAddCallback( menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu ); | |
2926 | } | |
2927 | /* Update toolbar if it's open */ | |
2928 | ! if( PtWidgetIsRealized( gui.vimToolBar ) ) | |
2929 | ! PtRealizeWidget( menu->id ); | |
2930 | } | |
2931 | else | |
2932 | #endif | |
2933 | ! if( menu_is_separator( menu->name ) ) | |
2934 | { | |
2935 | ! menu->id = PtCreateWidget( PtSeparator, parent->submenu_id, n, args ); | |
2936 | } | |
2937 | else | |
2938 | { | |
2939 | ! accel_key = vim_strchr( menu->name, '&' ); | |
2940 | ! if( accel_key != NULL ) | |
2941 | { | |
2942 | mnemonic_str[0] = accel_key[1]; | |
2943 | mnemonic_str[1] = NUL; | |
2944 | } | |
2945 | ||
2946 | ! PtSetArg( &args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0 ); | |
2947 | ! if( accel_key != NULL ) | |
2948 | ! PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, | |
2949 | ! 0 ); | |
2950 | ||
2951 | ! PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0 ); | |
2952 | ||
2953 | ! menu->id = PtCreateWidget( PtMenuButton, parent->submenu_id, n, args ); | |
2954 | ||
2955 | ! PtAddCallback( menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu ); | |
2956 | ||
2957 | #ifdef USE_PANEL_GROUP | |
2958 | ! if( gui_ph_is_buffer_item( menu, parent ) == TRUE ) | |
2959 | { | |
2960 | ! PtAddCallback( menu->id, Pt_CB_DESTROYED, | |
2961 | ! gui_ph_handle_buffer_remove, menu ); | |
2962 | ! gui_ph_pg_add_buffer( menu->dname ); | |
2963 | } | |
2964 | #endif | |
2965 | } | |
2966 | ||
2967 | ! gui_ph_position_menu( menu->id, menu->priority ); | |
2968 | } | |
2969 | ||
2970 | void | |
2971 | gui_mch_destroy_menu(vimmenu_T *menu) | |
2972 | { | |
2973 | ! if( menu->submenu_id != NULL ) | |
2974 | ! PtDestroyWidget( menu->submenu_id ); | |
2975 | ! if( menu->id != NULL ) | |
2976 | ! PtDestroyWidget( menu->id ); | |
2977 | ||
2978 | menu->submenu_id = NULL; | |
2979 | menu->id = NULL; | |
2980 | --- 2681,2784 ---- | |
2981 | PtArg_t args[13]; | |
2982 | ||
2983 | n = 0; | |
2984 | ! PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0); | |
2985 | ||
2986 | #ifdef FEAT_TOOLBAR | |
2987 | ! if (menu_is_toolbar(parent->name)) | |
2988 | { | |
2989 | ! if (menu_is_separator(menu->name)) | |
2990 | { | |
2991 | ! PtSetArg(&args[ n++ ], Pt_ARG_SEP_FLAGS, | |
2992 | ! Pt_SEP_VERTICAL, Pt_SEP_ORIENTATION); | |
2993 | ! PtSetArg(&args[ n++ ], Pt_ARG_SEP_TYPE, Pt_ETCHED_IN, 0); | |
2994 | ! PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, | |
2995 | ! Pt_TRUE, Pt_ANCHOR_TOP_BOTTOM); | |
2996 | ! PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, 2, 0); | |
2997 | ! menu->id = PtCreateWidget(PtSeparator, gui.vimToolBar, n, args); | |
2998 | } | |
2999 | else | |
3000 | { | |
3001 | ! if (strstr((const char *) p_toolbar, "text") != NULL) | |
3002 | { | |
3003 | ! PtSetArg(&args[ n++ ], Pt_ARG_BALLOON_POSITION, | |
3004 | ! Pt_BALLOON_BOTTOM, 0); | |
3005 | ! PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0); | |
3006 | ! PtSetArg(&args[ n++ ], Pt_ARG_TEXT_FONT, "TextFont08", 0); | |
3007 | } | |
3008 | ! if ((strstr((const char *) p_toolbar, "icons") != NULL) && | |
3009 | ! (gui_ph_toolbar_images != NULL)) | |
3010 | { | |
3011 | ! PtSetArg(&args[ n++ ], Pt_ARG_LABEL_IMAGE, | |
3012 | ! gui_ph_toolbar_find_icon(menu), 0); | |
3013 | ! PtSetArg(&args[ n++ ], Pt_ARG_LABEL_TYPE, Pt_TEXT_IMAGE, 0); | |
3014 | ! PtSetArg(&args[ n++ ], Pt_ARG_TEXT_IMAGE_SPACING, 0, 0); | |
3015 | } | |
3016 | ! if (strstr((const char *) p_toolbar, "tooltips") != NULL) | |
3017 | { | |
3018 | ! PtSetArg(&args[ n++ ], Pt_ARG_LABEL_BALLOON, | |
3019 | ! gui_ph_show_tooltip, 0); | |
3020 | ! PtSetArg(&args[ n++ ], Pt_ARG_LABEL_FLAGS, | |
3021 | ! Pt_TRUE, Pt_SHOW_BALLOON); | |
3022 | } | |
3023 | ! PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 1, 0); | |
3024 | ! PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 1, 0); | |
3025 | ! PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_FALSE, | |
3026 | ! Pt_HIGHLIGHTED | Pt_GETS_FOCUS); | |
3027 | ! PtSetArg(&args[ n++ ], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0); | |
3028 | ! menu->id = PtCreateWidget(PtButton, gui.vimToolBar, n, args); | |
3029 | ||
3030 | ! PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu); | |
3031 | } | |
3032 | /* Update toolbar if it's open */ | |
3033 | ! if (PtWidgetIsRealized(gui.vimToolBar)) | |
3034 | ! PtRealizeWidget(menu->id); | |
3035 | } | |
3036 | else | |
3037 | #endif | |
3038 | ! if (menu_is_separator(menu->name)) | |
3039 | { | |
3040 | ! menu->id = PtCreateWidget(PtSeparator, parent->submenu_id, n, args); | |
3041 | } | |
3042 | else | |
3043 | { | |
3044 | ! accel_key = vim_strchr(menu->name, '&'); | |
3045 | ! if (accel_key != NULL) | |
3046 | { | |
3047 | mnemonic_str[0] = accel_key[1]; | |
3048 | mnemonic_str[1] = NUL; | |
3049 | } | |
3050 | ||
3051 | ! PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0); | |
3052 | ! if (accel_key != NULL) | |
3053 | ! PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, | |
3054 | ! 0); | |
3055 | ||
3056 | ! PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0); | |
3057 | ||
3058 | ! menu->id = PtCreateWidget(PtMenuButton, parent->submenu_id, n, args); | |
3059 | ||
3060 | ! PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu); | |
3061 | ||
3062 | #ifdef USE_PANEL_GROUP | |
3063 | ! if (gui_ph_is_buffer_item(menu, parent) == TRUE) | |
3064 | { | |
3065 | ! PtAddCallback(menu->id, Pt_CB_DESTROYED, | |
3066 | ! gui_ph_handle_buffer_remove, menu); | |
3067 | ! gui_ph_pg_add_buffer(menu->dname); | |
3068 | } | |
3069 | #endif | |
3070 | } | |
3071 | ||
3072 | ! gui_ph_position_menu(menu->id, menu->priority); | |
3073 | } | |
3074 | ||
3075 | void | |
3076 | gui_mch_destroy_menu(vimmenu_T *menu) | |
3077 | { | |
3078 | ! if (menu->submenu_id != NULL) | |
3079 | ! PtDestroyWidget(menu->submenu_id); | |
3080 | ! if (menu->id != NULL) | |
3081 | ! PtDestroyWidget(menu->id); | |
3082 | ||
3083 | menu->submenu_id = NULL; | |
3084 | menu->id = NULL; | |
3085 | *************** | |
3086 | *** 2789,2800 **** | |
3087 | { | |
3088 | long flags, mask, fields; | |
3089 | ||
3090 | ! if( menu->id == NULL ) | |
3091 | return; | |
3092 | ||
3093 | ! flags = PtWidgetFlags( menu->id ); | |
3094 | ! if( PtWidgetIsClass( menu->id, PtMenuButton ) && | |
3095 | ! PtWidgetIsClass( PtWidgetParent( menu->id ), PtMenu ) ) | |
3096 | { | |
3097 | fields = Pt_FALSE; | |
3098 | mask = Pt_SELECTABLE | Pt_HIGHLIGHTED; | |
3099 | --- 2789,2800 ---- | |
3100 | { | |
3101 | long flags, mask, fields; | |
3102 | ||
3103 | ! if (menu->id == NULL) | |
3104 | return; | |
3105 | ||
3106 | ! flags = PtWidgetFlags(menu->id); | |
3107 | ! if (PtWidgetIsClass(menu->id, PtMenuButton) && | |
3108 | ! PtWidgetIsClass(PtWidgetParent(menu->id), PtMenu)) | |
3109 | { | |
3110 | fields = Pt_FALSE; | |
3111 | mask = Pt_SELECTABLE | Pt_HIGHLIGHTED; | |
3112 | *************** | |
3113 | *** 2805,2815 **** | |
3114 | mask = Pt_BLOCKED | Pt_GHOST; | |
3115 | } | |
3116 | ||
3117 | ! if( ! grey ) | |
3118 | fields = ~fields; | |
3119 | ||
3120 | ! PtSetResource( menu->id, Pt_ARG_FLAGS, fields, | |
3121 | ! mask ); | |
3122 | } | |
3123 | ||
3124 | void | |
3125 | --- 2805,2815 ---- | |
3126 | mask = Pt_BLOCKED | Pt_GHOST; | |
3127 | } | |
3128 | ||
3129 | ! if (! grey) | |
3130 | fields = ~fields; | |
3131 | ||
3132 | ! PtSetResource(menu->id, Pt_ARG_FLAGS, fields, | |
3133 | ! mask); | |
3134 | } | |
3135 | ||
3136 | void | |
3137 | *************** | |
3138 | *** 2830,2837 **** | |
3139 | void | |
3140 | gui_mch_show_popupmenu(vimmenu_T *menu) | |
3141 | { | |
3142 | ! PtSetResource( menu->submenu_id, Pt_ARG_POS, &abs_mouse, 0 ); | |
3143 | ! PtRealizeWidget( menu->submenu_id ); | |
3144 | } | |
3145 | ||
3146 | void | |
3147 | --- 2830,2837 ---- | |
3148 | void | |
3149 | gui_mch_show_popupmenu(vimmenu_T *menu) | |
3150 | { | |
3151 | ! PtSetResource(menu->submenu_id, Pt_ARG_POS, &abs_mouse, 0); | |
3152 | ! PtRealizeWidget(menu->submenu_id); | |
3153 | } | |
3154 | ||
3155 | void | |
3156 | *************** | |
3157 | *** 2842,2855 **** | |
3158 | ||
3159 | #endif | |
3160 | ||
3161 | ! #if defined( FEAT_TOOLBAR ) || defined( PROTO ) | |
3162 | void | |
3163 | gui_mch_show_toolbar(int showit) | |
3164 | { | |
3165 | ! if( showit ) | |
3166 | ! PtRealizeWidget( gui.vimToolBar ); | |
3167 | else | |
3168 | ! PtUnrealizeWidget( gui.vimToolBar ); | |
3169 | } | |
3170 | #endif | |
3171 | ||
3172 | --- 2842,2855 ---- | |
3173 | ||
3174 | #endif | |
3175 | ||
3176 | ! #if defined(FEAT_TOOLBAR) || defined(PROTO) | |
3177 | void | |
3178 | gui_mch_show_toolbar(int showit) | |
3179 | { | |
3180 | ! if (showit) | |
3181 | ! PtRealizeWidget(gui.vimToolBar); | |
3182 | else | |
3183 | ! PtUnrealizeWidget(gui.vimToolBar); | |
3184 | } | |
3185 | #endif | |
3186 | ||
3187 | *************** | |
3188 | *** 2870,2903 **** | |
3189 | FontQueryInfo info; | |
3190 | int_u style; | |
3191 | ||
3192 | ! font_tag = alloc( MAX_FONT_TAG ); | |
3193 | ! if( font_tag != NULL ) | |
3194 | { | |
3195 | ! if( PfGenerateFontName( font_name, font_flags, font_size, | |
3196 | ! font_tag ) != NULL ) | |
3197 | { | |
3198 | /* Enforce some limits on the font used */ | |
3199 | style = PHFONT_INFO_FIXED; | |
3200 | ||
3201 | ! if( enforce & PF_STYLE_BOLD ) | |
3202 | style |= PHFONT_INFO_BOLD; | |
3203 | ! if( enforce & PF_STYLE_ANTIALIAS ) | |
3204 | style |= PHFONT_INFO_ALIAS; | |
3205 | ! if( enforce & PF_STYLE_ITALIC ) | |
3206 | style |= PHFONT_INFO_ITALIC; | |
3207 | ||
3208 | ! PfQueryFontInfo( font_tag, &info ); | |
3209 | ||
3210 | ! if( info.size == 0 ) | |
3211 | font_size = 0; | |
3212 | ||
3213 | /* Make sure font size matches, and that the font style | |
3214 | * at least has the bits we're checking for */ | |
3215 | ! if( font_size == info.size && | |
3216 | ! style == (info.style & style) ) | |
3217 | return (GuiFont)font_tag; | |
3218 | } | |
3219 | ! vim_free( font_tag ); | |
3220 | } | |
3221 | return NULL; | |
3222 | } | |
3223 | --- 2870,2903 ---- | |
3224 | FontQueryInfo info; | |
3225 | int_u style; | |
3226 | ||
3227 | ! font_tag = alloc(MAX_FONT_TAG); | |
3228 | ! if (font_tag != NULL) | |
3229 | { | |
3230 | ! if (PfGenerateFontName(font_name, font_flags, font_size, | |
3231 | ! font_tag) != NULL) | |
3232 | { | |
3233 | /* Enforce some limits on the font used */ | |
3234 | style = PHFONT_INFO_FIXED; | |
3235 | ||
3236 | ! if (enforce & PF_STYLE_BOLD) | |
3237 | style |= PHFONT_INFO_BOLD; | |
3238 | ! if (enforce & PF_STYLE_ANTIALIAS) | |
3239 | style |= PHFONT_INFO_ALIAS; | |
3240 | ! if (enforce & PF_STYLE_ITALIC) | |
3241 | style |= PHFONT_INFO_ITALIC; | |
3242 | ||
3243 | ! PfQueryFontInfo(font_tag, &info); | |
3244 | ||
3245 | ! if (info.size == 0) | |
3246 | font_size = 0; | |
3247 | ||
3248 | /* Make sure font size matches, and that the font style | |
3249 | * at least has the bits we're checking for */ | |
3250 | ! if (font_size == info.size && | |
3251 | ! style == (info.style & style)) | |
3252 | return (GuiFont)font_tag; | |
3253 | } | |
3254 | ! vim_free(font_tag); | |
3255 | } | |
3256 | return NULL; | |
3257 | } | |
3258 | *************** | |
3259 | *** 2919,2936 **** | |
3260 | char_u *vim_font, | |
3261 | char_u **font_name, | |
3262 | int_u *font_flags, | |
3263 | ! int_u *font_size ) | |
3264 | { | |
3265 | char_u *mark; | |
3266 | int_u name_len, size; | |
3267 | ||
3268 | ! mark = vim_strchr( vim_font, ':' ); | |
3269 | ! if( mark == NULL ) | |
3270 | ! name_len = STRLEN( vim_font ); | |
3271 | else | |
3272 | ! name_len = (int_u) ( mark - vim_font ); | |
3273 | ||
3274 | ! *font_name = vim_strnsave( vim_font, name_len ); | |
3275 | if (*font_name != NULL) | |
3276 | { | |
3277 | if (mark != NULL) | |
3278 | --- 2919,2936 ---- | |
3279 | char_u *vim_font, | |
3280 | char_u **font_name, | |
3281 | int_u *font_flags, | |
3282 | ! int_u *font_size) | |
3283 | { | |
3284 | char_u *mark; | |
3285 | int_u name_len, size; | |
3286 | ||
3287 | ! mark = vim_strchr(vim_font, ':'); | |
3288 | ! if (mark == NULL) | |
3289 | ! name_len = STRLEN(vim_font); | |
3290 | else | |
3291 | ! name_len = (int_u) (mark - vim_font); | |
3292 | ||
3293 | ! *font_name = vim_strnsave(vim_font, name_len); | |
3294 | if (*font_name != NULL) | |
3295 | { | |
3296 | if (mark != NULL) | |
3297 | *************** | |
3298 | *** 2944,2950 **** | |
3299 | case 'i': *font_flags |= PF_STYLE_ITALIC; break; | |
3300 | ||
3301 | case 's': | |
3302 | ! size = getdigits( &mark ); | |
3303 | /* Restrict the size to some vague limits */ | |
3304 | if (size < 1 || size > 100) | |
3305 | size = 8; | |
3306 | --- 2944,2950 ---- | |
3307 | case 'i': *font_flags |= PF_STYLE_ITALIC; break; | |
3308 | ||
3309 | case 's': | |
3310 | ! size = getdigits(&mark); | |
3311 | /* Restrict the size to some vague limits */ | |
3312 | if (size < 1 || size > 100) | |
3313 | size = 8; | |
3314 | *************** | |
3315 | *** 2979,3031 **** | |
3316 | vim_font_name = "PC Terminal"; | |
3317 | } | |
3318 | ||
3319 | ! if (STRCMP( vim_font_name, "*" ) == 0) | |
3320 | { | |
3321 | ! font_tag = PtFontSelection( gui.vimWindow, NULL, NULL, | |
3322 | ! "pcterm12", -1, PHFONT_FIXED, NULL ); | |
3323 | ||
3324 | if (font_tag == NULL) | |
3325 | return FAIL; | |
3326 | ||
3327 | ! gui_mch_free_font( gui.norm_font ); | |
3328 | gui.norm_font = font_tag; | |
3329 | ||
3330 | ! PfQueryFontInfo( font_tag, &info ); | |
3331 | ! font_name = vim_strsave( info.font ); | |
3332 | } | |
3333 | else | |
3334 | { | |
3335 | ! if (gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags, | |
3336 | ! &font_size ) == FALSE) | |
3337 | return FAIL; | |
3338 | ||
3339 | ! font_tag = gui_ph_get_font( font_name, font_flags, font_size, 0 ); | |
3340 | if (font_tag == NULL) | |
3341 | { | |
3342 | ! vim_free( font_name ); | |
3343 | return FAIL; | |
3344 | } | |
3345 | ||
3346 | ! gui_mch_free_font( gui.norm_font ); | |
3347 | gui.norm_font = font_tag; | |
3348 | } | |
3349 | ||
3350 | ! gui_mch_free_font( gui.bold_font ); | |
3351 | ! gui.bold_font = gui_ph_get_font( font_name, font_flags | PF_STYLE_BOLD, | |
3352 | ! font_size, PF_STYLE_BOLD ); | |
3353 | ! | |
3354 | ! gui_mch_free_font( gui.ital_font ); | |
3355 | ! gui.ital_font = gui_ph_get_font( font_name, font_flags | PF_STYLE_ITALIC, | |
3356 | ! font_size, PF_STYLE_ITALIC ); | |
3357 | ||
3358 | /* This extent was brought to you by the letter 'g' */ | |
3359 | ! PfExtentText( &extent, NULL, font_tag, "g", 1 ); | |
3360 | ||
3361 | gui.char_width = extent.lr.x - extent.ul.x + 1; | |
3362 | gui.char_height = (- extent.ul.y) + extent.lr.y + 1; | |
3363 | gui.char_ascent = - extent.ul.y; | |
3364 | ||
3365 | ! vim_free( font_name ); | |
3366 | return OK; | |
3367 | } | |
3368 | ||
3369 | --- 2979,3031 ---- | |
3370 | vim_font_name = "PC Terminal"; | |
3371 | } | |
3372 | ||
3373 | ! if (STRCMP(vim_font_name, "*") == 0) | |
3374 | { | |
3375 | ! font_tag = PtFontSelection(gui.vimWindow, NULL, NULL, | |
3376 | ! "pcterm12", -1, PHFONT_FIXED, NULL); | |
3377 | ||
3378 | if (font_tag == NULL) | |
3379 | return FAIL; | |
3380 | ||
3381 | ! gui_mch_free_font(gui.norm_font); | |
3382 | gui.norm_font = font_tag; | |
3383 | ||
3384 | ! PfQueryFontInfo(font_tag, &info); | |
3385 | ! font_name = vim_strsave(info.font); | |
3386 | } | |
3387 | else | |
3388 | { | |
3389 | ! if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags, | |
3390 | ! &font_size) == FALSE) | |
3391 | return FAIL; | |
3392 | ||
3393 | ! font_tag = gui_ph_get_font(font_name, font_flags, font_size, 0); | |
3394 | if (font_tag == NULL) | |
3395 | { | |
3396 | ! vim_free(font_name); | |
3397 | return FAIL; | |
3398 | } | |
3399 | ||
3400 | ! gui_mch_free_font(gui.norm_font); | |
3401 | gui.norm_font = font_tag; | |
3402 | } | |
3403 | ||
3404 | ! gui_mch_free_font(gui.bold_font); | |
3405 | ! gui.bold_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_BOLD, | |
3406 | ! font_size, PF_STYLE_BOLD); | |
3407 | ! | |
3408 | ! gui_mch_free_font(gui.ital_font); | |
3409 | ! gui.ital_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_ITALIC, | |
3410 | ! font_size, PF_STYLE_ITALIC); | |
3411 | ||
3412 | /* This extent was brought to you by the letter 'g' */ | |
3413 | ! PfExtentText(&extent, NULL, font_tag, "g", 1); | |
3414 | ||
3415 | gui.char_width = extent.lr.x - extent.ul.x + 1; | |
3416 | gui.char_height = (- extent.ul.y) + extent.lr.y + 1; | |
3417 | gui.char_ascent = - extent.ul.y; | |
3418 | ||
3419 | ! vim_free(font_name); | |
3420 | return OK; | |
3421 | } | |
3422 | ||
3423 | *************** | |
3424 | *** 3037,3043 **** | |
3425 | { | |
3426 | FontQueryInfo info; | |
3427 | ||
3428 | ! PfQueryFontInfo( gui.norm_font, &info ); | |
3429 | ||
3430 | gui.char_height = - info.ascender + info.descender + p_linespace; | |
3431 | gui.char_ascent = - info.ascender + p_linespace / 2; | |
3432 | --- 3037,3043 ---- | |
3433 | { | |
3434 | FontQueryInfo info; | |
3435 | ||
3436 | ! PfQueryFontInfo(gui.norm_font, &info); | |
3437 | ||
3438 | gui.char_height = - info.ascender + info.descender + p_linespace; | |
3439 | gui.char_ascent = - info.ascender + p_linespace / 2; | |
3440 | *************** | |
3441 | *** 3053,3070 **** | |
3442 | int_u font_size = 12; | |
3443 | int_u font_flags = 0; | |
3444 | ||
3445 | ! if (gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags, | |
3446 | ! &font_size ) != FALSE) | |
3447 | { | |
3448 | ! font_tag = gui_ph_get_font( font_name, font_flags, font_size, -1 ); | |
3449 | ! vim_free( font_name ); | |
3450 | ||
3451 | if (font_tag != NULL) | |
3452 | return (GuiFont)font_tag; | |
3453 | } | |
3454 | ||
3455 | if (report_error) | |
3456 | ! EMSG2(e_font, vim_font_name ); | |
3457 | ||
3458 | return FAIL; | |
3459 | } | |
3460 | --- 3053,3070 ---- | |
3461 | int_u font_size = 12; | |
3462 | int_u font_flags = 0; | |
3463 | ||
3464 | ! if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags, | |
3465 | ! &font_size) != FALSE) | |
3466 | { | |
3467 | ! font_tag = gui_ph_get_font(font_name, font_flags, font_size, -1); | |
3468 | ! vim_free(font_name); | |
3469 | ||
3470 | if (font_tag != NULL) | |
3471 | return (GuiFont)font_tag; | |
3472 | } | |
3473 | ||
3474 | if (report_error) | |
3475 | ! EMSG2(e_font, vim_font_name); | |
3476 | ||
3477 | return FAIL; | |
3478 | } | |
3479 | *************** | |
3480 | *** 3088,3099 **** | |
3481 | void | |
3482 | gui_mch_set_font(GuiFont font) | |
3483 | { | |
3484 | ! PgSetFont( font ); | |
3485 | } | |
3486 | ||
3487 | void | |
3488 | gui_mch_free_font(GuiFont font) | |
3489 | { | |
3490 | ! vim_free( font ); | |
3491 | } | |
3492 | ||
3493 | --- 3088,3099 ---- | |
3494 | void | |
3495 | gui_mch_set_font(GuiFont font) | |
3496 | { | |
3497 | ! PgSetFont(font); | |
3498 | } | |
3499 | ||
3500 | void | |
3501 | gui_mch_free_font(GuiFont font) | |
3502 | { | |
3503 | ! vim_free(font); | |
3504 | } | |
3505 | ||
3506 | *** ../vim-7.3.309/src/version.c 2011-09-14 15:41:54.000000000 +0200 | |
3507 | --- src/version.c 2011-09-14 16:01:50.000000000 +0200 | |
3508 | *************** | |
3509 | *** 711,712 **** | |
3510 | --- 711,714 ---- | |
3511 | { /* Add new patch number below this line */ | |
3512 | + /**/ | |
3513 | + 310, | |
3514 | /**/ | |
3515 | ||
3516 | -- | |
3517 | An operatingsystem is just a name you give to the rest of bloating | |
3518 | idiosyncratic machine-based-features you left out of your editor. | |
3519 | (author unknown) | |
3520 | ||
3521 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
3522 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
3523 | \\\ an exciting new programming language -- http://www.Zimbu.org /// | |
3524 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |