Refactor previewable logic (#2235)
This commit is contained in:
1 parent
fc4b3637bb
commit
928bf9e3bd
2 files changed
+15
-3
No files matched your search
@@ -142,6 +142,18 @@ func (file *file) TotalSize() int64 {
|
||||
return file.Size()
|
||||
}
|
||||
|
||||
func (file *file) isPreviewable() bool {
|
||||
if file.Mode().IsRegular() {
|
||||
return true
|
||||
}
|
||||
|
||||
if file.IsDir() && gOpts.dirpreviews {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
type fakeStat struct {
|
||||
name string
|
||||
}
|
||||
@@ -806,7 +818,7 @@ func (nav *nav) preload() {
|
||||
}
|
||||
|
||||
file := dir.files[i]
|
||||
if !(file.Mode().IsRegular() || (file.IsDir() && gOpts.dirpreviews)) {
|
||||
if !file.isPreviewable() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -797,7 +797,7 @@ func (ui *ui) loadFile(app *app, volatile bool) {
|
||||
return
|
||||
}
|
||||
|
||||
if curr.Mode().IsRegular() || (curr.IsDir() && gOpts.dirpreviews) {
|
||||
if curr.isPreviewable() {
|
||||
ui.regPrev = app.nav.loadReg(curr.path, volatile)
|
||||
} else if curr.IsDir() {
|
||||
ui.dirPrev = app.nav.loadDir(curr.path)
|
||||
@@ -1294,7 +1294,7 @@ func (ui *ui) draw(nav *nav) {
|
||||
preview := ui.wins[len(ui.wins)-1]
|
||||
ui.sxScreen.clearSixel(preview, ui.screen, curr.path)
|
||||
if gOpts.preview {
|
||||
if curr.Mode().IsRegular() || (curr.IsDir() && gOpts.dirpreviews) {
|
||||
if curr.isPreviewable() {
|
||||
preview.printReg(ui.screen, ui.regPrev, nav.previewLoading, &ui.sxScreen)
|
||||
} else if curr.IsDir() {
|
||||
ui.sxScreen.lastFile = ""
|
||||
|
||||
Reference in new issue
Block a user