mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Cleanup.
This commit is contained in:
parent
b9d1fe6635
commit
56e85d0f5a
4 changed files with 43 additions and 63 deletions
|
@ -52,4 +52,5 @@ void xresource_dump ( void );
|
|||
*/
|
||||
void config_parser_add_option ( XrmOptionType type, const char *key, void **value, const char *comment );
|
||||
void print_options ( void );
|
||||
void print_help_msg ( const char *option, const char*text, const char *def, int isatty );
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "rofi.h"
|
||||
#include "dialogs/dmenu.h"
|
||||
#include "helper.h"
|
||||
#include "xrmoptions.h"
|
||||
|
||||
// We limit at 1000000 rows for now.
|
||||
#define DMENU_MAX_ROWS 1000000
|
||||
|
@ -79,7 +80,7 @@ static char **get_dmenu ( unsigned int *length )
|
|||
data[l - 1] = '\0';
|
||||
}
|
||||
|
||||
retv[( *length )] = data; //copy;
|
||||
retv[( *length )] = data;
|
||||
data = NULL;
|
||||
data_l = 0;
|
||||
|
||||
|
@ -397,34 +398,16 @@ int dmenu_switcher_dialog ( void )
|
|||
|
||||
void print_dmenu_options ( void )
|
||||
{
|
||||
if ( isatty ( fileno ( stdout ) ) ) {
|
||||
printf (
|
||||
"\t"color_bold "-mesg"color_reset
|
||||
" [string] Print a small user message under the prompt (uses pango markup)\n" );
|
||||
printf ( "\t"color_bold "-p"color_reset " [string] Prompt to display left of entry field\n" );
|
||||
printf ( "\t"color_bold "-selected-row"color_reset " [integer] Select row\n" );
|
||||
printf ( "\t"color_bold "-format"color_reset " [string] Output format string\n" );
|
||||
printf ( "\t\t"color_italic "s"color_reset "\n" );
|
||||
printf ( "\t"color_bold "-u"color_reset " [list] List of row indexes to mark urgent\n" );
|
||||
printf ( "\t"color_bold "-a"color_reset " [list] List of row indexes to mark active\n" );
|
||||
printf ( "\t"color_bold "-l"color_reset " [integer] Number of rows to display\n" );
|
||||
printf ( "\t"color_bold "-i"color_reset " Set filter to be case insensitive\n" );
|
||||
printf ( "\t"color_bold "-only-match"color_reset " Force selection or custom entry\n" );
|
||||
printf ( "\t"color_bold "-no-custom"color_reset " Don't accept custom entry\n" );
|
||||
printf ( "\t"color_bold "-select"color_reset " [string] Select the first row that matches\n" );
|
||||
}
|
||||
else {
|
||||
printf ( "\t-mesg [string] Print a small user message under the prompt (uses pango markup)\n" );
|
||||
printf ( "\t-p [string] Prompt to display left of entry field\n" );
|
||||
printf ( "\t-selected-row [integer] Select row\n" );
|
||||
printf ( "\t-format [string] Output format string\n" );
|
||||
printf ( "\t\ts\n" );
|
||||
printf ( "\t-u [list] List of row indexes to mark urgent\n" );
|
||||
printf ( "\t-a [list] List of row indexes to mark active\n" );
|
||||
printf ( "\t-l [integer] Number of rows to display\n" );
|
||||
printf ( "\t-i Set filter to be case insensitive\n" );
|
||||
printf ( "\t-only-match Force selection or custom entry\n" );
|
||||
printf ( "\t-no-custom Don't accept custom entry\n" );
|
||||
printf ( "\t-select [string] Select the first row that matches\n" );
|
||||
}
|
||||
int is_term = isatty ( fileno ( stdout ) );
|
||||
print_help_msg ( "-mesg [string]", "Print a small user message under the prompt (uses pango markup)", NULL, is_term );
|
||||
print_help_msg ( "-p [string]", "Prompt to display left of entry field", NULL, is_term );
|
||||
print_help_msg ( "-selected-row [integer]", "Select row", NULL, is_term );
|
||||
print_help_msg ( "-format [string]", "Output format string", "s", is_term );
|
||||
print_help_msg ( "-u [list]", "List of row indexes to mark urgent", NULL, is_term );
|
||||
print_help_msg ( "-a [list]", "List of row indexes to mark active", NULL, is_term );
|
||||
print_help_msg ( "-l [integer] ", "Number of rows to display", NULL, is_term );
|
||||
print_help_msg ( "-i", "Set filter to be case insensitive", NULL, is_term );
|
||||
print_help_msg ( "-only-match", "Force selection or custom entry", NULL, is_term );
|
||||
print_help_msg ( "-no-custom", "Don't accept custom entry", NULL, is_term );
|
||||
print_help_msg ( "-select [string]", "Select the first row that matches", NULL, is_term );
|
||||
}
|
||||
|
|
|
@ -1834,38 +1834,17 @@ static void handle_keypress ( XEvent *ev )
|
|||
static void print_main_application_options ( void )
|
||||
{
|
||||
int is_term = isatty ( fileno ( stdout ) );
|
||||
if ( is_term ) {
|
||||
printf ( "\t"color_bold "-no-config"color_reset " Do not load configuration, use default values.\n" );
|
||||
printf ( "\t"color_bold "-quiet"color_reset " Suppress information messages.\n" );
|
||||
printf ( "\t"color_bold "-v,-version"color_reset " Print the version number and exit.\n" );
|
||||
printf ( "\t"color_bold "-dmenu"color_reset " Start in dmenu mode.\n" );
|
||||
printf ( "\t"color_bold "-display [string]"color_reset " X server to contact.\n" );
|
||||
printf ( "\t\t"color_italic "${DISPLAY}"color_reset "\n" );
|
||||
printf ( "\t"color_bold "-h,-help"color_reset " This help message.\n" );
|
||||
printf ( "\t"color_bold "-dump-xresources"color_reset
|
||||
" Dump the current configuration in Xresources format and exit.\n" );
|
||||
printf ( "\t"color_bold "-e [string]"color_reset
|
||||
" Show a dialog displaying the passed message and exit.\n" );
|
||||
printf ( "\t"color_bold "-markup"color_reset " Enable pango markup where possible.\n" );
|
||||
printf ( "\t"color_bold "-normal-window"color_reset
|
||||
" In dmenu mode, behave as a normal window. (experimental)\n" );
|
||||
printf ( "\t"color_bold "-show [mode]"color_reset
|
||||
" Show the mode 'mode' and exit. The mode has to be enabled.\n" );
|
||||
}
|
||||
else {
|
||||
printf ( "\t-no-config Do not load configuration, use default values.\n" );
|
||||
printf ( "\t-quiet Suppress information messages.\n" );
|
||||
printf ( "\t-v,-version Print the version number and exit.\n" );
|
||||
printf ( "\t-dmenu Start in dmenu mode.\n" );
|
||||
printf ( "\t-display [string] X server to contact.\n" );
|
||||
printf ( "\t\t${DISPLAY}\n" );
|
||||
printf ( "\t-h,-help This help message.\n" );
|
||||
printf ( "\t-dump-xresources Dump the current configuration in Xresources format and exit.\n" );
|
||||
printf ( "\t-e [string] Show a dialog displaying the passed message and exit.\n" );
|
||||
printf ( "\t-markup Enable pango markup where possible.\n" );
|
||||
printf ( "\t-normal-window In dmenu mode, behave as a normal window. (experimental)\n" );
|
||||
printf ( "\t-show [mode] Show the mode 'mode' and exit. The mode has to be enabled.\n" );
|
||||
}
|
||||
print_help_msg ( "-no-config", "Do not load configuration, use default values.", NULL, is_term );
|
||||
print_help_msg ( "-quiet", "Suppress information messages.", NULL, is_term );
|
||||
print_help_msg ( "-v,-version", "Print the version number and exit.", NULL, is_term );
|
||||
print_help_msg ( "-dmenu", "Start in dmenu mode.", NULL, is_term );
|
||||
print_help_msg ( "-display [string]", "X server to contact.", "${DISPLAY}", is_term );
|
||||
print_help_msg ( "-h,-help", "This help message.", NULL, is_term );
|
||||
print_help_msg ( "-dump-xresources", "Dump the current configuration in Xresources format and exit.", NULL, is_term );
|
||||
print_help_msg ( "-e [string]", "Show a dialog displaying the passed message and exit.", NULL, is_term );
|
||||
print_help_msg ( "-markup", "Enable pango markup where possible.", NULL, is_term );
|
||||
print_help_msg ( "-normal-window", "In dmenu mode, behave as a normal window. (experimental)", NULL, is_term );
|
||||
print_help_msg ( "-show [mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term );
|
||||
}
|
||||
static void help ( G_GNUC_UNUSED int argc, char **argv )
|
||||
{
|
||||
|
|
|
@ -492,3 +492,20 @@ void print_options ( void )
|
|||
print_option ( &extra_options[i], is_term );
|
||||
}
|
||||
}
|
||||
|
||||
void print_help_msg ( const char *option, const char*text, const char *def, int isatty )
|
||||
{
|
||||
int l = 39 - strlen ( option );
|
||||
if ( isatty ) {
|
||||
printf ( "\t%s%s%s %-*c%s\n", color_bold, option, color_reset, l, ' ', text );
|
||||
if ( def != NULL ) {
|
||||
printf ( "\t\t%s%s%s\n", color_italic, def, color_reset );
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf ( "\t%s %-*c%s\n", option, l, ' ', text );
|
||||
if ( def != NULL ) {
|
||||
printf ( "\t\t%s\n", def );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue