1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-07-31 21:59:25 -04:00

[Keys] Cleanup view a bit.

This commit is contained in:
Dave Davenport 2017-03-17 14:07:11 +01:00
parent dfeb5940d4
commit 50477a0b99
10 changed files with 90 additions and 76 deletions

View file

@ -204,22 +204,22 @@ static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *stat
} }
for ( unsigned i = 0; i < pd->num_switchers; i++ ) { for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
if ( selected_line >= pd->starts[i] && selected_line < ( pd->starts[i] + pd->lengths[i] ) ) { if ( selected_line >= pd->starts[i] && selected_line < ( pd->starts[i] + pd->lengths[i] ) ) {
char * str = mode_get_display_value ( pd->switchers[i].mode, selected_line - pd->starts[i], state, attr_list, TRUE ); char * str = mode_get_display_value ( pd->switchers[i].mode, selected_line - pd->starts[i], state, attr_list, TRUE );
const char *dname = mode_get_display_name ( pd->switchers[i].mode ); const char *dname = mode_get_display_name ( pd->switchers[i].mode );
char * retv = g_strdup_printf ( "%s %s", dname, str ); char * retv = g_strdup_printf ( "%s %s", dname, str );
g_free ( str ); g_free ( str );
if ( attr_list != NULL ) { if ( attr_list != NULL ) {
ThemeWidget *wid = rofi_theme_find_widget ( sw->name, NULL, TRUE); ThemeWidget *wid = rofi_theme_find_widget ( sw->name, NULL, TRUE );
Property *p = rofi_theme_find_property ( wid, P_COLOR, pd->switchers[i].mode->name, TRUE); Property *p = rofi_theme_find_property ( wid, P_COLOR, pd->switchers[i].mode->name, TRUE );
if ( p != NULL ) { if ( p != NULL ) {
PangoAttribute *pa = pango_attr_foreground_new ( PangoAttribute *pa = pango_attr_foreground_new (
p->value.color.red * 65535, p->value.color.red * 65535,
p->value.color.green * 65535, p->value.color.green * 65535,
p->value.color.blue * 65535 ); p->value.color.blue * 65535 );
pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING; pa->start_index = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
pa->end_index = strlen(dname); pa->end_index = strlen ( dname );
*attr_list = g_list_append ( *attr_list, pa ); *attr_list = g_list_append ( *attr_list, pa );
} }
} }
return retv; return retv;

View file

@ -69,7 +69,7 @@ typedef struct
/* Generic Name */ /* Generic Name */
char *generic_name; char *generic_name;
#ifdef GET_CAT_PARSE_TIME #ifdef GET_CAT_PARSE_TIME
char **categories; char **categories;
#endif #endif
GKeyFile *key_file; GKeyFile *key_file;
@ -273,9 +273,9 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL ); gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL );
pd->entry_list[pd->cmd_list_length].generic_name = gn; pd->entry_list[pd->cmd_list_length].generic_name = gn;
#ifdef GET_CAT_PARSE_TIME #ifdef GET_CAT_PARSE_TIME
pd->entry_list[pd->cmd_list_length].categories= g_key_file_get_locale_string_list ( kf, "Desktop Entry", "Categories", NULL, NULL, NULL ); pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, "Desktop Entry", "Categories", NULL, NULL, NULL );
#endif #endif
pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, "Desktop Entry", "Exec", NULL ); pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, "Desktop Entry", "Exec", NULL );
// Keep keyfile around. // Keep keyfile around.
pd->entry_list[pd->cmd_list_length].key_file = kf; pd->entry_list[pd->cmd_list_length].key_file = kf;

View file

