1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

Fix keybinding with Shift in name. Alt-Shift-S -> Alt-S. Alt-Shift-1 -> Alt-exclam

+ indent.
This commit is contained in:
Dave Davenport 2016-11-14 16:25:04 +01:00
parent 01751db4c0
commit fcf3c33415
8 changed files with 32 additions and 46 deletions

View file

@ -46,16 +46,16 @@ typedef struct
*/ */
typedef enum typedef enum
{ {
TB_AUTOHEIGHT = 1 << 0, TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1, TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16, TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17, TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18, TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19, TB_EDITABLE = 1 << 19,
TB_MARKUP = 1 << 20, TB_MARKUP = 1 << 20,
TB_WRAP = 1 << 21, TB_WRAP = 1 << 21,
TB_PASSWORD = 1 << 22, TB_PASSWORD = 1 << 22,
TB_INDICATOR = 1 << 23, TB_INDICATOR = 1 << 23,
} TextboxFlags; } TextboxFlags;
/** /**
* Flags indicating current state of the textbox. * Flags indicating current state of the textbox.

View file

@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
// Reading one line per time. // Reading one line per time.
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) { while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Evaluate one line. // Evaluate one line.
unsigned int index = 0, ti = 0; unsigned int index = 0, ti = 0;
char *token = buffer; char *token = buffer;
// Tokenize it. // Tokenize it.

View file

@ -634,8 +634,8 @@ static void helper_eval_add_str ( GString *str, const char *input, int l, int ma
// g_utf8 does not work with NULL string. // g_utf8 does not work with NULL string.
const char *input_nn = input ? input : ""; const char *input_nn = input ? input : "";
// Both l and max_len are in characters, not bytes. // Both l and max_len are in characters, not bytes.
int nc = g_utf8_strlen ( input_nn, -1 ); int nc = g_utf8_strlen ( input_nn, -1 );
int spaces = 0; int spaces = 0;
if ( l == 0 ) { if ( l == 0 ) {
spaces = MAX ( 0, max_len - nc ); spaces = MAX ( 0, max_len - nc );
g_string_append ( str, input_nn ); g_string_append ( str, input_nn );

View file

@ -194,7 +194,7 @@ 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 ) #define R( s ) g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL )
GRegex * retv = NULL; GRegex * retv = NULL;
gchar *r; gchar *r;
switch ( config.matching_method ) switch ( config.matching_method )
{ {
case MM_GLOB: case MM_GLOB:
@ -234,7 +234,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
} }
char *saveptr = NULL, *token; char *saveptr = NULL, *token;
GRegex **retv = NULL; GRegex **retv = NULL;
if ( !config.tokenize ) { if ( !config.tokenize ) {
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 ); retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
retv[0] = (GRegex *) create_regex ( input, case_sensitive ); retv[0] = (GRegex *) create_regex ( input, case_sensitive );

View file

@ -37,7 +37,7 @@ ActionBindingEntry abe[NUM_ABE];
*/ */
DefaultBinding bindings[NUM_ABE] = DefaultBinding bindings[NUM_ABE] =
{ {
{ .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+Shift+v,Shift+Insert", .comment = "Paste primary selection" }, { .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+V,Shift+Insert", .comment = "Paste primary selection" },
{ .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", .comment = "Paste clipboard" }, { .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", .comment = "Paste clipboard" },
{ .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+w", .comment = "Clear input line" }, { .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+w", .comment = "Clear input line" },
{ .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", .comment = "Beginning of line" }, { .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", .comment = "Beginning of line" },
@ -46,7 +46,7 @@ DefaultBinding bindings[NUM_ABE] =
{ .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", .comment = "Move forward one word" }, { .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", .comment = "Move forward one word" },
{ .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b", .comment = "Move back one char" }, { .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b", .comment = "Move back one char" },
{ .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f", .comment = "Move forward one char" }, { .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f", .comment = "Move forward one char" },
{ .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h,Control+Backspace", .comment = "Delete previous word" }, { .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h,Control+BackSpace", .comment = "Delete previous word" },
{ .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", .comment = "Delete next word" }, { .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", .comment = "Delete next word" },
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", .comment = "Delete next char" }, { .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 = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", .comment = "Delete previous char" },
@ -68,7 +68,7 @@ DefaultBinding bindings[NUM_ABE] =
{ .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home", .comment = "Go to the first entry" }, { .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home", .comment = "Go to the first entry" },
{ .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End", .comment = "Go to the last entry" }, { .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End", .comment = "Go to the last entry" },
{ .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space", .comment = "Set selected item as input text" }, { .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space", .comment = "Set selected item as input text" },
{ .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+Shift+S", .comment = "Take a screenshot of the rofi window" }, { .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+S", .comment = "Take a screenshot of the rofi window" },
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave", .comment = "Toggle case sensitivity" }, { .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave", .comment = "Toggle case sensitivity" },
{ .id = TOGGLE_SORT, .name = "kb-toggle-sort", .keybinding = "Alt+grave", .comment = "Toggle sort" }, { .id = TOGGLE_SORT, .name = "kb-toggle-sort", .keybinding = "Alt+grave", .comment = "Toggle sort" },
{ .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape,Control+g,Control+bracketleft", .comment = "Quit rofi" }, { .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape,Control+g,Control+bracketleft", .comment = "Quit rofi" },
@ -82,15 +82,15 @@ DefaultBinding bindings[NUM_ABE] =
{ .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8", .comment = "Custom keybinding 8" }, { .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8", .comment = "Custom keybinding 8" },
{ .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9", .comment = "Custom keybinding 9" }, { .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9", .comment = "Custom keybinding 9" },
{ .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0", .comment = "Custom keybinding 10" }, { .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0", .comment = "Custom keybinding 10" },
{ .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+Shift+1", .comment = "Custom keybinding 11" }, { .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+exclam", .comment = "Custom keybinding 11" },
{ .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2", .comment = "Custom keybinding 12" }, { .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+at", .comment = "Custom keybinding 12" },
{ .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3", .comment = "Csutom keybinding 13" }, { .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+numbersign", .comment = "Csutom keybinding 13" },
{ .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4", .comment = "Custom keybinding 14" }, { .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+dollar", .comment = "Custom keybinding 14" },
{ .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5", .comment = "Custom keybinding 15" }, { .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+percent", .comment = "Custom keybinding 15" },
{ .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6", .comment = "Custom keybinding 16" }, { .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+dead_circumflex", .comment = "Custom keybinding 16" },
{ .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7", .comment = "Custom keybinding 17" }, { .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+ampersand", .comment = "Custom keybinding 17" },
{ .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8", .comment = "Custom keybinding 18" }, { .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+asterisk", .comment = "Custom keybinding 18" },
{ .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9", .comment = "Custom Keybinding 19" }, { .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+parenleft", .comment = "Custom Keybinding 19" },
}; };
void setup_abe ( void ) void setup_abe ( void )

