File tree 5 files changed +41
-18
lines changed
5 files changed +41
-18
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ options: object [ ; Options supplied to REBOL during startup
149
149
150
150
binary-base: 16 ; Default base for FORMed binary values (64, 16, 2)
151
151
decimal-digits: 15 ; Max number of decimal digits to print.
152
+ probe-limit: 16000 ; Max probed output size, 0 means no limit
152
153
module-paths: [%./ ]
153
154
default-suffix: %.reb ; Used by IMPORT if no suffix is provided
154
155
file-types: []
Original file line number Diff line number Diff line change @@ -131,15 +131,15 @@ static REBSER *Read_All_File(char *fname)
131
131
{
132
132
REBVAL * val = D_ARG (1 );
133
133
REB_MOLD mo = {0 };
134
- REBINT len = -1 ; // no limit
134
+ REBINT len = NO_LIMIT ;
135
135
136
136
if (D_REF (3 )) SET_FLAG (mo .opts , MOPT_MOLD_ALL );
137
137
if (D_REF (4 )) SET_FLAG (mo .opts , MOPT_INDENT );
138
138
if (D_REF (5 )) {
139
139
if (VAL_INT64 (D_ARG (6 )) > (i64 )MAX_I32 )
140
140
len = MAX_I32 ;
141
- else if (VAL_INT64 (D_ARG (6 )) < 0 )
142
- len = 0 ;
141
+ else if (VAL_INT64 (D_ARG (6 )) <= 0 )
142
+ len = NO_LIMIT ;
143
143
else
144
144
len = VAL_INT32 (D_ARG (6 ));
145
145
}
Original file line number Diff line number Diff line change @@ -19,8 +19,14 @@ REBOL [
19
19
probe : func [
20
20
{Debug print a molded value and returns that same value.}
21
21
value [any-type! ]
22
+ /local len
22
23
] [
23
- print mold :value
24
+ len: system/options/probe-limit
25
+ print either 0 < len [
26
+ ellipsize (mold /part :value len + 1 ) len
27
+ ][
28
+ mold :value
29
+ ]
24
30
:value
25
31
]
26
32
@@ -33,7 +39,7 @@ probe: func [
33
39
word? :name
34
40
path? :name
35
41
][
36
- prin ajoin ["^[ [1;32;49m " mold :name "^[ [0m: ^[ [32m" ]
42
+ prin ajoin ["^[ [1;32m " mold :name "^[ [0m: ^[ [32m" ]
37
43
prin either value? :name [mold /all get /any :name ] ["#[unset!]" ]
38
44
print "^[ [0m"
39
45
]
@@ -43,15 +49,15 @@ probe: func [
43
49
word? :word
44
50
path? :word
45
51
][
46
- prin ajoin ["^[ [1;32;49m " mold :word "^[ [0m: ^[ [32m" ]
52
+ prin ajoin ["^[ [1;32m " mold :word "^[ [0m: ^[ [32m" ]
47
53
prin either value? :word [mold /all get /any :word ]["#[unset!]" ]
48
54
print "^[ [0m"
49
55
][
50
- print ajoin ["^[ [1;32;49m " mold /all word "^[ [0m" ]
56
+ print ajoin ["^[ [1;32m " mold /all word "^[ [0m" ]
51
57
]
52
58
]
53
59
]
54
- true [print ajoin ["^[ [1;32;49m " mold /all :name "^[ [0m" ]]
60
+ true [print ajoin ["^[ [1;32m " mold /all :name "^[ [0m" ]]
55
61
]
56
62
exit
57
63
]
Original file line number Diff line number Diff line change @@ -44,3 +44,27 @@ reform: func [
44
44
] [
45
45
form reduce :value
46
46
]
47
+
48
+ ellipsize : func [
49
+ "Truncate and add ellipsis if str is longer than len"
50
+ str [string! ] "(modified)"
51
+ len [integer! ] "Max length"
52
+ /one-line "Escape line breaks"
53
+ /local chars
54
+ ] [
55
+ if one-line [
56
+ chars: #[bitset! [not bits #{ 0024 } ]]
57
+ parse str [
58
+ any [
59
+ some chars
60
+ | change #"^/" "^^ /"
61
+ | change #"^M" "^^ M"
62
+ ]
63
+ ]
64
+ ]
65
+ if len < length? str [
66
+ append clear skip str (len - 3 ) "..."
67
+ ]
68
+
69
+ str
70
+ ]
Original file line number Diff line number Diff line change @@ -71,15 +71,6 @@ import module [
71
71
buffer: insert buffer form reduce value
72
72
]
73
73
74
- clip-str : func [ str] [
75
- ; Keep string to one line.
76
- unless string? str [str: mold /part/flat str max-desc-width]
77
- replace/all str LF "^^ /"
78
- replace/all str CR "^^ M"
79
- if (length? str) > (max-desc-width - 1 ) [str: append copy/part str max-desc-width "..." ]
80
- str
81
- ]
82
-
83
74
interpunction: charset ";.?!"
84
75
dot : func [ value [string! ]] [
85
76
unless find interpunction last value [append value #"." ]
@@ -116,7 +107,8 @@ import module [
116
107
;none? :val [ mold/all val]
117
108
true [:val ]
118
109
]
119
- clip-str val
110
+ unless string? val [val: mold /part/flat val max-desc-width]
111
+ ellipsize/one-line val max-desc-width - 1
120
112
]
121
113
122
114
form-pad : func [ val size] [
You can’t perform that action at this time.
0 commit comments