From 8fa074db5eb8c9b0ea9497d269725df0ff391321 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Fri, 2 Aug 2013 21:36:01 -0400 Subject: cursor done better, fixed for chat windows --- testing/toxic/chat.c | 3 ++- testing/toxic/friendlist.c | 1 + testing/toxic/main.c | 23 +---------------------- testing/toxic/prompt.c | 1 + 4 files changed, 5 insertions(+), 23 deletions(-) (limited to 'testing') diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index 854d3817..1bfd94f5 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c @@ -106,6 +106,7 @@ static void chat_onKey(ToxWindow* self, int key) { } static void chat_onDraw(ToxWindow* self) { + curs_set(1); int x, y; ChatContext* ctx = (ChatContext*) self->x; @@ -117,7 +118,7 @@ static void chat_onDraw(ToxWindow* self) { wclear(ctx->linewin); mvwhline(ctx->linewin, 0, 0, '_', COLS); - mvwprintw(ctx->linewin, 1, 0, "%s\n", ctx->line); + mvwprintw(self->window, y-1, 0, "%s\n", ctx->line); wrefresh(self->window); } diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c index f9a413f9..b4b619a2 100644 --- a/testing/toxic/friendlist.c +++ b/testing/toxic/friendlist.c @@ -113,6 +113,7 @@ static void friendlist_onKey(ToxWindow* self, int key) { } static void friendlist_onDraw(ToxWindow* self) { + curs_set(0); size_t i; wclear(self->window); diff --git a/testing/toxic/main.c b/testing/toxic/main.c index c596b708..bcfc487f 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c @@ -280,26 +280,6 @@ void prepare_window(WINDOW* w) { wresize(w, LINES-2, COLS); } -/* - * Draws cursor relative to input on prompt window. - * Removes cursor on friends window and chat windows. - * - * TODO: Make it work for chat windows - */ -void position_cursor(WINDOW* w, char* title) -{ - curs_set(1); - if (strcmp(title, "[prompt]") == 0) { // main/prompt window - int x, y; - getyx(w, y, x); - move(y, x); - } - else if (strcmp(title, "[friends]") == 0) // friends window - curs_set(0); - else // any other window (i.e chat) - curs_set(0); -} - int main(int argc, char* argv[]) { int ch; ToxWindow* a; @@ -317,9 +297,8 @@ int main(int argc, char* argv[]) { a = &windows[w_active]; prepare_window(a->window); a->blink = false; - a->onDraw(a); draw_bar(); - position_cursor(a->window, a->title); + a->onDraw(a); // Handle input. ch = getch(); diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index b0f83811..484f5906 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -287,6 +287,7 @@ static void prompt_onKey(ToxWindow* self, int key) { } static void prompt_onDraw(ToxWindow* self) { + curs_set(1); int x, y; getyx(self->window, y, x); -- cgit v1.2.3