Skip to content

Commit

Permalink
Fixed indent, second try
Browse files Browse the repository at this point in the history
  • Loading branch information
jchtt committed May 12, 2020
1 parent 4c16958 commit d3d2e84
Show file tree
Hide file tree
Showing 14 changed files with 259 additions and 250 deletions.
11 changes: 5 additions & 6 deletions include/rofi-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,29 @@ typedef enum
ROFI_DISTANCE_MODIFIER_GROUP,
} RofiDistanceModifier;

typedef struct RofiDistanceUnit
typedef struct RofiDistanceUnit
{
/** Distance */
double distance;
double distance;
/** Unit type of the distance */
RofiPixelUnit type;
RofiPixelUnit type;

/** Type */
RofiDistanceModifier modtype;
RofiDistanceModifier modtype;

/** Modifier */
struct RofiDistanceUnit *left;

/** Modifier */
struct RofiDistanceUnit *right;

} RofiDistanceUnit;

typedef struct
{
/** Base */
RofiDistanceUnit base;
/** Style of the line (optional)*/
RofiLineStyle style;
RofiLineStyle style;
} RofiDistance;

/**
Expand Down
1 change: 0 additions & 1 deletion include/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doub
*/
void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d );


/**
* @param widget The widget to query
* @param property The property to query.
Expand Down
1 change: 0 additions & 1 deletion include/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ void rofi_capture_screenshot ( void );
*/
void rofi_view_set_window_title ( const char * title );


/**
* set ellipsize mode to start.
*/
Expand Down
84 changes: 42 additions & 42 deletions source/dialogs/combi.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef struct
{
Mode *mode;
gboolean disable;
gboolean print_newline;
gboolean print_newline;
} CombiMode;

typedef struct
Expand All @@ -72,8 +72,8 @@ static void combi_mode_parse_switchers ( Mode *sw )
const char * const sep = ",#";
// Split token on ','. This modifies switcher_str.

GHashTable *ht;
ht = g_hash_table_new ( g_str_hash, g_str_equal );
GHashTable *ht;
ht = g_hash_table_new ( g_str_hash, g_str_equal );

for ( char *token = strtok_r ( switcher_str, sep, &savept ); token != NULL;
token = strtok_r ( NULL, sep, &savept ) ) {
Expand All @@ -83,20 +83,20 @@ static void combi_mode_parse_switchers ( Mode *sw )

Mode *mode = rofi_collect_modi_search ( token );
if ( mode ) {
pd->switchers[pd->num_switchers].disable = FALSE;
pd->switchers[pd->num_switchers].mode = mode;
pd->switchers[pd->num_switchers].print_newline = TRUE;
g_hash_table_insert( ht, token, &( pd->switchers[pd->num_switchers++] ) );
/* g_hash_table_insert( ht, token, pd->switchers + pd->num_switchers ); */
pd->switchers[pd->num_switchers].disable = FALSE;
pd->switchers[pd->num_switchers].mode = mode;
pd->switchers[pd->num_switchers].print_newline = TRUE;
g_hash_table_insert ( ht, token, &( pd->switchers[pd->num_switchers++] ) );
/* g_hash_table_insert( ht, token, pd->switchers + pd->num_switchers ); */
}
else {
// If not build in, use custom switchers.
Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) {
pd->switchers[pd->num_switchers].disable = FALSE;
pd->switchers[pd->num_switchers].mode = sw;
pd->switchers[pd->num_switchers].print_newline = TRUE;
g_hash_table_insert( ht, token, &( pd->switchers[pd->num_switchers++] ) );
pd->switchers[pd->num_switchers].disable = FALSE;
pd->switchers[pd->num_switchers].mode = sw;
pd->switchers[pd->num_switchers].print_newline = TRUE;
g_hash_table_insert ( ht, token, &( pd->switchers[pd->num_switchers++] ) );
}
else {
// Report error, don't continue.
Expand All @@ -109,17 +109,17 @@ static void combi_mode_parse_switchers ( Mode *sw )
savept = NULL;
for ( char *token = strtok_r ( config.combi_no_linebreak_modi, sep, &savept ); token != NULL;
token = strtok_r ( NULL, sep, &savept ) ) {
CombiMode *mode = g_hash_table_lookup ( ht, token );
if ( mode != NULL ) {
mode->print_newline = FALSE;
}
else {
g_warning ( "%s is in -combi-no-linebreak-modi but not in -combi-modi.", token );
}
}
CombiMode *mode = g_hash_table_lookup ( ht, token );
if ( mode != NULL ) {
mode->print_newline = FALSE;
}
else {
g_warning ( "%s is in -combi-no-linebreak-modi but not in -combi-modi.", token );
}
}
// Free string that was modified by strtok_r
g_free ( switcher_str );
g_hash_table_destroy( ht );
g_hash_table_destroy ( ht );
}

