[DMenu] Implement -keep-right

Fixes: #1089
This commit is contained in:
Dave Davenport 2020-04-16 23:31:43 +02:00
parent 1104d1d53a
commit 3e64e4422d
7 changed files with 48 additions and 1 deletions

View file

@ -1124,6 +1124,12 @@ Reads the first 25 entries blocking, then switches to async mode. This makes it
.PP
Set name used for the window title. Will be shown as Rofi \- \fItitle\fP
.PP
\fB\fC\-keep\-right\fR
.PP
Set ellipsize mode to start. So end of string is visible.
.SS Message dialog
.PP
\fB\fC\-e\fR \fImessage\fP

View file

@ -672,6 +672,11 @@ Reads the first 25 entries blocking, then switches to async mode. This makes it
Set name used for the window title. Will be shown as Rofi - *title*
`-keep-right`
Set ellipsize mode to start. So end of string is visible.
### Message dialog
`-e` *message*

View file

@ -306,5 +306,11 @@ void rofi_capture_screenshot ( void );
* Set the window title.
*/
void rofi_view_set_window_title ( const char * title );
/**
* set ellipsize mode to start.
*/
void rofi_view_ellipsize_start ( RofiViewState *state );
/**@}*/
#endif

View file

@ -241,9 +241,17 @@ void listview_set_max_lines ( listview *lv, unsigned int max_lines );
/**
* @param lv Handler to the listview object.
*
* Set ellipsize modee.
* Set ellipsize mode.
*/
void listview_toggle_ellipsizing ( listview *lv );
/**
* @param lv Handler to the listview object.
*
* Set ellipsize mode to start.
*/
void listview_set_ellipsize_start ( listview *lv );
/* @} */
#endif // ROFI_LISTVIEW_H

View file

@ -664,6 +664,7 @@ int dmenu_switcher_dialog ( void )
find_arg ( "-selected-row" ) >= 0 ) {
async = FALSE;
}
// Check if the subsystem is setup for reading, otherwise do not read.
if ( pd->cancel != NULL ) {
if ( async ) {
@ -732,6 +733,11 @@ 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 );
}
// @TODO we should do this better.
if ( async && ( pd->cancel != NULL ) ) {
rofi_view_set_overlay ( state, "Loading.. " );
@ -764,4 +770,5 @@ void print_dmenu_options ( void )
print_help_msg ( "-sync", "", "Force dmenu to first read all input data, then show dialog.", NULL, is_term );
print_help_msg ( "-async-pre-read", "[number]", "Read several entries blocking before switching to async mode", "25", is_term );
print_help_msg ( "-w", "windowid", "Position over window with X11 windowid.", NULL, is_term );
print_help_msg ( "-keep-right", "", "Set ellipsize to end.", NULL, is_term );
}

View file

@ -1988,6 +1988,11 @@ void rofi_view_clear_input ( RofiViewState *state )
}
}
void rofi_view_ellipsize_start ( RofiViewState *state )
{
listview_set_ellipsize_start ( state->list_view );
}
void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
{
state->sw = mode;

View file

@ -971,6 +971,16 @@ void listview_set_fixed_num_lines ( listview *lv )
}
}
void listview_set_ellipsize_start ( listview *lv )
{
if ( lv ) {
lv->emode = PANGO_ELLIPSIZE_START;
for ( unsigned int i = 0; i < lv->cur_elements; i++ ) {
textbox_set_ellipsize ( lv->boxes[i].textbox, lv->emode );
}
}
}
void listview_toggle_ellipsizing ( listview *lv )
{
if ( lv ) {