diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index d9570334..69d2138d 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -763,6 +763,34 @@ window { .fi .RE +.RS +.IP \(bu 2 +Format: \fB\fCvar(PROPERTY NAME, DEFAULT)\fR + +.RE + +.PP +A reference can point to another reference. Currently, the maximum number of redirects is 20. +A property always refers to another property. It cannot be used for a subpart of the property. + +.PP +Example: + +.PP +.RS + +.nf +window { + width: var( width, 30%); +} + +.fi +.RE + +.PP +If the property \fB\fCwidth\fR is set globally (\fB\fC*{}\fR) that value is used, if the property +\fB\fCwidth\fR is not set, the default value is used. + .SH Orientation .RS .IP \(bu 2 @@ -816,6 +844,31 @@ The environment variable should be an alphanumeric string without white\-space. .fi .RE +.RS +.IP \(bu 2 +Format: \fB\fCenv(ENVIRONMENT, default)\fR + +.RE + +.PP +This will parse the environment variable as the property value. (that then can be any of the above types). +The environment variable should be an alphanumeric string without white\-space. +If the environment value is not found, the default value is used. + +.PP +.RS + +.nf +window { + width: env(WIDTH, 40%); +} + +.fi +.RE + +.PP +If environment WIDTH is set, then that value is parsed, otherwise the default value (\fB\fC40%\fR). + .SH Inherit .RS .IP \(bu 2 diff --git a/doc/rofi.1 b/doc/rofi.1 index feaa8de1..2b3109bc 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1393,6 +1393,46 @@ To get a searchable list of key bindings, run \fB\fCrofi \-show keys\fR\&. .PP A key binding starting with \fB\fC!\fR will act when all keys have been released. +.PP +You can bind certain events to key\-actions: + +.SS Timeout +.PP +You can configure an action to be taken when rofi has not been interacted +with for a certain amount of seconds. You can specify a keybinding to trigger +after X seconds. + +.PP +.RS + +.nf +configuration { + timeout { + delay: 15; + action: "kb\-cancel"; + } +} + +.fi +.RE + +.SS Input change +.PP +When the input of the textbox changes: + +.PP +.RS + +.nf +configuration { + inputchange { + action: "kb\-row\-first"; + } +} + +.fi +.RE + .SH Available Modi .SS window .PP diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index e1b070a1..5113f14c 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -838,6 +838,36 @@ To get a searchable list of key bindings, run `rofi -show keys`. A key binding starting with `!` will act when all keys have been released. +You can bind certain events to key-actions: + +### Timeout + +You can configure an action to be taken when rofi has not been interacted +with for a certain amount of seconds. You can specify a keybinding to trigger +after X seconds. + +```css +configuration { + timeout { + delay: 15; + action: "kb-cancel"; + } +} +``` + +### Input change + +When the input of the textbox changes: + +```css +configuration { + inputchange { + action: "kb-row-first"; + } +} +``` + + ## Available Modi ### window diff --git a/source/view.c b/source/view.c index 5fd269d3..52b75754 100644 --- a/source/view.c +++ b/source/view.c @@ -455,9 +455,9 @@ static gboolean rofi_view_reload_idle(G_GNUC_UNUSED gpointer data) { CacheState.idle_timeout = 0; return G_SOURCE_REMOVE; } -static gboolean rofi_view_user_timeout(G_GNUC_UNUSED gpointer data) { - CacheState.user_timeout = 0; - ThemeWidget *wid = rofi_config_find_widget("timeout", NULL, TRUE); + +static void rofi_view_take_action(const char *name) { + ThemeWidget *wid = rofi_config_find_widget(name, NULL, TRUE); if (wid) { /** Check string property */ Property *p = rofi_theme_find_property(wid, P_STRING, "action", TRUE); @@ -471,6 +471,10 @@ static gboolean rofi_view_user_timeout(G_GNUC_UNUSED gpointer data) { } } } +} +static gboolean rofi_view_user_timeout(G_GNUC_UNUSED gpointer data) { + CacheState.user_timeout = 0; + rofi_view_take_action("timeout"); return G_SOURCE_REMOVE; } @@ -1229,6 +1233,12 @@ void rofi_view_finalize(RofiViewState *state) { } } +/** + * This function should be called when the input of the entry is changed. + * TODO: Evaluate if this needs to be a 'signal' on textbox? + */ +static void rofi_view_input_changed() { rofi_view_take_action("inputchange"); } + static void rofi_view_trigger_global_action(KeyBindingAction action) { RofiViewState *state = rofi_view_get_active(); switch (action) { @@ -1410,6 +1420,7 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) { if (rc == 1) { // Entry changed. state->refilter = TRUE; + rofi_view_input_changed(); } else if (rc == 2) { // Movement. } @@ -1499,6 +1510,7 @@ gboolean rofi_view_trigger_action(RofiViewState *state, BindingsScope scope, void rofi_view_handle_text(RofiViewState *state, char *text) { if (textbox_append_text(state->text, text, strlen(text))) { state->refilter = TRUE; + rofi_view_input_changed(); } }