mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[Script] Add new-selection option.
Allow you to select an entry (based on view, so might not work in combi mode). fixes: #1248
This commit is contained in:
parent
d20926abab
commit
f3064e0fee
2 changed files with 12 additions and 1 deletions
|
@ -10,6 +10,7 @@ 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 -en "\0keep-selection\x1ftrue\n"
|
||||||
|
echo -en "\0new-selection\x1f2\n"
|
||||||
echo "red"
|
echo "red"
|
||||||
echo "lightgreen"
|
echo "lightgreen"
|
||||||
echo "lightblue"
|
echo "lightblue"
|
||||||
|
|
|
@ -68,6 +68,7 @@ typedef struct {
|
||||||
char *data;
|
char *data;
|
||||||
gboolean do_markup;
|
gboolean do_markup;
|
||||||
gboolean keep_selection;
|
gboolean keep_selection;
|
||||||
|
int64_t new_selection;
|
||||||
char delim;
|
char delim;
|
||||||
/** no custom */
|
/** no custom */
|
||||||
gboolean no_custom;
|
gboolean no_custom;
|
||||||
|
@ -138,6 +139,8 @@ static void parse_header_entry(Mode *sw, char *line, ssize_t length) {
|
||||||
pd->use_hot_keys = (strcasecmp(value, "true") == 0);
|
pd->use_hot_keys = (strcasecmp(value, "true") == 0);
|
||||||
} else if (strcasecmp(line, "keep-selection") == 0) {
|
} else if (strcasecmp(line, "keep-selection") == 0) {
|
||||||
pd->keep_selection = (strcasecmp(value, "true") == 0);
|
pd->keep_selection = (strcasecmp(value, "true") == 0);
|
||||||
|
} else if (strcasecmp(line, "new-selection") == 0) {
|
||||||
|
pd->new_selection = (int64_t)g_ascii_strtoll(value, NULL, 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);
|
||||||
|
@ -160,7 +163,9 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
|
||||||
char **argv = NULL;
|
char **argv = NULL;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
*length = 0;
|
*length = 0;
|
||||||
|
// Reset these between runs.
|
||||||
|
pd->new_selection = -1;
|
||||||
|
pd->keep_selection = -1;
|
||||||
// Environment
|
// Environment
|
||||||
char **env = g_get_environ();
|
char **env = g_get_environ();
|
||||||
|
|
||||||
|
@ -343,6 +348,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;
|
||||||
if (rmpd->keep_selection) {
|
if (rmpd->keep_selection) {
|
||||||
|
if (rmpd->new_selection >= 0 &&
|
||||||
|
rmpd->new_selection < rmpd->cmd_list_length) {
|
||||||
|
rofi_view_set_selected_line(rofi_view_get_active(),
|
||||||
|
rmpd->new_selection);
|
||||||
|
}
|
||||||
retv = RELOAD_DIALOG;
|
retv = RELOAD_DIALOG;
|
||||||
} else {
|
} else {
|
||||||
retv = RESET_DIALOG;
|
retv = RESET_DIALOG;
|
||||||
|
|
Loading…
Reference in a new issue