mudgangster

Log | Files | Refs

commit 278eea376445a38d8f94eaa520f8f8ec0d18bbe2
parent 7ce09b3b89a5c22e132fbeb19457f3cb3e71dc54
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon,  3 Sep 2018 15:12:26 +0300

Support background colours

Diffstat:
handlers.lua | 15+++++++++++++++
src/textbox.cc | 8++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/handlers.lua b/handlers.lua @@ -39,6 +39,12 @@ local function setFG( colour ) end end +local function setBG( colour ) + return function() + bg = colour + end +end + local Escapes = { m = { [ "0" ] = function() @@ -59,6 +65,15 @@ local Escapes = { [ "35" ] = setFG( 5 ), [ "36" ] = setFG( 6 ), [ "37" ] = setFG( 7 ), + + [ "40" ] = setBG( 0 ), + [ "41" ] = setBG( 1 ), + [ "42" ] = setBG( 2 ), + [ "43" ] = setBG( 3 ), + [ "44" ] = setBG( 4 ), + [ "45" ] = setBG( 5 ), + [ "46" ] = setBG( 6 ), + [ "47" ] = setBG( 7 ), }, } diff --git a/src/textbox.cc b/src/textbox.cc @@ -88,6 +88,14 @@ void textbox_draw( const TextBox * tb ) { if( top < 0 ) continue; + // bg + int top_spacing = SPACING / 2; + int bot_spacing = SPACING - top_spacing; + XSetForeground( UI.display, UI.gc, + glyph.bg == SYSTEM ? Style.Colours.system : Style.colours[ 0 ][ glyph.bg ] ); + XFillRectangle( UI.display, doublebuf, UI.gc, left, top - top_spacing, Style.font.width, Style.font.height + bot_spacing ); + + // fg XSetFont( UI.display, UI.gc, ( glyph.bold ? Style.fontBold : Style.font ).font->fid ); XSetForeground( UI.display, UI.gc, glyph.fg == SYSTEM ? Style.Colours.system : Style.colours[ glyph.bold ][ glyph.fg ] );