From a024e6f4374ca25465ce3d17bb4685200740d9d6 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 22 Mar 2014 12:11:36 +0800 Subject: [PATCH] Usermode/irc - Tweaking for terminal handling fixes --- Usermode/Applications/irc_src/main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Usermode/Applications/irc_src/main.c b/Usermode/Applications/irc_src/main.c index 83c98e05..1ca53c2b 100755 --- a/Usermode/Applications/irc_src/main.c +++ b/Usermode/Applications/irc_src/main.c @@ -120,7 +120,7 @@ int main(int argc, const char *argv[], const char *envp[]) printf("\x1B[?1047h"); printf("\x1B[%i;%ir", 0, giTerminal_Height-1); - SetCursorPos(giTerminal_Height-1, 0); + SetCursorPos(giTerminal_Height-1, 1); printf("[(status)] "); // HACK: Static server entry @@ -145,7 +145,7 @@ int main(int argc, const char *argv[], const char *envp[]) int MainLoop(void) { - SetCursorPos(giTerminal_Height-1, 0); + SetCursorPos(giTerminal_Height-1, 1); printf("[(status)] "); fflush(stdout); @@ -186,7 +186,7 @@ int MainLoop(void) } free(cmd); // Prompt - SetCursorPos(giTerminal_Height-1, 0); + SetCursorPos(giTerminal_Height-1, 1); printf("\x1B[2K"); // Clear line if( gpCurrentWindow->Name[0] ) printf("[%s:%s] ", @@ -486,7 +486,7 @@ tMessage *Message_Append(tServer *Server, int Type, const char *Source, const ch { printf("\33[s"); printf("\33[T"); // Scroll down 1 (free space below) - SetCursorPos(giTerminal_Height-2, 0); + SetCursorPos(giTerminal_Height-2, 1); int prefixlen = strlen(Source) + 3; int avail = giTerminal_Width - prefixlen; int msglen = strlen(Message); @@ -495,7 +495,7 @@ tMessage *Message_Append(tServer *Server, int Type, const char *Source, const ch msglen -= avail; Message += avail; printf("\33[T"); - SetCursorPos(giTerminal_Height-2, prefixlen); + SetCursorPos(giTerminal_Height-2, prefixlen+1); printf("%.*s", avail, Message); } printf("\x1b[u"); @@ -555,13 +555,13 @@ void Redraw_Screen(void) int i = 0, done = 0; y -= msglen / line_avail; // Extra lines (y-- above handles the 1 line case) - SetCursorPos(y, 0); + SetCursorPos(y, 1); printf("[%s] ", msg->Source); while(done < msglen) { done += printf("%.*s", line_avail, msg->Data+done); i ++; - SetCursorPos(y+i, prefix_len); + SetCursorPos(y+i, prefix_len+1); } } @@ -710,8 +710,7 @@ void ParseServerLine(tServer *Server, char *Line) const char *cmd = GetValue(Line, &pos); if( strcmp(cmd, "PING") == 0 ) { - writef(Server->FD, "PONG %s\n", gsHostname); - + writef(Server->FD, "PONG %s\n", Line+pos); } else { // Command to client -- 2.20.1