mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
view/keypress: Reindent
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
parent
117c2360a4
commit
143acf622b
1 changed files with 119 additions and 119 deletions
238
source/view.c
238
source/view.c
|
@ -1320,141 +1320,141 @@ void rofi_view_finalize ( RofiViewState *state )
|
||||||
|
|
||||||
static void rofi_view_handle_keypress ( RofiViewState *state, xkb_stuff *xkb, xcb_key_press_event_t *xkpe )
|
static void rofi_view_handle_keypress ( RofiViewState *state, xkb_stuff *xkb, xcb_key_press_event_t *xkpe )
|
||||||
{
|
{
|
||||||
xcb_keysym_t key;
|
xcb_keysym_t key;
|
||||||
char pad[32];
|
char pad[32];
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
key = xkb_state_key_get_one_sym ( xkb->state, xkpe->detail );
|
key = xkb_state_key_get_one_sym ( xkb->state, xkpe->detail );
|
||||||
|
|
||||||
if ( xkb->compose.state != NULL ) {
|
if ( xkb->compose.state != NULL ) {
|
||||||
if ( ( key != XKB_KEY_NoSymbol ) && ( xkb_compose_state_feed ( xkb->compose.state, key ) == XKB_COMPOSE_FEED_ACCEPTED ) ) {
|
if ( ( key != XKB_KEY_NoSymbol ) && ( xkb_compose_state_feed ( xkb->compose.state, key ) == XKB_COMPOSE_FEED_ACCEPTED ) ) {
|
||||||
switch ( xkb_compose_state_get_status ( xkb->compose.state ) )
|
switch ( xkb_compose_state_get_status ( xkb->compose.state ) )
|
||||||
{
|
{
|
||||||
case XKB_COMPOSE_CANCELLED:
|
case XKB_COMPOSE_CANCELLED:
|
||||||
/* Eat the keysym that cancelled the compose sequence.
|
/* Eat the keysym that cancelled the compose sequence.
|
||||||
* This is default behaviour with Xlib */
|
* This is default behaviour with Xlib */
|
||||||
case XKB_COMPOSE_COMPOSING:
|
case XKB_COMPOSE_COMPOSING:
|
||||||
key = XKB_KEY_NoSymbol;
|
key = XKB_KEY_NoSymbol;
|
||||||
break;
|
break;
|
||||||
case XKB_COMPOSE_COMPOSED:
|
case XKB_COMPOSE_COMPOSED:
|
||||||
key = xkb_compose_state_get_one_sym ( xkb->compose.state );
|
key = xkb_compose_state_get_one_sym ( xkb->compose.state );
|
||||||
len = xkb_compose_state_get_utf8 ( xkb->compose.state, pad, sizeof ( pad ) );
|
len = xkb_compose_state_get_utf8 ( xkb->compose.state, pad, sizeof ( pad ) );
|
||||||
break;
|
break;
|
||||||
case XKB_COMPOSE_NOTHING:
|
case XKB_COMPOSE_NOTHING:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( ( key == XKB_KEY_NoSymbol ) && ( len == 0 ) ) {
|
if ( ( key == XKB_KEY_NoSymbol ) && ( len == 0 ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( len == 0 ) {
|
if ( len == 0 ) {
|
||||||
len = xkb_state_key_get_utf8 ( xkb->state, xkpe->detail, pad, sizeof ( pad ) );
|
len = xkb_state_key_get_utf8 ( xkb->state, xkpe->detail, pad, sizeof ( pad ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int modstate = x11_canonalize_mask ( xkpe->state );
|
||||||
|
|
||||||
|
if ( key != XKB_KEY_NoSymbol ) {
|
||||||
|
// Handling of paste
|
||||||
|
if ( abe_test_action ( PASTE_PRIMARY, modstate, key ) ) {
|
||||||
|
xcb_convert_selection ( xcb->connection, CacheState.main_window, XCB_ATOM_PRIMARY,
|
||||||
|
xcb->ewmh.UTF8_STRING, xcb->ewmh.UTF8_STRING, XCB_CURRENT_TIME );
|
||||||
|
xcb_flush ( xcb->connection );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if ( abe_test_action ( PASTE_SECONDARY, modstate, key ) ) {
|
||||||
unsigned int modstate = x11_canonalize_mask ( xkpe->state );
|
xcb_convert_selection ( xcb->connection, CacheState.main_window, XCB_ATOM_SECONDARY,
|
||||||
|
xcb->ewmh.UTF8_STRING, xcb->ewmh.UTF8_STRING, XCB_CURRENT_TIME );
|
||||||
if ( key != XKB_KEY_NoSymbol ) {
|
xcb_flush ( xcb->connection );
|
||||||
// Handling of paste
|
return;
|
||||||
if ( abe_test_action ( PASTE_PRIMARY, modstate, key ) ) {
|
}
|
||||||
xcb_convert_selection ( xcb->connection, CacheState.main_window, XCB_ATOM_PRIMARY,
|
if ( abe_test_action ( SCREENSHOT, modstate, key ) ) {
|
||||||
xcb->ewmh.UTF8_STRING, xcb->ewmh.UTF8_STRING, XCB_CURRENT_TIME );
|
menu_capture_screenshot ( );
|
||||||
xcb_flush ( xcb->connection );
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if ( abe_test_action ( TOGGLE_SORT, modstate, key ) ) {
|
||||||
if ( abe_test_action ( PASTE_SECONDARY, modstate, key ) ) {
|
config.levenshtein_sort = !config.levenshtein_sort;
|
||||||
xcb_convert_selection ( xcb->connection, CacheState.main_window, XCB_ATOM_SECONDARY,
|
state->refilter = TRUE;
|
||||||
xcb->ewmh.UTF8_STRING, xcb->ewmh.UTF8_STRING, XCB_CURRENT_TIME );
|
state->update = TRUE;
|
||||||
xcb_flush ( xcb->connection );
|
textbox_text ( state->case_indicator, get_matching_state () );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( abe_test_action ( SCREENSHOT, modstate, key ) ) {
|
if ( abe_test_action ( MODE_PREVIOUS, modstate, key ) ) {
|
||||||
menu_capture_screenshot ( );
|
state->retv = MENU_PREVIOUS;
|
||||||
return;
|
( state->selected_line ) = 0;
|
||||||
}
|
state->quit = TRUE;
|
||||||
if ( abe_test_action ( TOGGLE_SORT, modstate, key ) ) {
|
return;
|
||||||
config.levenshtein_sort = !config.levenshtein_sort;
|
}
|
||||||
state->refilter = TRUE;
|
// Menu navigation.
|
||||||
state->update = TRUE;
|
if ( abe_test_action ( MODE_NEXT, modstate, key ) ) {
|
||||||
textbox_text ( state->case_indicator, get_matching_state () );
|
state->retv = MENU_NEXT;
|
||||||
return;
|
( state->selected_line ) = 0;
|
||||||
}
|
state->quit = TRUE;
|
||||||
if ( abe_test_action ( MODE_PREVIOUS, modstate, key ) ) {
|
return;
|
||||||
state->retv = MENU_PREVIOUS;
|
}
|
||||||
( state->selected_line ) = 0;
|
// Toggle case sensitivity.
|
||||||
|
if ( abe_test_action ( TOGGLE_CASE_SENSITIVITY, modstate, key ) ) {
|
||||||
|
config.case_sensitive = !config.case_sensitive;
|
||||||
|
( state->selected_line ) = 0;
|
||||||
|
state->refilter = TRUE;
|
||||||
|
state->update = TRUE;
|
||||||
|
textbox_text ( state->case_indicator, get_matching_state () );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Special delete entry command.
|
||||||
|
if ( abe_test_action ( DELETE_ENTRY, modstate, key ) ) {
|
||||||
|
if ( state->selected < state->filtered_lines ) {
|
||||||
|
( state->selected_line ) = state->line_map[state->selected];
|
||||||
|
state->retv = MENU_ENTRY_DELETE;
|
||||||
state->quit = TRUE;
|
state->quit = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Menu navigation.
|
|
||||||
if ( abe_test_action ( MODE_NEXT, modstate, key ) ) {
|
|
||||||
state->retv = MENU_NEXT;
|
|
||||||
( state->selected_line ) = 0;
|
|
||||||
state->quit = TRUE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Toggle case sensitivity.
|
|
||||||
if ( abe_test_action ( TOGGLE_CASE_SENSITIVITY, modstate, key ) ) {
|
|
||||||
config.case_sensitive = !config.case_sensitive;
|
|
||||||
( state->selected_line ) = 0;
|
|
||||||
state->refilter = TRUE;
|
|
||||||
state->update = TRUE;
|
|
||||||
textbox_text ( state->case_indicator, get_matching_state () );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Special delete entry command.
|
|
||||||
if ( abe_test_action ( DELETE_ENTRY, modstate, key ) ) {
|
|
||||||
if ( state->selected < state->filtered_lines ) {
|
|
||||||
( state->selected_line ) = state->line_map[state->selected];
|
|
||||||
state->retv = MENU_ENTRY_DELETE;
|
|
||||||
state->quit = TRUE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for ( unsigned int a = CUSTOM_1; a <= CUSTOM_19; a++ ) {
|
|
||||||
if ( abe_test_action ( a, modstate, key ) ) {
|
|
||||||
state->selected_line = UINT32_MAX;
|
|
||||||
if ( state->selected < state->filtered_lines ) {
|
|
||||||
( state->selected_line ) = state->line_map[state->selected];
|
|
||||||
}
|
|
||||||
state->retv = MENU_QUICK_SWITCH | ( ( a - CUSTOM_1 ) & MENU_LOWER_MASK );
|
|
||||||
state->quit = TRUE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( rofi_view_keyboard_navigation ( state, key, modstate ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for ( unsigned int a = CUSTOM_1; a <= CUSTOM_19; a++ ) {
|
||||||
int rc = textbox_keypress ( state->text, pad, len, modstate, key );
|
if ( abe_test_action ( a, modstate, key ) ) {
|
||||||
// Row is accepted.
|
|
||||||
if ( rc < 0 ) {
|
|
||||||
// If a valid item is selected, return that..
|
|
||||||
state->selected_line = UINT32_MAX;
|
state->selected_line = UINT32_MAX;
|
||||||
if ( state->selected < state->filtered_lines ) {
|
if ( state->selected < state->filtered_lines ) {
|
||||||
( state->selected_line ) = state->line_map[state->selected];
|
( state->selected_line ) = state->line_map[state->selected];
|
||||||
state->retv = MENU_OK;
|
|
||||||
}
|
}
|
||||||
else{
|
state->retv = MENU_QUICK_SWITCH | ( ( a - CUSTOM_1 ) & MENU_LOWER_MASK );
|
||||||
// Nothing entered and nothing selected.
|
|
||||||
state->retv = MENU_CUSTOM_INPUT;
|
|
||||||
}
|
|
||||||
if ( rc == -2 ) {
|
|
||||||
state->retv |= MENU_CUSTOM_ACTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
state->quit = TRUE;
|
state->quit = TRUE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Key press is handled by entry box.
|
}
|
||||||
else if ( rc == 1 ) {
|
if ( rofi_view_keyboard_navigation ( state, key, modstate ) ) {
|
||||||
state->refilter = TRUE;
|
return;
|
||||||
state->update = TRUE;
|
}
|
||||||
}
|
}
|
||||||
else if ( rc == 2 ) {
|
|
||||||
// redraw.
|
int rc = textbox_keypress ( state->text, pad, len, modstate, key );
|
||||||
state->update = TRUE;
|
// Row is accepted.
|
||||||
}
|
if ( rc < 0 ) {
|
||||||
|
// If a valid item is selected, return that..
|
||||||
|
state->selected_line = UINT32_MAX;
|
||||||
|
if ( state->selected < state->filtered_lines ) {
|
||||||
|
( state->selected_line ) = state->line_map[state->selected];
|
||||||
|
state->retv = MENU_OK;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// Nothing entered and nothing selected.
|
||||||
|
state->retv = MENU_CUSTOM_INPUT;
|
||||||
|
}
|
||||||
|
if ( rc == -2 ) {
|
||||||
|
state->retv |= MENU_CUSTOM_ACTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
state->quit = TRUE;
|
||||||
|
}
|
||||||
|
// Key press is handled by entry box.
|
||||||
|
else if ( rc == 1 ) {
|
||||||
|
state->refilter = TRUE;
|
||||||
|
state->update = TRUE;
|
||||||
|
}
|
||||||
|
else if ( rc == 2 ) {
|
||||||
|
// redraw.
|
||||||
|
state->update = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t *ev, xkb_stuff *xkb )
|
static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t *ev, xkb_stuff *xkb )
|
||||||
|
|
Loading…
Reference in a new issue