From de1e61bd5ad4fefd9563b460f8137942cb0d01cd Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Fri, 4 Jul 2014 13:24:18 -0400 Subject: [PATCH] code cleanup, improve welcome message --- README.md | 4 ++-- src/chat.c | 7 ++----- src/groupchat.c | 9 +++------ src/help.c | 4 ++++ src/line_info.h | 2 +- src/prompt.c | 26 ++++++++++++-------------- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index ddb345b..2158da4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Toxic [![Build Status](https://travis-ci.org/Tox/toxic.png?branch=master)](https://travis-ci.org/Tox/toxic) -Toxic is an ncurses-based instant messaging client for [Tox](https://tox.im) which formerly resided in the [Tox core repository](https://github.com/irungentoo/toxcore), and is now available as a standalone application. +Toxic is a [Tox](https://tox.im)-based instant messanging client which formerly resided in the [Tox core repository](https://github.com/irungentoo/toxcore), and is now available as a standalone application. -![Toxic Screenshot](https://i.imgur.com/LdXXM62.png "Main Screen"). +![Toxic Screenshot](https://i.imgur.com/AOnp7oD.png "Main Screen"). ## Installation diff --git a/src/chat.c b/src/chat.c index 7d50030..e8a2f7a 100644 --- a/src/chat.c +++ b/src/chat.c @@ -875,15 +875,12 @@ static void chat_onInit(ToxWindow *self, Tox *m) ctx->history = subwin(self->window, y2 - CHATBOX_HEIGHT + 1, x2, 0, 0); ctx->linewin = subwin(self->window, CHATBOX_HEIGHT, x2, y2 - CHATBOX_HEIGHT, 0); - ctx->hst = malloc(sizeof(struct history)); - ctx->log = malloc(sizeof(struct chatlog)); + ctx->hst = calloc(1, sizeof(struct history)); + ctx->log = calloc(1, sizeof(struct chatlog)); if (ctx->log == NULL || ctx->hst == NULL) exit_toxic_err("failed in chat_onInit", FATALERR_MEMORY); - memset(ctx->hst, 0, sizeof(struct history)); - memset(ctx->log, 0, sizeof(struct chatlog)); - line_info_init(ctx->hst); if (friends[self->num].logging_on) diff --git a/src/groupchat.c b/src/groupchat.c index 12c2dd9..df792b5 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -503,15 +503,12 @@ static void groupchat_onInit(ToxWindow *self, Tox *m) ctx->linewin = subwin(self->window, CHATBOX_HEIGHT, x2, y2 - CHATBOX_HEIGHT, 0); ctx->sidebar = subwin(self->window, y2 - CHATBOX_HEIGHT + 1, SIDEBAR_WIDTH, 0, x2 - SIDEBAR_WIDTH); - ctx->hst = malloc(sizeof(struct history)); - ctx->log = malloc(sizeof(struct chatlog)); + ctx->hst = calloc(1, sizeof(struct history)); + ctx->log = calloc(1, sizeof(struct chatlog)); if (ctx->log == NULL || ctx->hst == NULL) exit_toxic_err("failed in groupchat_onInit", FATALERR_MEMORY); - memset(ctx->hst, 0, sizeof(struct history)); - memset(ctx->log, 0, sizeof(struct chatlog)); - line_info_init(ctx->hst); if (user_settings->autolog == AUTOLOG_ON) @@ -538,7 +535,7 @@ ToxWindow new_group_chat(Tox *m, int groupnum) ret.onGroupNamelistChange = &groupchat_onGroupNamelistChange; ret.onGroupAction = &groupchat_onGroupAction; - snprintf(ret.name, sizeof(ret.name), "Room #%d", groupnum); + snprintf(ret.name, sizeof(ret.name), "Group %d", groupnum); ChatContext *chatwin = calloc(1, sizeof(ChatContext)); Help *help = calloc(1, sizeof(Help)); diff --git a/src/help.c b/src/help.c index fbc0460..162ba6c 100644 --- a/src/help.c +++ b/src/help.c @@ -233,7 +233,11 @@ void help_onKey(ToxWindow *self, wint_t key) break; case 'g': +#ifdef _SUPPORT_AUDIO help_init_window(self, 21, 80); +#else + help_init_window(self, 17, 80); +#endif self->help->type = HELP_GLOBAL; break; diff --git a/src/line_info.h b/src/line_info.h index 86c3858..1315b1f 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -27,7 +27,7 @@ #include "toxic.h" #define MAX_HISTORY 10000 -#define MIN_HISTORY 20 +#define MIN_HISTORY 40 #define MAX_QUEUE 128 enum { diff --git a/src/prompt.c b/src/prompt.c index 48ef8a6..c45b89a 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -367,17 +367,18 @@ static void print_welcome_msg(ToxWindow *self) { ChatContext *ctx = self->chatwin; - line_info_add(self, NULL, NULL, NULL, " |_ _|____ _(_) ___ ", SYS_MSG, 1, BLUE); - line_info_add(self, NULL, NULL, NULL, " | |/ _ \\ \\/ / |/ __|", SYS_MSG, 1, BLUE); - line_info_add(self, NULL, NULL, NULL, " | | (_) > <| | (__ ", SYS_MSG, 1, BLUE); - line_info_add(self, NULL, NULL, NULL, " |_|\\___/_/\\_\\_|\\___|", SYS_MSG, 1, BLUE); + line_info_add(self, NULL, NULL, NULL, " _____ _____ _____ ____ ", SYS_MSG, 1, BLUE); + line_info_add(self, NULL, NULL, NULL, " |_ _/ _ \\ \\/ /_ _/ ___|", SYS_MSG, 1, BLUE); + line_info_add(self, NULL, NULL, NULL, " | || | | \\ / | | | ", SYS_MSG, 1, BLUE); + line_info_add(self, NULL, NULL, NULL, " | || |_| / \\ | | |___ ", SYS_MSG, 1, BLUE); + line_info_add(self, NULL, NULL, NULL, " |_| \\___/_/\\_\\___\\____|", SYS_MSG, 1, BLUE); line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0); - uint8_t *msg = "Welcome to Toxic, a free open source messenger client for Tox. Type /help for a"\ - " list of commands and key bindings. Further help may be found via the man page."; - line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, 0); - line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 1, 0); - + uint8_t *msg = "Welcome to Toxic, a free, open source Tox-based instant messenging client."; + line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN); + msg = "Type \"/help\" for assistance. Further help may be found via the man page."; + line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 1, CYAN); + line_info_add(self, NULL, NULL, NULL, "", SYS_MSG, 0, 0); } static void prompt_onInit(ToxWindow *self, Tox *m) @@ -390,15 +391,12 @@ static void prompt_onInit(ToxWindow *self, Tox *m) ctx->history = subwin(self->window, y2 - CHATBOX_HEIGHT + 1, x2, 0, 0); ctx->linewin = subwin(self->window, CHATBOX_HEIGHT, x2, y2 - CHATBOX_HEIGHT, 0); - ctx->log = malloc(sizeof(struct chatlog)); - ctx->hst = malloc(sizeof(struct history)); + ctx->log = calloc(1, sizeof(struct chatlog)); + ctx->hst = calloc(1, sizeof(struct history)); if (ctx->log == NULL || ctx->hst == NULL) exit_toxic_err("failed in prompt_onInit", FATALERR_MEMORY); - memset(ctx->log, 0, sizeof(struct chatlog)); - memset(ctx->hst, 0, sizeof(struct history)); - line_info_init(ctx->hst); if (user_settings->autolog == AUTOLOG_ON) {