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

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.
.PP
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
.PP
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
Xresources: A method of storing key values in the Xserver. See
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
Command\-line options: Arguments passed to \fBrofi\fP\&.
.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)).
* 'd' index (1 \- N).
* 'q' quote string.
* 'e' escape string.
* 'f' filter string (user input).
* 'F' quoted filter string (user input).
Default: 's'
.fi
.RE
@ -921,18 +925,22 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.SH WEBSITE
.PP
\fBrofi\fP website can be found at here
\[la]https://davedavenport.github.io/rofi/\[ra]
.UR https://davedavenport.github.io/rofi/
.UE
.PP
\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
.PP
Qball Cow
\[la]qball@gmpclient.org\[ra]
.MT qball@gmpclient.org
.ME
.PP
Rasmus Steinke
.PP
Original code based on work by: Sean Pringle
\[la]sean.pringle@gmail.com\[ra]
.MT sean.pringle@gmail.com
.ME
.PP
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.
*/
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

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 string The selected entry.
* @param selected_line The selected line index.
* @param filter The entered filter.
*
* Function that outputs the selected line in the user-specified format.
* Currently the following formats are supported:
* * i: Print the index (0-(N-1))
* * d: Print the index (1-N)
* * 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
* 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++ ) {
if ( format[i] == 'i' ) {
@ -159,8 +162,11 @@ static void dmenu_output_formatted_line ( const char *format, const char *string
fputs ( quote, stdout );
g_free ( quote );
}
else if ( format[i] == 'e' ) {
char *quote = g_strescape ( string, "" );
else if ( format[i] == 'f' ) {
fputs ( filter, stdout );
}
else if ( format[i] == 'F' ) {
char *quote = g_shell_quote ( filter );
fputs ( quote, stdout );
g_free ( quote );
}
@ -213,6 +219,7 @@ int dmenu_switcher_dialog ( char **input )
return TRUE;
}
}
find_arg_str_alloc ( "-filter", input );
do {
int next_pos = selected_line;
@ -225,7 +232,7 @@ int dmenu_switcher_dialog ( char **input )
*/
restart = TRUE;
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;
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
retv = 10 + ( mretv & MENU_LOWER_MASK );
@ -239,10 +246,10 @@ int dmenu_switcher_dialog ( char **input )
restart = FALSE;
if ( ( mretv & ( MENU_OK | MENU_CUSTOM_INPUT ) ) && list[selected_line] != NULL ) {
if ( ( mretv & MENU_CUSTOM_INPUT ) ) {
dmenu_output_formatted_line ( format, *input, -1 );
dmenu_output_formatted_line ( format, *input, -1, *input );
}
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 ) ) {
restart = TRUE;
@ -256,10 +263,10 @@ int dmenu_switcher_dialog ( char **input )
}
else if ( ( mretv & MENU_QUICK_SWITCH ) ) {
if ( ( mretv & MENU_CUSTOM_INPUT ) ) {
dmenu_output_formatted_line ( format, *input, -1 );
dmenu_output_formatted_line ( format, *input, -1, *input );
}
else{
dmenu_output_formatted_line ( format, list[selected_line], selected_line );
dmenu_output_formatted_line ( format, list[selected_line], selected_line, *input );
}
restart = FALSE;

View File

@ -226,6 +226,19 @@ int find_arg_str ( const char * const key, char** val )
}
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 )
{