Skip to content
Snippets Groups Projects
Commit a024e6f4 authored by John Hodge's avatar John Hodge
Browse files

Usermode/irc - Tweaking for terminal handling fixes

parent bffcec43
No related merge requests found
...@@ -120,7 +120,7 @@ int main(int argc, const char *argv[], const char *envp[]) ...@@ -120,7 +120,7 @@ int main(int argc, const char *argv[], const char *envp[])
printf("\x1B[?1047h"); printf("\x1B[?1047h");
printf("\x1B[%i;%ir", 0, giTerminal_Height-1); printf("\x1B[%i;%ir", 0, giTerminal_Height-1);
SetCursorPos(giTerminal_Height-1, 0); SetCursorPos(giTerminal_Height-1, 1);
printf("[(status)] "); printf("[(status)] ");
// HACK: Static server entry // HACK: Static server entry
...@@ -145,7 +145,7 @@ int main(int argc, const char *argv[], const char *envp[]) ...@@ -145,7 +145,7 @@ int main(int argc, const char *argv[], const char *envp[])
int MainLoop(void) int MainLoop(void)
{ {
SetCursorPos(giTerminal_Height-1, 0); SetCursorPos(giTerminal_Height-1, 1);
printf("[(status)] "); printf("[(status)] ");
fflush(stdout); fflush(stdout);
...@@ -186,7 +186,7 @@ int MainLoop(void) ...@@ -186,7 +186,7 @@ int MainLoop(void)
} }
free(cmd); free(cmd);
// Prompt // Prompt
SetCursorPos(giTerminal_Height-1, 0); SetCursorPos(giTerminal_Height-1, 1);
printf("\x1B[2K"); // Clear line printf("\x1B[2K"); // Clear line
if( gpCurrentWindow->Name[0] ) if( gpCurrentWindow->Name[0] )
printf("[%s:%s] ", printf("[%s:%s] ",
...@@ -486,7 +486,7 @@ tMessage *Message_Append(tServer *Server, int Type, const char *Source, const ch ...@@ -486,7 +486,7 @@ tMessage *Message_Append(tServer *Server, int Type, const char *Source, const ch
{ {
printf("\33[s"); printf("\33[s");
printf("\33[T"); // Scroll down 1 (free space below) 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 prefixlen = strlen(Source) + 3;
int avail = giTerminal_Width - prefixlen; int avail = giTerminal_Width - prefixlen;
int msglen = strlen(Message); int msglen = strlen(Message);
...@@ -495,7 +495,7 @@ tMessage *Message_Append(tServer *Server, int Type, const char *Source, const ch ...@@ -495,7 +495,7 @@ tMessage *Message_Append(tServer *Server, int Type, const char *Source, const ch
msglen -= avail; msglen -= avail;
Message += avail; Message += avail;
printf("\33[T"); printf("\33[T");
SetCursorPos(giTerminal_Height-2, prefixlen); SetCursorPos(giTerminal_Height-2, prefixlen+1);
printf("%.*s", avail, Message); printf("%.*s", avail, Message);
} }
printf("\x1b[u"); printf("\x1b[u");
...@@ -555,13 +555,13 @@ void Redraw_Screen(void) ...@@ -555,13 +555,13 @@ void Redraw_Screen(void)
int i = 0, done = 0; int i = 0, done = 0;
y -= msglen / line_avail; // Extra lines (y-- above handles the 1 line case) y -= msglen / line_avail; // Extra lines (y-- above handles the 1 line case)
SetCursorPos(y, 0); SetCursorPos(y, 1);
printf("[%s] ", msg->Source); printf("[%s] ", msg->Source);
while(done < msglen) { while(done < msglen) {
done += printf("%.*s", line_avail, msg->Data+done); done += printf("%.*s", line_avail, msg->Data+done);
i ++; i ++;
SetCursorPos(y+i, prefix_len); SetCursorPos(y+i, prefix_len+1);
} }
} }
...@@ -710,8 +710,7 @@ void ParseServerLine(tServer *Server, char *Line) ...@@ -710,8 +710,7 @@ void ParseServerLine(tServer *Server, char *Line)
const char *cmd = GetValue(Line, &pos); const char *cmd = GetValue(Line, &pos);
if( strcmp(cmd, "PING") == 0 ) { if( strcmp(cmd, "PING") == 0 ) {
writef(Server->FD, "PONG %s\n", gsHostname); writef(Server->FD, "PONG %s\n", Line+pos);
} }
else { else {
// Command to client // Command to client
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment