Commit Graph

671 Commits

Author SHA1 Message Date
Nathan Sobo
a72dc17b87 Move hidden input to follow cursor to stop spurious scrolling
Commit 8e77c05c fixed scrolling *up* when clicking the buffer while
scrolled down. But it was still scrolling to the far left when typing /
clicking on a really long line. This commit solves both issues by
always positioning the hidden input to the same location as the cursor,
so it doesn't tell webkit to scroll away from the current focus when it
is focused or the user types.
2012-01-31 11:21:13 -07:00
Corey Johnson
84d9824b19 buffer.getTextInRange handles multiple lines. 2012-01-31 09:56:16 -08:00
Nathan Sobo
4575483d80 Selection expands flexibly when window is resized
If a region of the selection needs to span the full line, I assign
right: 0 instead of a width so that it always stretches across the
entire editor, even after a resize.
2012-01-31 10:55:17 -07:00
Nathan Sobo
666ef76c83 Never use more than 3 divs to render a selection
This should hopefully improve performance for large selections.
2012-01-31 10:44:10 -07:00
Nathan Sobo
21a5f25d93 Merge branch 'master' of github.com:github/atom into editor
Conflicts:
	src/atom/editor.coffee
2012-01-30 19:47:51 -07:00
Corey Johnson
f9527859a3 💄 2012-01-30 17:46:18 -08:00
Corey Johnson
7dba7dc3de meta-c copies text in selection 2012-01-30 17:46:03 -08:00
Corey Johnson
99cbb5e0a2 Cache compiled CoffeeScript on the Objective-C side.
This is a temporary fix, it just stores compiled scripts in memory. It
doesn't speed up the app start since the scripts need to be compiled
once. Here are some numbers.

#file load
pre: 1.5 seconds
post: 0.25 seconds

