Rename ui chat to log
parent
35589a5624
commit
7b5bc5aa41
2
chat.c
2
chat.c
|
@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
|
||||||
chat.user = strdup(chat.nick);
|
chat.user = strdup(chat.nick);
|
||||||
|
|
||||||
uiInit();
|
uiInit();
|
||||||
uiChat("Traveling...");
|
uiLog("Traveling...");
|
||||||
uiDraw();
|
uiDraw();
|
||||||
|
|
||||||
int sock = ircConnect(host, port, webPass);
|
int sock = ircConnect(host, port, webPass);
|
||||||
|
|
2
chat.h
2
chat.h
|
@ -40,7 +40,7 @@ void uiHide(void);
|
||||||
void uiDraw(void);
|
void uiDraw(void);
|
||||||
void uiRead(void);
|
void uiRead(void);
|
||||||
void uiTopic(const char *topic);
|
void uiTopic(const char *topic);
|
||||||
void uiChat(const char *line);
|
void uiLog(const char *line);
|
||||||
|
|
||||||
__attribute__((format(printf, 1, 2)))
|
__attribute__((format(printf, 1, 2)))
|
||||||
void uiFmt(const char *format, ...);
|
void uiFmt(const char *format, ...);
|
||||||
|
|
4
handle.c
4
handle.c
|
@ -58,9 +58,9 @@ static void handle432(char *prefix, char *params) {
|
||||||
shift(¶ms);
|
shift(¶ms);
|
||||||
shift(¶ms);
|
shift(¶ms);
|
||||||
char *mesg = shift(¶ms);
|
char *mesg = shift(¶ms);
|
||||||
uiChat("You can't use that name here");
|
uiLog("You can't use that name here");
|
||||||
uiFmt("Sheriff says, \"%s\"", mesg);
|
uiFmt("Sheriff says, \"%s\"", mesg);
|
||||||
uiChat("Type /nick <name> to choose a new one");
|
uiLog("Type /nick <name> to choose a new one");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle001(char *prefix, char *params) {
|
static void handle001(char *prefix, char *params) {
|
||||||
|
|
2
input.c
2
input.c
|
@ -60,7 +60,7 @@ static void inputNick(wchar_t *params) {
|
||||||
if (nick) {
|
if (nick) {
|
||||||
ircFmt("NICK %ls\r\n", nick);
|
ircFmt("NICK %ls\r\n", nick);
|
||||||
} else {
|
} else {
|
||||||
uiChat("/nick requires a name");
|
uiLog("/nick requires a name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
ui.c
28
ui.c
|
@ -37,12 +37,12 @@
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
static const int TOPIC_COLS = 512;
|
static const int TOPIC_COLS = 512;
|
||||||
static const int CHAT_LINES = 100;
|
|
||||||
static const int INPUT_COLS = 512;
|
static const int INPUT_COLS = 512;
|
||||||
|
static const int LOG_LINES = 100;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
WINDOW *topic;
|
WINDOW *topic;
|
||||||
WINDOW *chat;
|
WINDOW *log;
|
||||||
WINDOW *input;
|
WINDOW *input;
|
||||||
size_t cursor;
|
size_t cursor;
|
||||||
} ui;
|
} ui;
|
||||||
|
@ -67,10 +67,10 @@ void uiInit(void) {
|
||||||
ui.topic = newpad(2, TOPIC_COLS);
|
ui.topic = newpad(2, TOPIC_COLS);
|
||||||
mvwhline(ui.topic, 1, 0, ACS_HLINE, TOPIC_COLS);
|
mvwhline(ui.topic, 1, 0, ACS_HLINE, TOPIC_COLS);
|
||||||
|
|
||||||
ui.chat = newpad(CHAT_LINES, COLS);
|
ui.log = newpad(LOG_LINES, COLS);
|
||||||
wsetscrreg(ui.chat, 0, CHAT_LINES - 1);
|
wsetscrreg(ui.log, 0, LOG_LINES - 1);
|
||||||
scrollok(ui.chat, true);
|
scrollok(ui.log, true);
|
||||||
wmove(ui.chat, CHAT_LINES - (LINES - 4) - 1, 0);
|
wmove(ui.log, LOG_LINES - (LINES - 4) - 1, 0);
|
||||||
|
|
||||||
ui.input = newpad(2, INPUT_COLS);
|
ui.input = newpad(2, INPUT_COLS);
|
||||||
mvwhline(ui.input, 0, 0, ACS_HLINE, INPUT_COLS);
|
mvwhline(ui.input, 0, 0, ACS_HLINE, INPUT_COLS);
|
||||||
|
@ -79,8 +79,8 @@ void uiInit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uiResize(void) {
|
static void uiResize(void) {
|
||||||
wresize(ui.chat, CHAT_LINES, COLS);
|
wresize(ui.log, LOG_LINES, COLS);
|
||||||
wmove(ui.chat, CHAT_LINES - 1, COLS - 1);
|
wmove(ui.log, LOG_LINES - 1, COLS - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiHide(void) {
|
void uiHide(void) {
|
||||||
|
@ -98,8 +98,8 @@ void uiDraw(void) {
|
||||||
1, lastCol
|
1, lastCol
|
||||||
);
|
);
|
||||||
pnoutrefresh(
|
pnoutrefresh(
|
||||||
ui.chat,
|
ui.log,
|
||||||
CHAT_LINES - (LINES - 4), 0,
|
LOG_LINES - (LINES - 4), 0,
|
||||||
2, 0,
|
2, 0,
|
||||||
lastLine - 2, lastCol
|
lastLine - 2, lastCol
|
||||||
);
|
);
|
||||||
|
@ -194,9 +194,9 @@ void uiTopic(const char *topic) {
|
||||||
uiAdd(ui.topic, topic);
|
uiAdd(ui.topic, topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiChat(const char *line) {
|
void uiLog(const char *line) {
|
||||||
waddch(ui.chat, '\n');
|
waddch(ui.log, '\n');
|
||||||
uiAdd(ui.chat, line);
|
uiAdd(ui.log, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiFmt(const char *format, ...) {
|
void uiFmt(const char *format, ...) {
|
||||||
|
@ -206,7 +206,7 @@ void uiFmt(const char *format, ...) {
|
||||||
vasprintf(&buf, format, ap);
|
vasprintf(&buf, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
if (!buf) err(EX_OSERR, "vasprintf");
|
if (!buf) err(EX_OSERR, "vasprintf");
|
||||||
uiChat(buf);
|
uiLog(buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue