diff options
author | Jfreegman <Jfreegman@gmail.com> | 2013-08-02 21:36:01 -0400 |
---|---|---|
committer | Jfreegman <Jfreegman@gmail.com> | 2013-08-02 21:36:01 -0400 |
commit | 8fa074db5eb8c9b0ea9497d269725df0ff391321 (patch) | |
tree | 56eb1587b0d5c270a26b0ed909a5595330ace804 | |
parent | 948c82a0cb0fb0c925ab8c69f4c3dfffe8624216 (diff) |
cursor done better, fixed for chat windows
-rw-r--r-- | testing/toxic/chat.c | 3 | ||||
-rw-r--r-- | testing/toxic/friendlist.c | 1 | ||||
-rw-r--r-- | testing/toxic/main.c | 23 | ||||
-rw-r--r-- | testing/toxic/prompt.c | 1 |
4 files changed, 5 insertions, 23 deletions
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) { | |||
106 | } | 106 | } |
107 | 107 | ||
108 | static void chat_onDraw(ToxWindow* self) { | 108 | static void chat_onDraw(ToxWindow* self) { |
109 | curs_set(1); | ||
109 | int x, y; | 110 | int x, y; |
110 | ChatContext* ctx = (ChatContext*) self->x; | 111 | ChatContext* ctx = (ChatContext*) self->x; |
111 | 112 | ||
@@ -117,7 +118,7 @@ static void chat_onDraw(ToxWindow* self) { | |||
117 | 118 | ||
118 | wclear(ctx->linewin); | 119 | wclear(ctx->linewin); |
119 | mvwhline(ctx->linewin, 0, 0, '_', COLS); | 120 | mvwhline(ctx->linewin, 0, 0, '_', COLS); |
120 | mvwprintw(ctx->linewin, 1, 0, "%s\n", ctx->line); | 121 | mvwprintw(self->window, y-1, 0, "%s\n", ctx->line); |
121 | 122 | ||
122 | wrefresh(self->window); | 123 | wrefresh(self->window); |
123 | } | 124 | } |
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) { | |||
113 | } | 113 | } |
114 | 114 | ||
115 | static void friendlist_onDraw(ToxWindow* self) { | 115 | static void friendlist_onDraw(ToxWindow* self) { |
116 | curs_set(0); | ||
116 | size_t i; | 117 | size_t i; |
117 | 118 | ||
118 | wclear(self->window); | 119 | 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) { | |||
280 | wresize(w, LINES-2, COLS); | 280 | wresize(w, LINES-2, COLS); |
281 | } | 281 | } |
282 | 282 | ||
283 | /* | ||
284 | * Draws cursor relative to input on prompt window. | ||
285 | * Removes cursor on friends window and chat windows. | ||
286 | * | ||
287 | * TODO: Make it work for chat windows | ||
288 | */ | ||
289 | void position_cursor(WINDOW* w, char* title) | ||
290 | { | ||
291 | curs_set(1); | ||
292 | if (strcmp(title, "[prompt]") == 0) { // main/prompt window | ||
293 | int x, y; | ||
294 | getyx(w, y, x); | ||
295 | move(y, x); | ||
296 | } | ||
297 | else if (strcmp(title, "[friends]") == 0) // friends window | ||
298 | curs_set(0); | ||
299 | else // any other window (i.e chat) | ||
300 | curs_set(0); | ||
301 | } | ||
302 | |||
303 | int main(int argc, char* argv[]) { | 283 | int main(int argc, char* argv[]) { |
304 | int ch; | 284 | int ch; |
305 | ToxWindow* a; | 285 | ToxWindow* a; |
@@ -317,9 +297,8 @@ int main(int argc, char* argv[]) { | |||
317 | a = &windows[w_active]; | 297 | a = &windows[w_active]; |
318 | prepare_window(a->window); | 298 | prepare_window(a->window); |
319 | a->blink = false; | 299 | a->blink = false; |
320 | a->onDraw(a); | ||
321 | draw_bar(); | 300 | draw_bar(); |
322 | position_cursor(a->window, a->title); | 301 | a->onDraw(a); |
323 | 302 | ||
324 | // Handle input. | 303 | // Handle input. |
325 | ch = getch(); | 304 | 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) { | |||
287 | } | 287 | } |
288 | 288 | ||
289 | static void prompt_onDraw(ToxWindow* self) { | 289 | static void prompt_onDraw(ToxWindow* self) { |
290 | curs_set(1); | ||
290 | int x, y; | 291 | int x, y; |
291 | 292 | ||
292 | getyx(self->window, y, x); | 293 | getyx(self->window, y, x); |