Karsten Hopp 2f825d
To: vim_dev@googlegroups.com
Karsten Hopp 2f825d
Subject: Patch 7.3.310
Karsten Hopp 2f825d
Fcc: outbox
Karsten Hopp 2f825d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 2f825d
Mime-Version: 1.0
Karsten Hopp 2f825d
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 2f825d
Content-Transfer-Encoding: 8bit
Karsten Hopp 2f825d
------------
Karsten Hopp 2f825d
Karsten Hopp 2f825d
Patch 7.3.310
Karsten Hopp 2f825d
Problem:    Code not following Vim style.
Karsten Hopp 2f825d
Solution:   Fix the style. (Elias Diem)
Karsten Hopp 2f825d
Files:	    src/gui_photon.c
Karsten Hopp 2f825d
Karsten Hopp 2f825d
Karsten Hopp 2f825d
*** ../vim-7.3.309/src/gui_photon.c	2011-09-07 19:08:57.000000000 +0200
Karsten Hopp 2f825d
--- src/gui_photon.c	2011-09-14 16:01:55.000000000 +0200
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 477,483 ****
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	for(i = 0; special_keys[i].key_sym != 0; i++)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    if (special_keys[i].key_sym == key->key_cap)
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
--- 477,483 ----
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	for (i = 0; special_keys[i].key_sym != 0; i++)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    if (special_keys[i].key_sym == key->key_cap)
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 758,764 ****
Karsten Hopp 2f825d
      if (damage->next != NULL)
Karsten Hopp 2f825d
  	damage = damage->next;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     while(damage != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	r = &damage->rect;
Karsten Hopp 2f825d
  	gui_redraw(
Karsten Hopp 2f825d
--- 758,764 ----
Karsten Hopp 2f825d
      if (damage->next != NULL)
Karsten Hopp 2f825d
  	damage = damage->next;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     while (damage != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	r = &damage->rect;
Karsten Hopp 2f825d
  	gui_redraw(
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 798,809 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /* This is used for pulldown/popup menus and also toolbar buttons */
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_handle_menu( PtWidget_t *widget, void *data, PtCallbackInfo_t *info )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if( data != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	vimmenu_T *menu = (vimmenu_T *) data;
Karsten Hopp 2f825d
! 	gui_menu_cb( menu );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
--- 798,809 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /* This is used for pulldown/popup menus and also toolbar buttons */
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_handle_menu(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if (data != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	vimmenu_T *menu = (vimmenu_T *) data;
Karsten Hopp 2f825d
! 	gui_menu_cb(menu);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 813,821 ****
Karsten Hopp 2f825d
  gui_ph_handle_menu_unrealized(
Karsten Hopp 2f825d
  	PtWidget_t *widget,
Karsten Hopp 2f825d
  	void *data,
Karsten Hopp 2f825d
! 	PtCallbackInfo_t *info )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtGiveFocus( gui.vimTextArea, NULL );
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 813,821 ----
Karsten Hopp 2f825d
  gui_ph_handle_menu_unrealized(
Karsten Hopp 2f825d
  	PtWidget_t *widget,
Karsten Hopp 2f825d
  	void *data,
Karsten Hopp 2f825d
! 	PtCallbackInfo_t *info)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtGiveFocus(gui.vimTextArea, NULL);
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 823,831 ****
Karsten Hopp 2f825d
  gui_ph_handle_window_open(
Karsten Hopp 2f825d
  	PtWidget_t *widget,
Karsten Hopp 2f825d
  	void *data,
Karsten Hopp 2f825d
! 	PtCallbackInfo_t *info )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     gui_set_shellsize( FALSE, TRUE, RESIZE_BOTH );
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 823,831 ----
Karsten Hopp 2f825d
  gui_ph_handle_window_open(
Karsten Hopp 2f825d
  	PtWidget_t *widget,
Karsten Hopp 2f825d
  	void *data,
Karsten Hopp 2f825d
! 	PtCallbackInfo_t *info)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 836,909 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /* TODO: Set a clipping rect? */
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_draw_start( void )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhGC_t *gc;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gc = PgGetGC();
Karsten Hopp 2f825d
!     PgSetRegion( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) );
Karsten Hopp 2f825d
!     PgClearClippingsCx( gc );
Karsten Hopp 2f825d
!     PgClearTranslationCx( gc );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset );
Karsten Hopp 2f825d
!     PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos( gui.vimTextArea, NULL ) );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PgSetTranslation( &gui_ph_raw_offset, Pg_RELATIVE );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_draw_end( void )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      gui_ph_raw_offset.x = -gui_ph_raw_offset.x;
Karsten Hopp 2f825d
      gui_ph_raw_offset.y = -gui_ph_raw_offset.y;
Karsten Hopp 2f825d
!     PgSetTranslation( &gui_ph_raw_offset, Pg_RELATIVE );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
      static vimmenu_T *
Karsten Hopp 2f825d
! gui_ph_find_buffer_item( char_u *name )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      vimmenu_T *top_level = root_menu;
Karsten Hopp 2f825d
      vimmenu_T *items = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     while( top_level != NULL &&
Karsten Hopp 2f825d
! 	    ( STRCMP( top_level->dname, "Buffers" ) != 0 ) )
Karsten Hopp 2f825d
  	top_level = top_level->next;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( top_level != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	items = top_level->children;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	while( items != NULL &&
Karsten Hopp 2f825d
! 		( STRCMP( items->dname, name ) != 0 ) )
Karsten Hopp 2f825d
  	    items = items->next;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return items;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_pg_set_buffer_num( int_u buf_num )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      int i;
Karsten Hopp 2f825d
      char search[16];
Karsten Hopp 2f825d
      char *mark;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( gui.vimTextArea == NULL || buf_num == 0 )
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      search[0] = '(';
Karsten Hopp 2f825d
!     ultoa( buf_num, &search[1], 10 );
Karsten Hopp 2f825d
!     STRCAT( search, ")" );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     for( i = 0; i < num_panels; i++ )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	/* find the last "(" in the panel title and see if the buffer
Karsten Hopp 2f825d
  	 * number in the title matches the one we're looking for */
Karsten Hopp 2f825d
! 	mark = STRRCHR( panel_titles[ i ], '(' );
Karsten Hopp 2f825d
! 	if( mark != NULL && STRCMP( mark, search ) == 0 )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX,
Karsten Hopp 2f825d
! 		    i, 0 );
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
--- 836,909 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /* TODO: Set a clipping rect? */
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_draw_start(void)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhGC_t *gc;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gc = PgGetGC();
Karsten Hopp 2f825d
!     PgSetRegion(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)));
Karsten Hopp 2f825d
!     PgClearClippingsCx(gc);
Karsten Hopp 2f825d
!     PgClearTranslationCx(gc);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset);
Karsten Hopp 2f825d
!     PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL));
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_draw_end(void)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      gui_ph_raw_offset.x = -gui_ph_raw_offset.x;
Karsten Hopp 2f825d
      gui_ph_raw_offset.y = -gui_ph_raw_offset.y;
Karsten Hopp 2f825d
!     PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
      static vimmenu_T *
