mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
✨ Support sensitive input - fixes #106
This commit is contained in:
parent
9198572f34
commit
c9468c11ef
@ -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)
|
||||
|
1
NOTES.md
1
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)
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user