Commit Graph

260 Commits

Author SHA1 Message Date
9ace1ecb68 Moved from termion to crossterm for terminal handling.
This should (hopefully) make led work on Windows now.  Although
I don't have a Windows box to test on.

This also fixes a bug where control codes were ocassionally split
on input, resulting in e.g. a pg-down resulting in control
characters inserted into the buffer.
2020-01-25 04:07:56 +09:00
a867892183 Replaced docopt with clap for command line argument parsing. 2020-01-24 18:32:42 +09:00
bdbd9bce21 Make tests compile again after updating to Rust 2018. 2020-01-23 19:04:45 +09:00
dab1c9ed1b Updated to Rust 2018.
No functional changes.
2020-01-23 18:47:27 +09:00
9cadb9bd8c Run rustfmt and replace depricated try!() macro with ? operator.
No functional changes.
2020-01-22 10:20:29 +09:00
2f5adfad75 Run rustfmt. No functional changes. 2018-08-17 20:36:24 -07:00
b713b72e72 Updating for latest Ropey master. 2018-08-10 16:08:11 -07:00
75742c7aa4 Fixed bug with gutter size not updating as line numbers get wider. 2018-07-20 01:31:56 -07:00
bba508a814 Forgot to run rustfmt. 2018-07-14 01:32:58 -07:00
a3d98a59fb Updated to lastest master Ropey. 2018-07-14 01:32:24 -07:00
868aa3363f Updated some code for Ropey API changes. 2018-07-05 20:13:00 -07:00
f8a38111d4 Some nice performance improvements with a simple optimization.
We're now very close to being back to the performance levels
we were at before the new Ropey without built-in grapheme
support.
2018-07-05 18:43:17 -07:00
9348a9a916 Another small optimization. 2018-07-05 05:01:57 -07:00
b19997b975 Did some basic optimizations that made things fast again. Yay!
The basis for the optimizations were some less basic changes made
in Ropey.
2018-07-05 04:41:58 -07:00
5ca0f5e406 Fomatted with recent rustfmt. No actual code changes. 2018-07-05 02:00:10 -07:00
de625e71dc Updated to ropey git master, and got everything working again.
However, everything is very, very slow now.
2018-07-05 01:53:17 -07:00
16f2aab223 Updated to latest Ropey. 2018-01-11 02:05:00 -08:00
3f2dbf2c13 Fixed tiny bug in view scrolling behavior. 2018-01-01 15:22:28 -08:00
066f0b03cf Indentation detection can now detect arbitrary space counts.
It was using a fixed-size array before, but now is using a
HashMap.  This is technically slower, but it's such a negligible
part of the runtime to begin with that it doesn't matter.
2018-01-01 15:01:19 -08:00
020827806b Use iterator methods to make auto-detect code a little cleaner.
Also use chars instead of graphemes for indent detection code.
Graphemes are slower, and don't provide any benefit there.
2018-01-01 14:06:17 -08:00
7121469cba Termninal size information wasn't being set properly at startup. 2018-01-01 13:38:51 -08:00
54a16c6383 Fixed bug with word wrapping when a word is longer than a line. 2018-01-01 13:25:06 -08:00
dbb640b330 Fixed a couple of bugs that crashed at tiny terminal sizes. 2018-01-01 12:59:47 -08:00
86ca5f9edf Another silly bug... 2018-01-01 03:21:27 -08:00
cfcc9ab273 Silly bug due to forgetting to change a line of code. 2018-01-01 03:20:10 -08:00
2591aef6d4 Simplified the screen buffer writing.
Turns out the main reason it was so slow was because stdout isn't
buffered in Rust by default.  That actually makes a lot of sense,
but I'd forgotten.

