mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
refactor
This commit is contained in:
parent
fafd5234bd
commit
0898a7bb57
36 changed files with 215 additions and 171 deletions
10
vendor/github.com/jesseduffield/gocui/tcell_driver.go
generated
vendored
10
vendor/github.com/jesseduffield/gocui/tcell_driver.go
generated
vendored
|
@ -5,6 +5,8 @@
|
|||
package gocui
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
|
||||
|
@ -21,6 +23,7 @@ type oldStyle struct {
|
|||
// we're using this cache to speed up rendering, because obtaining the tcell style
|
||||
// from the old style is deterministic
|
||||
var cellStyleCache map[oldStyle]tcell.Style = map[oldStyle]tcell.Style{}
|
||||
var cacheMutex = sync.RWMutex{}
|
||||
|
||||
// tcellInit initializes tcell screen for use.
|
||||
func tcellInit() error {
|
||||
|
@ -43,7 +46,10 @@ func tcellSetCell(x, y int, ch rune, fg, bg Attribute, outputMode OutputMode) {
|
|||
|
||||
// getTcellStyle creates tcell.Style from Attributes
|
||||
func getTcellStyle(input oldStyle) tcell.Style {
|
||||
if cachedResult, ok := cellStyleCache[input]; ok {
|
||||
cacheMutex.RLock()
|
||||
cachedResult, ok := cellStyleCache[input]
|
||||
cacheMutex.RUnlock()
|
||||
if ok {
|
||||
return cachedResult
|
||||
}
|
||||
|
||||
|
@ -59,7 +65,9 @@ func getTcellStyle(input oldStyle) tcell.Style {
|
|||
st = setTcellFontEffectStyle(st, input.bg)
|
||||
}
|
||||
|
||||
cacheMutex.Lock()
|
||||
cellStyleCache[input] = st
|
||||
cacheMutex.Unlock()
|
||||
|
||||
return st
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue