summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-09-25 12:37:37 +1000
committerJesse Duffield <jessedduffield@gmail.com>2021-09-27 19:58:24 +1000
commitab0117c416847fcdb82383d31735391ba83bfd74 (patch)
tree09b32319df09e0732db5025b5b1485fc87484311 /vendor
parent652c97d2396c53d24fbb4a461573fa2ab381eab6 (diff)
fix some encodings
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/jesseduffield/gocui/gui.go11
-rw-r--r--vendor/github.com/jesseduffield/gocui/tcell_driver.go32
2 files changed, 33 insertions, 10 deletions
diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go
index eccae45a3..7bd764346 100644
--- a/vendor/github.com/jesseduffield/gocui/gui.go
+++ b/vendor/github.com/jesseduffield/gocui/gui.go
@@ -147,10 +147,6 @@ type Gui struct {
// match any known sequence, ESC means KeyEsc.
InputEsc bool
- // If ASCII is true then use ASCII instead of unicode to draw the
- // interface. Using ASCII is more portable.
- ASCII bool
-
// SupportOverlaps is true when we allow for view edges to overlap with other
// view edges
SupportOverlaps bool
@@ -754,9 +750,7 @@ func (g *Gui) clear(fg, bg Attribute) (int, int) {
// drawFrameEdges draws the horizontal and vertical edges of a view.
func (g *Gui) drawFrameEdges(v *View, fgColor, bgColor Attribute) error {
runeH, runeV := '─', '│'
- if g.ASCII {
- runeH, runeV = '-', '|'
- } else if len(v.FrameRunes) >= 2 {
+ if len(v.FrameRunes) >= 2 {
runeH, runeV = v.FrameRunes[0], v.FrameRunes[1]
}
@@ -882,9 +876,6 @@ func (g *Gui) drawFrameCorners(v *View, fgColor, bgColor Attribute) error {
runeBL = corner(v, TOP|RIGHT)
runeBR = corner(v, TOP|LEFT)
}
- if g.ASCII {
- runeTL, runeTR, runeBL, runeBR = '+', '+', '+', '+'
- }
corners := []struct {
x, y int
diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/vendor/github.com/jesseduffield/gocui/tcell_driver.go
index 8d5045bce..2783103c3 100644
--- a/vendor/github.com/jesseduffield/gocui/tcell_driver.go
+++ b/vendor/github.com/jesseduffield/gocui/tcell_driver.go
@@ -8,6 +8,7 @@ import (
"time"
"github.com/gdamore/tcell/v2"
+ "github.com/mattn/go-runewidth"
)
// We probably don't want this being a global variable for YOLO for now
@@ -20,19 +21,50 @@ type oldStyle struct {
outputMode OutputMode
}
+var runeReplacements = map[rune]string{
+ '┌': "+",
+ '┐': "+",
+ '└': "+",
+ '┘': "+",
+ '─': "-",
+
+ // using a hyphen here actually looks weird.
+ // We see these characters when in portrait mode
+ '╶': " ",
+ '╴': " ",
+
+ '├': "+",
+ '│': "|",
+ '▼': "v",
+ '►': ">",
+ '▲': "^",
+ '◄': "<",
+}
+
// tcellInit initializes tcell screen for use.
func (g *Gui) tcellInit() error {
+ runewidth.DefaultCondition.EastAsianWidth = false
+ tcell.SetEncodingFallback(tcell.EncodingFallbackASCII)
+
if s, e := tcell.NewScreen(); e != nil {
return e
} else if e = s.Init(); e != nil {
return e
} else {
+ registerRuneFallbacks(s)
+
g.screen = s
Screen = s
return nil
}
}
+func registerRuneFallbacks(s tcell.Screen) {
+ for before, after := range runeReplacements {
+ s.RegisterRuneFallback(before, after)
+ }
+}
+
// tcellInitSimulation initializes tcell screen for use.
func (g *Gui) tcellInitSimulation() error {
s := tcell.NewSimulationScreen("")