Karsten Hopp 2f825d
! gui_ph_find_buffer_item(char_u *name)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      vimmenu_T *top_level = root_menu;
Karsten Hopp 2f825d
      vimmenu_T *items = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     while (top_level != NULL &&
Karsten Hopp 2f825d
! 	    (STRCMP(top_level->dname, "Buffers") != 0))
Karsten Hopp 2f825d
  	top_level = top_level->next;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (top_level != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	items = top_level->children;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	while (items != NULL &&
Karsten Hopp 2f825d
! 		(STRCMP(items->dname, name) != 0))
Karsten Hopp 2f825d
  	    items = items->next;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return items;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_pg_set_buffer_num(int_u buf_num)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      int i;
Karsten Hopp 2f825d
      char search[16];
Karsten Hopp 2f825d
      char *mark;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (gui.vimTextArea == NULL || buf_num == 0)
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      search[0] = '(';
Karsten Hopp 2f825d
!     ultoa(buf_num, &search[1], 10);
Karsten Hopp 2f825d
!     STRCAT(search, ")");
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     for (i = 0; i < num_panels; i++)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	/* find the last "(" in the panel title and see if the buffer
Karsten Hopp 2f825d
  	 * number in the title matches the one we're looking for */
Karsten Hopp 2f825d
! 	mark = STRRCHR(panel_titles[ i ], '(');
Karsten Hopp 2f825d
! 	if (mark != NULL && STRCMP(mark, search) == 0)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX,
Karsten Hopp 2f825d
! 		    i, 0);
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 912,930 ****
Karsten Hopp 2f825d
  gui_ph_handle_pg_change(
Karsten Hopp 2f825d
  	PtWidget_t *widget,
Karsten Hopp 2f825d
  	void *data,
Karsten Hopp 2f825d
! 	PtCallbackInfo_t *info )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      vimmenu_T *menu;
Karsten Hopp 2f825d
      PtPanelGroupCallback_t *panel;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( info->event != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	panel = info->cbdata;
Karsten Hopp 2f825d
! 	if( panel->new_panel != NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    menu = gui_ph_find_buffer_item( panel->new_panel );
Karsten Hopp 2f825d
! 	    if( menu )
Karsten Hopp 2f825d
! 		gui_menu_cb( menu );
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
--- 912,930 ----
Karsten Hopp 2f825d
  gui_ph_handle_pg_change(
Karsten Hopp 2f825d
  	PtWidget_t *widget,
Karsten Hopp 2f825d
  	void *data,
Karsten Hopp 2f825d
! 	PtCallbackInfo_t *info)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      vimmenu_T *menu;
Karsten Hopp 2f825d
      PtPanelGroupCallback_t *panel;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (info->event != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	panel = info->cbdata;
Karsten Hopp 2f825d
! 	if (panel->new_panel != NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    menu = gui_ph_find_buffer_item(panel->new_panel);
Karsten Hopp 2f825d
! 	    if (menu)
Karsten Hopp 2f825d
! 		gui_menu_cb(menu);
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 935,951 ****
Karsten Hopp 2f825d
  	short *top,
Karsten Hopp 2f825d
  	short *bottom,
Karsten Hopp 2f825d
  	short *left,
Karsten Hopp 2f825d
! 	short *right )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      unsigned short abs_raw_x, abs_raw_y, abs_panel_x, abs_panel_y;
Karsten Hopp 2f825d
      const unsigned short *margin_top, *margin_bottom;
Karsten Hopp 2f825d
      const unsigned short *margin_left, *margin_right;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtGetAbsPosition( gui.vimTextArea, &abs_raw_x, &abs_raw_y );
Karsten Hopp 2f825d
!     PtGetAbsPosition( gui.vimPanelGroup, &abs_panel_x, &abs_panel_y );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtGetResource( gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0 );
Karsten Hopp 2f825d
!     PtGetResource( gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      abs_raw_x -= abs_panel_x;
Karsten Hopp 2f825d
      abs_raw_y -= abs_panel_y;
Karsten Hopp 2f825d
--- 935,951 ----
Karsten Hopp 2f825d
  	short *top,
Karsten Hopp 2f825d
  	short *bottom,
Karsten Hopp 2f825d
  	short *left,
Karsten Hopp 2f825d
! 	short *right)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      unsigned short abs_raw_x, abs_raw_y, abs_panel_x, abs_panel_y;
Karsten Hopp 2f825d
      const unsigned short *margin_top, *margin_bottom;
Karsten Hopp 2f825d
      const unsigned short *margin_left, *margin_right;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtGetAbsPosition(gui.vimTextArea, &abs_raw_x, &abs_raw_y);
Karsten Hopp 2f825d
!     PtGetAbsPosition(gui.vimPanelGroup, &abs_panel_x, &abs_panel_y);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0);
Karsten Hopp 2f825d
!     PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      abs_raw_x -= abs_panel_x;
Karsten Hopp 2f825d
      abs_raw_y -= abs_panel_y;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 959,979 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /* Used for the tabs for PtPanelGroup */
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_is_buffer_item( vimmenu_T *menu, vimmenu_T *parent )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      char *mark;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( STRCMP( parent->dname, "Buffers" ) == 0 )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	/* Look for '(' digits ')' */
Karsten Hopp 2f825d
! 	mark = vim_strchr( menu->dname, '(' );
Karsten Hopp 2f825d
! 	if( mark != NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    mark++;
Karsten Hopp 2f825d
! 	    while( isdigit( *mark ) )
Karsten Hopp 2f825d
  		mark++;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if( *mark == ')' )
Karsten Hopp 2f825d
  		return TRUE;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
--- 959,979 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /* Used for the tabs for PtPanelGroup */
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      char *mark;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (STRCMP(parent->dname, "Buffers") == 0)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	/* Look for '(' digits ')' */
Karsten Hopp 2f825d
! 	mark = vim_strchr(menu->dname, '(');
Karsten Hopp 2f825d
! 	if (mark != NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    mark++;
Karsten Hopp 2f825d
! 	    while (isdigit(*mark))
Karsten Hopp 2f825d
  		mark++;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if (*mark == ')')
Karsten Hopp 2f825d
  		return TRUE;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 981,1043 ****
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_pg_add_buffer(char *name )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      char **new_titles = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     new_titles = (char **) alloc( ( num_panels + 1 ) * sizeof( char ** ) );
Karsten Hopp 2f825d
!     if( new_titles != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if( num_panels > 0 )
Karsten Hopp 2f825d
! 	    memcpy( new_titles, panel_titles, num_panels * sizeof( char ** ) );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	new_titles[ num_panels++ ] = name;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
Karsten Hopp 2f825d
! 		num_panels );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	vim_free( panel_titles );
Karsten Hopp 2f825d
  	panel_titles = new_titles;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_pg_remove_buffer( char *name )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      int i;
Karsten Hopp 2f825d
      char **new_titles = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* If there is only 1 panel, we just use the temporary place holder */
Karsten Hopp 2f825d
!     if( num_panels > 1 )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	new_titles = (char **) alloc( ( num_panels - 1 ) * sizeof( char ** ) );
Karsten Hopp 2f825d
! 	if( new_titles != NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    char **s = new_titles;
Karsten Hopp 2f825d
  	    /* Copy all the titles except the one we're removing */
Karsten Hopp 2f825d
! 	    for( i = 0; i < num_panels; i++ )
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		if( STRCMP( panel_titles[ i ], name ) != 0 )
Karsten Hopp 2f825d
  		{
Karsten Hopp 2f825d
  		    *s++ = panel_titles[ i ];
Karsten Hopp 2f825d
  		}
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
  	    num_panels--;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
Karsten Hopp 2f825d
! 		    num_panels );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    vim_free( panel_titles );
Karsten Hopp 2f825d
  	    panel_titles = new_titles;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	num_panels--;
Karsten Hopp 2f825d
! 	PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title,
Karsten Hopp 2f825d
! 		1 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	vim_free( panel_titles );
Karsten Hopp 2f825d
  	panel_titles = NULL;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
--- 981,1043 ----
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_pg_add_buffer(char *name)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      char **new_titles = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     new_titles = (char **) alloc((num_panels + 1) * sizeof(char **));
Karsten Hopp 2f825d
!     if (new_titles != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (num_panels > 0)
Karsten Hopp 2f825d
! 	    memcpy(new_titles, panel_titles, num_panels * sizeof(char **));
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	new_titles[ num_panels++ ] = name;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
Karsten Hopp 2f825d
! 		num_panels);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	vim_free(panel_titles);
Karsten Hopp 2f825d
  	panel_titles = new_titles;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_pg_remove_buffer(char *name)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      int i;
Karsten Hopp 2f825d
      char **new_titles = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* If there is only 1 panel, we just use the temporary place holder */
Karsten Hopp 2f825d
!     if (num_panels > 1)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	new_titles = (char **) alloc((num_panels - 1) * sizeof(char **));
Karsten Hopp 2f825d
! 	if (new_titles != NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    char **s = new_titles;
Karsten Hopp 2f825d
  	    /* Copy all the titles except the one we're removing */
Karsten Hopp 2f825d
! 	    for (i = 0; i < num_panels; i++)
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		if (STRCMP(panel_titles[ i ], name) != 0)
Karsten Hopp 2f825d
  		{
Karsten Hopp 2f825d
  		    *s++ = panel_titles[ i ];
Karsten Hopp 2f825d
  		}
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
  	    num_panels--;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
Karsten Hopp 2f825d
! 		    num_panels);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    vim_free(panel_titles);
Karsten Hopp 2f825d
  	    panel_titles = new_titles;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	num_panels--;
Karsten Hopp 2f825d
! 	PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title,
Karsten Hopp 2f825d
! 		1);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	vim_free(panel_titles);
Karsten Hopp 2f825d
  	panel_titles = NULL;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1047,1060 ****
Karsten Hopp 2f825d
  gui_ph_handle_buffer_remove(
Karsten Hopp 2f825d
  	PtWidget_t *widget,
Karsten Hopp 2f825d
  	void *data,
Karsten Hopp 2f825d
! 	PtCallbackInfo_t *info )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      vimmenu_T *menu;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( data != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	menu = (vimmenu_T *) data;
Karsten Hopp 2f825d
! 	gui_ph_pg_remove_buffer( menu->dname );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
--- 1047,1060 ----
Karsten Hopp 2f825d
  gui_ph_handle_buffer_remove(
Karsten Hopp 2f825d
  	PtWidget_t *widget,
Karsten Hopp 2f825d
  	void *data,
Karsten Hopp 2f825d
! 	PtCallbackInfo_t *info)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      vimmenu_T *menu;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (data != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	menu = (vimmenu_T *) data;
Karsten Hopp 2f825d
! 	gui_ph_pg_remove_buffer(menu->dname);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1062,1074 ****
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_pane_resize( PtWidget_t *widget, void *data, PtCallbackInfo_t *info )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if( PtWidgetIsRealized( widget ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	is_ignore_draw = TRUE;
Karsten Hopp 2f825d
! 	PtStartFlux( gui.vimContainer );
Karsten Hopp 2f825d
! 	PtContainerHold( gui.vimContainer );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
--- 1062,1074 ----
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_pane_resize(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if (PtWidgetIsRealized(widget))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	is_ignore_draw = TRUE;
Karsten Hopp 2f825d
! 	PtStartFlux(gui.vimContainer);
Karsten Hopp 2f825d
! 	PtContainerHold(gui.vimContainer);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1078,1084 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef FEAT_MBYTE
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
! gui_ph_encoding_changed( int new_encoding )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      /* Default encoding is latin1 */
Karsten Hopp 2f825d
      char *charset = "latin1";
Karsten Hopp 2f825d
--- 1078,1084 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef FEAT_MBYTE
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
! gui_ph_encoding_changed(int new_encoding)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      /* Default encoding is latin1 */
Karsten Hopp 2f825d
      char *charset = "latin1";
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1094,1106 ****
Karsten Hopp 2f825d
  	{ DBCS_CHS, "gb" }
Karsten Hopp 2f825d
      };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     for( i = 0; i < ARRAY_LENGTH( charsets ); i++ )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if( new_encoding == charsets[ i ].encoding )
Karsten Hopp 2f825d
  	    charset = charsets[ i ].name;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     charset_translate = PxTranslateSet( charset_translate, charset );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 1094,1106 ----
Karsten Hopp 2f825d
  	{ DBCS_CHS, "gb" }
Karsten Hopp 2f825d
      };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     for (i = 0; i < ARRAY_LENGTH(charsets); i++)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (new_encoding == charsets[ i ].encoding)
Karsten Hopp 2f825d
  	    charset = charsets[ i ].name;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     charset_translate = PxTranslateSet(charset_translate, charset);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1112,1118 ****
Karsten Hopp 2f825d
      int	    *argc;
Karsten Hopp 2f825d
      char    **argv;
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtInit( NULL );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      int
Karsten Hopp 2f825d
--- 1112,1118 ----
Karsten Hopp 2f825d
      int	    *argc;
Karsten Hopp 2f825d
      char    **argv;
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtInit(NULL);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      int
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1124,1213 ****
Karsten Hopp 2f825d
      PhDim_t	window_size = {100, 100}; /* Arbitrary values */
Karsten Hopp 2f825d
      PhPoint_t	pos = {0, 0};
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.event_buffer = (PhEvent_t *) alloc( EVENT_BUFFER_SIZE );
Karsten Hopp 2f825d
!     if( gui.event_buffer == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Get a translation so we can convert from ISO Latin-1 to UTF */
Karsten Hopp 2f825d
!     charset_translate = PxTranslateSet( NULL, "latin1" );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* The +2 is for the 1 pixel dark line on each side */
Karsten Hopp 2f825d
      gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Handle close events ourselves */
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE,
Karsten Hopp 2f825d
! 	    Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_DIM, &window_size, 0 );
Karsten Hopp 2f825d
!     gui.vimWindow = PtCreateWidget( PtWindow, NULL, n, args );
Karsten Hopp 2f825d
!     if( gui.vimWindow == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback( gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL );
Karsten Hopp 2f825d
!     PtAddCallback( gui.vimWindow, Pt_CB_WINDOW_OPENING,
Karsten Hopp 2f825d
! 	    gui_ph_handle_window_open, NULL );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, Pt_IS_ANCHORED );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_DIM, &window_size, 0 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_POS, &pos, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
      /* Put in a temprary place holder title */
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.vimPanelGroup = PtCreateWidget( PtPanelGroup, gui.vimWindow, n, args );
Karsten Hopp 2f825d
!     if( gui.vimPanelGroup == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback( gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING,
Karsten Hopp 2f825d
! 	    gui_ph_handle_pg_change, NULL );
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
      /* Turn off all edge decorations */
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_CONTAINER_FLAGS, Pt_TRUE, Pt_AUTO_EXTENT );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.vimContainer = PtCreateWidget( PtPane, gui.vimWindow, n, args );
Karsten Hopp 2f825d
!     if( gui.vimContainer == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback( gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Size for the text area is set in gui_mch_set_text_area_pos */
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_BEVEL_WIDTH, GUI_PH_MARGIN, 0 );
Karsten Hopp 2f825d
      /*
Karsten Hopp 2f825d
       * Using focus render also causes the whole widget to be redrawn
Karsten Hopp 2f825d
       * whenever it changes focus, which is very annoying :p
Karsten Hopp 2f825d
       */
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE,
Karsten Hopp 2f825d
! 	    Pt_GETS_FOCUS | Pt_HIGHLIGHTED );
Karsten Hopp 2f825d
  #ifndef FEAT_MOUSESHAPE
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_CURSOR_TYPE, GUI_PH_MOUSE_TYPE, 0 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_CURSOR_COLOR, gui_ph_mouse_color, 0 );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.vimTextArea = PtCreateWidget( PtRaw, Pt_DFLT_PARENT, n, args );
Karsten Hopp 2f825d
!     if( gui.vimTextArea == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* TODO: use PtAddEventHandlers instead? */
Karsten Hopp 2f825d
      /* Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway */
Karsten Hopp 2f825d
!     PtAddEventHandler( gui.vimTextArea,
Karsten Hopp 2f825d
  	    Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON,
Karsten Hopp 2f825d
! 	    gui_ph_handle_mouse, NULL );
Karsten Hopp 2f825d
!     PtAddEventHandler( gui.vimTextArea, Ph_EV_KEY,
Karsten Hopp 2f825d
! 	    gui_ph_handle_keyboard, NULL );
Karsten Hopp 2f825d
!     PtAddCallback( gui.vimTextArea, Pt_CB_GOT_FOCUS,
Karsten Hopp 2f825d
! 	    gui_ph_handle_focus, NULL );
Karsten Hopp 2f825d
!     PtAddCallback( gui.vimTextArea, Pt_CB_LOST_FOCUS,
Karsten Hopp 2f825d
! 	    gui_ph_handle_focus, NULL );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /*
Karsten Hopp 2f825d
       * Now that the text area widget has been created, set up the colours,
Karsten Hopp 2f825d
--- 1124,1213 ----
Karsten Hopp 2f825d
      PhDim_t	window_size = {100, 100}; /* Arbitrary values */
Karsten Hopp 2f825d
      PhPoint_t	pos = {0, 0};
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.event_buffer = (PhEvent_t *) alloc(EVENT_BUFFER_SIZE);
Karsten Hopp 2f825d
!     if (gui.event_buffer == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Get a translation so we can convert from ISO Latin-1 to UTF */
Karsten Hopp 2f825d
!     charset_translate = PxTranslateSet(NULL, "latin1");
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* The +2 is for the 1 pixel dark line on each side */
Karsten Hopp 2f825d
      gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Handle close events ourselves */
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE,
Karsten Hopp 2f825d
! 	    Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0);
Karsten Hopp 2f825d
!     gui.vimWindow = PtCreateWidget(PtWindow, NULL, n, args);
Karsten Hopp 2f825d
!     if (gui.vimWindow == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback(gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL);
Karsten Hopp 2f825d
!     PtAddCallback(gui.vimWindow, Pt_CB_WINDOW_OPENING,
Karsten Hopp 2f825d
! 	    gui_ph_handle_window_open, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, Pt_IS_ANCHORED);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_POS, &pos, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
      /* Put in a temprary place holder title */
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.vimPanelGroup = PtCreateWidget(PtPanelGroup, gui.vimWindow, n, args);
Karsten Hopp 2f825d
!     if (gui.vimPanelGroup == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback(gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING,
Karsten Hopp 2f825d
! 	    gui_ph_handle_pg_change, NULL);
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
      /* Turn off all edge decorations */
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_CONTAINER_FLAGS, Pt_TRUE, Pt_AUTO_EXTENT);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.vimContainer = PtCreateWidget(PtPane, gui.vimWindow, n, args);
Karsten Hopp 2f825d
!     if (gui.vimContainer == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback(gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Size for the text area is set in gui_mch_set_text_area_pos */
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, GUI_PH_MARGIN, 0);
Karsten Hopp 2f825d
      /*
Karsten Hopp 2f825d
       * Using focus render also causes the whole widget to be redrawn
Karsten Hopp 2f825d
       * whenever it changes focus, which is very annoying :p
Karsten Hopp 2f825d
       */
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE,
Karsten Hopp 2f825d
! 	    Pt_GETS_FOCUS | Pt_HIGHLIGHTED);
Karsten Hopp 2f825d
  #ifndef FEAT_MOUSESHAPE
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_TYPE, GUI_PH_MOUSE_TYPE, 0);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_COLOR, gui_ph_mouse_color, 0);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.vimTextArea = PtCreateWidget(PtRaw, Pt_DFLT_PARENT, n, args);
Karsten Hopp 2f825d
!     if (gui.vimTextArea == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* TODO: use PtAddEventHandlers instead? */
Karsten Hopp 2f825d
      /* Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway */
Karsten Hopp 2f825d
!     PtAddEventHandler(gui.vimTextArea,
Karsten Hopp 2f825d
  	    Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON,
Karsten Hopp 2f825d
! 	    gui_ph_handle_mouse, NULL);
Karsten Hopp 2f825d
!     PtAddEventHandler(gui.vimTextArea, Ph_EV_KEY,
Karsten Hopp 2f825d
! 	    gui_ph_handle_keyboard, NULL);
Karsten Hopp 2f825d
!     PtAddCallback(gui.vimTextArea, Pt_CB_GOT_FOCUS,
Karsten Hopp 2f825d
! 	    gui_ph_handle_focus, NULL);
Karsten Hopp 2f825d
!     PtAddCallback(gui.vimTextArea, Pt_CB_LOST_FOCUS,
Karsten Hopp 2f825d
! 	    gui_ph_handle_focus, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /*
Karsten Hopp 2f825d
       * Now that the text area widget has been created, set up the colours,
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1218,1278 ****
Karsten Hopp 2f825d
       * Create the two timers, not as accurate as using the kernel timer
Karsten Hopp 2f825d
       * functions, but good enough
Karsten Hopp 2f825d
       */
Karsten Hopp 2f825d
!     gui_ph_timer_cursor  = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL );
Karsten Hopp 2f825d
!     if( gui_ph_timer_cursor == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui_ph_timer_timeout = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL );
Karsten Hopp 2f825d
!     if( gui_ph_timer_timeout == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback( gui_ph_timer_cursor,  Pt_CB_TIMER_ACTIVATE,
Karsten Hopp 2f825d
  	    gui_ph_handle_timer_cursor, NULL);
Karsten Hopp 2f825d
!     PtAddCallback( gui_ph_timer_timeout, Pt_CB_TIMER_ACTIVATE,
Karsten Hopp 2f825d
  	    gui_ph_handle_timer_timeout, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef FEAT_MENU
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT,
Karsten Hopp 2f825d
! 	    Pt_IS_ANCHORED );
Karsten Hopp 2f825d
!     gui.vimToolBarGroup = PtCreateWidget( PtToolbarGroup, gui.vimWindow,
Karsten Hopp 2f825d
! 	    n, args );
Karsten Hopp 2f825d
!     if( gui.vimToolBarGroup == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback( gui.vimToolBarGroup, Pt_CB_RESIZE,
Karsten Hopp 2f825d
! 	    gui_ph_handle_menu_resize, NULL );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
      flags = 0;
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 );
Karsten Hopp 2f825d
!     if( ! vim_strchr( p_go, GO_MENUS ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	flags |= Pt_DELAY_REALIZE;
Karsten Hopp 2f825d
! 	PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
!     gui.vimMenuBar = PtCreateWidget( PtMenuBar, gui.vimToolBarGroup, n, args );
Karsten Hopp 2f825d
!     if( gui.vimMenuBar == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  # ifdef FEAT_TOOLBAR
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS,
Karsten Hopp 2f825d
! 	    Pt_ANCHOR_LEFT_RIGHT |Pt_TOP_ANCHORED_TOP, Pt_IS_ANCHORED );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_RESIZE_FLAGS, Pt_TRUE,
Karsten Hopp 2f825d
! 	    Pt_RESIZE_Y_AS_REQUIRED );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      flags = Pt_GETS_FOCUS;
Karsten Hopp 2f825d
!     if( ! vim_strchr( p_go, GO_TOOLBAR ) )
Karsten Hopp 2f825d
  	flags |= Pt_DELAY_REALIZE;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.vimToolBar = PtCreateWidget( PtToolbar, gui.vimToolBarGroup, n, args );
Karsten Hopp 2f825d
!     if( gui.vimToolBar == NULL )
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /*
Karsten Hopp 2f825d
--- 1218,1278 ----
Karsten Hopp 2f825d
       * Create the two timers, not as accurate as using the kernel timer
Karsten Hopp 2f825d
       * functions, but good enough
Karsten Hopp 2f825d
       */
Karsten Hopp 2f825d
!     gui_ph_timer_cursor  = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL);
Karsten Hopp 2f825d
!     if (gui_ph_timer_cursor == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui_ph_timer_timeout = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL);
Karsten Hopp 2f825d
!     if (gui_ph_timer_timeout == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback(gui_ph_timer_cursor,  Pt_CB_TIMER_ACTIVATE,
Karsten Hopp 2f825d
  	    gui_ph_handle_timer_cursor, NULL);
Karsten Hopp 2f825d
!     PtAddCallback(gui_ph_timer_timeout, Pt_CB_TIMER_ACTIVATE,
Karsten Hopp 2f825d
  	    gui_ph_handle_timer_timeout, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef FEAT_MENU
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT,
Karsten Hopp 2f825d
! 	    Pt_IS_ANCHORED);
Karsten Hopp 2f825d
!     gui.vimToolBarGroup = PtCreateWidget(PtToolbarGroup, gui.vimWindow,
Karsten Hopp 2f825d
! 	    n, args);
Karsten Hopp 2f825d
!     if (gui.vimToolBarGroup == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback(gui.vimToolBarGroup, Pt_CB_RESIZE,
Karsten Hopp 2f825d
! 	    gui_ph_handle_menu_resize, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
      flags = 0;
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0);
Karsten Hopp 2f825d
!     if (! vim_strchr(p_go, GO_MENUS))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	flags |= Pt_DELAY_REALIZE;
Karsten Hopp 2f825d
! 	PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
!     gui.vimMenuBar = PtCreateWidget(PtMenuBar, gui.vimToolBarGroup, n, args);
Karsten Hopp 2f825d
!     if (gui.vimMenuBar == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  # ifdef FEAT_TOOLBAR
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS,
Karsten Hopp 2f825d
! 	    Pt_ANCHOR_LEFT_RIGHT |Pt_TOP_ANCHORED_TOP, Pt_IS_ANCHORED);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_RESIZE_FLAGS, Pt_TRUE,
Karsten Hopp 2f825d
! 	    Pt_RESIZE_Y_AS_REQUIRED);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      flags = Pt_GETS_FOCUS;
Karsten Hopp 2f825d
!     if (! vim_strchr(p_go, GO_TOOLBAR))
Karsten Hopp 2f825d
  	flags |= Pt_DELAY_REALIZE;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui.vimToolBar = PtCreateWidget(PtToolbar, gui.vimToolBarGroup, n, args);
Karsten Hopp 2f825d
!     if (gui.vimToolBar == NULL)
Karsten Hopp 2f825d
  	return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /*
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1310,1329 ****
Karsten Hopp 2f825d
      if (gui_win_x != -1 && gui_win_y != -1)
Karsten Hopp 2f825d
  	gui_mch_set_winpos(gui_win_x, gui_win_y);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     return (PtRealizeWidget( gui.vimWindow ) == 0) ? OK : FAIL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_exit(int rc)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtDestroyWidget( gui.vimWindow );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PxTranslateSet( charset_translate, NULL );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     vim_free( gui.event_buffer );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUPS
Karsten Hopp 2f825d
!     vim_free( panel_titles );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 1310,1329 ----
Karsten Hopp 2f825d
      if (gui_win_x != -1 && gui_win_y != -1)
Karsten Hopp 2f825d
  	gui_mch_set_winpos(gui_win_x, gui_win_y);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     return (PtRealizeWidget(gui.vimWindow) == 0) ? OK : FAIL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_exit(int rc)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtDestroyWidget(gui.vimWindow);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PxTranslateSet(charset_translate, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     vim_free(gui.event_buffer);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUPS
Karsten Hopp 2f825d
!     vim_free(panel_titles);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1333,1339 ****
Karsten Hopp 2f825d
  /* When no events are available, photon will call this function, working is
Karsten Hopp 2f825d
   * set to FALSE, and the gui_mch_update loop will exit. */
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! exit_gui_mch_update( void *data )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      *(int *)data = FALSE;
Karsten Hopp 2f825d
      return Pt_END;
Karsten Hopp 2f825d
--- 1333,1339 ----
Karsten Hopp 2f825d
  /* When no events are available, photon will call this function, working is
Karsten Hopp 2f825d
   * set to FALSE, and the gui_mch_update loop will exit. */
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! exit_gui_mch_update(void *data)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      *(int *)data = FALSE;
Karsten Hopp 2f825d
      return Pt_END;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1344,1351 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      int working = TRUE;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAppAddWorkProc( NULL, exit_gui_mch_update, &working );
Karsten Hopp 2f825d
!     while( ( working == TRUE ) && !vim_is_input_buf_full())
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	PtProcessEvent();
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
--- 1344,1351 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      int working = TRUE;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAppAddWorkProc(NULL, exit_gui_mch_update, &working);
Karsten Hopp 2f825d
!     while ((working == TRUE) && !vim_is_input_buf_full())
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	PtProcessEvent();
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1356,1378 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      is_timeout = FALSE;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( wtime > 0 )
Karsten Hopp 2f825d
! 	PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, wtime, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     while( 1 )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	PtProcessEvent();
Karsten Hopp 2f825d
! 	if( input_available() )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0 );
Karsten Hopp 2f825d
  	    return OK;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
! 	else if( is_timeout == TRUE )
Karsten Hopp 2f825d
  	    return FAIL;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! #if defined( FEAT_BROWSE ) || defined( PROTO )
Karsten Hopp 2f825d
  /*
Karsten Hopp 2f825d
   * Put up a file requester.
Karsten Hopp 2f825d
   * Returns the selected name in allocated memory, or NULL for Cancel.
Karsten Hopp 2f825d
--- 1356,1378 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      is_timeout = FALSE;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (wtime > 0)
Karsten Hopp 2f825d
! 	PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, wtime, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     while (1)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	PtProcessEvent();
Karsten Hopp 2f825d
! 	if (input_available())
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0);
Karsten Hopp 2f825d
  	    return OK;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
! 	else if (is_timeout == TRUE)
Karsten Hopp 2f825d
  	    return FAIL;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! #if defined(FEAT_BROWSE) || defined(PROTO)
Karsten Hopp 2f825d
  /*
Karsten Hopp 2f825d
   * Put up a file requester.
Karsten Hopp 2f825d
   * Returns the selected name in allocated memory, or NULL for Cancel.
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1398,1409 ****
Karsten Hopp 2f825d
      char_u  *open_text = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      flags = 0;
Karsten Hopp 2f825d
!     memset( &file, 0, sizeof( file ) );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     default_path = alloc( MAXPATHL + 1 + NAME_MAX + 1 );
Karsten Hopp 2f825d
!     if( default_path != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if( saving == TRUE )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    /* Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway */
Karsten Hopp 2f825d
  	    flags |= Pt_FSR_NO_FCHECK;
Karsten Hopp 2f825d
--- 1398,1409 ----
Karsten Hopp 2f825d
      char_u  *open_text = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      flags = 0;
Karsten Hopp 2f825d
!     memset(&file, 0, sizeof(file));
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     default_path = alloc(MAXPATHL + 1 + NAME_MAX + 1);
Karsten Hopp 2f825d
!     if (default_path != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (saving == TRUE)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    /* Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway */
Karsten Hopp 2f825d
  	    flags |= Pt_FSR_NO_FCHECK;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1411,1433 ****
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* combine the directory and filename into a single path */
Karsten Hopp 2f825d
! 	if( initdir == NULL || *initdir == NUL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    mch_dirname( default_path, MAXPATHL );
Karsten Hopp 2f825d
  	    initdir = default_path;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  	else
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    STRCPY( default_path, initdir );
Karsten Hopp 2f825d
  	    initdir = default_path;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if( default_name != NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    if( default_path[ STRLEN( default_path ) - 1 ] != '/' )
Karsten Hopp 2f825d
! 		STRCAT( default_path, "/" );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    STRCAT( default_path, default_name );
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* TODO: add a filter? */
Karsten Hopp 2f825d
--- 1411,1433 ----
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* combine the directory and filename into a single path */
Karsten Hopp 2f825d
! 	if (initdir == NULL || *initdir == NUL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    mch_dirname(default_path, MAXPATHL);
Karsten Hopp 2f825d
  	    initdir = default_path;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  	else
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    STRCPY(default_path, initdir);
Karsten Hopp 2f825d
  	    initdir = default_path;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if (default_name != NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    if (default_path[ STRLEN(default_path) - 1 ] != '/')
Karsten Hopp 2f825d
! 		STRCAT(default_path, "/");
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    STRCAT(default_path, default_name);
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* TODO: add a filter? */
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1441,1495 ****
Karsten Hopp 2f825d
  		NULL,
Karsten Hopp 2f825d
  		NULL,
Karsten Hopp 2f825d
  		&file,
Karsten Hopp 2f825d
! 		flags );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	vim_free( default_path );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if( file.ret == Pt_FSDIALOG_BTN1 )
Karsten Hopp 2f825d
  	    return vim_strsave(file.path);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return NULL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! #if defined( FEAT_GUI_DIALOG ) || defined( PROTO )
Karsten Hopp 2f825d
  static PtWidget_t *gui_ph_dialog_text = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_dialog_close( int button, void *data )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PtModalCtrl_t *modal_ctrl = data;
Karsten Hopp 2f825d
      char_u *dialog_text, *vim_text;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( gui_ph_dialog_text != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	PtGetResource( gui_ph_dialog_text, Pt_ARG_TEXT_STRING, &dialog_text, 0 );
Karsten Hopp 2f825d
! 	PtGetResource( gui_ph_dialog_text, Pt_ARG_POINTER, &vim_text, 0 );
Karsten Hopp 2f825d
! 	STRNCPY( vim_text, dialog_text, IOSIZE - 1 );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtModalUnblock( modal_ctrl, (void *) button );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return Pt_TRUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_dialog_text_enter( PtWidget_t *widget, void *data, PtCallbackInfo_t *info )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if( info->reason_subtype == Pt_EDIT_ACTIVATE )
Karsten Hopp 2f825d
! 	gui_ph_dialog_close( 1, data );
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_dialog_esc( PtWidget_t *widget, void *data, PtCallbackInfo_t *info )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhKeyEvent_t *key;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     key = PhGetData( info->event );
Karsten Hopp 2f825d
!     if( ( key->key_flags & Pk_KF_Cap_Valid ) && ( key->key_cap == Pk_Escape ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	gui_ph_dialog_close( 0, data );
Karsten Hopp 2f825d
  	return Pt_CONSUME;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return Pt_PROCESS;
Karsten Hopp 2f825d
--- 1441,1495 ----
Karsten Hopp 2f825d
  		NULL,
Karsten Hopp 2f825d
  		NULL,
Karsten Hopp 2f825d
  		&file,
Karsten Hopp 2f825d
! 		flags);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	vim_free(default_path);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if (file.ret == Pt_FSDIALOG_BTN1)
Karsten Hopp 2f825d
  	    return vim_strsave(file.path);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return NULL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
Karsten Hopp 2f825d
  static PtWidget_t *gui_ph_dialog_text = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_dialog_close(int button, void *data)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PtModalCtrl_t *modal_ctrl = data;
Karsten Hopp 2f825d
      char_u *dialog_text, *vim_text;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (gui_ph_dialog_text != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	PtGetResource(gui_ph_dialog_text, Pt_ARG_TEXT_STRING, &dialog_text, 0);
Karsten Hopp 2f825d
! 	PtGetResource(gui_ph_dialog_text, Pt_ARG_POINTER, &vim_text, 0);
Karsten Hopp 2f825d
! 	STRNCPY(vim_text, dialog_text, IOSIZE - 1);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtModalUnblock(modal_ctrl, (void *) button);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return Pt_TRUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_dialog_text_enter(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if (info->reason_subtype == Pt_EDIT_ACTIVATE)
Karsten Hopp 2f825d
! 	gui_ph_dialog_close(1, data);
Karsten Hopp 2f825d
      return Pt_CONTINUE;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
! gui_ph_dialog_esc(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhKeyEvent_t *key;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     key = PhGetData(info->event);
Karsten Hopp 2f825d
!     if ((key->key_flags & Pk_KF_Cap_Valid) && (key->key_cap == Pk_Escape))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	gui_ph_dialog_close(0, data);
Karsten Hopp 2f825d
  	return Pt_CONSUME;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return Pt_PROCESS;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1518,1557 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      button_count = len = i = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( buttons == NULL || *buttons == NUL )
Karsten Hopp 2f825d
  	return -1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* There is one less separator than buttons, so bump up the button count */
Karsten Hopp 2f825d
      button_count = 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Count string length and number of seperators */
Karsten Hopp 2f825d
!     for( str = buttons; *str; str++ )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	len++;
Karsten Hopp 2f825d
! 	if( *str == DLG_BUTTON_SEP )
Karsten Hopp 2f825d
  	    button_count++;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if ( title == NULL )
Karsten Hopp 2f825d
  	title = "Vim";
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     buttons_copy = alloc( len + 1 );
Karsten Hopp 2f825d
!     button_array = (char_u **) alloc( button_count * sizeof( char_u * ) );
Karsten Hopp 2f825d
!     if( buttons_copy != NULL && button_array != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	STRCPY( buttons_copy, buttons );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/*
Karsten Hopp 2f825d
  	 * Convert DLG_BUTTON_SEP into NUL's and fill in
Karsten Hopp 2f825d
  	 * button_array with the pointer to each NUL terminated string
Karsten Hopp 2f825d
  	 */
Karsten Hopp 2f825d
  	str = buttons_copy;
Karsten Hopp 2f825d
! 	for( i = 0; i < button_count; i++ )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    button_array[ i ] = str;
Karsten Hopp 2f825d
! 	    for( ; *str; str++ )
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		if( *str == DLG_BUTTON_SEP )
Karsten Hopp 2f825d
  		{
Karsten Hopp 2f825d
  		    *str++ = NUL;
Karsten Hopp 2f825d
  		    break;
Karsten Hopp 2f825d
--- 1518,1557 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      button_count = len = i = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (buttons == NULL || *buttons == NUL)
Karsten Hopp 2f825d
  	return -1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* There is one less separator than buttons, so bump up the button count */
Karsten Hopp 2f825d
      button_count = 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Count string length and number of seperators */
Karsten Hopp 2f825d
!     for (str = buttons; *str; str++)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	len++;
Karsten Hopp 2f825d
! 	if (*str == DLG_BUTTON_SEP)
Karsten Hopp 2f825d
  	    button_count++;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (title == NULL)
Karsten Hopp 2f825d
  	title = "Vim";
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     buttons_copy = alloc(len + 1);
Karsten Hopp 2f825d
!     button_array = (char_u **) alloc(button_count * sizeof(char_u *));
Karsten Hopp 2f825d
!     if (buttons_copy != NULL && button_array != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	STRCPY(buttons_copy, buttons);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/*
Karsten Hopp 2f825d
  	 * Convert DLG_BUTTON_SEP into NUL's and fill in
Karsten Hopp 2f825d
  	 * button_array with the pointer to each NUL terminated string
Karsten Hopp 2f825d
  	 */
Karsten Hopp 2f825d
  	str = buttons_copy;
Karsten Hopp 2f825d
! 	for (i = 0; i < button_count; i++)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    button_array[ i ] = str;
Karsten Hopp 2f825d
! 	    for (; *str; str++)
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		if (*str == DLG_BUTTON_SEP)
Karsten Hopp 2f825d
  		{
Karsten Hopp 2f825d
  		    *str++ = NUL;
Karsten Hopp 2f825d
  		    break;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1565,1571 ****
Karsten Hopp 2f825d
  		NULL,
Karsten Hopp 2f825d
  		message, NULL,
Karsten Hopp 2f825d
  		button_count, (const char **) button_array, NULL,
Karsten Hopp 2f825d
! 		default_button, 0, Pt_MODAL );
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
  	/* Writing the dialog ourselves lets us add extra features, like
Karsten Hopp 2f825d
  	 * trapping the escape key and returning 0 to vim */
Karsten Hopp 2f825d
--- 1565,1571 ----
Karsten Hopp 2f825d
  		NULL,
Karsten Hopp 2f825d
  		message, NULL,
Karsten Hopp 2f825d
  		button_count, (const char **) button_array, NULL,
Karsten Hopp 2f825d
! 		default_button, 0, Pt_MODAL);
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
  	/* Writing the dialog ourselves lets us add extra features, like
Karsten Hopp 2f825d
  	 * trapping the escape key and returning 0 to vim */
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1576,1607 ****
Karsten Hopp 2f825d
  	    PtModalCtrl_t modal_ctrl;
Karsten Hopp 2f825d
  	    PtDialogInfo_t di;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    memset( &di, 0, sizeof( di ) );
Karsten Hopp 2f825d
! 	    memset( &modal_ctrl, 0, sizeof( modal_ctrl ) );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    n = 0;
Karsten Hopp 2f825d
! 	    PtSetArg( &args[n++], Pt_ARG_GROUP_ROWS_COLS, 0, 0 );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[n++], Pt_ARG_WIDTH, 350, 0 );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[n++], Pt_ARG_GROUP_ORIENTATION,
Karsten Hopp 2f825d
! 		    Pt_GROUP_VERTICAL, 0 );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[n++], Pt_ARG_GROUP_FLAGS,
Karsten Hopp 2f825d
! 		    Pt_TRUE, Pt_GROUP_NO_KEYS | Pt_GROUP_STRETCH_HORIZONTAL );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[n++], Pt_ARG_CONTAINER_FLAGS, Pt_FALSE, Pt_TRUE );
Karsten Hopp 2f825d
! 	    pane = PtCreateWidget( PtGroup, NULL, n, args );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    n = 0;
Karsten Hopp 2f825d
! 	    PtSetArg( &args[n++], Pt_ARG_TEXT_STRING, message, 0 );
Karsten Hopp 2f825d
! 	    PtCreateWidget( PtLabel, pane, n, args );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if( textfield != NULL )
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
  		n = 0;
Karsten Hopp 2f825d
! 		PtSetArg( &args[n++], Pt_ARG_MAX_LENGTH, IOSIZE - 1, 0 );
Karsten Hopp 2f825d
! 		PtSetArg( &args[n++], Pt_ARG_TEXT_STRING, textfield, 0 );
Karsten Hopp 2f825d
! 		PtSetArg( &args[n++], Pt_ARG_POINTER, textfield, 0 );
Karsten Hopp 2f825d
! 		gui_ph_dialog_text = PtCreateWidget( PtText, pane, n, args );
Karsten Hopp 2f825d
! 		PtAddCallback( gui_ph_dialog_text, Pt_CB_ACTIVATE,
Karsten Hopp 2f825d
! 			gui_ph_dialog_text_enter, &modal_ctrl );
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    di.parent = gui.vimWindow;
Karsten Hopp 2f825d
--- 1576,1607 ----
Karsten Hopp 2f825d
  	    PtModalCtrl_t modal_ctrl;
Karsten Hopp 2f825d
  	    PtDialogInfo_t di;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    memset(&di, 0, sizeof(di));
Karsten Hopp 2f825d
! 	    memset(&modal_ctrl, 0, sizeof(modal_ctrl));
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    n = 0;
Karsten Hopp 2f825d
! 	    PtSetArg(&args[n++], Pt_ARG_GROUP_ROWS_COLS, 0, 0);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[n++], Pt_ARG_WIDTH, 350, 0);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[n++], Pt_ARG_GROUP_ORIENTATION,
Karsten Hopp 2f825d
! 		    Pt_GROUP_VERTICAL, 0);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[n++], Pt_ARG_GROUP_FLAGS,
Karsten Hopp 2f825d
! 		    Pt_TRUE, Pt_GROUP_NO_KEYS | Pt_GROUP_STRETCH_HORIZONTAL);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[n++], Pt_ARG_CONTAINER_FLAGS, Pt_FALSE, Pt_TRUE);
Karsten Hopp 2f825d
! 	    pane = PtCreateWidget(PtGroup, NULL, n, args);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    n = 0;
Karsten Hopp 2f825d
! 	    PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, message, 0);
Karsten Hopp 2f825d
! 	    PtCreateWidget(PtLabel, pane, n, args);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if (textfield != NULL)
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
  		n = 0;
Karsten Hopp 2f825d
! 		PtSetArg(&args[n++], Pt_ARG_MAX_LENGTH, IOSIZE - 1, 0);
Karsten Hopp 2f825d
! 		PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, textfield, 0);
Karsten Hopp 2f825d
! 		PtSetArg(&args[n++], Pt_ARG_POINTER, textfield, 0);
Karsten Hopp 2f825d
! 		gui_ph_dialog_text = PtCreateWidget(PtText, pane, n, args);
Karsten Hopp 2f825d
! 		PtAddCallback(gui_ph_dialog_text, Pt_CB_ACTIVATE,
Karsten Hopp 2f825d
! 			gui_ph_dialog_text_enter, &modal_ctrl);
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    di.parent = gui.vimWindow;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1616,1641 ****
Karsten Hopp 2f825d
  	    di.callback = gui_ph_dialog_close;
Karsten Hopp 2f825d
  	    di.data = &modal_ctrl;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    dialog = PtCreateDialog( &di );
Karsten Hopp 2f825d
! 	    PtAddFilterCallback( dialog, Ph_EV_KEY,
Karsten Hopp 2f825d
! 		    gui_ph_dialog_esc, &modal_ctrl );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if( gui_ph_dialog_text != NULL )
Karsten Hopp 2f825d
! 		PtGiveFocus( gui_ph_dialog_text, NULL );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    /* Open dialog, block the vim window and wait for the dialog to close */
Karsten Hopp 2f825d
! 	    PtRealizeWidget( dialog );
Karsten Hopp 2f825d
! 	    PtMakeModal( dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR );
Karsten Hopp 2f825d
! 	    dialog_result = (int) PtModalBlock( &modal_ctrl, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    PtDestroyWidget( dialog );
Karsten Hopp 2f825d
  	    gui_ph_dialog_text = NULL;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     vim_free( button_array );
Karsten Hopp 2f825d
!     vim_free( buttons_copy );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return dialog_result;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
--- 1616,1641 ----
Karsten Hopp 2f825d
  	    di.callback = gui_ph_dialog_close;
Karsten Hopp 2f825d
  	    di.data = &modal_ctrl;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    dialog = PtCreateDialog(&di);
Karsten Hopp 2f825d
! 	    PtAddFilterCallback(dialog, Ph_EV_KEY,
Karsten Hopp 2f825d
! 		    gui_ph_dialog_esc, &modal_ctrl);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if (gui_ph_dialog_text != NULL)
Karsten Hopp 2f825d
! 		PtGiveFocus(gui_ph_dialog_text, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    /* Open dialog, block the vim window and wait for the dialog to close */
Karsten Hopp 2f825d
! 	    PtRealizeWidget(dialog);
Karsten Hopp 2f825d
! 	    PtMakeModal(dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR);
Karsten Hopp 2f825d
! 	    dialog_result = (int) PtModalBlock(&modal_ctrl, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    PtDestroyWidget(dialog);
Karsten Hopp 2f825d
  	    gui_ph_dialog_text = NULL;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     vim_free(button_array);
Karsten Hopp 2f825d
!     vim_free(buttons_copy);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return dialog_result;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1648,1654 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhPoint_t *pos;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     pos = PtWidgetPos( gui.vimWindow, NULL );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      *x = pos->x;
Karsten Hopp 2f825d
      *y = pos->y;
Karsten Hopp 2f825d
--- 1648,1654 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhPoint_t *pos;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     pos = PtWidgetPos(gui.vimWindow, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      *x = pos->x;
Karsten Hopp 2f825d
      *y = pos->y;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1661,1667 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhPoint_t pos = { x, y };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource( gui.vimWindow, Pt_ARG_POS, &pos, 0 );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 1661,1667 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhPoint_t pos = { x, y };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource(gui.vimWindow, Pt_ARG_POS, &pos, 0);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1677,1686 ****
Karsten Hopp 2f825d
      window_size.h += pg_margin_top + pg_margin_bottom;
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource( gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0 );
Karsten Hopp 2f825d
!     PtSetResource( gui.vimWindow, Pt_ARG_DIM, &window_size, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( ! PtWidgetIsRealized( gui.vimWindow ) )
Karsten Hopp 2f825d
  	gui_ph_resize_container();
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 1677,1686 ----
Karsten Hopp 2f825d
      window_size.h += pg_margin_top + pg_margin_bottom;
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource(gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0);
Karsten Hopp 2f825d
!     PtSetResource(gui.vimWindow, Pt_ARG_DIM, &window_size, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (! PtWidgetIsRealized(gui.vimWindow))
Karsten Hopp 2f825d
  	gui_ph_resize_container();
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1693,1700 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhRect_t console;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PhWindowQueryVisible( Ph_QUERY_WORKSPACE, 0,
Karsten Hopp 2f825d
! 	    PhInputGroup( NULL ), &console );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      *screen_w = console.lr.x - console.ul.x + 1;
Karsten Hopp 2f825d
      *screen_h = console.lr.y - console.ul.y + 1;
Karsten Hopp 2f825d
--- 1693,1700 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhRect_t console;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PhWindowQueryVisible(Ph_QUERY_WORKSPACE, 0,
Karsten Hopp 2f825d
! 	    PhInputGroup(NULL), &console);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      *screen_w = console.lr.x - console.ul.x + 1;
Karsten Hopp 2f825d
      *screen_h = console.lr.y - console.ul.y + 1;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1705,1715 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhWindowEvent_t event;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     memset( &event, 0, sizeof (event) );
Karsten Hopp 2f825d
      event.event_f = Ph_WM_HIDE;
Karsten Hopp 2f825d
      event.event_state = Ph_WM_EVSTATE_HIDE;
Karsten Hopp 2f825d
!     event.rid = PtWidgetRid( gui.vimWindow );
Karsten Hopp 2f825d
!     PtForwardWindowEvent( &event );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #if defined(FEAT_EVAL) || defined(PROTO)
Karsten Hopp 2f825d
--- 1705,1715 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhWindowEvent_t event;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     memset(&event, 0, sizeof (event));
Karsten Hopp 2f825d
      event.event_f = Ph_WM_HIDE;
Karsten Hopp 2f825d
      event.event_state = Ph_WM_EVSTATE_HIDE;
Karsten Hopp 2f825d
!     event.rid = PtWidgetRid(gui.vimWindow);
Karsten Hopp 2f825d
!     PtForwardWindowEvent(&event);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #if defined(FEAT_EVAL) || defined(PROTO)
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1721,1731 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhWindowEvent_t event;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     memset( &event, 0, sizeof (event) );
Karsten Hopp 2f825d
      event.event_f = Ph_WM_TOFRONT;
Karsten Hopp 2f825d
      event.event_state = Ph_WM_EVSTATE_FFRONT;
Karsten Hopp 2f825d
!     event.rid = PtWidgetRid( gui.vimWindow );
Karsten Hopp 2f825d
!     PtForwardWindowEvent( &event );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 1721,1731 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhWindowEvent_t event;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     memset(&event, 0, sizeof (event));
Karsten Hopp 2f825d
      event.event_f = Ph_WM_TOFRONT;
Karsten Hopp 2f825d
      event.event_state = Ph_WM_EVSTATE_FFRONT;
Karsten Hopp 2f825d
!     event.rid = PtWidgetRid(gui.vimWindow);
Karsten Hopp 2f825d
!     PtForwardWindowEvent(&event);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1733,1741 ****
Karsten Hopp 2f825d
  gui_mch_settitle(char_u *title,	char_u *icon)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
!     gui_ph_pg_set_buffer_num( curwin->w_buffer->b_fnum );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
!     PtSetResource( gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0 );
Karsten Hopp 2f825d
      /* Not sure what to do with the icon text, set balloon text somehow? */
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 1733,1741 ----
Karsten Hopp 2f825d
  gui_mch_settitle(char_u *title,	char_u *icon)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
!     gui_ph_pg_set_buffer_num(curwin->w_buffer->b_fnum);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
!     PtSetResource(gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0);
Karsten Hopp 2f825d
      /* Not sure what to do with the icon text, set balloon text somehow? */
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1748,1757 ****
Karsten Hopp 2f825d
      int	    n = 0;
Karsten Hopp 2f825d
      PtArg_t args[3];
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_MAXIMUM, max, 0 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_SLIDER_SIZE, size, 0 );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_GAUGE_VALUE, val, 0 );
Karsten Hopp 2f825d
!     PtSetResources( sb->id, n, args );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 1748,1757 ----
Karsten Hopp 2f825d
      int	    n = 0;
Karsten Hopp 2f825d
      PtArg_t args[3];
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_MAXIMUM, max, 0);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_SLIDER_SIZE, size, 0);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_GAUGE_VALUE, val, 0);
Karsten Hopp 2f825d
!     PtSetResources(sb->id, n, args);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1759,1765 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhArea_t area = {{ x, y }, { w, h }};
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource( sb->id, Pt_ARG_AREA, &area, 0 );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 1759,1765 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhArea_t area = {{ x, y }, { w, h }};
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource(sb->id, Pt_ARG_AREA, &area, 0);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1775,1786 ****
Karsten Hopp 2f825d
       *
Karsten Hopp 2f825d
       * Also, don't let the scrollbar get focus
Karsten Hopp 2f825d
       */
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE,
Karsten Hopp 2f825d
! 	    Pt_DELAY_REALIZE | Pt_GETS_FOCUS );
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0);
Karsten Hopp 2f825d
  #if 0
Karsten Hopp 2f825d
      /* Don't need this anchoring for the scrollbars */
Karsten Hopp 2f825d
!     if( orient == SBAR_HORIZ )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM |
Karsten Hopp 2f825d
  	    Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT;
Karsten Hopp 2f825d
--- 1775,1786 ----
Karsten Hopp 2f825d
       *
Karsten Hopp 2f825d
       * Also, don't let the scrollbar get focus
Karsten Hopp 2f825d
       */
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE,
Karsten Hopp 2f825d
! 	    Pt_DELAY_REALIZE | Pt_GETS_FOCUS);
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0);
Karsten Hopp 2f825d
  #if 0
Karsten Hopp 2f825d
      /* Don't need this anchoring for the scrollbars */
Karsten Hopp 2f825d
!     if (orient == SBAR_HORIZ)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM |
Karsten Hopp 2f825d
  	    Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1788,1827 ****
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP;
Karsten Hopp 2f825d
! 	if( sb->wp != NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    if( sb == &sb->wp->w_scrollbars[ SBAR_LEFT ] )
Karsten Hopp 2f825d
  		anchor_flags |= Pt_LEFT_ANCHORED_LEFT;
Karsten Hopp 2f825d
  	    else
Karsten Hopp 2f825d
  		anchor_flags |= Pt_RIGHT_ANCHORED_RIGHT;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, anchor_flags, Pt_IS_ANCHORED );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_ORIENTATION,
Karsten Hopp 2f825d
! 	    (orient == SBAR_HORIZ) ? Pt_HORIZONTAL : Pt_VERTICAL, 0 );
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
!     sb->id = PtCreateWidget( PtScrollbar, gui.vimPanelGroup, n, args );
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
!     sb->id = PtCreateWidget( PtScrollbar, gui.vimContainer, n, args );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback( sb->id, Pt_CB_SCROLLBAR_MOVE, gui_ph_handle_scrollbar, sb );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if( flag != 0 )
Karsten Hopp 2f825d
! 	PtRealizeWidget( sb->id );
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
! 	PtUnrealizeWidget( sb->id );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_destroy_scrollbar(scrollbar_T *sb)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtDestroyWidget( sb->id );
Karsten Hopp 2f825d
      sb->id = NULL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 1788,1827 ----
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP;
Karsten Hopp 2f825d
! 	if (sb->wp != NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    if (sb == &sb->wp->w_scrollbars[ SBAR_LEFT ])
Karsten Hopp 2f825d
  		anchor_flags |= Pt_LEFT_ANCHORED_LEFT;
Karsten Hopp 2f825d
  	    else
Karsten Hopp 2f825d
  		anchor_flags |= Pt_RIGHT_ANCHORED_RIGHT;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, anchor_flags, Pt_IS_ANCHORED);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_ORIENTATION,
Karsten Hopp 2f825d
! 	    (orient == SBAR_HORIZ) ? Pt_HORIZONTAL : Pt_VERTICAL, 0);
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
!     sb->id = PtCreateWidget(PtScrollbar, gui.vimPanelGroup, n, args);
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
!     sb->id = PtCreateWidget(PtScrollbar, gui.vimContainer, n, args);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtAddCallback(sb->id, Pt_CB_SCROLLBAR_MOVE, gui_ph_handle_scrollbar, sb);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if (flag != 0)
Karsten Hopp 2f825d
! 	PtRealizeWidget(sb->id);
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
! 	PtUnrealizeWidget(sb->id);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_destroy_scrollbar(scrollbar_T *sb)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtDestroyWidget(sb->id);
Karsten Hopp 2f825d
      sb->id = NULL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1866,1873 ****
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      if (shape == MSHAPE_HIDE || gui.pointer_hidden)
Karsten Hopp 2f825d
! 	PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
Karsten Hopp 2f825d
! 		0 );
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	if (shape >= MSHAPE_NUMBERED)
Karsten Hopp 2f825d
--- 1866,1873 ----
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      if (shape == MSHAPE_HIDE || gui.pointer_hidden)
Karsten Hopp 2f825d
! 	PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
Karsten Hopp 2f825d
! 		0);
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	if (shape >= MSHAPE_NUMBERED)
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1875,1881 ****
Karsten Hopp 2f825d
  	else
Karsten Hopp 2f825d
  	    id = mshape_ids[shape];
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE, id,	0 );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      if (shape != MSHAPE_HIDE)
Karsten Hopp 2f825d
  	last_shape = shape;
