mirror of
https://github.com/davatorium/rofi.git
synced 2025-01-27 15:25:24 -05:00
Add separator option.
This commit is contained in:
parent
dd5d2576ea
commit
f728e3f03e
9 changed files with 92 additions and 4 deletions
|
@ -78,6 +78,7 @@ Settings config = {
|
||||||
.x_offset = 0,
|
.x_offset = 0,
|
||||||
.fixed_num_lines = FALSE,
|
.fixed_num_lines = FALSE,
|
||||||
.disable_history = FALSE,
|
.disable_history = FALSE,
|
||||||
.levenshtein_sort = FALSE
|
.levenshtein_sort = FALSE,
|
||||||
|
.separator = '\n'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ rofi - A window switcher, run dialog and dmenu replacement
|
||||||
[ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ]
|
[ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ]
|
||||||
[ -ssh-client *client* ] [ -ssh-command *command* ] [ -now ] [ -rnow ] [ -snow ] [ -version ]
|
[ -ssh-client *client* ] [ -ssh-command *command* ] [ -now ] [ -rnow ] [ -snow ] [ -version ]
|
||||||
[ -help] [ -dump-xresources ] [ -disable-history ] [ -levenshtein-sort ] [ -show *mode* ] [ -switcher
|
[ -help] [ -dump-xresources ] [ -disable-history ] [ -levenshtein-sort ] [ -show *mode* ] [ -switcher
|
||||||
*mode1,mode2* ] [ -e *message*]
|
*mode1,mode2* ] [ -e *message*] [ -sep *separator* ]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
|
|
||||||
|
@ -281,6 +281,10 @@ The default key combinations are:
|
||||||
|
|
||||||
Popup a message dialog (used internally for showing errors) with *message*.
|
Popup a message dialog (used internally for showing errors) with *message*.
|
||||||
|
|
||||||
|
`-sep` *separator*
|
||||||
|
|
||||||
|
Separator for dmenu.
|
||||||
|
|
||||||
## Pattern
|
## Pattern
|
||||||
|
|
||||||
To launch commands (e.g. when using the ssh dialog) the user can enter the used commandline,
|
To launch commands (e.g. when using the ssh dialog) the user can enter the used commandline,
|
||||||
|
|
10
doc/rofi.1
10
doc/rofi.1
|
@ -10,7 +10,7 @@ rofi \- A window switcher, run dialog and dmenu replacement
|
||||||
[ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ]
|
[ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ]
|
||||||
[ \-ssh\-client \fIclient\fP ] [ \-ssh\-command \fIcommand\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ]
|
[ \-ssh\-client \fIclient\fP ] [ \-ssh\-command \fIcommand\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ]
|
||||||
[ \-help] [ \-dump\-xresources ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-show \fImode\fP ] [ \-switcher
|
[ \-help] [ \-dump\-xresources ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-show \fImode\fP ] [ \-switcher
|
||||||
\fImode1,mode2\fP ] [ \-e \fImessage\fP]
|
\fImode1,mode2\fP ] [ \-e \fImessage\fP] [ \-sep \fIseparator\fP ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
\fBrofi\fP is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number.
|
\fBrofi\fP is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number.
|
||||||
|
@ -362,6 +362,14 @@ So to have a mode 'Workspaces' using the \fB\fCi3_switch_workspace.sh\fR script
|
||||||
Popup a message dialog (used internally for showing errors) with *message*.
|
Popup a message dialog (used internally for showing errors) with *message*.
|
||||||
.fi
|
.fi
|
||||||
.RE
|
.RE
|
||||||
|
.PP
|
||||||
|
\fB\fC\-sep\fR \fIseparator\fP
|
||||||
|
.PP
|
||||||
|
.RS
|
||||||
|
.nf
|
||||||
|
Separator for dmenu.
|
||||||
|
.fi
|
||||||
|
.RE
|
||||||
.SH Pattern
|
.SH Pattern
|
||||||
.PP
|
.PP
|
||||||
To launch commands (e.g. when using the ssh dialog) the user can enter the used commandline,
|
To launch commands (e.g. when using the ssh dialog) the user can enter the used commandline,
|
||||||
|
|
|
@ -3,4 +3,6 @@
|
||||||
|
|
||||||
int helper_parse_setup ( char * string, char ***output, int *lenght, ... );
|
int helper_parse_setup ( char * string, char ***output, int *lenght, ... );
|
||||||
|
|
||||||
|
char* fgets_s ( char* s, int n, FILE *iop, char sep );
|
||||||
|
|
||||||
#endif // __HELPER_H__
|
#endif // __HELPER_H__
|
||||||
|
|
|
@ -129,6 +129,7 @@ typedef struct _Settings
|
||||||
unsigned int disable_history;
|
unsigned int disable_history;
|
||||||
|
|
||||||
unsigned int levenshtein_sort;
|
unsigned int levenshtein_sort;
|
||||||
|
char separator;
|
||||||
} Settings;
|
} Settings;
|
||||||
|
|
||||||
extern Settings config;
|
extern Settings config;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "rofi.h"
|
#include "rofi.h"
|
||||||
#include "dmenu-dialog.h"
|
#include "dmenu-dialog.h"
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
char *dmenu_prompt = "dmenu ";
|
char *dmenu_prompt = "dmenu ";
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ static char **get_dmenu ( int *length )
|
||||||
|
|
||||||
*length = 0;
|
*length = 0;
|
||||||
|
|
||||||
while ( fgets ( buffer, 1024, stdin ) != NULL ) {
|
while ( fgets_s ( buffer, 1024, stdin, (char) config.separator ) != NULL ) {
|
||||||
retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) );
|
retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) );
|
||||||
retv[( *length )] = g_strdup ( buffer );
|
retv[( *length )] = g_strdup ( buffer );
|
||||||
retv[( *length ) + 1] = NULL;
|
retv[( *length ) + 1] = NULL;
|
||||||
|
|
|
@ -4,6 +4,27 @@
|
||||||
#include <helper.h>
|
#include <helper.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
|
||||||
|
char* fgets_s ( char* s, int n, FILE *iop, char sep )
|
||||||
|
{
|
||||||
|
register int c;
|
||||||
|
register char* cs;
|
||||||
|
cs = s;
|
||||||
|
|
||||||
|
while ( --n > 0 && ( c = getc ( iop ) ) != EOF ) {
|
||||||
|
// put the input char into the current pointer position, then increment it
|
||||||
|
// if a newline entered, break
|
||||||
|
if ( ( *cs++ = c ) == sep ) {
|
||||||
|
// Whipe separator
|
||||||
|
cs[-1] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*cs = '\0';
|
||||||
|
return ( c == EOF && cs == s ) ? NULL : s;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace the entries
|
* Replace the entries
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -263,6 +263,53 @@ static int find_arg_uint ( const int argc, char * const argv[], const char * con
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
static int find_arg_char ( const int argc, char * const argv[], const char * const key, char *val )
|
||||||
|
{
|
||||||
|
int i = find_arg ( argc, argv, key );
|
||||||
|
|
||||||
|
if ( val != NULL && i > 0 && i < ( argc - 1 ) ) {
|
||||||
|
int len = strlen ( argv[i + 1] );
|
||||||
|
if ( len == 1 ) {
|
||||||
|
*val = argv[i + 1][0];
|
||||||
|
}
|
||||||
|
else if ( len == 2 && argv[i + 1][0] == '\\' ) {
|
||||||
|
if ( argv[i + 1][1] == 'n' ) {
|
||||||
|
*val = '\n';
|
||||||
|
}
|
||||||
|
else if ( argv[i + 1][1] == 'a' ) {
|
||||||
|
*val = '\a';
|
||||||
|
}
|
||||||
|
else if ( argv[i + 1][1] == 'b' ) {
|
||||||
|
*val = '\b';
|
||||||
|
}
|
||||||
|
else if ( argv[i + 1][1] == 't' ) {
|
||||||
|
*val = '\t';
|
||||||
|
}
|
||||||
|
else if ( argv[i + 1][1] == 'v' ) {
|
||||||
|
*val = '\v';
|
||||||
|
}
|
||||||
|
else if ( argv[i + 1][1] == 'f' ) {
|
||||||
|
*val = '\f';
|
||||||
|
}
|
||||||
|
else if ( argv[i + 1][1] == 'r' ) {
|
||||||
|
*val = '\r';
|
||||||
|
}
|
||||||
|
else if ( argv[i + 1][1] == '\\' ) {
|
||||||
|
*val = '\\';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf ( stderr, "Failed to parse command-line argument." );
|
||||||
|
exit ( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
fprintf ( stderr, "Failed to parse command-line argument." );
|
||||||
|
exit ( 1 );
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ( *xerror )( Display *, XErrorEvent * );
|
static int ( *xerror )( Display *, XErrorEvent * );
|
||||||
|
@ -2198,6 +2245,8 @@ static void parse_cmd_options ( int argc, char ** argv )
|
||||||
find_arg_str ( argc, argv, "-skey", &( config.ssh_key ) );
|
find_arg_str ( argc, argv, "-skey", &( config.ssh_key ) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
find_arg_char ( argc, argv, "-sep", &( config.separator ) );
|
||||||
// Dump.
|
// Dump.
|
||||||
if ( find_arg ( argc, argv, "-dump-xresources" ) >= 0 ) {
|
if ( find_arg ( argc, argv, "-dump-xresources" ) >= 0 ) {
|
||||||
xresource_dump ();
|
xresource_dump ();
|
||||||
|
|
|
@ -109,6 +109,7 @@ static XrmOption xrmOptions[] = {
|
||||||
{ xrm_String, "key", { .str = &config.window_key }, NULL },
|
{ xrm_String, "key", { .str = &config.window_key }, NULL },
|
||||||
{ xrm_String, "rkey", { .str = &config.run_key }, NULL },
|
{ xrm_String, "rkey", { .str = &config.run_key }, NULL },
|
||||||
{ xrm_String, "skey", { .str = &config.ssh_key }, NULL },
|
{ xrm_String, "skey", { .str = &config.ssh_key }, NULL },
|
||||||
|
{ xrm_Number, "separator", { .num = &config.separator }, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue