Usermode/irc - Fixes to long line rendering, misc other changes
authorJohn Hodge <[email protected]>
Thu, 4 Aug 2011 09:03:21 +0000 (17:03 +0800)
committerJohn Hodge <[email protected]>
Thu, 4 Aug 2011 09:03:21 +0000 (17:03 +0800)
Usermode/Applications/irc_src/main.c

index aa0f2d4..952da4e 100644 (file)
@@ -116,6 +116,7 @@ int main(int argc, const char *argv[], const char *envp[])
        // HACK: Static server entry\r
        // UCC (University [of Western Australia] Computer Club) IRC Server\r
        gWindow_Status.Server = Server_Connect( "UCC", "130.95.13.18", 6667 );\r
+//     gWindow_Status.Server = Server_Connect( "Freenode", "89.16.176.16", 6667 );\r
 //     gWindow_Status.Server = Server_Connect( "Host", "10.0.2.2", 6667 );\r
 //     gWindow_Status.Server = Server_Connect( "BitlBee", "192.168.1.34", 6667 );\r
        \r
@@ -426,8 +427,17 @@ tMessage *Message_Append(tServer *Server, int Type, const char *Source, const ch
                int pos = SetCursorPos(giTerminal_Height-2, 0);\r
                #if 1\r
                if( win == gpCurrentWindow ) {\r
+                        int    prefixlen = strlen(Source) + 3;\r
+                        int    avail = giTerminal_Width - prefixlen;\r
+                        int    msglen = strlen(Message);\r
                        printf("\x1B[T");       // Scroll down 1 (free space below)\r
-                       printf("[%s] %s\n", Source, Message);\r
+                       printf("[%s] %.*s\n", Source, avail, Message);\r
+                       while( msglen > avail ) {\r
+                               msglen -= avail;\r
+                               printf("\x1B[T");\r
+                               SetCursorPos(giTerminal_Height-2, prefixlen);\r
+                               printf("%.*s\n", avail, Message);\r
+                       }\r
                }\r
                #else\r
                if(win->Name[0])\r
@@ -497,8 +507,8 @@ void Redraw_Screen(void)
                \r
                while(done < msglen) {\r
                        done += printf("%.*s", line_avail, msg->Data+done);\r
-                       SetCursorPos(y+i, prefix_len);\r
                        i ++;\r
+                       SetCursorPos(y+i, prefix_len);\r
                }\r
        }\r
 \r
@@ -517,7 +527,8 @@ void ParseServerLine(tServer *Server, char *Line)
 {\r
         int    pos = 0;\r
        char    *ident, *cmd;\r
-       \r
+\r
+       _SysDebug("Server %s: Line = %s", Server->Name, Line);  \r
        \r
        // Message?\r
        if( *Line == ':' )\r
@@ -547,13 +558,16 @@ void ParseServerLine(tServer *Server, char *Line)
                        {\r
                        case 353:       // /NAMES list\r
                                // <user> = <channel> :list\r
-                               GetValue(Line, &pos);   // '='\r
+//                             GetValue(Line, &pos);   // '='\r
                                user = GetValue(Line, &pos);    // Actually channel\r
                                message = Line + pos + 1;       // List\r
-                               Message_Append(Server, MSG_TYPE_SERVER, user, "", message);\r
+                               Message_AppendF(Server, MSG_TYPE_SERVER, user, "", "Names: %s", message);\r
                                break;\r
                        case 366:       // end of /NAMES list\r
-//                             Message_Append()\r
+                               // <user> <channel> :msg\r
+                               user = message;\r
+                               message = Line + pos + 1;\r
+                               Message_Append(Server, MSG_TYPE_SERVER, user, "", message);\r
                                break;\r
                        case 372:       // MOTD Data\r
                        case 376:       // MOTD End\r
@@ -591,7 +605,7 @@ void ParseServerLine(tServer *Server, char *Line)
                        else {\r
                                message = GetValue(Line, &pos);\r
                        }\r
-                       Cmd_PRIVMSG(Server, dest, ident, message);\r
+//                     Cmd_PRIVMSG(Server, dest, ident, message);\r
                        Message_Append(Server, MSG_TYPE_STANDARD, ident, dest, message);\r
                }\r
                else if( strcmp(cmd, "JOIN" ) == 0 )\r

UCC git Repository :: git.ucc.asn.au