1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 20:17:13 +03:00
Commit Graph

281 Commits

Author SHA1 Message Date
Johan Walles
fec9ad8149 Fix crash on paging down
Fixes #65.
2021-06-04 13:20:28 +02:00
Johan Walles
24776d7fe3 Improve vertical clipping in presence of wrapping
New vertical clipping algorithm:
1. Render all input lines we have
2. Scroll until the right ones are visible on screen

This makes us get closer to being able to show the last line in the
presence of wrapped lines, and paves the way for true sub-line
scrolling.
2021-06-03 07:25:02 +02:00
Johan Walles
8b242b42bc Fix rendering of empty input
Before this change, we rendered empty input as one empty line.

With this change in place, we now put the EOF marker at the top, where
it belongs if there's nothing to show.
2021-05-31 19:08:19 +02:00
Johan Walles
47036defd4 Fix crash reading empty input 2021-05-31 19:00:11 +02:00
Johan Walles
c1d046f65b First shot at wrap friendly line fitting
Tests crash, must fix.
2021-05-30 16:11:26 +02:00
Johan Walles
f7bad91000 Move search pattern into ScreenLines struct 2021-05-30 15:33:28 +02:00
Johan Walles
002d4e40af Modify input lines rendering API
Make the rendering function return both the lines and the clipped
first-line-number value.
2021-05-30 11:36:07 +02:00
Johan Walles
c4e8562c7c Revert "Remove failing test"
This reverts commit 4617c515b7.

The test is valid and the point of this branch is to make it pass.
2021-05-30 10:18:04 +02:00
Johan Walles
4617c515b7 Remove failing test
The test is valid, but it's broken on master as well and it doesn't
affect this branch, so remove it so we're able to merge this branch into
master.

That test will be taken care of in another branch.
2021-05-30 10:13:11 +02:00
Johan Walles
891b2ccd4f Add more cropping tests 2021-05-30 10:07:10 +02:00
Johan Walles
f84ae1df18 Move some tests into screenLines_test.go
Fix one crash, but I can provoke more so there are still more tests to
write.
2021-05-30 09:45:14 +02:00
Johan Walles
40905cd626 Extract single-line rendering into its own function 2021-05-29 16:08:53 +02:00
Johan Walles
5d0f11e4bc Fix some horizontal clipping / scrolling issues
Some still remain.
2021-05-29 16:00:05 +02:00
Johan Walles
5ff126946a Move pager lines rendering into its own file 2021-05-29 14:38:41 +02:00
Johan Walles
ecae4811de Test that scolling to the last line works
It doesn't when we're in word wrapping mode.

Not sure how to fix this, but it is broken.
2021-05-27 06:48:51 +02:00
Johan Walles
3dd20e609d Don't lose whitespace-only lines 2021-05-25 17:18:18 +02:00
Johan Walles
a062dd25f8 Break markdown links between text and URL
These tend to be long and screw up formatting, they need special
handling.
2021-05-25 17:10:24 +02:00
Johan Walles
3b7a906ce1 Word wrap URLs after / 2021-05-24 19:10:31 +02:00
Johan Walles
dda01e25a3 Break before whitespace 2021-05-24 18:46:00 +02:00
Johan Walles
ea7e9252b3 Extract wrap cutoff into its own function 2021-05-24 18:37:14 +02:00
Johan Walles
896ac3e874 Add word wrapping tests 2021-05-24 18:30:31 +02:00
Johan Walles
3df48a4ade Simplify line wrapping tests 2021-05-24 18:16:57 +02:00
Johan Walles
e605199d92 Trim leading whitespace from wrapped lines 2021-05-23 16:23:04 +02:00
Johan Walles
0a40404070 Improve test feedback
On comparison failure, print both flavors.
2021-05-23 16:12:00 +02:00
Johan Walles
8a5f6fe473 Strip trailing whitespace when wrapping 2021-05-23 15:25:46 +02:00
Johan Walles
ac6bdb4dbb Update tests with new status line format
Line numbers are gone, the tests should reflect that.
2021-05-22 16:05:06 +02:00
Johan Walles
1538ed7e8d Don't display current line numbers in the footer
They are visible on the side anyway, having them in the status bar is
just redundant.

