Commits

Anonymous committed 8477339

updated for version 7.3.262
Problem: Photon code style doesn't match Vim style.
Solution: Clean up some of it. (Elias Diem)

Comments (0)

Files changed (2)

 #endif
 
 #define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a[0]))
-#define RGB(r,g,b) PgRGB(r,g,b)
-
-#define EVENT_BUFFER_SIZE sizeof( PhEvent_t ) + 1000
+#define RGB(r, g, b) PgRGB(r, g, b)
+
+#define EVENT_BUFFER_SIZE sizeof(PhEvent_t) + 1000
 
 /* Some defines for gui_mch_mousehide() */
 #define MOUSE_HIDE		TRUE
 static PtCallbackF_t gui_ph_handle_menu_unrealized;
 
 #ifdef USE_PANEL_GROUP
-static void gui_ph_get_panelgroup_margins( short*, short*, short*, short* );
+static void gui_ph_get_panelgroup_margins(short*, short*, short*, short*);
 #endif
 
 #ifdef FEAT_TOOLBAR
-static PhImage_t *gui_ph_toolbar_find_icon( vimmenu_T *menu );
+static PhImage_t *gui_ph_toolbar_find_icon(vimmenu_T *menu);
 #endif
 
-static void gui_ph_draw_start( void );
-static void gui_ph_draw_end( void );
+static void gui_ph_draw_start(void);
+static void gui_ph_draw_end(void);
 
 /* Set the text for the balloon */
-static PtWidget_t * gui_ph_show_tooltip( PtWidget_t *window,
+static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window,
 			     PtWidget_t *widget,
 			     int position,
 			     char *text,
 			     char *font,
 			     PgColor_t fill_color,
-			     PgColor_t text_color );
+			     PgColor_t text_color);
 
 /****************************************************************************/
 
-static PtWidget_t * gui_ph_show_tooltip( PtWidget_t *window,
+static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window,
 			     PtWidget_t *widget,
 			     int position,
 			     char *text,
 			     char *font,
 			     PgColor_t fill_color,
-			     PgColor_t text_color )
+			     PgColor_t text_color)
 {
     PtArg_t arg;
     vimmenu_T *menu;
     char_u  *tooltip;
 
-    PtSetArg( &arg, Pt_ARG_POINTER, &menu, 0 );
-    PtGetResources( widget, 1, &arg );
+    PtSetArg(&arg, Pt_ARG_POINTER, &menu, 0);
+    PtGetResources(widget, 1, &arg);
 
     /* Override the text and position */
 
     tooltip = text;
-    if( menu != NULL )
+    if (menu != NULL)
     {
 	int index = MENU_INDEX_TIP;
-	if( menu->strings[ index ] != NULL )
+	if (menu->strings[ index ] != NULL)
 	    tooltip = menu->strings[ index ];
     }
 
-    return( PtInflateBalloon(
+    return PtInflateBalloon(
 	    window,
 	    widget,
 	    /* Don't put the balloon at the bottom,
 	    tooltip,
 	    font,
 	    fill_color,
-	    text_color ) );
+	    text_color);
 }
 
     static void
-gui_ph_resize_container( void )
+gui_ph_resize_container(void)
 {
     PhArea_t area;
 
-    PtWidgetArea( gui.vimWindow, &area );
-    PtWidgetPos ( gui.vimContainer, &area.pos );
-
-    PtSetResource( gui.vimContainer, Pt_ARG_AREA, &area, 0 );
+    PtWidgetArea(gui.vimWindow, &area);
+    PtWidgetPos (gui.vimContainer, &area.pos);
+
+    PtSetResource(gui.vimContainer, Pt_ARG_AREA, &area, 0);
 }
 
     static int
 gui_ph_handle_menu_resize(
 	PtWidget_t *widget,
 	void *other,
-	PtCallbackInfo_t *info )
+	PtCallbackInfo_t *info)
 {
     PtContainerCallback_t *sizes = info->cbdata;
     PtWidget_t		*container;
     /* Because vim treats the toolbar and menubar separately,
      * and here they're lumped together into a PtToolbarGroup,
      * we only need either menu_height or toolbar_height set at once */
-    if( gui.menu_is_active )
+    if (gui.menu_is_active)
     {
 	gui.menu_height = height;
 	gui.toolbar_height = 0;
     container = gui.vimContainer;
 #endif
 
-    PtSetResource( container, Pt_ARG_POS, &below_menu, 0 );
+    PtSetResource(container, Pt_ARG_POS, &below_menu, 0);
 
     gui_ph_resize_container();
 
 #ifdef USE_PANEL_GROUP
     gui_ph_get_panelgroup_margins(
 	    &pg_margin_top, &pg_margin_bottom,
-	    &pg_margin_left, &pg_margin_right );
+	    &pg_margin_left, &pg_margin_right);
 #endif
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
 /*
 gui_ph_handle_timer_cursor(
 	PtWidget_t *widget,
 	void *data,
-	PtCallbackInfo_t *info )
+	PtCallbackInfo_t *info)
 {
-    if( blink_state == BLINK_ON )
+    if (blink_state == BLINK_ON)
     {
 	gui_undraw_cursor();
 	blink_state = BLINK_OFF;
-	PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
-		blink_offtime, 0 );
+	PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
+		blink_offtime, 0);
     }
     else
     {
 	gui_update_cursor(TRUE, FALSE);
 	blink_state = BLINK_ON;
-	PtSetResource( gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
-		blink_ontime, 0 );
+	PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
+		blink_ontime, 0);
     }
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static int
 {
     is_timeout = TRUE;
 
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static int
 	    break;
     }
 
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static int
 
 	    case Pt_SCROLL_SET:
 		/* FIXME: return straight away here? */
-		return( Pt_CONTINUE );
+		return Pt_CONTINUE;
 		break;
 	}
 
 	gui_drag_scrollbar(sb, value, dragging);
     }
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static int
     /* We're a good lil photon program, aren't we? yes we are, yeess wee arrr */
     if( key->key_flags & Pk_KF_Compose )
     {
-	return( Pt_CONTINUE );
+	return Pt_CONTINUE;
     }
 
     if( (key->key_flags & Pk_KF_Cap_Valid) &&
 		gui_is_menu_shortcut( key->key_cap ) ) ) )
 	{
 	    /* Fallthrough and let photon look for the hotkey */
-	    return( Pt_CONTINUE );
+	    return Pt_CONTINUE;
 	}
 #endif
 
 			add_to_input_buf( string, len );
 		    }
 