Karsten Hopp 2f825d
--- 1875,1881 ----
Karsten Hopp 2f825d
  	else
Karsten Hopp 2f825d
  	    id = mshape_ids[shape];
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, id,	0);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      if (shape != MSHAPE_HIDE)
Karsten Hopp 2f825d
  	last_shape = shape;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1885,1903 ****
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_mousehide(int hide)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if( gui.pointer_hidden != hide )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	gui.pointer_hidden = hide;
Karsten Hopp 2f825d
  #ifdef FEAT_MOUSESHAPE
Karsten Hopp 2f825d
! 	if( hide )
Karsten Hopp 2f825d
! 	    PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
Karsten Hopp 2f825d
! 		    Ph_CURSOR_NONE, 0 );
Karsten Hopp 2f825d
  	else
Karsten Hopp 2f825d
! 	    mch_set_mouse_shape( last_shape );
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
! 	PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
Karsten Hopp 2f825d
! 		( hide == MOUSE_SHOW ) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE,
Karsten Hopp 2f825d
! 		0 );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
--- 1885,1903 ----
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_mousehide(int hide)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if (gui.pointer_hidden != hide)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	gui.pointer_hidden = hide;
Karsten Hopp 2f825d
  #ifdef FEAT_MOUSESHAPE
Karsten Hopp 2f825d
! 	if (hide)
Karsten Hopp 2f825d
! 	    PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
Karsten Hopp 2f825d
! 		    Ph_CURSOR_NONE, 0);
Karsten Hopp 2f825d
  	else
