From 54bead63d9ede2148ba624f2bcef5e9c96a60e91 Mon Sep 17 00:00:00 2001 From: Vladimir Markelov Date: Fri, 6 Nov 2015 11:55:57 -0800 Subject: [PATCH] better horizontal scroll draw support --- canvas.go | 10 +++++++--- demos/themes/acsii.theme | 2 +- demos/themes/turbovision.theme | 2 +- textutil.go | 2 +- theme.go | 2 +- themes/turbovision.theme | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/canvas.go b/canvas.go index 2306c2c..dd4ccd6 100644 --- a/canvas.go +++ b/canvas.go @@ -286,15 +286,19 @@ func (fb *FrameBuffer) DrawScroll(x, y, w, h, pos int, fgScroll, bgScroll, fgThu } if scrollChars == "" { - scrollChars = "░■▲▼" + scrollChars = "░■▲▼◄►" } parts := []rune(scrollChars) chLine, chCursor, chUp, chDown := parts[0], parts[1], parts[2], parts[3] + chLeft, chRight := '◄', '►' + if len(parts) > 4 { + chLeft, chRight = parts[4], parts[5] + } if h == 1 { - fb.PutChar(x, y, chUp, fgScroll, bgScroll) - fb.PutChar(x+w-1, y, chDown, fgScroll, bgScroll) + fb.PutChar(x, y, chLeft, fgScroll, bgScroll) + fb.PutChar(x+w-1, y, chRight, fgScroll, bgScroll) if w > 2 { for xx := 1; xx < w-1; xx++ { diff --git a/demos/themes/acsii.theme b/demos/themes/acsii.theme index 4e85984..82bc9e1 100644 --- a/demos/themes/acsii.theme +++ b/demos/themes/acsii.theme @@ -16,7 +16,7 @@ ProgressActiveText = white SingleBorder=-|++++ DoubleBorder==|++++ Edit=<>V -ScrollBar=|O^V +ScrollBar=|O^V<> ViewButtons=^_X[] CheckBox=[] X? Radio=() * diff --git a/demos/themes/turbovision.theme b/demos/themes/turbovision.theme index 31076da..4490f70 100644 --- a/demos/themes/turbovision.theme +++ b/demos/themes/turbovision.theme @@ -58,7 +58,7 @@ ButtonDisabledBack=white SingleBorder=─│┌┐└┘ DoubleBorder=═║╔╗╚╝ Edit=←→V -ScrollBar=░■▲▼ +ScrollBar=░■▲▼◄► ViewButtons=^↓○[] CheckBox=[] X? Radio=() * diff --git a/textutil.go b/textutil.go index e91f446..d39996a 100644 --- a/textutil.go +++ b/textutil.go @@ -134,7 +134,7 @@ func SliceColorized(str string, start, end int) string { parser := NewColorParser(str, term.ColorBlack, term.ColorBlack) var out string for { - if curr >= end { + if end != -1 && curr >= end { break } elem := parser.NextElement() diff --git a/theme.go b/theme.go index a3f706c..2607cd8 100644 --- a/theme.go +++ b/theme.go @@ -130,7 +130,7 @@ func (s *ThemeManager) Reset() { defTheme.objects[ObjSingleBorder] = "─│┌┐└┘" defTheme.objects[ObjDoubleBorder] = "═║╔╗╚╝" defTheme.objects[ObjEdit] = "←→V" - defTheme.objects[ObjScrollBar] = "░■▲▼" + defTheme.objects[ObjScrollBar] = "░■▲▼◄►" defTheme.objects[ObjViewButtons] = "^↓○[]" defTheme.objects[ObjCheckBox] = "[] X?" defTheme.objects[ObjRadio] = "() *" diff --git a/themes/turbovision.theme b/themes/turbovision.theme index d35faae..eb79f03 100644 --- a/themes/turbovision.theme +++ b/themes/turbovision.theme @@ -59,7 +59,7 @@ ButtonDisabledBack=white SingleBorder=─│┌┐└┘ DoubleBorder=═║╔╗╚╝ Edit=←→V -ScrollBar=░■▲▼ +ScrollBar=░■▲▼◄► ViewButtons=^↓○[] CheckBox=[] X? Radio=() *