diff options
-rw-r--r-- | src/gui_photon.c | 1116 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 560 insertions, 558 deletions
diff --git a/src/gui_photon.c b/src/gui_photon.c index 12005e58ad..06c8a6baa7 100644 --- a/src/gui_photon.c +++ b/src/gui_photon.c @@ -477,7 +477,7 @@ gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) } #endif - for(i = 0; special_keys[i].key_sym != 0; i++) + for (i = 0; special_keys[i].key_sym != 0; i++) { if (special_keys[i].key_sym == key->key_cap) { @@ -758,7 +758,7 @@ gui_ph_handle_raw_draw(PtWidget_t *widget, PhTile_t *damage) if (damage->next != NULL) damage = damage->next; - while(damage != NULL) + while (damage != NULL) { r = &damage->rect; gui_redraw( @@ -798,12 +798,12 @@ gui_ph_handle_pulldown_menu( /* This is used for pulldown/popup menus and also toolbar buttons */ static int -gui_ph_handle_menu( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_handle_menu(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { - if( data != NULL ) + if (data != NULL) { vimmenu_T *menu = (vimmenu_T *) data; - gui_menu_cb( menu ); + gui_menu_cb(menu); } return Pt_CONTINUE; } @@ -813,9 +813,9 @@ gui_ph_handle_menu( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) gui_ph_handle_menu_unrealized( PtWidget_t *widget, void *data, - PtCallbackInfo_t *info ) + PtCallbackInfo_t *info) { - PtGiveFocus( gui.vimTextArea, NULL ); + PtGiveFocus(gui.vimTextArea, NULL); return Pt_CONTINUE; } @@ -823,9 +823,9 @@ gui_ph_handle_menu_unrealized( gui_ph_handle_window_open( PtWidget_t *widget, void *data, - PtCallbackInfo_t *info ) + PtCallbackInfo_t *info) { - gui_set_shellsize( FALSE, TRUE, RESIZE_BOTH ); + gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH); return Pt_CONTINUE; } @@ -836,74 +836,74 @@ gui_ph_handle_window_open( /* TODO: Set a clipping rect? */ static void -gui_ph_draw_start( void ) +gui_ph_draw_start(void) { PhGC_t *gc; gc = PgGetGC(); - PgSetRegion( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) ); - PgClearClippingsCx( gc ); - PgClearTranslationCx( gc ); + PgSetRegion(PtWidgetRid(PtFindDisjoint(gui.vimTextArea))); + PgClearClippingsCx(gc); + PgClearTranslationCx(gc); - PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset ); - PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos( gui.vimTextArea, NULL ) ); + PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset); + PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL)); - PgSetTranslation( &gui_ph_raw_offset, Pg_RELATIVE ); + PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE); } static void -gui_ph_draw_end( void ) +gui_ph_draw_end(void) { gui_ph_raw_offset.x = -gui_ph_raw_offset.x; gui_ph_raw_offset.y = -gui_ph_raw_offset.y; - PgSetTranslation( &gui_ph_raw_offset, Pg_RELATIVE ); + PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE); } #ifdef USE_PANEL_GROUP static vimmenu_T * -gui_ph_find_buffer_item( char_u *name ) +gui_ph_find_buffer_item(char_u *name) { vimmenu_T *top_level = root_menu; vimmenu_T *items = NULL; - while( top_level != NULL && - ( STRCMP( top_level->dname, "Buffers" ) != 0 ) ) + while (top_level != NULL && + (STRCMP(top_level->dname, "Buffers") != 0)) top_level = top_level->next; - if( top_level != NULL ) + if (top_level != NULL) { items = top_level->children; - while( items != NULL && - ( STRCMP( items->dname, name ) != 0 ) ) + while (items != NULL && + (STRCMP(items->dname, name) != 0)) items = items->next; } return items; } static void -gui_ph_pg_set_buffer_num( int_u buf_num ) +gui_ph_pg_set_buffer_num(int_u buf_num) { int i; char search[16]; char *mark; - if( gui.vimTextArea == NULL || buf_num == 0 ) + if (gui.vimTextArea == NULL || buf_num == 0) return; search[0] = '('; - ultoa( buf_num, &search[1], 10 ); - STRCAT( search, ")" ); + ultoa(buf_num, &search[1], 10); + STRCAT(search, ")"); - for( i = 0; i < num_panels; i++ ) + for (i = 0; i < num_panels; i++) { /* find the last "(" in the panel title and see if the buffer * number in the title matches the one we're looking for */ - mark = STRRCHR( panel_titles[ i ], '(' ); - if( mark != NULL && STRCMP( mark, search ) == 0 ) + mark = STRRCHR(panel_titles[ i ], '('); + if (mark != NULL && STRCMP(mark, search) == 0) { - PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX, - i, 0 ); + PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX, + i, 0); } } } @@ -912,19 +912,19 @@ gui_ph_pg_set_buffer_num( int_u buf_num ) gui_ph_handle_pg_change( PtWidget_t *widget, void *data, - PtCallbackInfo_t *info ) + PtCallbackInfo_t *info) { vimmenu_T *menu; PtPanelGroupCallback_t *panel; - if( info->event != NULL ) + if (info->event != NULL) { panel = info->cbdata; - if( panel->new_panel != NULL ) + if (panel->new_panel != NULL) { - menu = gui_ph_find_buffer_item( panel->new_panel ); - if( menu ) - gui_menu_cb( menu ); + menu = gui_ph_find_buffer_item(panel->new_panel); + if (menu) + gui_menu_cb(menu); } } return Pt_CONTINUE; @@ -935,17 +935,17 @@ gui_ph_get_panelgroup_margins( short *top, short *bottom, short *left, - short *right ) + short *right) { unsigned short abs_raw_x, abs_raw_y, abs_panel_x, abs_panel_y; const unsigned short *margin_top, *margin_bottom; const unsigned short *margin_left, *margin_right; - PtGetAbsPosition( gui.vimTextArea, &abs_raw_x, &abs_raw_y ); - PtGetAbsPosition( gui.vimPanelGroup, &abs_panel_x, &abs_panel_y ); + PtGetAbsPosition(gui.vimTextArea, &abs_raw_x, &abs_raw_y); + PtGetAbsPosition(gui.vimPanelGroup, &abs_panel_x, &abs_panel_y); - PtGetResource( gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0 ); - PtGetResource( gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0 ); + PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0); + PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0); abs_raw_x -= abs_panel_x; abs_raw_y -= abs_panel_y; @@ -959,21 +959,21 @@ gui_ph_get_panelgroup_margins( /* Used for the tabs for PtPanelGroup */ static int -gui_ph_is_buffer_item( vimmenu_T *menu, vimmenu_T *parent ) +gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent) { char *mark; - if( STRCMP( parent->dname, "Buffers" ) == 0 ) + if (STRCMP(parent->dname, "Buffers") == 0) { /* Look for '(' digits ')' */ - mark = vim_strchr( menu->dname, '(' ); - if( mark != NULL ) + mark = vim_strchr(menu->dname, '('); + if (mark != NULL) { mark++; - while( isdigit( *mark ) ) + while (isdigit(*mark)) mark++; - if( *mark == ')' ) + if (*mark == ')') return TRUE; } } @@ -981,63 +981,63 @@ gui_ph_is_buffer_item( vimmenu_T *menu, vimmenu_T *parent ) } static void -gui_ph_pg_add_buffer(char *name ) +gui_ph_pg_add_buffer(char *name) { char **new_titles = NULL; - new_titles = (char **) alloc( ( num_panels + 1 ) * sizeof( char ** ) ); - if( new_titles != NULL ) + new_titles = (char **) alloc((num_panels + 1) * sizeof(char **)); + if (new_titles != NULL) { - if( num_panels > 0 ) - memcpy( new_titles, panel_titles, num_panels * sizeof( char ** ) ); + if (num_panels > 0) + memcpy(new_titles, panel_titles, num_panels * sizeof(char **)); new_titles[ num_panels++ ] = name; - PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, - num_panels ); + PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, + num_panels); - vim_free( panel_titles ); + vim_free(panel_titles); panel_titles = new_titles; } } static void -gui_ph_pg_remove_buffer( char *name ) +gui_ph_pg_remove_buffer(char *name) { int i; char **new_titles = NULL; /* If there is only 1 panel, we just use the temporary place holder */ - if( num_panels > 1 ) + if (num_panels > 1) { - new_titles = (char **) alloc( ( num_panels - 1 ) * sizeof( char ** ) ); - if( new_titles != NULL ) + new_titles = (char **) alloc((num_panels - 1) * sizeof(char **)); + if (new_titles != NULL) { char **s = new_titles; /* Copy all the titles except the one we're removing */ - for( i = 0; i < num_panels; i++ ) + for (i = 0; i < num_panels; i++) { - if( STRCMP( panel_titles[ i ], name ) != 0 ) + if (STRCMP(panel_titles[ i ], name) != 0) { *s++ = panel_titles[ i ]; } } num_panels--; - PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, - num_panels ); + PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles, + num_panels); - vim_free( panel_titles ); + vim_free(panel_titles); panel_titles = new_titles; } } else { num_panels--; - PtSetResource( gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title, - 1 ); + PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title, + 1); - vim_free( panel_titles ); + vim_free(panel_titles); panel_titles = NULL; } } @@ -1047,14 +1047,14 @@ gui_ph_pg_remove_buffer( char *name ) gui_ph_handle_buffer_remove( PtWidget_t *widget, void *data, - PtCallbackInfo_t *info ) + PtCallbackInfo_t *info) { vimmenu_T *menu; - if( data != NULL ) + if (data != NULL) { menu = (vimmenu_T *) data; - gui_ph_pg_remove_buffer( menu->dname ); + gui_ph_pg_remove_buffer(menu->dname); } return Pt_CONTINUE; @@ -1062,13 +1062,13 @@ gui_ph_handle_buffer_remove( #endif static int -gui_ph_pane_resize( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_pane_resize(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { - if( PtWidgetIsRealized( widget ) ) + if (PtWidgetIsRealized(widget)) { is_ignore_draw = TRUE; - PtStartFlux( gui.vimContainer ); - PtContainerHold( gui.vimContainer ); + PtStartFlux(gui.vimContainer); + PtContainerHold(gui.vimContainer); } return Pt_CONTINUE; @@ -1078,7 +1078,7 @@ gui_ph_pane_resize( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) #ifdef FEAT_MBYTE void -gui_ph_encoding_changed( int new_encoding ) +gui_ph_encoding_changed(int new_encoding) { /* Default encoding is latin1 */ char *charset = "latin1"; @@ -1094,13 +1094,13 @@ gui_ph_encoding_changed( int new_encoding ) { DBCS_CHS, "gb" } }; - for( i = 0; i < ARRAY_LENGTH( charsets ); i++ ) + for (i = 0; i < ARRAY_LENGTH(charsets); i++) { - if( new_encoding == charsets[ i ].encoding ) + if (new_encoding == charsets[ i ].encoding) charset = charsets[ i ].name; } - charset_translate = PxTranslateSet( charset_translate, charset ); + charset_translate = PxTranslateSet(charset_translate, charset); } #endif @@ -1112,7 +1112,7 @@ gui_mch_prepare(argc, argv) int *argc; char **argv; { - PtInit( NULL ); + PtInit(NULL); } int @@ -1124,90 +1124,90 @@ gui_mch_init(void) PhDim_t window_size = {100, 100}; /* Arbitrary values */ PhPoint_t pos = {0, 0}; - gui.event_buffer = (PhEvent_t *) alloc( EVENT_BUFFER_SIZE ); - if( gui.event_buffer == NULL ) + gui.event_buffer = (PhEvent_t *) alloc(EVENT_BUFFER_SIZE); + if (gui.event_buffer == NULL) return FAIL; /* Get a translation so we can convert from ISO Latin-1 to UTF */ - charset_translate = PxTranslateSet( NULL, "latin1" ); + charset_translate = PxTranslateSet(NULL, "latin1"); /* The +2 is for the 1 pixel dark line on each side */ gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2; /* Handle close events ourselves */ - PtSetArg( &args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE ); - PtSetArg( &args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, - Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS ); - PtSetArg( &args[ n++ ], Pt_ARG_DIM, &window_size, 0 ); - gui.vimWindow = PtCreateWidget( PtWindow, NULL, n, args ); - if( gui.vimWindow == NULL ) + PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE); + PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, + Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS); + PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0); + gui.vimWindow = PtCreateWidget(PtWindow, NULL, n, args); + if (gui.vimWindow == NULL) return FAIL; - PtAddCallback( gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL ); - PtAddCallback( gui.vimWindow, Pt_CB_WINDOW_OPENING, - gui_ph_handle_window_open, NULL ); + PtAddCallback(gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL); + PtAddCallback(gui.vimWindow, Pt_CB_WINDOW_OPENING, + gui_ph_handle_window_open, NULL); n = 0; - PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, Pt_IS_ANCHORED ); - PtSetArg( &args[ n++ ], Pt_ARG_DIM, &window_size, 0 ); - PtSetArg( &args[ n++ ], Pt_ARG_POS, &pos, 0 ); + PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, Pt_IS_ANCHORED); + PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0); + PtSetArg(&args[ n++ ], Pt_ARG_POS, &pos, 0); #ifdef USE_PANEL_GROUP /* Put in a temprary place holder title */ - PtSetArg( &args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1 ); + PtSetArg(&args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1); - gui.vimPanelGroup = PtCreateWidget( PtPanelGroup, gui.vimWindow, n, args ); - if( gui.vimPanelGroup == NULL ) + gui.vimPanelGroup = PtCreateWidget(PtPanelGroup, gui.vimWindow, n, args); + if (gui.vimPanelGroup == NULL) return FAIL; - PtAddCallback( gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING, - gui_ph_handle_pg_change, NULL ); + PtAddCallback(gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING, + gui_ph_handle_pg_change, NULL); #else /* Turn off all edge decorations */ - PtSetArg( &args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL ); - PtSetArg( &args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0 ); - PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0 ); - PtSetArg( &args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0 ); - PtSetArg( &args[ n++ ], Pt_ARG_CONTAINER_FLAGS, Pt_TRUE, Pt_AUTO_EXTENT ); - - gui.vimContainer = PtCreateWidget( PtPane, gui.vimWindow, n, args ); - if( gui.vimContainer == NULL ) + PtSetArg(&args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL); + PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0); + PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0); + PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0); + PtSetArg(&args[ n++ ], Pt_ARG_CONTAINER_FLAGS, Pt_TRUE, Pt_AUTO_EXTENT); + + gui.vimContainer = PtCreateWidget(PtPane, gui.vimWindow, n, args); + if (gui.vimContainer == NULL) return FAIL; - PtAddCallback( gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL ); + PtAddCallback(gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL); #endif /* Size for the text area is set in gui_mch_set_text_area_pos */ n = 0; - PtSetArg( &args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1 ); - PtSetArg( &args[ n++ ], Pt_ARG_BEVEL_WIDTH, GUI_PH_MARGIN, 0 ); + PtSetArg(&args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1); + PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, GUI_PH_MARGIN, 0); /* * Using focus render also causes the whole widget to be redrawn * whenever it changes focus, which is very annoying :p */ - PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, - Pt_GETS_FOCUS | Pt_HIGHLIGHTED ); + PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, + Pt_GETS_FOCUS | Pt_HIGHLIGHTED); #ifndef FEAT_MOUSESHAPE - PtSetArg( &args[ n++ ], Pt_ARG_CURSOR_TYPE, GUI_PH_MOUSE_TYPE, 0 ); - PtSetArg( &args[ n++ ], Pt_ARG_CURSOR_COLOR, gui_ph_mouse_color, 0 ); + PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_TYPE, GUI_PH_MOUSE_TYPE, 0); + PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_COLOR, gui_ph_mouse_color, 0); #endif - gui.vimTextArea = PtCreateWidget( PtRaw, Pt_DFLT_PARENT, n, args ); - if( gui.vimTextArea == NULL) + gui.vimTextArea = PtCreateWidget(PtRaw, Pt_DFLT_PARENT, n, args); + if (gui.vimTextArea == NULL) return FAIL; /* TODO: use PtAddEventHandlers instead? */ /* Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway */ - PtAddEventHandler( gui.vimTextArea, + PtAddEventHandler(gui.vimTextArea, Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON, - gui_ph_handle_mouse, NULL ); - PtAddEventHandler( gui.vimTextArea, Ph_EV_KEY, - gui_ph_handle_keyboard, NULL ); - PtAddCallback( gui.vimTextArea, Pt_CB_GOT_FOCUS, - gui_ph_handle_focus, NULL ); - PtAddCallback( gui.vimTextArea, Pt_CB_LOST_FOCUS, - gui_ph_handle_focus, NULL ); + gui_ph_handle_mouse, NULL); + PtAddEventHandler(gui.vimTextArea, Ph_EV_KEY, + gui_ph_handle_keyboard, NULL); + PtAddCallback(gui.vimTextArea, Pt_CB_GOT_FOCUS, + gui_ph_handle_focus, NULL); + PtAddCallback(gui.vimTextArea, Pt_CB_LOST_FOCUS, + gui_ph_handle_focus, NULL); /* * Now that the text area widget has been created, set up the colours, @@ -1218,61 +1218,61 @@ gui_mch_init(void) * Create the two timers, not as accurate as using the kernel timer * functions, but good enough */ - gui_ph_timer_cursor = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL ); - if( gui_ph_timer_cursor == NULL ) + gui_ph_timer_cursor = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL); + if (gui_ph_timer_cursor == NULL) return FAIL; - gui_ph_timer_timeout = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL ); - if( gui_ph_timer_timeout == NULL ) + gui_ph_timer_timeout = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL); + if (gui_ph_timer_timeout == NULL) return FAIL; - PtAddCallback( gui_ph_timer_cursor, Pt_CB_TIMER_ACTIVATE, + PtAddCallback(gui_ph_timer_cursor, Pt_CB_TIMER_ACTIVATE, gui_ph_handle_timer_cursor, NULL); - PtAddCallback( gui_ph_timer_timeout, Pt_CB_TIMER_ACTIVATE, + PtAddCallback(gui_ph_timer_timeout, Pt_CB_TIMER_ACTIVATE, gui_ph_handle_timer_timeout, NULL); #ifdef FEAT_MENU n = 0; - PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 ); - PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT, - Pt_IS_ANCHORED ); - gui.vimToolBarGroup = PtCreateWidget( PtToolbarGroup, gui.vimWindow, - n, args ); - if( gui.vimToolBarGroup == NULL ) + PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); + PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT, + Pt_IS_ANCHORED); + gui.vimToolBarGroup = PtCreateWidget(PtToolbarGroup, gui.vimWindow, + n, args); + if (gui.vimToolBarGroup == NULL) return FAIL; - PtAddCallback( gui.vimToolBarGroup, Pt_CB_RESIZE, - gui_ph_handle_menu_resize, NULL ); + PtAddCallback(gui.vimToolBarGroup, Pt_CB_RESIZE, + gui_ph_handle_menu_resize, NULL); n = 0; flags = 0; - PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 ); - if( ! vim_strchr( p_go, GO_MENUS ) ) + PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); + if (! vim_strchr(p_go, GO_MENUS)) { flags |= Pt_DELAY_REALIZE; - PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags ); + PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags); } - gui.vimMenuBar = PtCreateWidget( PtMenuBar, gui.vimToolBarGroup, n, args ); - if( gui.vimMenuBar == NULL ) + gui.vimMenuBar = PtCreateWidget(PtMenuBar, gui.vimToolBarGroup, n, args); + if (gui.vimMenuBar == NULL) return FAIL; # ifdef FEAT_TOOLBAR n = 0; - PtSetArg( &args[ n++ ], Pt_ARG_ANCHOR_FLAGS, - Pt_ANCHOR_LEFT_RIGHT |Pt_TOP_ANCHORED_TOP, Pt_IS_ANCHORED ); - PtSetArg( &args[ n++ ], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, - Pt_RESIZE_Y_AS_REQUIRED ); - PtSetArg( &args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0 ); + PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, + Pt_ANCHOR_LEFT_RIGHT |Pt_TOP_ANCHORED_TOP, Pt_IS_ANCHORED); + PtSetArg(&args[ n++ ], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, + Pt_RESIZE_Y_AS_REQUIRED); + PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0); flags = Pt_GETS_FOCUS; - if( ! vim_strchr( p_go, GO_TOOLBAR ) ) + if (! vim_strchr(p_go, GO_TOOLBAR)) flags |= Pt_DELAY_REALIZE; - PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags ); + PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags); - gui.vimToolBar = PtCreateWidget( PtToolbar, gui.vimToolBarGroup, n, args ); - if( gui.vimToolBar == NULL ) + gui.vimToolBar = PtCreateWidget(PtToolbar, gui.vimToolBarGroup, n, args); + if (gui.vimToolBar == NULL) return FAIL; /* @@ -1310,20 +1310,20 @@ gui_mch_open(void) if (gui_win_x != -1 && gui_win_y != -1) gui_mch_set_winpos(gui_win_x, gui_win_y); - return (PtRealizeWidget( gui.vimWindow ) == 0) ? OK : FAIL; + return (PtRealizeWidget(gui.vimWindow) == 0) ? OK : FAIL; } void gui_mch_exit(int rc) { - PtDestroyWidget( gui.vimWindow ); + PtDestroyWidget(gui.vimWindow); - PxTranslateSet( charset_translate, NULL ); + PxTranslateSet(charset_translate, NULL); - vim_free( gui.event_buffer ); + vim_free(gui.event_buffer); #ifdef USE_PANEL_GROUPS - vim_free( panel_titles ); + vim_free(panel_titles); #endif } @@ -1333,7 +1333,7 @@ gui_mch_exit(int rc) /* When no events are available, photon will call this function, working is * set to FALSE, and the gui_mch_update loop will exit. */ static int -exit_gui_mch_update( void *data ) +exit_gui_mch_update(void *data) { *(int *)data = FALSE; return Pt_END; @@ -1344,8 +1344,8 @@ gui_mch_update(void) { int working = TRUE; - PtAppAddWorkProc( NULL, exit_gui_mch_update, &working ); - while( ( working == TRUE ) && !vim_is_input_buf_full()) + PtAppAddWorkProc(NULL, exit_gui_mch_update, &working); + while ((working == TRUE) && !vim_is_input_buf_full()) { PtProcessEvent(); } @@ -1356,23 +1356,23 @@ gui_mch_wait_for_chars(int wtime) { is_timeout = FALSE; - if( wtime > 0 ) - PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, wtime, 0 ); + if (wtime > 0) + PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, wtime, 0); - while( 1 ) + while (1) { PtProcessEvent(); - if( input_available() ) + if (input_available()) { - PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0 ); + PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0); return OK; } - else if( is_timeout == TRUE ) + else if (is_timeout == TRUE) return FAIL; } } -#if defined( FEAT_BROWSE ) || defined( PROTO ) +#if defined(FEAT_BROWSE) || defined(PROTO) /* * Put up a file requester. * Returns the selected name in allocated memory, or NULL for Cancel. @@ -1398,12 +1398,12 @@ gui_mch_browse( char_u *open_text = NULL; flags = 0; - memset( &file, 0, sizeof( file ) ); + memset(&file, 0, sizeof(file)); - default_path = alloc( MAXPATHL + 1 + NAME_MAX + 1 ); - if( default_path != NULL ) + default_path = alloc(MAXPATHL + 1 + NAME_MAX + 1); + if (default_path != NULL) { - if( saving == TRUE ) + if (saving == TRUE) { /* Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway */ flags |= Pt_FSR_NO_FCHECK; @@ -1411,23 +1411,23 @@ gui_mch_browse( } /* combine the directory and filename into a single path */ - if( initdir == NULL || *initdir == NUL ) + if (initdir == NULL || *initdir == NUL) { - mch_dirname( default_path, MAXPATHL ); + mch_dirname(default_path, MAXPATHL); initdir = default_path; } else { - STRCPY( default_path, initdir ); + STRCPY(default_path, initdir); initdir = default_path; } - if( default_name != NULL ) + if (default_name != NULL) { - if( default_path[ STRLEN( default_path ) - 1 ] != '/' ) - STRCAT( default_path, "/" ); + if (default_path[ STRLEN(default_path) - 1 ] != '/') + STRCAT(default_path, "/"); - STRCAT( default_path, default_name ); + STRCAT(default_path, default_name); } /* TODO: add a filter? */ @@ -1441,55 +1441,55 @@ gui_mch_browse( NULL, NULL, &file, - flags ); + flags); - vim_free( default_path ); + vim_free(default_path); - if( file.ret == Pt_FSDIALOG_BTN1 ) + if (file.ret == Pt_FSDIALOG_BTN1) return vim_strsave(file.path); } return NULL; } #endif -#if defined( FEAT_GUI_DIALOG ) || defined( PROTO ) +#if defined(FEAT_GUI_DIALOG) || defined(PROTO) static PtWidget_t *gui_ph_dialog_text = NULL; static int -gui_ph_dialog_close( int button, void *data ) +gui_ph_dialog_close(int button, void *data) { PtModalCtrl_t *modal_ctrl = data; char_u *dialog_text, *vim_text; - if( gui_ph_dialog_text != NULL ) + if (gui_ph_dialog_text != NULL) { - PtGetResource( gui_ph_dialog_text, Pt_ARG_TEXT_STRING, &dialog_text, 0 ); - PtGetResource( gui_ph_dialog_text, Pt_ARG_POINTER, &vim_text, 0 ); - STRNCPY( vim_text, dialog_text, IOSIZE - 1 ); + PtGetResource(gui_ph_dialog_text, Pt_ARG_TEXT_STRING, &dialog_text, 0); + PtGetResource(gui_ph_dialog_text, Pt_ARG_POINTER, &vim_text, 0); + STRNCPY(vim_text, dialog_text, IOSIZE - 1); } - PtModalUnblock( modal_ctrl, (void *) button ); + PtModalUnblock(modal_ctrl, (void *) button); return Pt_TRUE; } static int -gui_ph_dialog_text_enter( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_dialog_text_enter(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { - if( info->reason_subtype == Pt_EDIT_ACTIVATE ) - gui_ph_dialog_close( 1, data ); + if (info->reason_subtype == Pt_EDIT_ACTIVATE) + gui_ph_dialog_close(1, data); return Pt_CONTINUE; } static int -gui_ph_dialog_esc( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) +gui_ph_dialog_esc(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) { PhKeyEvent_t *key; - key = PhGetData( info->event ); - if( ( key->key_flags & Pk_KF_Cap_Valid ) && ( key->key_cap == Pk_Escape ) ) + key = PhGetData(info->event); + if ((key->key_flags & Pk_KF_Cap_Valid) && (key->key_cap == Pk_Escape)) { - gui_ph_dialog_close( 0, data ); + gui_ph_dialog_close(0, data); return Pt_CONSUME; } return Pt_PROCESS; @@ -1518,40 +1518,40 @@ gui_mch_dialog( button_count = len = i = 0; - if( buttons == NULL || *buttons == NUL ) + if (buttons == NULL || *buttons == NUL) return -1; /* There is one less separator than buttons, so bump up the button count */ button_count = 1; /* Count string length and number of seperators */ - for( str = buttons; *str; str++ ) + for (str = buttons; *str; str++) { len++; - if( *str == DLG_BUTTON_SEP ) + if (*str == DLG_BUTTON_SEP) button_count++; } - if ( title == NULL ) + if (title == NULL) title = "Vim"; - buttons_copy = alloc( len + 1 ); - button_array = (char_u **) alloc( button_count * sizeof( char_u * ) ); - if( buttons_copy != NULL && button_array != NULL ) + buttons_copy = alloc(len + 1); + button_array = (char_u **) alloc(button_count * sizeof(char_u *)); + if (buttons_copy != NULL && button_array != NULL) { - STRCPY( buttons_copy, buttons ); + STRCPY(buttons_copy, buttons); /* * Convert DLG_BUTTON_SEP into NUL's and fill in * button_array with the pointer to each NUL terminated string */ str = buttons_copy; - for( i = 0; i < button_count; i++ ) + for (i = 0; i < button_count; i++) { button_array[ i ] = str; - for( ; *str; str++ ) + for (; *str; str++) { - if( *str == DLG_BUTTON_SEP ) + if (*str == DLG_BUTTON_SEP) { *str++ = NUL; break; @@ -1565,7 +1565,7 @@ gui_mch_dialog( NULL, message, NULL, button_count, (const char **) button_array, NULL, - default_button, 0, Pt_MODAL ); + default_button, 0, Pt_MODAL); #else /* Writing the dialog ourselves lets us add extra features, like * trapping the escape key and returning 0 to vim */ @@ -1576,32 +1576,32 @@ gui_mch_dialog( PtModalCtrl_t modal_ctrl; PtDialogInfo_t di; - memset( &di, 0, sizeof( di ) ); - memset( &modal_ctrl, 0, sizeof( modal_ctrl ) ); + memset(&di, 0, sizeof(di)); + memset(&modal_ctrl, 0, sizeof(modal_ctrl)); n = 0; - PtSetArg( &args[n++], Pt_ARG_GROUP_ROWS_COLS, 0, 0 ); - PtSetArg( &args[n++], Pt_ARG_WIDTH, 350, 0 ); - PtSetArg( &args[n++], Pt_ARG_GROUP_ORIENTATION, - Pt_GROUP_VERTICAL, 0 ); - PtSetArg( &args[n++], Pt_ARG_GROUP_FLAGS, - Pt_TRUE, Pt_GROUP_NO_KEYS | Pt_GROUP_STRETCH_HORIZONTAL ); - PtSetArg( &args[n++], Pt_ARG_CONTAINER_FLAGS, Pt_FALSE, Pt_TRUE ); - pane = PtCreateWidget( PtGroup, NULL, n, args ); + PtSetArg(&args[n++], Pt_ARG_GROUP_ROWS_COLS, 0, 0); + PtSetArg(&args[n++], Pt_ARG_WIDTH, 350, 0); + PtSetArg(&args[n++], Pt_ARG_GROUP_ORIENTATION, + Pt_GROUP_VERTICAL, 0); + PtSetArg(&args[n++], Pt_ARG_GROUP_FLAGS, + Pt_TRUE, Pt_GROUP_NO_KEYS | Pt_GROUP_STRETCH_HORIZONTAL); + PtSetArg(&args[n++], Pt_ARG_CONTAINER_FLAGS, Pt_FALSE, Pt_TRUE); + pane = PtCreateWidget(PtGroup, NULL, n, args); n = 0; - PtSetArg( &args[n++], Pt_ARG_TEXT_STRING, message, 0 ); - PtCreateWidget( PtLabel, pane, n, args ); + PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, message, 0); + PtCreateWidget(PtLabel, pane, n, args); - if( textfield != NULL ) + if (textfield != NULL) { n = 0; - PtSetArg( &args[n++], Pt_ARG_MAX_LENGTH, IOSIZE - 1, 0 ); - PtSetArg( &args[n++], Pt_ARG_TEXT_STRING, textfield, 0 ); - PtSetArg( &args[n++], Pt_ARG_POINTER, textfield, 0 ); - gui_ph_dialog_text = PtCreateWidget( PtText, pane, n, args ); - PtAddCallback( gui_ph_dialog_text, Pt_CB_ACTIVATE, - gui_ph_dialog_text_enter, &modal_ctrl ); + PtSetArg(&args[n++], Pt_ARG_MAX_LENGTH, IOSIZE - 1, 0); + PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, textfield, 0); + PtSetArg(&args[n++], Pt_ARG_POINTER, textfield, 0); + gui_ph_dialog_text = PtCreateWidget(PtText, pane, n, args); + PtAddCallback(gui_ph_dialog_text, Pt_CB_ACTIVATE, + gui_ph_dialog_text_enter, &modal_ctrl); } di.parent = gui.vimWindow; @@ -1616,26 +1616,26 @@ gui_mch_dialog( di.callback = gui_ph_dialog_close; di.data = &modal_ctrl; - dialog = PtCreateDialog( &di ); - PtAddFilterCallback( dialog, Ph_EV_KEY, - gui_ph_dialog_esc, &modal_ctrl ); + dialog = PtCreateDialog(&di); + PtAddFilterCallback(dialog, Ph_EV_KEY, + gui_ph_dialog_esc, &modal_ctrl); - if( gui_ph_dialog_text != NULL ) - PtGiveFocus( gui_ph_dialog_text, NULL ); + if (gui_ph_dialog_text != NULL) + PtGiveFocus(gui_ph_dialog_text, NULL); /* Open dialog, block the vim window and wait for the dialog to close */ - PtRealizeWidget( dialog ); - PtMakeModal( dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR ); - dialog_result = (int) PtModalBlock( &modal_ctrl, 0 ); + PtRealizeWidget(dialog); + PtMakeModal(dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR); + dialog_result = (int) PtModalBlock(&modal_ctrl, 0); - PtDestroyWidget( dialog ); + PtDestroyWidget(dialog); gui_ph_dialog_text = NULL; } #endif } - vim_free( button_array ); - vim_free( buttons_copy ); + vim_free(button_array); + vim_free(buttons_copy); return dialog_result; } @@ -1648,7 +1648,7 @@ gui_mch_get_winpos(int *x, int *y) { PhPoint_t *pos; - pos = PtWidgetPos( gui.vimWindow, NULL ); + pos = PtWidgetPos(gui.vimWindow, NULL); *x = pos->x; *y = pos->y; @@ -1661,7 +1661,7 @@ gui_mch_set_winpos(int x, int y) { PhPoint_t pos = { x, y }; - PtSetResource( gui.vimWindow, Pt_ARG_POS, &pos, 0 ); + PtSetResource(gui.vimWindow, Pt_ARG_POS, &pos, 0); } void @@ -1677,10 +1677,10 @@ gui_mch_set_shellsize(int width, int height, window_size.h += pg_margin_top + pg_margin_bottom; #endif - PtSetResource( gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0 ); - PtSetResource( gui.vimWindow, Pt_ARG_DIM, &window_size, 0 ); + PtSetResource(gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0); + PtSetResource(gui.vimWindow, Pt_ARG_DIM, &window_size, 0); - if( ! PtWidgetIsRealized( gui.vimWindow ) ) + if (! PtWidgetIsRealized(gui.vimWindow)) gui_ph_resize_container(); } @@ -1693,8 +1693,8 @@ gui_mch_get_screen_dimensions(int *screen_w, int *screen_h) { PhRect_t console; - PhWindowQueryVisible( Ph_QUERY_WORKSPACE, 0, - PhInputGroup( NULL ), &console ); + PhWindowQueryVisible(Ph_QUERY_WORKSPACE, 0, + PhInputGroup(NULL), &console); *screen_w = console.lr.x - console.ul.x + 1; *screen_h = console.lr.y - console.ul.y + 1; @@ -1705,11 +1705,11 @@ gui_mch_iconify(void) { PhWindowEvent_t event; - memset( &event, 0, sizeof (event) ); + memset(&event, 0, sizeof (event)); event.event_f = Ph_WM_HIDE; event.event_state = Ph_WM_EVSTATE_HIDE; - event.rid = PtWidgetRid( gui.vimWindow ); - PtForwardWindowEvent( &event ); + event.rid = PtWidgetRid(gui.vimWindow); + PtForwardWindowEvent(&event); } #if defined(FEAT_EVAL) || defined(PROTO) @@ -1721,11 +1721,11 @@ gui_mch_set_foreground() { PhWindowEvent_t event; - memset( &event, 0, sizeof (event) ); + memset(&event, 0, sizeof (event)); event.event_f = Ph_WM_TOFRONT; event.event_state = Ph_WM_EVSTATE_FFRONT; - event.rid = PtWidgetRid( gui.vimWindow ); - PtForwardWindowEvent( &event ); + event.rid = PtWidgetRid(gui.vimWindow); + PtForwardWindowEvent(&event); } #endif @@ -1733,9 +1733,9 @@ gui_mch_set_foreground() gui_mch_settitle(char_u *title, char_u *icon) { #ifdef USE_PANEL_GROUP - gui_ph_pg_set_buffer_num( curwin->w_buffer->b_fnum ); + gui_ph_pg_set_buffer_num(curwin->w_buffer->b_fnum); #endif - PtSetResource( gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0 ); + PtSetResource(gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0); /* Not sure what to do with the icon text, set balloon text somehow? */ } @@ -1748,10 +1748,10 @@ gui_mch_set_scrollbar_thumb(scrollbar_T *sb, int val, int size, int max) int n = 0; PtArg_t args[3]; - PtSetArg( &args[ n++ ], Pt_ARG_MAXIMUM, max, 0 ); - PtSetArg( &args[ n++ ], Pt_ARG_SLIDER_SIZE, size, 0 ); - PtSetArg( &args[ n++ ], Pt_ARG_GAUGE_VALUE, val, 0 ); - PtSetResources( sb->id, n, args ); + PtSetArg(&args[ n++ ], Pt_ARG_MAXIMUM, max, 0); + PtSetArg(&args[ n++ ], Pt_ARG_SLIDER_SIZE, size, 0); + PtSetArg(&args[ n++ ], Pt_ARG_GAUGE_VALUE, val, 0); + PtSetResources(sb->id, n, args); } void @@ -1759,7 +1759,7 @@ gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h) { PhArea_t area = {{ x, y }, { w, h }}; - PtSetResource( sb->id, Pt_ARG_AREA, &area, 0 ); + PtSetResource(sb->id, Pt_ARG_AREA, &area, 0); } void @@ -1775,12 +1775,12 @@ gui_mch_create_scrollbar(scrollbar_T *sb, int orient) * * Also, don't let the scrollbar get focus */ - PtSetArg( &args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, - Pt_DELAY_REALIZE | Pt_GETS_FOCUS ); - PtSetArg( &args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0); + PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE,< |