1if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; };
2
3# hop's tabkey script + my mods.
4
5package tabkey.sjh;
6
7# maximum number of nicks you want to keep track of...
8addset tabkey_max_nicks int;
9set tabkey_max_nicks 15;
10
11bind ^I parse_command ^tc.get_nick;
12bind ^R parse_command ^tc.get_nick_backward;
13bind ^X^X parse_command {
14	if (word($tc.position $tc.msglist)) {
15		xecho -b Nickname $word($tc.position $tc.msglist) removed;
16	};
17	@ tc.msglist = notw($tc.position $tc.msglist);
18	@ tc.num_nicks = #tc.msglist;
19	@ tc.position--;
20	tc.get_nick;
21};
22
23# add a word to a list -- makes sure the list doesnt get longer then
24# the number allowed in max_nicks.
25alias tc.add_to_list {
26	if (rmatch($0 =* *:*)) {
27		@:newnick = [$0];
28	} else {
29		@:newnick = [$servernum():$0];
30	};
31	@tc.msglist = [$newnick $remw($newnick $tc.msglist)];
32	@tc.msglist = leftw($getset(tabkey_max_nicks) $tc.msglist);
33	@tc.num_nicks = #tc.msglist;
34	@tc.position = 0;
35};
36
37alias tc.get_nick {
38	parsekey erase_line;
39	((tc.position >= tc.num_nicks) && (tc.position = 0));
40	xtype -l ${K}tkm $word($tc.position $tc.msglist) ;
41	((++tc.position >= tc.num_nicks) && (tc.position -= tc.num_nicks));
42};
43
44alias tc.get_nick_backward {
45	parsekey erase_line;
46	((--tc.position < 1) && (tc.position += tc.num_nicks));
47	xtype -l ${K}tkm $word(${tc.position - 1} $tc.msglist) ;
48};
49
50on #-msg -12782 "*" { tc.add_to_list $0; };
51on #-dcc_chat -12782 "*" { tc.add_to_list =$0; };
52on #-action -12782 "*" { if (!ischannel($1)) { tc.add_to_list $0; }; };
53on #-send_msg -12782 "*" { fe ($split(, $0)) x { tc.add_to_list $x; }; };
54on #-send_dcc_chat -12782 "*" { tc.add_to_list =$0; };
55on #-send_action -12782 "*" { if (!ischannel($0)) { tc.add_to_list $0; }; };
56
57# Remove a nick on a no such nick/chan error
58#on #-401 -12782 "*" { @ tc.msglist = remw($1 $tc.msglist; );
59
60# Update nicklist when someone changes their nick.
61on #-channel_nick -12782 "*" {
62	fe ( $tc.msglist ) nick {
63		if (nick == [$1] || nick == [$servernum():$1]) {
64			push :newlist $servernum():$2;
65		} else {
66			push :newlist $nick;
67		};
68	};
69
70	# Update input line if appropriate.
71	if (findw($word(1 $L) $1 $servernum():$1) > -1) {
72		@:oldcurpos = curpos();
73		parsekey erase_line;
74		xtype -l $word(0 $U) $servernum():$2 $afterw($word(1 $U) $U);
75		@:newcurpos = curpos();
76		# adjust old cursor position to reflect longer/shorter input line
77		@oldcurpos += (@L - @U);
78		parsekey beginning_of_line;
79		repeat $oldcurpos parsekey forward_character;
80	};
81};
82
83# Alias so you can go: /tkm <nick> /me farts loudly
84# equiv to going /describe <nick> farts loudly
85
86alias tkm {
87	@:srv = (match(*:* $0)) ? before(: $0) : servernum();
88
89	if ([$1]==[/me]) {
90		xeval -s $srv {describe $after(-1 : :$0) $2-};
91	} else {
92		xeval -s $srv {msg $after(-1 : :$0) $1-};
93	};
94};
95
96