Commit Graph

43 Commits

Author SHA1 Message Date
Kevin Sawicki & Nathan Sobo
59d0742c17 Remove Anchor and AnchorRange. They're fully replaced by markers.
We're still leaking markers for selections and cursors. We need to
clean that up before merging.
2013-02-05 18:15:48 -07:00
Nathan Sobo
1d30605f7f Convert selection and cursor fully over to markers. 2013-02-05 13:39:00 -07:00
Nathan Sobo
2380fa3445 Handle 'autoscroll' entirely in Cursor instead of in Anchor
This commit makes autoscroll a 3-valued property on the cursor. If it
is set to true or false, that setting will stick until the cursor's
next visual update. That means we can explicitly move the cursor with
autoscroll set to false, but also still autoscroll by default when the
cursor's anchor moves on its own.
2013-01-29 12:11:43 -07:00
Nathan Sobo
f4f3002e6d Rename Cursor and CursorView events to passive-voice scheme
Any events emitted from DOM nodes should be prefixed with an identifier
for the node that emits them. This eliminates the possibility of ambiguity
when the events bubble up the DOM away from their emitter.
2013-01-02 13:48:11 -07:00
Corey Johnson & Nathan Sobo
be2b9ee100 Store autoscroll state on Selection and Cursor models 2012-11-30 12:08:41 -07:00
Nathan Sobo
833ccb30ab Pass old and new screen position with Anchor/Cursor move events 2012-11-29 13:39:00 -07:00
Nathan Sobo
91e899456a Rename 'change-screen-position' event to 'moved' on Anchor and Cursor 2012-11-29 13:39:00 -07:00
Nathan Sobo
a1cff240b6 Use 'blink-off' css class to blink the cursor when editor is focused
Rather than managing the visibility directly, a class makes it easy. The cursors will always be toggling this class on and off in the background, but only on the focused editor will it actually have an effect.
2012-11-14 21:43:06 -07:00
Nathan Sobo
e47cc1256d Don't blink the cursor if it should not be visible
Also, when stopping blinking, set the cursor's visibility to whatever it is on the underlying model. This fixes issues where the cursor would blink when there was a selection.
2012-11-14 21:21:48 -07:00
Nathan Sobo
185ca22488 Make cursor blink by changing CSS visibility with setInterval
This is actually more efficient than the CSS animation we were doing previously, because it doesn't force the cursor to be sampled at 60 FPS for something that changes around twice a second.
2012-11-14 20:43:34 -07:00
Nathan Sobo
28a937089f Trigger 'cursor-move' events when cursor view changes 2012-11-14 14:35:08 -07:00
Corey Johnson & Nathan Sobo
9fa577f8c4 Using requestAnimationFrame with some disabled features
Not sure if it feels faster, but the code is a bit more organized at least.
2012-11-13 18:25:29 -07:00
Corey Johnson & Nathan Sobo
cef9ce6ca7 Add needsUpdate and needsAutoscroll properties to cursor views
Then in the editor, we update and autoscroll only the views that need it. Autoscrolling is suppressed when resetting the display so that we honor the scroll positions of the active EditSession.
2012-11-13 17:20:48 -07:00
Nathan Sobo
ee233d56a7 Remove unused autoscrollOnAttach flag from CursorView
We no longer call `updateDisplay` immediately when the cursor is attached. Instead, we always attach and remove cursor views from `Editor#updateDisplay`, so we will decide whether to autoscroll at that level.
2012-11-13 15:08:44 -07:00
Nathan Sobo
c09249313b Only add CursorViews during Editor#updateDisplay
The goal is that no model operation will ever modify the DOM directly. We will always request a display update, which will happen on the next animation frame.
2012-11-13 14:54:59 -07:00
Nathan Sobo
8aad2480b6 Only autoscroll to cursor when it is attached *after* reset 2012-11-13 14:30:24 -07:00
Corey Johnson & Nathan Sobo
b5efec308a wip: updateDisplay 2012-11-13 12:08:41 -08:00
Corey Johnson & Nathan Sobo
9c0f1d428f Rename updateAppearance to updateDisplay 2012-11-13 11:21:46 -08:00
Nathan Sobo
312f64d200 Don't make hidden input a child of Editor's scrollView
If the input element is a child of the scroll view, then focusing it can end up changing the scroll position of the view behind our backs. We *only* want to scroll the view via our interface on editor, because a bunch of of special code needs to run when we scroll. We can't just have the browser scrolling that view around willy-nilly.
2012-11-07 19:47:31 -07:00
Nathan Sobo
19c8a39fc8 Don't autoscroll to bottom of buffer on selectAll 2012-11-07 16:01:10 -07:00
Nathan Sobo
cd9e3b774a Always move the hidden input element to the cursor's screen location
This avoids spuriously auto-scrolling to the left when opening an autocomplete in an editor that's scrolled to the right.
2012-11-07 13:04:54 -07:00
Nathan Sobo
88e246b622 Hide the cursor when the selection is not empty 2012-10-29 15:51:32 -06:00
Corey Johnson & Nathan Sobo
2c763a4d48 💄 2012-10-01 15:44:56 -07:00
Nathan Sobo
c3e748a17c WIP: Use rake to start compiling resources (like require.coffee) 2012-08-26 16:29:46 -05:00
Nathan Sobo
c2c8724ad0 Initial commit 2012-08-10 13:32:19 -06:00
Nathan Sobo
4e74f1bf2e Fix issues with selections when switching between edit sessions
SelectionViews now update their appearance immediately when constructed. We can't assume they're empty. CursorView doesn't do a blanket `off()` call to its model when it's removed anymore, which was screwing up selection updates when switching back. Only attach selections / cursors when the editor is attached, and extract everything we do into a `renderWhenAttached` method.
2012-06-11 22:01:27 -06:00
Nathan Sobo
cffadcf4a8 Remove CompositeCursor and Selection. Move their remaining methods into Editor 2012-06-11 10:11:33 -06:00
Nathan Sobo
8c52fedd0d Remove last of the extraneous CursorView methods 2012-06-10 21:53:54 -06:00
Nathan Sobo
e0aa49cb53 More CompositeCursor 💄. Preparing to axe it 2012-06-10 21:43:24 -06:00
Nathan Sobo
80cd63227a Remove methods from CompositeCursor + more 💄 2012-06-08 19:08:44 -06:00
Nathan Sobo
b0d1dd217b Cursor *model* clears selection when cursor moves, not the view. 2012-06-08 18:49:18 -06:00
Nathan Sobo
31bd38dfcc Move merging of intersecting selections into EditSession and the Selection model 2012-06-08 13:26:54 -06:00
Nathan Sobo
f3144fe0d8 Base the screen range of the selection view on the selection model 2012-06-08 11:22:12 -06:00
Nathan Sobo
5a37a39b9b Tie creation of SelectionViews to adding Selection models to the EditSession 2012-06-07 18:20:00 -06:00
Nathan Sobo
608c4f48bf Remove more logic from cursor view 2012-06-07 16:58:45 -06:00
Nathan Sobo
f406786a3a Editor subscribes to EditSession for screen line changes. Remove more movement logic from cursor view. 2012-06-07 16:31:40 -06:00
Nathan Sobo
624cf3cbd3 EditSession informs cursor models of buffer changes (instead of Editor informing cursor views) 2012-06-07 15:41:35 -06:00
Nathan Sobo
d872d12e04 Transfer word movement methods into cursor model 2012-06-07 15:33:01 -06:00
Nathan Sobo
21ae28657c Move moveTo(Beginning/FirstCharacter/End)OfLine methods to cursor model
Also, implement move to end of line by adding a clip option to setBufferPosition and passing [row, Infinity]
2012-06-07 11:28:40 -06:00
Nathan Sobo
fccc88acaf Move moveLeft/Right/ToTop/ToBottom methods into cursor model 2012-06-07 10:57:21 -06:00
Nathan Sobo
ddf29e89ec Slave CursorView's screen position to its cursor model. Move moveUp and moveDown methods into cursor model. 2012-06-07 10:47:30 -06:00
Nathan Sobo
7387c553c3 Start introducing Cursor model in EditSession
The old cursor view still does most of the work, but to add a new cursor view we now must add a cursor model to the edit session at the correct position. The editor watches the 'add-cursor' event on edit session and add a corresponding CursorView to the CompositeCursor whenever a model is added. Next step: have the cursor view observe the cursor model and shadow its changes in position.
2012-06-06 21:52:19 -06:00
Nathan Sobo
e167afd794 Rename Cursor to CursorView in preparation for a Cursor model in EditSession 2012-06-06 18:01:08 -06:00