diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-11-03 00:07:28 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-11-03 00:09:02 +0900 |
commit | 68db9cb499ab32190edae6c285942c5fb7cf39ed (patch) | |
tree | 4c70d7627aac26faa5ba3fbadc90fad770416046 /src/tui | |
parent | d0466fa77714cccae6875facafb4a7d49e3f958e (diff) |
Sixel and Kitty image support on Windows binary (#2544)
Diffstat (limited to 'src/tui')
-rw-r--r-- | src/tui/dummy.go | 3 | ||||
-rw-r--r-- | src/tui/light.go | 8 | ||||
-rw-r--r-- | src/tui/tcell.go | 25 | ||||
-rw-r--r-- | src/tui/tui.go | 3 |
4 files changed, 29 insertions, 10 deletions
diff --git a/src/tui/dummy.go b/src/tui/dummy.go index cceb4478..d6495816 100644 --- a/src/tui/dummy.go +++ b/src/tui/dummy.go @@ -33,7 +33,8 @@ func (r *FullscreenRenderer) Init() {} func (r *FullscreenRenderer) Resize(maxHeightFunc func(int) int) {} func (r *FullscreenRenderer) Pause(bool) {} func (r *FullscreenRenderer) Resume(bool, bool) {} -func (r *FullscreenRenderer) PassThrough(string) {} +func (r *FullscreenRenderer) PassThrough(int, int, string) {} +func (r *FullscreenRenderer) Sync(bool) {} func (r *FullscreenRenderer) Clear() {} func (r *FullscreenRenderer) NeedScrollbarRedraw() bool { return false } func (r *FullscreenRenderer) Refresh() {} diff --git a/src/tui/light.go b/src/tui/light.go index e5950cde..dd1f9f3d 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -31,8 +31,12 @@ const consoleDevice string = "/dev/tty" var offsetRegexp *regexp.Regexp = regexp.MustCompile("(.*)\x1b\\[([0-9]+);([0-9]+)R") var offsetRegexpBegin *regexp.Regexp = regexp.MustCompile("^\x1b\\[[0-9]+;[0-9]+R") -func (r *LightRenderer) PassThrough(str string) { - r.queued.WriteString("\x1b7" + str + "\x1b8") +func (r *LightRenderer) PassThrough(y int, x int, data string) { + r.queued.WriteString("\x1b7" + data + "\x1b8") +} + +func (r *LightRenderer) Sync(bool) { + // No-op } func (r *LightRenderer) stderr(str string) { diff --git a/src/tui/tcell.go b/src/tui/tcell.go index 38641f7a..bf7b57cb 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -98,9 +98,22 @@ const ( AttrClear = Attr(1 << 8) ) -func (r *FullscreenRenderer) PassThrough(str string) { - // No-op - // https://github.com/gdamore/tcell/issues/363#issuecomment-680665073 +func (r *FullscreenRenderer) PassThrough(y int, x int, data string) { + tty, _ := _screen.Tty() + ti, err := tcell.LookupTerminfo(os.Getenv("TERM")) + if err != nil { + return + } + ti.TPuts(tty, ti.TGoto(x, y)) + ti.TPuts(tty, data) +} + +func (r *FullscreenRenderer) Sync(hard bool) { + if hard { + _screen.Sync() + } else { + _screen.Show() + } } func (r *FullscreenRenderer) Resize(maxHeightFunc func(int) int) {} @@ -207,10 +220,10 @@ func (r *FullscreenRenderer) Refresh() { // noop } -// TODO: Pixel width and height not implemented func (r *FullscreenRenderer) Size() TermSize { - cols, lines := _screen.Size() - return TermSize{lines, cols, 0, 0} + tty, _ := _screen.Tty() + ws, _ := tty.WindowSize() + return TermSize{ws.Height, ws.Width, ws.PixelWidth, ws.PixelHeight} } func (r *FullscreenRenderer) GetChar() Event { diff --git a/src/tui/tui.go b/src/tui/tui.go index 5a5e18d6..6834f350 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -489,7 +489,8 @@ type Renderer interface { RefreshWindows(windows []Window) Refresh() Close() - PassThrough(string) + PassThrough(y int, x int, data string) + Sync(bool) NeedScrollbarRedraw() bool GetChar() Event |