mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Issue #411: Show list of Keyboard bindings with rofi, from rofi.
This commit is contained in:
parent
e84e387e94
commit
1b5bcaa9f4
12 changed files with 295 additions and 64 deletions
|
@ -38,6 +38,7 @@ rofi_SOURCES=\
|
||||||
source/dialogs/combi.c\
|
source/dialogs/combi.c\
|
||||||
source/dialogs/window.c\
|
source/dialogs/window.c\
|
||||||
source/dialogs/script.c\
|
source/dialogs/script.c\
|
||||||
|
source/dialogs/help-keys.c\
|
||||||
include/xcb.h\
|
include/xcb.h\
|
||||||
include/xcb-internal.h\
|
include/xcb-internal.h\
|
||||||
include/rofi.h\
|
include/rofi.h\
|
||||||
|
@ -64,6 +65,7 @@ rofi_SOURCES=\
|
||||||
include/dialogs/script.h\
|
include/dialogs/script.h\
|
||||||
include/dialogs/window.h\
|
include/dialogs/window.h\
|
||||||
include/dialogs/dialogs.h\
|
include/dialogs/dialogs.h\
|
||||||
|
include/dialogs/help-keys.h\
|
||||||
include/xkb.h\
|
include/xkb.h\
|
||||||
include/xkb-internal.h
|
include/xkb-internal.h
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# My favorite format
|
# My favorite format
|
||||||
#
|
#
|
||||||
code_width = 140
|
code_width = 240
|
||||||
nl_max = 2
|
nl_max = 2
|
||||||
ls_func_split_full = True
|
ls_func_split_full = True
|
||||||
indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs
|
indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs
|
||||||
|
|
|
@ -15,4 +15,5 @@
|
||||||
#include "dialogs/script.h"
|
#include "dialogs/script.h"
|
||||||
#include "dialogs/window.h"
|
#include "dialogs/window.h"
|
||||||
#include "dialogs/combi.h"
|
#include "dialogs/combi.h"
|
||||||
|
#include "dialogs/help-keys.h"
|
||||||
#endif // ROFI_DIALOGS_DIALOGS_H
|
#endif // ROFI_DIALOGS_DIALOGS_H
|
||||||
|
|
11
include/dialogs/help-keys.h
Normal file
11
include/dialogs/help-keys.h
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef ROFI_DIALOG_HELPKEYS_H
|
||||||
|
#define ROFI_DIALOG_HELPKEYS_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup HELPKEYSMode KeysHelp
|
||||||
|
* @ingroup MODES
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
extern Mode help_keys_mode;
|
||||||
|
/*@}*/
|
||||||
|
#endif // ROFI_DIALOG_HELPKEYS_H
|
|
@ -142,5 +142,7 @@ void print_options ( void );
|
||||||
*/
|
*/
|
||||||
void print_help_msg ( const char *option, const char *type, const char*text, const char *def, int isatty );
|
void print_help_msg ( const char *option, const char *type, const char*text, const char *def, int isatty );
|
||||||
|
|
||||||
|
char ** config_parser_return_display_help ( unsigned int *length );
|
||||||
|
|
||||||
/* @}*/
|
/* @}*/
|
||||||
#endif
|
#endif
|
||||||
|
|
142
source/dialogs/help-keys.c
Normal file
142
source/dialogs/help-keys.c
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
/**
|
||||||
|
* rofi
|
||||||
|
*
|
||||||
|
* MIT/X11 License
|
||||||
|
* Copyright 2013-2016 Qball Cow <qball@gmpclient.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <config.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "rofi.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "helper.h"
|
||||||
|
#include "xrmoptions.h"
|
||||||
|
#include "dialogs/help-keys.h"
|
||||||
|
#include "textbox.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char **messages;
|
||||||
|
unsigned int messages_length;
|
||||||
|
} KeysHelpModePrivateData;
|
||||||
|
|
||||||
|
static void get_apps ( KeysHelpModePrivateData *pd )
|
||||||
|
{
|
||||||
|
pd->messages = config_parser_return_display_help ( &( pd->messages_length ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int help_keys_mode_init ( Mode *sw )
|
||||||
|
{
|
||||||
|
if ( mode_get_private_data ( sw ) == NULL ) {
|
||||||
|
KeysHelpModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
|
||||||
|
mode_set_private_data ( sw, (void *) pd );
|
||||||
|
get_apps ( pd );
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ModeMode help_keys_mode_result ( G_GNUC_UNUSED Mode *sw,
|
||||||
|
int mretv,
|
||||||
|
G_GNUC_UNUSED char **input,
|
||||||
|
G_GNUC_UNUSED unsigned int selected_line )
|
||||||
|
{
|
||||||
|
ModeMode retv = MODE_EXIT;
|
||||||
|
|
||||||
|
if ( mretv & MENU_NEXT ) {
|
||||||
|
retv = NEXT_DIALOG;
|
||||||
|
}
|
||||||
|
else if ( mretv & MENU_PREVIOUS ) {
|
||||||
|
retv = PREVIOUS_DIALOG;
|
||||||
|
}
|
||||||
|
else if ( mretv & MENU_QUICK_SWITCH ) {
|
||||||
|
retv = ( mretv & MENU_LOWER_MASK );
|
||||||
|
}
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
static void help_keys_mode_destroy ( Mode *sw )
|
||||||
|
{
|
||||||
|
KeysHelpModePrivateData *rmpd = (KeysHelpModePrivateData *) mode_get_private_data ( sw );
|
||||||
|
if ( rmpd != NULL ) {
|
||||||
|
g_strfreev ( rmpd->messages );
|
||||||
|
g_free ( rmpd );
|
||||||
|
mode_set_private_data ( sw, NULL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
|
||||||
|
{
|
||||||
|
KeysHelpModePrivateData *pd = (KeysHelpModePrivateData *) mode_get_private_data ( sw );
|
||||||
|
*state |= MARKUP;
|
||||||
|
if ( !get_entry ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return g_strdup ( pd->messages[selected_line] );
|
||||||
|
}
|
||||||
|
static int help_keys_token_match ( const Mode *data,
|
||||||
|
char **tokens,
|
||||||
|
int not_ascii,
|
||||||
|
int case_sensitive,
|
||||||
|
unsigned int index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
KeysHelpModePrivateData *rmpd = (KeysHelpModePrivateData *) mode_get_private_data ( data );
|
||||||
|
return token_match ( tokens, rmpd->messages[index], not_ascii, case_sensitive );
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int help_keys_mode_get_num_entries ( const Mode *sw )
|
||||||
|
{
|
||||||
|
const KeysHelpModePrivateData *pd = (const KeysHelpModePrivateData *) mode_get_private_data ( sw );
|
||||||
|
return pd->messages_length;
|
||||||
|
}
|
||||||
|
static int help_keys_is_not_ascii ( const Mode *sw, unsigned int index )
|
||||||
|
{
|
||||||
|
const KeysHelpModePrivateData *pd = (const KeysHelpModePrivateData *) mode_get_private_data ( sw );
|
||||||
|
return !g_str_is_ascii ( pd->messages[index] );
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "mode-private.h"
|
||||||
|
Mode help_keys_mode =
|
||||||
|
{
|
||||||
|
.name = "keys",
|
||||||
|
.cfg_name_key = "display-keys",
|
||||||
|
._init = help_keys_mode_init,
|
||||||
|
._get_num_entries = help_keys_mode_get_num_entries,
|
||||||
|
._result = help_keys_mode_result,
|
||||||
|
._destroy = help_keys_mode_destroy,
|
||||||
|
._token_match = help_keys_token_match,
|
||||||
|
._get_completion = NULL,
|
||||||
|
._get_display_value = _get_display_value,
|
||||||
|
._is_not_ascii = help_keys_is_not_ascii,
|
||||||
|
.private_data = NULL,
|
||||||
|
.free = NULL
|
||||||
|
};
|
|
@ -534,7 +534,7 @@ static inline int act_on_window ( xcb_window_t window )
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char window_str[100]; /* We are probably safe here */
|
char window_str[100]; /* We are probably safe here */
|
||||||
|
|
||||||
g_snprintf(window_str, sizeof window_str, "%d", window);
|
g_snprintf ( window_str, sizeof window_str, "%d", window );
|
||||||
|
|
||||||
helper_parse_setup ( config.window_command, &args, &argc, "{window}", window_str, NULL );
|
helper_parse_setup ( config.window_command, &args, &argc, "{window}", window_str, NULL );
|
||||||
|
|
||||||
|
|
105
source/keyb.c
105
source/keyb.c
|
@ -24,6 +24,7 @@ typedef struct
|
||||||
KeyBindingAction id;
|
KeyBindingAction id;
|
||||||
char *name;
|
char *name;
|
||||||
char *keybinding;
|
char *keybinding;
|
||||||
|
char *comment;
|
||||||
} DefaultBinding;
|
} DefaultBinding;
|
||||||
|
|
||||||
ActionBindingEntry abe[NUM_ABE];
|
ActionBindingEntry abe[NUM_ABE];
|
||||||
|
@ -33,57 +34,57 @@ 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", },
|
{ .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+Shift+v,Shift+Insert", .comment = "Keybinding paste primary clipboard" },
|
||||||
{ .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", },
|
{ .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", .comment = "Keybinding paste secondary clipboard" },
|
||||||
{ .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+u", },
|
{ .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+u", .comment = "Keybinding clear input line" },
|
||||||
{ .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", },
|
{ .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", .comment = "Keybinding move cursor to front" },
|
||||||
{ .id = MOVE_END, .name = "kb-move-end", .keybinding = "Control+e", },
|
{ .id = MOVE_END, .name = "kb-move-end", .keybinding = "Control+e", .comment = "Keybinding move cursor to end" },
|
||||||
{ .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", },
|
{ .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", .comment = "Keybinding move word back" },
|
||||||
{ .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", },
|
{ .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", .comment = "Keybinding" },
|
||||||
{ .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b" },
|
{ .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b", .comment = "Keybinding" },
|
||||||
{ .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f" },
|
{ .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f", .comment = "Keybinding" },
|
||||||
{ .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h", },
|
{ .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h", .comment = "Keybinding" },
|
||||||
{ .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", },
|
{ .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", .comment = "Keybinding" },
|
||||||
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", },
|
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", .comment = "Keybinding" },
|
||||||
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", },
|
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", .comment = "Keybinding" },
|
||||||
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", },
|
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", .comment = "Keybinding" },
|
||||||
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return,Shift+Return", },
|
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return,Shift+Return", .comment = "Keybinding" },
|
||||||
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab" },
|
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab", .comment = "Keybinding" },
|
||||||
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab" },
|
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab", .comment = "Keybinding" },
|
||||||
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave" },
|
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave", .comment = "Keybinding" },
|
||||||
{ .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete" },
|
{ .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete", .comment = "Keybinding" },
|
||||||
{ .id = ROW_LEFT, .name = "kb-row-left", .keybinding = "Control+Page_Up" },
|
{ .id = ROW_LEFT, .name = "kb-row-left", .keybinding = "Control+Page_Up", .comment = "Keybinding" },
|
||||||
{ .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = "Control+Page_Down" },
|
{ .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = "Control+Page_Down", .comment = "Keybinding" },
|
||||||
{ .id = ROW_UP, .name = "kb-row-up", .keybinding = "Up,Control+p,Shift+Tab,Shift+ISO_Left_Tab" },
|
{ .id = ROW_UP, .name = "kb-row-up", .keybinding = "Up,Control+p,Shift+Tab,Shift+ISO_Left_Tab", .comment = "Keybinding" },
|
||||||
{ .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n" },
|
{ .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n", .comment = "Keybinding" },
|
||||||
{ .id = ROW_TAB, .name = "kb-row-tab", .keybinding = "Tab" },
|
{ .id = ROW_TAB, .name = "kb-row-tab", .keybinding = "Tab", .comment = "Keybinding" },
|
||||||
{ .id = PAGE_PREV, .name = "kb-page-prev", .keybinding = "Page_Up" },
|
{ .id = PAGE_PREV, .name = "kb-page-prev", .keybinding = "Page_Up", .comment = "Keybinding" },
|
||||||
{ .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = "Page_Down" },
|
{ .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = "Page_Down", .comment = "Keybinding" },
|
||||||
{ .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home" },
|
{ .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home", .comment = "Keybinding" },
|
||||||
{ .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End" },
|
{ .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End", .comment = "Keybinding" },
|
||||||
{ .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space" },
|
{ .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space", .comment = "Keybinding" },
|
||||||
{ .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape,Control+bracketleft" },
|
{ .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape,Control+bracketleft", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_1, .name = "kb-custom-1", .keybinding = "Alt+1" },
|
{ .id = CUSTOM_1, .name = "kb-custom-1", .keybinding = "Alt+1", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_2, .name = "kb-custom-2", .keybinding = "Alt+2" },
|
{ .id = CUSTOM_2, .name = "kb-custom-2", .keybinding = "Alt+2", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_3, .name = "kb-custom-3", .keybinding = "Alt+3" },
|
{ .id = CUSTOM_3, .name = "kb-custom-3", .keybinding = "Alt+3", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_4, .name = "kb-custom-4", .keybinding = "Alt+4" },
|
{ .id = CUSTOM_4, .name = "kb-custom-4", .keybinding = "Alt+4", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_5, .name = "kb-custom-5", .keybinding = "Alt+5" },
|
{ .id = CUSTOM_5, .name = "kb-custom-5", .keybinding = "Alt+5", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_6, .name = "kb-custom-6", .keybinding = "Alt+6" },
|
{ .id = CUSTOM_6, .name = "kb-custom-6", .keybinding = "Alt+6", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_7, .name = "kb-custom-7", .keybinding = "Alt+7" },
|
{ .id = CUSTOM_7, .name = "kb-custom-7", .keybinding = "Alt+7", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8" },
|
{ .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9" },
|
{ .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0" },
|
{ .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+Shift+1" },
|
{ .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+Shift+1", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2" },
|
{ .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3" },
|
{ .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4" },
|
{ .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5" },
|
{ .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6" },
|
{ .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8" },
|
{ .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7" },
|
{ .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7", .comment = "Keybinding" },
|
||||||
{ .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9" },
|
{ .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9", .comment = "Keybinding" },
|
||||||
{ .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+Shift+S" },
|
{ .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+Shift+S", .comment = "Keybinding" },
|
||||||
{ .id = TOGGLE_SORT, .name = "kb-toggle-sort", .keybinding = "Alt+grave" },
|
{ .id = TOGGLE_SORT, .name = "kb-toggle-sort", .keybinding = "Alt+grave", .comment = "Keybinding" },
|
||||||
};
|
};
|
||||||
|
|
||||||
void setup_abe ( void )
|
void setup_abe ( void )
|
||||||
|
@ -96,7 +97,7 @@ void setup_abe ( void )
|
||||||
abe[id].num_bindings = 0;
|
abe[id].num_bindings = 0;
|
||||||
abe[id].kb = NULL;
|
abe[id].kb = NULL;
|
||||||
|
|
||||||
config_parser_add_option ( xrm_String, abe[id].name, (void * *) &( abe[id].keystr ), "Keybinding" );
|
config_parser_add_option ( xrm_String, abe[id].name, (void * *) &( abe[id].keystr ), bindings[iter].comment );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -334,6 +334,10 @@ static int add_mode ( const char * token )
|
||||||
modi[num_modi] = &ssh_mode;
|
modi[num_modi] = &ssh_mode;
|
||||||
num_modi++;
|
num_modi++;
|
||||||
}
|
}
|
||||||
|
else if ( strcasecmp ( token, mode_get_name ( &help_keys_mode ) ) ) {
|
||||||
|
modi[num_modi] = &help_keys_mode;
|
||||||
|
num_modi++;
|
||||||
|
}
|
||||||
// Run dialog
|
// Run dialog
|
||||||
else if ( strcasecmp ( token, "run" ) == 0 ) {
|
else if ( strcasecmp ( token, "run" ) == 0 ) {
|
||||||
modi[num_modi] = &run_mode;
|
modi[num_modi] = &run_mode;
|
||||||
|
|
|
@ -596,3 +596,71 @@ void config_parse_xresource_init ( void )
|
||||||
{
|
{
|
||||||
XrmInitialize ();
|
XrmInitialize ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char * config_parser_return_display_help_entry ( XrmOption *option )
|
||||||
|
{
|
||||||
|
switch ( option->type )
|
||||||
|
{
|
||||||
|
case xrm_Number:
|
||||||
|
return g_markup_printf_escaped ( "<b%s</b> (%u) <span style='italic' size='small'>%s</span>",
|
||||||
|
option->name, *( option->value.num ), option->comment );
|
||||||
|
case xrm_SNumber:
|
||||||
|
return g_markup_printf_escaped ( "<b%s</b> (%d) <span style='italic' size='small'>%s</span>",
|
||||||
|
option->name, *( option->value.snum ), option->comment );
|
||||||
|
case xrm_String:
|
||||||
|
return g_markup_printf_escaped ( "<b>%s</b> (%s) <span style='italic' size='small'>%s</span>",
|
||||||
|
option->name,
|
||||||
|
( *( option->value.str ) != NULL ) ? *( option->value.str ) : "null",
|
||||||
|
option->comment
|
||||||
|
);
|
||||||
|
case xrm_Boolean:
|
||||||
|
return g_markup_printf_escaped ( "<b>%s</b> (%s) <span style='italic' size='small'>%s</span>",
|
||||||
|
option->name, ( *( option->value.num ) == TRUE ) ? "true" : "false", option->comment );
|
||||||
|
case xrm_Char:
|
||||||
|
if ( *( option->value.charc ) > 32 && *( option->value.charc ) < 127 ) {
|
||||||
|
return g_markup_printf_escaped ( "<b>%s</b> (%c) <span style='italic' size='small'>%s</span>",
|
||||||
|
option->name, *( option->value.charc ), option->comment );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return g_markup_printf_escaped ( "<b%s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
|
||||||
|
option->name, *( option->value.charc ), option->comment );
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup ( "failed" );
|
||||||
|
}
|
||||||
|
|
||||||
|
char ** config_parser_return_display_help ( unsigned int *length )
|
||||||
|
{
|
||||||
|
unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions );
|
||||||
|
char **retv = NULL;
|
||||||
|
for ( unsigned int i = 0; i < entries; ++i ) {
|
||||||
|
if ( ( i + 1 ) < entries ) {
|
||||||
|
if ( xrmOptions[i].value.str == xrmOptions[i + 1].value.str ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( strncmp ( xrmOptions[i].name, "kb", 2 ) != 0 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) );
|
||||||
|
|
||||||
|
retv[( *length )] = config_parser_return_display_help_entry ( &xrmOptions[i] );
|
||||||
|
( *length )++;
|
||||||
|
}
|
||||||
|
for ( unsigned int i = 0; i < num_extra_options; i++ ) {
|
||||||
|
if ( strncmp ( extra_options[i].name, "kb", 2 ) != 0 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) );
|
||||||
|
retv[( *length )] = config_parser_return_display_help_entry ( &extra_options[i] );
|
||||||
|
( *length )++;
|
||||||
|
}
|
||||||
|
if ( ( *length ) > 0 ) {
|
||||||
|
retv[( *length )] = NULL;
|
||||||
|
}
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue