summaryrefslogtreecommitdiffstats
path: root/source/xrmoptions.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-05-30 10:25:58 +0200
committerDave Davenport <qball@gmpclient.org>2016-05-30 10:25:58 +0200
commit1b5bcaa9f4a73adf07a3a4eb3c37f4f91032a417 (patch)
tree29289deedc989d79bddf5bfbc68184b4141ed40d /source/xrmoptions.c
parente84e387e9423404df028c41ffa0ad17c66a25b0e (diff)
Issue #411: Show list of Keyboard bindings with rofi, from rofi.
Diffstat (limited to 'source/xrmoptions.c')
-rw-r--r--source/xrmoptions.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index 3119992e..63bf12c5 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -596,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;
+}