From e7da00dbff338327c5beb8ced42ab84016a18ed7 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 4 May 2019 10:24:59 +0200 Subject: [PATCH] [DMenu] Add format option to output string stripped from pango markup. --- doc/rofi-theme-selector.1 | 2 +- doc/rofi-theme.5 | 2 +- doc/rofi.1 | 5 ++++- doc/rofi.1.markdown | 1 + source/helper.c | 10 ++++++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/doc/rofi-theme-selector.1 b/doc/rofi-theme-selector.1 index 47d0bff7..74712e74 100644 --- a/doc/rofi-theme-selector.1 +++ b/doc/rofi-theme-selector.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ROFI\-THEME\-SELECTOR" "1" "January 2018" "" "" +.TH "ROFI\-THEME\-SELECTOR" "1" "May 2019" "" "" . .SH "NAME" \fBrofi\-theme\-selector\fR \- Preview and apply themes for \fBrofi\fR diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index d09cd0ae..52928dcf 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ROFI\-THEME" "5" "April 2019" "" "" +.TH "ROFI\-THEME" "5" "May 2019" "" "" . .SH "NAME" \fBrofi\-theme\fR \- Rofi theme format files diff --git a/doc/rofi.1 b/doc/rofi.1 index 34796684..f8ea3d81 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ROFI" "1" "March 2019" "" "" +.TH "ROFI" "1" "May 2019" "" "" . .SH "NAME" \fBrofi\fR \- A window switcher, application launcher, ssh dialog and dmenu replacement @@ -1021,6 +1021,9 @@ Allows the output of dmenu to be customized (N is the total number of input entr \'q\' quote string . .IP "\(bu" 4 +\'p\' Selected string stripped from pango markup (Needs to be a valid string) +. +.IP "\(bu" 4 \'f\' filter string (user input) . .IP "\(bu" 4 diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index d54d76ec..7c9fd572 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -597,6 +597,7 @@ Allows the output of dmenu to be customized (N is the total number of input entr * 'i' index (0 - (N-1)) * 'd' index (1 - N) * 'q' quote string + * 'p' Selected string stripped from pango markup (Needs to be a valid string) * 'f' filter string (user input) * 'F' quoted filter string (user input) diff --git a/source/helper.c b/source/helper.c index 8dde6627..8b522841 100644 --- a/source/helper.c +++ b/source/helper.c @@ -1180,6 +1180,16 @@ void rofi_output_formatted_line ( const char *format, const char *string, int se else if ( format[i] == 's' ) { fputs ( string, stdout ); } + else if ( format[i] == 'p' ) { + char *esc = NULL; + pango_parse_markup(string, -1, 0, NULL, &esc, NULL, NULL); + if ( esc ){ + fputs ( esc, stdout ); + g_free ( esc ); + } else { + fputs ( "invalid string" , stdout ); + } + } else if ( format[i] == 'q' ) { char *quote = g_shell_quote ( string ); fputs ( quote, stdout );