Wrapping it in a BufWriter solves the performance issues much more
gracefully.
2018-01-01 03:10:32 -08:00
1f62eb32a0 Fixed a bug where very narrow terminal sizes would crash the editor. 2018-01-01 02:37:33 -08:00
1bb93aae00 Got interactive responsiveness to terminal resizing working. 2018-01-01 02:30:11 -08:00
c91f1801ad Fixed bug in screen buffer display code.
This both more correct and faster at the same time.  Yay!
2018-01-01 01:27:37 -08:00
17beb9c06d Using a smallstring implementation inside the screen buffer.
This keeps things contiguous in memory in the common case.
2017-12-31 20:05:00 -08:00
0a309fab1a Made the screen buffer implemention way faster.
It's in a pretty good place now, I think.  Although its memory
usage could be improved with a small string type.
2017-12-31 19:40:45 -08:00
945505c5ff WIP making the buffer faster. 2017-12-31 19:30:28 -08:00
66a80baeed Doing screen buffering to eliminate flicker.
At the moment, it's brain-dead and really slow.
2017-12-31 18:51:02 -08:00
b63bb6f87d Fixed silly drawing bug.
The cursor wasn't displaying if it was on the end of a line.
2017-12-31 17:36:13 -08:00
c7adf195f7 Moving screen drawing handling to a submodule. 2017-12-31 17:30:21 -08:00
c11aee9bf6 WIP switching from Rustbox to Termion for terminal handling. 2017-12-31 16:55:27 -08:00
6ccba0510b Forgot to delete a bit from commandline option parsing. 2017-12-31 03:35:09 -08:00
e47c0e0451 Updated to the latest versions of dependencies. 2017-12-31 03:33:43 -08:00
29b17f6e20 Fixed minor bug in cursor navigation. 2017-12-31 03:04:25 -08:00
76bd98e5ae Got cursor movement working with graphemes, and fixed unit tests. 2017-12-31 02:41:07 -08:00
f221b90a82 Fixed cursor drawing for texts with graphemes in them. 2017-12-31 02:17:28 -08:00
2e9c2b2704 WIP getting graphemes working again. 2017-12-31 01:56:45 -08:00
ca948588e6 Fixed line-ending detection. 2017-12-31 01:04:33 -08:00
eb47c4844b Remove unused import. 2017-12-31 00:45:05 -08:00
c9d8be0704 Use Ropey's reader to load from disk.
Saves memory and is also faster.  Win-win!
2017-12-31 00:43:37 -08:00
2da187ff5d Got it fully working again except for graphemes. 2017-12-31 00:39:02 -08:00
47ed45aae6 More fixing. 2017-12-30 23:47:05 -08:00
9c302620e9 Updating to use the new Ropey.
This is mainly just for kicks and giggles, since it really won't
work quite properly anyway, due to the lack of grapheme indexing.
The next real thing is to... well, start from scratch.
2017-12-30 23:10:56 -08:00
45e6125bbc Updated to work with more recent library versions. Also RustFmt. 2016-03-05 02:40:01 -08:00
f1ffc2867a Unit tests now also compile on stable rust. 2015-07-06 19:31:55 -07:00
ec16e8ac6e Led is building on stable rust! Woo hoo! 2015-07-06 19:20:25 -07:00
6823706d69 Working towards rust stable support. 2015-07-06 18:39:00 -07:00
9644a1aa03 Updated dependencies for stable rust.
Warning: doesn't compile.  Haven't updated own code for stable
yet.
2015-07-06 18:14:12 -07:00
869cb187b6 Migrated code from std::old_io to std::io 2015-03-15 16:03:23 -07:00
57f013bd46 Updated to latest rustc and rustbox. 2015-03-15 14:47:16 -07:00
1d6a8cb107 Added ability for soft-wrapped lines to have additional indentation. 2015-03-08 19:58:18 -07:00
cbff82b462 Implemented word wrapping. 2015-03-08 19:47:30 -07:00
e1e06633c7 Added option to maintain indentation when wrapping lines.
Currently only exposed in code, not in UI.  Enabled by default.
2015-03-08 12:18:22 -07:00
ed510cffbc WIP more line wrapping options.
This commit just adds code to allow non-wrapping behavior.
2015-03-07 18:30:18 -08:00
b2f1044b48 Fixed bug resulting from API change in Ropey. 2015-03-03 16:27:38 -08:00
f4847a4f8e Updated to latest Docopt and Ropey.
Also fixed bug resulting from a change in API behavior in Ropey.
2015-03-03 15:26:20 -08:00
cca7133264 Updated code to latest Ropey. 2015-03-03 00:08:52 -08:00
1ae3a01566 Updated code to work with the latest Ropey. 2015-03-02 16:08:50 -08:00
ada003b346 Split rope implementation off into external lib "Ropey".
Ropey can be found at https://github.com/cessen/ropey
2015-02-25 20:05:17 -08:00
82e6fca1dd Updated code for latest rustc. 2015-02-23 20:50:55 -08:00
d3cd1c4b05 Fixed bug in Editor::move_view_to_cursor().
Was causing the view to move unecessarily when the cursor is at the end of
the buffer.
2015-02-22 20:35:41 -08:00
c532b10f22 Fixed bug in Editor::move_view_to_cursor()
It thought it was one line shorter than it actually was.
2015-02-22 20:30:33 -08:00
c348f252bb Fixed bug in buffer drawing code.
It was causing the entire last line to be re-scanned to find the
cursor drawing position if the cursor was at the end of the buffer.
This was both slow and resulted in an incorrect position, since
all the rest of the drawing assumes line blocks.
2015-02-22 20:24:19 -08:00
ae26c5f873 Fixed bugs in LineFormatter that was causing weird cursor nav behavior.
They were two pretty much identical bugs in both index_offset_vertical_v2d()
and index_set_horizontal_v2d().  Neither method was checking for slipping
off the end of a line block.
2015-02-22 20:09:18 -08:00
1b3acfd29f Fixed bug in LineFormatter::index_offset_vertical_v2d()
The bug was causing very incorrect behavior when a single line was long
enough to be split into multiple blocks.
2015-02-22 19:30:13 -08:00
9c462ee332 Finished converting codebase back to plain Rope's.
Everything appears to be working identically to how it was before converting
back.
2015-02-22 18:13:10 -08:00
fee6fc21a3 Removed line and node source files since they are no longer used. 2015-02-22 12:30:02 -08:00
dcfa3fe0d5 Got unit tests compiling again, and added a few more to Rope. 2015-02-22 12:28:31 -08:00
02f24e4e6f WIP refactor to switch over to Rope from BufferNode. 2015-02-22 11:45:57 -08:00
0ee364f6ce Added Rope methods for converting between grapheme indices and line/column indices. 2015-02-22 00:15:18 -08:00
759b23db4d Added methods to Rope for finding the relationship between lines and graphemes. 2015-02-21 23:51:15 -08:00
c276117ac6 Rope now tracks line endings. 2015-02-21 22:55:14 -08:00
0da0b532d0 Forgot to set rope leaf size back to something reasonable. 2015-02-21 13:18:28 -08:00
d87dd9a343 Implemented efficient Rope splitting.
Rope::split() should now run in O(log N) time instead of O(N).
2015-02-21 13:12:26 -08:00
e082defad8 Added benchmarks for Rope::append() and Rope::split(). 2015-02-21 11:44:32 -08:00
52cb5f9456 Improved Rope's text insertion performance for large insertion strings. 2015-02-21 11:16:21 -08:00
a37bc17289 Even further improved balance unit tests.
Now the ropes are directly checked for adhering to the AVL balance
invariants.
2015-02-19 23:39:24 -08:00
b3ba8acdf5 Significantly improved Rope::rebalance() unit tests.
Now they directly run rebalance() on hand-constructed trees that test
various situations.
2015-02-19 23:23:36 -08:00
fe0a7e48ca Fixed bug in Rope::new_from_str().
The stragglers appended at the end were being appended at the top of
the tree, making it very unbalanced.  Using proper appending now.
2015-02-19 22:52:21 -08:00
2df1302723 Fixed bug in Rope::rebalance(). Stats weren't updated after rebalance. 2015-02-19 22:46:30 -08:00
5500c845f5 Ropes can now generate graphviz of their tree. Useful for debugging. 2015-02-19 22:39:57 -08:00
de668c5ddf Improved Rope::append()
Append no longer depends on a performant rebalance() operation in any
cases.  Append is guaranteed O(log N) now.
2015-02-18 23:41:28 -08:00
d95161b88f Improved Rope::rebalance() to actually rebalance properly in non-AVL cases.
The prior version worked fine for the typical single insertion/removal
cases.  But when larger imbalances happened due to bulk insertion or
removal it wouldn't work correctly.