-		    return( Pt_CONSUME );
+		    return Pt_CONSUME;
 		}
 		len = 0;
 #endif
 		}
 		else
 		{
-		    return( Pt_CONTINUE );
+		    return Pt_CONTINUE;
 		}
 	    }
 	    else
 	if( len > 0 )
 	{
 	    add_to_input_buf( string, len );
-	    return( Pt_CONSUME );
+	    return Pt_CONSUME;
 	}
     }
 
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static int
     if( info->event->type == Ph_EV_PTR_MOTION_NOBUTTON )
     {
 	gui_mouse_moved( mouse_x, mouse_y );
-	return( Pt_CONTINUE );
+	return Pt_CONTINUE;
     }
 
     if( pointer->key_mods & Pk_KM_Shift )
 	gui_send_mouse_event( button , mouse_x, mouse_y, repeated_click, modifiers );
     }
 
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
 /* Handle a focus change of the PtRaw widget */
 	PtAddEventHandler( gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON,
 		gui_ph_handle_mouse, NULL );
     }
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static void
 	PtRealizeWidget( menu->submenu_id );
     }
 
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
 /* This is used for pulldown/popup menus and also toolbar buttons */
 	vimmenu_T *menu = (vimmenu_T *) data;
 	gui_menu_cb( menu );
     }
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
 /* Stop focus from disappearing into the menubar... */
 	PtCallbackInfo_t *info )
 {
     PtGiveFocus( gui.vimTextArea, NULL );
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static int
 	PtCallbackInfo_t *info )
 {
     gui_set_shellsize( FALSE, TRUE, RESIZE_BOTH );
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
 /****************************************************************************/
 		( STRCMP( items->dname, name ) != 0 ) )
 	    items = items->next;
     }
-    return( items );
+    return items;
 }
 
     static void
 		gui_menu_cb( menu );
 	}
     }
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static void
 		mark++;
 
 	    if( *mark == ')' )
-		return( TRUE);
+		return TRUE;
 	}
     }
-    return( FALSE );
+    return FALSE;
 }
 
     static void
 	gui_ph_pg_remove_buffer( menu->dname );
     }
 
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 #endif
 
 	PtContainerHold( gui.vimContainer );
     }
 
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
 /****************************************************************************/
 
     gui.event_buffer = (PhEvent_t *) alloc( EVENT_BUFFER_SIZE );
     if( gui.event_buffer == NULL )