Karsten Hopp 2f825d
! 	    mch_set_mouse_shape(last_shape);
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
! 	PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
Karsten Hopp 2f825d
! 		(hide == MOUSE_SHOW) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE,
Karsten Hopp 2f825d
! 		0);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1910,1917 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* FIXME: does this return the correct position,
Karsten Hopp 2f825d
       * with respect to the border? */
Karsten Hopp 2f825d
!     PhQueryCursor( PhInputGroup( NULL ), &info );
Karsten Hopp 2f825d
!     PtGetAbsPosition( gui.vimTextArea , &ix, &iy );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      *x = info.pos.x - ix;
Karsten Hopp 2f825d
      *y = info.pos.y - iy;
Karsten Hopp 2f825d
--- 1910,1917 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* FIXME: does this return the correct position,
Karsten Hopp 2f825d
       * with respect to the border? */
Karsten Hopp 2f825d
!     PhQueryCursor(PhInputGroup(NULL), &info;;
Karsten Hopp 2f825d
!     PtGetAbsPosition(gui.vimTextArea , &ix, &iy;;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      *x = info.pos.x - ix;
Karsten Hopp 2f825d
      *y = info.pos.y - iy;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1922,1930 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      short abs_x, abs_y;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtGetAbsPosition( gui.vimTextArea, &abs_x, &abs_y );
Karsten Hopp 2f825d
      /* Add the border offset? */
Karsten Hopp 2f825d
!     PhMoveCursorAbs( PhInputGroup( NULL ), abs_x + x, abs_y + y );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /****************************************************************************/
Karsten Hopp 2f825d
--- 1922,1930 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      short abs_x, abs_y;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtGetAbsPosition(gui.vimTextArea, &abs_x, &abs_y);
Karsten Hopp 2f825d
      /* Add the border offset? */
Karsten Hopp 2f825d
!     PhMoveCursorAbs(PhInputGroup(NULL), abs_x + x, abs_y + y);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /****************************************************************************/
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 1952,1974 ****
Karsten Hopp 2f825d
      color_diff = gui_get_lightness(gui_ph_mouse_color)
Karsten Hopp 2f825d
  					  - gui_get_lightness(gui.back_pixel);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( abs( color_diff ) < 64 )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	short r, g, b;
Karsten Hopp 2f825d
  	/* not a great algorithm... */
Karsten Hopp 2f825d
! 	r = PgRedValue( gui_ph_mouse_color ) ^ 255;
Karsten Hopp 2f825d
! 	g = PgGreenValue( gui_ph_mouse_color ) ^ 255;
Karsten Hopp 2f825d
! 	b = PgBlueValue( gui_ph_mouse_color ) ^ 255;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifndef FEAT_MOUSESHAPE
Karsten Hopp 2f825d
! 	gui_ph_mouse_color = PgRGB( r, g, b );
Karsten Hopp 2f825d
! 	PtSetResource( gui.vimTextArea, Pt_ARG_CURSOR_COLOR,
Karsten Hopp 2f825d
! 		gui_ph_mouse_color, 0 );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource( gui.vimTextArea, Pt_ARG_FILL_COLOR, gui.back_pixel, 0 );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
--- 1952,1974 ----
Karsten Hopp 2f825d
      color_diff = gui_get_lightness(gui_ph_mouse_color)
Karsten Hopp 2f825d
  					  - gui_get_lightness(gui.back_pixel);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (abs(color_diff) < 64)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	short r, g, b;
Karsten Hopp 2f825d
  	/* not a great algorithm... */
Karsten Hopp 2f825d
! 	r = PgRedValue(gui_ph_mouse_color) ^ 255;
Karsten Hopp 2f825d
! 	g = PgGreenValue(gui_ph_mouse_color) ^ 255;
Karsten Hopp 2f825d
! 	b = PgBlueValue(gui_ph_mouse_color) ^ 255;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifndef FEAT_MOUSESHAPE
Karsten Hopp 2f825d
! 	gui_ph_mouse_color = PgRGB(r, g, b);
Karsten Hopp 2f825d
! 	PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_COLOR,
Karsten Hopp 2f825d
! 		gui_ph_mouse_color, 0);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource(gui.vimTextArea, Pt_ARG_FILL_COLOR, gui.back_pixel, 0);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      static int
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2058,2076 ****
Karsten Hopp 2f825d
      };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* is name #rrggbb format? */
