Index: network_gui.c =================================================================== --- network_gui.c (revision 3305) +++ network_gui.c (working copy) @@ -6,6 +6,7 @@ #include "strings.h" #include "table/sprites.h" #include "network.h" +#include "debug.h" #include "hal.h" // for file list @@ -1302,7 +1303,31 @@ } +static inline void ChatNickTabCompletion(Window *w) +{ + Textbuf *tb = &WP(w, querystr_d).text; + const NetworkClientInfo* ci; + int len, i; + for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) { + // Skip non-active items + if (ci->client_index == NETWORK_EMPTY_INDEX) continue; + + len = strlen(ci->client_name); + if(tb->length < len && strncmp(ci->client_name, tb->buf, tb->length) == 0) { + DeleteTextBufferAll(tb); + + for(i = 0; i < len; i++) + InsertTextBufferChar(tb, ci->client_name[i]); + + InsertTextBufferChar(tb, ':'); + InsertTextBufferChar(tb, ' '); + + break; + } + } +} + #define MAX_QUERYSTR_LEN 64 static void ChatWindowWndProc(Window *w, WindowEvent *e) @@ -1360,12 +1385,16 @@ } break; case WE_KEYPRESS: { - switch(HandleEditBoxKey(w, 1, e)) { - case 1: // Return - goto press_ok; - case 2: // Escape - DeleteWindow(w); - break; + if(e->keypress.keycode == WKC_TAB) { + ChatNickTabCompletion(w); + } else { + switch(HandleEditBoxKey(w, 1, e)) { + case 1: // Return + goto press_ok; + case 2: // Escape + DeleteWindow(w); + break; + } } } break;