1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00
This commit is contained in:
QC 2015-05-16 13:58:09 +02:00
parent 571aca9834
commit 354ccdd94d
5 changed files with 48 additions and 18 deletions

View file

@ -520,7 +520,8 @@ The following options are further explained in the theming section:
* 'i' index (0 - (N-1)). * 'i' index (0 - (N-1)).
* 'd' index (1 - N). * 'd' index (1 - N).
* 'q' quote string. * 'q' quote string.
* 'e' escape string. * 'f' filter string (user input).
* 'F' quoted filter string (user input).
Default: 's' Default: 's'

View file

@ -87,7 +87,8 @@ Keybindings can also be specified in the \fB\fCXresources\fR file.
\fBrofi\fP can emulate \fB\fCdmenu\fR (a dynamic menu for X) when launched with the \fB\fC\-dmenu\fR flag. \fBrofi\fP can emulate \fB\fCdmenu\fR (a dynamic menu for X) when launched with the \fB\fC\-dmenu\fR flag.
.PP .PP
The official website for \fB\fCdmenu\fR can be found here The official website for \fB\fCdmenu\fR can be found here
\[la]http://tools.suckless.org/dmenu/\[ra]\&. .UR http://tools.suckless.org/dmenu/
.UE \&.
.SH OPTIONS .SH OPTIONS
.PP .PP
There are currently three methods of setting configuration options: There are currently three methods of setting configuration options:
@ -97,7 +98,9 @@ Compile time: edit config.c. This method is strongly discouraged.
.IP \(bu 2 .IP \(bu 2
Xresources: A method of storing key values in the Xserver. See Xresources: A method of storing key values in the Xserver. See
here here
\[la]https://en.wikipedia.org/wiki/X_resources\[ra] for more information. .UR https://en.wikipedia.org/wiki/X_resources
.UE
for more information.
.IP \(bu 2 .IP \(bu 2
Command\-line options: Arguments passed to \fBrofi\fP\&. Command\-line options: Arguments passed to \fBrofi\fP\&.
.RE .RE
@ -679,7 +682,8 @@ Allows the output of dmenu to be customized (N is total number of input entries)
* 'i' index (0 \- (N\-1)). * 'i' index (0 \- (N\-1)).
* 'd' index (1 \- N). * 'd' index (1 \- N).
* 'q' quote string. * 'q' quote string.
* 'e' escape string. * 'f' filter string (user input).
* 'F' quoted filter string (user input).
Default: 's' Default: 's'
.fi .fi
.RE .RE
@ -921,18 +925,22 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.SH WEBSITE .SH WEBSITE
.PP .PP
\fBrofi\fP website can be found at here \fBrofi\fP website can be found at here
\[la]https://davedavenport.github.io/rofi/\[ra] .UR https://davedavenport.github.io/rofi/
.UE
.PP .PP
\fBrofi\fP bugtracker can be found here \fBrofi\fP bugtracker can be found here
\[la]https://github.com/DaveDavenport/rofi/issues\[ra] .UR https://github.com/DaveDavenport/rofi/issues
.UE
.SH AUTHOR .SH AUTHOR
.PP .PP
Qball Cow Qball Cow
\[la]qball@gmpclient.org\[ra] .MT qball@gmpclient.org
.ME
.PP .PP
Rasmus Steinke Rasmus Steinke
.PP .PP
Original code based on work by: Sean Pringle Original code based on work by: Sean Pringle
\[la]sean.pringle@gmail.com\[ra] .MT sean.pringle@gmail.com
.ME
.PP .PP
For a full list of authors, check the AUTHORS file. For a full list of authors, check the AUTHORS file.

View file

@ -81,6 +81,7 @@ int find_arg_int ( const char * const key, int *val );
* @returns TRUE if key was found and val was set. * @returns TRUE if key was found and val was set.
*/ */
int find_arg_str ( const char * const key, char** val ); int find_arg_str ( const char * const key, char** val );
int find_arg_str_alloc ( const char * const key, char** val );
/** /**
* @param key The key to search for * @param key The key to search for

View file

@ -131,18 +131,21 @@ static const char *get_display_data ( unsigned int index, void *data, G_GNUC_UNU
* @param format The format string used. See below for possible syntax. * @param format The format string used. See below for possible syntax.
* @param string The selected entry. * @param string The selected entry.
* @param selected_line The selected line index. * @param selected_line The selected line index.
* @param filter The entered filter.
* *
* Function that outputs the selected line in the user-specified format. * Function that outputs the selected line in the user-specified format.
* Currently the following formats are supported: * Currently the following formats are supported:
* * i: Print the index (0-(N-1)) * * i: Print the index (0-(N-1))
* * d: Print the index (1-N) * * d: Print the index (1-N)
* * s: Print input string. * * s: Print input string.
* * e: Print input string shell quoted. * * q: Print quoted input string.
* * f: Print the entered filter.
* * F: Print the entered filter, quoted
* *
* This functions outputs the formatted string to stdout, appends a newline (\n) character and * This functions outputs the formatted string to stdout, appends a newline (\n) character and
* calls flush on the file descriptor. * calls flush on the file descriptor.
*/ */
static void dmenu_output_formatted_line ( const char *format, const char *string, int selected_line ) static void dmenu_output_formatted_line ( const char *format, const char *string, int selected_line, const char *filter )
{ {
for ( int i = 0; format && format[i]; i++ ) { for ( int i = 0; format && format[i]; i++ ) {
if ( format[i] == 'i' ) { if ( format[i] == 'i' ) {
@ -159,8 +162,11 @@ static void dmenu_output_formatted_line ( const char *format, const char *string
fputs ( quote, stdout ); fputs ( quote, stdout );
g_free ( quote ); g_free ( quote );
} }
else if ( format[i] == 'e' ) { else if ( format[i] == 'f' ) {
char *quote = g_strescape ( string, "" ); fputs ( filter, stdout );
}
else if ( format[i] == 'F' ) {
char *quote = g_shell_quote ( filter );
fputs ( quote, stdout ); fputs ( quote, stdout );
g_free ( quote ); g_free ( quote );
} }
@ -213,6 +219,7 @@ int dmenu_switcher_dialog ( char **input )
return TRUE; return TRUE;
} }
} }
find_arg_str_alloc ( "-filter", input );
do { do {
int next_pos = selected_line; int next_pos = selected_line;
@ -225,7 +232,7 @@ int dmenu_switcher_dialog ( char **input )
*/ */
restart = TRUE; restart = TRUE;
if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && list[selected_line] != NULL ) { if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && list[selected_line] != NULL ) {
dmenu_output_formatted_line ( format, list[selected_line], selected_line ); dmenu_output_formatted_line ( format, list[selected_line], selected_line, *input );
retv = TRUE; retv = TRUE;
if ( ( mretv & MENU_QUICK_SWITCH ) ) { if ( ( mretv & MENU_QUICK_SWITCH ) ) {
retv = 10 + ( mretv & MENU_LOWER_MASK ); retv = 10 + ( mretv & MENU_LOWER_MASK );
@ -239,10 +246,10 @@ int dmenu_switcher_dialog ( char **input )
restart = FALSE; restart = FALSE;
if ( ( mretv & ( MENU_OK | MENU_CUSTOM_INPUT ) ) && list[selected_line] != NULL ) { if ( ( mretv & ( MENU_OK | MENU_CUSTOM_INPUT ) ) && list[selected_line] != NULL ) {
if ( ( mretv & MENU_CUSTOM_INPUT ) ) { if ( ( mretv & MENU_CUSTOM_INPUT ) ) {
dmenu_output_formatted_line ( format, *input, -1 ); dmenu_output_formatted_line ( format, *input, -1, *input );
} }
else{ else{
dmenu_output_formatted_line ( format, list[selected_line], selected_line ); dmenu_output_formatted_line ( format, list[selected_line], selected_line, *input );
} }
if ( ( mretv & MENU_SHIFT ) ) { if ( ( mretv & MENU_SHIFT ) ) {
restart = TRUE; restart = TRUE;
@ -256,10 +263,10 @@ int dmenu_switcher_dialog ( char **input )
} }
else if ( ( mretv & MENU_QUICK_SWITCH ) ) { else if ( ( mretv & MENU_QUICK_SWITCH ) ) {
if ( ( mretv & MENU_CUSTOM_INPUT ) ) { if ( ( mretv & MENU_CUSTOM_INPUT ) ) {
dmenu_output_formatted_line ( format, *input, -1 ); dmenu_output_formatted_line ( format, *input, -1, *input );
} }
else{ else{
dmenu_output_formatted_line ( format, list[selected_line], selected_line ); dmenu_output_formatted_line ( format, list[selected_line], selected_line, *input );
} }
restart = FALSE; restart = FALSE;

View file

@ -226,6 +226,19 @@ int find_arg_str ( const char * const key, char** val )
} }
return FALSE; return FALSE;
} }
int find_arg_str_alloc ( const char * const key, char** val )
{
int i = find_arg ( key );
if ( val != NULL && i > 0 && i < stored_argc - 1 ) {
if ( *val != NULL ) {
g_free ( *val );
}
*val = g_strdup ( stored_argv[i + 1] );
return TRUE;
}
return FALSE;
}
int find_arg_int ( const char * const key, int *val ) int find_arg_int ( const char * const key, int *val )
{ {