aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/textadept.c
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2022-03-23 17:46:49 -0400
committerGravatar Benjamin Barenblat <bbaren@google.com>2022-03-23 17:59:37 -0400
commit866c123c1cf161bf9046a0ab8209902ac994e273 (patch)
tree549d7201a534b011dac1ae78f1992b898c35ea31 /src/textadept.c
parente5995723976bba046c104cf988327a9c65d64e02 (diff)
Support software flow controlHEADdefault
Add a new `-p` / `--preserve` flag to textadept-curses. When specified, don’t grab the XON and XOFF control characters from the TTY driver. This allows textadept-curses to run effectively on serial terminals that use XON/XOFF flow control. The `-p` flag was chosen to align with nano, where it has the same behavior.
Diffstat (limited to 'src/textadept.c')
-rw-r--r--src/textadept.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/textadept.c b/src/textadept.c
index a5e8ddbc..b34adc2a 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -2473,7 +2473,21 @@ int main(int argc, char **argv) {
#if GTK
gtk_init(&argc, &argv);
#elif CURSES
- ta_tk = termkey_new(0, 0);
+ int termkey_flags = 0;
+ for (int i = 0; i < argc; i++) {
+ if (strcmp("-p", argv[i]) == 0 || strcmp("--preserve", argv[i]) == 0) {
+ termkey_flags |= TERMKEY_FLAG_FLOWCONTROL;
+
+ // Remove -p/--preserve from the argument list so it doesn't get interpreted as a session
+ // name.
+ memmove(argv + i, argv + i + 1, (argc - 1 - i) * sizeof(*argv));
+ argc--;
+
+ break;
+ }
+ }
+
+ ta_tk = termkey_new(0, termkey_flags);
setlocale(LC_CTYPE, ""); // for displaying UTF-8 characters properly
initscr(); // raw()/cbreak() and noecho() are taken care of in libtermkey
#if NCURSES_REENTRANT