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 From dd6f44a2c722068067ac665f3cffed494d609216 Mon Sep 17 00:00:00 2001 From: g Date: Sat, 3 Aug 2013 15:59:46 +0800 Subject: Added break Statement --- testing/toxic/prompt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'testing') diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index b0f83811..b248b63a 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -140,6 +140,7 @@ static void execute(ToxWindow* self, char* cmd) { break; case -2: wprintw(self->window, "Please add a message to your request.\n"); + break; case -3: wprintw(self->window, "That appears to be your own ID.\n"); break; -- cgit v1.2.3 From d5493bb24f6afe7854ade088f1f4291c3ad58e9b Mon Sep 17 00:00:00 2001 From: Michael Kress Date: Sat, 3 Aug 2013 13:27:52 +0200 Subject: added backspace to nTox; removed trailing spaces --- testing/nTox.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'testing') diff --git a/testing/nTox.c b/testing/nTox.c index 24d40ead..13db58d7 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with Tox. If not, see . - * + * */ #include "nTox.h" #include "misc_tools.h" @@ -54,7 +54,7 @@ void get_id(char *data) { if (self_public_key[i] < (PUB_KEY_BYTES / 2)) strcpy(idstring1[i],"0"); - else + else strcpy(idstring1[i], ""); sprintf(idstring2[i], "%hhX",self_public_key[i]); } @@ -71,9 +71,9 @@ void get_id(char *data) void new_lines(char *line) { int i = 0; - for (i = HISTORY-1; i > 0; i--) + for (i = HISTORY-1; i > 0; i--) strncpy(lines[i], lines[i-1], STRING_LENGTH - 1); - + strncpy(lines[0], line, STRING_LENGTH - 1); do_refresh(); } @@ -133,7 +133,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) if (inpt_command == 'f') { // add friend command: /f ID int i; char temp_id[128]; - for (i = 0; i < 128; i++) + for (i = 0; i < 128; i++) temp_id[i] = line[i+prompt_offset]; int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); @@ -166,8 +166,8 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) } else if (inpt_command == 'm') { //message command: /m friendnumber messsage size_t len = strlen(line); - if(len < 3) - return; + if(len < 3) + return; char numstring[len-3]; char message[len-3]; @@ -248,7 +248,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) else if (inpt_command == 'q') { //exit endwin(); exit(EXIT_SUCCESS); - } else { + } else { new_lines("[i] invalid command"); } } else { @@ -335,7 +335,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length) new_lines(format_message((char*)string, friendnumber)); } -void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) +void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { char name[MAX_NAME_LENGTH]; getname(friendnumber, (uint8_t*)name); @@ -344,7 +344,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) new_lines(msg); } -void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) +void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) { char name[MAX_NAME_LENGTH]; getname(friendnumber, (uint8_t*)name); @@ -353,7 +353,7 @@ void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) new_lines(msg); } -void load_key() +void load_key() { FILE *data_file = NULL; data_file = fopen("data","r"); @@ -368,7 +368,7 @@ void load_key() exit(1); } Messenger_load(data, size); - } else { + } else { //else save new keys int size = Messenger_size(); uint8_t data[size]; @@ -418,9 +418,9 @@ int main(int argc, char *argv[]) int resolved_address = resolve_addr(argv[1]); if (resolved_address != 0) bootstrap_ip_port.ip.i = resolved_address; - else + else exit(1); - + DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); nodelay(stdscr, TRUE); while(true) { @@ -441,7 +441,7 @@ int main(int argc, char *argv[]) if (c == '\n') { line_eval(lines, line); strcpy(line, ""); - } else if (c == 127) { + } else if (c == 8 || c == 127) { line[strlen(line)-1] = '\0'; } else if (isalnum(c) || ispunct(c) || c == ' ') { strcpy(line, appender(line, (char) c)); -- cgit v1.2.3