The new improved version works on any tree whose children are themselves
balanced, even if they are extremely different heights when compared to
each other.  It works in O(log N) time.
2015-02-18 23:11:10 -08:00
535f219c41 Improved algorithm of Rope::append()
It doesn't use an intermediate conversion to a string anymore, and should
execute in O(log N) as long as the right-hand rope is equal length or
smaller than the left.

It may also be O(log N) for the left-hand rope being smaller, but that
depends on whether the rebalance code executes in O(log N) time when
the left and right hand side are individually balanced.  I haven't
analysed it yet, so dunno.
2015-02-17 23:10:38 -08:00
d26c95ab1d Fixed some bugs in the display code.
Everything seems to display correctly now.
2015-02-16 22:46:38 -08:00
311f8aca67 First attempt at making display code really take advantage of long line support.
It's not quite working right, but it does at least prevent performance
degradation.
2015-02-16 22:29:41 -08:00
86f3ada8ea Small tweak to indentation style auto-detection.
Very slightly favor larger indentations, instead of very slight favor
smaller indentations.  This is more likely to do the right thing on
very small files.
2015-02-16 22:06:48 -08:00
d3cbc7644f Updates for latest rustc. 2015-02-16 22:01:22 -08:00
0bc809781d WIP: fixes for long line support. 2015-02-15 23:23:17 -08:00
ecf91607ac WIP long line support.
Got index_offset_vertical_v2d() partially working.  Still seems to be a tad
buggy, though.
2015-02-15 23:09:13 -08:00
a1d636a4d8 WIP: handling extremely long lines with good performance.
The formatters now work on grapheme iterators instead of directly on
lines, which frees up the LineFormatter to break up long lines into
smaller blocks of text.  This is partially taken advantage of right
now in various parts of the code, but more work is still needed to
get it both working properly and fast.
2015-02-15 22:41:11 -08:00
f4a70ba1ad Made screen drawing a tad faster for long lines.
In preparation for much more major speed-ups with long lines.
2015-02-15 20:35:17 -08:00
6eed3fcc74 Improved file load times.
There was a regression after switching to ropes.  Now it's pretty much
back to pre-rope load times.
2015-02-15 20:15:19 -08:00
de58f01b2f Added some benchmarks for Rope, and improved new_from_str() for Rope.
The new new_from_str() uses an algorithm that should be linear time
complexity compared to the length of the string.
2015-02-15 19:42:07 -08:00
e1c9a6955d Lines now internally use ropes to store their text.
The rope uses a large leaf-node text length, so in the vast majority of
cases this ends up being the same as directly storing the string data.
But in the case that the line becomes extremely long, this will allow
for reasonable performance
2015-02-15 14:56:56 -08:00