Skip to content

Commit 7af09dc

Browse files
committed
FEAT: some improvements in HELP output
1 parent eb3b7c1 commit 7af09dc

File tree

2 files changed

+137
-142
lines changed

2 files changed

+137
-142
lines changed

src/mezz/base-debug.r

+10-9
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,34 @@ probe: func [
2626

2727
??: func [
2828
{Debug print a word, path, or block of such, followed by its molded value.}
29-
'name "Word, path, and block to obtain values."
30-
/local out
29+
'name "Word, path or block to obtain values."
3130
][
3231
case [
3332
any [
3433
word? :name
3534
path? :name
3635
][
37-
print ajoin [name ": " mold name: get :name]
36+
prin ajoin ["^[[1;32;49m" mold :name "^[[0m == ^[[32m"]
37+
prin either value? :name [mold/all get/any :name] ["#[unset!]"]
38+
print "^[[0m"
3839
]
3940
block? :name [
40-
out: make string! 50
4141
foreach word name [
4242
either any [
4343
word? :word
4444
path? :word
4545
][
46-
repend out [word ": " mold get word " "]
46+
prin ajoin ["^[[1;32;49m" mold :word "^[[0m == ^[[32m"]
47+
prin either value? :word [mold/all get/any :word]["#[unset!]"]
48+
print "^[[0m"
4749
][
48-
repend out [mold word " "]
50+
print ajoin ["^[[1;32;49m" mold/all word "^[[0m"]
4951
]
5052
]
51-
print out
5253
]
53-
true [probe :name]
54+
true [print ajoin ["^[[1;32;49m" mold/all word "^[[0m"]]
5455
]
55-
:name
56+
exit
5657
]
5758

5859
boot-print: func [

src/mezz/mezz-help.r

+127-133
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ dump-obj: function [
7575
]
7676
]
7777
][
78-
str: form-pad word 15
79-
append str #" "
80-
append str form-pad type 10 - ((length? str) - 15)
78+
str: join "^[[1;32;49m" form-pad word 15
79+
append str "^[[0m "
80+
append str form-pad type 24 - ((length? str) - 15)
8181
append out reform [
82-
" " str
82+
" " str "^[[32m"
8383
if type <> 'unset! [form-val :val]
84-
newline
84+
"^[[0m^/"
8585
]
8686
]
8787
]
@@ -124,26 +124,19 @@ dump-obj: function [
124124
^[[0m
125125
Other debug functions:
126126
127-
^[[1;32;49mdocs^[[0m - open browser to web documentation
128-
^[[1;32;49m??^[[0m - display a variable and its value
129-
^[[1;32;49mprobe^[[0m - print a value (molded)
130-
^[[1;32;49msource func^[[0m - show source code of func
131-
^[[1;32;49mtrace^[[0m - trace evaluation steps
132-
^[[1;32;49mwhat^[[0m - show a list of known functions
133-
^[[1;32;49mwhy?^[[0m - explain more about last error (via web)
127+
^[[1;32;49mdocs^[[0m - open browser to web documentation
128+
^[[1;32;49m??^[[0m - display a variable and its value
129+
^[[1;32;49mprobe^[[0m - print a value (molded)
130+
^[[1;32;49msource^[[0m - show source code of func
131+
^[[1;32;49mtrace^[[0m - trace evaluation steps
132+
^[[1;32;49mwhat^[[0m - show a list of known functions
133+
^[[1;32;49mwhy?^[[0m - explain more about last error (via web)
134134
135135
Other information:
136136
137-
^[[1;32;49mchat^[[0m - open DevBase developer forum/BBS
138-
^[[1;32;49mdocs^[[0m - open DocBase document wiki website
139-
^[[1;32;49mbugs^[[0m - open CureCore bug database website
140-
^[[1;32;49mdemo^[[0m - run demo launcher (from rebol.com)
141-
^[[1;32;49mabout^[[0m - see general product info
142-
^[[1;32;49mupgrade^[[0m - check for newer versions
143-
^[[1;32;49mchanges^[[0m - show changes for recent version
144-
^[[1;32;49minstall^[[0m - install (when applicable)
137+
^[[1;32;49mabout^[[0m - see general product info
145138
^[[1;32;49mlicense^[[0m - show user license
146-
^[[1;32;49musage^[[0m - program cmd line options
139+
^[[1;32;49musage^[[0m - program cmd line options
147140
}
148141
exit
149142
]
@@ -178,7 +171,7 @@ dump-obj: function [
178171
word? :word
179172
any [any-function? get :word datatype? get :word]
180173
][
181-
item: form :word
174+
item: mold :word
182175
either any-function? get :word [
183176
foreach [a b] [ ; need a better method !
184177
"!" "-ex"
@@ -202,37 +195,37 @@ dump-obj: function [
202195
if any [string? :word all [word? :word datatype? get :word]] [
203196
if all [word? :word datatype? get :word] [
204197
value: spec-of get :word
205-
print [
206-
mold :word "is a datatype" newline
207-
"It is defined as" either find "aeiou" first value/title ["an"] ["a"] value/title newline
208-
"It is of the general type" value/type newline
198+
print ajoin [
199+
"^[[1;32;49m" mold :word "^[[0m is a datatype" newline
200+
"It is defined as " either find "aeiou" first value/title ["an "] ["a "] value/title newline
201+
"It is of the general type ^[[1;32;49m" value/type "^[[0m^/"
209202
]
210203
]
211204
if any [:word = 'unset! not value? :word] [exit]
212205
types: dump-obj/match lib :word
213206
sort types
214207
if not empty? types [
215-
print ["Found these related words:" newline types]
208+
print ["Found these related words:^[[32m" newline types "^[[0m"]
216209
exit
217210
]
218211
if all [word? :word datatype? get :word] [
219-
print ["No values defined for" word]
212+
print ["No values defined for^[[1;32;49m" word "^[[0m"]
220213
exit
221214
]
222-
print ["No information on" word]
215+
print ["No information on^[[1;32;49m" word "^[[0m"]
223216
exit
224217
]
225218

226219
; Print type name with proper singular article:
227220
type-name: func [value] [
228221
value: mold type? :value
229-
clear back tail value
222+
clear back tail value ;removes the ! char from datatype name
230223
join either find "aeiou" first value ["an "]["a "] value
231224
]
232225

233226
; Print literal values:
234227
if not any [word? :word path? :word][
235-
print [mold :word "is" type-name :word]
228+
print ajoin ["^[[1;32;49m" mold :word "^[[0m is " type-name :word]
236229
exit
237230
]
238231

@@ -259,8 +252,9 @@ dump-obj: function [
259252
value: get :word
260253
]
261254
unless any-function? :value [
262-
prin [uppercase mold word "is" type-name :value "of value: "]
263-
print either any [object? value port? value] [print "" dump-obj value][mold :value]
255+
prin ajoin ["^[[1;32;49m" uppercase mold word "^[[0m is " type-name :value " of value: ^[[32m"]
256+
prin either any [object? value port? value] [print "" dump-obj value][mold/all :value]
257+
print "^[[0m"
264258
exit
265259
]
266260

@@ -276,7 +270,7 @@ dump-obj: function [
276270
either op? :value [
277271
print [args/1 word args/2]
278272
][
279-
print [uppercase mold word args]
273+
print [uppercase mold word mold/only args]
280274
]
281275

282276
print ajoin [
@@ -293,7 +287,7 @@ dump-obj: function [
293287
if empty? list [exit]
294288
print label
295289
foreach arg list [
296-
str: ajoin [tab arg/1]
290+
str: ajoin [tab mold arg/1]
297291
if all [extra word? arg/1] [insert str tab]
298292
if arg/2 [append append str " -- " arg/2]
299293
if all [arg/3 not refinement? arg/1] [
@@ -422,101 +416,101 @@ what: func [
422416
exit
423417
]
424418

425-
pending: does [
426-
comment "temp function"
427-
print "Pending implementation."
428-
]
429-
430-
say-browser: does [
431-
comment "temp function"
432-
print "Opening web browser..."
433-
]
434-
435-
upgrade: function [
436-
"Check for newer versions (update REBOL)."
437-
][
438-
print "Fetching upgrade check ..."
439-
if error? err: try [do http://www.rebol.com/r3/upgrade.r none][
440-
either err/id = 'protocol [print "Cannot upgrade from web."][do err]
441-
]
442-
exit
443-
]
444-
445-
chat: function [
446-
"Open REBOL DevBase forum/BBS."
447-
][
448-
print "Fetching chat..."
449-
if error? err: try [do http://www.rebol.com/r3/chat.r none][
450-
either err/id = 'protocol [print "Cannot load chat from web."][do err]
451-
]
452-
exit
453-
]
454-
455-
docs: func [
456-
"Browse on-line documentation."
457-
][
458-
say-browser
459-
browse http://www.rebol.com/r3/docs
460-
exit
461-
]
462-
463-
bugs: func [
464-
"View bug database."
465-
][
466-
say-browser
467-
browse http://curecode.org/rebol3/
468-
exit
469-
]
470-
471-
changes: func [
472-
"What's new about this version."
473-
][
474-
say-browser
475-
browse http://www.rebol.com/r3/changes.html
476-
exit
477-
]
478-
479-
why?: func [
480-
"Explain the last error in more detail."
481-
'err [word! path! error! none! unset!] "Optional error value"
482-
][
483-
case [
484-
unset? :err [err: none]
485-
word? err [err: get err]
486-
path? err [err: get err]
487-
]
488-
489-
either all [
490-
error? err: any [:err system/state/last-error]
491-
err/type ; avoids lower level error types (like halt)
492-
][
493-
say-browser
494-
err: lowercase ajoin [err/type #"-" err/id]
495-
browse join http://www.rebol.com/r3/docs/errors/ [err ".html"]
496-
][
497-
print "No information is available."
498-
]
499-
exit
500-
]
501-
502-
demo: function [
503-
"Run R3 demo."
504-
][
505-
print "Fetching demo..."
506-
if error? err: try [do http://www.rebol.com/r3/demo.r none][
507-
either err/id = 'protocol [print "Cannot load demo from web."][do err]
508-
]
509-
exit
510-
]
511-
512-
load-gui: function [
513-
"Download current GUI module from web. (Temporary)"
514-
][
515-
print "Fetching GUI..."
516-
either error? data: try [load http://www.rebol.com/r3/gui.r][
517-
either data/id = 'protocol [print "Cannot load GUI from web."][do err]
518-
][
519-
do data
520-
]
521-
exit
522-
]
419+
;pending: does [
420+
; comment "temp function"
421+
; print "Pending implementation."
422+
;]
423+
;
424+
;say-browser: does [
425+
; comment "temp function"
426+
; print "Opening web browser..."
427+
;]
428+
;
429+
;upgrade: function [
430+
; "Check for newer versions (update REBOL)."
431+
;][
432+
; print "Fetching upgrade check ..."
433+
; if error? err: try [do http://www.rebol.com/r3/upgrade.r none][
434+
; either err/id = 'protocol [print "Cannot upgrade from web."][do err]
435+
; ]
436+
; exit
437+
;]
438+
;
439+
;chat: function [
440+
; "Open REBOL DevBase forum/BBS."
441+
;][
442+
; print "Fetching chat..."
443+
; if error? err: try [do http://www.rebol.com/r3/chat.r none][
444+
; either err/id = 'protocol [print "Cannot load chat from web."][do err]
445+
; ]
446+
; exit
447+
;]
448+
;
449+
;docs: func [
450+
; "Browse on-line documentation."
451+
;][
452+
; say-browser
453+
; browse http://www.rebol.com/r3/docs
454+
; exit
455+
;]
456+
;
457+
;bugs: func [
458+
; "View bug database."
459+
;][
460+
; say-browser
461+
; browse http://curecode.org/rebol3/
462+
; exit
463+
;]
464+
;
465+
;changes: func [
466+
; "What's new about this version."
467+
;][
468+
; say-browser
469+
; browse http://www.rebol.com/r3/changes.html
470+
; exit
471+
;]
472+
;
473+
;why?: func [
474+
; "Explain the last error in more detail."
475+
; 'err [word! path! error! none! unset!] "Optional error value"
476+
;][
477+
; case [
478+
; unset? :err [err: none]
479+
; word? err [err: get err]
480+
; path? err [err: get err]
481+
; ]
482+
;
483+
; either all [
484+
; error? err: any [:err system/state/last-error]
485+
; err/type ; avoids lower level error types (like halt)
486+
; ][
487+
; say-browser
488+
; err: lowercase ajoin [err/type #"-" err/id]
489+
; browse join http://www.rebol.com/r3/docs/errors/ [err ".html"]
490+
; ][
491+
; print "No information is available."
492+
; ]
493+
; exit
494+
;]
495+
;
496+
;demo: function [
497+
; "Run R3 demo."
498+
;][
499+
; print "Fetching demo..."
500+
; if error? err: try [do http://www.rebol.com/r3/demo.r none][
501+
; either err/id = 'protocol [print "Cannot load demo from web."][do err]
502+
; ]
503+
; exit
504+
;]
505+
;
506+
;load-gui: function [
507+
; "Download current GUI module from web. (Temporary)"
508+
;][
509+
; print "Fetching GUI..."
510+
; either error? data: try [load http://www.rebol.com/r3/gui.r][
511+
; either data/id = 'protocol [print "Cannot load GUI from web."][do err]
512+
; ][
513+
; do data
514+
; ]
515+
; exit
516+
;]

0 commit comments

Comments
 (0)