#spec load
pre: 5.4 seconds
post: 0.36 seconds
2012-01-30 16:19:28 -08:00
Nathan Sobo
8e77c05c06 Fix bug: Don't scroll to top on click after scrolling down.
The editor has a tabindex of -1 so it can receive focus. This makes it
behave like a focusable element such as a textarea. But in reality,
when the editor receives focus, it just focuses the hidden input that
it watches for textInput events. So when you click, focus is stolen
away from the hidden input and goes to the editor. But then the editor
sends focus back to the hidden input. Because the input was at the top
of the screen, WebKit would scroll up to bring it on screen when
focused. So now I just bring the hidden input on screen (by positioning
it even with scrollTop) before focusing it. That prevents the WebKit
from scrolling.
2012-01-28 22:36:47 -07:00
Nathan Sobo
a77dd28e47 Fix bug: can now delete multiple lines
Before, we were traversing through lines to remove in ascending order
and then calling remove(n) for each. But when we removed line 10, line
11 became the *new* line 10. So when we removed line 11 we ended up
skipping the old line 11. I solved this by traversing in reverse when
we need to delete lines.
2012-01-28 22:05:35 -07:00
Nathan Sobo
1dd718f896 Can select text with the mouse 2012-01-28 17:00:59 -08:00
Nathan Sobo
3e5cef9672 Cursor can be re-positioned with the mouse 2012-01-28 15:54:01 -08:00
Nathan Sobo
7f97747acb Oops 😳 2012-01-27 18:48:19 -08:00
Nathan Sobo
cb3d97692e Auto-scroll horizontally after exceeding editor.hScrollMargin
Rename previous editor.scrollMargin to vScrollMargin to indicate it's
for vertical scrolling.
2012-01-27 18:42:20 -08:00
Corey Johnson & Nathan Sobo
dea99216d4 Cursor blinks 2012-01-27 17:33:02 -08:00
Corey Johnson & Nathan Sobo
900f745b65 Delete removes character in front of cursor. 2012-01-27 14:16:17 -08:00
Corey Johnson & Nathan Sobo
3b64b78336 Backspace with a selection only deletes the selected text 2012-01-27 13:48:20 -08:00
Corey Johnson & Nathan Sobo
fbd4b0b78a Show console with alt-meta-i instead of on startup 2012-01-27 13:18:29 -08:00
Corey Johnson & Nathan Sobo
43ae4fd4e8 Editor owns cursor again.
Selection just watches for cursor movement, but it doesn't need to
contain the cursor.
2012-01-27 13:05:55 -08:00
Corey Johnson & Nathan Sobo
a7a38d075d Selection and cursor update their own appearance
Cursor emits a move event that the selection listens for. The selection
updates its appearance when this happens, but does not tell the cursor
to update. The cursor takes care of itself.
2012-01-27 12:53:07 -08:00
Corey Johnson & Nathan Sobo
29e7a6d774 Moving the cursor without holding shift clears selection 2012-01-27 12:42:33 -08:00
Nathan Sobo
6bf82a27c9 Selections render themselves on screen (1 div per line)
Still a lot of details to cover, but basic selection creation is
working.
2012-01-26 18:54:18 -08:00
Nathan Sobo
5aeef9e58f WIP: Starting on creating a selection with shift-arrows
Introduce Point and Range objects. Selection.selectRight places an
anchor object before moving right if no anchor yet exists. Still no
visual treatment.
2012-01-26 15:45:49 -08:00
Nathan Sobo
4c7441326c Move text manipulation methods to selection
Ultimately, the current selection will control the location / extent of
any manipulation, so it makes sense to put these methods there.
2012-01-26 14:16:17 -08:00
Nathan Sobo
2825c945e5 💄 2012-01-26 13:46:12 -08:00
Nathan Sobo
c70206fc9c Introduce Selection object that contains the cursor
All cursor operations will be proxied through the selection, so that
the selection can be cleared if necessary.
2012-01-26 13:23:59 -08:00
Corey Johnson
902c714f00 Rename col to column 2012-01-26 10:16:43 -08:00
Corey Johnson
585cfe429b 💄 2012-01-26 09:46:32 -08:00
Nathan Sobo
8ea937b15b When possible, re-assign line element text instead of replacing.
Slight speculative optimization but it's pretty simple.
2012-01-25 18:39:56 -08:00
Corey Johnson & Nathan Sobo
90faddf9f1 Refactor all buffer manipulation to use Buffer.change
Change takes a range and a string and replaces the range with the
string, then emits a change event with the range of text that was
changed, the range of text occupied by the new string, and the string
itself. This can be used to implement backspace, insert, as well as
various cut and paste manipulations.
2012-01-25 17:59:15 -08:00
Corey Johnson & Nathan Sobo
b5317b83a5 Implement backspace on Editor 2012-01-25 16:07:04 -08:00
Corey Johnson & Nathan Sobo
3a423e2a16 Implement backspace on Buffer 2012-01-25 14:33:47 -08:00
Corey Johnson & Nathan Sobo
045c3c39bf Render empty lines correctly when inserting newlines 2012-01-25 13:36:32 -08:00
Corey Johnson & Nathan Sobo
c536933c0b Newline chars can be inserted into the buffer. 2012-01-25 12:58:36 -08:00
Corey Johnson & Nathan Sobo
430869b7e0 Show inspector with javascript 2012-01-25 12:29:36 -08:00
Corey Johnson & Nathan Sobo
c11a618a9f X and Y were inverted 2012-01-25 12:20:58 -08:00
Corey Johnson & Nathan Sobo
0528a7b8cb 💄 2012-01-25 10:37:19 -08:00
Corey Johnson & Nathan Sobo
3317afb695 Make @edtior a field on Cursor 2012-01-25 10:28:50 -08:00
Corey Johnson & Nathan Sobo
e192bc7350 cursor has an @editor method instead of referring to @parentView a lot
Punt on making a field since @parentView is null when Cursor.initialize
is called.
2012-01-25 09:47:53 -08:00
Corey Johnson & Nathan Sobo
f6ec9daf39 Rename col/row to x/y 2012-01-25 09:35:33 -08:00
Nathan Sobo
9d911d29c5 Bug fix: Editor retains focus when clicked while already focused
I couldn't find a way to test this really. It's some interaction
between focusout and focus events. When the hidden input has focus and
then we call focus on the editor, the handling of the focusout event
away from input was trigerring a call to focus on the editor, which
didn't seem to trigger the handler that shifted it back to the hidden
input. Here I only focus the editor if something *outside* of the
editor was de-focused. So focusing the editor when the input is focused
is ignored, and focus is gracefully returned back to the input.
2012-01-24 18:14:38 -08:00
Corey Johnson & Nathan Sobo
0fe70f0920 Focus Editor on DOM attachement 2012-01-24 17:26:38 -08:00
Corey Johnson & Nathan Sobo
b4d91f2bc7 Typing inserts a character at the cursor position 2012-01-24 17:19:01 -08:00
Corey Johnson & Nathan Sobo
6af33c3337 Editor directs focus to a hidden input element.
Now we'll be able to listen for textInput events, which give us better
information about what character is being entered in the presence of
multi-keystroke compositions like alt-u,u for ü
2012-01-24 15:27:05 -08:00
Corey Johnson & Nathan Sobo
59086a1131 Map h to MoveRight 2012-01-24 10:06:25 -08:00
Corey Johnson & Nathan Sobo
10bf803fe0 Make tests green
Some need to be disabled because they rely on ace. Others fixed. Others
deleted.
2012-01-23 17:28:16 -08:00
Corey Johnson & Nathan Sobo
5ddf4e1a0b Ensure combined scroll margins are smaller than editor height.
This prevents jerky scrolling when the window is very short.
2012-01-23 17:15:11 -08:00
Corey Johnson & Nathan Sobo
1a52890d19 Cursor scrolls editor as it moves 2012-01-23 16:45:00 -08:00
Corey Johnson & Nathan Sobo
81fc69120f Retain goal column when moving up on first line.
Also: Respect a goal column of 0 when moving down on last line and then
back up. (Unlike TextMate)
2012-01-23 14:56:30 -08:00
Corey Johnson & Nathan Sobo
101d20692d Don't nuke goalColumn when moving down on last line 2012-01-23 14:37:03 -08:00