Drop another dependency

This commit is contained in:
Kovid Goyal 2022-08-24 19:32:56 +05:30
parent 19ffbc6f3d
commit 10d11bc749
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 6 additions and 14 deletions

2
go.mod
View File

@ -3,7 +3,6 @@ module kitty
go 1.19 go 1.19
require ( require (
github.com/mattn/go-runewidth v0.0.13
github.com/seancfoley/ipaddress-go v1.2.1 github.com/seancfoley/ipaddress-go v1.2.1
github.com/spf13/cobra v1.5.0 github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
@ -13,6 +12,5 @@ require (
require ( require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/seancfoley/bintree v1.1.0 // indirect github.com/seancfoley/bintree v1.1.0 // indirect
) )

4
go.sum
View File

@ -1,10 +1,6 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/seancfoley/bintree v1.1.0 h1:6J0rj9hLNLIcWSsfYdZ4ZHkMHokaK/PHkak8qyBO/mc= github.com/seancfoley/bintree v1.1.0 h1:6J0rj9hLNLIcWSsfYdZ4ZHkMHokaK/PHkak8qyBO/mc=
github.com/seancfoley/bintree v1.1.0/go.mod h1:CtE6qO6/n9H3V2CAGEC0lpaYr6/OijhNaMG/dt7P70c= github.com/seancfoley/bintree v1.1.0/go.mod h1:CtE6qO6/n9H3V2CAGEC0lpaYr6/OijhNaMG/dt7P70c=

View File

@ -10,13 +10,13 @@ import (
"strings" "strings"
"unicode" "unicode"
"github.com/mattn/go-runewidth"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"kitty" "kitty"
"kitty/tools/tty" "kitty/tools/tty"
"kitty/tools/tui"
"kitty/tools/utils" "kitty/tools/utils"
) )
@ -120,7 +120,7 @@ func format_line_with_indent(output io.Writer, text string, indent string, scree
var escapes strings.Builder var escapes strings.Builder
print_word := func(r rune) { print_word := func(r rune) {
w := runewidth.StringWidth(current_word.String()) w := tui.Wcswidth(current_word.String())
if x+w > screen_width { if x+w > screen_width {
fmt.Fprintln(output) fmt.Fprintln(output)
fmt.Fprint(output, indent) fmt.Fprint(output, indent)

View File

@ -4,8 +4,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"strings" "strings"
"github.com/mattn/go-runewidth"
) )
type KilledBySignal struct { type KilledBySignal struct {
@ -25,9 +23,9 @@ func ReadPassword(prompt string, kill_if_signaled bool) (password string, err er
} }
loop.OnText = func(loop *Loop, text string, from_key_event bool, in_bracketed_paste bool) error { loop.OnText = func(loop *Loop, text string, from_key_event bool, in_bracketed_paste bool) error {
old_width := runewidth.StringWidth(password) old_width := Wcswidth(password)
password += text password += text
new_width := runewidth.StringWidth(password) new_width := Wcswidth(password)
if new_width > old_width { if new_width > old_width {
extra := strings.Repeat("*", new_width-old_width) extra := strings.Repeat("*", new_width-old_width)
loop.QueueWriteString(extra) loop.QueueWriteString(extra)
@ -40,9 +38,9 @@ func ReadPassword(prompt string, kill_if_signaled bool) (password string, err er
if event.MatchesPressOrRepeat("backscape") || event.MatchesPressOrRepeat("delete") { if event.MatchesPressOrRepeat("backscape") || event.MatchesPressOrRepeat("delete") {
event.Handled = true event.Handled = true
if len(password) > 0 { if len(password) > 0 {
old_width := runewidth.StringWidth(password) old_width := Wcswidth(password)
password = password[:len(password)-1] password = password[:len(password)-1]
new_width := runewidth.StringWidth(password) new_width := Wcswidth(password)
delta := new_width - old_width delta := new_width - old_width
if delta > 0 { if delta > 0 {
if delta > len(shadow) { if delta > len(shadow) {