summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorGerd Möllmann <gerd@gnu.org>2022-09-11 11:42:18 +0200
committerGerd Möllmann <gerd@gnu.org>2022-09-17 15:33:10 +0200
commitcbac94b4aeecdf57e2a1f3e95e27ec76505ae964 (patch)
treed9f6c4bc4a5313849d57aa14bbb57e59f6564ff2 /src/term.c
parent5bf8f9cc0d2fb12071301f50f9b85640d240a1fc (diff)
downloademacs-cbac94b4aeecdf57e2a1f3e95e27ec76505ae964.tar.gz
Optimize tty display updates (bug#57727)
* src/dispnew.c (update_frame_1): Don'f flush if tty's output_buffer_size is non-zero. * src/sysdep.c (init_sys_modes): Setvbuf depending on the tty's output_buffer_size. * src/term.c (Ftty__set_output_buffer_size, Ftty__output_buffer_size): Low-level interface for setting and retrieving a tty's output buffer size. (syms_of_term): Defsubr the new functions. * src/termchar.h (struct tty_display_info): New member output_buffer_size. * stc/NEWS: Describe the change.
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/term.c b/src/term.c
index 2e43d89232f..231324d002a 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2400,6 +2400,42 @@ frame's terminal). */)
return Qnil;
}
+DEFUN ("tty--set-output-buffer-size", Ftty__set_output_buffer_size,
+ Stty__set_output_buffer_size, 1, 2, 0, doc:
+ /* Set the output buffer size for a TTY.
+
+SIZE zero means use the system's default value. If SIZE is
+non-zero, this also avoids flushing the output stream.
+
+TTY may be a terminal object, a frame, or nil (meaning the selected
+frame's terminal).
+
+This function temporarily suspends and resumes the terminal
+device. */)
+ (Lisp_Object size, Lisp_Object tty)
+{
+ if (!TYPE_RANGED_FIXNUMP (size_t, size))
+ error ("Invalid output buffer size");
+ Fsuspend_tty (tty);
+ struct terminal *terminal = decode_tty_terminal (tty);
+ terminal->display_info.tty->output_buffer_size = XFIXNUM (size);
+ return Fresume_tty (tty);
+}
+
+DEFUN ("tty--output-buffer-size", Ftty__output_buffer_size,
+ Stty__output_buffer_size, 0, 1, 0, doc:
+ /* Return the output buffer size of TTY.
+
+TTY may be a terminal object, a frame, or nil (meaning the selected
+frame's terminal).
+
+A value of zero means TTY uses the system's default value. */)
+ (Lisp_Object tty)
+{
+ struct terminal *terminal = decode_tty_terminal (tty);
+ return make_fixnum (terminal->display_info.tty->output_buffer_size);
+}
+
/***********************************************************************
Mouse
@@ -4556,6 +4592,8 @@ trigger redisplay. */);
defsubr (&Stty_top_frame);
defsubr (&Ssuspend_tty);
defsubr (&Sresume_tty);
+ defsubr (&Stty__set_output_buffer_size);
+ defsubr (&Stty__output_buffer_size);
#ifdef HAVE_GPM
defsubr (&Sgpm_mouse_start);
defsubr (&Sgpm_mouse_stop);