summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-06-01 19:03:23 +0200
committerDave Davenport <qball@gmpclient.org>2016-06-01 19:04:52 +0200
commit72d6c2087629379926550331a0f8d592e9c6204d (patch)
tree376cc37a7f9878b894689172db1f5320bf8d8fe0 /source
parentf96461a5434ef8c6c02ffc7162def09dc80df60e (diff)
parentc0954764193fd4113347bb66f847a9c9f45366e6 (diff)
Merge remote-tracking branch 'origin/master' into highlight_match
Diffstat (limited to 'source')
-rw-r--r--source/dialogs/drun.c2
-rw-r--r--source/dialogs/help-keys.c134
-rw-r--r--source/dialogs/window.c48
-rw-r--r--source/history.c2
-rw-r--r--source/keyb.c105
-rw-r--r--source/rofi.c7
-rw-r--r--source/view.c24
-rw-r--r--source/xrmoptions.c70
8 files changed, 314 insertions, 78 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index fcab4f0e..f0ffd551 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -220,7 +220,7 @@ static void get_apps_dir ( DRunModePrivateData *pd, const char *bp )
}
}
/**
- * @param cmd The command to remove from history
+ * @param entry The command entry to remove from history
*
* Remove command from history.
*/
diff --git a/source/dialogs/help-keys.c b/source/dialogs/help-keys.c
new file mode 100644
index 00000000..dc0955e6
--- /dev/null
+++ b/source/dialogs/help-keys.c
@@ -0,0 +1,134 @@
+/**
+ * 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,
+ GRegex **tokens,
+ unsigned int index
+ )
+{
+ KeysHelpModePrivateData *rmpd = (KeysHelpModePrivateData *) mode_get_private_data ( data );
+ return token_match ( tokens, rmpd->messages[index] );
+}
+
+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;
+}
+
+#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,
+ .private_data = NULL,
+ .free = NULL
+};
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index 56ff8d01..d56e76f0 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -367,6 +367,22 @@ static unsigned int window_mode_get_num_entries ( const Mode *sw )
const ModeModePrivateData *pd = (const ModeModePrivateData *) mode_get_private_data ( sw );
return pd->cmd_list_length;
}
+/**
+ * Small helper function to find the right entry in the ewmh reply.
+ * Is there a call for this?
+ */
+static const char * _window_name_list_entry ( const char *str, uint32_t length, int entry )
+{
+ uint32_t offset = 0;
+ int index = 0;
+ while ( index < entry && offset < length ) {
+ if ( str[offset] == 0 ) {
+ index++;
+ }
+ offset++;
+ }
+ return &str[offset];
+}
static void _window_mode_load_data ( Mode *sw, unsigned int cd )
{
ModeModePrivateData *pd = (ModeModePrivateData *) mode_get_private_data ( sw );
@@ -455,6 +471,12 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
}
pd->cmd_list = g_malloc0_n ( ( pd->ids->len + 1 ), sizeof ( char* ) );
+ c = xcb_ewmh_get_desktop_names ( &xcb->ewmh, xcb->screen_nbr );
+ xcb_ewmh_get_utf8_strings_reply_t names;
+ int has_names = FALSE;
+ if ( xcb_ewmh_get_desktop_names_reply ( &xcb->ewmh, c, &names, NULL ) ) {
+ has_names = TRUE;
+ }
// build the actual list
for ( i = 0; i < ( pd->ids->len ); i++ ) {
xcb_window_t w = pd->ids->array[i];
@@ -462,11 +484,8 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
if ( ( c = window_client ( w ) ) ) {
// final line format
- char desktop[5];
- desktop[0] = 0;
- size_t len =
- ( ( c->title != NULL ) ? strlen ( c->title ) : 0 ) + ( c->class ? strlen ( c->class ) : 0 ) + classfield + 50;
- char *line = g_malloc ( len );
+ char *desktop = NULL;
+ char *line = NULL;
if ( !pd->config_i3_mode ) {
uint32_t wmdesktop = 0;
// find client's desktop.
@@ -492,18 +511,29 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
free ( r );
if ( wmdesktop < 0xFFFFFFFF ) {
- snprintf ( desktop, 5, "%u", (uint32_t) wmdesktop );
+ if ( has_names ) {
+ desktop = g_strdup_printf ( "%s", _window_name_list_entry ( names.strings, names.strings_len, wmdesktop ) );
+ }
+ else {
+ desktop = g_strdup_printf ( "%u", (uint32_t) wmdesktop );
+ }
+ }
+ else {
+ desktop = g_strdup ( "" );
}
- snprintf ( line, len, pattern, desktop, c->class ? c->class : "", c->title ? c->title : "" );
+ line = g_strdup_printf ( pattern, desktop, c->class ? c->class : "", c->title ? c->title : "" );
}
else{
- snprintf ( line, len, pattern, c->class ? c->class : "", c->title ? c->title : "" );
+ line = g_strdup_printf ( pattern, c->class ? c->class : "", c->title ? c->title : "" );
}
-
+ g_free ( desktop );
pd->cmd_list[pd->cmd_list_length++] = line;
}
}
+ if ( has_names ) {
+ xcb_ewmh_get_utf8_strings_reply_wipe ( &names );
+ }
}
}
static int window_mode_init ( Mode *sw )
diff --git a/source/history.c b/source/history.c
index 3b2de37a..d404d36b 100644
--- a/source/history.c
+++ b/source/history.c
@@ -99,7 +99,7 @@ static _element ** __history_get_element_list ( FILE *fd, unsigned int *length )
continue;
}
start++;
- if ( ( l - ( start - buffer ) ) < 3 ) {
+ if ( ( l - ( start - buffer ) ) < 2 ) {
continue;
}
// Resize and check.
diff --git a/source/keyb.c b/source/keyb.c
index c0e3bc5a..5ef27029 100644
--- a/source/keyb.c
+++ b/source/keyb.c
@@ -24,6 +24,7 @@ typedef struct
KeyBindingAction id;
char *name;
char *keybinding;
+ char *comment;
} DefaultBinding;
ActionBindingEntry abe[NUM_ABE];
@@ -33,57 +34,57 @@ ActionBindingEntry abe[NUM_ABE];
*/
DefaultBinding bindings[NUM_ABE] =
{
- { .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+Shift+v,Shift+Insert", },
- { .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", },
- { .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+u", },
- { .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", },
- { .id = MOVE_END, .name = "kb-move-end", .keybinding = "Control+e", },
- { .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", },
- { .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", },
- { .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b" },
- { .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f" },
- { .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h", },
- { .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", },
- { .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", },
- { .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", },
- { .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", },
- { .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return,Shift+Return", },
- { .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab" },
- { .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab" },
- { .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave" },
- { .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete" },
- { .id = ROW_LEFT, .name = "kb-row-left", .keybinding = "Control+Page_Up" },
- { .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = "Control+Page_Down" },
- { .id = ROW_UP, .name = "kb-row-up", .keybinding = "Up,Control+p,Shift+Tab,Shift+ISO_Left_Tab" },
- { .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n" },
- { .id = ROW_TAB, .name = "kb-row-tab", .keybinding = "Tab" },
- { .id = PAGE_PREV, .name = "kb-page-prev", .keybinding = "Page_Up" },
- { .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = "Page_Down" },
- { .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home" },
- { .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End" },
- { .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space" },
- { .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape,Control+bracketleft" },
- { .id = CUSTOM_1, .name = "kb-custom-1", .keybinding = "Alt+1" },
- { .id = CUSTOM_2, .name = "kb-custom-2", .keybinding = "Alt+2" },
- { .id = CUSTOM_3, .name = "kb-custom-3", .keybinding = "Alt+3" },
- { .id = CUSTOM_4, .name = "kb-custom-4", .keybinding = "Alt+4" },
- { .id = CUSTOM_5, .name = "kb-custom-5", .keybinding = "Alt+5" },
- { .id = CUSTOM_6, .name = "kb-custom-6", .keybinding = "Alt+6" },
- { .id = CUSTOM_7, .name = "kb-custom-7", .keybinding = "Alt+7" },
- { .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8" },
- { .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9" },
- { .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0" },
- { .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+Shift+1" },
- { .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2" },
- { .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3" },
- { .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4" },
- { .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5" },
- { .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6" },
- { .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8" },
- { .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7" },
- { .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9" },
- { .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+Shift+S" },
- { .id = TOGGLE_SORT, .name = "kb-toggle-sort", .keybinding = "Alt+grave" },
+ { .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+Shift+v,Shift+Insert", .comment = "Paste primary selection" },
+ { .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", .comment = "Paste clipboard" },
+ { .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+u", .comment = "Clear input line" },
+ { .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", .comment = "Beginning of line" },
+ { .id = MOVE_END, .name = "kb-move-end", .keybinding = "Control+e", .comment = "End of line" },
+ { .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", .comment = "Move back 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_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", .comment = "Delete previous 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_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 = 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,Tab", .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" },
+ { .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_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 = 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 = CANCEL, .name = "kb-cancel", .keybinding = "Escape,Control+bracketleft", .comment = "Quit rofi" },
+ { .id = CUSTOM_1, .name = "kb-custom-1", .keybinding = "Alt+1", .comment = "Custom keybinding 1" },
+ { .id = CUSTOM_2, .name = "kb-custom-2", .keybinding = "Alt+2", .comment = "Custom keybinding 2" },
+ { .id = CUSTOM_3, .name = "kb-custom-3", .keybinding = "Alt+3", .comment = "Custom keybinding 3" },
+ { .id = CUSTOM_4, .name = "kb-custom-4", .keybinding = "Alt+4", .comment = "Custom keybinding 4" },
+ { .id = CUSTOM_5, .name = "kb-custom-5", .keybinding = "Alt+5", .comment = "Custom Keybinding 5" },
+ { .id = CUSTOM_6, .name = "kb-custom-6", .keybinding = "Alt+6", .comment = "Custom keybinding 6" },
+ { .id = CUSTOM_7, .name = "kb-custom-7", .keybinding = "Alt+7", .comment = "Custom Keybinding 7" },
+ { .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_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_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2", .comment = "Custom keybinding 12" },
+ { .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3", .comment = "Csutom keybinding 13" },
+ { .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4", .comment = "Custom keybinding 14" },
+ { .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5", .comment = "Custom keybinding 15" },
+ { .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6", .comment = "Custom keybinding 16" },
+ { .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7", .comment = "Custom keybinding 17" },
+ { .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8", .comment = "Custom keybinding 18" },
+ { .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9", .comment = "Custom Keybinding 19" },
};
void setup_abe ( void )
@@ -96,7 +97,7 @@ void setup_abe ( void )
abe[id].num_bindings = 0;
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 );
}
}
diff --git a/source/rofi.c b/source/rofi.c
index 474deebb..9910ebd8 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -282,7 +282,7 @@ static void cleanup ()
rofi_view_workers_finalize ();
if ( main_loop != NULL ) {
if ( main_loop_source ) {
- g_water_xcb_source_unref ( main_loop_source );
+ g_water_xcb_source_free ( main_loop_source );
}
g_main_loop_unref ( main_loop );
main_loop = NULL;
@@ -334,6 +334,10 @@ static int add_mode ( const char * token )
modi[num_modi] = &ssh_mode;
num_modi++;
}
+ else if ( strcasecmp ( token, mode_get_name ( &help_keys_mode ) ) == 0 ) {
+ modi[num_modi] = &help_keys_mode;
+ num_modi++;
+ }
// Run dialog
else if ( strcasecmp ( token, "run" ) == 0 ) {
modi[num_modi] = &run_mode;
@@ -389,7 +393,6 @@ static void setup_modi ( void )
}
/**
- * @param display Pointer to the X connection to use.
* Load configuration.
* Following priority: (current), X, commandline arguments
*/
diff --git a/source/view.c b/source/view.c
index 6a565aab..f88259f0 100644
--- a/source/view.c
+++ b/source/view.c
@@ -180,10 +180,7 @@ static void menu_capture_screenshot ( void )
}
/**
- * @param state the state of the View.
- * @param mon the work area.
- *
- * Calculates the window poslition
+ * Calculates the window position
*/
static void calculate_window_position ( void )
{
@@ -792,14 +789,16 @@ inline static void rofi_view_nav_left ( RofiViewState *state )
*/
inline static void rofi_view_nav_up ( RofiViewState *state )
{
+ // If no lines or don't cycle, do nothing.
+ if ( state->filtered_lines == 0 || ( state->selected == 0 && !config.cycle ) ) {
+ return;
+ }
+
// Wrap around.
if ( state->selected == 0 ) {
state->selected = state->filtered_lines;
}
-
- if ( state->selected > 0 ) {
- state->selected--;
- }
+ state->selected--;
state->update = TRUE;
}
@@ -811,8 +810,8 @@ inline static void rofi_view_nav_up ( RofiViewState *state )
*/
inline static void rofi_view_nav_down ( RofiViewState *state )
{
- // If no lines, do nothing.
- if ( state->filtered_lines == 0 ) {
+ // If no lines or don't cycle, do nothing.
+ if ( state->filtered_lines == 0 || ( state->selected == state->filtered_lines - 1 && !config.cycle ) ) {
return;
}
state->selected = state->selected < state->filtered_lines - 1 ? MIN ( state->filtered_lines - 1, state->selected + 1 ) : 0;
@@ -1116,10 +1115,9 @@ static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t
/**
* @param state Internal state of the menu.
- * @param key the Key being pressed.
- * @param modstate the modifier state.
+ * @param action The action to perform.
*
- * Keyboard navigation through the elements.
+ * Perform keyboard navigation action.
*/
static void rofi_view_keyboard_navigation ( RofiViewState *state, KeyBindingAction action )
{
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index 66a1494a..63bf12c5 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -125,6 +125,8 @@ static XrmOption xrmOptions[] = {
"Use levenshtein sorting" },
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL,
"Set case-sensitivity" },
+ { xrm_Boolean, "cycle", { .num = &config.cycle }, NULL,
+ "Cycle through the results list" },
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL,
"Enable sidebar-mode" },
{ xrm_SNumber, "eh", { .snum = &config.element_height }, NULL,
@@ -594,3 +596,71 @@ void config_parse_xresource_init ( void )
{
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;
+}