diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-09-25 12:37:37 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-09-27 19:58:24 +1000 |
commit | ab0117c416847fcdb82383d31735391ba83bfd74 (patch) | |
tree | 09b32319df09e0732db5025b5b1485fc87484311 | |
parent | 652c97d2396c53d24fbb4a461573fa2ab381eab6 (diff) |
fix some encodings
-rw-r--r-- | pkg/gui/gui.go | 8 | ||||
-rw-r--r-- | vendor/github.com/jesseduffield/gocui/gui.go | 11 | ||||
-rw-r--r-- | vendor/github.com/jesseduffield/gocui/tcell_driver.go | 32 |
3 files changed, 33 insertions, 18 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 975f0ad9e..95c165a71 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "log" "os" - "runtime" "sync" "os/exec" @@ -30,7 +29,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/updates" "github.com/jesseduffield/lazygit/pkg/utils" - "github.com/mattn/go-runewidth" "github.com/sirupsen/logrus" ) @@ -51,10 +49,6 @@ const StartupPopupVersion = 5 // OverlappingEdges determines if panel edges overlap var OverlappingEdges = false -func init() { - runewidth.DefaultCondition.EastAsianWidth = false -} - type ContextManager struct { ContextStack []Context sync.RWMutex @@ -497,8 +491,6 @@ func (gui *Gui) Run() error { g.NextSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.NextMatch) g.PrevSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.PrevMatch) - g.ASCII = runtime.GOOS == "windows" && runewidth.IsEastAsian() - g.ShowListFooter = userConfig.Gui.ShowListFooter if userConfig.Gui.MouseEvents { 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("") |