aboutsummaryrefslogtreecommitdiff
path: root/src/ui.c.old
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-02-17 03:45:41 -0500
committerB. Watson <urchlay@slackware.uk>2026-02-17 03:45:41 -0500
commitf1bf0a483e917b67cf9db6483072db261f7688c3 (patch)
tree66fc917d1c224f891eb57a6a59710b73569482ba /src/ui.c.old
parent4187e2f3bd0d12e37c494cb990bf4fbd7885555e (diff)
downloadfujinet-chat-f1bf0a483e917b67cf9db6483072db261f7688c3.tar.gz
Start welding the new UI code to the client. Compiles but doesn't work yet...
Diffstat (limited to 'src/ui.c.old')
-rw-r--r--src/ui.c.old73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/ui.c.old b/src/ui.c.old
new file mode 100644
index 0000000..68f32a0
--- /dev/null
+++ b/src/ui.c.old
@@ -0,0 +1,73 @@
+#include <atari.h>
+#include <stdio.h>
+#include "irc.h"
+#include <conio.h>
+#include "conio.h"
+
+#define MAX_INPUT_LEN 119
+
+static char input_buffer[MAX_INPUT_LEN + 1];
+static short inbuf_len = 0;
+
+void ui_init(void) {
+ OS.escflg = 0;
+ inbuf_len = input_buffer[0] = 0;
+}
+
+void ui_start_msg() {
+ /* TODO: use msg_src and msg_dest to decide which window to
+ print to (when we have multi-window support) */
+ OS.crsinh = 1;
+ putchar(CH_DELLINE);
+}
+
+void ui_end_msg(void) {
+ OS.crsinh = 0;
+ // putchar(CH_EOL); // NO!
+ if(inbuf_len) print(input_buffer);
+}
+
+void ui_print(const char *str) {
+ OS.escflg = 0x80;
+ print(str);
+ OS.escflg = 0;
+}
+
+void ui_putchar(char c) {
+ putchar(c);
+}
+
+void ui_keystroke(void) {
+ char c;
+
+ OS.escflg = 0x80;
+
+ /* pressing ctrl-3 (aka EOF) crashes cc65-compiled binaries *hard*,
+ so don't allow it. */
+ if(OS.ch == (KEY_3 | KEY_CTRL)) {
+ OS.ch = KEY_NONE;
+ return;
+ }
+
+ c = cgetc();
+
+ if(c == CH_EOL && !inbuf_len)
+ return; /* ignore empty message */
+
+ if(c == CH_DEL && inbuf_len) {
+ OS.escflg = 0;
+ putchar(c);
+ OS.escflg = 0x80;
+ input_buffer[inbuf_len--] = 0;
+ } else if(inbuf_len == MAX_INPUT_LEN) {
+ return; /* ignore */
+ } else {
+ putchar(c);
+ input_buffer[inbuf_len++] = c;
+ input_buffer[inbuf_len] = 0;
+ if(c == CH_EOL) {
+ cmd_command(input_buffer);
+ ui_init();
+ }
+ }
+}