Browse Source

Disable terminal flow control

This opens up C-o, C-q and C-s for key bindings without C-v.
master
Causal Agent 6 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 {
TermPasteEnd,
};
void termInit(void);
void termNoFlow(void);
void termTitle(const char *title);
void termMode(enum TermMode mode, bool set);
enum TermEvent termEvent(char ch);

+ 11
- 0
term.c View File

@@ -18,6 +18,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>

#include "chat.h"

@@ -28,6 +30,15 @@ void termInit(void) {
xterm = term && !strncmp(term, "xterm", 5);
}

void termNoFlow(void) {
struct termios attr;
int error = tcgetattr(STDIN_FILENO, &attr);
if (error) return;
attr.c_iflag &= ~IXON;
attr.c_cc[VDISCARD] = _POSIX_VDISABLE;
tcsetattr(STDIN_FILENO, TCSANOW, &attr);
}

void termTitle(const char *title) {
if (!xterm) return;
printf("\33]0;%s\33\\", title);

+ 1
- 0
ui.c View File

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

Loading…
Cancel
Save