static int combi_mode_init ( Mode *sw )
Expand Down Expand Up @@ -179,11 +179,11 @@ static ModeMode combi_mode_result ( Mode *sw, int mretv, char **input, unsigned
CombiModePrivateData *pd = mode_get_private_data ( sw );

if ( input[0][0] == '!' ) {
int switcher = -1;
int switcher = -1;
// Implement strchrnul behaviour.
char *eob = g_utf8_strchr ( input[0], -1,' ' );
char *eob = g_utf8_strchr ( input[0], -1, ' ' );
if ( eob == NULL ) {
eob = &(input[0][strlen(input[0])]);
eob = &( input[0][strlen ( input[0] )] );
}
ssize_t bang_len = g_utf8_pointer_to_offset ( input[0], eob ) - 1;
if ( bang_len > 0 ) {
Expand All @@ -208,11 +208,11 @@ static ModeMode combi_mode_result ( Mode *sw, int mretv, char **input, unsigned
return mretv & MENU_LOWER_MASK;
}

unsigned offset = 0;
unsigned offset = 0;
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
if ( pd->switchers[i].disable ) {
offset += pd->lengths[i];
}
if ( pd->switchers[i].disable ) {
offset += pd->lengths[i];
}
if ( selected_line >= pd->starts[i] &&
selected_line < ( pd->starts[i] + pd->lengths[i] ) ) {
return mode_result ( pd->switchers[i].mode, mretv, input, selected_line - pd->starts[i] );
Expand All @@ -236,9 +236,9 @@ static int combi_mode_match ( const Mode *sw, rofi_int_matcher **tokens, unsigne
static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *state, GList **attr_list, int get_entry )
{
CombiModePrivateData *pd = mode_get_private_data ( sw );
if (config.markup_combi) {
*state |= MARKUP;
}
if ( config.markup_combi ) {
*state |= MARKUP;
}
if ( !get_entry ) {
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
if ( selected_line >= pd->starts[i] && selected_line < ( pd->starts[i] + pd->lengths[i] ) ) {
Expand All @@ -254,16 +254,16 @@ static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *stat
char * str = retv = 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 );
if ( !config.combi_hide_mode_prefix ) {
char *dname_markup = g_markup_escape_text ( dname, -1 );
char *opt_linebreak = g_strdup(pd->switchers[i].print_newline ? "\n" : config.combi_no_linebreak_str);
retv = helper_string_replace_if_exists( config.combi_display_format,
"{mode}", dname_markup,
"{linebreak}", opt_linebreak,
"{element}", str,
NULL );
char *dname_markup = g_markup_escape_text ( dname, -1 );
char *opt_linebreak = g_strdup ( pd->switchers[i].print_newline ? "\n" : config.combi_no_linebreak_str );
retv = helper_string_replace_if_exists ( config.combi_display_format,
"{mode}", dname_markup,
"{linebreak}", opt_linebreak,
"{element}", str,
NULL );
g_free ( str );
g_free ( dname_markup );
g_free ( opt_linebreak );
g_free ( dname_markup );
g_free ( opt_linebreak );
}

if ( attr_list != NULL ) {
Expand Down Expand Up @@ -321,10 +321,10 @@ static char * combi_preprocess_input ( Mode *sw, const char *input )
}
if ( input != NULL && input[0] == '!' ) {
// Implement strchrnul behaviour.
const char *eob = g_utf8_strchr ( input, -1, ' ' );
const char *eob = g_utf8_strchr ( input, -1, ' ' );
if ( eob == NULL ) {
// Set it to end.
eob = &(input[strlen(input)]);
eob = &( input[strlen ( input )] );
}
ssize_t bang_len = g_utf8_pointer_to_offset ( input, eob ) - 1;
if ( bang_len > 0 ) {
Expand Down
1 change: 0 additions & 1 deletion source/dialogs/dmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ int dmenu_switcher_dialog ( void )
find_arg_str ( "-p", &( dmenu_mode.display_name ) );
RofiViewState *state = rofi_view_create ( &dmenu_mode, input, menu_flags, dmenu_finalize );


if ( find_arg ( "-keep-right" ) >= 0 ) {
rofi_view_ellipsize_start ( state );
}
Expand Down
2 changes: 1 addition & 1 deletion source/dialogs/drun.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static gboolean drun_helper_eval_cb ( const GMatchInfo *info, GString *res, gpoi
case 'm':
break;
case '%':
g_string_append(res, "%");
g_string_append ( res, "%" );
break;
case 'k':
if ( e->e->path ) {
Expand Down
46 changes: 24 additions & 22 deletions source/dialogs/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct
char *message;
char *prompt;
gboolean do_markup;
char delim;
char delim;
/** no custom */
gboolean no_custom;
} ScriptModePrivateData;
Expand All @@ -83,7 +83,7 @@ void dmenuscript_parse_entry_extras ( G_GNUC_UNUSED Mode *sw, DmenuScriptEntry *
length_key++;
}
// Should be not last character in buffer.
if ( (length_key+1) < (length) ) {
if ( ( length_key + 1 ) < ( length ) ) {
buffer[length_key] = '\0';
char *value = buffer + length_key + 1;
if ( strcasecmp ( buffer, "icon" ) == 0 ) {
Expand All @@ -110,7 +110,7 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
length_key++;
}

if ( (length_key+1) < length ) {
if ( ( length_key + 1 ) < length ) {
line[length_key] = '\0';
char *value = line + length_key + 1;
if ( strcasecmp ( line, "message" ) == 0 ) {
Expand All @@ -133,31 +133,30 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
}
else if ( strcasecmp ( line, "delim" ) == 0 ) {
pd->delim = helper_parse_char ( value );
} else if ( strcasecmp ( line, "no-custom" ) == 0 ) {
pd->no_custom = ( strcasecmp ( value, "true") == 0 );
}
else if ( strcasecmp ( line, "no-custom" ) == 0 ) {
pd->no_custom = ( strcasecmp ( value, "true" ) == 0 );
}
}
}

static DmenuScriptEntry *execute_executor ( Mode *sw, char *arg, unsigned int *length, int value )
{
ScriptModePrivateData *pd = (ScriptModePrivateData *) sw->private_data;
int fd = -1;
GError *error = NULL;
DmenuScriptEntry *retv = NULL;
char **argv = NULL;
int argc = 0;
ScriptModePrivateData *pd = (ScriptModePrivateData *) sw->private_data;
int fd = -1;
GError *error = NULL;
DmenuScriptEntry *retv = NULL;
char **argv = NULL;
int argc = 0;
*length = 0;


// Environment
char ** env = g_get_environ ();

char *str_value = g_strdup_printf("%d", value);
env = g_environ_setenv ( env, "ROFI_RETV", str_value, TRUE);
char *str_value = g_strdup_printf ( "%d", value );
env = g_environ_setenv ( env, "ROFI_RETV", str_value, TRUE );
g_free ( str_value );


if ( g_shell_parse_argv ( sw->ed, &argc, &argv, &error ) ) {
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );
argv[argc] = g_strdup ( arg );
Expand All @@ -166,7 +165,7 @@ static DmenuScriptEntry *execute_executor ( Mode *sw, char *arg, unsigned int *l
}
g_strfreev ( env );
if ( error != NULL ) {
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", (char*)sw->ed, error->message );
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", (char*) sw->ed, error->message );
rofi_view_error_dialog ( msg, FALSE );
g_free ( msg );
// print error.
Expand Down Expand Up @@ -233,7 +232,7 @@ static int script_mode_init ( Mode *sw )
{
if ( sw->private_data == NULL ) {
ScriptModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
pd->delim = '\n';
pd->delim = '\n';
sw->private_data = (void *) pd;
pd->cmd_list = execute_executor ( sw, NULL, &( pd->cmd_list_length ), 0 );
}
Expand Down Expand Up @@ -274,11 +273,13 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
//retv = 1+( mretv & MENU_LOWER_MASK );
script_mode_reset_highlight ( sw );
if ( selected_line != UINT32_MAX ) {
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length,10+( mretv & MENU_LOWER_MASK ) );
} else {
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 10 + ( mretv & MENU_LOWER_MASK ) );
}
else {
if ( rmpd->no_custom == FALSE ) {
new_list = execute_executor ( sw, *input, &new_length,10+( mretv & MENU_LOWER_MASK ) );
} else {
new_list = execute_executor ( sw, *input, &new_length, 10 + ( mretv & MENU_LOWER_MASK ) );
}
else {
return RELOAD_DIALOG;
}
}
Expand All @@ -294,7 +295,8 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
if ( rmpd->no_custom == FALSE ) {
script_mode_reset_highlight ( sw );
new_list = execute_executor ( sw, *input, &new_length, 2 );
} else {
}
else {
return RELOAD_DIALOG;
}
}
Expand Down
Loading

0 comments on commit d3d2e84

Please sign in to comment.