mirror of
https://github.com/davatorium/rofi.git
synced 2025-04-14 17:43:01 -04:00
[Doc] Fix documentation and test for keybindings
This commit is contained in:
parent
f0c938c3d8
commit
46bfc49640
4 changed files with 55 additions and 50 deletions
|
@ -495,6 +495,18 @@ Go down in the entry history.
|
|||
|
||||
Default: Control+Down
|
||||
|
||||
`kb-matcher-up`
|
||||
|
||||
Select the next matcher.
|
||||
|
||||
Default: Super+equal
|
||||
|
||||
`kb-matcher-down`
|
||||
|
||||
Select the previous matcher.
|
||||
|
||||
Default: Super+minus
|
||||
|
||||
## Mouse Bindings
|
||||
|
||||
`ml-row-left`
|
||||
|
|
|
@ -55,13 +55,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char * const MatchingMethodStr[MM_NUM_MATCHERS] = {
|
||||
"Normal",
|
||||
"Regex",
|
||||
"Glob",
|
||||
"Fuzzy",
|
||||
"Prefix"
|
||||
};
|
||||
const char *const MatchingMethodStr[MM_NUM_MATCHERS] = {
|
||||
"Normal", "Regex", "Glob", "Fuzzy", "Prefix"};
|
||||
/**
|
||||
* Textual description of positioning rofi.
|
||||
*/
|
||||
|
@ -75,9 +70,8 @@ char **stored_argv = NULL;
|
|||
|
||||
char *helper_string_replace_if_exists_v(char *string, GHashTable *h);
|
||||
|
||||
|
||||
const char * helper_get_matching_mode_str(void) {
|
||||
return MatchingMethodStr[config.matching_method];
|
||||
const char *helper_get_matching_mode_str(void) {
|
||||
return MatchingMethodStr[config.matching_method];
|
||||
}
|
||||
|
||||
void cmd_set_arguments(int argc, char **argv) {
|
||||
|
|
|
@ -174,7 +174,7 @@ struct {
|
|||
.max_refilter_time = 0.0,
|
||||
.delayed_mode = FALSE,
|
||||
.user_timeout = 0,
|
||||
.overlay_timeout = 0,
|
||||
.overlay_timeout = 0,
|
||||
.count = 0L,
|
||||
.repaint_source = 0,
|
||||
.fullscreen = FALSE,
|
||||
|
@ -221,8 +221,8 @@ static void screenshot_taken_user_callback(const char *path) {
|
|||
|
||||
char **args = NULL;
|
||||
int argv = 0;
|
||||
helper_parse_setup(config.on_screenshot_taken, &args, &argv, "{path}",
|
||||
path, (char *)0);
|
||||
helper_parse_setup(config.on_screenshot_taken, &args, &argv, "{path}", path,
|
||||
(char *)0);
|
||||
if (args != NULL)
|
||||
helper_execute(NULL, args, "", config.on_screenshot_taken, NULL);
|
||||
}
|
||||
|
@ -1302,17 +1302,18 @@ inline static void rofi_view_nav_last(RofiViewState *state) {
|
|||
// state->selected = state->filtered_lines - 1;
|
||||
listview_set_selected(state->list_view, -1);
|
||||
}
|
||||
static void selection_changed_user_callback(unsigned int index, RofiViewState *state) {
|
||||
static void selection_changed_user_callback(unsigned int index,
|
||||
RofiViewState *state) {
|
||||
if (config.on_selection_changed == NULL)
|
||||
return;
|
||||
|
||||
int fstate = 0;
|
||||
char *text = mode_get_display_value(state->sw, state->line_map[index],
|
||||
&fstate, NULL, TRUE);
|
||||
&fstate, NULL, TRUE);
|
||||
char **args = NULL;
|
||||
int argv = 0;
|
||||
helper_parse_setup(config.on_selection_changed, &args, &argv, "{entry}",
|
||||
text, (char *)0);
|
||||
helper_parse_setup(config.on_selection_changed, &args, &argv, "{entry}", text,
|
||||
(char *)0);
|
||||
if (args != NULL)
|
||||
helper_execute(NULL, args, "", config.on_selection_changed, NULL);
|
||||
g_free(text);
|
||||
|
@ -1489,7 +1490,7 @@ static gboolean rofi_view_refilter_real(RofiViewState *state) {
|
|||
state->case_sensitive = parse_case_sensitivity(state->text->text);
|
||||
state->tokens = helper_tokenize(pattern, state->case_sensitive);
|
||||
|
||||
if ( config.case_smart && state->case_indicator ) {
|
||||
if (config.case_smart && state->case_indicator) {
|
||||
textbox_text(state->case_indicator, get_matching_state(state));
|
||||
}
|
||||
/**
|
||||
|
@ -1983,19 +1984,19 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
|
|||
break;
|
||||
}
|
||||
case MATCHER_UP:
|
||||
config.matching_method = (config.matching_method+1)%MM_NUM_MATCHERS;
|
||||
rofi_view_refilter(state);
|
||||
rofi_view_set_overlay_timeout(state, helper_get_matching_mode_str());
|
||||
break;
|
||||
config.matching_method = (config.matching_method + 1) % MM_NUM_MATCHERS;
|
||||
rofi_view_refilter(state);
|
||||
rofi_view_set_overlay_timeout(state, helper_get_matching_mode_str());
|
||||
break;
|
||||
case MATCHER_DOWN:
|
||||
if ( config.matching_method == 0 ){
|
||||
config.matching_method = MM_NUM_MATCHERS-1;
|
||||
} else {
|
||||
config.matching_method = (config.matching_method-1)%MM_NUM_MATCHERS;
|
||||
}
|
||||
rofi_view_refilter(state);
|
||||
rofi_view_set_overlay_timeout(state, helper_get_matching_mode_str());
|
||||
break;
|
||||
if (config.matching_method == 0) {
|
||||
config.matching_method = MM_NUM_MATCHERS - 1;
|
||||
} else {
|
||||
config.matching_method = (config.matching_method - 1) % MM_NUM_MATCHERS;
|
||||
}
|
||||
rofi_view_refilter(state);
|
||||
rofi_view_set_overlay_timeout(state, helper_get_matching_mode_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2152,22 +2153,20 @@ static void rofi_quit_user_callback(RofiViewState *state) {
|
|||
return;
|
||||
// Pass selected text to custom command
|
||||
char *text = mode_get_display_value(state->sw, state->line_map[selected],
|
||||
&fstate, NULL, TRUE);
|
||||
&fstate, NULL, TRUE);
|
||||
char **args = NULL;
|
||||
int argv = 0;
|
||||
helper_parse_setup(config.on_entry_accepted, &args, &argv, "{entry}",
|
||||
text, (char *)0);
|
||||
helper_parse_setup(config.on_entry_accepted, &args, &argv, "{entry}", text,
|
||||
(char *)0);
|
||||
if (args != NULL)
|
||||
helper_execute(NULL, args, "", config.on_entry_accepted, NULL);
|
||||
g_free(text);
|
||||
} else if(state->retv & MENU_CANCEL) {
|
||||
} else if (state->retv & MENU_CANCEL) {
|
||||
if (config.on_menu_canceled == NULL)
|
||||
return;
|
||||
helper_execute_command(NULL, config.on_menu_canceled, FALSE, NULL);
|
||||
} else if (state->retv & MENU_NEXT ||
|
||||
state->retv & MENU_PREVIOUS ||
|
||||
state->retv & MENU_QUICK_SWITCH ||
|
||||
state->retv & MENU_COMPLETE) {
|
||||
} else if (state->retv & MENU_NEXT || state->retv & MENU_PREVIOUS ||
|
||||
state->retv & MENU_QUICK_SWITCH || state->retv & MENU_COMPLETE) {
|
||||
if (config.on_mode_changed == NULL)
|
||||
return;
|
||||
// TODO: pass mode name to custom command
|
||||
|
@ -2668,8 +2667,8 @@ static void rofi_error_user_callback(const char *msg) {
|
|||
|
||||
char **args = NULL;
|
||||
int argv = 0;
|
||||
helper_parse_setup(config.on_menu_error, &args, &argv, "{error}",
|
||||
msg, (char *)0);
|
||||
helper_parse_setup(config.on_menu_error, &args, &argv, "{error}", msg,
|
||||
(char *)0);
|
||||
if (args != NULL)
|
||||
helper_execute(NULL, args, "", config.on_menu_error, NULL);
|
||||
}
|
||||
|
@ -2739,7 +2738,7 @@ void rofi_view_cleanup(void) {
|
|||
g_source_remove(CacheState.refilter_timeout);
|
||||
CacheState.refilter_timeout = 0;
|
||||
}
|
||||
if ( CacheState.overlay_timeout ) {
|
||||
if (CacheState.overlay_timeout) {
|
||||
g_source_remove(CacheState.overlay_timeout);
|
||||
CacheState.overlay_timeout = 0;
|
||||
}
|
||||
|
@ -2846,17 +2845,16 @@ void rofi_view_workers_finalize(void) {
|
|||
}
|
||||
Mode *rofi_view_get_mode(RofiViewState *state) { return state->sw; }
|
||||
|
||||
|
||||
static gboolean rofi_view_overlay_timeout(G_GNUC_UNUSED gpointer user_data) {
|
||||
RofiViewState *state = rofi_view_get_active();
|
||||
if ( state ) {
|
||||
widget_disable(WIDGET(state->overlay));
|
||||
if (state) {
|
||||
widget_disable(WIDGET(state->overlay));
|
||||
}
|
||||
CacheState.overlay_timeout = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
void rofi_view_set_overlay_timeout (RofiViewState *state, const char *text) {
|
||||
void rofi_view_set_overlay_timeout(RofiViewState *state, const char *text) {
|
||||
if (state->overlay == NULL || state->list_view == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -2865,16 +2863,17 @@ void rofi_view_set_overlay_timeout (RofiViewState *state, const char *text) {
|
|||
return;
|
||||
}
|
||||
rofi_view_set_overlay(state, text);
|
||||
CacheState.overlay_timeout = g_timeout_add_seconds(3, rofi_view_overlay_timeout, state);
|
||||
CacheState.overlay_timeout =
|
||||
g_timeout_add_seconds(3, rofi_view_overlay_timeout, state);
|
||||
}
|
||||
|
||||
void rofi_view_set_overlay(RofiViewState *state, const char *text) {
|
||||
if (state->overlay == NULL || state->list_view == NULL) {
|
||||
return;
|
||||
}
|
||||
if ( CacheState.overlay_timeout > 0 ){
|
||||
g_source_remove(CacheState.overlay_timeout);
|
||||
CacheState.overlay_timeout = 0;
|
||||
if (CacheState.overlay_timeout > 0) {
|
||||
g_source_remove(CacheState.overlay_timeout);
|
||||
CacheState.overlay_timeout = 0;
|
||||
}
|
||||
if (text == NULL) {
|
||||
widget_disable(WIDGET(state->overlay));
|
||||
|
|
|
@ -127,7 +127,7 @@ END_TEST
|
|||
|
||||
START_TEST(test_mode_num_items) {
|
||||
unsigned int rows = mode_get_num_entries(&help_keys_mode);
|
||||
ck_assert_int_eq(rows, 79);
|
||||
ck_assert_int_eq(rows, 81);
|
||||
for (unsigned int i = 0; i < rows; i++) {
|
||||
int state = 0;
|
||||
GList *list = NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue