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

[Script] Add keep-selection flag that keeps the current selection.

Fixes: #1064
This commit is contained in:
Dave Davenport 2022-07-09 14:12:28 +02:00
parent 96027decd9
commit daf3127d3a
4 changed files with 17 additions and 1 deletions

View file

@ -9,6 +9,7 @@ if [ "$@" ]
then
# Override the previously set prompt.
echo -en "\0theme\x1felement-text { background-color: "$@";}\n"
echo -en "\0keep-selection\x1ftrue\n"
echo "red"
echo "lightgreen"
echo "lightblue"
@ -18,11 +19,16 @@ else
echo -en "\x00prompt\x1ftesting\n"
echo -en "\0urgent\x1f0,2\n"
echo -en "\0active\x1f1\n"
echo -en "\0keep-selection\x1ftrue\n"
echo -en "\0message\x1fSpecial <b>bold</b>message\n"
echo "red"
echo "lightgreen"
echo "lightblue"
echo "lightyellow"
echo "pink"
echo "green"
echo "blue"
echo "gold"
echo "quit"
fi

View file

@ -124,6 +124,8 @@ The following extra options exists:
.IP \(bu 2
\fBuse-hot-keys\fP: If set to true, it enabled the Custom keybindings for script. Warning this breaks the normal rofi flow.
.IP \(bu 2
\fBkeep-selection\fP: If set, the selection is not moved to the first entry, but the current position is maintained.
.IP \(bu 2
\fBdata\fP: Passed data to the next execution of the script via \fBROFI_DATA\fP\&.
.IP \(bu 2
\fBtheme\fP: Small theme snippet to f.e. change the background color of a widget.

View file

@ -88,6 +88,7 @@ The following extra options exists:
* **delim**: Set the delimiter for for next rows. Default is '\n' and this option should finish with this. Only call this on first call of script, it is remembered for consecutive calls.
* **no-custom**: If set to 'true'; only accept listed entries, ignore custom input.
* **use-hot-keys**: If set to true, it enabled the Custom keybindings for script. Warning this breaks the normal rofi flow.
* **keep-selection**: If set, the selection is not moved to the first entry, but the current position is maintained.
* **data**: Passed data to the next execution of the script via **ROFI_DATA**.
* **theme**: Small theme snippet to f.e. change the background color of a widget.

View file

@ -67,6 +67,7 @@ typedef struct {
char *prompt;
char *data;
gboolean do_markup;
gboolean keep_selection;
char delim;
/** no custom */
gboolean no_custom;
@ -135,6 +136,8 @@ static void parse_header_entry(Mode *sw, char *line, ssize_t length) {
pd->no_custom = (strcasecmp(value, "true") == 0);
} else if (strcasecmp(line, "use-hot-keys") == 0) {
pd->use_hot_keys = (strcasecmp(value, "true") == 0);
} else if (strcasecmp(line, "keep-selection") == 0) {
pd->keep_selection = (strcasecmp(value, "true") == 0);
} else if (strcasecmp(line, "data") == 0) {
g_free(pd->data);
pd->data = g_strdup(value);
@ -339,7 +342,11 @@ static ModeMode script_mode_result(Mode *sw, int mretv, char **input,
rmpd->cmd_list = new_list;
rmpd->cmd_list_length = new_length;
retv = RESET_DIALOG;
if (rmpd->keep_selection) {
retv = RELOAD_DIALOG;
} else {
retv = RESET_DIALOG;
}
}
return retv;
}