File: less

package info (click to toggle)
epic 3.004-17.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,192 kB
  • ctags: 3,197
  • sloc: ansic: 40,843; makefile: 530; sh: 129; perl: 17
file content (56 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (4)
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
#
# A file pager.  A demonstration of how to do something useful in ircII.
# This cheesy rip-off was written by hop in 1996.
# My apologies in advance to archon.
#

alias less
{
	if ([$0])
	{
		if (fexist($0) == 1)
		{
			@ fd = open($0 R)
			less_file $fd ${winsize() - 1}
		}
		{
			echo $0\: no such file.
		}
	}
	{
		echo Usage: /more <filename>
	}
}


alias less_file
{
	@ line = 0

	while (!eof($0) && (line++ < [$1]))
	{
		@ ugh = read($0)
		if (!eof($0)) 
		{
			echo $ugh
		}
	}

	if (!eof($0))
	{
		@ less.fd = [$0]
		@ less.nl = [$1]
		input_char "Enter q to quit, or anything else to continue "
		{
			if ([$0] != [q])
			{
				less_file $less.fd $less.nl
			}
		}
	}
	{
		@ close($fd)
	}
}

#hop'96