summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@blame.services>2022-01-31 12:56:18 +0100
committerDave Davenport <qball@blame.services>2022-01-31 12:56:18 +0100
commit61aa11ba12c17f4510cf9dd0bc25bd4e54969e71 (patch)
treef975a9a3a6e625e192784ad514d5722b0292ec55
parent36d4aee4900d9e029c17dbb09a899c7013b7d137 (diff)
[DMenu] Document the -display-columns and -display-column-separator option.
-rw-r--r--doc/rofi-dmenu.515
-rw-r--r--doc/rofi-dmenu.5.markdown10
-rw-r--r--source/dialogs/dmenu.c20
3 files changed, 38 insertions, 7 deletions
diff --git a/doc/rofi-dmenu.5 b/doc/rofi-dmenu.5
index 297dc3f0..49c12e55 100644
--- a/doc/rofi-dmenu.5
+++ b/doc/rofi-dmenu.5
@@ -274,6 +274,21 @@ Position \fBrofi\fP over the window with the given X11 window ID.
.PP
Set ellipsize mode to start. So, the end of the string is visible.
+.PP
+\fB\fC\-display\-columns\fR
+
+.PP
+A comma seperated list of columns to show.
+
+.PP
+\fB\fC\-display\-column\-separator\fR
+
+.PP
+The column separator. This is a regex.
+
+.PP
+\fIdefault\fP: '\\t'
+
.SH RETURN VALUE
.RS
.IP \(bu 2
diff --git a/doc/rofi-dmenu.5.markdown b/doc/rofi-dmenu.5.markdown
index 73ff2235..80c7e749 100644
--- a/doc/rofi-dmenu.5.markdown
+++ b/doc/rofi-dmenu.5.markdown
@@ -177,6 +177,16 @@ Position **rofi** over the window with the given X11 window ID.
Set ellipsize mode to start. So, the end of the string is visible.
+`-display-columns`
+
+A comma seperated list of columns to show.
+
+`-display-column-separator`
+
+The column separator. This is a regex.
+
+*default*: '\t'
+
## RETURN VALUE
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index ebfb810b..42b8a371 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -239,21 +239,23 @@ static gchar *dmenu_format_output_string(const DmenuModePrivateData *pd,
for (; splitted && splitted[ns]; ns++) {
;
}
+ GString *str_retv = g_string_new("");
for (uint32_t i = 0; pd->columns && pd->columns[i]; i++) {
unsigned int index =
(unsigned int)g_ascii_strtoull(pd->columns[i], NULL, 10);
- if (index < ns && index > 0) {
- if (retv == NULL) {
- retv = g_strdup(splitted[index - 1]);
+ if (index <= ns && index > 0) {
+ if (index == 1) {
+ g_string_append(str_retv, splitted[index - 1]);
} else {
- gchar *t = g_strjoin("\t", retv, splitted[index - 1], NULL);
- g_free(retv);
- retv = t;
+ g_string_append_c(str_retv, '\t');
+ g_string_append(str_retv, splitted[index - 1]);
}
}
}
g_strfreev(splitted);
- return retv ? retv : g_strdup("");
+ retv = str_retv->str;
+ g_string_free(str_retv, FALSE);
+ return retv;
}
static inline unsigned int get_index(unsigned int length, int index) {
@@ -818,4 +820,8 @@ void print_dmenu_options(void) {
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);
+ print_help_msg("--display-columns", "", "Only show the selected columns",
+ NULL, is_term);
+ print_help_msg("--display-column-separator", "\t",
+ "Separator to use to split columns (regex)", NULL, is_term);
}