Skip to content

Commit be032e5

Browse files
authored
Merge pull request #1160 from DoctorWkt/less_revised
Applications/util/less.c: This now uses tgetstr() properly.
2 parents 5691fc1 + 25fefb8 commit be032e5

File tree

4 files changed

+587
-0
lines changed

4 files changed

+587
-0
lines changed

Applications/util/Makefile.common

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ SRCS = \
112112
xargs.c
113113

114114
SRCTC = fleamacs.c \
115+
less.c \
115116
tget.c \
116117
tchelp.c \
117118
marksman.c \

Applications/util/fuzix-util.pkg

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ f 0755 /bin/groups groups
8888
f 0755 /bin/head head
8989
f 0755 /bin/id id
9090
f 0755 /bin/kbdrate kbdrate
91+
f 0755 /bin/less less
9192
f 0755 /bin/ll ll
9293
f 0755 /bin/logname logname
9394
f 0755 /bin/mail mail
@@ -137,6 +138,7 @@ f 0755 /bin/yes yes
137138
f 0655 /usr/man/man1/cp.1 cp.1
138139
f 0655 /usr/man/man1/cpuinfo.1 cpuinfo.1
139140
f 0655 /usr/man/man1/date.1 date.1
141+
f 0655 /usr/man/man1/less.1 less.1
140142
f 0655 /usr/man/man1/man.1 man.1
141143
f 0655 /usr/man/man1/mkdir.1 mkdir.1
142144
f 0655 /usr/man/man1/mv.1 mv.1

Applications/util/less.1

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.TH LESS 1
2+
.SH NAME
3+
less
4+
\- display pager
5+
.SH SYNOPSIS
6+
.B less
7+
[file]
8+
.SH DESCRIPTION
9+
.I Less
10+
is a small and memory-efficient subset of the normal Unix
11+
.IR less(1)
12+
pager. It displays either the text file named on the command line,
13+
or standard input if there is no command-line argument. The input
14+
is displayed one screen at a time, and the user can scroll backwards
15+
and forwards through the input using these commands:
16+
.RS
17+
.TP
18+
.B f or <space>
19+
Move forward one screen
20+
.TP
21+
.B b
22+
Move backwards one screen
23+
.TP
24+
.B d
25+
Move forward half a screen
26+
.TP
27+
.B u
28+
Move backwards half a screen
29+
.TP
30+
.B j or <return>
31+
Move forward a line
32+
.TP
33+
.B k
34+
Move backwards a line
35+
.TP
36+
.B g
37+
Move to the start of the input
38+
.TP
39+
.B q
40+
Exit the program
41+
.RE
42+
.PP
43+
.IR less(1)
44+
will interpret sequences in the input such as x<backspace>x and
45+
display them in bold using ANSI escape sequences. Similarly,
46+
input sequences such as x<backspace>_ will be displayed underlined.
47+
.PP
48+
When using standard input,
49+
.IR less(1)
50+
buffers the input in a temporary file which is immediately unlinked
51+
so that it does not persist after the program exits.
52+
.SH SEE ALSO
53+
.IR more(1)
54+
.SH DIAGNOSTICS
55+
.IR less(1)
56+
normally exits with a zero value unless something goes wrong, when it will
57+
exit with value 1. These diagnostic messages may be issued:
58+
.RS
59+
.TP
60+
.B Unable to open <filename>
61+
The file named on the command line does not exist.
62+
.TP
63+
.B Cannot tc[gs]etattr
64+
The terminal cannot be put into cbreak mode.
65+
.TP
66+
.B fseek error in <function>
67+
.IR less(1)
68+
tried to move to a position in the input file which is not there.
69+
.TP
70+
.B Unable to open /dev/tty
71+
The character device /dev/tty does not exist:
72+
.IR less(1)
73+
needs to open this to set it to cbreak mode.
74+
.TP
75+
.B [mc]alloc error in <function>
76+
The program ran out of memory, even after freeing some memory.
77+
.RE
78+
.SH BUGS AND LIMITTATIONS
79+
.IR less(1)
80+
caches the file offsets for each line in memory. As you page down through
81+
a big file,
82+
.IR less(1)
83+
may run out of memory to hold all the offsets. When this happens, offsets
84+
from the beginning of the file are freed. This implies that you may not
85+
be able to page back to the top of the file.

0 commit comments

Comments
 (0)