Drop another dependency

This commit is contained in:
Kovid Goyal
2022-08-24 19:32:56 +05:30
parent 19ffbc6f3d
commit 10d11bc749
4 changed files with 6 additions and 14 deletions

View File

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

View File

@@ -4,8 +4,6 @@ import (
"errors"
"fmt"
"strings"
"github.com/mattn/go-runewidth"
)
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 {
old_width := runewidth.StringWidth(password)
old_width := Wcswidth(password)
password += text
new_width := runewidth.StringWidth(password)
new_width := Wcswidth(password)
if new_width > old_width {
extra := strings.Repeat("*", new_width-old_width)
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") {
event.Handled = true
if len(password) > 0 {
old_width := runewidth.StringWidth(password)
old_width := Wcswidth(password)
password = password[:len(password)-1]
new_width := runewidth.StringWidth(password)
new_width := Wcswidth(password)
delta := new_width - old_width
if delta > 0 {
if delta > len(shadow) {