diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-02-12 19:06:50 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-02-12 19:06:50 -0800 |
commit | fdb885e3ac75f901e3d51a0bf5bcef9a8969e847 (patch) | |
tree | 53b5d8824e4703f9d1baf66e82e24529b52c16e2 | |
parent | 2484f339278a684bab095d5c21d85b21d18b3d06 (diff) | |
download | txr-fdb885e3ac75f901e3d51a0bf5bcef9a8969e847.tar.gz txr-fdb885e3ac75f901e3d51a0bf5bcef9a8969e847.tar.bz2 txr-fdb885e3ac75f901e3d51a0bf5bcef9a8969e847.zip |
* debug.c (breakpoints, last_command): linkage changed to static.
(cols): New static variable.
(debug): Print context intelligently, fitting into the width of
the screen.
(debug_init): Try to get terminal width, from the COLUMNS variable.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | debug.c | 25 |
2 files changed, 29 insertions, 4 deletions
@@ -1,5 +1,13 @@ 2012-02-12 Kaz Kylheku <kaz@kylheku.com> + * debug.c (breakpoints, last_command): linkage changed to static. + (cols): New static variable. + (debug): Print context intelligently, fitting into the width of + the screen. + (debug_init): Try to get terminal width, from the COLUMNS variable. + +2012-02-12 Kaz Kylheku <kaz@kylheku.com> + * lib.c (lazy_flatten): Bugfix: function was assuming that the input is a list, and not handling the case atom -> (atom) like its non-lazy counterpart. @@ -19,8 +19,9 @@ int debug_depth; val debug_block_s; static int step_mode; static int next_depth = -1; -val breakpoints; -val last_command; +static val breakpoints; +static val last_command; +static int cols = 80; static void help(val stream) { @@ -81,8 +82,17 @@ val debug(val form, val bindings, val data, val line, val pos, val base) if (print_data) { if (data && pos) { - val prefix = sub_str(data, zero, pos); - val suffix = sub_str(data, pos, nil); + val half = num((cols - 8) / 2); + val full = num((cols - 8)); + val prefix, suffix; + + if (lt(pos, half)) { + prefix = sub_str(data, zero, pos); + suffix = sub_str(data, pos, full); + } else { + prefix = sub_str(data, minus(pos, half), pos); + suffix = sub_str(data, pos, plus(pos, half)); + } format(std_output, lit("data (~s:~s):\n~s . ~s\n"), line, plus(pos, base), prefix, suffix, nao); @@ -169,4 +179,11 @@ void debug_init(void) step_mode = 1; protect(&breakpoints, &last_command, (val *) 0); debug_block_s = intern(lit("debug-block"), system_package); + { + char *columns = getenv("COLUMNS"); + if (columns) + cols = atoi(columns); + if (cols < 40) + cols = 40; + } } |