@ -50,12 +50,11 @@
#include "history.h" #include "history.h"
#include "dialogs/ssh.h" #include "dialogs/ssh.h"
/** /**
* Log domain for the ssh modi. * Log domain for the ssh modi.
*/ */
#define LOG_DOMAIN "Dialogs.Ssh" #define LOG_DOMAIN "Dialogs.Ssh"
/** /**
* Name of the history file where previously choosen hosts are stored. * Name of the history file where previously choosen hosts are stored.
@ -265,9 +264,9 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned int *length, unsigned int num_favorites ) static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned int *length, unsigned int num_favorites )
{ {
FILE *fd = fopen ( filename, "r" ); FILE *fd = fopen ( filename, "r" );
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Parsing ssh config file: %s" , filename); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Parsing ssh config file: %s", filename );
if ( fd != NULL ) { if ( fd != NULL ) {
char *buffer = NULL; char *buffer = NULL;
size_t buffer_length = 0; size_t buffer_length = 0;
@ -286,22 +285,23 @@ static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned
continue; continue;
} }
if ( g_strcmp0 ( token, "Include") == 0 ) { if ( g_strcmp0 ( token, "Include" ) == 0 ) {
token = strtok_r ( NULL, SSH_TOKEN_DELIM, &strtok_pointer ); token = strtok_r ( NULL, SSH_TOKEN_DELIM, &strtok_pointer );
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Found Include: %s" , token); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Found Include: %s", token );
gchar *path = rofi_expand_path ( token ); gchar *path = rofi_expand_path ( token );
gchar *full_path = NULL; gchar *full_path = NULL;
if ( ! g_path_is_absolute ( path ) ){ if ( !g_path_is_absolute ( path ) ) {
char *dirname = g_path_get_dirname ( filename ); char *dirname = g_path_get_dirname ( filename );
full_path = g_build_filename ( dirname, path, NULL ); full_path = g_build_filename ( dirname, path, NULL );
g_free(dirname); g_free ( dirname );
} else { }
else {
full_path = g_strdup ( path ); full_path = g_strdup ( path );
} }
glob_t globbuf = {0,}; glob_t globbuf = { 0, };
if ( glob ( full_path, 0, NULL, &globbuf ) == 0 ){ if ( glob ( full_path, 0, NULL, &globbuf ) == 0 ) {
for ( size_t iter = 0; iter < globbuf.gl_pathc; iter++){ for ( size_t iter = 0; iter < globbuf.gl_pathc; iter++ ) {
parse_ssh_config_file ( globbuf.gl_pathv[iter], retv, length, num_favorites ); parse_ssh_config_file ( globbuf.gl_pathv[iter], retv, length, num_favorites );
} }
} }
@ -333,7 +333,7 @@ static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned
// given num_favorites is max 25. // given num_favorites is max 25.
int found = 0; int found = 0;
for ( unsigned int j = 0; j < num_favorites; j++ ) { for ( unsigned int j = 0; j < num_favorites; j++ ) {
if ( !g_ascii_strcasecmp ( token, (*retv)[j] ) ) { if ( !g_ascii_strcasecmp ( token, ( *retv )[j] ) ) {
found = 1; found = 1;
break; break;
} }
@ -344,9 +344,9 @@ static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned
} }
// Add this host name to the list. // Add this host name to the list.
(*retv) = g_realloc ( (*retv), ( ( *length ) + 2 ) * sizeof ( char* ) ); ( *retv ) = g_realloc ( ( *retv ), ( ( *length ) + 2 ) * sizeof ( char* ) );
(*retv)[( *length )] = g_strdup ( token ); ( *retv )[( *length )] = g_strdup ( token );
(*retv)[( *length ) + 1] = NULL; ( *retv )[( *length ) + 1] = NULL;
( *length )++; ( *length )++;
} }
} }

View file

@ -53,7 +53,7 @@ char * mode_get_completion ( const Mode *mode, unsigned int selected_line )
else { else {
int state; int state;
g_assert ( mode->_get_display_value != NULL ); g_assert ( mode->_get_display_value != NULL );
return mode->_get_display_value ( mode, selected_line, &state,NULL, TRUE ); return mode->_get_display_value ( mode, selected_line, &state, NULL, TRUE );
} }
} }

View file

@ -404,7 +404,7 @@ static void cleanup ()
* Collected modi * Collected modi
*/ */
/** List of (possibly uninitialized) modi's */ /** List of (possibly uninitialized) modi's */
Mode ** available_modi = NULL; Mode ** available_modi = NULL;
/** Length of #num_available_modi */ /** Length of #num_available_modi */
unsigned int num_available_modi = 0; unsigned int num_available_modi = 0;

View file