Karsten Hopp 2f825d
!     if( name[0] == '#' && STRLEN( name ) == 7 )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	r = hex_digit( name[1] ) * 16 + hex_digit( name[2] );
Karsten Hopp 2f825d
! 	g = hex_digit( name[3] ) * 16 + hex_digit( name[4] );
Karsten Hopp 2f825d
! 	b = hex_digit( name[5] ) * 16 + hex_digit( name[6] );
Karsten Hopp 2f825d
! 	if( r < 0 || g < 0 || b < 0 )
Karsten Hopp 2f825d
  	    return INVALCOLOR;
Karsten Hopp 2f825d
  	return RGB(r, g, b);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     for( i = 0; i < ARRAY_LENGTH( table ); i++ )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if( STRICMP( name, table[i].name ) == 0 )
Karsten Hopp 2f825d
  	    return table[i].colour;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2058,2076 ----
Karsten Hopp 2f825d
      };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* is name #rrggbb format? */
Karsten Hopp 2f825d
!     if (name[0] == '#' && STRLEN(name) == 7)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	r = hex_digit(name[1]) * 16 + hex_digit(name[2]);
Karsten Hopp 2f825d
! 	g = hex_digit(name[3]) * 16 + hex_digit(name[4]);
Karsten Hopp 2f825d
! 	b = hex_digit(name[5]) * 16 + hex_digit(name[6]);
Karsten Hopp 2f825d
! 	if (r < 0 || g < 0 || b < 0)
Karsten Hopp 2f825d
  	    return INVALCOLOR;
Karsten Hopp 2f825d
  	return RGB(r, g, b);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     for (i = 0; i < ARRAY_LENGTH(table); i++)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (STRICMP(name, table[i].name) == 0)
Karsten Hopp 2f825d
  	    return table[i].colour;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2129,2141 ****
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_set_fg_color(guicolor_T color)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PgSetTextColor( color );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_set_bg_color(guicolor_T color)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PgSetFillColor( color );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 2129,2141 ----
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_set_fg_color(guicolor_T color)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PgSetTextColor(color);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_set_bg_color(guicolor_T color)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PgSetFillColor(color);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2148,2168 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhRect_t rect;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.ul.x = FILL_X( col );
Karsten Hopp 2f825d
!     rect.ul.y = FILL_Y( row );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* FIXME: This has an off by one pixel problem */
Karsten Hopp 2f825d
      rect.lr.x = rect.ul.x + nc * gui.char_width;
Karsten Hopp 2f825d
      rect.lr.y = rect.ul.y + nr * gui.char_height;
Karsten Hopp 2f825d
!     if( nc > 0 )
Karsten Hopp 2f825d
  	rect.lr.x -= 1;
Karsten Hopp 2f825d
!     if( nr > 0 )
Karsten Hopp 2f825d
  	rect.lr.y -= 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     PgSetDrawMode( Pg_DrawModeDSTINVERT );
Karsten Hopp 2f825d
!     PgDrawRect( &rect, Pg_DRAW_FILL );
Karsten Hopp 2f825d
!     PgSetDrawMode( Pg_DrawModeSRCCOPY );
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2148,2168 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhRect_t rect;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.ul.x = FILL_X(col);
Karsten Hopp 2f825d
!     rect.ul.y = FILL_Y(row);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* FIXME: This has an off by one pixel problem */
Karsten Hopp 2f825d
      rect.lr.x = rect.ul.x + nc * gui.char_width;
Karsten Hopp 2f825d
      rect.lr.y = rect.ul.y + nr * gui.char_height;
Karsten Hopp 2f825d
!     if (nc > 0)
Karsten Hopp 2f825d
  	rect.lr.x -= 1;
Karsten Hopp 2f825d
!     if (nr > 0)
Karsten Hopp 2f825d
  	rect.lr.y -= 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     PgSetDrawMode(Pg_DrawModeDSTINVERT);
Karsten Hopp 2f825d
!     PgDrawRect(&rect, Pg_DRAW_FILL);
Karsten Hopp 2f825d
!     PgSetDrawMode(Pg_DrawModeSRCCOPY);
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2170,2182 ****
Karsten Hopp 2f825d
  gui_mch_clear_block(int row1, int col1, int row2, int col2)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhRect_t block = {
Karsten Hopp 2f825d
! 	{ FILL_X( col1 ), FILL_Y( row1 ) },
Karsten Hopp 2f825d
! 	{ FILL_X( col2 + 1 ) - 1, FILL_Y( row2 + 1 ) - 1}
Karsten Hopp 2f825d
      };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     gui_mch_set_bg_color( gui.back_pixel );
Karsten Hopp 2f825d
!     PgDrawRect( &block, Pg_DRAW_FILL );
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2170,2182 ----
Karsten Hopp 2f825d
  gui_mch_clear_block(int row1, int col1, int row2, int col2)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhRect_t block = {
Karsten Hopp 2f825d
! 	{ FILL_X(col1), FILL_Y(row1) },
Karsten Hopp 2f825d
! 	{ FILL_X(col2 + 1) - 1, FILL_Y(row2 + 1) - 1}
Karsten Hopp 2f825d
      };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     gui_mch_set_bg_color(gui.back_pixel);
Karsten Hopp 2f825d
!     PgDrawRect(&block, Pg_DRAW_FILL);
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2189,2200 ****
Karsten Hopp 2f825d
  	    Rows * gui.char_height + gui.border_width - 1 }
Karsten Hopp 2f825d
      };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( is_ignore_draw == TRUE )
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     gui_mch_set_bg_color( gui.back_pixel );
Karsten Hopp 2f825d
!     PgDrawRect( &text_rect, Pg_DRAW_FILL );
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2189,2200 ----
Karsten Hopp 2f825d
  	    Rows * gui.char_height + gui.border_width - 1 }
Karsten Hopp 2f825d
      };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (is_ignore_draw == TRUE)
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     gui_mch_set_bg_color(gui.back_pixel);
Karsten Hopp 2f825d
!     PgDrawRect(&text_rect, Pg_DRAW_FILL);
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2204,2231 ****
Karsten Hopp 2f825d
      PhRect_t    rect;
Karsten Hopp 2f825d
      PhPoint_t   delta;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.ul.x = FILL_X( gui.scroll_region_left );
Karsten Hopp 2f825d
!     rect.ul.y = FILL_Y( row + num_lines );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.lr.x = FILL_X( gui.scroll_region_right + 1 ) - 1;
Karsten Hopp 2f825d
!     rect.lr.y = FILL_Y( gui.scroll_region_bot + 1) - 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset );
Karsten Hopp 2f825d
!     PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL));
Karsten Hopp 2f825d
!     PhTranslateRect( &rect, &gui_ph_raw_offset );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      delta.x = 0;
Karsten Hopp 2f825d
      delta.y = -num_lines * gui.char_height;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      PgFlush();
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PhBlit( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ), &rect, &delta );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gui_clear_block(
Karsten Hopp 2f825d
  	gui.scroll_region_bot - num_lines + 1,
Karsten Hopp 2f825d
  	gui.scroll_region_left,
Karsten Hopp 2f825d
  	gui.scroll_region_bot,
Karsten Hopp 2f825d
! 	gui.scroll_region_right );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 2204,2231 ----
Karsten Hopp 2f825d
      PhRect_t    rect;
Karsten Hopp 2f825d
      PhPoint_t   delta;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.ul.x = FILL_X(gui.scroll_region_left);
Karsten Hopp 2f825d
!     rect.ul.y = FILL_Y(row + num_lines);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1;
Karsten Hopp 2f825d
!     rect.lr.y = FILL_Y(gui.scroll_region_bot + 1) - 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset);
Karsten Hopp 2f825d
!     PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL));
Karsten Hopp 2f825d
!     PhTranslateRect(&rect, &gui_ph_raw_offset);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      delta.x = 0;
Karsten Hopp 2f825d
      delta.y = -num_lines * gui.char_height;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      PgFlush();
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)), &rect, &delta);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gui_clear_block(
Karsten Hopp 2f825d
  	gui.scroll_region_bot - num_lines + 1,
Karsten Hopp 2f825d
  	gui.scroll_region_left,
Karsten Hopp 2f825d
  	gui.scroll_region_bot,
Karsten Hopp 2f825d
! 	gui.scroll_region_right);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2234,2258 ****
Karsten Hopp 2f825d
      PhRect_t    rect;
Karsten Hopp 2f825d
      PhPoint_t   delta;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.ul.x = FILL_X( gui.scroll_region_left );
Karsten Hopp 2f825d
!     rect.ul.y = FILL_Y( row );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.lr.x = FILL_X( gui.scroll_region_right + 1 ) - 1;
Karsten Hopp 2f825d
!     rect.lr.y = FILL_Y( gui.scroll_region_bot - num_lines + 1 ) - 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset );
Karsten Hopp 2f825d
!     PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos( gui.vimTextArea, NULL ) );
Karsten Hopp 2f825d
!     PhTranslateRect( &rect, &gui_ph_raw_offset );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      delta.x = 0;
Karsten Hopp 2f825d
      delta.y = num_lines * gui.char_height;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      PgFlush();
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PhBlit( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) , &rect, &delta );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui_clear_block( row, gui.scroll_region_left,
Karsten Hopp 2f825d
! 	    row + num_lines - 1, gui.scroll_region_right );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 2234,2258 ----
Karsten Hopp 2f825d
      PhRect_t    rect;
Karsten Hopp 2f825d
      PhPoint_t   delta;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.ul.x = FILL_X(gui.scroll_region_left);
Karsten Hopp 2f825d
!     rect.ul.y = FILL_Y(row);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1;
Karsten Hopp 2f825d
!     rect.lr.y = FILL_Y(gui.scroll_region_bot - num_lines + 1) - 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset);
Karsten Hopp 2f825d
!     PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL));
Karsten Hopp 2f825d
!     PhTranslateRect(&rect, &gui_ph_raw_offset);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      delta.x = 0;
Karsten Hopp 2f825d
      delta.y = num_lines * gui.char_height;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      PgFlush();
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)) , &rect, &delta);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui_clear_block(row, gui.scroll_region_left,
Karsten Hopp 2f825d
! 	    row + num_lines - 1, gui.scroll_region_right);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2261,2297 ****
Karsten Hopp 2f825d
      static char *utf8_buffer = NULL;
Karsten Hopp 2f825d
      static int	utf8_len = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PhPoint_t	pos = { TEXT_X( col ), TEXT_Y( row ) };
