[DMenu] Document the -display-columns and -display-column-separator option.

This commit is contained in:
Dave Davenport 2022-01-31 12:56:18 +01:00
parent 36d4aee490
commit 61aa11ba12
3 changed files with 38 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}