@ -273,10 +273,10 @@ void yyerror ( YYLTYPE *yylloc, const char *what, const char* s )
g_string_append_printf ( str, "\tParser error: <span size=\"smaller\" style=\"italic\">%s</span>\n", esc ); g_string_append_printf ( str, "\tParser error: <span size=\"smaller\" style=\"italic\">%s</span>\n", esc );
g_free ( esc ); g_free ( esc );
if ( yylloc->filename != NULL ) { if ( yylloc->filename != NULL ) {
g_string_append_printf ( str, "\tLocation: line %d column %d to line %d column %d.\n"\ g_string_append_printf ( str, "\tLocation: line %d column %d to line %d column %d.\n" \
"\tFile '%s'\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column, yylloc->filename); "\tFile '%s'\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column, yylloc->filename );
}
}else { else {
g_string_append_printf ( str, "\tLocation: line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column ); g_string_append_printf ( str, "\tLocation: line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column );
} }
rofi_add_error_message ( str ); rofi_add_error_message ( str );
@ -320,10 +320,10 @@ static ThemeWidget *rofi_theme_find ( ThemeWidget *widget, const char *name, con
if ( widget == NULL || name == NULL ) { if ( widget == NULL || name == NULL ) {
return widget; return widget;
} }
char *tname = g_strdup(name ); char *tname = g_strdup ( name );
char *saveptr = NULL; char *saveptr = NULL;
int found = TRUE; int found = TRUE;
for (const char *iter = strtok_r (tname, ".", &saveptr); iter != NULL ; iter = strtok_r ( NULL, "." , &saveptr ) ) { for ( const char *iter = strtok_r ( tname, ".", &saveptr ); iter != NULL; iter = strtok_r ( NULL, ".", &saveptr ) ) {
found = FALSE; found = FALSE;
ThemeWidget *f = rofi_theme_find_single ( widget, iter ); ThemeWidget *f = rofi_theme_find_single ( widget, iter );
if ( f != widget ) { if ( f != widget ) {
@ -567,7 +567,7 @@ gboolean rofi_theme_is_empty ( void )
if ( rofi_theme == NULL ) { if ( rofi_theme == NULL ) {
return TRUE; return TRUE;
} }
if ( rofi_theme->properties == NULL && rofi_theme->num_widgets == 0 ) { if ( rofi_theme->properties == NULL && rofi_theme->num_widgets == 0 ) {
return TRUE; return TRUE;
} }

View file

@ -879,8 +879,8 @@ static void update_callback ( textbox *t, unsigned int index, void *udata, TextB
RofiViewState *state = (RofiViewState *) udata; RofiViewState *state = (RofiViewState *) udata;
if ( full ) { if ( full ) {
GList *add_list = NULL; GList *add_list = NULL;
int fstate = 0; int fstate = 0;
char *text = mode_get_display_value ( state->sw, state->line_map[index], &fstate, &add_list, TRUE ); char *text = mode_get_display_value ( state->sw, state->line_map[index], &fstate, &add_list, TRUE );
type |= fstate; type |= fstate;
textbox_font ( t, type ); textbox_font ( t, type );
// Move into list view. // Move into list view.
@ -898,12 +898,12 @@ static void update_callback ( textbox *t, unsigned int index, void *udata, TextB
th = rofi_theme_get_highlight ( WIDGET ( t ), "highlight", th ); th = rofi_theme_get_highlight ( WIDGET ( t ), "highlight", th );
helper_token_match_get_pango_attr ( th, state->tokens, textbox_get_visible_text ( t ), list ); helper_token_match_get_pango_attr ( th, state->tokens, textbox_get_visible_text ( t ), list );
} }
for ( GList *iter = g_list_first ( add_list ); iter != NULL ; iter = g_list_next(iter) ) { for ( GList *iter = g_list_first ( add_list ); iter != NULL; iter = g_list_next ( iter ) ) {
pango_attr_list_insert ( list, (PangoAttribute *)(iter->data)); pango_attr_list_insert ( list, (PangoAttribute *) ( iter->data ) );
} }
textbox_set_pango_attributes ( t, list ); textbox_set_pango_attributes ( t, list );
pango_attr_list_unref ( list ); pango_attr_list_unref ( list );
g_list_free( add_list); g_list_free ( add_list );
g_free ( text ); g_free ( text );
} }
else { else {

View file

@ -330,15 +330,13 @@ static void textbox_free ( widget *wid )
static void textbox_draw ( widget *wid, cairo_t *draw ) static void textbox_draw ( widget *wid, cairo_t *draw )
{ {
textbox *tb = (textbox *) wid; textbox *tb = (textbox *) wid;
unsigned int offset = ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0; unsigned int offset = ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0;
if ( tb->changed ) { if ( tb->changed ) {
__textbox_update_pango_text ( tb ); __textbox_update_pango_text ( tb );
} }
// Skip the side MARGIN on the X axis. // Skip the side MARGIN on the X axis.
int x = widget_padding_get_left ( WIDGET ( tb ) ) + offset; int x = widget_padding_get_left ( WIDGET ( tb ) ) + offset;
@ -360,7 +358,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
rofi_theme_get_color ( WIDGET ( tb ), "text", draw ); rofi_theme_get_color ( WIDGET ( tb ), "text", draw );
// draw the cursor // draw the cursor
if ( tb->flags & TB_EDITABLE && tb->blink ) { if ( tb->flags & TB_EDITABLE && tb->blink ) {
int y = top + ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE; int y = top + ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE;
// We want to place the cursor based on the text shown. // We want to place the cursor based on the text shown.
const char *text = pango_layout_get_text ( tb->layout ); const char *text = pango_layout_get_text ( tb->layout );
// Clamp the position, should not be needed, but we are paranoid. // Clamp the position, should not be needed, but we are paranoid.
@ -369,10 +367,10 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
// convert to byte location. // convert to byte location.
char *offset = g_utf8_offset_to_pointer ( text, cursor_offset ); char *offset = g_utf8_offset_to_pointer ( text, cursor_offset );
pango_layout_get_cursor_pos ( tb->layout, offset - text, &pos, NULL ); pango_layout_get_cursor_pos ( tb->layout, offset - text, &pos, NULL );
int cursor_x = pos.x / PANGO_SCALE; int cursor_x = pos.x / PANGO_SCALE;
int cursor_y = pos.y / PANGO_SCALE; int cursor_y = pos.y / PANGO_SCALE;
int cursor_height = pos.height / PANGO_SCALE; int cursor_height = pos.height / PANGO_SCALE;
int cursor_width = 2; int cursor_width = 2;
cairo_rectangle ( draw, x + cursor_x, y + cursor_y, cursor_width, cursor_height ); cairo_rectangle ( draw, x + cursor_x, y + cursor_y, cursor_width, cursor_height );
cairo_fill ( draw ); cairo_fill ( draw );
} }

View file

@ -184,11 +184,11 @@ void widget_draw ( widget *widget, cairo_t *d )
cairo_new_path ( d ); cairo_new_path ( d );
rofi_theme_get_color ( widget, "foreground", d ); rofi_theme_get_color ( widget, "foreground", d );
if ( left > 0 ) { if ( left > 0 ) {
double offset = ( radius_tl > 0 ) ? floor(top / 2.0) : 0; double offset = ( radius_tl > 0 ) ? floor ( top / 2.0 ) : 0;
cairo_set_line_width ( d, left ); cairo_set_line_width ( d, left );
distance_get_linestyle ( widget->border.left, d ); distance_get_linestyle ( widget->border.left, d );
cairo_move_to ( d, margin_left + left / 2.0, margin_top + radius_tl + offset ); cairo_move_to ( d, margin_left + left / 2.0, margin_top + radius_tl + offset );
offset = ( radius_bl > 0 ) ? floor(bottom / 2.0) : 0; offset = ( radius_bl > 0 ) ? floor ( bottom / 2.0 ) : 0;
cairo_line_to ( d, margin_left + left / 2.0, widget->h - margin_bottom - radius_bl - offset ); cairo_line_to ( d, margin_left + left / 2.0, widget->h - margin_bottom - radius_bl - offset );
cairo_stroke ( d ); cairo_stroke ( d );
} }
@ -216,11 +216,11 @@ void widget_draw ( widget *widget, cairo_t *d )
} }
} }
if ( top > 0 ) { if ( top > 0 ) {
double offset = ( radius_tl > 0 ) ? floor( left / 2.0 ) : 0; double offset = ( radius_tl > 0 ) ? floor ( left / 2.0 ) : 0;
cairo_set_line_width ( d, top ); cairo_set_line_width ( d, top );
distance_get_linestyle ( widget->border.top, d ); distance_get_linestyle ( widget->border.top, d );
cairo_move_to ( d, margin_left + radius_tl + offset, margin_top + top / 2.0 ); cairo_move_to ( d, margin_left + radius_tl + offset, margin_top + top / 2.0 );
offset = ( radius_tr > 0 ) ? floor(right / 2.0) : 0; offset = ( radius_tr > 0 ) ? floor ( right / 2.0 ) : 0;
cairo_line_to ( d, widget->w - margin_right - radius_tr - offset, margin_top + top / 2.0 ); cairo_line_to ( d, widget->w - margin_right - radius_tr - offset, margin_top + top / 2.0 );
cairo_stroke ( d ); cairo_stroke ( d );
} }
@ -247,11 +247,11 @@ void widget_draw ( widget *widget, cairo_t *d )
} }
} }
if ( right > 0 ) { if ( right > 0 ) {
double offset = ( radius_tr > 0 ) ? floor(top / 2.0) : 0; double offset = ( radius_tr > 0 ) ? floor ( top / 2.0 ) : 0;
cairo_set_line_width ( d, right ); cairo_set_line_width ( d, right );
distance_get_linestyle ( widget->border.right, d ); distance_get_linestyle ( widget->border.right, d );
cairo_move_to ( d, widget->w - margin_right - right / 2.0, margin_top + radius_tr + offset ); cairo_move_to ( d, widget->w - margin_right - right / 2.0, margin_top + radius_tr + offset );
offset = ( radius_br > 0 ) ?floor( bottom / 2.0) : 0; offset = ( radius_br > 0 ) ? floor ( bottom / 2.0 ) : 0;
cairo_line_to ( d, widget->w - margin_right - right / 2.0, widget->h - margin_bottom - radius_br - offset ); cairo_line_to ( d, widget->w - margin_right - right / 2.0, widget->h - margin_bottom - radius_br - offset );
cairo_stroke ( d ); cairo_stroke ( d );
} }
@ -278,11 +278,11 @@ void widget_draw ( widget *widget, cairo_t *d )
} }
} }
if ( bottom > 0 ) { if ( bottom > 0 ) {
double offset = ( radius_bl > 0 ) ? floor( left / 2.0 ) : 0; double offset = ( radius_bl > 0 ) ? floor ( left / 2.0 ) : 0;
cairo_set_line_width ( d, bottom ); cairo_set_line_width ( d, bottom );
distance_get_linestyle ( widget->border.bottom, d ); distance_get_linestyle ( widget->border.bottom, d );
cairo_move_to ( d, margin_left + radius_bl + offset, widget->h - bottom / 2.0 - margin_bottom ); cairo_move_to ( d, margin_left + radius_bl + offset, widget->h - bottom / 2.0 - margin_bottom );
offset = ( radius_br > 0 ) ? floor( right / 2.0 ) : 0; offset = ( radius_br > 0 ) ? floor ( right / 2.0 ) : 0;
cairo_line_to ( d, widget->w - margin_right - radius_br - offset, widget->h - bottom / 2.0 - margin_bottom ); cairo_line_to ( d, widget->w - margin_right - radius_br - offset, widget->h - bottom / 2.0 - margin_bottom );
cairo_stroke ( d ); cairo_stroke ( d );
} }