Karsten Hopp 2f825d
      PhRect_t	rect;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( is_ignore_draw == TRUE )
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( !( flags & DRAW_TRANSP ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	PgDrawIRect(
Karsten Hopp 2f825d
! 		FILL_X( col ), FILL_Y( row ),
Karsten Hopp 2f825d
! 		FILL_X( col + len ) - 1, FILL_Y( row + 1 ) - 1,
Karsten Hopp 2f825d
! 		Pg_DRAW_FILL );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( flags & DRAW_UNDERL )
Karsten Hopp 2f825d
! 	PgSetUnderline( gui.norm_pixel, Pg_TRANSPARENT, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( charset_translate != NULL
Karsten Hopp 2f825d
  #ifdef FEAT_MBYTE
Karsten Hopp 2f825d
  	    && enc_utf8 == 0
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
! 	    )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	int src_taken, dst_made;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* Use a static buffer to avoid large amounts of de/allocations */
Karsten Hopp 2f825d
! 	if( utf8_len < len )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    utf8_buffer = realloc( utf8_buffer, len * MB_LEN_MAX );
Karsten Hopp 2f825d
  	    utf8_len = len;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2261,2297 ----
Karsten Hopp 2f825d
      static char *utf8_buffer = NULL;
Karsten Hopp 2f825d
      static int	utf8_len = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PhPoint_t	pos = { TEXT_X(col), TEXT_Y(row) };
Karsten Hopp 2f825d
      PhRect_t	rect;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (is_ignore_draw == TRUE)
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (!(flags & DRAW_TRANSP))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	PgDrawIRect(
Karsten Hopp 2f825d
! 		FILL_X(col), FILL_Y(row),
Karsten Hopp 2f825d
! 		FILL_X(col + len) - 1, FILL_Y(row + 1) - 1,
Karsten Hopp 2f825d
! 		Pg_DRAW_FILL);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (flags & DRAW_UNDERL)
Karsten Hopp 2f825d
! 	PgSetUnderline(gui.norm_pixel, Pg_TRANSPARENT, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (charset_translate != NULL
Karsten Hopp 2f825d
  #ifdef FEAT_MBYTE
Karsten Hopp 2f825d
  	    && enc_utf8 == 0
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
! 	   )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	int src_taken, dst_made;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* Use a static buffer to avoid large amounts of de/allocations */
Karsten Hopp 2f825d
! 	if (utf8_len < len)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    utf8_buffer = realloc(utf8_buffer, len * MB_LEN_MAX);
Karsten Hopp 2f825d
  	    utf8_len = len;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2302,2337 ****
Karsten Hopp 2f825d
  		&src_taken,
Karsten Hopp 2f825d
  		utf8_buffer,
Karsten Hopp 2f825d
  		utf8_len,
Karsten Hopp 2f825d
! 		&dst_made );
Karsten Hopp 2f825d
  	s = utf8_buffer;
Karsten Hopp 2f825d
  	len = dst_made;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PgDrawText( s, len, &pos, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( flags & DRAW_BOLD )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	/* FIXME: try and only calculate these values once... */
Karsten Hopp 2f825d
! 	rect.ul.x = FILL_X( col ) + 1;
Karsten Hopp 2f825d
! 	rect.ul.y = FILL_Y( row );
Karsten Hopp 2f825d
! 	rect.lr.x = FILL_X( col + len ) - 1;
Karsten Hopp 2f825d
! 	rect.lr.y = FILL_Y( row + 1) - 1;
Karsten Hopp 2f825d
! 	/* PgSetUserClip( NULL ) causes the scrollbar to not redraw... */
Karsten Hopp 2f825d
  #if 0
Karsten Hopp 2f825d
  	pos.x++;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PgSetUserClip( &rect );
Karsten Hopp 2f825d
! 	PgDrawText( s, len, &pos, 0 );
Karsten Hopp 2f825d
! 	PgSetUserClip( NULL );
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
! 	rect.lr.y -= ( p_linespace + 1 ) / 2;
Karsten Hopp 2f825d
  	/* XXX: DrawTextArea doesn't work with phditto */
Karsten Hopp 2f825d
! 	PgDrawTextArea( s, len, &rect, Pg_TEXT_BOTTOM );
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( flags & DRAW_UNDERL )
Karsten Hopp 2f825d
! 	PgSetUnderline( Pg_TRANSPARENT, Pg_TRANSPARENT, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
--- 2302,2337 ----
Karsten Hopp 2f825d
  		&src_taken,
Karsten Hopp 2f825d
  		utf8_buffer,
Karsten Hopp 2f825d
  		utf8_len,
Karsten Hopp 2f825d
! 		&dst_made);
Karsten Hopp 2f825d
  	s = utf8_buffer;
Karsten Hopp 2f825d
  	len = dst_made;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PgDrawText(s, len, &pos, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (flags & DRAW_BOLD)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	/* FIXME: try and only calculate these values once... */
Karsten Hopp 2f825d
! 	rect.ul.x = FILL_X(col) + 1;
Karsten Hopp 2f825d
! 	rect.ul.y = FILL_Y(row);
Karsten Hopp 2f825d
! 	rect.lr.x = FILL_X(col + len) - 1;
Karsten Hopp 2f825d
! 	rect.lr.y = FILL_Y(row + 1) - 1;
Karsten Hopp 2f825d
! 	/* PgSetUserClip(NULL) causes the scrollbar to not redraw... */
Karsten Hopp 2f825d
  #if 0
Karsten Hopp 2f825d
  	pos.x++;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PgSetUserClip(&rect);
Karsten Hopp 2f825d
! 	PgDrawText(s, len, &pos, 0);
Karsten Hopp 2f825d
! 	PgSetUserClip(NULL);
Karsten Hopp 2f825d
  #else
Karsten Hopp 2f825d
! 	rect.lr.y -= (p_linespace + 1) / 2;
Karsten Hopp 2f825d
  	/* XXX: DrawTextArea doesn't work with phditto */
Karsten Hopp 2f825d
! 	PgDrawTextArea(s, len, &rect, Pg_TEXT_BOTTOM);
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (flags & DRAW_UNDERL)
Karsten Hopp 2f825d
! 	PgSetUnderline(Pg_TRANSPARENT, Pg_TRANSPARENT, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2346,2359 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* FIXME: Double width characters */
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     r.ul.x = FILL_X( gui.col );
Karsten Hopp 2f825d
!     r.ul.y = FILL_Y( gui.row );
Karsten Hopp 2f825d
      r.lr.x = r.ul.x + gui.char_width - 1;
Karsten Hopp 2f825d
      r.lr.y = r.ul.y + gui.char_height - 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     PgSetStrokeColor( color );
Karsten Hopp 2f825d
!     PgDrawRect( &r, Pg_DRAW_STROKE );
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2346,2359 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* FIXME: Double width characters */
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     r.ul.x = FILL_X(gui.col);
Karsten Hopp 2f825d
!     r.ul.y = FILL_Y(gui.row);
Karsten Hopp 2f825d
      r.lr.x = r.ul.x + gui.char_width - 1;
Karsten Hopp 2f825d
      r.lr.y = r.ul.y + gui.char_height - 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     PgSetStrokeColor(color);
Karsten Hopp 2f825d
!     PgDrawRect(&r, Pg_DRAW_STROKE);
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2362,2375 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhRect_t r;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     r.ul.x = FILL_X( gui.col );
Karsten Hopp 2f825d
!     r.ul.y = FILL_Y( gui.row ) + gui.char_height - h;
Karsten Hopp 2f825d
      r.lr.x = r.ul.x + w - 1;
Karsten Hopp 2f825d
      r.lr.y = r.ul.y + h - 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     gui_mch_set_bg_color( color );
Karsten Hopp 2f825d
!     PgDrawRect( &r, Pg_DRAW_FILL );
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2362,2375 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhRect_t r;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     r.ul.x = FILL_X(gui.col);
Karsten Hopp 2f825d
!     r.ul.y = FILL_Y(gui.row) + gui.char_height - h;
Karsten Hopp 2f825d
      r.lr.x = r.ul.x + w - 1;
Karsten Hopp 2f825d
      r.lr.y = r.ul.y + h - 1;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      DRAW_START;
Karsten Hopp 2f825d
!     gui_mch_set_bg_color(color);
Karsten Hopp 2f825d
!     PgDrawRect(&r, Pg_DRAW_FILL);
Karsten Hopp 2f825d
      DRAW_END;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2385,2394 ****
Karsten Hopp 2f825d
  gui_mch_start_blink(void)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      /* Only turn on the timer on if none of the times are zero */
Karsten Hopp 2f825d
!     if( blink_waittime && blink_ontime && blink_offtime && gui.in_focus)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
Karsten Hopp 2f825d
! 		blink_waittime, 0 );
Karsten Hopp 2f825d
  	blink_state = BLINK_ON;
Karsten Hopp 2f825d
  	gui_update_cursor(TRUE, FALSE);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
--- 2385,2394 ----
Karsten Hopp 2f825d
  gui_mch_start_blink(void)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      /* Only turn on the timer on if none of the times are zero */
Karsten Hopp 2f825d
!     if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
Karsten Hopp 2f825d
! 		blink_waittime, 0);
Karsten Hopp 2f825d
  	blink_state = BLINK_ON;
Karsten Hopp 2f825d
  	gui_update_cursor(TRUE, FALSE);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2397,2405 ****
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_stop_blink(void)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( blink_state == BLINK_OFF )
Karsten Hopp 2f825d
  	gui_update_cursor(TRUE, FALSE);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      blink_state = BLINK_NONE;
Karsten Hopp 2f825d
--- 2397,2405 ----
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_stop_blink(void)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (blink_state == BLINK_OFF)
Karsten Hopp 2f825d
  	gui_update_cursor(TRUE, FALSE);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      blink_state = BLINK_NONE;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2417,2431 ****
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_flash(int msec)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PgSetFillXORColor( Pg_BLACK, Pg_WHITE );
Karsten Hopp 2f825d
!     PgSetDrawMode( Pg_DRAWMODE_XOR );
Karsten Hopp 2f825d
      gui_mch_clear_all();
Karsten Hopp 2f825d
      gui_mch_flush();
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     ui_delay( (long) msec, TRUE );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gui_mch_clear_all();
Karsten Hopp 2f825d
!     PgSetDrawMode( Pg_DRAWMODE_OPAQUE );
Karsten Hopp 2f825d
      gui_mch_flush();
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2417,2431 ----
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_flash(int msec)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PgSetFillXORColor(Pg_BLACK, Pg_WHITE);
Karsten Hopp 2f825d
!     PgSetDrawMode(Pg_DRAWMODE_XOR);
Karsten Hopp 2f825d
      gui_mch_clear_all();
Karsten Hopp 2f825d
      gui_mch_flush();
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     ui_delay((long) msec, TRUE);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gui_mch_clear_all();
Karsten Hopp 2f825d
!     PgSetDrawMode(Pg_DRAWMODE_OPAQUE);
Karsten Hopp 2f825d
      gui_mch_flush();
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2440,2446 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhArea_t area = {{x, y}, {w, h}};
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource( gui.vimTextArea, Pt_ARG_AREA, &area, 0 );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      int
Karsten Hopp 2f825d
--- 2440,2446 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PhArea_t area = {{x, y}, {w, h}};
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource(gui.vimTextArea, Pt_ARG_AREA, &area, 0);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      int
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2496,2514 ****
Karsten Hopp 2f825d
  };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  static PhImage_t *
Karsten Hopp 2f825d
! gui_ph_toolbar_load_icon( char_u *iconfile )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      static PhImage_t external_icon;
Karsten Hopp 2f825d
      PhImage_t *temp_phi = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     temp_phi = PxLoadImage( iconfile, NULL );
Karsten Hopp 2f825d
!     if( temp_phi != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	/* The label widget will free the image/palette/etc. for us when
Karsten Hopp 2f825d
  	 * it's destroyed */
Karsten Hopp 2f825d
  	temp_phi->flags |= Ph_RELEASE_IMAGE_ALL;
Karsten Hopp 2f825d
! 	memcpy( &external_icon, temp_phi, sizeof( external_icon ) );
Karsten Hopp 2f825d
! 	free( temp_phi );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	temp_phi = &external_icon;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
--- 2496,2514 ----
Karsten Hopp 2f825d
  };
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  static PhImage_t *
Karsten Hopp 2f825d
! gui_ph_toolbar_load_icon(char_u *iconfile)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      static PhImage_t external_icon;
Karsten Hopp 2f825d
      PhImage_t *temp_phi = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     temp_phi = PxLoadImage(iconfile, NULL);
Karsten Hopp 2f825d
!     if (temp_phi != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	/* The label widget will free the image/palette/etc. for us when
Karsten Hopp 2f825d
  	 * it's destroyed */
Karsten Hopp 2f825d
  	temp_phi->flags |= Ph_RELEASE_IMAGE_ALL;
Karsten Hopp 2f825d
! 	memcpy(&external_icon, temp_phi, sizeof(external_icon));
Karsten Hopp 2f825d
! 	free(temp_phi);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	temp_phi = &external_icon;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2523,2551 ****
Karsten Hopp 2f825d
   * PhImage_t are copied, and the original PhImage_t aren't needed anymore).
Karsten Hopp 2f825d
   */
Karsten Hopp 2f825d
  static PhImage_t *
Karsten Hopp 2f825d
! gui_ph_toolbar_find_icon( vimmenu_T *menu )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      char_u full_pathname[ MAXPATHL + 1 ];
Karsten Hopp 2f825d
      PhImage_t *icon = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( menu->icon_builtin == FALSE )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if( menu->iconfile != NULL )
Karsten Hopp 2f825d
  	    /* TODO: use gui_find_iconfile() */
Karsten Hopp 2f825d
! 	    icon = gui_ph_toolbar_load_icon( menu->iconfile );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* TODO: Restrict loading to just .png? Search for any format? */
Karsten Hopp 2f825d
! 	if( ( icon == NULL ) &&
Karsten Hopp 2f825d
! 	    ( ( gui_find_bitmap( menu->name, full_pathname, "gif" ) == OK ) ||
Karsten Hopp 2f825d
! 	      ( gui_find_bitmap( menu->name, full_pathname, "png" ) == OK ) ) )
Karsten Hopp 2f825d
! 	    icon = gui_ph_toolbar_load_icon( full_pathname );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if( icon != NULL )
Karsten Hopp 2f825d
  	    return icon;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( menu->iconidx >= 0 &&
Karsten Hopp 2f825d
! 	    ( menu->iconidx < ARRAY_LENGTH( gui_ph_toolbar_images ) ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	return gui_ph_toolbar_images[menu->iconidx];
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
--- 2523,2551 ----
Karsten Hopp 2f825d
   * PhImage_t are copied, and the original PhImage_t aren't needed anymore).
Karsten Hopp 2f825d
   */
Karsten Hopp 2f825d
  static PhImage_t *
Karsten Hopp 2f825d
! gui_ph_toolbar_find_icon(vimmenu_T *menu)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      char_u full_pathname[ MAXPATHL + 1 ];
Karsten Hopp 2f825d
      PhImage_t *icon = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (menu->icon_builtin == FALSE)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (menu->iconfile != NULL)
Karsten Hopp 2f825d
  	    /* TODO: use gui_find_iconfile() */
Karsten Hopp 2f825d
! 	    icon = gui_ph_toolbar_load_icon(menu->iconfile);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* TODO: Restrict loading to just .png? Search for any format? */
Karsten Hopp 2f825d
! 	if ((icon == NULL) &&
Karsten Hopp 2f825d
! 	    ((gui_find_bitmap(menu->name, full_pathname, "gif") == OK) ||
Karsten Hopp 2f825d
! 	      (gui_find_bitmap(menu->name, full_pathname, "png") == OK)))
Karsten Hopp 2f825d
! 	    icon = gui_ph_toolbar_load_icon(full_pathname);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if (icon != NULL)
Karsten Hopp 2f825d
  	    return icon;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (menu->iconidx >= 0 &&
Karsten Hopp 2f825d
! 	    (menu->iconidx < ARRAY_LENGTH(gui_ph_toolbar_images)))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	return gui_ph_toolbar_images[menu->iconidx];
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2554,2567 ****
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! #if defined( FEAT_MENU ) || defined( PROTO )
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_enable_menu(int flag)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if( flag != 0 )
Karsten Hopp 2f825d
! 	PtRealizeWidget( gui.vimMenuBar );
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
! 	PtUnrealizeWidget( gui.vimMenuBar );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 2554,2567 ----
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! #if defined(FEAT_MENU) || defined(PROTO)
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_enable_menu(int flag)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if (flag != 0)
Karsten Hopp 2f825d
! 	PtRealizeWidget(gui.vimMenuBar);
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
! 	PtUnrealizeWidget(gui.vimMenuBar);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2572,2601 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /* Change the position of a menu button in the parent */
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_position_menu( PtWidget_t *widget, int priority )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PtWidget_t	*traverse;
Karsten Hopp 2f825d
      vimmenu_T	*menu;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     traverse = PtWidgetChildBack( PtWidgetParent( widget ) );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Iterate through the list of widgets in traverse, until
Karsten Hopp 2f825d
       * we find the position we want to insert our widget into */
Karsten Hopp 2f825d
      /* TODO: traverse from front to back, possible speedup? */
Karsten Hopp 2f825d
!     while( traverse != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	PtGetResource( traverse, Pt_ARG_POINTER, &menu, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if( menu != NULL &&
Karsten Hopp 2f825d
  		priority < menu->priority &&
Karsten Hopp 2f825d
! 		widget != traverse )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    /* Insert the widget before the current traverse widget */
Karsten Hopp 2f825d
! 	    PtWidgetInsert( widget, traverse, 1 );
Karsten Hopp 2f825d
  	    return;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	traverse = PtWidgetBrotherInFront( traverse );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2572,2601 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  /* Change the position of a menu button in the parent */
Karsten Hopp 2f825d
      static void
Karsten Hopp 2f825d
! gui_ph_position_menu(PtWidget_t *widget, int priority)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      PtWidget_t	*traverse;
Karsten Hopp 2f825d
      vimmenu_T	*menu;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     traverse = PtWidgetChildBack(PtWidgetParent(widget));
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* Iterate through the list of widgets in traverse, until
Karsten Hopp 2f825d
       * we find the position we want to insert our widget into */
Karsten Hopp 2f825d
      /* TODO: traverse from front to back, possible speedup? */
Karsten Hopp 2f825d
!     while (traverse != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	PtGetResource(traverse, Pt_ARG_POINTER, &menu, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if (menu != NULL &&
Karsten Hopp 2f825d
  		priority < menu->priority &&
Karsten Hopp 2f825d
! 		widget != traverse)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    /* Insert the widget before the current traverse widget */
Karsten Hopp 2f825d
! 	    PtWidgetInsert(widget, traverse, 1);
Karsten Hopp 2f825d
  	    return;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	traverse = PtWidgetBrotherInFront(traverse);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2611,2621 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      menu->submenu_id = menu->id = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( menu_is_menubar( menu->name ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	accel_key = vim_strchr( menu->name, '&' );
Karsten Hopp 2f825d
! 	if( accel_key != NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    mnemonic_str[0] = accel_key[1];
Karsten Hopp 2f825d
  	    mnemonic_str[1] = NUL;
Karsten Hopp 2f825d
--- 2611,2621 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      menu->submenu_id = menu->id = NULL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (menu_is_menubar(menu->name))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	accel_key = vim_strchr(menu->name, '&';;
Karsten Hopp 2f825d
! 	if (accel_key != NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    mnemonic_str[0] = accel_key[1];
Karsten Hopp 2f825d
  	    mnemonic_str[1] = NUL;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2623,2673 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* Create the menu button */
Karsten Hopp 2f825d
  	n = 0;
Karsten Hopp 2f825d
! 	PtSetArg( &args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0 );
Karsten Hopp 2f825d
! 	PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0 );
Karsten Hopp 2f825d
! 	if( accel_key != NULL )
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, 0 );
Karsten Hopp 2f825d
! 	PtSetArg( &args[ n++ ], Pt_ARG_POINTER, menu, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if( parent != NULL )
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	menu->id = PtCreateWidget( PtMenuButton,
Karsten Hopp 2f825d
  		(parent == NULL) ? gui.vimMenuBar : parent->submenu_id,
Karsten Hopp 2f825d
! 		n, args );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtAddCallback( menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* Create the actual menu */
Karsten Hopp 2f825d
  	n = 0;
Karsten Hopp 2f825d
! 	if( parent != NULL )
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	menu->submenu_id = PtCreateWidget( PtMenu, menu->id, n, args );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if( parent == NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtAddCallback( menu->submenu_id, Pt_CB_UNREALIZED,
Karsten Hopp 2f825d
! 		    gui_ph_handle_menu_unrealized, menu );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if( menu->mnemonic != 0 )
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		PtAddHotkeyHandler( gui.vimWindow, tolower( menu->mnemonic ),
Karsten Hopp 2f825d
! 			Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu );
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	gui_ph_position_menu( menu->id, menu->priority );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* Redraw menubar here instead of gui_mch_draw_menubar */
Karsten Hopp 2f825d
! 	if( gui.menu_is_active )
Karsten Hopp 2f825d
! 	    PtRealizeWidget( menu->id );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
!     else if( menu_is_popup( menu->name ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	menu->submenu_id = PtCreateWidget( PtMenu, gui.vimWindow, 0, NULL );
Karsten Hopp 2f825d
! 	PtAddCallback( menu->submenu_id, Pt_CB_UNREALIZED,
Karsten Hopp 2f825d
! 		gui_ph_handle_menu_unrealized, menu );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2623,2673 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* Create the menu button */
Karsten Hopp 2f825d
  	n = 0;
Karsten Hopp 2f825d
! 	PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0);
Karsten Hopp 2f825d
! 	PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0);
Karsten Hopp 2f825d
! 	if (accel_key != NULL)
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, 0);
Karsten Hopp 2f825d
! 	PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if (parent != NULL)
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	menu->id = PtCreateWidget(PtMenuButton,
Karsten Hopp 2f825d
  		(parent == NULL) ? gui.vimMenuBar : parent->submenu_id,
Karsten Hopp 2f825d
! 		n, args);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtAddCallback(menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* Create the actual menu */
Karsten Hopp 2f825d
  	n = 0;
Karsten Hopp 2f825d
! 	if (parent != NULL)
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	menu->submenu_id = PtCreateWidget(PtMenu, menu->id, n, args);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	if (parent == NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED,
Karsten Hopp 2f825d
! 		    gui_ph_handle_menu_unrealized, menu);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if (menu->mnemonic != 0)
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		PtAddHotkeyHandler(gui.vimWindow, tolower(menu->mnemonic),
Karsten Hopp 2f825d
! 			Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu);
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	gui_ph_position_menu(menu->id, menu->priority);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	/* Redraw menubar here instead of gui_mch_draw_menubar */
Karsten Hopp 2f825d
! 	if (gui.menu_is_active)
Karsten Hopp 2f825d
! 	    PtRealizeWidget(menu->id);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
!     else if (menu_is_popup(menu->name))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	menu->submenu_id = PtCreateWidget(PtMenu, gui.vimWindow, 0, NULL);
Karsten Hopp 2f825d
! 	PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED,
Karsten Hopp 2f825d
! 		gui_ph_handle_menu_unrealized, menu);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2681,2784 ****
Karsten Hopp 2f825d
      PtArg_t args[13];
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
!     PtSetArg( &args[ n++ ], Pt_ARG_POINTER, menu, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef FEAT_TOOLBAR
Karsten Hopp 2f825d
!     if( menu_is_toolbar( parent->name ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if( menu_is_separator( menu->name ) )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_SEP_FLAGS,
Karsten Hopp 2f825d
! 		    Pt_SEP_VERTICAL, Pt_SEP_ORIENTATION );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_SEP_TYPE, Pt_ETCHED_IN, 0 );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS,
Karsten Hopp 2f825d
! 		    Pt_TRUE, Pt_ANCHOR_TOP_BOTTOM );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, 2, 0 );
Karsten Hopp 2f825d
! 	    menu->id = PtCreateWidget( PtSeparator, gui.vimToolBar, n, args );
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  	else
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    if( strstr( (const char *) p_toolbar, "text" ) != NULL )
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		PtSetArg( &args[ n++ ], Pt_ARG_BALLOON_POSITION,
Karsten Hopp 2f825d
! 			Pt_BALLOON_BOTTOM, 0 );
Karsten Hopp 2f825d
! 		PtSetArg( &args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0 );
Karsten Hopp 2f825d
! 		PtSetArg( &args[ n++ ], Pt_ARG_TEXT_FONT, "TextFont08", 0 );
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
! 	    if( ( strstr( (const char *) p_toolbar, "icons" ) != NULL ) &&
Karsten Hopp 2f825d
! 		    ( gui_ph_toolbar_images != NULL ) )
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		PtSetArg( &args[ n++ ], Pt_ARG_LABEL_IMAGE,
Karsten Hopp 2f825d
! 			gui_ph_toolbar_find_icon( menu ), 0 );
Karsten Hopp 2f825d
! 		PtSetArg( &args[ n++ ], Pt_ARG_LABEL_TYPE, Pt_TEXT_IMAGE, 0 );
Karsten Hopp 2f825d
! 		PtSetArg( &args[ n++ ], Pt_ARG_TEXT_IMAGE_SPACING, 0, 0 );
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
! 	    if( strstr( (const char *) p_toolbar, "tooltips" ) != NULL )
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		PtSetArg( &args[ n++ ], Pt_ARG_LABEL_BALLOON,
Karsten Hopp 2f825d
! 			gui_ph_show_tooltip, 0 );
Karsten Hopp 2f825d
! 		PtSetArg( &args[ n++ ], Pt_ARG_LABEL_FLAGS,
Karsten Hopp 2f825d
! 			Pt_TRUE, Pt_SHOW_BALLOON );
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 1, 0 );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_WIDTH, 1, 0 );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_FALSE,
Karsten Hopp 2f825d
! 		    Pt_HIGHLIGHTED | Pt_GETS_FOCUS );
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 );
Karsten Hopp 2f825d
! 	    menu->id = PtCreateWidget( PtButton, gui.vimToolBar, n, args );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    PtAddCallback( menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu );
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  	/* Update toolbar if it's open */
Karsten Hopp 2f825d
! 	if( PtWidgetIsRealized( gui.vimToolBar ) )
Karsten Hopp 2f825d
! 	    PtRealizeWidget( menu->id );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
! 	if( menu_is_separator( menu->name ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	menu->id = PtCreateWidget( PtSeparator, parent->submenu_id, n, args );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	accel_key = vim_strchr( menu->name, '&' );
Karsten Hopp 2f825d
! 	if( accel_key != NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    mnemonic_str[0] = accel_key[1];
Karsten Hopp 2f825d
  	    mnemonic_str[1] = NUL;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtSetArg( &args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0 );
Karsten Hopp 2f825d
! 	if( accel_key != NULL )
Karsten Hopp 2f825d
! 	    PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str,
Karsten Hopp 2f825d
! 		    0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtSetArg( &args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	menu->id = PtCreateWidget( PtMenuButton, parent->submenu_id, n, args );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtAddCallback( menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
! 	if( gui_ph_is_buffer_item( menu, parent ) == TRUE )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtAddCallback( menu->id, Pt_CB_DESTROYED,
Karsten Hopp 2f825d
! 		    gui_ph_handle_buffer_remove, menu );
Karsten Hopp 2f825d
! 	    gui_ph_pg_add_buffer( menu->dname );
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui_ph_position_menu( menu->id, menu->priority );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_destroy_menu(vimmenu_T *menu)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if( menu->submenu_id != NULL )
Karsten Hopp 2f825d
! 	PtDestroyWidget( menu->submenu_id );
Karsten Hopp 2f825d
!     if( menu->id != NULL )
Karsten Hopp 2f825d
! 	PtDestroyWidget( menu->id );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      menu->submenu_id = NULL;
Karsten Hopp 2f825d
      menu->id = NULL;
Karsten Hopp 2f825d
--- 2681,2784 ----
Karsten Hopp 2f825d
      PtArg_t args[13];
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      n = 0;
Karsten Hopp 2f825d
!     PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef FEAT_TOOLBAR
Karsten Hopp 2f825d
!     if (menu_is_toolbar(parent->name))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (menu_is_separator(menu->name))
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_SEP_FLAGS,
Karsten Hopp 2f825d
! 		    Pt_SEP_VERTICAL, Pt_SEP_ORIENTATION);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_SEP_TYPE, Pt_ETCHED_IN, 0);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS,
Karsten Hopp 2f825d
! 		    Pt_TRUE, Pt_ANCHOR_TOP_BOTTOM);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, 2, 0);
Karsten Hopp 2f825d
! 	    menu->id = PtCreateWidget(PtSeparator, gui.vimToolBar, n, args);
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  	else
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    if (strstr((const char *) p_toolbar, "text") != NULL)
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		PtSetArg(&args[ n++ ], Pt_ARG_BALLOON_POSITION,
Karsten Hopp 2f825d
! 			Pt_BALLOON_BOTTOM, 0);
Karsten Hopp 2f825d
! 		PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0);
Karsten Hopp 2f825d
! 		PtSetArg(&args[ n++ ], Pt_ARG_TEXT_FONT, "TextFont08", 0);
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
! 	    if ((strstr((const char *) p_toolbar, "icons") != NULL) &&
Karsten Hopp 2f825d
! 		    (gui_ph_toolbar_images != NULL))
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		PtSetArg(&args[ n++ ], Pt_ARG_LABEL_IMAGE,
Karsten Hopp 2f825d
! 			gui_ph_toolbar_find_icon(menu), 0);
Karsten Hopp 2f825d
! 		PtSetArg(&args[ n++ ], Pt_ARG_LABEL_TYPE, Pt_TEXT_IMAGE, 0);
Karsten Hopp 2f825d
! 		PtSetArg(&args[ n++ ], Pt_ARG_TEXT_IMAGE_SPACING, 0, 0);
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
! 	    if (strstr((const char *) p_toolbar, "tooltips") != NULL)
Karsten Hopp 2f825d
  	    {
Karsten Hopp 2f825d
! 		PtSetArg(&args[ n++ ], Pt_ARG_LABEL_BALLOON,
Karsten Hopp 2f825d
! 			gui_ph_show_tooltip, 0);
Karsten Hopp 2f825d
! 		PtSetArg(&args[ n++ ], Pt_ARG_LABEL_FLAGS,
Karsten Hopp 2f825d
! 			Pt_TRUE, Pt_SHOW_BALLOON);
Karsten Hopp 2f825d
  	    }
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 1, 0);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 1, 0);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_FALSE,
Karsten Hopp 2f825d
! 		    Pt_HIGHLIGHTED | Pt_GETS_FOCUS);
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0);
Karsten Hopp 2f825d
! 	    menu->id = PtCreateWidget(PtButton, gui.vimToolBar, n, args);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu);
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  	/* Update toolbar if it's open */
Karsten Hopp 2f825d
! 	if (PtWidgetIsRealized(gui.vimToolBar))
Karsten Hopp 2f825d
! 	    PtRealizeWidget(menu->id);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
! 	if (menu_is_separator(menu->name))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	menu->id = PtCreateWidget(PtSeparator, parent->submenu_id, n, args);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	accel_key = vim_strchr(menu->name, '&';;
Karsten Hopp 2f825d
! 	if (accel_key != NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    mnemonic_str[0] = accel_key[1];
Karsten Hopp 2f825d
  	    mnemonic_str[1] = NUL;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0);
Karsten Hopp 2f825d
! 	if (accel_key != NULL)
Karsten Hopp 2f825d
! 	    PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str,
Karsten Hopp 2f825d
! 		    0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	menu->id = PtCreateWidget(PtMenuButton, parent->submenu_id, n, args);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #ifdef USE_PANEL_GROUP
Karsten Hopp 2f825d
! 	if (gui_ph_is_buffer_item(menu, parent) == TRUE)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    PtAddCallback(menu->id, Pt_CB_DESTROYED,
Karsten Hopp 2f825d
! 		    gui_ph_handle_buffer_remove, menu);
Karsten Hopp 2f825d
! 	    gui_ph_pg_add_buffer(menu->dname);
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui_ph_position_menu(menu->id, menu->priority);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_destroy_menu(vimmenu_T *menu)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if (menu->submenu_id != NULL)
Karsten Hopp 2f825d
! 	PtDestroyWidget(menu->submenu_id);
Karsten Hopp 2f825d
!     if (menu->id != NULL)
Karsten Hopp 2f825d
! 	PtDestroyWidget(menu->id);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      menu->submenu_id = NULL;
Karsten Hopp 2f825d
      menu->id = NULL;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2789,2800 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      long    flags, mask, fields;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( menu->id == NULL )
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     flags = PtWidgetFlags( menu->id );
Karsten Hopp 2f825d
!     if( PtWidgetIsClass( menu->id, PtMenuButton ) &&
Karsten Hopp 2f825d
! 	    PtWidgetIsClass( PtWidgetParent( menu->id ), PtMenu ) )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	fields = Pt_FALSE;
Karsten Hopp 2f825d
  	mask = Pt_SELECTABLE | Pt_HIGHLIGHTED;
Karsten Hopp 2f825d
--- 2789,2800 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      long    flags, mask, fields;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (menu->id == NULL)
Karsten Hopp 2f825d
  	return;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     flags = PtWidgetFlags(menu->id);
Karsten Hopp 2f825d
!     if (PtWidgetIsClass(menu->id, PtMenuButton) &&
Karsten Hopp 2f825d
! 	    PtWidgetIsClass(PtWidgetParent(menu->id), PtMenu))
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	fields = Pt_FALSE;
Karsten Hopp 2f825d
  	mask = Pt_SELECTABLE | Pt_HIGHLIGHTED;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2805,2815 ****
Karsten Hopp 2f825d
  	mask = Pt_BLOCKED | Pt_GHOST;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if( ! grey )
Karsten Hopp 2f825d
  	fields = ~fields;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource( menu->id, Pt_ARG_FLAGS, fields,
Karsten Hopp 2f825d
! 	    mask );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 2805,2815 ----
Karsten Hopp 2f825d
  	mask = Pt_BLOCKED | Pt_GHOST;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (! grey)
Karsten Hopp 2f825d
  	fields = ~fields;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PtSetResource(menu->id, Pt_ARG_FLAGS, fields,
Karsten Hopp 2f825d
! 	    mask);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2830,2837 ****
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_show_popupmenu(vimmenu_T *menu)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtSetResource( menu->submenu_id, Pt_ARG_POS, &abs_mouse, 0 );
Karsten Hopp 2f825d
!     PtRealizeWidget( menu->submenu_id );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
--- 2830,2837 ----
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_show_popupmenu(vimmenu_T *menu)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PtSetResource(menu->submenu_id, Pt_ARG_POS, &abs_mouse, 0);
Karsten Hopp 2f825d
!     PtRealizeWidget(menu->submenu_id);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2842,2855 ****
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! #if defined( FEAT_TOOLBAR ) || defined( PROTO )
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_show_toolbar(int showit)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if( showit )
Karsten Hopp 2f825d
! 	PtRealizeWidget( gui.vimToolBar );
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
! 	PtUnrealizeWidget( gui.vimToolBar );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2842,2855 ----
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! #if defined(FEAT_TOOLBAR) || defined(PROTO)
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_show_toolbar(int showit)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     if (showit)
Karsten Hopp 2f825d
! 	PtRealizeWidget(gui.vimToolBar);
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
! 	PtUnrealizeWidget(gui.vimToolBar);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  #endif
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2870,2903 ****
Karsten Hopp 2f825d
      FontQueryInfo   info;
Karsten Hopp 2f825d
      int_u	    style;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     font_tag = alloc( MAX_FONT_TAG );
Karsten Hopp 2f825d
!     if( font_tag != NULL )
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if( PfGenerateFontName( font_name, font_flags, font_size,
Karsten Hopp 2f825d
! 		    font_tag ) != NULL )
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    /* Enforce some limits on the font used */
Karsten Hopp 2f825d
  	    style = PHFONT_INFO_FIXED;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if( enforce & PF_STYLE_BOLD )
Karsten Hopp 2f825d
  		style |= PHFONT_INFO_BOLD;
Karsten Hopp 2f825d
! 	    if( enforce & PF_STYLE_ANTIALIAS )
Karsten Hopp 2f825d
  		style |= PHFONT_INFO_ALIAS;
Karsten Hopp 2f825d
! 	    if( enforce & PF_STYLE_ITALIC )
Karsten Hopp 2f825d
  		style |= PHFONT_INFO_ITALIC;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    PfQueryFontInfo( font_tag, &info );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if( info.size == 0 )
Karsten Hopp 2f825d
  		font_size = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    /* Make sure font size matches, and that the font style
Karsten Hopp 2f825d
  	     * at least has the bits we're checking for */
Karsten Hopp 2f825d
! 	    if( font_size == info.size &&
Karsten Hopp 2f825d
! 		    style == (info.style & style) )
Karsten Hopp 2f825d
  		return (GuiFont)font_tag;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
! 	vim_free( font_tag );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return NULL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
--- 2870,2903 ----
Karsten Hopp 2f825d
      FontQueryInfo   info;
Karsten Hopp 2f825d
      int_u	    style;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     font_tag = alloc(MAX_FONT_TAG);
Karsten Hopp 2f825d
!     if (font_tag != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (PfGenerateFontName(font_name, font_flags, font_size,
Karsten Hopp 2f825d
! 		    font_tag) != NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
  	    /* Enforce some limits on the font used */
Karsten Hopp 2f825d
  	    style = PHFONT_INFO_FIXED;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if (enforce & PF_STYLE_BOLD)
Karsten Hopp 2f825d
  		style |= PHFONT_INFO_BOLD;
Karsten Hopp 2f825d
! 	    if (enforce & PF_STYLE_ANTIALIAS)
Karsten Hopp 2f825d
  		style |= PHFONT_INFO_ALIAS;
Karsten Hopp 2f825d
! 	    if (enforce & PF_STYLE_ITALIC)
Karsten Hopp 2f825d
  		style |= PHFONT_INFO_ITALIC;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    PfQueryFontInfo(font_tag, &info;;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	    if (info.size == 0)
Karsten Hopp 2f825d
  		font_size = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	    /* Make sure font size matches, and that the font style
Karsten Hopp 2f825d
  	     * at least has the bits we're checking for */
Karsten Hopp 2f825d
! 	    if (font_size == info.size &&
Karsten Hopp 2f825d
! 		    style == (info.style & style))
Karsten Hopp 2f825d
  		return (GuiFont)font_tag;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
! 	vim_free(font_tag);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      return NULL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2919,2936 ****
Karsten Hopp 2f825d
  	char_u *vim_font,
Karsten Hopp 2f825d
  	char_u **font_name,
Karsten Hopp 2f825d
  	int_u *font_flags,
Karsten Hopp 2f825d
! 	int_u *font_size )
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      char_u  *mark;
Karsten Hopp 2f825d
      int_u   name_len, size;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     mark = vim_strchr( vim_font, ':' );
Karsten Hopp 2f825d
!     if( mark == NULL )
Karsten Hopp 2f825d
! 	name_len = STRLEN( vim_font );
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
! 	name_len = (int_u) ( mark - vim_font );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     *font_name = vim_strnsave( vim_font, name_len );
Karsten Hopp 2f825d
      if (*font_name != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	if (mark != NULL)
Karsten Hopp 2f825d
--- 2919,2936 ----
Karsten Hopp 2f825d
  	char_u *vim_font,
Karsten Hopp 2f825d
  	char_u **font_name,
Karsten Hopp 2f825d
  	int_u *font_flags,
Karsten Hopp 2f825d
! 	int_u *font_size)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      char_u  *mark;
Karsten Hopp 2f825d
      int_u   name_len, size;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     mark = vim_strchr(vim_font, ':');
Karsten Hopp 2f825d
!     if (mark == NULL)
Karsten Hopp 2f825d
! 	name_len = STRLEN(vim_font);
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
! 	name_len = (int_u) (mark - vim_font);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     *font_name = vim_strnsave(vim_font, name_len);
Karsten Hopp 2f825d
      if (*font_name != NULL)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
  	if (mark != NULL)
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2944,2950 ****
Karsten Hopp 2f825d
  		    case 'i': *font_flags |= PF_STYLE_ITALIC; break;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  		    case 's':
Karsten Hopp 2f825d
! 			size = getdigits( &mark );
Karsten Hopp 2f825d
  			/* Restrict the size to some vague limits */
Karsten Hopp 2f825d
  			if (size < 1 || size > 100)
Karsten Hopp 2f825d
  			    size = 8;
Karsten Hopp 2f825d
--- 2944,2950 ----
Karsten Hopp 2f825d
  		    case 'i': *font_flags |= PF_STYLE_ITALIC; break;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  		    case 's':
Karsten Hopp 2f825d
! 			size = getdigits(&mark);
Karsten Hopp 2f825d
  			/* Restrict the size to some vague limits */
Karsten Hopp 2f825d
  			if (size < 1 || size > 100)
Karsten Hopp 2f825d
  			    size = 8;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 2979,3031 ****
Karsten Hopp 2f825d
  	vim_font_name = "PC Terminal";
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (STRCMP( vim_font_name, "*" ) == 0)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	font_tag = PtFontSelection( gui.vimWindow, NULL, NULL,
Karsten Hopp 2f825d
! 		"pcterm12", -1, PHFONT_FIXED, NULL );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	if (font_tag == NULL)
Karsten Hopp 2f825d
  	    return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	gui_mch_free_font( gui.norm_font );
Karsten Hopp 2f825d
  	gui.norm_font = font_tag;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PfQueryFontInfo( font_tag, &info );
Karsten Hopp 2f825d
! 	font_name = vim_strsave( info.font );
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags,
Karsten Hopp 2f825d
! 		    &font_size ) == FALSE)
Karsten Hopp 2f825d
  	    return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	font_tag = gui_ph_get_font( font_name, font_flags, font_size, 0 );
Karsten Hopp 2f825d
  	if (font_tag == NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    vim_free( font_name );
Karsten Hopp 2f825d
  	    return FAIL;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	gui_mch_free_font( gui.norm_font );
Karsten Hopp 2f825d
  	gui.norm_font = font_tag;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui_mch_free_font( gui.bold_font );
Karsten Hopp 2f825d
!     gui.bold_font = gui_ph_get_font( font_name, font_flags | PF_STYLE_BOLD,
Karsten Hopp 2f825d
! 	    font_size, PF_STYLE_BOLD );
Karsten Hopp 2f825d
! 
Karsten Hopp 2f825d
!     gui_mch_free_font( gui.ital_font );
Karsten Hopp 2f825d
!     gui.ital_font = gui_ph_get_font( font_name, font_flags | PF_STYLE_ITALIC,
Karsten Hopp 2f825d
! 	    font_size, PF_STYLE_ITALIC );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* This extent was brought to you by the letter 'g' */
Karsten Hopp 2f825d
!     PfExtentText( &extent, NULL, font_tag, "g", 1 );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gui.char_width = extent.lr.x - extent.ul.x + 1;
Karsten Hopp 2f825d
      gui.char_height = (- extent.ul.y) + extent.lr.y + 1;
Karsten Hopp 2f825d
      gui.char_ascent = - extent.ul.y;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     vim_free( font_name );
Karsten Hopp 2f825d
      return OK;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 2979,3031 ----
Karsten Hopp 2f825d
  	vim_font_name = "PC Terminal";
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (STRCMP(vim_font_name, "*") == 0)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	font_tag = PtFontSelection(gui.vimWindow, NULL, NULL,
Karsten Hopp 2f825d
! 		"pcterm12", -1, PHFONT_FIXED, NULL);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	if (font_tag == NULL)
Karsten Hopp 2f825d
  	    return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	gui_mch_free_font(gui.norm_font);
Karsten Hopp 2f825d
  	gui.norm_font = font_tag;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	PfQueryFontInfo(font_tag, &info;;
Karsten Hopp 2f825d
! 	font_name = vim_strsave(info.font);
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
      else
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags,
Karsten Hopp 2f825d
! 		    &font_size) == FALSE)
Karsten Hopp 2f825d
  	    return FAIL;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	font_tag = gui_ph_get_font(font_name, font_flags, font_size, 0);
Karsten Hopp 2f825d
  	if (font_tag == NULL)
Karsten Hopp 2f825d
  	{
Karsten Hopp 2f825d
! 	    vim_free(font_name);
Karsten Hopp 2f825d
  	    return FAIL;
Karsten Hopp 2f825d
  	}
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
! 	gui_mch_free_font(gui.norm_font);
Karsten Hopp 2f825d
  	gui.norm_font = font_tag;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     gui_mch_free_font(gui.bold_font);
Karsten Hopp 2f825d
!     gui.bold_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_BOLD,
Karsten Hopp 2f825d
! 	    font_size, PF_STYLE_BOLD);
Karsten Hopp 2f825d
! 
Karsten Hopp 2f825d
!     gui_mch_free_font(gui.ital_font);
Karsten Hopp 2f825d
!     gui.ital_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_ITALIC,
Karsten Hopp 2f825d
! 	    font_size, PF_STYLE_ITALIC);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      /* This extent was brought to you by the letter 'g' */
Karsten Hopp 2f825d
!     PfExtentText(&extent, NULL, font_tag, "g", 1);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gui.char_width = extent.lr.x - extent.ul.x + 1;
Karsten Hopp 2f825d
      gui.char_height = (- extent.ul.y) + extent.lr.y + 1;
Karsten Hopp 2f825d
      gui.char_ascent = - extent.ul.y;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     vim_free(font_name);
Karsten Hopp 2f825d
      return OK;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 3037,3043 ****
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      FontQueryInfo info;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PfQueryFontInfo( gui.norm_font, &info );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gui.char_height = - info.ascender + info.descender + p_linespace;
Karsten Hopp 2f825d
      gui.char_ascent = - info.ascender + p_linespace / 2;
Karsten Hopp 2f825d
--- 3037,3043 ----
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
      FontQueryInfo info;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     PfQueryFontInfo(gui.norm_font, &info;;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      gui.char_height = - info.ascender + info.descender + p_linespace;
Karsten Hopp 2f825d
      gui.char_ascent = - info.ascender + p_linespace / 2;
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 3053,3070 ****
Karsten Hopp 2f825d
      int_u   font_size = 12;
Karsten Hopp 2f825d
      int_u   font_flags = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags,
Karsten Hopp 2f825d
! 		&font_size ) != FALSE)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	font_tag = gui_ph_get_font( font_name, font_flags, font_size, -1 );
Karsten Hopp 2f825d
! 	vim_free( font_name );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	if (font_tag != NULL)
Karsten Hopp 2f825d
  	    return (GuiFont)font_tag;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      if (report_error)
Karsten Hopp 2f825d
! 	EMSG2(e_font, vim_font_name );
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return FAIL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
--- 3053,3070 ----
Karsten Hopp 2f825d
      int_u   font_size = 12;
Karsten Hopp 2f825d
      int_u   font_flags = 0;
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
!     if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags,
Karsten Hopp 2f825d
! 		&font_size) != FALSE)
Karsten Hopp 2f825d
      {
Karsten Hopp 2f825d
! 	font_tag = gui_ph_get_font(font_name, font_flags, font_size, -1);
Karsten Hopp 2f825d
! 	vim_free(font_name);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
  	if (font_tag != NULL)
Karsten Hopp 2f825d
  	    return (GuiFont)font_tag;
Karsten Hopp 2f825d
      }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      if (report_error)
Karsten Hopp 2f825d
! 	EMSG2(e_font, vim_font_name);
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      return FAIL;
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 3088,3099 ****
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_set_font(GuiFont font)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PgSetFont( font );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_free_font(GuiFont font)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     vim_free( font );
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
--- 3088,3099 ----
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_set_font(GuiFont font)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     PgSetFont(font);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
      void
Karsten Hopp 2f825d
  gui_mch_free_font(GuiFont font)
Karsten Hopp 2f825d
  {
Karsten Hopp 2f825d
!     vim_free(font);
Karsten Hopp 2f825d
  }
Karsten Hopp 2f825d
  
Karsten Hopp 2f825d
*** ../vim-7.3.309/src/version.c	2011-09-14 15:41:54.000000000 +0200
Karsten Hopp 2f825d
--- src/version.c	2011-09-14 16:01:50.000000000 +0200
Karsten Hopp 2f825d
***************
Karsten Hopp 2f825d
*** 711,712 ****
Karsten Hopp 2f825d
--- 711,714 ----
Karsten Hopp 2f825d
  {   /* Add new patch number below this line */
Karsten Hopp 2f825d
+ /**/
Karsten Hopp 2f825d
+     310,
Karsten Hopp 2f825d
  /**/
Karsten Hopp 2f825d
Karsten Hopp 2f825d
-- 
Karsten Hopp 2f825d
An operatingsystem is just a name you give to the rest of bloating
Karsten Hopp 2f825d
idiosyncratic machine-based-features you left out of your editor.
Karsten Hopp 2f825d
			(author unknown)
Karsten Hopp 2f825d
Karsten Hopp 2f825d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 2f825d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 2f825d
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 2f825d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///