1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Add -combi-display-format (#1570)

Implement a new option -combi-display-format (analogous to
-drun-display-format) that allows to change position appearance of
the mode name in the combi entries.
This commit is contained in:
Jakub Jirutka 2022-01-22 22:03:10 +01:00 committed by GitHub
parent 64062b2a94
commit 50b85ba954
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 1 deletions

View file

@ -133,6 +133,7 @@ Settings config = {
.plugin_path = PLUGIN_PATH, .plugin_path = PLUGIN_PATH,
.max_history_size = 25, .max_history_size = 25,
.combi_hide_mode_prefix = FALSE, .combi_hide_mode_prefix = FALSE,
.combi_display_format = "{mode} {text}",
.matching_negate_char = '-', .matching_negate_char = '-',

View file

@ -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. **NOTE**: The i3 window manager dislikes commas in the command when specifying an exec command.
For that case, `#` can be used as a separator. 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 ### History and Sorting
`-disable-history` `-disable-history`

View file

@ -120,6 +120,8 @@ rofi.scroll-method: 0
! rofi.max-history-size: 25 ! rofi.max-history-size: 25
! "Hide the prefix mode prefix on the combi view." Set from: Default ! "Hide the prefix mode prefix on the combi view." Set from: Default
! rofi.combi-hide-mode-prefix: false ! 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 ! "Set the character used to negate the matching. ('\0' to disable)" Set from: Default
! rofi.matching-negate-char: - ! rofi.matching-negate-char: -
! "Directory where history and temporary files are stored." Set from: Default ! "Directory where history and temporary files are stored." Set from: Default

View file

@ -154,6 +154,8 @@ typedef struct {
/** Maximum history length per mode. */ /** Maximum history length per mode. */
unsigned int max_history_size; unsigned int max_history_size;
gboolean combi_hide_mode_prefix; gboolean combi_hide_mode_prefix;
/** Combi format display */
char *combi_display_format;
char matching_negate_char; char matching_negate_char;

View file

@ -35,6 +35,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "mode-private.h" #include "mode-private.h"
#include "widgets/textbox.h"
#include <dialogs/dialogs.h> #include <dialogs/dialogs.h>
#include <pango/pango.h> #include <pango/pango.h>
#include <theme.h> #include <theme.h>
@ -225,8 +226,20 @@ static char *combi_mgrv(const Mode *sw, unsigned int selected_line, int *state,
selected_line - pd->starts[i], selected_line - pd->starts[i],
state, attr_list, TRUE); state, attr_list, TRUE);
const char *dname = mode_get_display_name(pd->switchers[i].mode); const char *dname = mode_get_display_name(pd->switchers[i].mode);
if (!config.combi_hide_mode_prefix) { 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); g_free(str);
if (attr_list != NULL) { if (attr_list != NULL) {

View file

@ -356,6 +356,12 @@ static XrmOption xrmOptions[] = {
NULL, NULL,
"Hide the prefix mode prefix on the combi view.", "Hide the prefix mode prefix on the combi view.",
CONFIG_DEFAULT}, CONFIG_DEFAULT},
{xrm_String,
"combi-display-format",
{.str = &config.combi_display_format},
NULL,
"Combi format string. (Supports: mode, text)",
CONFIG_DEFAULT},
{xrm_Char, {xrm_Char,
"matching-negate-char", "matching-negate-char",
{.charc = &config.matching_negate_char}, {.charc = &config.matching_negate_char},