summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/config.c8
-rw-r--r--doc/test_xr.txt4
-rw-r--r--include/keyb.h1
-rw-r--r--include/textbox.h18
-rw-r--r--source/dialogs/ssh.c2
-rw-r--r--source/helper.c4
-rw-r--r--source/keyb.c5
-rw-r--r--source/rofi.c36
-rw-r--r--source/textbox.c6
-rw-r--r--source/view.c70
10 files changed, 86 insertions, 68 deletions
diff --git a/config/config.c b/config/config.c
index c1455cef..82ab987c 100644
--- a/config/config.c
+++ b/config/config.c
@@ -107,10 +107,10 @@ Settings config = {
/** Parse ~/.ssh/known_hosts file in ssh view. */
.parse_known_hosts = TRUE,
/** Modi to combine into one view. */
- .combi_modi = "window,run",
- .glob = FALSE,
- .tokenize = TRUE,
- .regex = FALSE,
+ .combi_modi = "window,run",
+ .glob = FALSE,
+ .tokenize = TRUE,
+ .regex = FALSE,
/** Monitor */
.monitor = -1,
/** set line margin */
diff --git a/doc/test_xr.txt b/doc/test_xr.txt
index d895e08d..c2576518 100644
--- a/doc/test_xr.txt
+++ b/doc/test_xr.txt
@@ -125,7 +125,9 @@ rofi.kb-remove-char-back: BackSpace,Control+h
! Accept entry
rofi.kb-accept-entry: Control+j,Control+m,Return,KP_Enter
! Use entered text as command (in ssh/run modi)
-rofi.kb-accept-custom: Control+Return,Shift+Return
+rofi.kb-accept-custom: Control+Return
+! Use alternate accept command.
+rofi.kb-accept-alt: Shift+Return
! Delete entry from history
rofi.kb-delete-entry: Shift+Delete
! Switch to the next mode.
diff --git a/include/keyb.h b/include/keyb.h
index 5bdea14b..7fee420a 100644
--- a/include/keyb.h
+++ b/include/keyb.h
@@ -37,6 +37,7 @@ typedef enum
REMOVE_CHAR_BACK,
/** Accept the current selected entry */
ACCEPT_ENTRY,
+ ACCEPT_ALT,
ACCEPT_CUSTOM,
MODE_NEXT,
MODE_PREVIOUS,
diff --git a/include/textbox.h b/include/textbox.h
index 455904f8..a7619f7d 100644
--- a/include/textbox.h
+++ b/include/textbox.h
@@ -39,15 +39,15 @@ typedef struct
typedef enum
{
- TB_AUTOHEIGHT = 1 << 0,
- TB_AUTOWIDTH = 1 << 1,
- TB_LEFT = 1 << 16,
- TB_RIGHT = 1 << 17,
- TB_CENTER = 1 << 18,
- TB_EDITABLE = 1 << 19,
- TB_MARKUP = 1 << 20,
- TB_WRAP = 1 << 21,
- TB_PASSWORD = 1 << 22,
+ TB_AUTOHEIGHT = 1 << 0,
+ TB_AUTOWIDTH = 1 << 1,
+ TB_LEFT = 1 << 16,
+ TB_RIGHT = 1 << 17,
+ TB_CENTER = 1 << 18,
+ TB_EDITABLE = 1 << 19,
+ TB_MARKUP = 1 << 20,
+ TB_WRAP = 1 << 21,
+ TB_PASSWORD = 1 << 22,
} TextboxFlags;
typedef enum
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index 331e5431..9cc75543 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
// Reading one line per time.
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Evaluate one line.
- unsigned int index = 0, ti = 0;
+ unsigned int index = 0, ti = 0;
char *token = buffer;
// Tokenize it.
diff --git a/source/helper.c b/source/helper.c
index 3b4ae2b8..e2c9b2f0 100644
--- a/source/helper.c
+++ b/source/helper.c
@@ -164,7 +164,7 @@ static gchar *glob_to_regex ( const char *input )
static GRegex * create_regex ( const char *input, int case_sensitive )
{
#define R( s ) g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL )
- GRegex *retv = NULL;
+ GRegex * retv = NULL;
if ( config.glob ) {
gchar *r = glob_to_regex ( input );
retv = R ( r );
@@ -197,7 +197,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
}
char *saveptr = NULL, *token;
- GRegex **retv = NULL;
+ GRegex **retv = NULL;
if ( !config.tokenize ) {
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
diff --git a/source/keyb.c b/source/keyb.c
index 5db62f24..c8d21ea8 100644
--- a/source/keyb.c
+++ b/source/keyb.c
@@ -48,14 +48,15 @@ DefaultBinding bindings[NUM_ABE] =
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", .comment = "Delete next char" },
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", .comment = "Delete previous char" },
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", .comment = "Accept entry" },
- { .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return,Shift+Return", .comment = "Use entered text as command (in ssh/run modi)" },
+ { .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return", .comment = "Use entered text as command (in ssh/run modi)" },
+ { .id = ACCEPT_ALT, .name = "kb-accept-alt", .keybinding = "Shift+Return", .comment = "Use alternate accept command." },
{ .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete", .comment = "Delete entry from history" },
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab", .comment = "Switch to the next mode." },
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab", .comment = "Switch to the previous mode." },
{ .id = ROW_LEFT, .name = "kb-row-left", .keybinding = "Control+Page_Up", .comment = "Go to the previous column" },
{ .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = "Control+Page_Down", .comment = "Go to the next column" },
{ .id = ROW_UP, .name = "kb-row-up", .keybinding = "Up,Control+p,Shift+Tab,Shift+ISO_Left_Tab", .comment = "Select previous entry" },
- { .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n", .comment = "Select next entry" },
+ { .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n", .comment = "Select next entry" },
{ .id = ROW_TAB, .name = "kb-row-tab", .keybinding = "Tab", .comment = "Go to next row, if one left, accept it, if no left next mode." },
{ .id = PAGE_PREV, .name = "kb-page-prev", .keybinding = "Page_Up", .comment = "Go to the previous page" },
{ .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = "Page_Down", .comment = "Go to the next page" },
diff --git a/source/rofi.c b/source/rofi.c
index d4fadc6d..02eef1fd 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -74,9 +74,9 @@ struct xkb_stuff xkb = {
.keymap = NULL,
.state = NULL,
.compose = {
- .table = NULL,
- .state = NULL
- }
+ .table = NULL,
+ .state = NULL
+}
};
char *config_path = NULL;
// Array of modi.
@@ -441,22 +441,22 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
break;
case XCB_XKB_STATE_NOTIFY:
- {
- xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
- guint modmask;
- xkb_state_update_mask ( xkb.state,
- ksne->baseMods,
- ksne->latchedMods,
- ksne->lockedMods,
- ksne->baseGroup,
- ksne->latchedGroup,
- ksne->lockedGroup );
- modmask = x11_get_current_mask ( &xkb );
- if ( modmask == 0 ) {
- abe_trigger_release ( );
+ {
+ xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
+ guint modmask;
+ xkb_state_update_mask ( xkb.state,
+ ksne->baseMods,
+ ksne->latchedMods,
+ ksne->lockedMods,
+ ksne->baseGroup,
+ ksne->latchedGroup,
+ ksne->lockedGroup );
+ modmask = x11_get_current_mask ( &xkb );
+ if ( modmask == 0 ) {
+ abe_trigger_release ( );
+ }
+ break;
}
- break;
- }
}
return G_SOURCE_CONTINUE;
}
diff --git a/source/textbox.c b/source/textbox.c
index 425dbf44..e19234b2 100644
--- a/source/textbox.c
+++ b/source/textbox.c
@@ -589,15 +589,9 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action )
case REMOVE_CHAR_BACK:
textbox_cursor_bkspc ( tb );
return 1;
- case ACCEPT_CUSTOM:
- return -2;
- case ACCEPT_ENTRY:
- return -1;
default:
g_return_val_if_reached ( 0 );
}
-
- g_return_val_if_reached ( 0 );
}
gboolean textbox_append_char ( textbox *tb, char *pad, int pad_len )
diff --git a/source/view.c b/source/view.c
index 59ad874a..f6d9b3d5 100644
--- a/source/view.c
+++ b/source/view.c
@@ -947,7 +947,9 @@ static void rofi_view_draw ( RofiViewState *state, cairo_t *d )
if ( list != NULL ) {
pango_attr_list_ref ( list );
}
- else{ list = pango_attr_list_new (); }
+ else{
+ list = pango_attr_list_new ();
+ }
token_match_get_pango_attr ( tokens, textbox_get_visible_text ( state->boxes[i] ), list );
textbox_set_pango_attributes ( state->boxes[i], list );
pango_attr_list_unref ( list );
@@ -1452,39 +1454,57 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
case MOVE_WORD_BACK:
case MOVE_WORD_FORWARD:
case REMOVE_CHAR_BACK:
- case ACCEPT_CUSTOM:
- case ACCEPT_ENTRY:
{
int rc = textbox_keybinding ( state->text, action );
- // 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 ) {
+ if ( rc == 1 ) {
+ // Entry changed.
state->refilter = TRUE;
state->update = TRUE;
}
- else if ( rc == 2 ) {
- // redraw.
+ else if ( rc == 2 ) {
+ // Movement.
state->update = TRUE;
}
break;
}
+ case ACCEPT_ALT:
+ {
+ 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;
+ }
+ state->retv |= MENU_CUSTOM_ACTION;
+ state->quit = TRUE;
+ break;
+ }
+ case ACCEPT_CUSTOM:
+ {
+ state->selected_line = UINT32_MAX;
+ state->retv = MENU_CUSTOM_INPUT;
+ state->quit = TRUE;
+ break;
+ }
+ case ACCEPT_ENTRY:
+ {
+ // 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;
+ }
+
+ state->quit = TRUE;
+ break;
+ }
case NUM_ABE:
ret = FALSE;
break;