mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
Experimental Sixel support (#2544)
This commit is contained in:
@@ -38,6 +38,9 @@ func (r *FullscreenRenderer) Clear() {}
|
||||
func (r *FullscreenRenderer) NeedScrollbarRedraw() bool { return false }
|
||||
func (r *FullscreenRenderer) Refresh() {}
|
||||
func (r *FullscreenRenderer) Close() {}
|
||||
func (r *FullscreenRenderer) Size() (termSize, error) {
|
||||
return termSize{}, nil
|
||||
}
|
||||
|
||||
func (r *FullscreenRenderer) GetChar() Event { return Event{} }
|
||||
func (r *FullscreenRenderer) MaxX() int { return 0 }
|
||||
|
||||
@@ -32,7 +32,7 @@ var offsetRegexp *regexp.Regexp = regexp.MustCompile("(.*)\x1b\\[([0-9]+);([0-9]
|
||||
var offsetRegexpBegin *regexp.Regexp = regexp.MustCompile("^\x1b\\[[0-9]+;[0-9]+R")
|
||||
|
||||
func (r *LightRenderer) PassThrough(str string) {
|
||||
r.queued.WriteString(str)
|
||||
r.queued.WriteString("\x1b7" + str + "\x1b8")
|
||||
r.flush()
|
||||
}
|
||||
|
||||
@@ -756,6 +756,10 @@ func (r *LightRenderer) NewWindow(top int, left int, width int, height int, prev
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *LightWindow) DrawBorder() {
|
||||
w.drawBorder(false)
|
||||
}
|
||||
|
||||
func (w *LightWindow) DrawHBorder() {
|
||||
w.drawBorder(true)
|
||||
}
|
||||
@@ -1095,7 +1099,8 @@ func (w *LightWindow) FinishFill() {
|
||||
}
|
||||
|
||||
func (w *LightWindow) Erase() {
|
||||
w.drawBorder(false)
|
||||
// We don't erase the window here to avoid flickering during scroll
|
||||
w.DrawBorder()
|
||||
w.Move(0, 0)
|
||||
w.FinishFill()
|
||||
w.Move(0, 0)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/junegunn/fzf/src/util"
|
||||
"golang.org/x/term"
|
||||
@@ -108,3 +109,19 @@ func (r *LightRenderer) getch(nonblock bool) (int, bool) {
|
||||
}
|
||||
return int(b[0]), true
|
||||
}
|
||||
|
||||
type window struct {
|
||||
lines uint16
|
||||
columns uint16
|
||||
width uint16
|
||||
height uint16
|
||||
}
|
||||
|
||||
func (r *LightRenderer) Size() (termSize, error) {
|
||||
w := new(window)
|
||||
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, r.ttyin.Fd(), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(w)))
|
||||
if err != 0 {
|
||||
return termSize{}, err
|
||||
}
|
||||
return termSize{int(w.lines), int(w.columns), int(w.width), int(w.height)}, nil
|
||||
}
|
||||
|
||||
@@ -203,6 +203,11 @@ func (r *FullscreenRenderer) Refresh() {
|
||||
// noop
|
||||
}
|
||||
|
||||
func (r *FullscreenRenderer) Size() (termSize, error) {
|
||||
cols, lines := _screen.Size()
|
||||
return termSize{lines, cols, 0, 0}, error("Not implemented")
|
||||
}
|
||||
|
||||
func (r *FullscreenRenderer) GetChar() Event {
|
||||
ev := _screen.PollEvent()
|
||||
switch ev := ev.(type) {
|
||||
@@ -541,6 +546,7 @@ func fill(x, y, w, h int, n ColorPair, r rune) {
|
||||
}
|
||||
|
||||
func (w *TcellWindow) Erase() {
|
||||
w.drawBorder(false)
|
||||
fill(w.left-1, w.top, w.width+1, w.height-1, w.normal, ' ')
|
||||
}
|
||||
|
||||
@@ -692,6 +698,10 @@ func (w *TcellWindow) CFill(fg Color, bg Color, a Attr, str string) FillReturn {
|
||||
return w.fillString(str, NewColorPair(fg, bg, a))
|
||||
}
|
||||
|
||||
func (w *TcellWindow) DrawBorder() {
|
||||
w.drawBorder(false)
|
||||
}
|
||||
|
||||
func (w *TcellWindow) DrawHBorder() {
|
||||
w.drawBorder(true)
|
||||
}
|
||||
|
||||
@@ -473,6 +473,13 @@ func MakeTransparentBorder() BorderStyle {
|
||||
bottomRight: ' '}
|
||||
}
|
||||
|
||||
type termSize struct {
|
||||
Lines int
|
||||
Columns int
|
||||
Width int
|
||||
Height int
|
||||
}
|
||||
|
||||
type Renderer interface {
|
||||
Init()
|
||||
Resize(maxHeightFunc func(int) int)
|
||||
@@ -490,6 +497,8 @@ type Renderer interface {
|
||||
MaxX() int
|
||||
MaxY() int
|
||||
|
||||
Size() (termSize, error)
|
||||
|
||||
NewWindow(top int, left int, width int, height int, preview bool, borderStyle BorderStyle) Window
|
||||
}
|
||||
|
||||
@@ -499,6 +508,7 @@ type Window interface {
|
||||
Width() int
|
||||
Height() int
|
||||
|
||||
DrawBorder()
|
||||
DrawHBorder()
|
||||
Refresh()
|
||||
FinishFill()
|
||||
|
||||
Reference in New Issue
Block a user