File: tabkey.sjh

package info (click to toggle)
epic5 3.0.3-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 5,328 kB
  • sloc: ansic: 75,810; makefile: 648; ruby: 227; python: 215; sh: 78; perl: 13
file content (95 lines) | stat: -rw-r--r-- 2,777 bytes parent folder | download | duplicates (5)
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
88
89
90
91
92
93
94
95
if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; };

# hop's tabkey script + my mods.

package tabkey.sjh;

# maximum number of nicks you want to keep track of...
addset tabkey_max_nicks int;
set tabkey_max_nicks 15;

bind ^I parse_command ^tc.get_nick;
bind ^R parse_command ^tc.get_nick_backward;
bind ^X^X parse_command {
	if (word($tc.position $tc.msglist)) {
		xecho -b Nickname $word($tc.position $tc.msglist) removed;
	};
	@ tc.msglist = notw($tc.position $tc.msglist);
	@ tc.num_nicks = #tc.msglist;
	@ tc.position--;
	tc.get_nick;
};

# add a word to a list -- makes sure the list doesnt get longer then
# the number allowed in max_nicks.
alias tc.add_to_list {
	if (rmatch($0 =* *:*)) {
		@:newnick = [$0];
	} else {
		@:newnick = [$servernum():$0];
	};
	@tc.msglist = [$newnick $remw($newnick $tc.msglist)];
	@tc.msglist = leftw($getset(tabkey_max_nicks) $tc.msglist);
	@tc.num_nicks = #tc.msglist;
	@tc.position = 0;
};

alias tc.get_nick {
	parsekey erase_line;
	((tc.position >= tc.num_nicks) && (tc.position = 0));
	xtype -l ${K}tkm $word($tc.position $tc.msglist) ;
	((++tc.position >= tc.num_nicks) && (tc.position -= tc.num_nicks));
};

alias tc.get_nick_backward {
	parsekey erase_line;
	((--tc.position < 1) && (tc.position += tc.num_nicks));
	xtype -l ${K}tkm $word(${tc.position - 1} $tc.msglist) ;
};

on #-msg -12782 "*" { tc.add_to_list $0; };
on #-dcc_chat -12782 "*" { tc.add_to_list =$0; };
on #-action -12782 "*" { if (!ischannel($1)) { tc.add_to_list $0; }; };
on #-send_msg -12782 "*" { fe ($split(, $0)) x { tc.add_to_list $x; }; };
on #-send_dcc_chat -12782 "*" { tc.add_to_list =$0; };
on #-send_action -12782 "*" { if (!ischannel($0)) { tc.add_to_list $0; }; };

# Remove a nick on a no such nick/chan error
#on #-401 -12782 "*" { @ tc.msglist = remw($1 $tc.msglist; );

# Update nicklist when someone changes their nick.
on #-channel_nick -12782 "*" {
	fe ( $tc.msglist ) nick {
		if (nick == [$1] || nick == [$servernum():$1]) {
			push :newlist $servernum():$2;
		} else {
			push :newlist $nick;
		};
	};

	# Update input line if appropriate.
	if (findw($word(1 $L) $1 $servernum():$1) > -1) {
		@:oldcurpos = curpos();
		parsekey erase_line;
		xtype -l $word(0 $U) $servernum():$2 $afterw($word(1 $U) $U);
		@:newcurpos = curpos();
		# adjust old cursor position to reflect longer/shorter input line
		@oldcurpos += (@L - @U);
		parsekey beginning_of_line;
		repeat $oldcurpos parsekey forward_character;
	};
};

# Alias so you can go: /tkm <nick> /me farts loudly
# equiv to going /describe <nick> farts loudly

alias tkm {
	@:srv = (match(*:* $0)) ? before(: $0) : servernum();

	if ([$1]==[/me]) {
		xeval -s $srv {describe $after(-1 : :$0) $2-};
	} else {
		xeval -s $srv {msg $after(-1 : :$0) $1-};
	};
};