-	return( FAIL );
+	return FAIL;
 
     /* Get a translation so we can convert from ISO Latin-1 to UTF */
     charset_translate = PxTranslateSet( NULL, "latin1" );
     PtSetArg( &args[ n++ ], Pt_ARG_DIM, &window_size, 0 );
     gui.vimWindow = PtCreateWidget( PtWindow, NULL, n, args );
     if( gui.vimWindow == NULL )
-	return( FAIL );
+	return FAIL;
 
     PtAddCallback( gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL );
     PtAddCallback( gui.vimWindow, Pt_CB_WINDOW_OPENING,
 
     gui.vimPanelGroup = PtCreateWidget( PtPanelGroup, gui.vimWindow, n, args );
     if( gui.vimPanelGroup == NULL )
-	return( FAIL );
+	return FAIL;
 
     PtAddCallback( gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING,
 	    gui_ph_handle_pg_change, NULL );
 
     gui.vimContainer = PtCreateWidget( PtPane, gui.vimWindow, n, args );
     if( gui.vimContainer == NULL )
-	return( FAIL );
+	return FAIL;
 
     PtAddCallback( gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL );
 #endif
 
     gui.vimTextArea = PtCreateWidget( PtRaw, Pt_DFLT_PARENT, n, args );
     if( gui.vimTextArea == NULL)
-	return( FAIL );
+	return FAIL;
 
     /* TODO: use PtAddEventHandlers instead? */
     /* Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway */
      */
     gui_ph_timer_cursor  = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL );
     if( gui_ph_timer_cursor == NULL )
-	return( FAIL );
+	return FAIL;
 
     gui_ph_timer_timeout = PtCreateWidget( PtTimer, gui.vimWindow, 0, NULL );
     if( gui_ph_timer_timeout == NULL )
-	return( FAIL );
+	return FAIL;
 
     PtAddCallback( gui_ph_timer_cursor,  Pt_CB_TIMER_ACTIVATE,
 	    gui_ph_handle_timer_cursor, NULL);
     gui.vimToolBarGroup = PtCreateWidget( PtToolbarGroup, gui.vimWindow,
 	    n, args );
     if( gui.vimToolBarGroup == NULL )
-	return( FAIL );
+	return FAIL;
 
     PtAddCallback( gui.vimToolBarGroup, Pt_CB_RESIZE,
 	    gui_ph_handle_menu_resize, NULL );
     }
     gui.vimMenuBar = PtCreateWidget( PtMenuBar, gui.vimToolBarGroup, n, args );
     if( gui.vimMenuBar == NULL )
-	return( FAIL );
+	return FAIL;
 
 # ifdef FEAT_TOOLBAR
     n = 0;
 
     gui.vimToolBar = PtCreateWidget( PtToolbar, gui.vimToolBarGroup, n, args );
     if( gui.vimToolBar == NULL )
-	return( FAIL );
+	return FAIL;
 
     /*
      * Size for the toolbar is fetched in gui_mch_show_toolbar, after
 
 #endif
 
-    return( OK );
+    return OK;
 }
 
     int
 gui_mch_init_check(void)
 {
-    return( (is_photon_available == TRUE) ? OK : FAIL );
+    return (is_photon_available == TRUE) ? OK : FAIL;
 }
 
     int
     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
 exit_gui_mch_update( void *data )
 {
     *(int *)data = FALSE;
-    return( Pt_END );
+    return Pt_END;
 }
 
     void
 	if( input_available() )
 	{
 	    PtSetResource( gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0 );
-	    return( OK );
+	    return OK;
 	}
 	else if( is_timeout == TRUE )
-	    return( FAIL );
+	    return FAIL;
     }
 }
 
 	vim_free( default_path );
 
 	if( file.ret == Pt_FSDIALOG_BTN1 )
-	    return( vim_strsave( file.path ) );
+	    return vim_strsave(file.path);
     }
-    return( NULL );
+    return NULL;
 }
 #endif
 
 
     PtModalUnblock( modal_ctrl, (void *) button );
 
-    return( Pt_TRUE );
+    return Pt_TRUE;
 }
 
     static int
 {
     if( info->reason_subtype == Pt_EDIT_ACTIVATE )
 	gui_ph_dialog_close( 1, data );
-    return( Pt_CONTINUE );
+    return Pt_CONTINUE;
 }
 
     static int
     if( ( key->key_flags & Pk_KF_Cap_Valid ) && ( key->key_cap == Pk_Escape ) )
     {
 	gui_ph_dialog_close( 0, data );
-	return( Pt_CONSUME );
+	return Pt_CONSUME;
     }
-    return( Pt_PROCESS );
+    return Pt_PROCESS;
 }
 
     int
     button_count = len = i = 0;
 
     if( buttons == NULL || *buttons == NUL )
-	return( -1 );
+	return -1;
 
     /* There is one less separator than buttons, so bump up the button count */
     button_count = 1;
     vim_free( button_array );
     vim_free( buttons_copy );
 
