about summary refs log tree commit diff
path: root/chat.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-10 23:31:20 -0400
committerJune McEnroe <june@causal.agency>2018-08-10 23:31:20 -0400
commit07c750d25cf26883507d46bf319e55d2e35d6a94 (patch)
treedcf7dbc50dd717a1190c2f034ff440badf5a525c /chat.h
parentMove process spawning onto the event loop (diff)
downloadcatgirl-07c750d25cf26883507d46bf319e55d2e35d6a94.tar.gz
catgirl-07c750d25cf26883507d46bf319e55d2e35d6a94.zip
Become multi-channel
There's a lot of UI missing for it, but it technically works.
Diffstat (limited to '')
-rw-r--r--chat.h104
1 files changed, 67 insertions, 37 deletions
diff --git a/chat.h b/chat.h
index 9a1b855..9219334 100644
--- a/chat.h
+++ b/chat.h
@@ -30,18 +30,23 @@ struct {
 	char *nick;
 	char *user;
 	char *join;
-} chat;
+} self;
 
-void spawn(char *const argv[]);
+void selfNick(const char *nick);
+void selfUser(const char *user);
+void selfJoin(const char *join);
 
-int ircConnect(
-	const char *host, const char *port, const char *pass, const char *webPass
-);
-void ircRead(void);
-void ircWrite(const char *ptr, size_t len);
+struct Tag {
+	size_t id;
+	const char *name;
+};
 
-__attribute__((format(printf, 1, 2)))
-void ircFmt(const char *format, ...);
+enum { TAGS_LEN = 256 };
+const struct Tag TAG_ALL;
+const struct Tag TAG_DEFAULT;
+struct Tag tagFor(const char *name);
+struct Tag tagName(const char *name);
+struct Tag tagNum(size_t num);
 
 enum {
 	IRC_BOLD      = 002,
@@ -52,47 +57,72 @@ enum {
 	IRC_UNDERLINE = 037,
 };
 
+void handle(char *line);
+void input(struct Tag tag, char *line);
+void inputTab(void);
+
+int ircConnect(
+	const char *host, const char *port, const char *pass, const char *webPass
+);
+void ircRead(void);
+void ircWrite(const char *ptr, size_t len);
+void ircFmt(const char *format, ...) __attribute__((format(printf, 1, 2)));
+
 void uiInit(void);
 void uiHide(void);
 void uiExit(void);
 void uiDraw(void);
 void uiBeep(void);
 void uiRead(void);
-void uiTopic(const wchar_t *topic);
-void uiTopicStr(const char *topic);
-void uiLog(const wchar_t *line);
-void uiFmt(const wchar_t *format, ...);
-
-// HACK: clang won't check wchar_t *format strings.
-#ifdef NDEBUG
-#define uiFmt(format, ...) uiFmt(L##format, __VA_ARGS__)
-#else
-#define uiFmt(format, ...) do { \
-	snprintf(NULL, 0, format, __VA_ARGS__); \
-	uiFmt(L##format, __VA_ARGS__); \
-} while(0)
-#endif
-
+void uiFocus(struct Tag tag);
+void uiTopic(struct Tag tag, const char *topic);
+void uiLog(struct Tag tag, const wchar_t *line);
+void uiFmt(struct Tag tag, const wchar_t *format, ...);
+
+enum Edit {
+	EDIT_LEFT,
+	EDIT_RIGHT,
+	EDIT_HOME,
+	EDIT_END,
+	EDIT_BACK_WORD,
+	EDIT_FORE_WORD,
+	EDIT_INSERT,
+	EDIT_BACKSPACE,
+	EDIT_DELETE,
+	EDIT_KILL_BACK_WORD,
+	EDIT_KILL_FORE_WORD,
+	EDIT_KILL_LINE,
+	EDIT_COMPLETE,
+	EDIT_ENTER,
+};
+void edit(struct Tag tag, enum Edit op, wchar_t ch);
 const wchar_t *editHead(void);
 const wchar_t *editTail(void);
-bool edit(bool meta, bool ctrl, wchar_t ch);
-
-void handle(char *line);
-
-void inputTab(void);
-void input(char *line);
-
-void urlScan(const char *str);
-void urlList(void);
-void urlOpen(size_t i);
 
-void tabTouch(const char *word);
-void tabRemove(const char *word);
+void tabTouch(struct Tag tag, const char *word);
+void tabRemove(struct Tag tag, const char *word);
+void tabClear(struct Tag tag);
 void tabReplace(const char *prev, const char *next);
-const char *tabNext(const char *prefix);
+const char *tabNext(struct Tag tag, const char *prefix);
 void tabAccept(void);
 void tabReject(void);
 
+void urlScan(struct Tag tag, const char *str);
+void urlList(struct Tag tag);
+void urlOpen(struct Tag tag, size_t fromEnd);
+
+void spawn(char *const argv[]);
+
 wchar_t *ambstowcs(const char *src);
 char *awcstombs(const wchar_t *src);
 int vaswprintf(wchar_t **ret, const wchar_t *format, va_list ap);
+
+// HACK: clang won't check wchar_t *format strings.
+#ifdef NDEBUG
+#define uiFmt(tag, format, ...) uiFmt(tag, L##format, __VA_ARGS__)
+#else
+#define uiFmt(tag, format, ...) do { \
+	snprintf(NULL, 0, format, __VA_ARGS__); \
+	uiFmt(tag, L##format, __VA_ARGS__); \
+} while(0)
+#endif