diff --git a/src/boot/sysobj.reb b/src/boot/sysobj.reb index 09240c78dd..e55d3acf29 100644 --- a/src/boot/sysobj.reb +++ b/src/boot/sysobj.reb @@ -149,6 +149,7 @@ options: object [ ; Options supplied to REBOL during startup binary-base: 16 ; Default base for FORMed binary values (64, 16, 2) decimal-digits: 15 ; Max number of decimal digits to print. + probe-limit: 16000 ; Max probed output size, 0 means no limit module-paths: [%./] default-suffix: %.reb ; Used by IMPORT if no suffix is provided file-types: [] diff --git a/src/core/n-io.c b/src/core/n-io.c index 3ecda8f297..908e901738 100644 --- a/src/core/n-io.c +++ b/src/core/n-io.c @@ -131,15 +131,15 @@ static REBSER *Read_All_File(char *fname) { REBVAL *val = D_ARG(1); REB_MOLD mo = {0}; - REBINT len = -1; // no limit + REBINT len = NO_LIMIT; if (D_REF(3)) SET_FLAG(mo.opts, MOPT_MOLD_ALL); if (D_REF(4)) SET_FLAG(mo.opts, MOPT_INDENT); if (D_REF(5)) { if (VAL_INT64(D_ARG(6)) > (i64)MAX_I32) len = MAX_I32; - else if (VAL_INT64(D_ARG(6)) < 0) - len = 0; + else if (VAL_INT64(D_ARG(6)) <= 0) + len = NO_LIMIT; else len = VAL_INT32(D_ARG(6)); } diff --git a/src/mezz/base-debug.reb b/src/mezz/base-debug.reb index ef409dd507..15da1c18f4 100644 --- a/src/mezz/base-debug.reb +++ b/src/mezz/base-debug.reb @@ -19,8 +19,14 @@ REBOL [ probe: func [ {Debug print a molded value and returns that same value.} value [any-type!] + /local len ][ - print mold :value + len: system/options/probe-limit + print either 0 < len [ + ellipsize (mold/part :value len + 1) len + ][ + mold :value + ] :value ] @@ -33,7 +39,7 @@ probe: func [ word? :name path? :name ][ - prin ajoin ["^[[1;32;49m" mold :name "^[[0m: ^[[32m"] + prin ajoin ["^[[1;32m" mold :name "^[[0m: ^[[32m"] prin either value? :name [mold/all get/any :name] ["#[unset!]"] print "^[[0m" ] @@ -43,15 +49,15 @@ probe: func [ word? :word path? :word ][ - prin ajoin ["^[[1;32;49m" mold :word "^[[0m: ^[[32m"] + prin ajoin ["^[[1;32m" mold :word "^[[0m: ^[[32m"] prin either value? :word [mold/all get/any :word]["#[unset!]"] print "^[[0m" ][ - print ajoin ["^[[1;32;49m" mold/all word "^[[0m"] + print ajoin ["^[[1;32m" mold/all word "^[[0m"] ] ] ] - true [print ajoin ["^[[1;32;49m" mold/all :name "^[[0m"]] + true [print ajoin ["^[[1;32m" mold/all :name "^[[0m"]] ] exit ] diff --git a/src/mezz/base-series.reb b/src/mezz/base-series.reb index edf46cdea0..ac68c1893b 100644 --- a/src/mezz/base-series.reb +++ b/src/mezz/base-series.reb @@ -44,3 +44,27 @@ reform: func [ ][ form reduce :value ] + +ellipsize: func [ + "Truncate and add ellipsis if str is longer than len" + str [string!] "(modified)" + len [integer!] "Max length" + /one-line "Escape line breaks" + /local chars +][ + if one-line [ + chars: #[bitset! [not bits #{0024}]] + parse str [ + any [ + some chars + | change #"^/" "^^/" + | change #"^M" "^^M" + ] + ] + ] + if len < length? str [ + append clear skip str (len - 3) "..." + ] + + str +] diff --git a/src/mezz/mezz-help.reb b/src/mezz/mezz-help.reb index b2dcccbc66..9fe072fcee 100644 --- a/src/mezz/mezz-help.reb +++ b/src/mezz/mezz-help.reb @@ -71,15 +71,6 @@ import module [ buffer: insert buffer form reduce value ] - clip-str: func [str] [ - ; Keep string to one line. - unless string? str [str: mold/part/flat str max-desc-width] - replace/all str LF "^^/" - replace/all str CR "^^M" - if (length? str) > (max-desc-width - 1) [str: append copy/part str max-desc-width "..."] - str - ] - interpunction: charset ";.?!" dot: func[value [string!]][ unless find interpunction last value [append value #"."] @@ -116,7 +107,8 @@ import module [ ;none? :val [ mold/all val] true [:val] ] - clip-str val + unless string? val [val: mold/part/flat val max-desc-width] + ellipsize/one-line val max-desc-width - 1 ] form-pad: func [val size] [