Skip to content

Commit 9ab1b13

Browse files
committed
FEAT: improving HELP output on datatypes.
It also displays different results if used directly on datatype, like: ``` help char! ``` or when used on value, which holds datatype, like in: ``` my-value: char! help my-value ``` First one displays: ``` CHAR! is a datatype. It is defined as a 8bit and 16bit character. It is of the general type scalar. Found these related words: null char! #"^@" space char! #" " sp char! #" " backspace char! #"^H" bs char! #"^H" tab char! #"^-" newline char! #"^/" newpage char! #"^L" slash char! #"/" backslash char! #"\" escape char! #"^[" cr char! #"^M" lf char! #"^/" ``` while the second one just: ``` MY-VALUE is a datatype of value: char! ```
1 parent d8fa4c3 commit 9ab1b13

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/mezz/mezz-help.r

+23-9
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ import module [
126126
/weak "Provides sorting and does not displays unset values"
127127
/match "Include only those that match a string or datatype"
128128
pattern
129+
/only {Do not display "no info" message}
129130
/local start wild type str result
130131
][
131-
result: make string! 250
132+
result: clear ""
132133
; Search for matching strings:
133134
wild: all [string? pattern find pattern "*"]
134135
foreach [word val] obj [
@@ -162,9 +163,9 @@ import module [
162163
]
163164
]
164165
]
165-
either all [pattern empty? result] [
166+
either all [pattern empty? result not only] [
166167
ajoin ["No information on: ^[[32m" pattern "^[[m^/"]
167-
][ result ]
168+
][ copy result ]
168169
]
169170

170171
out-description: func [des [block!]][
@@ -185,7 +186,7 @@ import module [
185186
try [
186187
max-desc-width: (query/mode system/ports/input 'buffer-cols) - 36
187188
]
188-
buffer: any [string make string! 1024]
189+
buffer: any [string clear ""]
189190
catch [
190191
case/all [
191192
unset? :word [
@@ -202,8 +203,23 @@ import module [
202203
throw true
203204
]
204205
datatype? :value [
205-
output ajoin ["^[[1;32m" uppercase mold :word "^[[m is a datatype of value: ^[[32m" mold :value "^[[m^/"]
206-
output dump-obj/match system/contexts/lib :word
206+
spec: spec-of :value
207+
either :word <> to word! :value [
208+
; for example: value: string! help value
209+
output ajoin [
210+
"^[[1;32m" uppercase mold :word "^[[m is a datatype of value: ^[[32m" mold :value "^[[m^/"
211+
]
212+
][
213+
; for example: help string!
214+
output ajoin [
215+
"^[[1;32m" uppercase mold :word "^[[m is a datatype.^[[m^/"
216+
"It is defined as" either find "aeiou" first spec/title [" an "] [" a "] spec/title ".^/"
217+
"It is of the general type ^[[1;32m" spec/type "^[[m.^/^/"
218+
]
219+
unless empty? value: dump-obj/match/only system/contexts/lib :word [
220+
output ajoin ["Found these related words:^/" value]
221+
]
222+
]
207223
throw true
208224
]
209225
not any [word? :word path? :word] [
@@ -320,9 +336,7 @@ import module [
320336
]
321337
]
322338
]
323-
also
324-
either into [buffer][print head buffer]
325-
buffer: none
339+
either into [buffer][print head buffer]
326340
]
327341

328342
about: func [

0 commit comments

Comments
 (0)