This commit is contained in:
2025-11-21 22:57:08 -08:00
parent e830c79f9f
commit a3a987f6c4
7 changed files with 0 additions and 334 deletions

View File

@@ -1,57 +0,0 @@
VERSION := 0.9.2
CC ?= gcc
TARGET := ke
OBJS := main.o
LIBS :=
PREFIX ?= $PREFIX
MANDIR ?= $MANDIR
CFLAGS += -Wall -Wextra -pedantic -Wshadow -Werror -std=c99 -g
CFLAGS += -DKE_VERSION="\"$(TARGET) version $(VERSION)\""
CFLAGS += OS_CFLAGS
all: $(TARGET)
clean:
-rm -f .?*.* *.core *.o *.html tags $(TARGET) $(OBJS)
-rm -rf security
-rm -rf $(TARGET)-$(VERSION)
-rm -f $(TARGET)-$(VERSION).tgz
$(TARGET): $(OBJS)
${CC} -o $(TARGET) ${CFLAGS} ${LDFLAGS} $(LIBS) $(OBJS)
install: $(TARGET)
install -m 0755 $(TARGET) $(PREFIX)/bin/$(TARGET)
install -m 0755 -d $(MANDIR)/man1
install -m 0444 $(TARGET).1 $(MANDIR)/man1/$(TARGET).1
uninstall:
-rm -f $(PREFIX)/bin/$(TARGET)
-rm -f $(MANDIR)/man1/$(TARGET).1
lint:
-mkdir security
-rats -w 3 $(TARGET).[ch] > security/rats.out
-lint -fhrs $(TARGET).c > security/lint.out
-splint +posixlib $(TARGET).[ch] > security/splint.out
dist: clean
-mkdir $(TARGET)-$(VERSION)
-cp * $(TARGET)-$(VERSION)
-cd $(TARGET)-$(VERSION) && make distclean && cd ..
-tar czf $(TARGET)-$(VERSION).tgz $(TARGET)-$(VERSION)
distclean: clean
-rm -f Makefile
htmldoc:
-mandoc -Thtml $(TARGET).1 > $(TARGET).1.html
tags:
ctags *.[ch]
.c.o:
$(CC) -c ${CFLAGS} $?
.PHONY: clean all install lint uninstall dist distclean htmldoc tags

View File

@@ -1,73 +0,0 @@
#!/bin/sh
TARGET="$(cat Makefile.in | grep 'TARGET :=' | awk -F' ' '{ print $3; }')"
echo "configuring ${TARGET}"
which sed 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]
then
echo "cannot find sed!" 1>&2
fi
OPSYS=$(uname -s)
echo "Configuring for ${OPSYS}..."
if [ "x${OPSYS}" = "xLinux" ]
then
OS_CFLAGS="-D_DEFAULT_SOURCE -D_XOPEN_SOURCE"
OS_LIBS="-lbsd"
if [ "x${CC}" = "xclang" ]; then
OS_CFLAGS="${OS_CFLAGS} -fsanitize=memory"
fi
if [ -e "/usr/lib/libefence.a" ]
then
OS_LIBS="${OS_LIBS}" # -lefence"
fi
else
OS_CFLAGS=""
OS_LIBS=""
fi
if [ -z "${OS_CFLAGS}" ]
then
echo "${OPSYS} requires no extra build flags."
else
echo "${OPSYS} requires build flags ${OS_CFLAGS}"
fi
if [ -z "${OS_LIBS}" ]
then
echo "${OPSYS} requires no extra linkages."
else
echo "${OPSYS} requires linking with ${OS_LIBS}."
fi
if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local"
fi
if [ "${PREFIX}" = "/usr" ]
then
MANDIR="$(PREFIX)/share/man"
elif [ "${PREFIX}" = "/usr/local" ]
then
if [ "${OPSYS}" = "Darwin" ]
then
MANDIR="${PREFIX}/share/man"
else
MANDIR="${PREFIX}/man"
fi
else
MANDIR="${PREFIX}/man"
fi
echo "prefix: ${PREFIX}"
echo "mandir: ${MANDIR}"
echo "writing new Makefile"
cat Makefile.in | sed -e "s|OS_CFLAGS|${OS_CFLAGS}|" | \
sed -e "s|OS_LIBS|${OS_LIBS}|" | \
sed -e "s|\$PREFIX|${PREFIX}|" | \
sed -e "s|\$MANDIR|${MANDIR}|" > Makefile
echo "done."

View File

