diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-11 20:41:28 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-11 20:41:28 -0700 |
commit | 5df51b54116d4287df161c42ca0edb16fb1f79a5 (patch) | |
tree | 6f6046d624fafa24843ddefd46522871e7104bed /stream.c | |
parent | 423366b14fec676bcd13f04659f91ad7b6512724 (diff) | |
download | txr-5df51b54116d4287df161c42ca0edb16fb1f79a5.tar.gz txr-5df51b54116d4287df161c42ca0edb16fb1f79a5.tar.bz2 txr-5df51b54116d4287df161c42ca0edb16fb1f79a5.zip |
streams: new function inc-indent-abs.
* stream.c (inc_indent_abs): New function.
(stream_init): inc-init-abs intrinsic registered.
* stream.h (inc_indent_abs): Declared.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -4104,6 +4104,18 @@ val inc_indent(val stream, val delta) return oldval; } +val inc_indent_abs(val stream, val delta) +{ + val self = lit("inc-indent-abs"); + struct strm_base *s = coerce(struct strm_base *, + cobj_handle(self, stream, stream_cls)); + val oldval = num(s->indent_chars); + s->indent_chars = c_num(plus(delta, oldval), self); + if (s->indent_chars < 0) + s->indent_chars = 0; + return oldval; +} + val width_check(val stream, val alt) { val self = lit("width-check"); @@ -5553,6 +5565,7 @@ void stream_init(void) reg_fun(intern(lit("get-indent"), user_package), func_n1(get_indent)); reg_fun(intern(lit("set-indent"), user_package), func_n2(set_indent)); reg_fun(intern(lit("inc-indent"), user_package), func_n2(inc_indent)); + reg_fun(intern(lit("inc-indent-abs"), user_package), func_n2(inc_indent_abs)); reg_fun(intern(lit("width-check"), user_package), func_n2(width_check)); reg_fun(intern(lit("force-break"), user_package), func_n1(force_break)); reg_fun(intern(lit("set-max-length"), user_package), func_n2(set_max_length)); |