NOTE: Wrapping should:
	* default to off
	* be controllable from the command line
	* documented
2021-05-22 15:44:15 +02:00
Johan Walles
4efa280389 Make wrapping optional
And controllable from within by pressing 'w'.

NOTE: Wrapping should:
    * default to off
    * be controllable from the command line
    * documented
	* not mean we get the displayed line numbers wrong in the status line
2021-05-22 15:41:44 +02:00
Johan Walles
dcf8bbf9a7 Always wrap
NOTE: Wrapping should:
* be optional
* documented
* default to off
* be controllable from the command line
* be possible to toggle by pressing 'w'
2021-05-22 15:41:44 +02:00
Johan Walles
f0283e9e57 Implement simplistic wrapping 2021-05-22 15:41:44 +02:00
Johan Walles
b4a82b2668 Add initial line wrapper implementation
With failing tests.
2021-05-22 15:41:44 +02:00
Johan Walles
dc070cad75 Left pad line numbers
Fixes a regression, this is what it used to look like and should have
looked like all the time.
2021-05-22 15:39:39 +02:00
Johan Walles
f1061202ba Extract search highlighting into its own Line method 2021-05-22 11:25:44 +02:00
Johan Walles
7e3a73f053 Three-group line numbers
Both the numbers in the left column of the file display, and the line
numbers shown in the page footer.

Fixes #6.
2021-05-21 19:38:10 +02:00
Johan Walles
2b1e87b8ac Log received events on trace level
If you run moar with -trace you'll get all handled events listed after
moar finishes running.

The point would be to be able to debug mishandled keys as reported
in #55.

Also, remove the screen refresh timings from the trace logs. We get lots
of them, and I don't think they provide value any more.
2021-05-13 19:12:44 +02:00
Johan Walles
c95e164595 Enable picking style and formatter from command line
Related to #60.
2021-05-13 07:37:34 +02:00
Steven Penny
61f071936a Clean up imports
Remove "io/ioutil" and "math"
2021-05-11 12:20:31 -05:00
Steven Penny
747dd0a914 NewReaderFromStream: simplify init code
Remove redundant and single use variables
2021-05-11 11:35:04 -05:00
Johan Walles
5e49329110 Split a large function into smaller ones
For great readability.
2021-05-08 17:21:08 +02:00
Johan Walles
e3e8be0b8b CTRL-L isn't a thing any more
Since replacing tcell with twin, we now redraw the whole screen every
time, and CTRL-L doesn't do anything.
2021-05-08 15:05:12 +02:00
Johan Walles
5d5ecae7c0 Speed up line counting 4x
And improve large file loading performance in the process.
2021-05-08 14:16:38 +02:00
Johan Walles
09ab8a4072 Add a line counting performance benchmark 2021-05-08 13:57:54 +02:00
Johan Walles
78ab63273a Move some test-only code into *_test.go files 2021-05-08 10:32:04 +02:00
Johan Walles
99d8db63fb Improve startup interactivity
By moving line counting into the background goroutine that consumes the
input stream.

This will make the UI appear faster for large files where line counting
takes time.
2021-05-08 10:26:16 +02:00
Johan Walles
5e847f4cd7 Improve large file reading performance by 10%
By reading the file in two passes.

The first pass just counts the lines in the file.

The second pass starts by preallocating the correct number of lines, and
then reads the file.

The whole time saving comes from not having to dynamically resize the
lines slice while reading the file.
2021-05-03 20:33:25 +02:00
Johan Walles
97884d1805 Add a large file benchmark 2021-05-03 19:15:43 +02:00
Johan Walles
f8e45f73e2 Log input stream consumption time
At debug level.
2021-05-03 08:08:41 +02:00
Johan Walles
9af12f451c Move code outside of a lock 2021-05-03 06:44:57 +02:00
Johan Walles
7a66c633ca Lower memory usage by 10%
When loading a 577MB file.
2021-05-02 19:28:51 +02:00
Johan Walles
306442f2b2 Split a line to improve profilability
The line is top of the pprof alloc profile, but splitting it might
show which allocation on that line it is that is so common.
2021-05-02 17:36:22 +02:00