From e517001d3951a4bb299c11ca427902ec7771f2b1 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 3 Jun 2015 09:04:29 +0200 Subject: [PATCH] Fix ellip. in entry box, wrap message box. --- Changelog | 4 +++- source/rofi.c | 3 ++- source/textbox.c | 19 ++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Changelog b/Changelog index 45731dd8..a68fd45f 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ 0.15.6 (unrelease): - + Bug fixes: + - Auto-wrap text in message dialog. + - Fix ellipsiziing in entry box. 0.15.5: Bug fixes: diff --git a/source/rofi.c b/source/rofi.c index 96034e11..7d811def 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1020,7 +1020,8 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom state.message_tb = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT | TB_MARKUP, ( config.padding ), state.top_offset, - entrybox_width, -1, + state.w - ( 2 * ( config.padding ) ), + -1, NORMAL, message ); textbox_show ( state.message_tb ); diff --git a/source/textbox.c b/source/textbox.c index 9bc37e20..d5fe2e52 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -119,6 +119,7 @@ textbox* textbox_create ( Window parent, textbox_font ( tb, tbft ); if ( ( flags & TB_MARKUP ) == TB_MARKUP ) { + pango_layout_set_wrap ( tb->layout, PANGO_WRAP_WORD_CHAR ); textbox_text_markup ( tb, text ? text : "" ); } else{ @@ -228,10 +229,6 @@ void textbox_move ( textbox *tb, int x, int y ) // within the parent handled auto width/height modes void textbox_moveresize ( textbox *tb, int x, int y, int w, int h ) { - if ( tb->flags & TB_AUTOHEIGHT ) { - h = textbox_get_height ( tb ); - } - if ( tb->flags & TB_AUTOWIDTH ) { pango_layout_set_width ( tb->layout, -1 ); if ( w > 1 ) { @@ -246,19 +243,27 @@ void textbox_moveresize ( textbox *tb, int x, int y, int w, int h ) if ( ( tb->flags & TB_EDITABLE ) == TB_EDITABLE ) { pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_MIDDLE ); } - else{ + else if ( ( tb->flags & TB_MARKUP ) != TB_MARKUP ) { pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_END ); } } + if ( tb->flags & TB_AUTOHEIGHT ) { + // Width determines height! + int tw = MAX ( 1, w ); + pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tw - 2 * SIDE_MARGIN ) ); + h = textbox_get_height ( tb ); + } + if ( x != tb->x || y != tb->y || w != tb->w || h != tb->h ) { tb->x = x; tb->y = y; - tb->w = MAX ( 1, w ); tb->h = MAX ( 1, h ); + tb->w = MAX ( 1, w ); XMoveResizeWindow ( display, tb->window, tb->x, tb->y, tb->w, tb->h ); - pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->w - 2 * SIDE_MARGIN ) ); } + // We always want to update this + pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->w - 2 * SIDE_MARGIN ) ); } void textbox_show ( textbox *tb )