mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
[Script] Add keep-selection flag that keeps the current selection.
Fixes: #1064
This commit is contained in:
parent
96027decd9
commit
daf3127d3a
4 changed files with 17 additions and 1 deletions
|
@ -9,6 +9,7 @@ if [ "$@" ]
|
||||||
then
|
then
|
||||||
# Override the previously set prompt.
|
# Override the previously set prompt.
|
||||||
echo -en "\0theme\x1felement-text { background-color: "$@";}\n"
|
echo -en "\0theme\x1felement-text { background-color: "$@";}\n"
|
||||||
|
echo -en "\0keep-selection\x1ftrue\n"
|
||||||
echo "red"
|
echo "red"
|
||||||
echo "lightgreen"
|
echo "lightgreen"
|
||||||
echo "lightblue"
|
echo "lightblue"
|
||||||
|
@ -18,11 +19,16 @@ else
|
||||||
echo -en "\x00prompt\x1ftesting\n"
|
echo -en "\x00prompt\x1ftesting\n"
|
||||||
echo -en "\0urgent\x1f0,2\n"
|
echo -en "\0urgent\x1f0,2\n"
|
||||||
echo -en "\0active\x1f1\n"
|
echo -en "\0active\x1f1\n"
|
||||||
|
echo -en "\0keep-selection\x1ftrue\n"
|
||||||
echo -en "\0message\x1fSpecial <b>bold</b>message\n"
|
echo -en "\0message\x1fSpecial <b>bold</b>message\n"
|
||||||
|
|
||||||
echo "red"
|
echo "red"
|
||||||
echo "lightgreen"
|
echo "lightgreen"
|
||||||
echo "lightblue"
|
echo "lightblue"
|
||||||
echo "lightyellow"
|
echo "lightyellow"
|
||||||
|
echo "pink"
|
||||||
|
echo "green"
|
||||||
|
echo "blue"
|
||||||
|
echo "gold"
|
||||||
echo "quit"
|
echo "quit"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -124,6 +124,8 @@ The following extra options exists:
|
||||||
.IP \(bu 2
|
.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.
|
\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
|
.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\&.
|
\fBdata\fP: Passed data to the next execution of the script via \fBROFI_DATA\fP\&.
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
\fBtheme\fP: Small theme snippet to f.e. change the background color of a widget.
|
\fBtheme\fP: Small theme snippet to f.e. change the background color of a widget.
|
||||||
|
|
|
@ -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.
|
* **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.
|
* **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.
|
* **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**.
|
* **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.
|
* **theme**: Small theme snippet to f.e. change the background color of a widget.
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ typedef struct {
|
||||||
char *prompt;
|
char *prompt;
|
||||||
char *data;
|
char *data;
|
||||||
gboolean do_markup;
|
gboolean do_markup;
|
||||||
|
gboolean keep_selection;
|
||||||
char delim;
|
char delim;
|
||||||
/** no custom */
|
/** no custom */
|
||||||
gboolean 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);
|
pd->no_custom = (strcasecmp(value, "true") == 0);
|
||||||
} else if (strcasecmp(line, "use-hot-keys") == 0) {
|
} else if (strcasecmp(line, "use-hot-keys") == 0) {
|
||||||
pd->use_hot_keys = (strcasecmp(value, "true") == 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) {
|
} else if (strcasecmp(line, "data") == 0) {
|
||||||
g_free(pd->data);
|
g_free(pd->data);
|
||||||
pd->data = g_strdup(value);
|
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 = new_list;
|
||||||
rmpd->cmd_list_length = new_length;
|
rmpd->cmd_list_length = new_length;
|
||||||
retv = RESET_DIALOG;
|
if (rmpd->keep_selection) {
|
||||||
|
retv = RELOAD_DIALOG;
|
||||||
|
} else {
|
||||||
|
retv = RESET_DIALOG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue