Commit Graph

1290 Commits

Author SHA1 Message Date
Nathan Sobo
796e24f278 Add Editor.linesForScreenRows and .getScreenLines
These just abstract the line wrapper as the source of the screen lines.
2012-02-27 10:31:37 -07:00
Nathan Sobo
8e107359f3 Changes correctly update cursor position when there are folds 2012-02-24 22:08:34 -07:00
Nathan Sobo
0bc510ab58 Properly translate positions when wrapper and folder are composed
The key was in LineMap.linesForScreenRows. For each screen line, it
concatenates all line fragments (if there are indeed more than 1) that
traverse that line to return a single line fragment representing the
line. The key was to update the buffer delta for that fragment to
always be 1,0. Because the wrapper is treating the folder as if it's
the buffer, the lines it stores in its map need to traverse only a
single "buffer" line (that's a single line after folds are taken into
account). We may need better language than "screen" and "buffer"
because the wrapper treats the folder as the "buffer" but that's
confusing because it isn't.
2012-02-24 21:56:18 -07:00
Nathan Sobo
35f1243d32 Restore LineWrapper.clipScreenPosition version that passes existing tests.
It's still wrong, but I need a test to demonstrate how.
2012-02-24 21:13:34 -07:00
Nathan Sobo
17205cae3f WIP: Working on position translation. Pretty broken right now.
The layered relationship between the line wrapper and the folder is
still not quite ironed out yet. The editor behaves pretty erratically
when text is folded.
2012-02-24 21:05:49 -07:00
Nathan Sobo
33ff32f9a4 Add clipScreenPosition to LineFolder & LineMap 2012-02-24 15:35:28 -07:00
Nathan Sobo
b8ef7685de LineWrapper translates positions correctly with respect to folding. 2012-02-24 14:20:06 -07:00
Nathan Sobo
63be776837 LineFolder emits 'fold' and 'unfold' events 2012-02-24 14:18:55 -07:00
Nathan Sobo
c8c7033550 Rename Cursor.set/getPosition to set/getScreenPosition
Now that buffer positions don't always line up with screen positions, it's important that it's clear which one we're talking about.
2012-02-24 11:53:18 -07:00
Nathan Sobo
dfcf4a1629 Alt-meta-f folds the current selection 2012-02-24 11:30:32 -07:00
Nathan Sobo
0bdc45037f Install the LineFolder into the editor
LineWrapper now takes a LineFolder instead of a Highlighter. It's a
cascade of processing steps.
2012-02-23 22:19:42 -07:00
Nathan Sobo
8eed1a4c94 💄 2012-02-23 22:18:27 -07:00
Nathan Sobo
c0d0768df8 A change to a range surrounding a fold removes the fold 2012-02-23 22:12:21 -07:00
Nathan Sobo
68bbe2708c 💄 2012-02-23 22:11:22 -07:00
Nathan Sobo
422df7989a Handle changes inside of folds.
Don't emit an event since nothing changes (since it's all folded). But update the position of the fold's end marker so when it's unfolded, things render correctly.
2012-02-23 17:28:55 -07:00
Nathan Sobo
de5eab13d2 Insertions at beginning/end of a fold are considered to be outside it.
Also added a spec where text is changed on a line in between two
placeholders and handled correctly.
2012-02-23 17:08:54 -07:00
Nathan Sobo
d229585cd4 Handle changes to unfolded text directly preceding a fold placeholder 2012-02-23 16:32:57 -07:00
Nathan Sobo
16a2fd0bb3 WIP: Start handling buffer updates w/ LineFolder
Still a ways to go here, but folds are moved correctly when there are
buffer updates. Many unfinished specs.
2012-02-23 16:12:22 -07:00
Nathan Sobo
43c66a02a4 Merge Delta into Point
Point and delta were really pretty much the same thing. Point might need to be renamed… I'm thinking now it should be called offset, and have rows and columns instead of a row and column. Then you could interpret it as an offset from the beginning of the buffer, or an offset from any other location.
2012-02-23 15:38:03 -07:00
Nathan Sobo
e8ba72c3ec Fixes for screenLineCount rename 2012-02-22 22:42:17 -07:00
Nathan Sobo
f7bf36eb1b Add LineFolder.lastRow 2012-02-22 22:40:14 -07:00
Nathan Sobo
c658423bea Rename LineMap.lineCount to .screenLineCount 2012-02-22 22:40:03 -07:00
Nathan Sobo
1fc200c018 💄 2012-02-22 22:34:21 -07:00
Nathan Sobo
5bb539df27 💄 2012-02-22 17:36:38 -07:00
Nathan Sobo
237c03be7b 💄
More consistent method names among Highlighter, LineWrapper,
LineFolder, and LineMap
2012-02-22 17:24:27 -07:00
Nathan Sobo
852d066378 💄 2012-02-22 16:53:08 -07:00
Nathan Sobo
7bf12430cd Folds can be created and destroyed; Folder emits change events
Reorganized the line folder spec around creating and destroying folds
2012-02-22 16:52:18 -07:00
Nathan Sobo
cf00753c9c WIP: can destroy folds. emits change events. 2012-02-22 14:02:51 -07:00
Nathan Sobo
3ba17d28e8 Un F 2012-02-22 12:20:50 -07:00
Nathan Sobo
e42a8878e9 Fix position translation 2012-02-22 12:17:08 -07:00
Nathan Sobo
2132b5f8f4 Buffer positions inside folds translate to screen positions preceding fold placeholder 2012-02-22 11:15:15 -07:00
Nathan Sobo
8ef270f797 Add more position translation specs to LineFolder spec 2012-02-22 10:48:35 -07:00
Nathan Sobo
526f15bcd2 Remove SpanIndex. Fully replaced by LineMap 2012-02-22 10:29:07 -07:00
Nathan Sobo
ab9a93b390 Eliminate old ScreenLine 2012-02-22 10:27:49 -07:00
Nathan Sobo
52e1400dc4 💄 for LineWrapper 2012-02-21 23:54:17 -07:00
Nathan Sobo
14fc741b42 Eliminate @index from LineWrapper plus 💄
LineWrapper only uses LineMap now
2012-02-21 23:36:11 -07:00
Nathan Sobo
29543c73b7 Add LineMap.lineForBufferRow to support LineWrapper
LineWrapper uses lineForBufferRow to expand ranges to encompass the
entire span of the lines that contain them when emitting change events.
2012-02-21 23:33:55 -07:00
Nathan Sobo
c13b90b6b6 Back LineWrapper.bufferPositionForScreenPosition with LineMap
Also rename From -> For
2012-02-21 09:46:30 -07:00
Nathan Sobo
ba506fcd45 💄 2012-02-20 22:15:37 -07:00
Nathan Sobo
8c810bbbcf Use LineMap in LineWrapper.screenPositionForBufferPosition
Also rename from screenPositionFrom… to screenPositionFor… and rename allowEOL parameter (which defaults to false) to eagerWrap (which defaults to true).
2012-02-20 22:14:59 -07:00
Nathan Sobo
a05c0e077f Add eagerWrap option to LineMap.screenPositionForBufferPosition
If eagerWrap is true, the default, then a position at the end of a wrapped line will move to the next screen line. If it's false, it will hang on the end of the screen line. This support the line wrapper, which needs to convert ranges to not wrap (so selections can go to the end of wrapped lines) but otherwise needs to wrap the cursor to the beginning of a wrapped line.
2012-02-20 22:11:15 -07:00
Nathan Sobo
6bda6d4de5 Use LineMap for LineWrapper.screenLineCount
Also set screenDelta to [1, 0] for wrapped lines.
2012-02-17 18:27:35 -07:00
Nathan Sobo
7d1b79d1d0 Add LineWrapper.screenLineCount 2012-02-17 18:27:00 -07:00
Nathan Sobo
3df3f47483 WIP: LineWrapper maintains a LineMap in parallel w/ SpanIndex.
Planning to convert method at a time to use the LineMap instead of the SpanIndex.
2012-02-17 18:07:51 -07:00
Nathan Sobo
312bb34c0b Use LineMap in LineFolder. All specs pass. 2012-02-17 16:52:12 -07:00
Nathan Sobo
d1d48f8fca WIP: Starting on LineMap 2012-02-16 20:52:12 -07:00
Nathan Sobo
6cc46d959b Start on rough version of LineFolder.screenPositionForBufferPosition
Still pretty ugly and not working quite right.
2012-02-15 19:06:53 -07:00
Nathan Sobo
cdd2b7faf5 Line folder handles folds starting and ending on same line. 2012-02-15 17:11:28 -07:00
Nathan Sobo
6de6852e92 SpanIndex.spanForIndex returns span of elements up to and *including* index. 2012-02-15 17:11:06 -07:00
Corey Johnson & Nathan Sobo
3782119a0a LineFolder renders a placeholder in place of a folded region. 2012-02-15 15:20:27 -07:00