mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-10 15:44:41 -05:00
Issue #287 mark selected rows.
This commit is contained in:
parent
f3897b2a60
commit
544229d975
3 changed files with 30 additions and 5 deletions
|
@ -47,15 +47,16 @@ typedef enum
|
||||||
NORMAL = 0,
|
NORMAL = 0,
|
||||||
URGENT = 1,
|
URGENT = 1,
|
||||||
ACTIVE = 2,
|
ACTIVE = 2,
|
||||||
MARKUP = 4,
|
SELECTED = 4,
|
||||||
|
MARKUP = 8,
|
||||||
|
|
||||||
// Alternating row.
|
// Alternating row.
|
||||||
ALT = 8,
|
ALT = 16,
|
||||||
// Render font highlighted (inverted colors.)
|
// Render font highlighted (inverted colors.)
|
||||||
HIGHLIGHT = 16,
|
HIGHLIGHT = 32,
|
||||||
|
|
||||||
FMOD_MASK = ( ALT | HIGHLIGHT ),
|
FMOD_MASK = ( ALT | HIGHLIGHT ),
|
||||||
STATE_MASK = ~( MARKUP | ALT | HIGHLIGHT )
|
STATE_MASK = ~( SELECTED | MARKUP | ALT | HIGHLIGHT )
|
||||||
} TextBoxFontType;
|
} TextBoxFontType;
|
||||||
|
|
||||||
textbox* textbox_create ( TextboxFlags flags,
|
textbox* textbox_create ( TextboxFlags flags,
|
||||||
|
|
|
@ -56,6 +56,8 @@ typedef struct _DmenuModePrivateData
|
||||||
unsigned int num_urgent_list;
|
unsigned int num_urgent_list;
|
||||||
struct range_pair * active_list;
|
struct range_pair * active_list;
|
||||||
unsigned int num_active_list;
|
unsigned int num_active_list;
|
||||||
|
struct range_pair * selected_list;
|
||||||
|
unsigned int num_selected_list;
|
||||||
// List with entries.
|
// List with entries.
|
||||||
char **cmd_list;
|
char **cmd_list;
|
||||||
unsigned int cmd_list_length;
|
unsigned int cmd_list_length;
|
||||||
|
@ -152,6 +154,11 @@ static char *get_display_data ( const Mode *data, unsigned int index, int *state
|
||||||
*state |= URGENT;
|
*state |= URGENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for ( unsigned int i = 0; i < pd->num_selected_list; i++ ) {
|
||||||
|
if ( index >= pd->selected_list[i].start && index <= pd->selected_list[i].stop ) {
|
||||||
|
*state |= SELECTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
return get_entry ? g_strdup ( retv[index] ) : NULL;
|
return get_entry ? g_strdup ( retv[index] ) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,6 +228,7 @@ static void dmenu_mode_free ( Mode *sw )
|
||||||
g_free ( pd->cmd_list );
|
g_free ( pd->cmd_list );
|
||||||
g_free ( pd->urgent_list );
|
g_free ( pd->urgent_list );
|
||||||
g_free ( pd->active_list );
|
g_free ( pd->active_list );
|
||||||
|
g_free ( pd->selected_list );
|
||||||
|
|
||||||
g_free ( pd );
|
g_free ( pd );
|
||||||
sw->private_data = NULL;
|
sw->private_data = NULL;
|
||||||
|
@ -386,6 +394,21 @@ int dmenu_switcher_dialog ( void )
|
||||||
dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input );
|
dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input );
|
||||||
if ( ( mretv & MENU_SHIFT ) ) {
|
if ( ( mretv & MENU_SHIFT ) ) {
|
||||||
restart = TRUE;
|
restart = TRUE;
|
||||||
|
int seen = FALSE;
|
||||||
|
if ( pd->selected_list != NULL ) {
|
||||||
|
if ( pd->selected_list[pd->num_selected_list - 1].stop == ( pd->selected_line - 1 ) ) {
|
||||||
|
pd->selected_list[pd->num_selected_list - 1].stop = pd->selected_line;
|
||||||
|
seen = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !seen ) {
|
||||||
|
pd->selected_list = g_realloc ( pd->selected_list,
|
||||||
|
( pd->num_selected_list + 1 ) * sizeof ( struct range_pair ) );
|
||||||
|
pd->selected_list[pd->num_selected_list].start = pd->selected_line;
|
||||||
|
pd->selected_list[pd->num_selected_list].stop = pd->selected_line;
|
||||||
|
( pd->num_selected_list )++;
|
||||||
|
}
|
||||||
|
|
||||||
// Move to next line.
|
// Move to next line.
|
||||||
pd->selected_line = MIN ( next_pos, cmd_list_length - 1 );
|
pd->selected_line = MIN ( next_pos, cmd_list_length - 1 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,8 @@ static void texbox_update ( textbox *tb )
|
||||||
|
|
||||||
// Set ARGB
|
// Set ARGB
|
||||||
col = tb->color_fg;
|
col = tb->color_fg;
|
||||||
cairo_set_source_rgba ( tb->main_draw, col.red, col.green, col.blue, col.alpha );
|
double scale = tb->tbft & SELECTED ? 0.5 : 1.0;
|
||||||
|
cairo_set_source_rgba ( tb->main_draw, col.red, col.green, col.blue, col.alpha * scale );
|
||||||
cairo_move_to ( tb->main_draw, x, y );
|
cairo_move_to ( tb->main_draw, x, y );
|
||||||
pango_cairo_show_layout ( tb->main_draw, tb->layout );
|
pango_cairo_show_layout ( tb->main_draw, tb->layout );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue