From 6dccef4fd1a101d01dbad7d1810a9fc38b2a6b2d Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Thu, 3 Apr 2003 17:25:16 +0000 Subject: Stupid Readline Completion --- vchat-user.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'vchat-user.c') diff --git a/vchat-user.c b/vchat-user.c index 868fcc5..5f073a6 100755 --- a/vchat-user.c +++ b/vchat-user.c @@ -20,8 +20,20 @@ #include #include #include +#include +#include #include "vchat.h" +struct user +{ + unsigned char *nick; /* nick of user */ + int chan; /* channel user is on */ + int chan_valid; /* are we sure he is? */ + int client_pv; /* client protocol version */ + int messaged; /* did we message with this user? */ + struct user *next; /* next user in linked list */ +}; + /* version of this module */ unsigned char *vchat_us_version = "$Id$"; @@ -79,6 +91,7 @@ ul_add (unsigned char *name, int ignored) } } } + rl_last_func = NULL; } /* delete user from userlist */ @@ -119,6 +132,7 @@ ul_del (unsigned char *name, int ignored) ltmp = tmp; tmp = tmp->next; } + rl_last_func = NULL; } /* let user join a channel */ @@ -131,6 +145,7 @@ ul_join (unsigned char *name, int channel) ownjoin (channel); return; } else ul_moveuser(name,channel); + rl_last_func = NULL; } user * @@ -169,20 +184,39 @@ ul_matchuser( unsigned char *regex) { return tmpstr; } +static void +ul_usertofront( user *who ) { + user *tmp = nicks; + + while( tmp->next && ( tmp->next != who ) ) + tmp = tmp->next; + + if( tmp->next == who ) { + tmp->next = tmp->next->next; + who->next = nicks; + nicks = who; + } + rl_last_func = NULL; +} + void ul_msgto (unsigned char *name) { user *tmp = ul_finduser(name); - if (tmp) - tmp->messaged |= 1; + if (tmp) { + tmp->messaged |= 1; + ul_usertofront( tmp ); + } } void ul_msgfrom (unsigned char *name) { user *tmp = ul_finduser(name); - if (tmp) - tmp->messaged |= 2; + if (tmp) { + tmp->messaged |= 2; + ul_usertofront( tmp ); + } } /* set channel of user */ @@ -195,6 +229,7 @@ ul_moveuser (unsigned char *name, int channel) { tmp->chan = channel; tmp->chan_valid = 1; } + rl_last_func = NULL; } /* let user leave a channel */ @@ -215,6 +250,7 @@ ul_leave (unsigned char *name, int channel) tmp->chan_valid = 0; return; } + rl_last_func = NULL; } /* let user change nick */ @@ -235,6 +271,7 @@ ul_nickchange (unsigned char *oldnick, unsigned char *newnick) tmp->nick = strdup (newnick); return; } + rl_last_func = NULL; } /* clear userlist */ @@ -254,6 +291,7 @@ ul_clear (void) } /* mark list empty */ nicks = NULL; + rl_last_func = NULL; } int ulnc_casenick(user *tmp, const unsigned char *text, int len, int value) { -- cgit v1.2.3