1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 02:33:02 +01:00

didn't mean to delete that

This commit is contained in:
Jfreegman 2013-08-04 05:00:16 -04:00
parent 6ea6af557b
commit 18dcb06920

11
chat.c
View File

@ -94,6 +94,11 @@ int string_is_empty(char *string)
static void chat_onKey(ToxWindow* self, int key) { static void chat_onKey(ToxWindow* self, int key) {
ChatContext* ctx = (ChatContext*) self->x; ChatContext* ctx = (ChatContext*) self->x;
time_t now;
time(&now);
struct tm * timeinfo;
timeinfo = localtime(&now);
/* PRINTABLE characters: Add to line */ /* PRINTABLE characters: Add to line */
if(isprint(key)) { if(isprint(key)) {
if(ctx->pos != sizeof(ctx->line)-1) { if(ctx->pos != sizeof(ctx->line)-1) {
@ -107,11 +112,15 @@ static void chat_onKey(ToxWindow* self, int key) {
if (ctx->line[0] == '/') if (ctx->line[0] == '/')
execute(self, ctx, ctx->line); execute(self, ctx, ctx->line);
else { else {
if(!string_is_empty(ctx->line)) {
/* make sure the string has at least non-space character */
wattron(ctx->history, COLOR_PAIR(2));
wprintw(ctx->history, "%02d:%02d:%02d ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
wattron(ctx->history, COLOR_PAIR(1)); wattron(ctx->history, COLOR_PAIR(1));
wprintw(ctx->history, "you: ", ctx->line); wprintw(ctx->history, "you: ", ctx->line);
wattroff(ctx->history, COLOR_PAIR(1)); wattroff(ctx->history, COLOR_PAIR(1));
wprintw(ctx->history, "%s\n", ctx->line); wprintw(ctx->history, "%s\n", ctx->line);
}
if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) { if(m_sendmessage(ctx->friendnum, (uint8_t*) ctx->line, strlen(ctx->line)+1) < 0) {
wattron(ctx->history, COLOR_PAIR(3)); wattron(ctx->history, COLOR_PAIR(3));
wprintw(ctx->history, " * Failed to send message.\n"); wprintw(ctx->history, " * Failed to send message.\n");