File: altchan

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 (64 lines) | stat: -rw-r--r-- 1,892 bytes parent folder | download
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
if (word(2 $loadinfo()) != 'pf') {
	load -pf $word(1 $loadinfo());
	return;
};

#	Copyright 2007 EPIC Software Labs
#	Written by BlackJac@EFNet
#
#	Version: 2.0.2007.03.16.1
#
#	This script will allow you to switch between your hidden windows more
#	easily. Press Alt+<number> or Esc+<number> (depending on your terminal
#	application) to switch to hidden window <number>. If you are in hidden
#	window 5 and you press Alt+5, you will go to window 15, then 25, etc.
#	(assuming those windows exist), until you cycle back to window 5. You
#	may also use Alt+? to be prompted for a window number. Press Alt+- or
#	Alt+= to cycle through the previous or next windows, respectively.

package altchan;

alias altchan.input (void) {
	input "$banner Switch to which window \(currently $winnum()\)? " {
		if (strlen($*)) {
			altchan.toggle $0;
		};
	};
};

alias altchan.toggle (number, void) {
	if (number) {
		if (number == winnum()) {
			@ :window = number + 10;
			if (winnum($window) != -1) {
				window refnum_or_swap $window;
			} else {
				xecho -b -c Window $window does not exist;
			};
		} else if (number == right(1 $winnum())) {
			@ :window = winnum() + 10;
			if (winnum($window) != -1) {
				window refnum_or_swap $window;
			} else if (winnum($number) != -1) {
				window refnum_or_swap $number;
			} else {
				xecho -b -c Windows $window and $number do not exist;
			};
		} else {
			if (winnum($number) != -1) {
				window refnum_or_swap $number;
			} else {
				xecho -b -c Window $number does not exist;
			};
		};
	};
};

@ bindctl(sequence ^[0 set parse_command altchan.toggle 10);
fe ($jot(1 9 1)) aa {
	@ bindctl(sequence ^[$aa set parse_command altchan.toggle $aa);
	alias $aa altchan.toggle $aa;
};
@ bindctl(sequence ^[- set parse_command window previous);
@ bindctl(sequence ^[= set parse_command window next);
@ bindctl(sequence ^[? set parse_command altchan.input);