Age | Commit message (Collapse) | Author |
|
|
|
|
|
Before tabs were treated as a width of 1, which would cause issues with
man page headers.
|
|
|
|
|
|
This change moves from wrapping lines at the start to operating on whole
lines and wrapping them as needed.
This has a few added benefits:
- line numbers are now always accurate.
- going to a line actually works
|
|
|
|
While mathematically equivalent, the presence of a size_t forces the
comparison to work with size_t's. This means that '-1 < 0' is false,
contrary to the 'mathematically pure' interpretation of the inequality.
|
|
Before this patch less would query the terminal geometry only at
startup and use this information to render the file when
appropriate. If the terminal is resized then the output is broken in
several different ways because of this.
This patch adds a SIGWINCH signal handler receive notification any
time the terminal is resized. This signal handler just sets a flag to
notify the main loop that a resize has occurred.
The main loop of the program just calls get_key_sequence() to get
input from the user, interpreting keystrokes as commands like scroll
up or down. The get_key_sequence() function has been changed to return
Optional<String>, so it either returns a keystroke from the user or it
returns nothing as an empty Optional.
While the user is not pressing any keys on the keyboard, the program
is blocking on a read() system call in get_key_sequence(). When
SIGWINCH is received, this read() will return with -1 and errno is set
to EINTR since the system call was interrupted by the signal. When
this happens we just return an empty Optional.
The mainloop now checks to see if a resize has been requested by
checking the flag, and if it has it performs a resize.
init() now just calls resize() since the required logic is the same.
Setters for m_filename and m_prompt are removed because these are now
just initialized by the constructor, as they never change for the life
of the program.
|
|
|
|
Using StringView instead of C strings is basically always preferable.
The only reason to use a C string is because you are calling a C API.
|
|
|
|
|
|
|
|
- 'u' and 'd' now scroll up and down half a page
- Typing a number followed by 'j', 'k', 'return', 'up' or 'down' will
scroll that many lines in the appropriate direction
- Typing a number followed by 'g' or 'G' will scroll directly to the
line corresponding to that number
|
|
'down_n()' now correctly buffers the needed number of lines, previously
there were issues with using it to scroll much more than the existing
buffer.
|
|
|
|
|
|
|
|
|
|
This is the most logical behavior when less is used in a pipe.
|
|
|
|
This patch also removes the existing implementation of more, as it is
now redundant.
|
|
GNU less has a pretty cool prompt format language. This patch adds
support for the language and specifiers for filename, linenumber, and
ending.
|
|
less is a re-implementation of gnu less, a terminal pager with backwards
scrolling and alternate screen support.
|