Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -combi-display-format #1570

Merged
merged 1 commit into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Settings config = {
.plugin_path = PLUGIN_PATH,
.max_history_size = 25,
.combi_hide_mode_prefix = FALSE,
.combi_display_format = "{mode} {text}",

.matching_negate_char = '-',

Expand Down
14 changes: 14 additions & 0 deletions doc/rofi.1.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,20 @@ To get one merge view, of `window`,`run`, and `ssh`:
**NOTE**: The i3 window manager dislikes commas in the command when specifying an exec command.
For that case, `#` can be used as a separator.

`-combi-display-format`

The format string for entries in the `combi` dialog:

* **mode**: the mode display name
* **text**: the entry text

Pango markup can be used to formatting the output.

Default: {mode} {text}

Note: This setting is ignored if `combi-hide-mode-prefix` is eanbled.


### History and Sorting

`-disable-history`
Expand Down
2 changes: 2 additions & 0 deletions doc/test_xr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ rofi.scroll-method: 0
! rofi.max-history-size: 25
! "Hide the prefix mode prefix on the combi view." Set from: Default
! rofi.combi-hide-mode-prefix: false
! "Combi format string. (Supports: mode, text)" Set from: Default
! rofi.combi-display-format: {mode} {text}
! "Set the character used to negate the matching. ('\0' to disable)" Set from: Default
! rofi.matching-negate-char: -
! "Directory where history and temporary files are stored." Set from: Default
Expand Down
2 changes: 2 additions & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ typedef struct {
/** Maximum history length per mode. */
unsigned int max_history_size;
gboolean combi_hide_mode_prefix;
/** Combi format display */
char *combi_display_format;

char matching_negate_char;

Expand Down
15 changes: 14 additions & 1 deletion source/dialogs/combi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <stdlib.h>

#include "mode-private.h"
#include "widgets/textbox.h"
jirutka marked this conversation as resolved.
Show resolved Hide resolved
#include <dialogs/dialogs.h>
#include <pango/pango.h>
#include <theme.h>
Expand Down Expand Up @@ -225,8 +226,20 @@ static char *combi_mgrv(const Mode *sw, unsigned int selected_line, int *state,
selected_line - pd->starts[i],
state, attr_list, TRUE);
const char *dname = mode_get_display_name(pd->switchers[i].mode);

if (!config.combi_hide_mode_prefix) {
retv = g_strdup_printf("%s %s", dname, str);
if (!(*state & MARKUP)) {
char *tmp = str;
str = g_markup_escape_text(tmp, -1);
g_free(tmp);
*state |= MARKUP;
}

retv = helper_string_replace_if_exists(
config.combi_display_format,
"{mode}", dname,
"{text}", str,
NULL);
g_free(str);

if (attr_list != NULL) {
Expand Down
6 changes: 6 additions & 0 deletions source/xrmoptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ static XrmOption xrmOptions[] = {
NULL,
"Hide the prefix mode prefix on the combi view.",
CONFIG_DEFAULT},
{xrm_String,
"combi-display-format",
{.str = &config.combi_display_format},
NULL,
"Combi format string. (Supports: mode, text)",
CONFIG_DEFAULT},
{xrm_Char,
"matching-negate-char",
{.charc = &config.matching_negate_char},
Expand Down