Browse Source

Disable terminal flow control

This opens up C-o, C-q and C-s for key bindings without C-v.
Causal Agent 2 months ago
parent
commit
facc3aa9a0
Signed by: Curtis McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
3 changed files with 13 additions and 0 deletions
  1. 1
    0
      chat.h
  2. 11
    0
      term.c
  3. 1
    0
      ui.c

+ 1
- 0
chat.h View File

@@ -145,6 +145,7 @@ enum TermEvent {
145 145
 	TermPasteEnd,
146 146
 };
147 147
 void termInit(void);
148
+void termNoFlow(void);
148 149
 void termTitle(const char *title);
149 150
 void termMode(enum TermMode mode, bool set);
150 151
 enum TermEvent termEvent(char ch);

+ 11
- 0
term.c View File

@@ -18,6 +18,8 @@
18 18
 #include <stdio.h>
19 19
 #include <stdlib.h>
20 20
 #include <string.h>
21
+#include <termios.h>
22
+#include <unistd.h>
21 23
 
22 24
 #include "chat.h"
23 25
 
@@ -28,6 +30,15 @@ void termInit(void) {
28 30
 	xterm = term && !strncmp(term, "xterm", 5);
29 31
 }
30 32
 
33
+void termNoFlow(void) {
34
+	struct termios attr;
35
+	int error = tcgetattr(STDIN_FILENO, &attr);
36
+	if (error) return;
37
+	attr.c_iflag &= ~IXON;
38
+	attr.c_cc[VDISCARD] = _POSIX_VDISABLE;
39
+	tcsetattr(STDIN_FILENO, TCSANOW, &attr);
40
+}
41
+
31 42
 void termTitle(const char *title) {
32 43
 	if (!xterm) return;
33 44
 	printf("\33]0;%s\33\\", title);

+ 1
- 0
ui.c View File

@@ -189,6 +189,7 @@ void uiInit(void) {
189 189
 	cbreak();
190 190
 	noecho();
191 191
 	termInit();
192
+	termNoFlow();
192 193
 	colorInit();
193 194
 	ui.status = newwin(1, COLS, 0, 0);
194 195
 	ui.input = newpad(1, 512);

Loading…
Cancel
Save