summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2020-04-16 23:31:43 +0200
committerDave Davenport <qball@gmpclient.org>2020-04-16 23:31:43 +0200
commit3e64e4422df516acb519de767889890e384c7645 (patch)
tree0c02bd6c5cd5a7691da61db1f586df5af3378129
parent1104d1d53a6e8be8448adb2ef5bf7d66d08aa5b9 (diff)
[DMenu] Implement -keep-right
Fixes: #1089
-rw-r--r--doc/rofi.16
-rw-r--r--doc/rofi.1.markdown5
-rw-r--r--include/view.h6
-rw-r--r--include/widgets/listview.h10
-rw-r--r--source/dialogs/dmenu.c7
-rw-r--r--source/view.c5
-rw-r--r--source/widgets/listview.c10
7 files changed, 48 insertions, 1 deletions
diff --git a/doc/rofi.1 b/doc/rofi.1
index 8b2f214c..30d661dc 100644
--- a/doc/rofi.1
+++ b/doc/rofi.1
@@ -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
diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown
index f5460340..f63e4206 100644
--- a/doc/rofi.1.markdown
+++ b/doc/rofi.1.markdown
@@ -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*
diff --git a/include/view.h b/include/view.h
index ed194466..ba07f32e 100644
--- a/include/view.h
+++ b/include/view.h
@@ -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
diff --git a/include/widgets/listview.h b/include/widgets/listview.h
index 0aa6fab0..90c31bba 100644
--- a/include/widgets/listview.h
+++ b/include/widgets/listview.h
@@ -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
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index 6322e3e3..219dc98a 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -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 );
}
diff --git a/source/view.c b/source/view.c
index 3f3b6319..2c746e37 100644
--- a/source/view.c
+++ b/source/view.c
@@ -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;
diff --git a/source/widgets/listview.c b/source/widgets/listview.c
index 8739a846..e77438c0 100644
--- a/source/widgets/listview.c
+++ b/source/widgets/listview.c
@@ -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 ) {