mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
parent
e7da00dbff
commit
52c5592a6f
9 changed files with 64 additions and 2 deletions
|
@ -190,6 +190,8 @@ rofi.kb-row-last: End,KP_End
|
|||
rofi.kb-row-select: Control+space
|
||||
! "Take a screenshot of the rofi window" Set from: File
|
||||
rofi.kb-screenshot: Alt+S
|
||||
! "Toggle between ellipsize modes for displayed data" Set from: Default
|
||||
! rofi.kb-ellipsize: Alt+period
|
||||
! "Toggle case sensitivity" Set from: File
|
||||
rofi.kb-toggle-case-sensitivity: grave,dead_grave
|
||||
! "Toggle sort" Set from: File
|
||||
|
|
|
@ -126,6 +126,7 @@ typedef enum
|
|||
CUSTOM_18,
|
||||
CUSTOM_19,
|
||||
SCREENSHOT,
|
||||
CHANGE_ELLIPSIZE,
|
||||
TOGGLE_SORT,
|
||||
SELECT_ELEMENT_1,
|
||||
SELECT_ELEMENT_2,
|
||||
|
|
|
@ -238,6 +238,12 @@ void listview_set_fixed_num_lines ( listview *lv );
|
|||
*/
|
||||
void listview_set_max_lines ( listview *lv, unsigned int max_lines );
|
||||
|
||||
/**
|
||||
* @param lv Handler to the listview object.
|
||||
*
|
||||
* Set ellipsize modee.
|
||||
*/
|
||||
void listview_toggle_ellipsizing ( listview *lv );
|
||||
/* @} */
|
||||
|
||||
#endif // ROFI_LISTVIEW_H
|
||||
|
|
|
@ -68,6 +68,7 @@ typedef struct
|
|||
double xalign;
|
||||
|
||||
PangoFontMetrics *metrics;
|
||||
PangoEllipsizeMode emode;
|
||||
int left_offset;
|
||||
//
|
||||
const char *theme_name;
|
||||
|
@ -334,5 +335,13 @@ int textbox_get_desired_width ( widget *wid );
|
|||
* Move the cursor to the end of the string.
|
||||
*/
|
||||
void textbox_cursor_end ( textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
* @param mode The PangoEllipsizeMode to use displaying the text in the textbox
|
||||
*
|
||||
* Set the ellipsizing mode used on the string.
|
||||
*/
|
||||
void textbox_set_ellipsize ( textbox *tb, PangoEllipsizeMode mode );
|
||||
/*@}*/
|
||||
#endif //ROFI_TEXTBOX_H
|
||||
|
|
|
@ -77,6 +77,7 @@ ActionBindingEntry rofi_bindings[] =
|
|||
{ .id = ROW_LAST, .name = "kb-row-last", .binding = "End,KP_End", .comment = "Go to the last entry" },
|
||||
{ .id = ROW_SELECT, .name = "kb-row-select", .binding = "Control+space", .comment = "Set selected item as input text" },
|
||||
{ .id = SCREENSHOT, .name = "kb-screenshot", .binding = "Alt+S", .comment = "Take a screenshot of the rofi window" },
|
||||
{ .id = CHANGE_ELLIPSIZE, .name = "kb-ellipsize", .binding = "Alt+period", .comment = "Toggle between ellipsize modes for displayed data" },
|
||||
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .binding = "grave,dead_grave", .comment = "Toggle case sensitivity" },
|
||||
{ .id = TOGGLE_SORT, .name = "kb-toggle-sort", .binding = "Alt+grave", .comment = "Toggle sort" },
|
||||
{ .id = CANCEL, .name = "kb-cancel", .binding = "Escape,Control+g,Control+bracketleft", .comment = "Quit rofi" },
|
||||
|
|
|
@ -1149,6 +1149,11 @@ static void rofi_view_trigger_global_action ( KeyBindingAction action )
|
|||
case SCREENSHOT:
|
||||
rofi_capture_screenshot ( );
|
||||
break;
|
||||
case CHANGE_ELLIPSIZE:
|
||||
if ( state->list_view ) {
|
||||
listview_toggle_ellipsizing ( state->list_view );
|
||||
}
|
||||
break;
|
||||
case TOGGLE_SORT:
|
||||
if ( state->case_indicator != NULL ) {
|
||||
config.sort = !config.sort;
|
||||
|
|
|
@ -109,6 +109,8 @@ struct _listview
|
|||
|
||||
char *listview_name;
|
||||
|
||||
|
||||
PangoEllipsizeMode emode;
|
||||
/** Barview */
|
||||
struct
|
||||
{
|
||||
|
@ -532,6 +534,7 @@ listview *listview_create ( widget *parent, const char *name, listview_update_ca
|
|||
lv->widget.get_desired_height = listview_get_desired_height;
|
||||
lv->eh = eh;
|
||||
|
||||
lv->emode = PANGO_ELLIPSIZE_END;
|
||||
lv->scrollbar = scrollbar_create ( WIDGET ( lv ), "scrollbar" );
|
||||
// Calculate height of an element.
|
||||
//
|
||||
|
@ -830,3 +833,21 @@ void listview_set_fixed_num_lines ( listview *lv )
|
|||
lv->fixed_num_lines = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void listview_toggle_ellipsizing ( listview *lv )
|
||||
{
|
||||
if ( lv ) {
|
||||
PangoEllipsizeMode mode = lv->emode;
|
||||
if ( mode == PANGO_ELLIPSIZE_START ) {
|
||||
mode = PANGO_ELLIPSIZE_MIDDLE;
|
||||
} else if ( mode == PANGO_ELLIPSIZE_MIDDLE ) {
|
||||
mode = PANGO_ELLIPSIZE_END;
|
||||
} else if ( mode == PANGO_ELLIPSIZE_END ) {
|
||||
mode = PANGO_ELLIPSIZE_START;
|
||||
}
|
||||
lv->emode = mode;
|
||||
for ( unsigned int i = 0; i < lv->cur_elements; i++ ) {
|
||||
textbox_set_ellipsize ( lv->boxes[i], mode );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,6 +177,7 @@ textbox* textbox_create ( widget *parent, WidgetType type, const char *name, Tex
|
|||
tb->widget.get_desired_height = textbox_get_desired_height;
|
||||
tb->widget.get_desired_width = textbox_get_desired_width;
|
||||
tb->flags = flags;
|
||||
tb->emode = PANGO_ELLIPSIZE_END;
|
||||
|
||||
tb->changed = FALSE;
|
||||
|
||||
|
@ -362,7 +363,9 @@ void textbox_moveresize ( textbox *tb, int x, int y, int w, int h )
|
|||
pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_MIDDLE );
|
||||
}
|
||||
else if ( ( tb->flags & TB_WRAP ) != TB_WRAP ) {
|
||||
pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_END );
|
||||
pango_layout_set_ellipsize ( tb->layout, tb->emode );
|
||||
} else {
|
||||
pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_NONE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,3 +953,17 @@ int textbox_get_desired_width ( widget *wid )
|
|||
pango_layout_set_width ( tb->layout, old_width );
|
||||
return width + padding + offset;
|
||||
}
|
||||
|
||||
|
||||
void textbox_set_ellipsize ( textbox *tb, PangoEllipsizeMode mode )
|
||||
{
|
||||
if ( tb )
|
||||
{
|
||||
tb->emode = mode;
|
||||
if ( ( tb->flags & TB_WRAP ) != TB_WRAP ) {
|
||||
// Store the mode.
|
||||
pango_layout_set_ellipsize ( tb->layout, tb->emode );
|
||||
widget_queue_redraw ( WIDGET ( tb ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ END_TEST
|
|||
START_TEST(test_mode_num_items)
|
||||
{
|
||||
unsigned int rows = mode_get_num_entries ( &help_keys_mode);
|
||||
ck_assert_int_eq ( rows, 71);
|
||||
ck_assert_int_eq ( rows, 72);
|
||||
for ( unsigned int i =0; i < rows; i++ ){
|
||||
int state = 0;
|
||||
GList *list = NULL;
|
||||
|
|
Loading…
Reference in a new issue