Commit Graph

86 Commits

Author SHA1 Message Date
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
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
0bc809781d WIP: fixes for long line support. 2015-02-15 23:23: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
a89e505fb0 Beginnings of a Rope data structure for strings.
This will be used to hold the text of an individual line, for better
long-line handling.
2015-02-14 14:19:46 -08:00
2d50906f43 Moved the rest of file loading/saving into Buffer. 2015-02-07 23:35:25 -08:00
e9462e4400 Silencing some rustc warnings. 2015-02-07 19:55:25 -08:00
26965417f3 WOrking on getting cursor movement working again. 2015-02-07 19:46:08 -08:00
6f2cbe5b87 Basic text buffer drawing is working again. 2015-02-07 00:45:28 -08:00
8319033ae5 First step in pulling formatters out of the text buffer.
This commit pulls the formatter out of the text buffer and
puts it in the editor instead.  However, there is a lot of
commented code utlizing the buffer and formatter that still
needs to be updated.

In short, the editor is pretty non-functional in this commit.
2015-02-06 19:47:52 -08:00
e29777e33c Improved file loading.
File loading is now the responsibility of the Buffer, which allows
it to do some weird internal stuff to make it faster.

Also, using custom code for scanning the text, so all line endings
are handled now, not just LF and CRLF.
2015-02-01 23:17:43 -08:00
c9d09f6f98 Moved line_ending_type out of Buffer and into Editor. 2015-01-31 15:06:04 -08:00
afa1a8f67c Fixed nasty bug in reformatting code.
It was not actually reformatting things...
2015-01-31 13:41:41 -08:00
7b87db4e41 Line wrapping width is now determined by terminal width. 2015-01-31 13:19:14 -08:00
8701ebbba7 Tweaked code to avoid warnings from latest rustc compiler. 2015-01-29 21:03:56 -08:00
5652b62fc8 Misc code cleanup. 2015-01-28 00:09:07 -08:00
f222cd6a54 Fixed remaining cursor navigation bugs (I think...?). 2015-01-27 23:58:45 -08:00
04816ebe84 Beginnings of line wrapping for terminal ui. 2015-01-26 22:55:47 -08:00
352e5370ce Fully updated unit tests. All passing again. 2015-01-25 13:28:04 -08:00
0557f5f6ce Reorganized the code a bit, and started updating unit tests. 2015-01-25 13:20:16 -08:00
a69f89d238 Fixed bug in v2d_to_index code that was causing cursor nav issues. 2015-01-24 21:15:32 -08:00
4caad17e56 Console drawing is almost back up to snuff.
Just missing drawing the cursors if it's at the end of the text buffer.
2015-01-24 21:00:30 -08:00
c69ebc240f WIP: making Buffers so they can be given LineFormatters.
A LineFormatter determines how a line of text is visually displayed in
2d space.  This allows both the Console and GUI version of the editor
to share the same buffer code whilst still handling the differing ways
in which both handle visual display.
2015-01-24 14:35:49 -08:00
ac784077f0 Split cursor code into separate file.
There is now a CursorSet type that handles multiple cursors, and makes
it convenient to maintain the necessary invariants expected by the rest
of the code for multi-cursor editing.
2015-01-18 15:11:49 -08:00
d6e28b02a3 Fixed some warnings. 2015-01-11 01:16:21 -08:00
f56d3f0ad4 Split remove_text() into remove_text_before() and remove_text_after().
This is useful so that undo knows where to put the cursor.
2015-01-11 00:59:02 -08:00
dfcf9fc6a5 A simple implementation of move_text.
This should probably be replaced by a more efficient implementation in
the future, as this version will be slow and require large allocations
when moving large pieces of text.  But let's wait and see if it's a
problem in practice first.
2015-01-11 00:26:39 -08:00