1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 12:15:43 +03:00

Add scroll-right markers

For lines extending to the right of the screen width.
This commit is contained in:
Johan Walles 2019-08-03 20:14:22 +02:00
parent 193805abc9
commit df9920c11c
2 changed files with 17 additions and 7 deletions

View File

@ -89,13 +89,6 @@ FIXME: Go release instructions
TODO
----
* Add '>' markers at the end of lines being cut because they are too long
* Doing moar on an arbitrary binary (like /bin/ls) should put all
line-continuation markers at the rightmost column. This really
means our truncation code must work even with things like tabs and
various control characters.
* Make sure search hits are highlighted even when we have to scroll right
to see them
@ -138,3 +131,13 @@ TODO
* Retain the search string when pressing / to search a second time.
* Make sure "git grep" output gets highlighted properly.
Done
----
* Add '>' markers at the end of lines being cut because they are too long
* Doing moar on an arbitrary binary (like /bin/ls) should put all
line-continuation markers at the rightmost column. This really
means our truncation code must work even with things like tabs and
various control characters.

View File

@ -111,6 +111,13 @@ func (p *_Pager) _AddLine(logger *log.Logger, lineNumber int, line string) {
matchRanges := GetMatchRanges(plainString, p.searchPattern)
for _, token := range tokens[p.leftColumnZeroBased:] {
width, _ := p.screen.Size()
if pos >= width {
// Indicate that this line continues to the right
p.screen.SetContent(pos-1, lineNumber, '>', nil, tcell.StyleDefault.Reverse(true))
break
}
style := token.Style
if matchRanges.InRange(pos) {
// FIXME: This doesn't work if the style is already reversed