From 566de7d4516c8c0d161a95dafcbb530601306538 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 16 Apr 2019 18:36:56 -0700 Subject: streams: force-off indent mode. The fourth indent mode indent-foff (force off) is introduced. * buf.c (buf_print): Turn on data mode indentation if the current mode is not indent-foff, rather than when it is indent-off. * lib.c (obj_print_impl): The unconditional set_indent_mode calls are replaced with test_neq_set_indent_mode so we only set the mode if it is not forced off. * stream.c (formatv): For the ! directive, turn on data mode identation is not indent-foff, rather than when it is indent-off. (put_string, put_char, width_check): Recognize ident-foff as indentation off. (test_neq_set_indent_mode): New function. (stream_init): Register test-neq-set-indent-mode function and indent-foff variable. * stream.h (indent_mode): New enum constant, indent_foff. (test_neq_set_indent_mode): Declared. * struct.c (struct_inst_print): Turn on data mode indentation if the current mode is not indent-foff, rather than when it is indent-off. * txr.1: Documented. --- stream.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'stream.h') diff --git a/stream.h b/stream.h index 37ab89a9..a7895064 100644 --- a/stream.h +++ b/stream.h @@ -34,7 +34,8 @@ enum strm_whence { enum indent_mode { indent_off, indent_data, - indent_code + indent_code, + indent_foff }; struct strm_ctx { @@ -205,6 +206,7 @@ val seek_stream(val stream, val offset, val whence); val truncate_stream(val stream, val len); val get_indent_mode(val stream); val test_set_indent_mode(val stream, val compare, val mode); +val test_neq_set_indent_mode(val stream, val compare, val mode); val set_indent_mode(val stream, val mode); val get_indent(val stream); val set_indent(val stream, val indent); -- cgit v1.2.3