@@ -1,26 +0,0 @@
ESCAPE CODES
============
note: these will all omit the leading ESC[
https://vt100.net/docs/vt100-ug/chapter3.html
H reposition cursor @ 1,1
${row};${col}H reposition cursor @ ${row},${col}
J erase-in-display
0: cursor to end of screen
1: up to cursor
2: whole screen
K erase-in-line
0: (default) to the right of the cursor
1: to the left of the cursor
2: whole line
h set mode
l reset mode
modes:
?25 hide cursor feature
~ special keys?
5: pgup
6: pgdn
m coloring
7m: inverted
default: normal

View File

@@ -1,49 +0,0 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <wctype.h>
struct termios orig_termios;
void
disableRawMode()
{
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void
enableRawMode()
{
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_lflag &= ~(ECHO | ICANON);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int
main()
{
enableRawMode();
wchar_t c;
while (read(STDIN_FILENO, &c, sizeof(c)) > 0 && c != 'q') {
if (iswcntrl(c)) {
printf("$%02x\n", c);
} else {
printf("$%02x ('%lc')\n", c, c);
}
}
perror("read");
return 0;
}

View File

@@ -1,37 +0,0 @@
An Exploration of the Keys
==========================
ESC: 1b
Function keys: 1b followed by
F1 F2 F3 F4 F5 F6 F7 F8
4f O 4F O 4F O 4F O 5B 5B 5B 5B
50 P 51 Q 52 R 54 S 31 1 31 1 31 1 31 1
35 5 37 7 38 8 39 9
7E ~ 7E ~ 7E ~ 7E ~
F9 F10 F11 F12
5B [ 5B [ 5B [ 5B [
32 2 32 2 32 2 32 2
30 0 31 1 33 3 34 4
7E ~ 7E ~ 7E ~ 7E ~
DEL 7F - BUT IT SHOULD BE A 4-BYTE ESCAPE SEQUENCE?
BKSP 7F
Arrow keys: 1b followed by
UP DN LF RT
5b [ 5b [ 5b [ 5b [
41 A 42 B 44 D 43 C
Other keys: 1b followed by
HOME END PGUP PGDN INS
5b [ 5b [ 5b [ 5b [ 5b [
48 H 46 F 35 5 36 6 32 2
7e ~ 7e ~ 7e ~
Notes: any time you see escape, you must process another key to figure
out what to do.

View File

@@ -1,91 +0,0 @@
static void
enable_termraw()
{
struct termios raw;
/* Read the current terminal parameters for standard input. */
if (tcgetattr(STDIN_FILENO, &raw) == -1) {
die("tcgetattr while enabling raw mode");
}
/*
* Turn off software flow control. IXON: disable flow control,
* so named because XON and XOFF :)
*
* ICRNL: Don't interpret carriage returns as newlines.
*
* raw.c_iflag &= ~(ICRNL|IXON|BRKINT|INPCK|ISTRIP);
*/
/*
* Turn off the terminal's conversion of newlines -> carriage
* return + newline.
*
* raw.c_oflag &= ~(OPOST);
*/
/*
* Turn off the local ECHO mode, which we need to do in raw mode
* because what gets displayed is going to need extra control.
*
* ICANON: Turn off canonical mode.
*
* ISIG: Turn off SIGINT / SIGSTP processing.
*
* IEXTEN: turn off ^v processing.
*
* NOTE(kyle): look into cfmakeraw, which will require
* snapshotting. However, this skips all the notes about what
* it takes to put the terminal in raw mode.
*
* raw.c_lflag &= ~(ECHO|ICANON|ISIG|IEXTEN);
*/
/*
* The following are probably not really needed on modern
* terminals, but it's fashionable to do as much.
*
* BRKINT: break conditions trigger SIGINT.
*
* INPCK: parity checking, which might be useful over serial
* terminals?
*
* ISTRIP strips the high bit.
*
* CS: set character size to 8-bit.
* raw.c_iflag &= ~(BRKINT | INPCK | ISTRIP);
*
* NOTE(kyle): I had this set here, but then it turns out
* that it fuckled my terminal.
* raw.c_cflag |= CS8;
*/
/*
* Switched over to cfmakeraw.
*/
cfmakeraw(&raw);
/*
* Set timeout for read(2).
*
* VMIN: what is the minimum number of bytes required for read
* to return?
*
* VTIME: max time before read(2) returns in hundreds of milli-
* seconds.
*/
raw.c_cc[VMIN] = 0;
raw.c_cc[VTIME] = 1;
/*
* Now write the terminal parameters to the current terminal,
* after flushing any waiting input out.
*/
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1) {
die("tcsetattr while enabling raw mode");
}
}
So this is a really long line; it should overflow the buffer and it's helpful for doing things like testing horizontal scrolling. Furthermore, it's at least twice as long as the line is likely to be, so there's more opportunity to test whether scrolling works correctly.
But this line is nominal.

View File

@@ -1 +0,0 @@
hello world s ome tex t for you