Skip to content

Commit d059565

Browse files
committed
FEAT: implemented ask/char, which waits only for a single key press
1 parent 1999b1b commit d059565

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/mezz/mezz-files.reb

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ ask: func [
104104
question [series!] "Prompt to user"
105105
/hide "Turns off echoing inputs"
106106
/char "Waits only on single key press and returns char as a result"
107+
limit [bitset! string! block! char! none!] "Limit input to specified chars or control words"
107108
][
108109
prin question
109-
input/:hide
110+
either char [wait-for-key/only limit][input/:hide]
110111
]
111112

112113
confirm: func [

src/mezz/mezz-shell.reb

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ file-checksum: function [
131131

132132
wait-for-key: func[
133133
"Wait for single key press and return char (or word for control keys) as a result"
134-
/only limit [bitset! string! block!] "Limit input to specified chars or control words"
134+
/only limit [bitset! string! block! none! char!] "Limit input to specified chars or control words"
135135
/local port old-awake
136136
][
137137
;; using existing input port
@@ -153,6 +153,8 @@ wait-for-key: func[
153153
true
154154
]
155155
]
156+
;; handle single char limit
157+
if char? limit [limit: to string! limit]
156158
;; wait for user input
157159
wait/only port
158160
;; put back original awake actor and read-line mode

0 commit comments

Comments
 (0)