-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor motion. #87
Refactor motion. #87
Conversation
e0da902
to
364d5b5
Compare
As this is a major refactor, let me know what you think @guillermooo or @adriaanp or @kimitake (as you had done the original work). |
d6a110a
to
baf8889
Compare
6dd2b41
to
2aab565
Compare
Create a base motion class in which cursor and caret extend. The difference between the two classes: * Valid positioning for Caret = [0, EOL) * Valid position for Cursor = [0, EOL] * Whenever we do get a styling for cursor/caret, that logic can be placed in their respective classes. Motions were becoming cumbersome. With this refactor, motions are now composable making repeatable actions super easy: `new Cursor().left().left().left().up().down().move(); The UI updates on the `move()` command. Also fixes #89 in this refactor.
2aab565
to
d04b0d7
Compare
👍 Love it! |
I strongly agree with to instantiate the cursor/caret in mode class, actually I tried to do when I created caret class, but I needed to modify a lots, so I gave it up :) btw, do you have a plan to add default argument as 1 for left, right, up, down etc? |
No, you can achieve the same composing it => new cursor().right().right().right(). |
e.g. the user inputs "10h", so for (var i=0; i<10; i++) { Is this correct? how about 1000G etc? |
Well, |
👍 |
Create a base motion class in which cursor and caret extend. The difference between the
caret
vscursor
and why I thought it necessitated separate classes:Another reason for the refactor was to move towards a model of OOP rather than static functions. Additionally, motions are now composable. This makes repeatable actions super easy:
new Cursor().left().left().left().left()
or mix and match:
new Cursor().left().lineEnd().down()
The UI is only updated on the
move()
command =>new Cursor(0, 2).lineBegin().down().move()