Commit Graph

160 Commits

Author SHA1 Message Date
Nathan Sobo
bbc1a264b5 Make each section of presenter state self-contained
This means we have some duplicated values in different parts of the
tree, but it’s cleaner in the view since each component only consumes
a single object. Seems like the presenter should convey the correct
data to the correct locations and minimize the logic in the view. A
few duplicated integers is a reasonable trade-off.
2015-02-03 15:05:31 -07:00
Nathan Sobo
76241fb779 Handle line and line number preservation in presenter
The target of mousewheel events needs to be preserved when scrolling.
It used to be dealt with in the view, but now we can do it in the
presenter for a simpler view implementation.
2015-02-03 15:05:29 -07:00
Nathan Sobo
fd50a0db6c Construct TextEditorPresenter before component mounts
This allows us to use the presenter for all stages of the component
lifecycle rather than needing to wait until it is created.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:28 -07:00
Max Brunsfeld
fd4f28911d Use presenter state for placeholder text
Signed-off-by: Nathan Sobo <nathan@github.com>
2015-02-03 15:05:27 -07:00
Nathan Sobo
f5fa3b837e Set content.indentGuidesVisible in presenter if editor is mini 2015-02-03 15:05:26 -07:00
Nathan Sobo
b21b9c3402 Use presenter’s scrollingVertically property to defer line measurement 2015-02-03 15:05:26 -07:00
Nathan Sobo
837b9eefbb Use backgroundColor from presenter in LinesComponent 2015-02-03 15:05:26 -07:00
Nathan Sobo
96ba4cc6bd Remove unused React props and methods that build them 2015-02-03 15:05:25 -07:00
Nathan Sobo
a5580a704d Remove unused properties in EditorComponent and children 2015-02-03 15:05:25 -07:00
Nathan Sobo
d26e8a2df1 Move vertical scroll state to root of presenter state object
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:23 -07:00
Nathan Sobo
49bf3bb14e Use presenter to render flashes
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:22 -07:00
Nathan Sobo
8ebd057b0c Use presenter to render highlights
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:22 -07:00
Nathan Sobo
4b0536ab6a Remove unused props
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:21 -07:00
Nathan Sobo
06b5eba17c Fix 0-width cursors in presenter instead of view 2015-02-03 15:05:20 -07:00
Nathan Sobo
4ed07bb66d Use presenter state in CursorsComponent 2015-02-03 15:05:20 -07:00
Nathan Sobo
b7b0ec067c 🎨 2015-02-03 15:05:19 -07:00
Nathan Sobo
add3972477 Use presenter’s scrollTop/scrollLeft in LinesComponent 2015-02-03 15:05:19 -07:00
Nathan Sobo
78d87d8f7c Use presenter to supply scrollHeight to lines component 2015-02-03 15:05:19 -07:00
Nathan Sobo
e9d6e36b6a Remove unused code 2015-02-03 15:05:18 -07:00
Nathan Sobo
773482467e Handle updates to line decorations in TextEditorPresenter
This isn’t a super efficient approach, but it is simple and should be
correct. Once we move all state to the presenter we can perform a more
efficient synchronous update when markers change.
2015-02-03 15:05:17 -07:00
Nathan Sobo
bf9428aa19 Read scrollWidth from the presenter state when rendering 2015-02-03 15:05:16 -07:00
Nathan Sobo
64ef8add71 Remove unused argument 2015-02-03 15:05:16 -07:00
Nathan Sobo
32a1854b7c Use TextEditorPresenter::state.content.indentGuidesVisible 2015-02-03 15:05:16 -07:00
Nathan Sobo
22942ae1bd Remove unused local vars 2015-02-03 15:05:15 -07:00
Nathan Sobo
0a9f7586ae Add top-level .content object to presenter state
It contains the .scrollWidth and then all the lines in a nested .lines
object. The .width has been removed from each line and replaced with
.content.scrollWidth.
2015-02-03 15:05:15 -07:00
Nathan Sobo
3ec4b632ba Update TextEditorPresenter with scoped character widths in component
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:15 -07:00
Nathan Sobo
20bb14da81 Start using TextEditorPresenter in LinesComponent
Removed shouldComponentUpdate because we will always update the
component manually once this is done, but I don’t want to accidentally
prevent the component from updating during the conversion process.

