/* * TABKEY.BX - Tab key completion script for BitchX * Author: Brian Weiss - 2001 * * Last modified: 5/7/02 * * This script uses serial number 420 for all ON hooks. * * This is just a port of my Darkstar/EPIC4 tabkey module. * If you want to check it out, visit the following site. * http://www.got.net/~brian/ */ /*** CONFIG SECTION ***/ assign TABKEY_NICK_HISTORY 6 assign TABKEY_NICKCOMP_SUFFIX : /*** END CONFIG SECTION ***/ bind ^I parse_command tabkey.process_tabkey alias cleartab (void) { fe ($aliasctl(assign match TABKEY.NICKS.)) var { ^assign -$var } fe ($aliasctl(assign match TABKEY.INDEX.)) var { ^assign -$var } xecho -s -b Tabkey history cleared } alias tabkey.process_tabkey (void) { if (L) { @ :lastw = word(${numwords($L) - 1} $L) if (left(1 $lastw) == [#]) { @ tabkey.channel_routine() } \ elsif (index($left(1 $L) $K) > -1) { switch ($rest(1 $L)) { (%) { parsekey command_completion } (channel %) (j %) (join %) (l %) (leave %) (mode %) (part %) { @ tabkey.channel_routine() } (dcc send % %) (exec *) (less %) (load %) { @ tabkey.file_routine() } (m % *) (msg % *) { @ tabkey.msg_routine() } (*) { @ tabkey.nick_routine() } } }{ @ tabkey.nick_routine() } }{ @ tabkey.msg_routine() } } alias tabkey.add_nick (nick, void) { if (match($nick $TABKEY.NICKS[$winserv()])) { @ TABKEY.NICKS.$winserv() = remw($nick $TABKEY.NICKS[$winserv()]) } if (numwords($TABKEY.NICKS[$winserv()]) == TABKEY_NICK_HISTORY) { shift TABKEY.NICKS.$winserv() } @ push(TABKEY.NICKS[$winserv()] $nick) @ TABKEY.INDEX.$winserv() = [-1] return } alias tabkey.channel_routine (void) { @ :lastc = mid(${strlen($L) - 1} 1 $L) unless (lastc == [ ]) { @ :lastw = word(${#L - 1} $L) @ :findchan = pattern($lastw% $mychannels()) if (match($lastw $findchan)) { xecho -b Matches: echo $findchan } if (#findchan == 1) { @ :space = [ ] parsekey delete_to_previous_space xtype -l $findchan$space } \ elsif (#findchan > 1) { parsekey delete_to_previous_space xtype -l $prefix($findchan) @ :lastw = word(${#L - 1} $L) if (!match($lastw $findchan)) { xecho -b Matches: echo $findchan } } } return } alias tabkey.file_routine (void) { @ :lastc = mid(${strlen($L) - 1} 1 $L) unless (lastc == [ ]) { @ :lastw = twiddle($word(${#L - 1} $L)) @ :findfile = pattern($lastw% $glob($lastw*)) if (#findfile == 1) { @ :lastc = mid(${strlen($findfile) - 1} 1 $findfile) @ :space = [ ] parsekey delete_to_previous_space xtype -l $findfile${lastc == [/] ? [] : [ ]} } \ elsif (#findfile > 1) { parsekey delete_to_previous_space xtype -l $prefix($findfile) xecho -b Matches: fe ($findfile) file { echo $file } } } return } alias tabkey.msg_routine (void) { @ :nicks = TABKEY.NICKS[$winserv()] @ :index = TABKEY.INDEX[$winserv()] @ :msg_cmd = CMDCHARS ## [msg] @ :trailing = restw(2 $L) if (nicks) { ^local nick if (index > 0) { @ nick = word(${index - 1} $nicks) @ TABKEY.INDEX.$winserv() = index - 1 }{ @ nick = word(${numwords($nicks) - 1} $nicks) @ TABKEY.INDEX.$winserv() = numwords($nicks) - 1 } parsekey erase_line xtype -l $msg_cmd $nick $trailing }{ @ TABKEY.INDEX.$winserv() = [-1] } return } alias tabkey.nick_routine (void) { @ :lastc = mid(${strlen($L) - 1} 1 $L) unless (lastc == [ ]) { @ :lastw = word(${#L - 1} $L) @ :findnick = pattern($lastw% $onchannel()) if (match($word(1 $L) $findnick)) { xecho -b Matches: echo $findnick } if (#findnick == 1) { ^local space if (#L == 1) { @ space = TABKEY_NICKCOMP_SUFFIX ## [ ] }{ @ space = [ ] } parsekey delete_to_previous_space xtype -l $findnick$space } \ elsif (#findnick > 1) { parsekey delete_to_previous_space xtype -l $prefix($findnick) if (!match($word(1 $L) $findnick)) { xecho -b Matches: echo $findnick } } } return } fe (msg send_msg) hook { on #^$hook 420 "*" { @ tabkey.add_nick($0) } } fe (dcc_chat send_dcc_chat) hook { on #^$hook 420 "*" { @ tabkey.add_nick(=$0) } } on #^dcc_connect 420 "% CHAT *" { @ tabkey.add_nick(=$0) } /* bmw '01 */