View file

@ -635,33 +635,34 @@ void config_parse_xresources_theme_dump ( void )
} }
} }
static char * config_parser_return_display_help_entry ( XrmOption *option ) static char * config_parser_return_display_help_entry ( XrmOption *option, size_t l )
{ {
int ll = (int) l;
switch ( option->type ) switch ( option->type )
{ {
case xrm_Number: case xrm_Number:
return g_markup_printf_escaped ( "<b%s</b> (%u) <span style='italic' size='small'>%s</span>", return g_markup_printf_escaped ( "<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>",
option->name, *( option->value.num ), option->comment ); ll, option->name + 3, *( option->value.num ), option->comment );
case xrm_SNumber: case xrm_SNumber:
return g_markup_printf_escaped ( "<b%s</b> (%d) <span style='italic' size='small'>%s</span>", return g_markup_printf_escaped ( "<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>",
option->name, *( option->value.snum ), option->comment ); ll, option->name + 3, *( option->value.snum ), option->comment );
case xrm_String: case xrm_String:
return g_markup_printf_escaped ( "<b>%s</b> (%s) <span style='italic' size='small'>%s</span>", return g_markup_printf_escaped ( "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>",
option->name, ll, option->name + 3,
( *( option->value.str ) != NULL ) ? *( option->value.str ) : "null", ( *( option->value.str ) != NULL ) ? *( option->value.str ) : "null",
option->comment option->comment
); );
case xrm_Boolean: case xrm_Boolean:
return g_markup_printf_escaped ( "<b>%s</b> (%s) <span style='italic' size='small'>%s</span>", return g_markup_printf_escaped ( "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>",
option->name, ( *( option->value.num ) == TRUE ) ? "true" : "false", option->comment ); ll, option->name + 3, ( *( option->value.num ) == TRUE ) ? "true" : "false", option->comment );
case xrm_Char: case xrm_Char:
if ( *( option->value.charc ) > 32 && *( option->value.charc ) < 127 ) { if ( *( option->value.charc ) > 32 && *( option->value.charc ) < 127 ) {
return g_markup_printf_escaped ( "<b>%s</b> (%c) <span style='italic' size='small'>%s</span>", return g_markup_printf_escaped ( "<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>",
option->name, *( option->value.charc ), option->comment ); ll, option->name + 3, *( option->value.charc ), option->comment );
} }
else { else {
return g_markup_printf_escaped ( "<b%s</b> (\\x%02X) <span style='italic' size='small'>%s</span>", return g_markup_printf_escaped ( "<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
option->name, *( option->value.charc ), option->comment ); ll, option->name + 3, *( option->value.charc ), option->comment );
} }
default: default:
break; break;
@ -674,6 +675,21 @@ char ** config_parser_return_display_help ( unsigned int *length )
{ {
unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions ); unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions );
char **retv = NULL; char **retv = NULL;
/**
* Get length of name
*/
size_t max_length = 0;
for ( unsigned int i = 0; i < entries; ++i ) {
size_t l = strlen ( xrmOptions[i].name );
max_length = MAX ( max_length, l );
}
for ( unsigned int i = 0; i < num_extra_options; i++ ) {
size_t l = strlen ( extra_options[i].name );
max_length = MAX ( max_length, l );
}
/**
* Generate entries
*/
for ( unsigned int i = 0; i < entries; ++i ) { for ( unsigned int i = 0; i < entries; ++i ) {
if ( ( i + 1 ) < entries ) { if ( ( i + 1 ) < entries ) {
if ( xrmOptions[i].value.str == xrmOptions[i + 1].value.str ) { if ( xrmOptions[i].value.str == xrmOptions[i + 1].value.str ) {
@ -686,7 +702,7 @@ char ** config_parser_return_display_help ( unsigned int *length )
retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) ); retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) );
retv[( *length )] = config_parser_return_display_help_entry ( &xrmOptions[i] ); retv[( *length )] = config_parser_return_display_help_entry ( &xrmOptions[i], max_length );
( *length )++; ( *length )++;
} }
for ( unsigned int i = 0; i < num_extra_options; i++ ) { for ( unsigned int i = 0; i < num_extra_options; i++ ) {
@ -694,7 +710,7 @@ char ** config_parser_return_display_help ( unsigned int *length )
continue; continue;
} }
retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) ); retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) );
retv[( *length )] = config_parser_return_display_help_entry ( &extra_options[i] ); retv[( *length )] = config_parser_return_display_help_entry ( &extra_options[i], max_length );
( *length )++; ( *length )++;
} }
if ( ( *length ) > 0 ) { if ( ( *length ) > 0 ) {