summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/config.def.c3
-rw-r--r--include/rofi.h2
-rw-r--r--include/textbox.h2
-rw-r--r--source/rofi.c12
-rw-r--r--source/textbox.c34
-rw-r--r--source/xrmoptions.c3
6 files changed, 21 insertions, 35 deletions
diff --git a/config/config.def.c b/config/config.def.c
index 37ab74c6..1afcd483 100644
--- a/config/config.def.c
+++ b/config/config.def.c
@@ -139,5 +139,6 @@ Settings config = {
/** Separator style: dash/solid */
.separator_style = "dash",
/** Hide scrollbar */
- .hide_scrollbar = FALSE,
+ .hide_scrollbar = FALSE,
+ .markup_rows = FALSE,
};
diff --git a/include/rofi.h b/include/rofi.h
index 35d56cc8..d44ddbf7 100644
--- a/include/rofi.h
+++ b/include/rofi.h
@@ -236,6 +236,8 @@ typedef struct _Settings
char *separator_style;
/** hide scrollbar */
unsigned int hide_scrollbar;
+ /** show markup in elements. */
+ unsigned int markup_rows;
} Settings;
/** Global Settings structure. */
diff --git a/include/textbox.h b/include/textbox.h
index 20252fe7..95105177 100644
--- a/include/textbox.h
+++ b/include/textbox.h
@@ -239,6 +239,4 @@ void textbox_delete ( textbox *tb, int pos, int dlen );
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h );
int textbox_get_estimated_char_height ( void );
-
-void textbox_text_markup ( textbox *tb, const char *text );
#endif //ROFI_TEXTBOX_H
diff --git a/source/rofi.c b/source/rofi.c
index 3007e2bd..2c831506 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -909,9 +909,13 @@ static void menu_resize ( MenuState *state )
int y_offset = state->top_offset;
int x_offset = config.padding;
+ int rstate = 0;
+ if ( config.markup_rows ) {
+ rstate = TB_MARKUP;
+ }
// Add newly added boxes.
for ( unsigned int i = last_length; i < state->max_elements; i++ ) {
- state->boxes[i] = textbox_create ( main_window, &vinfo, map, 0, x_offset, y_offset,
+ state->boxes[i] = textbox_create ( main_window, &vinfo, map, rstate, x_offset, y_offset,
state->element_width, element_height, NORMAL, "" );
}
scrollbar_resize ( state->scrollbar, -1, ( state->max_rows ) * ( element_height ) - config.line_margin );
@@ -1028,8 +1032,12 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
int y_offset = state.top_offset;
int x_offset = config.padding;
+ int rstate = 0;
+ if ( config.markup_rows ) {
+ rstate = TB_MARKUP;
+ }
for ( unsigned int i = 0; i < state.max_elements; i++ ) {
- state.boxes[i] = textbox_create ( main_window, &vinfo, map, 0, x_offset, y_offset,
+ state.boxes[i] = textbox_create ( main_window, &vinfo, map, rstate, x_offset, y_offset,
state.element_width, element_height, NORMAL, "" );
}
if ( !config.hide_scrollbar ) {
diff --git a/source/textbox.c b/source/textbox.c
index bce3acfa..0cfe0d76 100644
--- a/source/textbox.c
+++ b/source/textbox.c
@@ -80,7 +80,6 @@ textbox* textbox_create ( Window parent, XVisualInfo *vinfo, Colormap map, Textb
tb->layout = pango_layout_new ( p_context );
- tb->markup = FALSE;
tb->changed = FALSE;
unsigned int cp;
@@ -111,11 +110,8 @@ textbox* textbox_create ( Window parent, XVisualInfo *vinfo, Colormap map, Textb
if ( ( flags & TB_MARKUP ) == TB_MARKUP ) {
pango_layout_set_wrap ( tb->layout, PANGO_WRAP_WORD_CHAR );
- textbox_text_markup ( tb, text ? text : "" );
- }
- else{
- textbox_text ( tb, text ? text : "" );
}
+ textbox_text ( tb, text ? text : "" );
textbox_cursor_end ( tb );
// auto height/width modes get handled here
@@ -173,32 +169,12 @@ void textbox_text ( textbox *tb, const char *text )
tb->text = g_strdup ( "Invalid UTF-8 string." );
}
}
- pango_layout_set_text ( tb->layout, tb->text, strlen ( tb->text ) );
- if ( tb->flags & TB_AUTOWIDTH ) {
- textbox_moveresize ( tb, tb->x, tb->y, tb->w, tb->h );
- }
-
- tb->cursor = MAX ( 0, MIN ( ( int ) strlen ( text ), tb->cursor ) );
-}
-// set the default text to display
-void textbox_text_markup ( textbox *tb, const char *text )
-{
- g_free ( tb->text );
- const gchar *last_pointer = NULL;
- if ( g_utf8_validate ( text, -1, &last_pointer ) ) {
- tb->text = g_strdup ( text );
+ if ( tb->flags & TB_MARKUP ) {
+ pango_layout_set_markup ( tb->layout, tb->text, strlen ( tb->text ) );
}
else {
- if ( last_pointer != NULL ) {
- // Copy string up to invalid character.
- tb->text = g_strndup ( text, ( last_pointer - text ) );
- }
- else {
- tb->text = g_strdup ( "Invalid UTF-8 string." );
- }
+ pango_layout_set_text ( tb->layout, tb->text, strlen ( tb->text ) );
}
- tb->markup = TRUE;
- pango_layout_set_markup ( tb->layout, tb->text, strlen ( tb->text ) );
if ( tb->flags & TB_AUTOWIDTH ) {
textbox_moveresize ( tb, tb->x, tb->y, tb->w, tb->h );
}
@@ -301,7 +277,7 @@ void textbox_draw ( textbox *tb )
int cursor_width = MAX ( 2, font_height / 10 );
if ( tb->changed ) {
- if ( tb->markup ) {
+ if ( tb->flags & TB_MARKUP ) {
pango_layout_set_markup ( tb->layout, text, text_len );
}
else{
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index 47cb89fe..ffd05115 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -128,7 +128,8 @@ static XrmOption xrmOptions[] = {
{ xrm_Number, "line-margin", { .num = &config.line_margin }, NULL },
{ xrm_String, "filter", { .str = &config.filter }, NULL },
{ xrm_String, "separator-style", { .str = &config.separator_style }, NULL },
- { xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar }, NULL }
+ { xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar }, NULL },
+ { xrm_Boolean, "markup-rows", { .num = &config.markup_rows }, NULL }
};
// Dynamic options.