about summary refs log tree commit diff stats
path: root/page
blob: c478d7a2eb2b801c66a04beba2cdc0a6f5766510 (plain)
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
#!/bin/bash
# pager

. ./wrap

cleanup() {
	tput reset
	exit
}

refresh() {
	shopt -s checkwinsize
	(
		:
		:
	)
	printf '\e[?1049h\e?7l\e[2J\e[3;%sr\e[999H' "$((LINES - 1))"
}

resize() {
	refresh

	printf '\e7\e[?25l\e[H'
	_wrap "$file"
	printf '\e[999H\e[?25h'
}

_wrap() {
	wrap "$COLUMNS" <"$1"
}

main() {
	refresh

	file="$1"
	resize

	trap resize WINCH
	trap cleanup INT

	while :; do
		:
	done
}

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
	main "$@"
fi