mirror of
https://codeberg.org/cage/tinmop/
synced 2025-01-03 01:09:20 +01:00
- added a slot in 'command-window' to allow the user to insert secret
input. the same character is echoed instead of the actual input.
This commit is contained in:
parent
5169deaedd
commit
dd1e4f6066
@ -37,6 +37,10 @@ main-window.foreground = white
|
|||||||
|
|
||||||
crypted.mark.value = " 🔏👌"
|
crypted.mark.value = " 🔏👌"
|
||||||
|
|
||||||
|
# the string to be drawn instead of actual character when input password
|
||||||
|
|
||||||
|
password-echo-character = "•"
|
||||||
|
|
||||||
# the character used to draw the vote's horizontal histogram
|
# the character used to draw the vote's horizontal histogram
|
||||||
# note: keeps it one character wide
|
# note: keeps it one character wide
|
||||||
|
|
||||||
|
@ -22,6 +22,13 @@
|
|||||||
:initarg :command-line
|
:initarg :command-line
|
||||||
:accessor command-line
|
:accessor command-line
|
||||||
:documentation "A list of keys so far inserted by the user")
|
:documentation "A list of keys so far inserted by the user")
|
||||||
|
(echo-character
|
||||||
|
:initform nil
|
||||||
|
:initarg :echo-character
|
||||||
|
:accessor echo-character
|
||||||
|
:documentation "If non nil print a number of copies (equals to
|
||||||
|
length of slot 'command-line' of this string instead of the
|
||||||
|
command-line itself")
|
||||||
(error-message
|
(error-message
|
||||||
:initform nil
|
:initform nil
|
||||||
:initarg :error-message
|
:initarg :error-message
|
||||||
@ -159,7 +166,13 @@ be either `:keybinding' or `:string'. the former for key command the latter for
|
|||||||
(point-position point-position)
|
(point-position point-position)
|
||||||
(point-bg point-bg)
|
(point-bg point-bg)
|
||||||
(point-fg point-fg)
|
(point-fg point-fg)
|
||||||
(prompt prompt)) win
|
(prompt prompt)
|
||||||
|
(echo-character echo-character)) win
|
||||||
|
(flet ((print-echo-character ()
|
||||||
|
(let ((echoed (with-output-to-string (stream)
|
||||||
|
(loop repeat (length command-line) do
|
||||||
|
(princ echo-character stream)))))
|
||||||
|
(print-text win echoed (length prompt) 0))))
|
||||||
(let* ((length-cmd-line (length command-line))
|
(let* ((length-cmd-line (length command-line))
|
||||||
(no-prompt-point-pos (no-prompt-point-pos win))
|
(no-prompt-point-pos (no-prompt-point-pos win))
|
||||||
(cursor-value (if (and (> length-cmd-line 0)
|
(cursor-value (if (and (> length-cmd-line 0)
|
||||||
@ -169,13 +182,15 @@ be either `:keybinding' or `:string'. the former for key command the latter for
|
|||||||
#\Space)))
|
#\Space)))
|
||||||
(print-text win prompt 0 0)
|
(print-text win prompt 0 0)
|
||||||
(when command-line
|
(when command-line
|
||||||
(print-text win command-line (length prompt) 0))
|
(if echo-character
|
||||||
|
(print-echo-character)
|
||||||
|
(print-text win command-line (length prompt) 0)))
|
||||||
(print-text win
|
(print-text win
|
||||||
cursor-value
|
cursor-value
|
||||||
point-position
|
point-position
|
||||||
0
|
0
|
||||||
:fgcolor point-fg
|
:fgcolor point-fg
|
||||||
:bgcolor point-bg))))
|
:bgcolor point-bg)))))
|
||||||
|
|
||||||
(defmethod draw ((object command-window))
|
(defmethod draw ((object command-window))
|
||||||
(with-accessors ((command-line command-line)
|
(with-accessors ((command-line command-line)
|
||||||
|
@ -993,6 +993,7 @@
|
|||||||
:config-notification-life
|
:config-notification-life
|
||||||
:config-server-name
|
:config-server-name
|
||||||
:config-username
|
:config-username
|
||||||
|
:config-password-echo-character
|
||||||
:config-win-focus-mark
|
:config-win-focus-mark
|
||||||
:thread-message-symbol
|
:thread-message-symbol
|
||||||
:thread-message-read-colors
|
:thread-message-read-colors
|
||||||
@ -1784,6 +1785,7 @@
|
|||||||
:print-error
|
:print-error
|
||||||
:command-window
|
:command-window
|
||||||
:command-line
|
:command-line
|
||||||
|
:echo-character
|
||||||
:event-to-answer
|
:event-to-answer
|
||||||
:prompt
|
:prompt
|
||||||
:add-error-message
|
:add-error-message
|
||||||
|
@ -172,6 +172,10 @@
|
|||||||
:initform nil
|
:initform nil
|
||||||
:initarg :initial-value
|
:initarg :initial-value
|
||||||
:accessor initial-value)
|
:accessor initial-value)
|
||||||
|
(echo-character
|
||||||
|
:initform nil
|
||||||
|
:initarg :echo-character
|
||||||
|
:accessor echo-character)
|
||||||
(complete-fn
|
(complete-fn
|
||||||
:initform nil
|
:initform nil
|
||||||
:initarg :complete-fn
|
:initarg :complete-fn
|
||||||
@ -191,7 +195,8 @@
|
|||||||
(defmethod process-event ((object ask-user-input-string-event))
|
(defmethod process-event ((object ask-user-input-string-event))
|
||||||
(with-accessors ((prompt prompt)
|
(with-accessors ((prompt prompt)
|
||||||
(initial-value initial-value)
|
(initial-value initial-value)
|
||||||
(complete-fn complete-fn)) object
|
(complete-fn complete-fn)
|
||||||
|
(echo-character echo-character)) object
|
||||||
(setf (command-window:event-to-answer specials:*command-window*)
|
(setf (command-window:event-to-answer specials:*command-window*)
|
||||||
object)
|
object)
|
||||||
(setf (point-tracker:prompt specials:*command-window*)
|
(setf (point-tracker:prompt specials:*command-window*)
|
||||||
@ -203,6 +208,8 @@
|
|||||||
(setf (command-window:command-line specials:*command-window*)
|
(setf (command-window:command-line specials:*command-window*)
|
||||||
initial-value)
|
initial-value)
|
||||||
(point-tracker:move-point-to-end specials:*command-window* initial-value)
|
(point-tracker:move-point-to-end specials:*command-window* initial-value)
|
||||||
|
(setf (command-window:echo-character specials:*command-window*)
|
||||||
|
echo-character)
|
||||||
(windows:draw specials:*command-window*)))
|
(windows:draw specials:*command-window*)))
|
||||||
|
|
||||||
(defclass user-input-string-event (ask-user-input-string-event)
|
(defclass user-input-string-event (ask-user-input-string-event)
|
||||||
@ -220,6 +227,8 @@
|
|||||||
(defmethod process-event ((object user-input-string-event))
|
(defmethod process-event ((object user-input-string-event))
|
||||||
(with-accessors ((lock lock)
|
(with-accessors ((lock lock)
|
||||||
(condition-variable condition-variable)) object
|
(condition-variable condition-variable)) object
|
||||||
|
(setf (command-window:echo-character specials:*command-window*)
|
||||||
|
nil)
|
||||||
(with-lock (lock)
|
(with-lock (lock)
|
||||||
(bt:condition-notify condition-variable))))
|
(bt:condition-notify condition-variable))))
|
||||||
|
|
||||||
|
@ -399,6 +399,7 @@
|
|||||||
input
|
input
|
||||||
read
|
read
|
||||||
unread
|
unread
|
||||||
|
password-echo-character
|
||||||
color-re
|
color-re
|
||||||
ignore-user-re
|
ignore-user-re
|
||||||
purge-history-days-offset
|
purge-history-days-offset
|
||||||
@ -657,6 +658,9 @@
|
|||||||
(gen-simple-access (username)
|
(gen-simple-access (username)
|
||||||
+key-username+)
|
+key-username+)
|
||||||
|
|
||||||
|
(gen-simple-access (password-echo-character)
|
||||||
|
+key-password-echo-character+)
|
||||||
|
|
||||||
(defun config-win-focus-mark ()
|
(defun config-win-focus-mark ()
|
||||||
(values (access:accesses *software-configuration*
|
(values (access:accesses *software-configuration*
|
||||||
+key-window+
|
+key-window+
|
||||||
|
@ -155,7 +155,7 @@ as argument `complex-string'."
|
|||||||
(croatoan:concat-complex-string a b :color-attributes-contagion color-attributes-contagion))
|
(croatoan:concat-complex-string a b :color-attributes-contagion color-attributes-contagion))
|
||||||
|
|
||||||
(defmethod cat-complex-string ((a complex-string) (b complex-string)
|
(defmethod cat-complex-string ((a complex-string) (b complex-string)
|
||||||
&key (color-attributes-contagion t))
|
&key (color-attributes-contagion nil))
|
||||||
"Return a complex string that is the results of concatenating of `a'
|
"Return a complex string that is the results of concatenating of `a'
|
||||||
and `b': two `complex-string'. If `color-attributes-contagion' is
|
and `b': two `complex-string'. If `color-attributes-contagion' is
|
||||||
non nil `b' will inherit all the attributes and color of a."
|
non nil `b' will inherit all the attributes and color of a."
|
||||||
|
@ -145,12 +145,16 @@
|
|||||||
|
|
||||||
(defun ask-string-input (on-input-complete-fn
|
(defun ask-string-input (on-input-complete-fn
|
||||||
&key
|
&key
|
||||||
|
(hide-input nil)
|
||||||
(priority nil)
|
(priority nil)
|
||||||
(initial-value nil)
|
(initial-value nil)
|
||||||
(prompt +default-command-prompt+)
|
(prompt +default-command-prompt+)
|
||||||
(complete-fn #'complete:directory-complete))
|
(complete-fn #'complete:directory-complete))
|
||||||
(flet ((thread-fn ()
|
(flet ((thread-fn ()
|
||||||
(let ((event (make-instance 'ask-user-input-string-event
|
(let* ((password-echo (and hide-input
|
||||||
|
(swconf:config-password-echo-character)))
|
||||||
|
(event (make-instance 'ask-user-input-string-event
|
||||||
|
:echo-character password-echo
|
||||||
:forced-priority priority
|
:forced-priority priority
|
||||||
:initial-value initial-value
|
:initial-value initial-value
|
||||||
:complete-fn complete-fn
|
:complete-fn complete-fn
|
||||||
|
Loading…
Reference in New Issue
Block a user