Implement builtin support for sixel images, allow combining with text (#2109)

* Add function for reading lines in file

* Implement sixel drawing

* Remove sixel option

* Fix linting error
This commit is contained in:
Joe Lim authored and GitHub committed 2025-08-25 22:19:14 +10:00
1 parent aba73884e3
commit 13da770af6
11 files changed
+190 -99

No files matched your search

+6 -18
View File
@@ -92,10 +92,7 @@ func (e *setExpr) eval(app *app, args []string) {
err = applyBoolOpt(&gOpts.drawbox, e)
if err == nil {
app.ui.renew()
if app.nav.height != app.ui.wins[0].h {
app.nav.height = app.ui.wins[0].h
clear(app.nav.regCache)
}
clear(app.nav.regCache)
app.ui.loadFile(app, true)
}
case "hidden", "nohidden", "hidden!":
@@ -148,10 +145,8 @@ func (e *setExpr) eval(app *app, args []string) {
err = errors.New("preview: 'ratios' should consist of at least two numbers before enabling 'preview'")
}
if err == nil {
if gOpts.sixel {
app.ui.sxScreen.forceClear = true
}
gOpts.preview = preview
app.ui.sxScreen.forceClear = true
app.ui.loadFile(app, true)
}
case "relativenumber", "norelativenumber", "relativenumber!":
@@ -166,11 +161,9 @@ func (e *setExpr) eval(app *app, args []string) {
err = applyBoolOpt(&gOpts.roundbox, e)
case "showbinds", "noshowbinds", "showbinds!":
err = applyBoolOpt(&gOpts.showbinds, e)
// DEPRECATED: remove after r38 is released
case "sixel", "nosixel", "sixel!":
err = applyBoolOpt(&gOpts.sixel, e)
clear(app.nav.regCache)
app.ui.sxScreen.forceClear = true
app.ui.loadFile(app, true)
app.ui.echoerr("option 'sixel' has been removed as it is now enabled by default")
case "smartcase", "nosmartcase", "smartcase!":
err = applyBoolOpt(&gOpts.smartcase, e)
if err == nil {
@@ -355,9 +348,7 @@ func (e *setExpr) eval(app *app, args []string) {
}
gOpts.ratios = rats
app.ui.wins = getWins(app.ui.screen)
if gOpts.sixel {
clear(app.nav.regCache)
}
clear(app.nav.regCache)
app.ui.loadFile(app, true)
case "rulerfmt":
gOpts.rulerfmt = e.val
@@ -1352,13 +1343,10 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.height = app.ui.wins[0].h
clear(app.nav.regCache)
}
if gOpts.sixel {
clear(app.nav.regCache)
app.ui.sxScreen.forceClear = true
}
for _, dir := range app.nav.dirs {
dir.boundPos(app.nav.height)
}
app.ui.sxScreen.forceClear = true
app.ui.loadFile(app, true)
onRedraw(app)
case "load":