-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* (WIP) Add support for up/down arrows. Up and down arrows now have some behavior, but it is currently not as intended. * (WIP) Change up and down arrow support implementation. * (WIP) Up and down arrows working. Movement is working, but behavior is still undefined at the and end of files, so there are a few bugs to be fixed. * Change init of variables to avoid conflict. Newline index variables n1 and n2 now initialize to -1 to avoid conflict when running into the beginning of the document. * (WIP) Fix down arrow behavior Down arrow behavior seems to be working in standard use and some edge cases. Up arrow has not been fixed. * Fix down arrow behavior * Fix up/down arrow bugs Got an implementation of up/down arrow behavior working. The implementation is rather convoluted and hard to reason about. There is definitely room for tightening the logic and improving readability. It's also worth considering a change to the way editor text is currently represented, so that it maps more closely to Termbox's 2D structure. A 2D array of runes might make a more natural interface between the linear CRDT document and the 2D Termbox terminal, and therefore make the code cleaner and more maintainable. Future: - tighten logic - remove logging - refactor (explore alternate ways to store editor text) * Change comments in MoveCursor function. * Remove duplicate line. * Remove logging and unused variable. * Refactor MoveCursor into smaller functions. * Fix unused parameter and duplicate initialization. * Fix ineffassign linting error. * Fix panics occurring with empty document. Fixed a couple of crashes that happened due to out of bounds errors if the document was empty. MoveCursor would try to do some invalid calculations which are now avoided by checking the text length first. Also, on delete, the cursor was getting reset to 1 instead of 0, which caused a crash when characters were inserted. * (WIP) Add tests and fix some cursor movement bugs. Added many tests for cursor movement. Still in the process of fixing the bugs found in the tests. Also temporarily added logging to help with bug fixing. * Upward cursor movement now passes tests. Rewrote calcCursor up with slightly different logic. It is simpler and cleaner than the previous attempts. Further refinement might be possible. * Remove old functions and extraneous comments. * Refactor downward cursor movement. Changed calcCursorDown to match calcCursorUp logic. Both functions now pass tests. * Add test cases. * Fix cursor movement bugs and add/update comments. Fixed a couple more edge cases with the new cursor movement logic, including some cases where panics occurred. Behavior now seems to match expectations. Also updated comments for both calcCursorUp and calcCursorDown. * Fix first character not able to be deleted. --------- Co-authored-by: burntcarrot <[email protected]> Co-authored-by: Aadhav Vignesh <[email protected]>
- Loading branch information
1 parent
86779c0
commit aea18bb
Showing
4 changed files
with
216 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters