Skip to content

Commit

Permalink
Merge branch 'gokcehan:master' into sixel
Browse files Browse the repository at this point in the history
  • Loading branch information
horriblename authored Jul 23, 2022
2 parents 6dfd656 + e031432 commit 96d42a2
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 11 deletions.
6 changes: 4 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ func newApp(ui *ui, nav *nav) *app {
}

func (app *app) quit() {
if err := app.writeHistory(); err != nil {
log.Printf("writing history file: %s", err)
if gOpts.history {
if err := app.writeHistory(); err != nil {
log.Printf("writing history file: %s", err)
}
}
if !gSingleMode {
if err := remote(fmt.Sprintf("drop %d", gClientID)); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ The following options can be used to customize the behavior of lf:
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
Expand Down Expand Up @@ -708,7 +709,7 @@ Preview filtering is disabled and files are displayed as they are when the value
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
Format string of the prompt shown in the top line.
Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter.
Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. '%S' may be used once and will provide a spacer so that the following parts are right aligned on the screen.
Home folder is shown as '~' in the working directory expansion.
Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
Expand Down
10 changes: 6 additions & 4 deletions docstring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ func (e *setExpr) eval(app *app, args []string) {
app.nav.position()
app.ui.sort()
app.ui.loadFile(app.nav, true)
case "history":
gOpts.history = true
case "nohistory":
gOpts.history = false
case "history!":
gOpts.history = !gOpts.history
case "icons":
gOpts.icons = true
case "noicons":
Expand Down Expand Up @@ -1917,6 +1923,7 @@ func (e *callExpr) eval(app *app, args []string) {
update(app)
case "cmd-delete-back":
if len(app.ui.cmdAccLeft) == 0 {
normal(app)
return
}
app.ui.cmdAccLeft = app.ui.cmdAccLeft[:len(app.ui.cmdAccLeft)-1]
Expand Down
3 changes: 2 additions & 1 deletion lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ The following options can be used to customize the behavior of lf:
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
Expand Down Expand Up @@ -860,7 +861,7 @@ Set the path of a previewer file to filter the content of regular files for prev
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
.EE
.PP
Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. '%S' may be used once and will provide a spacer so that the following parts are right aligned on the screen. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
.PP
.EX
ratios []int (default '1:2:3')
Expand Down
9 changes: 6 additions & 3 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -1745,9 +1745,12 @@ func (nav *nav) readTags() error {

scanner := bufio.NewScanner(f)
for scanner.Scan() {
toks := strings.SplitN(scanner.Text(), ":", 2)
if _, ok := nav.tags[toks[0]]; !ok {
nav.tags[toks[0]] = toks[1]
text := scanner.Text()
ind := strings.LastIndex(text, ":")
path := text[0:ind]
mark := text[ind+1:]
if _, ok := nav.tags[path]; !ok {
nav.tags[path] = mark
}
}

Expand Down
2 changes: 2 additions & 0 deletions opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var gOpts struct {
truncatechar string
ratios []int
hiddenfiles []string
history bool
info []string
shellopts []string
keys map[string]expr
Expand Down Expand Up @@ -117,6 +118,7 @@ func init() {
gOpts.truncatechar = "~"
gOpts.ratios = []int{1, 2, 3}
gOpts.hiddenfiles = []string{".*"}
gOpts.history = true
gOpts.info = nil
gOpts.shellopts = nil
gOpts.sortType = sortType{naturalSort, dirfirstSort}
Expand Down
7 changes: 7 additions & 0 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,13 @@ func (ui *ui) drawPromptLine(nav *nav) {
prompt = strings.Replace(prompt, "%F", "", -1)
}

// spacer
avail := ui.promptWin.w - printLength(prompt) + 2
if avail > 0 {
prompt = strings.Replace(prompt, "%S", strings.Repeat(" ", avail), 1)
}
prompt = strings.Replace(prompt, "%S", "", -1)

ui.promptWin.print(ui.screen, 0, 0, st, prompt)
}

Expand Down

0 comments on commit 96d42a2

Please sign in to comment.