This commit has a failing spec due to the presenter not accounting for
individual character widths.
2015-02-03 15:05:14 -07:00
Nathan Sobo
2120c3c298 Instantiate presenter in TextEditorComponent and update measurements 2015-02-03 15:05:12 -07:00
Nathan Sobo
002918049d 🐎 Cache gutterVisible state in React component
This avoids a config read on every render.
2015-01-12 16:21:31 -07:00
Nathan Sobo
08971562cd Store useShadowDOM setting when TextEditorElement is created
Rather than reading it repeatedly, since the value could potentially
change over time.
2014-11-13 16:04:56 -08:00
Ben Ogle
97a671cb49 Works with the shadow DOM disabled. 2014-11-11 16:30:22 -08:00
Ben Ogle
c79db992d9 Overlay decorations render 2014-11-11 11:25:36 -08:00
Nathan Sobo
0e57ede712 Only create a shadow root if editor.useShadowDOM config setting is true
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2014-11-04 16:37:27 -07:00
Nathan Sobo
5cc243ec11 Inject both underlayer and overlayer via shadow DOM insertion points 2014-11-04 16:37:25 -07:00
Nathan Sobo
ab846a2495 Put views appended via appendToLinesView in the light DOM
This adds an insertion point to the lines div via a <content> tag,
allowing immediate children of the editor tag to be positioned relative
to the lines div but still be styled via global CSS.
2014-11-04 16:37:24 -07:00
Kevin Sawicki
edec6b9b0a 🐎 Use cached pair character information
Tokenized lines break out atomic tokens so trust the hasPairCharacter
value on the token instead of rechecking it.
2014-10-28 18:15:13 -07:00
Kevin Sawicki
05dc9aad89 💄 2014-10-24 13:31:43 -07:00
Kevin Sawicki
e5660e5e83 🐎 Only use String::substr for pair chars 2014-10-24 13:31:43 -07:00
Kevin Sawicki
e928447eab Stored paired characters in width cache
Previously characters were treated individually even when multiple
characters would render as a single character on screen.
2014-10-24 13:31:43 -07:00
Ben Ogle
31490ca31e Last of scopeDescriptor -> scopes from tokens 2014-10-21 11:49:49 -07:00
Ben Ogle
16ad957609 scopeDescriptor -> scopes
Now that we have a real ScopeDescriptor object, 
these should change back!
2014-10-21 11:38:43 -07:00
Ben Ogle
c0091b4601 scopes -> scopeDescriptor
!!!
2014-10-13 16:30:41 -07:00
Nathan Sobo
2a94e4a33c Pass tokenizedLines to LinesComponent so measuring stays in sync
Fixes #3318
2014-08-25 18:16:45 -06:00
Nathan Sobo
a71a524ec7 Rework DOM measurement to try to prevent measurement errors
* Simplify scrollbar refresh and measurement by using imperative DOM
  manipulation instead of React to hide/show scrollbars.
* Rename `::performInitialMeasurement` to `::becameVisible`
* Break `::checkForVisibilityChange` out of `::pollDOM` and use it in
  to check for the element becoming visible in `componentWillUpdate`.
* Don't rely on stored visibility state anywhere. Always check again.
  This could potentially be cached for an update cycle but being wrong
  about this is disastrous so I'm being conservative.
2014-08-21 17:50:46 -06:00
Nathan Sobo
6c52bcf20c Assign ::firstNonWhitespace/TrailingWhitespaceIndex in Token::split
Fixes #3277
2014-08-15 12:58:27 -06:00
Nathan Sobo
c74f6bb615 Remove handling of invisibles from EditorComponent 2014-08-13 16:31:40 -06:00
Nathan Sobo
63f2ab3088 Render end-of-line invisibles based on state of TokenizedLine 2014-08-13 16:31:39 -06:00
Ben Ogle
7de2ad34aa Remove opaque backgrounds on mini editors
Fixes #3239
2014-08-12 14:53:09 -07:00
Nathan Sobo
393552a4b6 Take cursors off the GPU and position them on the lines layer
The compositor overhead is not worth it.
2014-07-27 11:47:33 -06:00
Nathan Sobo
c6116468e4 Apply background color of root editor node to lines as an inline style
This ensures lines have an opaque background that matches whatever the
editor is styled as, but avoids the need to apply the .editor-colors
class to the .lines div. That approach fell down when people were
setting the background color via means other than .editor-colors, such
as styling mini editors via the .editor.mini selector in the settings
view.
2014-07-24 16:54:01 -07:00