1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Code not following Vim style.
12 Solution: Fix the style. (Elias Diem)
13 Files: src/gui_photon.c
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
23 ! for(i = 0; special_keys[i].key_sym != 0; i++)
25 if (special_keys[i].key_sym == key->key_cap)
31 ! for (i = 0; special_keys[i].key_sym != 0; i++)
33 if (special_keys[i].key_sym == key->key_cap)
37 if (damage->next != NULL)
38 damage = damage->next;
40 ! while(damage != NULL)
45 if (damage->next != NULL)
46 damage = damage->next;
48 ! while (damage != NULL)
55 /* This is used for pulldown/popup menus and also toolbar buttons */
57 ! gui_ph_handle_menu( PtWidget_t *widget, void *data, PtCallbackInfo_t *info )
61 vimmenu_T *menu = (vimmenu_T *) data;
62 ! gui_menu_cb( menu );
68 /* This is used for pulldown/popup menus and also toolbar buttons */
70 ! gui_ph_handle_menu(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
74 vimmenu_T *menu = (vimmenu_T *) data;
81 gui_ph_handle_menu_unrealized(
84 ! PtCallbackInfo_t *info )
86 ! PtGiveFocus( gui.vimTextArea, NULL );
91 gui_ph_handle_menu_unrealized(
94 ! PtCallbackInfo_t *info)
96 ! PtGiveFocus(gui.vimTextArea, NULL);
102 gui_ph_handle_window_open(
105 ! PtCallbackInfo_t *info )
107 ! gui_set_shellsize( FALSE, TRUE, RESIZE_BOTH );
112 gui_ph_handle_window_open(
115 ! PtCallbackInfo_t *info)
117 ! gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
124 /* TODO: Set a clipping rect? */
126 ! gui_ph_draw_start( void )
131 ! PgSetRegion( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) );
132 ! PgClearClippingsCx( gc );
133 ! PgClearTranslationCx( gc );
135 ! PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset );
136 ! PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos( gui.vimTextArea, NULL ) );
138 ! PgSetTranslation( &gui_ph_raw_offset, Pg_RELATIVE );
142 ! gui_ph_draw_end( void )
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 );
149 #ifdef USE_PANEL_GROUP
151 ! gui_ph_find_buffer_item( char_u *name )
153 vimmenu_T *top_level = root_menu;
154 vimmenu_T *items = NULL;
156 ! while( top_level != NULL &&
157 ! ( STRCMP( top_level->dname, "Buffers" ) != 0 ) )
158 top_level = top_level->next;
160 ! if( top_level != NULL )
162 items = top_level->children;
164 ! while( items != NULL &&
165 ! ( STRCMP( items->dname, name ) != 0 ) )
172 ! gui_ph_pg_set_buffer_num( int_u buf_num )
178 ! if( gui.vimTextArea == NULL || buf_num == 0 )
182 ! ultoa( buf_num, &search[1], 10 );
183 ! STRCAT( search, ")" );
185 ! for( i = 0; i < num_panels; i++ )
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 )
192 ! PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX,
199 /* TODO: Set a clipping rect? */
201 ! gui_ph_draw_start(void)
206 ! PgSetRegion(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)));
207 ! PgClearClippingsCx(gc);
208 ! PgClearTranslationCx(gc);
210 ! PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset);
211 ! PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL));
213 ! PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE);
217 ! gui_ph_draw_end(void)
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);
224 #ifdef USE_PANEL_GROUP
226 ! gui_ph_find_buffer_item(char_u *name)
228 vimmenu_T *top_level = root_menu;
229 vimmenu_T *items = NULL;
231 ! while (top_level != NULL &&
232 ! (STRCMP(top_level->dname, "Buffers") != 0))
233 top_level = top_level->next;
235 ! if (top_level != NULL)
237 items = top_level->children;
239 ! while (items != NULL &&
240 ! (STRCMP(items->dname, name) != 0))
247 ! gui_ph_pg_set_buffer_num(int_u buf_num)
253 ! if (gui.vimTextArea == NULL || buf_num == 0)
257 ! ultoa(buf_num, &search[1], 10);
258 ! STRCAT(search, ")");
260 ! for (i = 0; i < num_panels; i++)
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)
267 ! PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX,
274 gui_ph_handle_pg_change(
277 ! PtCallbackInfo_t *info )
280 PtPanelGroupCallback_t *panel;
282 ! if( info->event != NULL )
284 panel = info->cbdata;
285 ! if( panel->new_panel != NULL )
287 ! menu = gui_ph_find_buffer_item( panel->new_panel );
289 ! gui_menu_cb( menu );
294 gui_ph_handle_pg_change(
297 ! PtCallbackInfo_t *info)
300 PtPanelGroupCallback_t *panel;
302 ! if (info->event != NULL)
304 panel = info->cbdata;
305 ! if (panel->new_panel != NULL)
307 ! menu = gui_ph_find_buffer_item(panel->new_panel);
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;
324 ! PtGetAbsPosition( gui.vimTextArea, &abs_raw_x, &abs_raw_y );
325 ! PtGetAbsPosition( gui.vimPanelGroup, &abs_panel_x, &abs_panel_y );
327 ! PtGetResource( gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0 );
328 ! PtGetResource( gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0 );
330 abs_raw_x -= abs_panel_x;
331 abs_raw_y -= abs_panel_y;
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;
342 ! PtGetAbsPosition(gui.vimTextArea, &abs_raw_x, &abs_raw_y);
343 ! PtGetAbsPosition(gui.vimPanelGroup, &abs_panel_x, &abs_panel_y);
345 ! PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0);
346 ! PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0);
348 abs_raw_x -= abs_panel_x;
349 abs_raw_y -= abs_panel_y;
353 /* Used for the tabs for PtPanelGroup */
355 ! gui_ph_is_buffer_item( vimmenu_T *menu, vimmenu_T *parent )
359 ! if( STRCMP( parent->dname, "Buffers" ) == 0 )
361 /* Look for '(' digits ')' */
362 ! mark = vim_strchr( menu->dname, '(' );
366 ! while( isdigit( *mark ) )
375 /* Used for the tabs for PtPanelGroup */
377 ! gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent)
381 ! if (STRCMP(parent->dname, "Buffers") == 0)
383 /* Look for '(' digits ')' */
384 ! mark = vim_strchr(menu->dname, '(');
388 ! while (isdigit(*mark))
400 ! gui_ph_pg_add_buffer(char *name )
402 char **new_titles = NULL;
404 ! new_titles = (char **) alloc( ( num_panels + 1 ) * sizeof( char ** ) );
405 ! if( new_titles != NULL )
407 ! if( num_panels > 0 )
408 ! memcpy( new_titles, panel_titles, num_panels * sizeof( char ** ) );
410 new_titles[ num_panels++ ] = name;
412 ! PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
415 ! vim_free( panel_titles );
416 panel_titles = new_titles;
421 ! gui_ph_pg_remove_buffer( char *name )
424 char **new_titles = NULL;
426 /* If there is only 1 panel, we just use the temporary place holder */
427 ! if( num_panels > 1 )
429 ! new_titles = (char **) alloc( ( num_panels - 1 ) * sizeof( char ** ) );
430 ! if( new_titles != NULL )
432 char **s = new_titles;
433 /* Copy all the titles except the one we're removing */
434 ! for( i = 0; i < num_panels; i++ )
436 ! if( STRCMP( panel_titles[ i ], name ) != 0 )
438 *s++ = panel_titles[ i ];
443 ! PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
446 ! vim_free( panel_titles );
447 panel_titles = new_titles;
453 ! PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title,
456 ! vim_free( panel_titles );
464 ! gui_ph_pg_add_buffer(char *name)
466 char **new_titles = NULL;
468 ! new_titles = (char **) alloc((num_panels + 1) * sizeof(char **));
469 ! if (new_titles != NULL)
471 ! if (num_panels > 0)
472 ! memcpy(new_titles, panel_titles, num_panels * sizeof(char **));
474 new_titles[ num_panels++ ] = name;
476 ! PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
479 ! vim_free(panel_titles);
480 panel_titles = new_titles;
485 ! gui_ph_pg_remove_buffer(char *name)
488 char **new_titles = NULL;
490 /* If there is only 1 panel, we just use the temporary place holder */
491 ! if (num_panels > 1)
493 ! new_titles = (char **) alloc((num_panels - 1) * sizeof(char **));
494 ! if (new_titles != NULL)
496 char **s = new_titles;
497 /* Copy all the titles except the one we're removing */
498 ! for (i = 0; i < num_panels; i++)
500 ! if (STRCMP(panel_titles[ i ], name) != 0)
502 *s++ = panel_titles[ i ];
507 ! PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
510 ! vim_free(panel_titles);
511 panel_titles = new_titles;
517 ! PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title,
520 ! vim_free(panel_titles);
526 gui_ph_handle_buffer_remove(
529 ! PtCallbackInfo_t *info )
535 menu = (vimmenu_T *) data;
536 ! gui_ph_pg_remove_buffer( menu->dname );
541 gui_ph_handle_buffer_remove(
544 ! PtCallbackInfo_t *info)
550 menu = (vimmenu_T *) data;
551 ! gui_ph_pg_remove_buffer(menu->dname);
560 ! gui_ph_pane_resize( PtWidget_t *widget, void *data, PtCallbackInfo_t *info )
562 ! if( PtWidgetIsRealized( widget ) )
564 is_ignore_draw = TRUE;
565 ! PtStartFlux( gui.vimContainer );
566 ! PtContainerHold( gui.vimContainer );
574 ! gui_ph_pane_resize(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
576 ! if (PtWidgetIsRealized(widget))
578 is_ignore_draw = TRUE;
579 ! PtStartFlux(gui.vimContainer);
580 ! PtContainerHold(gui.vimContainer);
589 ! gui_ph_encoding_changed( int new_encoding )
591 /* Default encoding is latin1 */
592 char *charset = "latin1";
597 ! gui_ph_encoding_changed(int new_encoding)
599 /* Default encoding is latin1 */
600 char *charset = "latin1";
606 ! for( i = 0; i < ARRAY_LENGTH( charsets ); i++ )
608 ! if( new_encoding == charsets[ i ].encoding )
609 charset = charsets[ i ].name;
612 ! charset_translate = PxTranslateSet( charset_translate, charset );
620 ! for (i = 0; i < ARRAY_LENGTH(charsets); i++)
622 ! if (new_encoding == charsets[ i ].encoding)
623 charset = charsets[ i ].name;
626 ! charset_translate = PxTranslateSet(charset_translate, charset);
649 PhDim_t window_size = {100, 100}; /* Arbitrary values */
650 PhPoint_t pos = {0, 0};
652 ! gui.event_buffer = (PhEvent_t *) alloc( EVENT_BUFFER_SIZE );
653 ! if( gui.event_buffer == NULL )
656 /* Get a translation so we can convert from ISO Latin-1 to UTF */
657 ! charset_translate = PxTranslateSet( NULL, "latin1" );
659 /* The +2 is for the 1 pixel dark line on each side */
660 gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2;
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 )
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 );
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 );
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 );
684 ! gui.vimPanelGroup = PtCreateWidget( PtPanelGroup, gui.vimWindow, n, args );
685 ! if( gui.vimPanelGroup == NULL )
688 ! PtAddCallback( gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING,
689 ! gui_ph_handle_pg_change, NULL );
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 );
698 ! gui.vimContainer = PtCreateWidget( PtPane, gui.vimWindow, n, args );
699 ! if( gui.vimContainer == NULL )
702 ! PtAddCallback( gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL );
705 /* Size for the text area is set in gui_mch_set_text_area_pos */
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 );
711 * Using focus render also causes the whole widget to be redrawn
712 * whenever it changes focus, which is very annoying :p
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 );
721 ! gui.vimTextArea = PtCreateWidget( PtRaw, Pt_DFLT_PARENT, n, args );
722 ! if( gui.vimTextArea == NULL)
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 );
738 * Now that the text area widget has been created, set up the colours,
740 PhDim_t window_size = {100, 100}; /* Arbitrary values */
741 PhPoint_t pos = {0, 0};
743 ! gui.event_buffer = (PhEvent_t *) alloc(EVENT_BUFFER_SIZE);
744 ! if (gui.event_buffer == NULL)
747 /* Get a translation so we can convert from ISO Latin-1 to UTF */
748 ! charset_translate = PxTranslateSet(NULL, "latin1");
750 /* The +2 is for the 1 pixel dark line on each side */
751 gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2;
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)
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);
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);
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);
775 ! gui.vimPanelGroup = PtCreateWidget(PtPanelGroup, gui.vimWindow, n, args);
776 ! if (gui.vimPanelGroup == NULL)
779 ! PtAddCallback(gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING,
780 ! gui_ph_handle_pg_change, NULL);
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);
789 ! gui.vimContainer = PtCreateWidget(PtPane, gui.vimWindow, n, args);
790 ! if (gui.vimContainer == NULL)
793 ! PtAddCallback(gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL);
796 /* Size for the text area is set in gui_mch_set_text_area_pos */
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);
802 * Using focus render also causes the whole widget to be redrawn
803 * whenever it changes focus, which is very annoying :p
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);
812 ! gui.vimTextArea = PtCreateWidget(PtRaw, Pt_DFLT_PARENT, n, args);
813 ! if (gui.vimTextArea == NULL)
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);
829 * Now that the text area widget has been created, set up the colours,
832 * Create the two timers, not as accurate as using the kernel timer
833 * functions, but good enough
835 ! gui_ph_timer_cursor = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL );
836 ! if( gui_ph_timer_cursor == NULL )
839 ! gui_ph_timer_timeout = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL );
840 ! if( gui_ph_timer_timeout == NULL )
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);
850 ! PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 );
851 ! PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT,
853 ! gui.vimToolBarGroup = PtCreateWidget( PtToolbarGroup, gui.vimWindow,
855 ! if( gui.vimToolBarGroup == NULL )
858 ! PtAddCallback( gui.vimToolBarGroup, Pt_CB_RESIZE,
859 ! gui_ph_handle_menu_resize, NULL );
863 ! PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 );
864 ! if( ! vim_strchr( p_go, GO_MENUS ) )
866 flags |= Pt_DELAY_REALIZE;
867 ! PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags );
869 ! gui.vimMenuBar = PtCreateWidget( PtMenuBar, gui.vimToolBarGroup, n, args );
870 ! if( gui.vimMenuBar == NULL )
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 );
882 flags = Pt_GETS_FOCUS;
883 ! if( ! vim_strchr( p_go, GO_TOOLBAR ) )
884 flags |= Pt_DELAY_REALIZE;
886 ! PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags );
888 ! gui.vimToolBar = PtCreateWidget( PtToolbar, gui.vimToolBarGroup, n, args );
889 ! if( gui.vimToolBar == NULL )
894 * Create the two timers, not as accurate as using the kernel timer
895 * functions, but good enough
897 ! gui_ph_timer_cursor = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL);
898 ! if (gui_ph_timer_cursor == NULL)
901 ! gui_ph_timer_timeout = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL);
902 ! if (gui_ph_timer_timeout == NULL)
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);
912 ! PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0);
913 ! PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT,
915 ! gui.vimToolBarGroup = PtCreateWidget(PtToolbarGroup, gui.vimWindow,
917 ! if (gui.vimToolBarGroup == NULL)
920 ! PtAddCallback(gui.vimToolBarGroup, Pt_CB_RESIZE,
921 ! gui_ph_handle_menu_resize, NULL);
925 ! PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0);
926 ! if (! vim_strchr(p_go, GO_MENUS))
928 flags |= Pt_DELAY_REALIZE;
929 ! PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags);
931 ! gui.vimMenuBar = PtCreateWidget(PtMenuBar, gui.vimToolBarGroup, n, args);
932 ! if (gui.vimMenuBar == NULL)
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);
944 flags = Pt_GETS_FOCUS;
945 ! if (! vim_strchr(p_go, GO_TOOLBAR))
946 flags |= Pt_DELAY_REALIZE;
948 ! PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags);
950 ! gui.vimToolBar = PtCreateWidget(PtToolbar, gui.vimToolBarGroup, n, args);
951 ! if (gui.vimToolBar == NULL)
957 if (gui_win_x != -1 && gui_win_y != -1)
958 gui_mch_set_winpos(gui_win_x, gui_win_y);
960 ! return (PtRealizeWidget( gui.vimWindow ) == 0) ? OK : FAIL;
966 ! PtDestroyWidget( gui.vimWindow );
968 ! PxTranslateSet( charset_translate, NULL );
970 ! vim_free( gui.event_buffer );
972 #ifdef USE_PANEL_GROUPS
973 ! vim_free( panel_titles );
978 if (gui_win_x != -1 && gui_win_y != -1)
979 gui_mch_set_winpos(gui_win_x, gui_win_y);
981 ! return (PtRealizeWidget(gui.vimWindow) == 0) ? OK : FAIL;
987 ! PtDestroyWidget(gui.vimWindow);
989 ! PxTranslateSet(charset_translate, NULL);
991 ! vim_free(gui.event_buffer);
993 #ifdef USE_PANEL_GROUPS
994 ! vim_free(panel_titles);
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. */
1003 ! exit_gui_mch_update( void *data )
1005 *(int *)data = FALSE;
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. */
1011 ! exit_gui_mch_update(void *data)
1013 *(int *)data = FALSE;
1020 ! PtAppAddWorkProc( NULL, exit_gui_mch_update, &working );
1021 ! while( ( working == TRUE ) && !vim_is_input_buf_full())
1029 ! PtAppAddWorkProc(NULL, exit_gui_mch_update, &working);
1030 ! while ((working == TRUE) && !vim_is_input_buf_full())
1040 ! PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, wtime, 0 );
1045 ! if( input_available() )
1047 ! PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0 );
1050 ! else if( is_timeout == TRUE )
1055 ! #if defined( FEAT_BROWSE ) || defined( PROTO )
1057 * Put up a file requester.
1058 * Returns the selected name in allocated memory, or NULL for Cancel.
1064 ! PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, wtime, 0);
1069 ! if (input_available())
1071 ! PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0);
1074 ! else if (is_timeout == TRUE)
1079 ! #if defined(FEAT_BROWSE) || defined(PROTO)
1081 * Put up a file requester.
1082 * Returns the selected name in allocated memory, or NULL for Cancel.
1085 char_u *open_text = NULL;
1088 ! memset( &file, 0, sizeof( file ) );
1090 ! default_path = alloc( MAXPATHL + 1 + NAME_MAX + 1 );
1091 ! if( default_path != NULL )
1093 ! if( saving == TRUE )
1095 /* Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway */
1096 flags |= Pt_FSR_NO_FCHECK;
1098 char_u *open_text = NULL;
1101 ! memset(&file, 0, sizeof(file));
1103 ! default_path = alloc(MAXPATHL + 1 + NAME_MAX + 1);
1104 ! if (default_path != NULL)
1106 ! if (saving == TRUE)
1108 /* Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway */
1109 flags |= Pt_FSR_NO_FCHECK;
1114 /* combine the directory and filename into a single path */
1115 ! if( initdir == NULL || *initdir == NUL )
1117 ! mch_dirname( default_path, MAXPATHL );
1118 initdir = default_path;
1122 ! STRCPY( default_path, initdir );
1123 initdir = default_path;
1126 ! if( default_name != NULL )
1128 ! if( default_path[ STRLEN( default_path ) - 1 ] != '/' )
1129 ! STRCAT( default_path, "/" );
1131 ! STRCAT( default_path, default_name );
1134 /* TODO: add a filter? */
1138 /* combine the directory and filename into a single path */
1139 ! if (initdir == NULL || *initdir == NUL)
1141 ! mch_dirname(default_path, MAXPATHL);
1142 initdir = default_path;
1146 ! STRCPY(default_path, initdir);
1147 initdir = default_path;
1150 ! if (default_name != NULL)
1152 ! if (default_path[ STRLEN(default_path) - 1 ] != '/')
1153 ! STRCAT(default_path, "/");
1155 ! STRCAT(default_path, default_name);
1158 /* TODO: add a filter? */
1166 ! vim_free( default_path );
1168 ! if( file.ret == Pt_FSDIALOG_BTN1 )
1169 return vim_strsave(file.path);
1175 ! #if defined( FEAT_GUI_DIALOG ) || defined( PROTO )
1176 static PtWidget_t *gui_ph_dialog_text = NULL;
1179 ! gui_ph_dialog_close( int button, void *data )
1181 PtModalCtrl_t *modal_ctrl = data;
1182 char_u *dialog_text, *vim_text;
1184 ! if( gui_ph_dialog_text != NULL )
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 );
1191 ! PtModalUnblock( modal_ctrl, (void *) button );
1197 ! gui_ph_dialog_text_enter( PtWidget_t *widget, void *data, PtCallbackInfo_t *info )
1199 ! if( info->reason_subtype == Pt_EDIT_ACTIVATE )
1200 ! gui_ph_dialog_close( 1, data );
1205 ! gui_ph_dialog_esc( PtWidget_t *widget, void *data, PtCallbackInfo_t *info )
1209 ! key = PhGetData( info->event );
1210 ! if( ( key->key_flags & Pk_KF_Cap_Valid ) && ( key->key_cap == Pk_Escape ) )
1212 ! gui_ph_dialog_close( 0, data );
1222 ! vim_free(default_path);
1224 ! if (file.ret == Pt_FSDIALOG_BTN1)
1225 return vim_strsave(file.path);
1231 ! #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
1232 static PtWidget_t *gui_ph_dialog_text = NULL;
1235 ! gui_ph_dialog_close(int button, void *data)
1237 PtModalCtrl_t *modal_ctrl = data;
1238 char_u *dialog_text, *vim_text;
1240 ! if (gui_ph_dialog_text != NULL)
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);
1247 ! PtModalUnblock(modal_ctrl, (void *) button);
1253 ! gui_ph_dialog_text_enter(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
1255 ! if (info->reason_subtype == Pt_EDIT_ACTIVATE)
1256 ! gui_ph_dialog_close(1, data);
1261 ! gui_ph_dialog_esc(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
1265 ! key = PhGetData(info->event);
1266 ! if ((key->key_flags & Pk_KF_Cap_Valid) && (key->key_cap == Pk_Escape))
1268 ! gui_ph_dialog_close(0, data);
1275 button_count = len = i = 0;
1277 ! if( buttons == NULL || *buttons == NUL )
1280 /* There is one less separator than buttons, so bump up the button count */
1283 /* Count string length and number of seperators */
1284 ! for( str = buttons; *str; str++ )
1287 ! if( *str == DLG_BUTTON_SEP )
1291 ! if ( title == NULL )
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 )
1298 ! STRCPY( buttons_copy, buttons );
1301 * Convert DLG_BUTTON_SEP into NUL's and fill in
1302 * button_array with the pointer to each NUL terminated string
1305 ! for( i = 0; i < button_count; i++ )
1307 button_array[ i ] = str;
1308 ! for( ; *str; str++ )
1310 ! if( *str == DLG_BUTTON_SEP )
1316 button_count = len = i = 0;
1318 ! if (buttons == NULL || *buttons == NUL)
1321 /* There is one less separator than buttons, so bump up the button count */
1324 /* Count string length and number of seperators */
1325 ! for (str = buttons; *str; str++)
1328 ! if (*str == DLG_BUTTON_SEP)
1332 ! if (title == NULL)
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)
1339 ! STRCPY(buttons_copy, buttons);
1342 * Convert DLG_BUTTON_SEP into NUL's and fill in
1343 * button_array with the pointer to each NUL terminated string
1346 ! for (i = 0; i < button_count; i++)
1348 button_array[ i ] = str;
1349 ! for (; *str; str++)
1351 ! if (*str == DLG_BUTTON_SEP)
1359 button_count, (const char **) button_array, NULL,
1360 ! default_button, 0, Pt_MODAL );
1362 /* Writing the dialog ourselves lets us add extra features, like
1363 * trapping the escape key and returning 0 to vim */
1367 button_count, (const char **) button_array, NULL,
1368 ! default_button, 0, Pt_MODAL);
1370 /* Writing the dialog ourselves lets us add extra features, like
1371 * trapping the escape key and returning 0 to vim */
1374 PtModalCtrl_t modal_ctrl;
1377 ! memset( &di, 0, sizeof( di ) );
1378 ! memset( &modal_ctrl, 0, sizeof( modal_ctrl ) );
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 );
1391 ! PtSetArg( &args[n++], Pt_ARG_TEXT_STRING, message, 0 );
1392 ! PtCreateWidget( PtLabel, pane, n, args );
1394 ! if( textfield != NULL )
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 );
1405 di.parent = gui.vimWindow;
1407 PtModalCtrl_t modal_ctrl;
1410 ! memset(&di, 0, sizeof(di));
1411 ! memset(&modal_ctrl, 0, sizeof(modal_ctrl));
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);
1424 ! PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, message, 0);
1425 ! PtCreateWidget(PtLabel, pane, n, args);
1427 ! if (textfield != NULL)
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);
1438 di.parent = gui.vimWindow;
1441 di.callback = gui_ph_dialog_close;
1442 di.data = &modal_ctrl;
1444 ! dialog = PtCreateDialog( &di );
1445 ! PtAddFilterCallback( dialog, Ph_EV_KEY,
1446 ! gui_ph_dialog_esc, &modal_ctrl );
1448 ! if( gui_ph_dialog_text != NULL )
1449 ! PtGiveFocus( gui_ph_dialog_text, NULL );
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 );
1456 ! PtDestroyWidget( dialog );
1457 gui_ph_dialog_text = NULL;
1462 ! vim_free( button_array );
1463 ! vim_free( buttons_copy );
1465 return dialog_result;
1468 di.callback = gui_ph_dialog_close;
1469 di.data = &modal_ctrl;
1471 ! dialog = PtCreateDialog(&di);
1472 ! PtAddFilterCallback(dialog, Ph_EV_KEY,
1473 ! gui_ph_dialog_esc, &modal_ctrl);
1475 ! if (gui_ph_dialog_text != NULL)
1476 ! PtGiveFocus(gui_ph_dialog_text, NULL);
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);
1483 ! PtDestroyWidget(dialog);
1484 gui_ph_dialog_text = NULL;
1489 ! vim_free(button_array);
1490 ! vim_free(buttons_copy);
1492 return dialog_result;
1499 ! pos = PtWidgetPos( gui.vimWindow, NULL );
1507 ! pos = PtWidgetPos(gui.vimWindow, NULL);
1514 PhPoint_t pos = { x, y };
1516 ! PtSetResource( gui.vimWindow, Pt_ARG_POS, &pos, 0 );
1522 PhPoint_t pos = { x, y };
1524 ! PtSetResource(gui.vimWindow, Pt_ARG_POS, &pos, 0);
1530 window_size.h += pg_margin_top + pg_margin_bottom;
1533 ! PtSetResource( gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0 );
1534 ! PtSetResource( gui.vimWindow, Pt_ARG_DIM, &window_size, 0 );
1536 ! if( ! PtWidgetIsRealized( gui.vimWindow ) )
1537 gui_ph_resize_container();
1541 window_size.h += pg_margin_top + pg_margin_bottom;
1544 ! PtSetResource(gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0);
1545 ! PtSetResource(gui.vimWindow, Pt_ARG_DIM, &window_size, 0);
1547 ! if (! PtWidgetIsRealized(gui.vimWindow))
1548 gui_ph_resize_container();
1556 ! PhWindowQueryVisible( Ph_QUERY_WORKSPACE, 0,
1557 ! PhInputGroup( NULL ), &console );
1559 *screen_w = console.lr.x - console.ul.x + 1;
1560 *screen_h = console.lr.y - console.ul.y + 1;
1565 ! PhWindowQueryVisible(Ph_QUERY_WORKSPACE, 0,
1566 ! PhInputGroup(NULL), &console);
1568 *screen_w = console.lr.x - console.ul.x + 1;
1569 *screen_h = console.lr.y - console.ul.y + 1;
1573 PhWindowEvent_t event;
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 );
1582 #if defined(FEAT_EVAL) || defined(PROTO)
1585 PhWindowEvent_t event;
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);
1594 #if defined(FEAT_EVAL) || defined(PROTO)
1598 PhWindowEvent_t event;
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 );
1610 PhWindowEvent_t event;
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);
1622 gui_mch_settitle(char_u *title, char_u *icon)
1624 #ifdef USE_PANEL_GROUP
1625 ! gui_ph_pg_set_buffer_num( curwin->w_buffer->b_fnum );
1627 ! PtSetResource( gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0 );
1628 /* Not sure what to do with the icon text, set balloon text somehow? */
1632 gui_mch_settitle(char_u *title, char_u *icon)
1634 #ifdef USE_PANEL_GROUP
1635 ! gui_ph_pg_set_buffer_num(curwin->w_buffer->b_fnum);
1637 ! PtSetResource(gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0);
1638 /* Not sure what to do with the icon text, set balloon text somehow? */
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 );
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);
1667 PhArea_t area = {{ x, y }, { w, h }};
1669 ! PtSetResource( sb->id, Pt_ARG_AREA, &area, 0 );
1675 PhArea_t area = {{ x, y }, { w, h }};
1677 ! PtSetResource(sb->id, Pt_ARG_AREA, &area, 0);
1684 * Also, don't let the scrollbar get focus
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);
1690 /* Don't need this anchoring for the scrollbars */
1691 ! if( orient == SBAR_HORIZ )
1693 anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM |
1694 Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT;
1697 * Also, don't let the scrollbar get focus
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);
1703 /* Don't need this anchoring for the scrollbars */
1704 ! if (orient == SBAR_HORIZ)
1706 anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM |
1707 Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT;
1712 anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP;
1713 ! if( sb->wp != NULL )
1715 ! if( sb == &sb->wp->w_scrollbars[ SBAR_LEFT ] )
1716 anchor_flags |= Pt_LEFT_ANCHORED_LEFT;
1718 anchor_flags |= Pt_RIGHT_ANCHORED_RIGHT;
1721 ! PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, anchor_flags, Pt_IS_ANCHORED );
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 );
1728 ! sb->id = PtCreateWidget( PtScrollbar, gui.vimContainer, n, args );
1731 ! PtAddCallback( sb->id, Pt_CB_SCROLLBAR_MOVE, gui_ph_handle_scrollbar, sb );
1735 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
1738 ! PtRealizeWidget( sb->id );
1740 ! PtUnrealizeWidget( sb->id );
1744 gui_mch_destroy_scrollbar(scrollbar_T *sb)
1746 ! PtDestroyWidget( sb->id );
1753 anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP;
1754 ! if (sb->wp != NULL)
1756 ! if (sb == &sb->wp->w_scrollbars[ SBAR_LEFT ])
1757 anchor_flags |= Pt_LEFT_ANCHORED_LEFT;
1759 anchor_flags |= Pt_RIGHT_ANCHORED_RIGHT;
1762 ! PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, anchor_flags, Pt_IS_ANCHORED);
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);
1769 ! sb->id = PtCreateWidget(PtScrollbar, gui.vimContainer, n, args);
1772 ! PtAddCallback(sb->id, Pt_CB_SCROLLBAR_MOVE, gui_ph_handle_scrollbar, sb);
1776 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
1779 ! PtRealizeWidget(sb->id);
1781 ! PtUnrealizeWidget(sb->id);
1785 gui_mch_destroy_scrollbar(scrollbar_T *sb)
1787 ! PtDestroyWidget(sb->id);
1795 if (shape == MSHAPE_HIDE || gui.pointer_hidden)
1796 ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
1800 if (shape >= MSHAPE_NUMBERED)
1804 if (shape == MSHAPE_HIDE || gui.pointer_hidden)
1805 ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
1809 if (shape >= MSHAPE_NUMBERED)
1813 id = mshape_ids[shape];
1815 ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE, id, 0 );
1817 if (shape != MSHAPE_HIDE)
1821 id = mshape_ids[shape];
1823 ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, id, 0);
1825 if (shape != MSHAPE_HIDE)
1830 gui_mch_mousehide(int hide)
1832 ! if( gui.pointer_hidden != hide )
1834 gui.pointer_hidden = hide;
1835 #ifdef FEAT_MOUSESHAPE
1837 ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
1838 ! Ph_CURSOR_NONE, 0 );
1840 ! mch_set_mouse_shape( last_shape );
1842 ! PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
1843 ! ( hide == MOUSE_SHOW ) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE,
1850 gui_mch_mousehide(int hide)
1852 ! if (gui.pointer_hidden != hide)
1854 gui.pointer_hidden = hide;
1855 #ifdef FEAT_MOUSESHAPE
1857 ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
1858 ! Ph_CURSOR_NONE, 0);
1860 ! mch_set_mouse_shape(last_shape);
1862 ! PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
1863 ! (hide == MOUSE_SHOW) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE,
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 );
1876 *x = info.pos.x - ix;
1877 *y = info.pos.y - iy;
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);
1885 *x = info.pos.x - ix;
1886 *y = info.pos.y - iy;
1892 ! PtGetAbsPosition( gui.vimTextArea, &abs_x, &abs_y );
1893 /* Add the border offset? */
1894 ! PhMoveCursorAbs( PhInputGroup( NULL ), abs_x + x, abs_y + y );
1897 /****************************************************************************/
1902 ! PtGetAbsPosition(gui.vimTextArea, &abs_x, &abs_y);
1903 /* Add the border offset? */
1904 ! PhMoveCursorAbs(PhInputGroup(NULL), abs_x + x, abs_y + y);
1907 /****************************************************************************/
1910 color_diff = gui_get_lightness(gui_ph_mouse_color)
1911 - gui_get_lightness(gui.back_pixel);
1913 ! if( abs( color_diff ) < 64 )
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;
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 );
1929 ! PtSetResource( gui.vimTextArea, Pt_ARG_FILL_COLOR, gui.back_pixel, 0 );
1934 color_diff = gui_get_lightness(gui_ph_mouse_color)
1935 - gui_get_lightness(gui.back_pixel);
1937 ! if (abs(color_diff) < 64)
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;
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);
1953 ! PtSetResource(gui.vimTextArea, Pt_ARG_FILL_COLOR, gui.back_pixel, 0);
1961 /* is name #rrggbb format? */
1962 ! if( name[0] == '#' && STRLEN( name ) == 7 )
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 )
1969 return RGB(r, g, b);
1972 ! for( i = 0; i < ARRAY_LENGTH( table ); i++ )
1974 ! if( STRICMP( name, table[i].name ) == 0 )
1975 return table[i].colour;
1981 /* is name #rrggbb format? */
1982 ! if (name[0] == '#' && STRLEN(name) == 7)
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)
1989 return RGB(r, g, b);
1992 ! for (i = 0; i < ARRAY_LENGTH(table); i++)
1994 ! if (STRICMP(name, table[i].name) == 0)
1995 return table[i].colour;
2001 gui_mch_set_fg_color(guicolor_T color)
2003 ! PgSetTextColor( color );
2007 gui_mch_set_bg_color(guicolor_T color)
2009 ! PgSetFillColor( color );
2015 gui_mch_set_fg_color(guicolor_T color)
2017 ! PgSetTextColor(color);
2021 gui_mch_set_bg_color(guicolor_T color)
2023 ! PgSetFillColor(color);
2032 ! rect.ul.x = FILL_X( col );
2033 ! rect.ul.y = FILL_Y( row );
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;
2044 ! PgSetDrawMode( Pg_DrawModeDSTINVERT );
2045 ! PgDrawRect( &rect, Pg_DRAW_FILL );
2046 ! PgSetDrawMode( Pg_DrawModeSRCCOPY );
2054 ! rect.ul.x = FILL_X(col);
2055 ! rect.ul.y = FILL_Y(row);
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;
2066 ! PgSetDrawMode(Pg_DrawModeDSTINVERT);
2067 ! PgDrawRect(&rect, Pg_DRAW_FILL);
2068 ! PgSetDrawMode(Pg_DrawModeSRCCOPY);
2074 gui_mch_clear_block(int row1, int col1, int row2, int col2)
2077 ! { FILL_X( col1 ), FILL_Y( row1 ) },
2078 ! { FILL_X( col2 + 1 ) - 1, FILL_Y( row2 + 1 ) - 1}
2082 ! gui_mch_set_bg_color( gui.back_pixel );
2083 ! PgDrawRect( &block, Pg_DRAW_FILL );
2088 gui_mch_clear_block(int row1, int col1, int row2, int col2)
2091 ! { FILL_X(col1), FILL_Y(row1) },
2092 ! { FILL_X(col2 + 1) - 1, FILL_Y(row2 + 1) - 1}
2096 ! gui_mch_set_bg_color(gui.back_pixel);
2097 ! PgDrawRect(&block, Pg_DRAW_FILL);
2103 Rows * gui.char_height + gui.border_width - 1 }
2106 ! if( is_ignore_draw == TRUE )
2110 ! gui_mch_set_bg_color( gui.back_pixel );
2111 ! PgDrawRect( &text_rect, Pg_DRAW_FILL );
2116 Rows * gui.char_height + gui.border_width - 1 }
2119 ! if (is_ignore_draw == TRUE)
2123 ! gui_mch_set_bg_color(gui.back_pixel);
2124 ! PgDrawRect(&text_rect, Pg_DRAW_FILL);
2133 ! rect.ul.x = FILL_X( gui.scroll_region_left );
2134 ! rect.ul.y = FILL_Y( row + num_lines );
2136 ! rect.lr.x = FILL_X( gui.scroll_region_right + 1 ) - 1;
2137 ! rect.lr.y = FILL_Y( gui.scroll_region_bot + 1) - 1;
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 );
2144 delta.y = -num_lines * gui.char_height;
2148 ! PhBlit( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ), &rect, &delta );
2151 gui.scroll_region_bot - num_lines + 1,
2152 gui.scroll_region_left,
2153 gui.scroll_region_bot,
2154 ! gui.scroll_region_right );
2162 ! rect.ul.x = FILL_X(gui.scroll_region_left);
2163 ! rect.ul.y = FILL_Y(row + num_lines);
2165 ! rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1;
2166 ! rect.lr.y = FILL_Y(gui.scroll_region_bot + 1) - 1;
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);
2173 delta.y = -num_lines * gui.char_height;
2177 ! PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)), &rect, &delta);
2180 gui.scroll_region_bot - num_lines + 1,
2181 gui.scroll_region_left,
2182 gui.scroll_region_bot,
2183 ! gui.scroll_region_right);
2192 ! rect.ul.x = FILL_X( gui.scroll_region_left );
2193 ! rect.ul.y = FILL_Y( row );
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;
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 );
2203 delta.y = num_lines * gui.char_height;
2207 ! PhBlit( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) , &rect, &delta );
2209 ! gui_clear_block( row, gui.scroll_region_left,
2210 ! row + num_lines - 1, gui.scroll_region_right );
2218 ! rect.ul.x = FILL_X(gui.scroll_region_left);
2219 ! rect.ul.y = FILL_Y(row);
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;
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);
2229 delta.y = num_lines * gui.char_height;
2233 ! PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)) , &rect, &delta);
2235 ! gui_clear_block(row, gui.scroll_region_left,
2236 ! row + num_lines - 1, gui.scroll_region_right);
2242 static char *utf8_buffer = NULL;
2243 static int utf8_len = 0;
2245 ! PhPoint_t pos = { TEXT_X( col ), TEXT_Y( row ) };
2248 ! if( is_ignore_draw == TRUE )
2253 ! if( !( flags & DRAW_TRANSP ) )
2256 ! FILL_X( col ), FILL_Y( row ),
2257 ! FILL_X( col + len ) - 1, FILL_Y( row + 1 ) - 1,
2261 ! if( flags & DRAW_UNDERL )
2262 ! PgSetUnderline( gui.norm_pixel, Pg_TRANSPARENT, 0 );
2264 ! if( charset_translate != NULL
2270 int src_taken, dst_made;
2272 /* Use a static buffer to avoid large amounts of de/allocations */
2273 ! if( utf8_len < len )
2275 ! utf8_buffer = realloc( utf8_buffer, len * MB_LEN_MAX );
2280 static char *utf8_buffer = NULL;
2281 static int utf8_len = 0;
2283 ! PhPoint_t pos = { TEXT_X(col), TEXT_Y(row) };
2286 ! if (is_ignore_draw == TRUE)
2291 ! if (!(flags & DRAW_TRANSP))
2294 ! FILL_X(col), FILL_Y(row),
2295 ! FILL_X(col + len) - 1, FILL_Y(row + 1) - 1,
2299 ! if (flags & DRAW_UNDERL)
2300 ! PgSetUnderline(gui.norm_pixel, Pg_TRANSPARENT, 0);
2302 ! if (charset_translate != NULL
2308 int src_taken, dst_made;
2310 /* Use a static buffer to avoid large amounts of de/allocations */
2311 ! if (utf8_len < len)
2313 ! utf8_buffer = realloc(utf8_buffer, len * MB_LEN_MAX);
2327 ! PgDrawText( s, len, &pos, 0 );
2329 ! if( flags & DRAW_BOLD )
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... */
2340 ! PgSetUserClip( &rect );
2341 ! PgDrawText( s, len, &pos, 0 );
2342 ! PgSetUserClip( NULL );
2344 ! rect.lr.y -= ( p_linespace + 1 ) / 2;
2345 /* XXX: DrawTextArea doesn't work with phditto */
2346 ! PgDrawTextArea( s, len, &rect, Pg_TEXT_BOTTOM );
2350 ! if( flags & DRAW_UNDERL )
2351 ! PgSetUnderline( Pg_TRANSPARENT, Pg_TRANSPARENT, 0 );
2364 ! PgDrawText(s, len, &pos, 0);
2366 ! if (flags & DRAW_BOLD)
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... */
2377 ! PgSetUserClip(&rect);
2378 ! PgDrawText(s, len, &pos, 0);
2379 ! PgSetUserClip(NULL);
2381 ! rect.lr.y -= (p_linespace + 1) / 2;
2382 /* XXX: DrawTextArea doesn't work with phditto */
2383 ! PgDrawTextArea(s, len, &rect, Pg_TEXT_BOTTOM);
2387 ! if (flags & DRAW_UNDERL)
2388 ! PgSetUnderline(Pg_TRANSPARENT, Pg_TRANSPARENT, 0);
2395 /* FIXME: Double width characters */
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;
2403 ! PgSetStrokeColor( color );
2404 ! PgDrawRect( &r, Pg_DRAW_STROKE );
2410 /* FIXME: Double width characters */
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;
2418 ! PgSetStrokeColor(color);
2419 ! PgDrawRect(&r, Pg_DRAW_STROKE);
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;
2434 ! gui_mch_set_bg_color( color );
2435 ! PgDrawRect( &r, Pg_DRAW_FILL );
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;
2449 ! gui_mch_set_bg_color(color);
2450 ! PgDrawRect(&r, Pg_DRAW_FILL);
2456 gui_mch_start_blink(void)
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)
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);
2467 gui_mch_start_blink(void)
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)
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);
2480 gui_mch_stop_blink(void)
2482 ! PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0 );
2484 ! if( blink_state == BLINK_OFF )
2485 gui_update_cursor(TRUE, FALSE);
2487 blink_state = BLINK_NONE;
2490 gui_mch_stop_blink(void)
2492 ! PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0);
2494 ! if (blink_state == BLINK_OFF)
2495 gui_update_cursor(TRUE, FALSE);
2497 blink_state = BLINK_NONE;
2501 gui_mch_flash(int msec)
2503 ! PgSetFillXORColor( Pg_BLACK, Pg_WHITE );
2504 ! PgSetDrawMode( Pg_DRAWMODE_XOR );
2505 gui_mch_clear_all();
2508 ! ui_delay( (long) msec, TRUE );
2510 gui_mch_clear_all();
2511 ! PgSetDrawMode( Pg_DRAWMODE_OPAQUE );
2517 gui_mch_flash(int msec)
2519 ! PgSetFillXORColor(Pg_BLACK, Pg_WHITE);
2520 ! PgSetDrawMode(Pg_DRAWMODE_XOR);
2521 gui_mch_clear_all();
2524 ! ui_delay((long) msec, TRUE);
2526 gui_mch_clear_all();
2527 ! PgSetDrawMode(Pg_DRAWMODE_OPAQUE);
2534 PhArea_t area = {{x, y}, {w, h}};
2536 ! PtSetResource( gui.vimTextArea, Pt_ARG_AREA, &area, 0 );
2542 PhArea_t area = {{x, y}, {w, h}};
2544 ! PtSetResource(gui.vimTextArea, Pt_ARG_AREA, &area, 0);
2553 ! gui_ph_toolbar_load_icon( char_u *iconfile )
2555 static PhImage_t external_icon;
2556 PhImage_t *temp_phi = NULL;
2558 ! temp_phi = PxLoadImage( iconfile, NULL );
2559 ! if( temp_phi != NULL )
2561 /* The label widget will free the image/palette/etc. for us when
2563 temp_phi->flags |= Ph_RELEASE_IMAGE_ALL;
2564 ! memcpy( &external_icon, temp_phi, sizeof( external_icon ) );
2567 temp_phi = &external_icon;
2573 ! gui_ph_toolbar_load_icon(char_u *iconfile)
2575 static PhImage_t external_icon;
2576 PhImage_t *temp_phi = NULL;
2578 ! temp_phi = PxLoadImage(iconfile, NULL);
2579 ! if (temp_phi != NULL)
2581 /* The label widget will free the image/palette/etc. for us when
2583 temp_phi->flags |= Ph_RELEASE_IMAGE_ALL;
2584 ! memcpy(&external_icon, temp_phi, sizeof(external_icon));
2587 temp_phi = &external_icon;
2591 * PhImage_t are copied, and the original PhImage_t aren't needed anymore).
2594 ! gui_ph_toolbar_find_icon( vimmenu_T *menu )
2596 char_u full_pathname[ MAXPATHL + 1 ];
2597 PhImage_t *icon = NULL;
2599 ! if( menu->icon_builtin == FALSE )
2601 ! if( menu->iconfile != NULL )
2602 /* TODO: use gui_find_iconfile() */
2603 ! icon = gui_ph_toolbar_load_icon( menu->iconfile );
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 );
2611 ! if( icon != NULL )
2615 ! if( menu->iconidx >= 0 &&
2616 ! ( menu->iconidx < ARRAY_LENGTH( gui_ph_toolbar_images ) ) )
2618 return gui_ph_toolbar_images[menu->iconidx];
2621 * PhImage_t are copied, and the original PhImage_t aren't needed anymore).
2624 ! gui_ph_toolbar_find_icon(vimmenu_T *menu)
2626 char_u full_pathname[ MAXPATHL + 1 ];
2627 PhImage_t *icon = NULL;
2629 ! if (menu->icon_builtin == FALSE)
2631 ! if (menu->iconfile != NULL)
2632 /* TODO: use gui_find_iconfile() */
2633 ! icon = gui_ph_toolbar_load_icon(menu->iconfile);
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);
2645 ! if (menu->iconidx >= 0 &&
2646 ! (menu->iconidx < ARRAY_LENGTH(gui_ph_toolbar_images)))
2648 return gui_ph_toolbar_images[menu->iconidx];
2655 ! #if defined( FEAT_MENU ) || defined( PROTO )
2657 gui_mch_enable_menu(int flag)
2660 ! PtRealizeWidget( gui.vimMenuBar );
2662 ! PtUnrealizeWidget( gui.vimMenuBar );
2670 ! #if defined(FEAT_MENU) || defined(PROTO)
2672 gui_mch_enable_menu(int flag)
2675 ! PtRealizeWidget(gui.vimMenuBar);
2677 ! PtUnrealizeWidget(gui.vimMenuBar);
2684 /* Change the position of a menu button in the parent */
2686 ! gui_ph_position_menu( PtWidget_t *widget, int priority )
2688 PtWidget_t *traverse;
2691 ! traverse = PtWidgetChildBack( PtWidgetParent( widget ) );
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 )
2698 ! PtGetResource( traverse, Pt_ARG_POINTER, &menu, 0 );
2700 ! if( menu != NULL &&
2701 priority < menu->priority &&
2702 ! widget != traverse )
2704 /* Insert the widget before the current traverse widget */
2705 ! PtWidgetInsert( widget, traverse, 1 );
2709 ! traverse = PtWidgetBrotherInFront( traverse );
2715 /* Change the position of a menu button in the parent */
2717 ! gui_ph_position_menu(PtWidget_t *widget, int priority)
2719 PtWidget_t *traverse;
2722 ! traverse = PtWidgetChildBack(PtWidgetParent(widget));
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)
2729 ! PtGetResource(traverse, Pt_ARG_POINTER, &menu, 0);
2731 ! if (menu != NULL &&
2732 priority < menu->priority &&
2733 ! widget != traverse)
2735 /* Insert the widget before the current traverse widget */
2736 ! PtWidgetInsert(widget, traverse, 1);
2740 ! traverse = PtWidgetBrotherInFront(traverse);
2747 menu->submenu_id = menu->id = NULL;
2749 ! if( menu_is_menubar( menu->name ) )
2752 ! accel_key = vim_strchr( menu->name, '&' );
2753 ! if( accel_key != NULL )
2755 mnemonic_str[0] = accel_key[1];
2756 mnemonic_str[1] = NUL;
2759 menu->submenu_id = menu->id = NULL;
2761 ! if (menu_is_menubar(menu->name))
2764 ! accel_key = vim_strchr(menu->name, '&');
2765 ! if (accel_key != NULL)
2767 mnemonic_str[0] = accel_key[1];
2768 mnemonic_str[1] = NUL;
2772 /* Create the menu button */
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 );
2780 ! if( parent != NULL )
2781 ! PtSetArg( &args[ n++ ], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0 );
2783 ! menu->id = PtCreateWidget( PtMenuButton,
2784 (parent == NULL) ? gui.vimMenuBar : parent->submenu_id,
2787 ! PtAddCallback( menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu );
2789 /* Create the actual menu */
2791 ! if( parent != NULL )
2792 ! PtSetArg( &args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD );
2794 ! menu->submenu_id = PtCreateWidget( PtMenu, menu->id, n, args );
2796 ! if( parent == NULL )
2798 ! PtAddCallback( menu->submenu_id, Pt_CB_UNREALIZED,
2799 ! gui_ph_handle_menu_unrealized, menu );
2801 ! if( menu->mnemonic != 0 )
2803 ! PtAddHotkeyHandler( gui.vimWindow, tolower( menu->mnemonic ),
2804 ! Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu );
2808 ! gui_ph_position_menu( menu->id, menu->priority );
2810 /* Redraw menubar here instead of gui_mch_draw_menubar */
2811 ! if( gui.menu_is_active )
2812 ! PtRealizeWidget( menu->id );
2814 ! else if( menu_is_popup( menu->name ) )
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 );
2824 /* Create the menu button */
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);
2832 ! if (parent != NULL)
2833 ! PtSetArg(&args[ n++ ], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0);
2835 ! menu->id = PtCreateWidget(PtMenuButton,
2836 (parent == NULL) ? gui.vimMenuBar : parent->submenu_id,
2839 ! PtAddCallback(menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu);
2841 /* Create the actual menu */
2843 ! if (parent != NULL)
2844 ! PtSetArg(&args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD);
2846 ! menu->submenu_id = PtCreateWidget(PtMenu, menu->id, n, args);
2848 ! if (parent == NULL)
2850 ! PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED,
2851 ! gui_ph_handle_menu_unrealized, menu);
2853 ! if (menu->mnemonic != 0)
2855 ! PtAddHotkeyHandler(gui.vimWindow, tolower(menu->mnemonic),
2856 ! Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu);
2860 ! gui_ph_position_menu(menu->id, menu->priority);
2862 /* Redraw menubar here instead of gui_mch_draw_menubar */
2863 ! if (gui.menu_is_active)
2864 ! PtRealizeWidget(menu->id);
2866 ! else if (menu_is_popup(menu->name))
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);
2879 ! PtSetArg( &args[ n++ ], Pt_ARG_POINTER, menu, 0 );
2882 ! if( menu_is_toolbar( parent->name ) )
2884 ! if( menu_is_separator( menu->name ) )
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 );
2896 ! if( strstr( (const char *) p_toolbar, "text" ) != NULL )
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 );
2903 ! if( ( strstr( (const char *) p_toolbar, "icons" ) != NULL ) &&
2904 ! ( gui_ph_toolbar_images != NULL ) )
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 );
2911 ! if( strstr( (const char *) p_toolbar, "tooltips" ) != NULL )
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 );
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 );
2925 ! PtAddCallback( menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu );
2927 /* Update toolbar if it's open */
2928 ! if( PtWidgetIsRealized( gui.vimToolBar ) )
2929 ! PtRealizeWidget( menu->id );
2933 ! if( menu_is_separator( menu->name ) )
2935 ! menu->id = PtCreateWidget( PtSeparator, parent->submenu_id, n, args );
2939 ! accel_key = vim_strchr( menu->name, '&' );
2940 ! if( accel_key != NULL )
2942 mnemonic_str[0] = accel_key[1];
2943 mnemonic_str[1] = NUL;
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,
2951 ! PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0 );
2953 ! menu->id = PtCreateWidget( PtMenuButton, parent->submenu_id, n, args );
2955 ! PtAddCallback( menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu );
2957 #ifdef USE_PANEL_GROUP
2958 ! if( gui_ph_is_buffer_item( menu, parent ) == TRUE )
2960 ! PtAddCallback( menu->id, Pt_CB_DESTROYED,
2961 ! gui_ph_handle_buffer_remove, menu );
2962 ! gui_ph_pg_add_buffer( menu->dname );
2967 ! gui_ph_position_menu( menu->id, menu->priority );
2971 gui_mch_destroy_menu(vimmenu_T *menu)
2973 ! if( menu->submenu_id != NULL )
2974 ! PtDestroyWidget( menu->submenu_id );
2975 ! if( menu->id != NULL )
2976 ! PtDestroyWidget( menu->id );
2978 menu->submenu_id = NULL;
2984 ! PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0);
2987 ! if (menu_is_toolbar(parent->name))
2989 ! if (menu_is_separator(menu->name))
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);
3001 ! if (strstr((const char *) p_toolbar, "text") != NULL)
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);
3008 ! if ((strstr((const char *) p_toolbar, "icons") != NULL) &&
3009 ! (gui_ph_toolbar_images != NULL))
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);
3016 ! if (strstr((const char *) p_toolbar, "tooltips") != NULL)
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);
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);
3030 ! PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu);
3032 /* Update toolbar if it's open */
3033 ! if (PtWidgetIsRealized(gui.vimToolBar))
3034 ! PtRealizeWidget(menu->id);
3038 ! if (menu_is_separator(menu->name))
3040 ! menu->id = PtCreateWidget(PtSeparator, parent->submenu_id, n, args);
3044 ! accel_key = vim_strchr(menu->name, '&');
3045 ! if (accel_key != NULL)
3047 mnemonic_str[0] = accel_key[1];
3048 mnemonic_str[1] = NUL;
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,
3056 ! PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0);
3058 ! menu->id = PtCreateWidget(PtMenuButton, parent->submenu_id, n, args);
3060 ! PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu);
3062 #ifdef USE_PANEL_GROUP
3063 ! if (gui_ph_is_buffer_item(menu, parent) == TRUE)
3065 ! PtAddCallback(menu->id, Pt_CB_DESTROYED,
3066 ! gui_ph_handle_buffer_remove, menu);
3067 ! gui_ph_pg_add_buffer(menu->dname);
3072 ! gui_ph_position_menu(menu->id, menu->priority);
3076 gui_mch_destroy_menu(vimmenu_T *menu)
3078 ! if (menu->submenu_id != NULL)
3079 ! PtDestroyWidget(menu->submenu_id);
3080 ! if (menu->id != NULL)
3081 ! PtDestroyWidget(menu->id);
3083 menu->submenu_id = NULL;
3088 long flags, mask, fields;
3090 ! if( menu->id == NULL )
3093 ! flags = PtWidgetFlags( menu->id );
3094 ! if( PtWidgetIsClass( menu->id, PtMenuButton ) &&
3095 ! PtWidgetIsClass( PtWidgetParent( menu->id ), PtMenu ) )
3098 mask = Pt_SELECTABLE | Pt_HIGHLIGHTED;
3101 long flags, mask, fields;
3103 ! if (menu->id == NULL)
3106 ! flags = PtWidgetFlags(menu->id);
3107 ! if (PtWidgetIsClass(menu->id, PtMenuButton) &&
3108 ! PtWidgetIsClass(PtWidgetParent(menu->id), PtMenu))
3111 mask = Pt_SELECTABLE | Pt_HIGHLIGHTED;
3114 mask = Pt_BLOCKED | Pt_GHOST;
3120 ! PtSetResource( menu->id, Pt_ARG_FLAGS, fields,
3126 mask = Pt_BLOCKED | Pt_GHOST;
3132 ! PtSetResource(menu->id, Pt_ARG_FLAGS, fields,
3140 gui_mch_show_popupmenu(vimmenu_T *menu)
3142 ! PtSetResource( menu->submenu_id, Pt_ARG_POS, &abs_mouse, 0 );
3143 ! PtRealizeWidget( menu->submenu_id );
3149 gui_mch_show_popupmenu(vimmenu_T *menu)
3151 ! PtSetResource(menu->submenu_id, Pt_ARG_POS, &abs_mouse, 0);
3152 ! PtRealizeWidget(menu->submenu_id);
3161 ! #if defined( FEAT_TOOLBAR ) || defined( PROTO )
3163 gui_mch_show_toolbar(int showit)
3166 ! PtRealizeWidget( gui.vimToolBar );
3168 ! PtUnrealizeWidget( gui.vimToolBar );
3176 ! #if defined(FEAT_TOOLBAR) || defined(PROTO)
3178 gui_mch_show_toolbar(int showit)
3181 ! PtRealizeWidget(gui.vimToolBar);
3183 ! PtUnrealizeWidget(gui.vimToolBar);
3192 ! font_tag = alloc( MAX_FONT_TAG );
3193 ! if( font_tag != NULL )
3195 ! if( PfGenerateFontName( font_name, font_flags, font_size,
3196 ! font_tag ) != NULL )
3198 /* Enforce some limits on the font used */
3199 style = PHFONT_INFO_FIXED;
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;
3208 ! PfQueryFontInfo( font_tag, &info );
3210 ! if( info.size == 0 )
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;
3219 ! vim_free( font_tag );
3227 ! font_tag = alloc(MAX_FONT_TAG);
3228 ! if (font_tag != NULL)
3230 ! if (PfGenerateFontName(font_name, font_flags, font_size,
3231 ! font_tag) != NULL)
3233 /* Enforce some limits on the font used */
3234 style = PHFONT_INFO_FIXED;
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;
3243 ! PfQueryFontInfo(font_tag, &info);
3245 ! if (info.size == 0)
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;
3254 ! vim_free(font_tag);
3263 ! int_u *font_size )
3266 int_u name_len, size;
3268 ! mark = vim_strchr( vim_font, ':' );
3269 ! if( mark == NULL )
3270 ! name_len = STRLEN( vim_font );
3272 ! name_len = (int_u) ( mark - vim_font );
3274 ! *font_name = vim_strnsave( vim_font, name_len );
3275 if (*font_name != NULL)
3285 int_u name_len, size;
3287 ! mark = vim_strchr(vim_font, ':');
3289 ! name_len = STRLEN(vim_font);
3291 ! name_len = (int_u) (mark - vim_font);
3293 ! *font_name = vim_strnsave(vim_font, name_len);
3294 if (*font_name != NULL)
3299 case 'i': *font_flags |= PF_STYLE_ITALIC; break;
3302 ! size = getdigits( &mark );
3303 /* Restrict the size to some vague limits */
3304 if (size < 1 || size > 100)
3307 case 'i': *font_flags |= PF_STYLE_ITALIC; break;
3310 ! size = getdigits(&mark);
3311 /* Restrict the size to some vague limits */
3312 if (size < 1 || size > 100)
3316 vim_font_name = "PC Terminal";
3319 ! if (STRCMP( vim_font_name, "*" ) == 0)
3321 ! font_tag = PtFontSelection( gui.vimWindow, NULL, NULL,
3322 ! "pcterm12", -1, PHFONT_FIXED, NULL );
3324 if (font_tag == NULL)
3327 ! gui_mch_free_font( gui.norm_font );
3328 gui.norm_font = font_tag;
3330 ! PfQueryFontInfo( font_tag, &info );
3331 ! font_name = vim_strsave( info.font );
3335 ! if (gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags,
3336 ! &font_size ) == FALSE)
3339 ! font_tag = gui_ph_get_font( font_name, font_flags, font_size, 0 );
3340 if (font_tag == NULL)
3342 ! vim_free( font_name );
3346 ! gui_mch_free_font( gui.norm_font );
3347 gui.norm_font = font_tag;
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 );
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 );
3358 /* This extent was brought to you by the letter 'g' */
3359 ! PfExtentText( &extent, NULL, font_tag, "g", 1 );
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;
3365 ! vim_free( font_name );
3370 vim_font_name = "PC Terminal";
3373 ! if (STRCMP(vim_font_name, "*") == 0)
3375 ! font_tag = PtFontSelection(gui.vimWindow, NULL, NULL,
3376 ! "pcterm12", -1, PHFONT_FIXED, NULL);
3378 if (font_tag == NULL)
3381 ! gui_mch_free_font(gui.norm_font);
3382 gui.norm_font = font_tag;
3384 ! PfQueryFontInfo(font_tag, &info);
3385 ! font_name = vim_strsave(info.font);
3389 ! if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags,
3390 ! &font_size) == FALSE)
3393 ! font_tag = gui_ph_get_font(font_name, font_flags, font_size, 0);
3394 if (font_tag == NULL)
3396 ! vim_free(font_name);
3400 ! gui_mch_free_font(gui.norm_font);
3401 gui.norm_font = font_tag;
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);
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);
3412 /* This extent was brought to you by the letter 'g' */
3413 ! PfExtentText(&extent, NULL, font_tag, "g", 1);
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;
3419 ! vim_free(font_name);
3428 ! PfQueryFontInfo( gui.norm_font, &info );
3430 gui.char_height = - info.ascender + info.descender + p_linespace;
3431 gui.char_ascent = - info.ascender + p_linespace / 2;
3436 ! PfQueryFontInfo(gui.norm_font, &info);
3438 gui.char_height = - info.ascender + info.descender + p_linespace;
3439 gui.char_ascent = - info.ascender + p_linespace / 2;
3442 int_u font_size = 12;
3443 int_u font_flags = 0;
3445 ! if (gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags,
3446 ! &font_size ) != FALSE)
3448 ! font_tag = gui_ph_get_font( font_name, font_flags, font_size, -1 );
3449 ! vim_free( font_name );
3451 if (font_tag != NULL)
3452 return (GuiFont)font_tag;
3456 ! EMSG2(e_font, vim_font_name );
3461 int_u font_size = 12;
3462 int_u font_flags = 0;
3464 ! if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags,
3465 ! &font_size) != FALSE)
3467 ! font_tag = gui_ph_get_font(font_name, font_flags, font_size, -1);
3468 ! vim_free(font_name);
3470 if (font_tag != NULL)
3471 return (GuiFont)font_tag;
3475 ! EMSG2(e_font, vim_font_name);
3482 gui_mch_set_font(GuiFont font)
3484 ! PgSetFont( font );
3488 gui_mch_free_font(GuiFont font)
3495 gui_mch_set_font(GuiFont font)
3501 gui_mch_free_font(GuiFont font)
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
3511 { /* Add new patch number below this line */
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.
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 ///