-    return( dialog_result );
+    return dialog_result;
 }
 #endif
 /****************************************************************************/
     *x = pos->x;
     *y = pos->y;
 
-    return( OK );
+    return OK;
 }
 
     void
 hex_digit(int c)
 {
     if (VIM_ISDIGIT(c))
-	return( c - '0' );
+	return c - '0';
     c = TOLOWER_ASC(c);
     if (c >= 'a' && c <= 'f')
-	return( c - 'a' + 10 );
-    return( -1000 );
+	return c - 'a' + 10;
+    return -1000;
 }
 
 
 	b = hex_digit( name[5] ) * 16 + hex_digit( name[6] );
 	if( r < 0 || g < 0 || b < 0 )
 	    return INVALCOLOR;
-	return( RGB( r, g, b ) );
+	return RGB(r, g, b);
     }
 
     for( i = 0; i < ARRAY_LENGTH( table ); i++ )
     {
 	if( STRICMP( name, table[i].name ) == 0 )
-	    return( table[i].colour );
+	    return table[i].colour;
     }
 
     /*
 	    if (STRICMP(color, name) == 0)
 	    {
 		fclose(fd);
-		return( (guicolor_T) RGB(r,g,b) );
+		return (guicolor_T)RGB(r, g, b);
 	    }
 	}
 
     for (i = 0; special_keys[i].key_sym != 0; i++)
 	if (name[0] == special_keys[i].vim_code0 &&
 		 name[1] == special_keys[i].vim_code1)
-	    return( OK );
-    return( FAIL );
+	    return OK;
+    return FAIL;
 }
 
 /****************************************************************************/
 
 	temp_phi = &external_icon;
     }
-    return( temp_phi );
+    return temp_phi;
 }
 
 /*
 	    icon = gui_ph_toolbar_load_icon( full_pathname );
 
 	if( icon != NULL )
-	    return( icon );
+	    return icon;
     }
 
     if( menu->iconidx >= 0 &&
 	    ( menu->iconidx < ARRAY_LENGTH( gui_ph_toolbar_images ) ) )
     {
-	return( gui_ph_toolbar_images[ menu->iconidx ] );
+	return gui_ph_toolbar_images[menu->iconidx];
     }
 
-    return( NULL );
+    return NULL;
 }
 #endif
 
 	     * at least has the bits we're checking for */
 	    if( font_size == info.size &&
 		    style == (info.style & style) )
-		return( (GuiFont) font_tag );
+		return (GuiFont)font_tag;
 	}
 	vim_free( font_tag );
     }
-    return( NULL );
+    return NULL;
 }
 
 /*
 		}
 	    }
 	}
-	return( TRUE );
+	return TRUE;
     }
-    return( FALSE );
+    return FALSE;
 }
 
     int
 		"pcterm12", -1, PHFONT_FIXED, NULL );
 
 	if( font_tag == NULL )
-	    return( FAIL );
+	    return FAIL;
 
 	gui_mch_free_font( gui.norm_font );
 	gui.norm_font = font_tag;
     {
 	if( gui_ph_parse_font_name( vim_font_name, &font_name, &font_flags,
 		    &font_size ) == FALSE )
-	    return( FAIL );
+	    return FAIL;
 
 	font_tag = gui_ph_get_font( font_name, font_flags, font_size, 0 );
 	if( font_tag == NULL )
 	{
 	    vim_free( font_name );
-	    return( FAIL );
+	    return FAIL;
 	}
 
 	gui_mch_free_font( gui.norm_font );
     gui.char_ascent = - extent.ul.y;
 
     vim_free( font_name );
-    return( OK );
+    return OK;
 }
 
 /*
     gui.char_height = - info.ascender + info.descender + p_linespace;
     gui.char_ascent = - info.ascender + p_linespace / 2;
 
-    return( OK );
+    return OK;
 }
 
     GuiFont
 	vim_free( font_name );
 
 	if( font_tag != NULL )
-	    return( (GuiFont) font_tag );
+	    return (GuiFont)font_tag;
     }
 
     if( report_error )
 	EMSG2(e_font, vim_font_name );
 
-    return( FAIL );
+    return FAIL;
 }
 
 #if defined(FEAT_EVAL) || defined(PROTO)
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    262,
+/**/
     261,
 /**/
     260,