* gnulib-local/lib/term-ostream.oo.h (ttyctl_t): New type.
(term_ostream_create): Add tty_control argument.
* gnulib-local/lib/term-ostream.oo.c (term_ostream_create): Likewise.
* gnulib-local/lib/term-styled-ostream.oo.h: Include term-ostream.h.
(term_styled_ostream_create): Add tty_control argument.
* gnulib-local/lib/term-styled-ostream.oo.c (term_styled_ostream_create):
Likewise.
* gnulib-local/tests/test-term-ostream.c (main): Use TTYCTL_AUTO.
* gettext-tools/src/color.c (print_color_test): Likewise.
* gettext-tools/src/write-catalog.c (msgdomain_list_print): Likewise.
term_ostream_t stream;
int i, row, col;
- stream = term_ostream_create (1, "stdout");
+ stream = term_ostream_create (1, "stdout", TTYCTL_AUTO);
for (i = 0; i < 8; i++)
colors[i].c =
style_file_prepare ("PO_STYLE",
"GETTEXTSTYLESDIR", relocate (GETTEXTSTYLESDIR),
"po-default.css");
- stream = term_styled_ostream_create (fd, filename, style_file_name);
+ stream =
+ term_styled_ostream_create (fd, filename, TTYCTL_AUTO, style_file_name);
if (stream == NULL)
stream = fd_ostream_create (fd, filename, true);
output_syntax->print (mdlp, stream, page_width, debug);
/* Output stream for attributed text, producing ANSI escape sequences.
- Copyright (C) 2006-2008, 2017 Free Software Foundation, Inc.
+ Copyright (C) 2006-2008, 2017, 2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
}
term_ostream_t
-term_ostream_create (int fd, const char *filename)
+term_ostream_create (int fd, const char *filename, ttyctl_t tty_control)
{
term_ostream_t stream = XMALLOC (struct term_ostream_representation);
const char *term;
/* Output stream for attributed text, producing ANSI escape sequences.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
term_underline_t underline);
};
+/* The amount of control to take over the underlying tty in order to avoid
+ garbled output on the screen, due to interleaved output of escape sequences
+ and output from the kernel (such as when the kernel echoes user's input
+ or when the kernel prints '^C' after the user pressed Ctrl-C). */
+typedef enum
+{
+ TTYCTL_AUTO = 0, /* Automatic best-possible choice. */
+ TTYCTL_NONE, /* No control.
+ Result: Garbled output can occur, and the terminal can
+ be left in any state when the program is interrupted. */
+ TTYCTL_PARTIAL, /* Signal handling.
+ Result: Garbled output can occur, but the terminal will
+ be left in the default state when the program is
+ interrupted. */
+ TTYCTL_FULL /* Signal handling and disabling echo and flush-upon-signal.
+ Result: No garbled output, and the the terminal will
+ be left in the default state when the program is
+ interrupted. */
+} ttyctl_t;
+
#ifdef __cplusplus
extern "C" {
/* Create an output stream referring to the file descriptor FD.
FILENAME is used only for error messages.
+ TTY_CONTROL specifies the amount of control to take over the underlying tty.
The resulting stream will be line-buffered.
Note that the resulting stream must be closed before FD can be closed. */
-extern term_ostream_t term_ostream_create (int fd, const char *filename);
+extern term_ostream_t
+ term_ostream_create (int fd, const char *filename, ttyctl_t tty_control);
#ifdef __cplusplus
/* Output stream for CSS styled text, producing ANSI escape sequences.
- Copyright (C) 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2006-2007, 2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
/* Constructor. */
term_styled_ostream_t
-term_styled_ostream_create (int fd, const char *filename,
+term_styled_ostream_create (int fd, const char *filename, ttyctl_t tty_control,
const char *css_filename)
{
term_styled_ostream_t stream =
CRStyleSheet *css_file_contents;
stream->base.base.vtable = &term_styled_ostream_vtable;
- stream->destination = term_ostream_create (fd, filename);
+ stream->destination = term_ostream_create (fd, filename, tty_control);
if (cr_om_parser_simply_parse_file ((const guchar *) css_filename,
CR_UTF_8, /* CR_AUTO is not supported */
/* Output stream for CSS styled text, producing ANSI escape sequences.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
#define _TERM_STYLED_OSTREAM_H
#include "styled-ostream.h"
+#include "term-ostream.h"
struct term_styled_ostream : struct styled_ostream
/* Create an output stream referring to the file descriptor FD, styled with
the file CSS_FILENAME.
FILENAME is used only for error messages.
+ TTY_CONTROL specifies the amount of control to take over the underlying tty.
Note that the resulting stream must be closed before FD can be closed.
Return NULL upon failure. */
extern term_styled_ostream_t
term_styled_ostream_create (int fd, const char *filename,
+ ttyctl_t tty_control,
const char *css_filename);
term_ostream_t stream;
int i, row, col;
- stream = term_ostream_create (1, "stdout");
+ stream = term_ostream_create (1, "stdout", TTYCTL_AUTO);
for (i = 0; i < 8; i++)
colors[i].c =