More misc fixes for TUI

This commit is contained in:
Kovid Goyal
2022-08-24 22:13:21 +05:30
parent 5703a3370e
commit 235eb868b2
3 changed files with 9 additions and 6 deletions

View File

@@ -256,7 +256,7 @@ func get_password(password string, password_file string, password_env string, us
if ans == "" && password_file != "" {
if password_file == "-" {
if tty.IsTerminal(os.Stdin.Fd()) {
ans, err = tui.ReadPassword("Password: ", false)
ans, err = tui.ReadPassword("Password: ", true)
if err != nil {
return
}

View File

@@ -217,14 +217,14 @@ func (self *ParsedShortcut) String() string {
return ans
}
var parsed_shortcut_cache map[string]ParsedShortcut
var parsed_shortcut_cache map[string]*ParsedShortcut
func ParseShortcut(spec string) *ParsedShortcut {
if parsed_shortcut_cache == nil {
parsed_shortcut_cache = make(map[string]ParsedShortcut, 128)
parsed_shortcut_cache = make(map[string]*ParsedShortcut, 128)
}
if val, ok := parsed_shortcut_cache[spec]; ok {
return &val
return val
}
ospec := spec
if strings.HasSuffix(spec, "+") {
@@ -243,7 +243,6 @@ func ParseShortcut(spec string) *ParsedShortcut {
}
}
ans := ParsedShortcut{KeyName: key_name}
parsed_shortcut_cache[spec] = ans
if len(parts) > 1 {
for _, q := range parts[:len(parts)-1] {
val, ok := kitty.ConfigModMap[strings.ToUpper(q)]
@@ -254,6 +253,7 @@ func ParseShortcut(spec string) *ParsedShortcut {
}
}
}
parsed_shortcut_cache[spec] = &ans
return &ans
}

View File

@@ -24,7 +24,10 @@ func ReadPassword(prompt string, kill_if_signaled bool) (password string, err er
return
}
loop.OnInitialize = func(loop *Loop) string { return "\r\n" }
loop.OnInitialize = func(loop *Loop) string {
loop.QueueWriteString(prompt)
return "\r\n"
}
loop.OnText = func(loop *Loop, text string, from_key_event bool, in_bracketed_paste bool) error {
old_width := wcswidth.Stringwidth(password)