parent
9fb16f78e0
commit
ae779ae25d
46
ui.go
46
ui.go
@ -383,7 +383,7 @@ func (win *win) printDir(dir *dir, marks map[string]int, saves map[string]bool)
|
|||||||
|
|
||||||
type ui struct {
|
type ui struct {
|
||||||
wins []*win
|
wins []*win
|
||||||
pwdWin *win
|
promptWin *win
|
||||||
msgWin *win
|
msgWin *win
|
||||||
menuWin *win
|
menuWin *win
|
||||||
msg string
|
msg string
|
||||||
@ -449,7 +449,7 @@ func newUI() *ui {
|
|||||||
|
|
||||||
return &ui{
|
return &ui{
|
||||||
wins: getWins(),
|
wins: getWins(),
|
||||||
pwdWin: newWin(wtot, 1, 0, 0),
|
promptWin: newWin(wtot, 1, 0, 0),
|
||||||
msgWin: newWin(wtot, 1, 0, htot-1),
|
msgWin: newWin(wtot, 1, 0, htot-1),
|
||||||
menuWin: newWin(wtot, 1, 0, htot-2),
|
menuWin: newWin(wtot, 1, 0, htot-2),
|
||||||
keyChan: make(chan string, 1000),
|
keyChan: make(chan string, 1000),
|
||||||
@ -512,6 +512,39 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
ui.msg = fmt.Sprintf("%v %4s %v", curr.Mode(), humanize(curr.Size()), curr.ModTime().Format(gOpts.timefmt))
|
ui.msg = fmt.Sprintf("%v %4s %v", curr.Mode(), humanize(curr.Size()), curr.ModTime().Format(gOpts.timefmt))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ui *ui) drawPromptLine(nav *nav) {
|
||||||
|
fg, bg := termbox.ColorDefault, termbox.ColorDefault
|
||||||
|
|
||||||
|
dir := nav.currDir()
|
||||||
|
|
||||||
|
pwd := strings.Replace(dir.path, gUser.HomeDir, "~", -1)
|
||||||
|
pwd = filepath.Clean(pwd)
|
||||||
|
|
||||||
|
var base string
|
||||||
|
curr, err := nav.currFile()
|
||||||
|
if err == nil {
|
||||||
|
base = filepath.Base(curr.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(gUser.Username)+len(gHostname)+len(pwd)+len(base)+3 > ui.promptWin.w {
|
||||||
|
sep := string(filepath.Separator)
|
||||||
|
names := strings.Split(pwd, sep)
|
||||||
|
for i, _ := range names {
|
||||||
|
r, _ := utf8.DecodeRuneInString(names[i])
|
||||||
|
names[i] = string(r)
|
||||||
|
if len(gUser.Username)+len(gHostname)+len(strings.Join(names, sep))+len(base)+3 <= ui.promptWin.w {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pwd = strings.Join(names, sep)
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.promptWin.printf(0, 0, termbox.AttrBold|termbox.ColorGreen, bg, "%s@%s", gUser.Username, gHostname)
|
||||||
|
ui.promptWin.printf(len(gUser.Username)+len(gHostname)+1, 0, fg, bg, ":")
|
||||||
|
ui.promptWin.printf(len(gUser.Username)+len(gHostname)+2, 0, termbox.AttrBold|termbox.ColorBlue, bg, "%s/", pwd)
|
||||||
|
ui.promptWin.printf(len(gUser.Username)+len(gHostname)+len(pwd)+3, 0, termbox.AttrBold|fg, bg, "%s", base)
|
||||||
|
}
|
||||||
|
|
||||||
func (ui *ui) drawStatLine(nav *nav) {
|
func (ui *ui) drawStatLine(nav *nav) {
|
||||||
fg, bg := termbox.ColorDefault, termbox.ColorDefault
|
fg, bg := termbox.ColorDefault, termbox.ColorDefault
|
||||||
|
|
||||||
@ -532,14 +565,7 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
|
|
||||||
termbox.Clear(fg, bg)
|
termbox.Clear(fg, bg)
|
||||||
|
|
||||||
dir := nav.currDir()
|
ui.drawPromptLine(nav)
|
||||||
|
|
||||||
path := strings.Replace(dir.path, gUser.HomeDir, "~", -1)
|
|
||||||
path = filepath.Clean(path)
|
|
||||||
|
|
||||||
ui.pwdWin.printf(0, 0, termbox.AttrBold|termbox.ColorGreen, bg, "%s@%s", gUser.Username, gHostname)
|
|
||||||
ui.pwdWin.printf(len(gUser.Username)+len(gHostname)+1, 0, fg, bg, ":")
|
|
||||||
ui.pwdWin.printf(len(gUser.Username)+len(gHostname)+2, 0, termbox.AttrBold|termbox.ColorBlue, bg, "%s", path)
|
|
||||||
|
|
||||||
length := min(len(ui.wins), len(nav.dirs))
|
length := min(len(ui.wins), len(nav.dirs))
|
||||||
woff := len(ui.wins) - length
|
woff := len(ui.wins) - length
|
||||||
|
Loading…
Reference in New Issue
Block a user