1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-08 09:06:46 +02:00

toxic: Made everything 1000x more userfriendly.

This commit is contained in:
plutooo
2013-07-31 11:20:16 -07:00
parent 7290527cdc
commit 9559e37cfb
5 changed files with 79 additions and 24 deletions

27
chat.c
View File

@ -1,3 +1,7 @@
/*
* Toxic -- Tox Curses Client
*/
#include <curses.h>
#include <stdlib.h>
#include <string.h>
@ -38,7 +42,13 @@ static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len)
fix_name(msg);
fix_name(nick);
wprintw(ctx->history, "%s: %s\n", nick, msg);
wattron(ctx->history, COLOR_PAIR(4));
wprintw(ctx->history, "%s: ", nick);
wattroff(ctx->history, COLOR_PAIR(4));
wprintw(ctx->history, "%s\n", msg);
self->blink = true;
}
static void chat_onNickChange(ToxWindow* self, int num, uint8_t* nick, uint16_t len) {
@ -70,15 +80,27 @@ static void chat_onKey(ToxWindow* self, int key) {
}
}
else if(key == '\n') {
wprintw(ctx->history, "you: %s\n", ctx->line);
wattron(ctx->history, COLOR_PAIR(1));
wprintw(ctx->history, "you: ", ctx->line);
wattroff(ctx->history, COLOR_PAIR(1));
wprintw(ctx->history, "%s\n", ctx->line);
if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) {
wattron(ctx->history, COLOR_PAIR(3));
wprintw(ctx->history, " * Failed to send message.\n");
wattroff(ctx->history, COLOR_PAIR(3));
}
ctx->line[0] = '\0';
ctx->pos = 0;
}
else if(key == 0x107) {
if(ctx->pos != 0) {
ctx->line[--ctx->pos] = '\0';
}
}
}
static void chat_onDraw(ToxWindow* self) {
@ -105,7 +127,6 @@ static void chat_onInit(ToxWindow* self) {
getmaxyx(self->window, y, x);
ctx->history = subwin(self->window, y - 4, x, 0, 0);
wprintw(ctx->history, "Here goes chat\n");
scrollok(ctx->history, 1);
ctx->linewin = subwin(self->window, 2, x, y - 3, 0);