diff --git a/Changelog b/Changelog index 17776fd0..9ece8160 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,8 @@ - Auto-wrap text in message dialog. - Fix ellipsiziing in entry box. - Fix crash on empty list with custom input (#175). + New feature: + - Markup support error message. 0.15.5: Bug fixes: diff --git a/include/rofi.h b/include/rofi.h index 02783700..f9b8a6e4 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -233,10 +233,11 @@ extern Settings config; /** * @param msg The error message to show. + * @param markup The error message uses pango markup. * * The error message to show. */ -void error_dialog ( const char *msg ); +void error_dialog ( const char *msg, int markup ); /** * Structure defining a switcher. diff --git a/include/textbox.h b/include/textbox.h index 9d49aedb..37b4fbef 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -25,13 +25,13 @@ typedef struct typedef enum { - TB_AUTOHEIGHT = 1 << 0, - TB_AUTOWIDTH = 1 << 1, - TB_LEFT = 1 << 16, - TB_RIGHT = 1 << 17, - TB_CENTER = 1 << 18, - TB_EDITABLE = 1 << 19, - TB_MARKUP = 1 << 20, + TB_AUTOHEIGHT = 1 << 0, + TB_AUTOWIDTH = 1 << 1, + TB_LEFT = 1 << 16, + TB_RIGHT = 1 << 17, + TB_CENTER = 1 << 18, + TB_EDITABLE = 1 << 19, + TB_MARKUP = 1 << 20, } TextboxFlags; diff --git a/source/dialogs/run.c b/source/dialogs/run.c index 289fcd7a..8ea7395d 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -62,7 +62,7 @@ static inline void execsh ( const char *cmd, int run_in_term ) if ( error != NULL ) { char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd, error->message ); - error_dialog ( msg ); + error_dialog ( msg, FALSE ); g_free ( msg ); // print error. g_error_free ( error ); diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index 2ff58260..897e2b45 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -64,7 +64,7 @@ static inline int execshssh ( const char *host ) if ( error != NULL ) { char *msg = g_strdup_printf ( "Failed to execute: 'ssh %s'\nError: '%s'", host, error->message ); - error_dialog ( msg ); + error_dialog ( msg, FALSE ); g_free ( msg ); // print error. g_error_free ( error ); diff --git a/source/i3-support.c b/source/i3-support.c index 8fe14d92..4bfe26a5 100644 --- a/source/i3-support.c +++ b/source/i3-support.c @@ -86,7 +86,7 @@ void i3_support_focus_window ( Window id ) t = send ( s, &head, sizeof ( i3_ipc_header_t ), 0 ); if ( t == -1 ) { char *msg = g_strdup_printf ( "Failed to send message header to i3: %s\n", strerror ( errno ) ); - error_dialog ( msg ); + error_dialog ( msg, FALSE ); g_free ( msg ); close ( s ); return; @@ -95,7 +95,7 @@ void i3_support_focus_window ( Window id ) t = send ( s, command, strlen ( command ), 0 ); if ( t == -1 ) { char *msg = g_strdup_printf ( "Failed to send message body to i3: %s\n", strerror ( errno ) ); - error_dialog ( msg ); + error_dialog ( msg, FALSE ); g_free ( msg ); close ( s ); return; diff --git a/source/rofi.c b/source/rofi.c index 7d811def..bbe94e33 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1371,7 +1371,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom return retv; } -void error_dialog ( const char *msg ) +void error_dialog ( const char *msg, int markup ) { MenuState state = { .selected_line = NULL, @@ -1409,7 +1409,7 @@ void error_dialog ( const char *msg ) menu_calculate_window_and_element_width ( &state, &mon ); state.max_elements = 0; - state.text = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT, + state.text = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT + ( ( markup ) ? TB_MARKUP : 0 ), ( config.padding ), ( config.padding ), ( state.w - ( 2 * ( config.padding ) ) ), @@ -1741,7 +1741,7 @@ static void hup_action_handler ( int num ) } } -static void show_error_message ( const char *msg ) +static void show_error_message ( const char *msg, int markup ) { // Create pid file create_pid_file ( pidfile ); @@ -1749,7 +1749,7 @@ static void show_error_message ( const char *msg ) // Request truecolor visual. create_visual_and_colormap ( display ); textbox_setup ( &vinfo, map ); - error_dialog ( msg ); + error_dialog ( msg, markup ); textbox_cleanup ( ); if ( map != None ) { XFreeColormap ( display, map ); @@ -1861,7 +1861,11 @@ int main ( int argc, char *argv[] ) char *msg = NULL; if ( find_arg_str ( "-e", &( msg ) ) ) { - show_error_message ( msg ); + int markup = FALSE; + if ( find_arg ( "-markup" ) >= 0 ) { + markup = TRUE; + } + show_error_message ( msg, markup ); exit ( EXIT_SUCCESS ); }