From 2a49dd9bf5a1a5c16ad41f84ff76d46ccbeb45fc Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 17 Oct 2026 15:11:02 +0100 Subject: [PATCH] ncdu: update to tcell v3 which fixes duplicated keys on Windows The tcell v2 pin at v2.9.0 is removed as tcell v3 contains the fix for duplicated key events on Windows (tcell issue 1124). Note that tcell v3 uses the Windows VT console modes so ncdu requires Windows 10 build 1703 or later. See: #9539 --- RELEASE.md | 6 +----- cmd/ncdu/ncdu.go | 18 +++++++++--------- go.mod | 3 ++- go.sum | 6 ++++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 3bcfcc5d3..a249850dc 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -62,10 +62,6 @@ This file describes how to make the various kinds of releases Early in the next release cycle update the dependencies. - Active Pins - - `github.com/gdamore/tcell/v2` v2.9.0 - awaiting fix for [tcell/issues/1124](https://github.com/gdamore/tcell/issues/1124) - - See: [#9539](https://github.com/rclone/rclone/issues/9539) - - Fixed on the tcell `v2` branch (tcell PR #1154) but not in a release - yet (v2.13.10 doesn't have it) - `github.com/coreos/go-systemd/v22` v22.6.0 - v22.7.0 fails to compile on netbsd - `github.com/hanwen/go-fuse/v2` v2.11.0 - v2.12.0 fails to compile on 32 bit linux, awaiting fix for @@ -73,7 +69,7 @@ Early in the next release cycle update the dependencies. - Review Active Pins in go.mod and remove if possible - `make updatedirect` - The update ignores the pins so put them back, eg - `go get github.com/gdamore/tcell/v2@v2.9.0` then `go mod tidy` + `go get github.com/coreos/go-systemd/v22@v22.6.0` then `go mod tidy` - `make GOTAGS=cmount` - `make compiletest` - Fix anything which doesn't compile at this point and commit changes here diff --git a/cmd/ncdu/ncdu.go b/cmd/ncdu/ncdu.go index 3a84a3ac7..67603d184 100644 --- a/cmd/ncdu/ncdu.go +++ b/cmd/ncdu/ncdu.go @@ -12,9 +12,11 @@ import ( "reflect" "sort" "strings" + "unicode/utf8" "github.com/atotto/clipboard" - "github.com/gdamore/tcell/v2" + "github.com/gdamore/tcell/v3" + "github.com/gdamore/tcell/v3/color" runewidth "github.com/mattn/go-runewidth" "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/cmd/ncdu/scan" @@ -283,7 +285,7 @@ func (u *UI) Box() { ymax := y + len(u.boxText) // draw text - style := tcell.StyleDefault.Background(tcell.ColorRed).Reverse(true) + style := tcell.StyleDefault.Background(color.Red).Reverse(true) for i, s := range u.boxText { u.Line(x, y+i, xmax, style, ' ', s) style = tcell.StyleDefault.Reverse(true) @@ -408,13 +410,13 @@ func (u *UI) Draw() { _, isSelected := u.selectedEntries[entry.String()] style := tcell.StyleDefault if attrs.EntriesHaveErrors { - style = style.Foreground(tcell.ColorYellow) + style = style.Foreground(color.Yellow) } if err != nil { - style = style.Foreground(tcell.ColorRed) + style = style.Foreground(color.Red) } if isSelected { - style = style.Foreground(tcell.ColorLightYellow) + style = style.Foreground(color.LightYellow) } if n == dirPos.entry { style = style.Reverse(true) @@ -961,9 +963,7 @@ func (u *UI) Run() error { // scan the disk in the background rootChan, errChan, updated := u.scan() - // Poll the events into a channel - events := make(chan tcell.Event) - go u.s.ChannelEvents(events, nil) + events := u.s.EventQ() // Main loop, waiting for events and channels outer: @@ -989,7 +989,7 @@ outer: case *tcell.EventKey: var c rune if k := ev.Key(); k == tcell.KeyRune { - c = ev.Rune() + c, _ = utf8.DecodeRuneInString(ev.Str()) } else { c = key(k) } diff --git a/go.mod b/go.mod index 8227fa62b..707a8c5dd 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/dop251/scsu v0.0.0-20220106150536-84ac88021d00 github.com/dropbox/dropbox-sdk-go-unofficial/v6 v6.6.2 github.com/gabriel-vasile/mimetype v1.4.15 - github.com/gdamore/tcell/v2 v2.9.0 + github.com/gdamore/tcell/v3 v3.6.0 github.com/go-chi/chi/v5 v5.5.0 github.com/go-darwin/apfs v0.0.0-20211011131704-f84b94dbf348 github.com/go-git/go-billy/v5 v5.9.2 @@ -151,6 +151,7 @@ require ( github.com/calebcase/tmpfile v1.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chilts/sid v0.0.0-20190607042430-660e94789ec9 // indirect + github.com/clipperhouse/displaywidth v0.11.0 // indirect github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/cloudflare/circl v1.6.4 // indirect github.com/cloudsoda/sddl v0.0.0-20250224235906-926454e91efc // indirect diff --git a/go.sum b/go.sum index e7975ee09..23aa97889 100644 --- a/go.sum +++ b/go.sum @@ -153,6 +153,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chilts/sid v0.0.0-20190607042430-660e94789ec9 h1:z0uK8UQqjMVYzvk4tiiu3obv2B44+XBsvgEJREQfnO8= github.com/chilts/sid v0.0.0-20190607042430-660e94789ec9/go.mod h1:Jl2neWsQaDanWORdqZ4emBl50J4/aRBBS4FyyG9/PFo= +github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8= +github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0= github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= @@ -224,8 +226,8 @@ github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ= github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw= github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo= -github.com/gdamore/tcell/v2 v2.9.0 h1:N6t+eqK7/xwtRPwxzs1PXeRWnm0H9l02CrgJ7DLn1ys= -github.com/gdamore/tcell/v2 v2.9.0/go.mod h1:8/ZoqM9rxzYphT9tH/9LnunhV9oPBqwS8WHGYm5nrmo= +github.com/gdamore/tcell/v3 v3.6.0 h1:jW20qS6Tm38KVDqLHq9KWSvyjNl00FbhbD8rIAnHBws= +github.com/gdamore/tcell/v3 v3.6.0/go.mod h1:CBZxkl2T+XxEyuBfOh4zaahqm27dngvhfBfCCZxJsgc= github.com/geoffgarside/ber v1.2.0 h1:/loowoRcs/MWLYmGX9QtIAbA+V/FrnVLsMMPhwiRm64= github.com/geoffgarside/ber v1.2.0/go.mod h1:jVPKeCbj6MvQZhwLYsGwaGI52oUorHoHKNecGT85ZCc= github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=