View file

@ -356,7 +356,7 @@ static int add_mode ( const char * token )
} }
else else
#endif // WINDOW_MODE #endif // WINDOW_MODE
// SSh dialog // SSh dialog
if ( strcasecmp ( token, "ssh" ) == 0 ) { if ( strcasecmp ( token, "ssh" ) == 0 ) {
modi[num_modi] = &ssh_mode; modi[num_modi] = &ssh_mode;
num_modi++; num_modi++;

View file

@ -1194,7 +1194,7 @@ static void rofi_view_handle_keypress ( RofiViewState *state, xkb_stuff *xkb, xc
xkb_mod_mask_t consumed = xkb_state_key_get_consumed_mods ( xkb->state, xkpe->detail ); xkb_mod_mask_t consumed = xkb_state_key_get_consumed_mods ( xkb->state, xkpe->detail );
unsigned int modstate = x11_canonalize_mask ( xkpe->state& (~consumed) ); unsigned int modstate = x11_canonalize_mask ( xkpe->state & ( ~consumed ) );
if ( key != XKB_KEY_NoSymbol ) { if ( key != XKB_KEY_NoSymbol ) {
KeyBindingAction action; KeyBindingAction action;

View file

@ -678,25 +678,11 @@ gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key, gboo
*mod = modmask; *mod = modmask;
} }
// Parse key // Parse key
xkb_keysym_t sym = XKB_KEY_NoSymbol; xkb_keysym_t sym = XKB_KEY_NoSymbol;
if ( ( modmask & x11_mod_masks[X11MOD_SHIFT] ) != 0 ) { sym = xkb_keysym_from_name ( combo + i, XKB_KEYSYM_NO_FLAGS );
gchar * str = g_utf8_next_char ( combo + i );
// If it is a single char, we make a capital out of it.
if ( str != NULL && *str == '\0' ) {
int l = 0;
char buff[8];
gunichar v = g_utf8_get_char ( combo + i );
gunichar u = g_unichar_toupper ( v );
if ( ( l = g_unichar_to_utf8 ( u, buff ) ) ) {
buff[l] = '\0';
sym = xkb_keysym_from_name ( buff, XKB_KEYSYM_NO_FLAGS );
}
}
}
if ( sym == XKB_KEY_NoSymbol ) {
sym = xkb_keysym_from_name ( combo + i, XKB_KEYSYM_CASE_INSENSITIVE );
}
if ( sym == XKB_KEY_NoSymbol || ( !modmask && ( strchr ( combo, '-' ) || strchr ( combo, '+' ) ) ) ) { if ( sym == XKB_KEY_NoSymbol || ( !modmask && ( strchr ( combo, '-' ) || strchr ( combo, '+' ) ) ) ) {
g_string_append_printf ( str, "Sorry, rofi cannot understand the key combination: <i>%s</i>\n", combo ); g_string_append_printf ( str, "Sorry, rofi cannot understand the key combination: <i>%s</i>\n", combo );