diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a1e867..164db45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ability to set custom keybindings in config (#135) - Added scrollbar, by default only appears on pages that go off-screen (#89, #107) - More internal about pages, see `about:about` (#160, 187) +- Sensitive input fields (status code 11) display with asterisks over the text (#106) ### Changed - Update cview to `d776e728ef6d2a9990a5cd86a70b31f0678613e2` for large performance and feature updates (#107) diff --git a/NOTES.md b/NOTES.md index 7eaf9a0..c176421 100644 --- a/NOTES.md +++ b/NOTES.md @@ -10,3 +10,4 @@ - [ANSI conversion is messed up](https://gitlab.com/tslocum/cview/-/issues/48) - [WordWrap is broken in some cases](https://gitlab.com/tslocum/cview/-/issues/27#note_475438483) - close #156 if this is fixed - [Prevent panic when reformatting](https://gitlab.com/tslocum/cview/-/issues/50) - can't reliably reproduce or debug +- [Unicode bullet symbol mask causes issues with PasswordInput](https://gitlab.com/tslocum/cview/-/issues/55) diff --git a/display/handlers.go b/display/handlers.go index 9aed8ea..b0deb9a 100644 --- a/display/handlers.go +++ b/display/handlers.go @@ -432,7 +432,16 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) { // Handle each status code switch res.Status { case 10, 11: - userInput, ok := Input(res.Meta) + var userInput string + var ok bool + + if res.Status == 10 { + // Regular input + userInput, ok = Input(res.Meta, false) + } else { + // Sensitive input + userInput, ok = Input(res.Meta, true) + } if ok { // Make another request with the query string added parsed.RawQuery = gemini.QueryEscape(userInput) diff --git a/display/modals.go b/display/modals.go index 84e6a99..30747c5 100644 --- a/display/modals.go +++ b/display/modals.go @@ -213,18 +213,27 @@ func Info(s string) { // Input pulls up a modal that asks for input, and returns the user's input. // It returns an bool indicating if the user chose to send input or not. -func Input(prompt string) (string, bool) { +func Input(prompt string, sensitive bool) (string, bool) { // Remove elements and re-add them - to clear input text and keep input in focus inputModal.ClearButtons() inputModal.GetForm().Clear(false) inputModal.AddButtons([]string{"Send", "Cancel"}) inputModalText = "" - inputModal.GetForm().AddInputField("", "", 0, nil, - func(text string) { - // Store for use later - inputModalText = text - }) + + if sensitive { + // TODO use bullet characters if user wants it once bug is fixed - see NOTES.md + inputModal.GetForm().AddPasswordField("", "", 0, '*', + func(text string) { + // Store for use later + inputModalText = text + }) + } else { + inputModal.GetForm().AddInputField("", "", 0, nil, + func(text string) { + inputModalText = text + }) + } inputModal.SetText(prompt + " ") panels.ShowPanel("input")