Added new Promptfmt Option to remove trailing separator (#545)
* Added new Promptfmt Option to remove trailing seperator * Small fix * small fix with multiple format options also renamed the format options
This commit is contained in:
parent
9f8bbe26e2
commit
07d42c9a80
12
ui.go
12
ui.go
@ -663,10 +663,6 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
|
|
||||||
sep := string(filepath.Separator)
|
sep := string(filepath.Separator)
|
||||||
|
|
||||||
if !strings.HasSuffix(pwd, sep) {
|
|
||||||
pwd += sep
|
|
||||||
}
|
|
||||||
|
|
||||||
var fname string
|
var fname string
|
||||||
curr, err := nav.currFile()
|
curr, err := nav.currFile()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -679,7 +675,7 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
prompt = strings.Replace(prompt, "%h", gHostname, -1)
|
prompt = strings.Replace(prompt, "%h", gHostname, -1)
|
||||||
prompt = strings.Replace(prompt, "%f", fname, -1)
|
prompt = strings.Replace(prompt, "%f", fname, -1)
|
||||||
|
|
||||||
if printLength(strings.Replace(prompt, "%w", pwd, -1)) > ui.promptWin.w {
|
if printLength(strings.Replace(strings.Replace(prompt, "%w", pwd, -1), "%d", pwd, -1)) > ui.promptWin.w {
|
||||||
names := strings.Split(pwd, sep)
|
names := strings.Split(pwd, sep)
|
||||||
for i := range names {
|
for i := range names {
|
||||||
if names[i] == "" {
|
if names[i] == "" {
|
||||||
@ -687,7 +683,7 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
}
|
}
|
||||||
r, _ := utf8.DecodeRuneInString(names[i])
|
r, _ := utf8.DecodeRuneInString(names[i])
|
||||||
names[i] = string(r)
|
names[i] = string(r)
|
||||||
if printLength(strings.Replace(prompt, "%w", strings.Join(names, sep), -1)) <= ui.promptWin.w {
|
if printLength(strings.Replace(strings.Replace(prompt, "%w", strings.Join(names, sep), -1), "%d", strings.Join(names, sep), -1)) <= ui.promptWin.w {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -695,6 +691,10 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prompt = strings.Replace(prompt, "%w", pwd, -1)
|
prompt = strings.Replace(prompt, "%w", pwd, -1)
|
||||||
|
if !strings.HasSuffix(pwd, sep) {
|
||||||
|
pwd += sep
|
||||||
|
}
|
||||||
|
prompt = strings.Replace(prompt, "%d", pwd, -1)
|
||||||
|
|
||||||
ui.promptWin.print(ui.screen, 0, 0, st, prompt)
|
ui.promptWin.print(ui.screen, 0, 0, st, prompt)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user