summary refs log tree commit diff
path: root/bin/edi/edi.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/edi/edi.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/bin/edi/edi.h b/bin/edi/edi.h
new file mode 100644
index 00000000..ced4f4a9
--- /dev/null
+++ b/bin/edi/edi.h
@@ -0,0 +1,86 @@
+/* Copyright (C) 2018  June McEnroe <june@causal.agency>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include <wchar.h>
+
+struct Span {
+	size_t at, to;
+};
+
+static inline struct Span spanNext(struct Span span, size_t len) {
+	return (struct Span) { span.to, span.to + len };
+}
+
+struct Slice {
+	const wchar_t *ptr;
+	size_t len;
+};
+
+struct Buffer {
+	size_t cap;
+	size_t len;
+	struct Slice slice;
+	struct Block {
+		struct Block *prev;
+		wchar_t chars[];
+	} *block;
+};
+
+struct Buffer bufferAlloc(size_t cap);
+void bufferFree(struct Buffer *buf);
+void bufferInsert(struct Buffer *buf);
+void bufferAppend(struct Buffer *buf, wchar_t ch);
+wchar_t *bufferDest(struct Buffer *buf, size_t len);
+
+struct Table {
+	size_t len;
+	struct Slice slices[];
+};
+
+struct Table *tableInsert(const struct Table *prev, size_t at, struct Slice slice);
+struct Table *tableDelete(const struct Table *prev, struct Span del);
+
+struct Log {
+	size_t cap;
+	size_t len;
+	size_t index;
+	struct State {
+		struct Table *table;
+		size_t prev;
+		size_t next;
+	} *states;
+};
+
+struct Log logAlloc(size_t cap);
+void logFree(struct Log *log);
+void logPush(struct Log *log, struct Table *table);
+
+static inline struct Table *logTable(struct Log *log) {
+	return log->states[log->index].table;
+}
+static inline void logPrev(struct Log *log) {
+	log->index = log->states[log->index].prev;
+}
+static inline void logNext(struct Log *log) {
+	log->index = log->states[log->index].next;
+}
+static inline void logBack(struct Log *log) {
+	if (log->index) log->index--;
+}
+static inline void logFore(struct Log *log) {
+	if (log->index + 1 < log->len) log->index++;
+}
href='/src/commit/home/.config/cwm/cwmrc?id=21b0300a4ddbebc32447a5f0e58d587feffa2d3f&follow=1'>Add bindings for brightness controlJune McEnroe Weirdly the Fn key doesn't change how the F row registers... I wonder if I can do something about that. 2021-02-07Set X key repeat rateJune McEnroe 2021-02-07Bump font size to 12June McEnroe 11 is what I use on macOS, but I feel like my eyes are working harder here. 2021-02-07Fully configure and rebind cwmJune McEnroe This is sort of a mix of trying to emulate macOS somewhat for my muscle memory and just rebinding some of the cwm defaults to use 4- rather than M-. 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe cwm still needs a lot more rebinding, and I need to actually look at its other options. xterm definitely still needs some configuration, but I at least managed to get it to use a decent looking font. Very happy that OpenBSD includes Luxi Mono, which is what my usual font, Go Mono, is based on anyway. Still missing is xmodmap and such. 2021-02-06Add xterm output to schemeJune McEnroe