File: tabkey.th

package info (click to toggle)
epic4 1%3A3.0-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,780 kB
  • sloc: ansic: 56,285; makefile: 630; sh: 161; perl: 30
file content (87 lines) | stat: -rw-r--r-- 2,245 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#
# These are my tabkey routines. Pressing the tabkey with nothing in your buffer
# will cycle through people you are talking to or if you type part of a
# nickname and then tab it will complete the nickname. Enjoy.
#
# - whitefang (thall@epicsol.org)
#


bind ^i parse_command proc.tabkey

alias proc.tabkey
{
        ^local text,word,comp,comm,nick,temp

        @ text = L, word = rightw(1 $text), comp = pattern($^\word* $chanusers())
        unless (text)
        {
                type /msg
                @ text = L
        }
        @ comm = word(0 $text), nick = word(1 $text)

        /* msg buffer routine */
        if (comm == [/msg])
        {
                if (finditem(TK $nick) >= 0)
                {
                        parsekey erase_line
                        @ temp = getitem(TK ${finditem(TK $nick)-1})
                        xtype -l /msg ${temp?temp:getitem(TK ${numitems(TK)-1})}$chr(32)
                } {
                        parsekey erase_line
                        xtype -l /msg $getitem(TK ${numitems(TK)-1})$chr(32)
                }
                return
        }

        /* nick completion routine */
        if (!word || !numwords($comp) || right(1 $word) == [:])
        {
                return
        }
        if (numwords($comp) > 1)
        {
                xecho -b Matches:
                echo $comp
                return
        }
        if (numwords($text) == 1)
        {
                parsekey erase_line
                xtype -l $comp:$chr(32)
        } {
                pop text
                parsekey erase_line
                xtype -l $text $comp
        }
}

alias proc.add_tabkey (nick)
{
        if (nick)
        {
                if (finditem(TK $nick) >= 0) {@ delitem(TK $finditem(TK $nick))}
                @ setitem(TK $numitems(TK) $nick)
                if (numitems(TK) == 10) {@ delitem(TK 0)}
        }
}

on #-dcc_chat -420 * proc.add_tabkey =$0
on #-dcc_connect -420 "% CHAT *" proc.add_tabkey =$0
on #-msg -420 * proc.add_tabkey $0
on #-send_dcc_chat -420 * proc.add_tabkey =$0
on #-send_msg -420 * proc.add_tabkey $0

alias m msg
alias msg
{
        //msg $*
        if (@)
        {
                proc.add_tabkey $0
        }
}

# tjbh/2000