keep a copy of saved files and show in the ui
Mentioned in #13 and #36.
This commit is contained in:
parent
1511e05a2c
commit
724422efa3
1
eval.go
1
eval.go
@ -318,6 +318,7 @@ func (e *CallExpr) eval(app *App, args []string) {
|
|||||||
}
|
}
|
||||||
app.nav.renew(app.nav.height)
|
app.nav.renew(app.nav.height)
|
||||||
app.nav.save(false)
|
app.nav.save(false)
|
||||||
|
app.nav.saves = make(map[string]bool)
|
||||||
saveFiles(nil, false)
|
saveFiles(nil, false)
|
||||||
case "renew":
|
case "renew":
|
||||||
app.ui.sync()
|
app.ui.sync()
|
||||||
|
10
nav.go
10
nav.go
@ -217,6 +217,7 @@ type Nav struct {
|
|||||||
poss map[string]int
|
poss map[string]int
|
||||||
names map[string]string
|
names map[string]string
|
||||||
marks map[string]bool
|
marks map[string]bool
|
||||||
|
saves map[string]bool
|
||||||
height int
|
height int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,6 +258,7 @@ func newNav(height int) *Nav {
|
|||||||
poss: make(map[string]int),
|
poss: make(map[string]int),
|
||||||
names: make(map[string]string),
|
names: make(map[string]string),
|
||||||
marks: make(map[string]bool),
|
marks: make(map[string]bool),
|
||||||
|
saves: make(map[string]bool),
|
||||||
height: height,
|
height: height,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -430,6 +432,9 @@ func (nav *Nav) save(copy bool) error {
|
|||||||
if err := saveFiles([]string{curr.Path}, copy); err != nil {
|
if err := saveFiles([]string{curr.Path}, copy); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav.saves = make(map[string]bool)
|
||||||
|
nav.saves[curr.Path] = copy
|
||||||
} else {
|
} else {
|
||||||
var fs []string
|
var fs []string
|
||||||
for f := range nav.marks {
|
for f := range nav.marks {
|
||||||
@ -439,6 +444,11 @@ func (nav *Nav) save(copy bool) error {
|
|||||||
if err := saveFiles(fs, copy); err != nil {
|
if err := saveFiles(fs, copy); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav.saves = make(map[string]bool)
|
||||||
|
for f := range nav.marks {
|
||||||
|
nav.saves[f] = copy
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
12
ui.go
12
ui.go
@ -215,7 +215,7 @@ func (win *Win) printl(x, y int, fg, bg termbox.Attribute, s string) {
|
|||||||
win.printf(x, y, fg, bg, "%s%*s", s, win.w-len(s), "")
|
win.printf(x, y, fg, bg, "%s%*s", s, win.w-len(s), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (win *Win) printd(dir *Dir, marks map[string]bool) {
|
func (win *Win) printd(dir *Dir, marks, saves map[string]bool) {
|
||||||
if win.w < 3 {
|
if win.w < 3 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -264,6 +264,12 @@ func (win *Win) printd(dir *Dir, marks map[string]bool) {
|
|||||||
|
|
||||||
if marks[path] {
|
if marks[path] {
|
||||||
win.print(0, i, fg, termbox.ColorMagenta, " ")
|
win.print(0, i, fg, termbox.ColorMagenta, " ")
|
||||||
|
} else if copy, ok := saves[path]; ok {
|
||||||
|
if copy {
|
||||||
|
win.print(0, i, fg, termbox.ColorYellow, " ")
|
||||||
|
} else {
|
||||||
|
win.print(0, i, fg, termbox.ColorRed, " ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if i == dir.pos {
|
if i == dir.pos {
|
||||||
@ -504,7 +510,7 @@ func (ui *UI) draw(nav *Nav) {
|
|||||||
|
|
||||||
doff = len(nav.dirs) - length
|
doff = len(nav.dirs) - length
|
||||||
for i := 0; i < length; i++ {
|
for i := 0; i < length; i++ {
|
||||||
ui.wins[woff+i].printd(nav.dirs[doff+i], nav.marks)
|
ui.wins[woff+i].printd(nav.dirs[doff+i], nav.marks, nav.saves)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer ui.msgwin.print(0, 0, fg, bg, ui.message)
|
defer ui.msgwin.print(0, 0, fg, bg, ui.message)
|
||||||
@ -518,7 +524,7 @@ func (ui *UI) draw(nav *Nav) {
|
|||||||
preview := ui.wins[len(ui.wins)-1]
|
preview := ui.wins[len(ui.wins)-1]
|
||||||
|
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
preview.printd(ui.dirprev, nav.marks)
|
preview.printd(ui.dirprev, nav.marks, nav.saves)
|
||||||
} else if f.Mode().IsRegular() {
|
} else if f.Mode().IsRegular() {
|
||||||
preview.printr(ui.regprev)
|
preview.printr(ui.regprev)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user