Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gokcehan/lf
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: r33
Choose a base ref
...
head repository: gokcehan/lf
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Nov 1, 2024

  1. Bump github.com/fsnotify/fsnotify from 1.7.0 to 1.8.0 (#1821)

    Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.7.0 to 1.8.0.
    - [Release notes](https://github.com/fsnotify/fsnotify/releases)
    - [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md)
    - [Commits](fsnotify/fsnotify@v1.7.0...v1.8.0)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/fsnotify/fsnotify
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 1, 2024
    Copy the full SHA
    4079aea View commit details
  2. Add option to sort base on certain locale. (#1818)

    * Add support for localized sorting
    
    * Switch go-locale module; Use collate option for natural sorting
    
    * Doc and error message improvement
    
    * Simplify predicated checking of localized sorting.
    
    * Improve error handling of `set locale` command
    SirZenith authored Nov 1, 2024
    Copy the full SHA
    3f63bc9 View commit details
  3. Cleanup doc (#1823)

    joelim-work authored Nov 1, 2024
    Copy the full SHA
    dda8e88 View commit details

Commits on Nov 2, 2024

  1. Copy the full SHA
    1b1628c View commit details

Commits on Nov 3, 2024

  1. Hardcode diacritics instead of generating during runtime (#1827)

    * Hardcode diacritics instead of generating during runtime
    
    * Remove redundant test
    Limero authored Nov 3, 2024
    Copy the full SHA
    4408f37 View commit details
  2. Small optimizations for os.go (#1829)

    * Small optimizations for os.go
    
    * Cleanup isHidden check further
    Limero authored Nov 3, 2024
    Copy the full SHA
    f5a0e65 View commit details
  3. Copy the full SHA
    0f48f36 View commit details
  4. Small optimizations for opts.go (#1831)

    * Small optimizations for opts.go
    
    * Add back all opts
    Limero authored Nov 3, 2024
    Copy the full SHA
    fa2fa19 View commit details

Commits on Nov 4, 2024

  1. Bump Go to 1.23 (#1832)

    Limero authored Nov 4, 2024
    Copy the full SHA
    b5b7b84 View commit details
  2. Bump golang.org/x/text from 0.18.0 to 0.19.0 (#1833)

    Bumps [golang.org/x/text](https://github.com/golang/text) from 0.18.0 to 0.19.0.
    - [Release notes](https://github.com/golang/text/releases)
    - [Commits](golang/text@v0.18.0...v0.19.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/text
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 4, 2024
    Copy the full SHA
    d9a6ca5 View commit details
  3. Copy the full SHA
    0b51987 View commit details

Commits on Nov 6, 2024

  1. Copy the full SHA
    670343a View commit details
  2. Copy the full SHA
    ce3dbea View commit details

Commits on Nov 8, 2024

  1. Bump golang.org/x/term from 0.25.0 to 0.26.0 (#1841)

    Bumps [golang.org/x/term](https://github.com/golang/term) from 0.25.0 to 0.26.0.
    - [Commits](golang/term@v0.25.0...v0.26.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/term
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 8, 2024
    Copy the full SHA
    dec026e View commit details
  2. Bump golang.org/x/text from 0.19.0 to 0.20.0 (#1842)

    Bumps [golang.org/x/text](https://github.com/golang/text) from 0.19.0 to 0.20.0.
    - [Release notes](https://github.com/golang/text/releases)
    - [Commits](golang/text@v0.19.0...v0.20.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/text
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 8, 2024
    Copy the full SHA
    0b5749f View commit details

Commits on Nov 10, 2024

  1. Copy the full SHA
    4fefcf7 View commit details

Commits on Nov 13, 2024

  1. Copy the full SHA
    23bef4d View commit details

Commits on Nov 14, 2024

  1. Copy the full SHA
    f0dddcc View commit details

Commits on Nov 17, 2024

  1. Copy the full SHA
    68a29c9 View commit details

Commits on Dec 5, 2024

  1. Bump golang.org/x/text from 0.20.0 to 0.21.0 (#1870)

    Bumps [golang.org/x/text](https://github.com/golang/text) from 0.20.0 to 0.21.0.
    - [Release notes](https://github.com/golang/text/releases)
    - [Commits](golang/text@v0.20.0...v0.21.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/text
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 5, 2024
    Copy the full SHA
    085717b View commit details
  2. Bump golang.org/x/term from 0.26.0 to 0.27.0 (#1868)

    Bumps [golang.org/x/term](https://github.com/golang/term) from 0.26.0 to 0.27.0.
    - [Commits](golang/term@v0.26.0...v0.27.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/term
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 5, 2024
    Copy the full SHA
    8bfa3a6 View commit details

Commits on Jan 15, 2025

  1. Various fixes for updating dircounts with watch enabled (#1881)

    * Fix file size bug when copying files
    
    * Don't remove existing watches
    
    * Bump fsnotify
    
    * Ignore watching `/dev`
    joelim-work authored Jan 15, 2025
    Copy the full SHA
    2095efa View commit details
  2. Bump golang.org/x/term from 0.27.0 to 0.28.0 (#1884)

    Bumps [golang.org/x/term](https://github.com/golang/term) from 0.27.0 to 0.28.0.
    - [Commits](golang/term@v0.27.0...v0.28.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/term
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jan 15, 2025
    Copy the full SHA
    df0b62a View commit details
  3. Bump github.com/gdamore/tcell/v2 from 2.7.4 to 2.8.1 (#1888)

    Bumps [github.com/gdamore/tcell/v2](https://github.com/gdamore/tcell) from 2.7.4 to 2.8.1.
    - [Release notes](https://github.com/gdamore/tcell/releases)
    - [Changelog](https://github.com/gdamore/tcell/blob/main/CHANGESv2.md)
    - [Commits](gdamore/tcell@v2.7.4...v2.8.1)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/gdamore/tcell/v2
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jan 15, 2025
    Copy the full SHA
    b34ca15 View commit details
  4. Copy the full SHA
    2375b65 View commit details
  5. Copy the full SHA
    2745c1a View commit details

Commits on Jan 29, 2025

  1. Add workaround for equivalent paths for watch option (#1895)

    * Add workaround for equivalent paths for watch option
    
    * Add comment
    
    * Simplify path watching
    joelim-work authored Jan 29, 2025
    Copy the full SHA
    7595e05 View commit details

Commits on Feb 2, 2025

  1. Copy the full SHA
    4f0a5d6 View commit details

Commits on Feb 9, 2025

  1. Copy the full SHA
    c25647d View commit details
  2. Bump golang.org/x/term from 0.28.0 to 0.29.0 (#1905)

    Bumps [golang.org/x/term](https://github.com/golang/term) from 0.28.0 to 0.29.0.
    - [Commits](golang/term@v0.28.0...v0.29.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/term
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 9, 2025
    Copy the full SHA
    ec42237 View commit details
  3. Bump golang.org/x/text from 0.21.0 to 0.22.0 (#1906)

    Bumps [golang.org/x/text](https://github.com/golang/text) from 0.21.0 to 0.22.0.
    - [Release notes](https://github.com/golang/text/releases)
    - [Commits](golang/text@v0.21.0...v0.22.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/text
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 9, 2025
    Copy the full SHA
    5b1ec5b View commit details
  4. Bump github.com/Xuanwo/go-locale from 1.1.2 to 1.1.3 (#1902)

    Bumps [github.com/Xuanwo/go-locale](https://github.com/Xuanwo/go-locale) from 1.1.2 to 1.1.3.
    - [Release notes](https://github.com/Xuanwo/go-locale/releases)
    - [Changelog](https://github.com/Xuanwo/go-locale/blob/master/CHANGELOG.md)
    - [Commits](Xuanwo/go-locale@v1.1.2...v1.1.3)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/Xuanwo/go-locale
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 9, 2025
    Copy the full SHA
    3b56a9f View commit details
  5. Copy the full SHA
    b3c652c View commit details

Commits on Feb 10, 2025

  1. Copy the full SHA
    7797ad6 View commit details
  2. Copy the full SHA
    74b2954 View commit details

Commits on Feb 14, 2025

  1. Copy the full SHA
    c42942d View commit details

Commits on Feb 18, 2025

  1. verify the Trash directory exists before moving files there (#1918)

    * verify the Trash directory exists before moving files there
    
    * Update etc/lfrc.example
    
    Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com>
    valoq and joelim-work authored Feb 18, 2025
    Copy the full SHA
    b087bf7 View commit details
  2. Add dircounts to setlocal options (#1920)

    * Remove plural from setlocal variable names
    
    * Add `dircounts` for `setlocal`
    
    * Update documentation
    
    * Fix failing test
    joelim-work authored Feb 18, 2025
    Copy the full SHA
    f981374 View commit details

Commits on Feb 23, 2025

  1. Copy the full SHA
    2a32925 View commit details
  2. cleanup (#1922)

    joelim-work authored Feb 23, 2025
    Copy the full SHA
    938e02e View commit details
  3. Copy the full SHA
    0e66d02 View commit details
Showing with 849 additions and 554 deletions.
  1. +4 −4 .github/workflows/go.yml
  2. +1 −1 .github/workflows/release.yml
  3. +1 −1 README.md
  4. +22 −17 app.go
  5. +2 −1 client.go
  6. +83 −49 colors.go
  7. +11 −0 colors_test.go
  8. +7 −6 complete.go
  9. +4 −4 complete_test.go
  10. +37 −43 diacritics.go
  11. +6 −7 diacritics_test.go
  12. +15 −3 doc.md
  13. +21 −6 doc.txt
  14. +1 −1 etc/lfrc.example
  15. +65 −34 eval.go
  16. +9 −8 go.mod
  17. +46 −13 go.sum
  18. +1 −3 icons.go
  19. +21 −6 lf.1
  20. +2 −2 main.go
  21. +53 −22 misc.go
  22. +51 −0 misc_test.go
  23. +61 −33 nav.go
  24. +163 −139 opts.go
  25. +22 −35 os.go
  26. +9 −17 os_windows.go
  27. +2 −5 parse.go
  28. +1 −1 server.go
  29. +1 −1 sixel.go
  30. +79 −74 ui.go
  31. +48 −18 watch.go
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.18"
go-version: "1.23"

- name: Build
run: go build -v ./...
@@ -31,7 +31,7 @@ jobs:

- uses: dominikh/staticcheck-action@v1.3.1
with:
version: "2022.1.3"
version: "2024.1.1"
install-go: false

cross-compile:
@@ -44,7 +44,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.18"
go-version: "1.23"

- name: Cross-compile on all supported platforms
run: gen/xbuild.sh
@@ -59,7 +59,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.18"
go-version: "1.23"

- name: Test `go fmt` creates no diffs
run: go fmt && git diff --exit-code
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.18"
go-version: "1.23"

- name: Build
run: gen/xbuild.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
[![Go Build](https://github.com/gokcehan/lf/actions/workflows/go.yml/badge.svg)](https://github.com/gokcehan/lf/actions/workflows/go.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/gokcehan/lf)](https://goreportcard.com/report/github.com/gokcehan/lf)

`lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from ranger file manager.
`lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from [`ranger`](https://github.com/ranger/ranger) file manager.
See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts.

![multicol-screenshot](http://i.imgur.com/DaTUenu.png)
39 changes: 22 additions & 17 deletions app.go
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ type app struct {
menuCompInd int
selectionOut []string
watch *watch
quitting bool
}

func newApp(ui *ui, nav *nav) *app {
@@ -66,6 +67,14 @@ func newApp(ui *ui, nav *nav) *app {
}

func (app *app) quit() {
// Using synchronous shell commands for `on-quit` can cause this to be
// called again, so a guard variable is introduced here to prevent an
// infinite loop.
if app.quitting {
return
}
app.quitting = true

onQuit(app)

if gOpts.history {
@@ -418,7 +427,7 @@ func (app *app) loop() {
}
}

app.setWatchPaths()
app.watchDir(d)

app.ui.draw(app.nav)
case r := <-app.nav.regChan:
@@ -433,12 +442,7 @@ func (app *app) loop() {

app.ui.draw(app.nav)
case f := <-app.nav.fileChan:
dirs := app.nav.dirs
if app.ui.dirPrev != nil {
dirs = append(dirs, app.ui.dirPrev)
}

for _, dir := range dirs {
for _, dir := range app.nav.dirCache {
if dir.path != filepath.Dir(f.path) {
continue
}
@@ -463,6 +467,11 @@ func (app *app) loop() {
case path := <-app.nav.delChan:
delete(app.nav.dirCache, path)
delete(app.nav.regCache, path)

delete(app.nav.selections, path)
if len(app.nav.selections) == 0 {
app.nav.selectionInd = 0
}
case ev := <-app.ui.evChan:
e := app.ui.readEvent(ev, app.nav)
if e == nil {
@@ -629,21 +638,17 @@ func (app *app) runShell(s string, args []string, prefix string) {
}
}

func (app *app) setWatchPaths() {
if !gOpts.watch || len(app.nav.dirs) == 0 {
func (app *app) watchDir(dir *dir) {
if !gOpts.watch {
return
}

paths := make(map[string]bool)
for _, dir := range app.nav.dirs {
paths[dir.path] = true
}
app.watch.add(dir.path)

for _, file := range app.nav.currDir().allFiles {
// ensure dircounts are updated for child directories
for _, file := range dir.allFiles {
if file.IsDir() {
paths[file.path] = true
app.watch.add(file.path)
}
}

app.watch.set(paths)
}
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ func readExpr() <-chan expr {
ch := make(chan expr)

go func() {
duration := 1 * time.Second
duration := 100 * time.Millisecond

c, err := net.Dial(gSocketProt, gSocketPath)
for err != nil {
@@ -130,6 +130,7 @@ func readExpr() <-chan expr {
fmt.Fprintf(c, "conn %d\n", gClientID)

ch <- &callExpr{"sync", nil, 1}
ch <- &callExpr{"on-init", nil, 1}

s := bufio.NewScanner(c)
for s.Scan() {
132 changes: 83 additions & 49 deletions colors.go
Original file line number Diff line number Diff line change
@@ -98,82 +98,116 @@ func parseEscapeSequence(s string) tcell.Style {
func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
toks := strings.Split(s, ";")

var nums []int
for _, tok := range toks {
if tok == "" {
nums = append(nums, 0)
continue
}
n, err := strconv.Atoi(tok)
if err != nil {
log.Printf("converting escape code: %s", err)
continue
}
nums = append(nums, n)
}

// ECMA-48 details the standard
// TODO: should we support turning off attributes?
// Probably because this is used for previewers too
for i := 0; i < len(nums); i++ {
n := nums[i]
switch {
case n == 0:
tokslen := len(toks)
for i := 0; i < tokslen; i++ {
switch strings.TrimLeft(toks[i], "0") {
case "":
st = tcell.StyleDefault
case n == 1:
case "1":
st = st.Bold(true)
case n == 2:
case "2":
st = st.Dim(true)
case n == 3:
case "3":
st = st.Italic(true)
case n == 4:
case "4:0":
st = st.Underline(false)
case "4", "4:1":
st = st.Underline(true)
case n == 5 || n == 6:
case "4:2":
st = st.Underline(tcell.UnderlineStyleDouble)
case "4:3":
st = st.Underline(tcell.UnderlineStyleCurly)
case "4:4":
st = st.Underline(tcell.UnderlineStyleDotted)
case "4:5":
st = st.Underline(tcell.UnderlineStyleDashed)
case "5", "6":
st = st.Blink(true)
case n == 7:
case "7":
st = st.Reverse(true)
case n == 8:
case "8":
// TODO: tcell PR for proper conceal
_, bg, _ := st.Decompose()
st = st.Foreground(bg)
case n == 9:
case "9":
st = st.StrikeThrough(true)
case n >= 30 && n <= 37:
case "30", "31", "32", "33", "34", "35", "36", "37":
n, _ := strconv.Atoi(toks[i])
st = st.Foreground(tcell.PaletteColor(n - 30))
case n >= 90 && n <= 97:
case "90", "91", "92", "93", "94", "95", "96", "97":
n, _ := strconv.Atoi(toks[i])
st = st.Foreground(tcell.PaletteColor(n - 82))
case n == 38:
if i+3 <= len(nums) && nums[i+1] == 5 {
st = st.Foreground(tcell.PaletteColor(nums[i+2]))
case "38":
if toks[i+1] == "5" && i+2 < tokslen {
n, err := strconv.Atoi(toks[i+2])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+2])
continue
}
st = st.Foreground(tcell.PaletteColor(n))
i += 2
} else if i+5 <= len(nums) && nums[i+1] == 2 {
st = st.Foreground(tcell.NewRGBColor(
int32(nums[i+2]),
int32(nums[i+3]),
int32(nums[i+4])))
} else if toks[i+1] == "2" && i+4 < tokslen {
r, err := strconv.Atoi(toks[i+2])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+2])
continue
}
g, err := strconv.Atoi(toks[i+3])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+3])
continue
}
b, err := strconv.Atoi(toks[i+4])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+4])
continue
}
st = st.Foreground(tcell.NewRGBColor(int32(r), int32(g), int32(b)))
i += 4
} else {
log.Printf("unknown ansi code or incorrect form: %d", n)
log.Printf("unknown ansi code or incorrect form: %s", toks[i])
}
case n >= 40 && n <= 47:
case "40", "41", "42", "43", "44", "45", "46", "47":
n, _ := strconv.Atoi(toks[i])
st = st.Background(tcell.PaletteColor(n - 40))
case n >= 100 && n <= 107:
case "100", "101", "102", "103", "104", "105", "106", "107":
n, _ := strconv.Atoi(toks[i])
st = st.Background(tcell.PaletteColor(n - 92))
case n == 48:
if i+3 <= len(nums) && nums[i+1] == 5 {
st = st.Background(tcell.PaletteColor(nums[i+2]))
case "48":
if toks[i+1] == "5" && i+2 < tokslen {
n, err := strconv.Atoi(toks[i+2])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+2])
continue
}
st = st.Background(tcell.PaletteColor(n))
i += 2
} else if i+5 <= len(nums) && nums[i+1] == 2 {
st = st.Background(tcell.NewRGBColor(
int32(nums[i+2]),
int32(nums[i+3]),
int32(nums[i+4])))
} else if toks[i+1] == "2" && i+4 < tokslen {
r, err := strconv.Atoi(toks[i+2])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+2])
continue
}
g, err := strconv.Atoi(toks[i+3])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+3])
continue
}
b, err := strconv.Atoi(toks[i+4])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+4])
continue
}
st = st.Background(tcell.NewRGBColor(int32(r), int32(g), int32(b)))
i += 4
} else {
log.Printf("unknown ansi code or incorrect form: %d", n)
log.Printf("unknown ansi code or incorrect form: %s", toks[i])
}
default:
log.Printf("unknown ansi code: %d", n)
log.Printf("unknown ansi code: %s", toks[i])
}
}

11 changes: 11 additions & 0 deletions colors_test.go
Original file line number Diff line number Diff line change
@@ -35,6 +35,14 @@ func TestApplyAnsiCodes(t *testing.T) {
{"4", none.Bold(true), none.Bold(true).Underline(true)},
{"4", none.Foreground(tcell.ColorMaroon).Bold(true), none.Foreground(tcell.ColorMaroon).Bold(true).Underline(true)},

{"4:0", none, none},
{"4:0", none.Underline(true), none},
{"4:1", none, none.Underline(true)},
{"4:2", none, none.Underline(tcell.UnderlineStyleDouble)},
{"4:3", none, none.Underline(tcell.UnderlineStyleCurly)},
{"4:4", none, none.Underline(tcell.UnderlineStyleDotted)},
{"4:5", none, none.Underline(tcell.UnderlineStyleDashed)},

{"31", none, none.Foreground(tcell.ColorMaroon)},
{"31", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon)},
{"31", none.Foreground(tcell.ColorGreen).Bold(true), none.Foreground(tcell.ColorMaroon).Bold(true)},
@@ -45,6 +53,9 @@ func TestApplyAnsiCodes(t *testing.T) {
{"1;31", none, none.Foreground(tcell.ColorMaroon).Bold(true)},
{"1;31", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon).Bold(true)},

{"01;31", none, none.Foreground(tcell.ColorMaroon).Bold(true)},
{"01;31", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon).Bold(true)},

{"38;5;0", none, none.Foreground(tcell.ColorBlack)},
{"38;5;1", none, none.Foreground(tcell.ColorMaroon)},
{"38;5;8", none, none.Foreground(tcell.ColorGray)},
13 changes: 7 additions & 6 deletions complete.go
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ var (

func getOptWords(opts any) (optWords []string) {
t := reflect.TypeOf(opts)
for i := 0; i < t.NumField(); i++ {
for i := range t.NumField() {
field := t.Field(i)
switch field.Type.Kind() {
case reflect.Map:
@@ -134,9 +134,9 @@ func getOptWords(opts any) (optWords []string) {

func getLocalOptWords(localOpts any) (localOptWords []string) {
t := reflect.TypeOf(localOpts)
for i := 0; i < t.NumField(); i++ {
for i := range t.NumField() {
field := t.Field(i)
name := strings.TrimSuffix(field.Name, "s")
name := field.Name
if field.Type.Kind() != reflect.Map {
continue
}
@@ -215,9 +215,9 @@ func matchExec(s string) (matches []string, longest []rune) {
}
}

sort.Strings(words)

if len(words) > 0 {
sort.Strings(words)

uniq := words[:1]
for i := 1; i < len(words); i++ {
if words[i] != words[i-1] {
@@ -294,7 +294,8 @@ func matchFile(s string) (matches []string, longest []rune) {
}

func matchCmd(s string) (matches []string, longest []rune) {
words := gCmdWords
words := make([]string, 0, len(gCmdWords)+len(gOpts.cmds))
words = append(words, gCmdWords...)
for c := range gOpts.cmds {
words = append(words, c)
}
Loading