Comparar commits

...

339 Commits

Autor SHA1 Mensagem Data
Nathan Sobo d14d4aaae1 Remove subscriptions in editor view that are handled in presenter 2015-02-04 15:12:21 -07:00
Nathan Sobo 77599c799c Rename TextEditorPresenter::height to ::explicitHeight
This clarifies that the height is being assigned externally rather than
derived from the content.
2015-02-04 15:10:58 -07:00
Nathan Sobo b94576dc09 Pass view measurements to model via presenter
Someday, we won’t need to pass measurements to the model anymore.
2015-02-04 14:48:17 -07:00
Nathan Sobo 9bdb961b3f Update vertical scroll state when contentFrameWidth changes
A wider content frame can mean the horizontal scrollbar gets hidden,
which could in turn mean we need to adjust the scrollTop because the
clientHeight changed.
2015-02-04 11:51:46 -07:00
Nathan Sobo 59d96c9f1a Measure scrollbars immediately when editor becomes visible
This ensures all required measurements are present so assignment of
subsequent measurements such as backgroundColor have an effect.
2015-02-04 11:48:47 -07:00
Nathan Sobo 6196882b9d Include scrollbar dimensions in required measurements in presenter 2015-02-04 11:35:07 -07:00
Nathan Sobo 3973939de1 Don’t constrain scrollTop/Left until required measurements are assigned
This commit also adds to the list of required measurements and updates
the spec with a buildPresenter helper to more easily supply default
values for required measurements in each spec when they aren’t relevant
to that spec’s content.
2015-02-04 11:13:24 -07:00
Nathan Sobo b792190693 Constrain scrollLeft based on computed clientWith and scrollWidth 2015-02-04 10:22:29 -07:00
Nathan Sobo 1ae25ed85d Make randomized presenter spec failures easier to reproduce 2015-02-04 10:05:47 -07:00
Nathan Sobo 5bb3095ffa Constrain scrollTop based on clientHeight and scrollHeight 2015-02-04 09:38:00 -07:00
Nathan Sobo 3656d4cca6 Pass options in DisplayBuffer::screenRangeForBufferRange 2015-02-04 08:42:34 -07:00
Nathan Sobo 3e6669cf3e Log code for repeatable randomized presenter spec failures 2015-02-04 08:42:06 -07:00
Nathan Sobo 6977660699 Store ‘isOnlyWhitespace’ in line presenter state 2015-02-04 07:59:34 -07:00
Nathan Sobo ba6d11e24e Merge branch 'master' into ns-editor-presenters 2015-02-04 07:57:04 -07:00
Nathan Sobo 86991bbec2 Merge branch 'driskell-bugs/ident_guide_whitespace_only' 2015-02-03 21:26:25 -07:00
Nathan Sobo 973d7ebf13 Add spec coverage for indent guides + invisibles on blank lines 2015-02-03 21:26:01 -07:00
Nathan Sobo a685f3dc37 Prevent updates for off-screen line decoration markers on change
When there were lots of off-screen markers, we were performing lots of
redundant updates when off-screen markers changed. Now we only perform
updates if they intersect the visible row range.

@maxbrunsfeld this should improve the situation for folding/unfolding
when there are lots of others folds. Let me know.
2015-02-03 21:02:33 -07:00
Nathan Sobo 20a95269c9 Preserve line number for mouseWheelScreenRow in a sane way
What we were doing before made no sense.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 20:41:59 -07:00
Kevin Sawicki c7315e2be6 Merge pull request #5342 from paulcbetts/deltas
Delta Packages for Windows + Update Squirrel.Windows
2015-02-03 17:14:36 -08:00
Kevin Sawicki a4976c32ae Remove release notes from event payload
The release notes are provided by Squirrel on Mac but not by Squirrel for
Windows and the release notes package pulls them down manually anyway
so this field is no longer needed.

Checking for the presence of the release notes previously was preventing the
event from firing on Windows which would cause old release notes to show in
the package.

Closes #3757
2015-02-03 14:57:33 -08:00
Nathan Sobo 78b8039384 Don’t require sync update before measuring when autoHeight changes
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:45 -07:00
Nathan Sobo cd77870286 In presenter, handle the first line being soft-wrapped
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:44 -07:00
Nathan Sobo 75652e36d9 Remove ? guard from ::oldState and ::newState references 2015-02-03 15:05:44 -07:00
Nathan Sobo 9991cd73c7 Reference scrollingVertically in the proper location in presenter state 2015-02-03 15:05:44 -07:00
Nathan Sobo ac215e11b4 Fix velocity scrolling upward
There’s no need to check that the mouseWheelScreenRow is on screen
before preserving the corresponding line.
2015-02-03 15:05:44 -07:00
Nathan Sobo 20ce35c017 Emit update events in TextEditorPresenter when highlights are removed 2015-02-03 15:05:44 -07:00
Nathan Sobo edd595a72f Access mouseWheelScreenRow property instead of calling removed method 2015-02-03 15:05:43 -07:00
Nathan Sobo 0a6116a785 Fix undefined method errors in overlay manager
Access properties directly now
2015-02-03 15:05:43 -07:00
Nathan Sobo 2dc29a60ef Avoid full decorations query when decorations are added 2015-02-03 15:05:43 -07:00
Nathan Sobo b78522d8e6 Avoid full decoration query when line decorations’ markers change 2015-02-03 15:05:43 -07:00
Nathan Sobo c6f23c2edb Dispose of decoration subscriptions when it’s destroyed 2015-02-03 15:05:43 -07:00
Nathan Sobo 342903567e Avoid full decoration query when line decorations are destroyed 2015-02-03 15:05:43 -07:00
Nathan Sobo 648c58d41e Hide line decorations for invalid markers again 2015-02-03 15:05:42 -07:00
Nathan Sobo 7deb411e84 Fix randomized spec failures 2015-02-03 15:05:42 -07:00
Nathan Sobo cf50ec1861 Fix action logging in random spec 2015-02-03 15:05:42 -07:00
Nathan Sobo 4a74d4adba Avoid decoration queries when updating individual highlight decorations 2015-02-03 15:05:42 -07:00
Nathan Sobo f337553a70 Handle highlight state updates in ::updateDecorations 2015-02-03 15:05:42 -07:00
Nathan Sobo 0e85efdd28 🐎 Cache line/line-number decorations to avoid per-line queries 2015-02-03 15:05:34 -07:00
Nathan Sobo 3884a30f39 Unify decoration observation 2015-02-03 15:05:33 -07:00
Nathan Sobo f99b85a299 Use properties directly instead of getters
This will emphasize a design where everything is updated when the model
and view measurements change rather than recomputed as needed.
2015-02-03 15:05:33 -07:00
Nathan Sobo de5c1fc28d Add randomized fuzz test for TextEditorPresenter
This test performs random operations on the editor and assigns random
measurements from the view. After each operation, the state of a
pre-existing presenter is compared with that of a new presenter created
with the same parameters.

Since it’s easier to reason about building fresh state than it is to
reason about state updates, I hope this will catch any bugs in our
update logic as we optimize it and explore every corner case.
2015-02-03 15:05:33 -07:00
Nathan Sobo 89344c6cfd Update scrollbars state when editor content changes 2015-02-03 15:05:33 -07:00
Nathan Sobo 74e4756ef0 🐎 Don’t update presenter state unless measurements change 2015-02-03 15:05:33 -07:00
Nathan Sobo 510520d2c7 🎨 rename ::getStart/EndRow to ::computeStart/EndRow 2015-02-03 15:05:32 -07:00
Nathan Sobo 4eb39b1be2 Remove unnecessary onDidChangeSoftWrapped subscription 2015-02-03 15:05:32 -07:00
Nathan Sobo 9d507ea692 Break out state updates explicitly when editor content changes 2015-02-03 15:05:32 -07:00
Nathan Sobo f005b2005f Add specs for updating scrollWidth when the longest line changes 2015-02-03 15:05:32 -07:00
Nathan Sobo b521e8dc97 Handle auto-height in TextEditorPresenter 2015-02-03 15:05:32 -07:00
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 da4b3a47ef Don’t observe decorations in text editor view 2015-02-03 15:05:31 -07:00
Nathan Sobo 0e27bebbb3 Fix indentation 2015-02-03 15:05:31 -07:00
Nathan Sobo efdba9fc24 Use presenter state for scrollbars and scrollbar corner 2015-02-03 15:05:31 -07:00
Nathan Sobo 0910e86357 Add .right and .bottom to presenter scrollbar states 2015-02-03 15:05:31 -07:00
Nathan Sobo 14776e3f0a Give each scrollbar its own state object and track visibility 2015-02-03 15:05:30 -07:00
Nathan Sobo 42ab02d7d2 Rename ::clientHeight/Width to ::height and ::contentFrameWidth
The term “client” was actually a misnomer here because it typically
means the height excluding the scrollbars, which wasn’t how we were
using it here.
2015-02-03 15:05:30 -07:00
Nathan Sobo 1b5be9aef8 Track horizontal/vertical scrollbar height/width in presenter 2015-02-03 15:05:30 -07:00
Nathan Sobo 9de8ab949f Drop TextEditorComponent::getRenderedRowRange 2015-02-03 15:05:30 -07:00
Nathan Sobo 6108c04f40 Add spec coverage for deprecated ‘cursor:moved’ event
So we don’t accidentally drop it during this transition
2015-02-03 15:05:30 -07:00
Nathan Sobo d8cafb1fc6 Don’t observe screen line changes in editor component 2015-02-03 15:05:29 -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 d9a5d141eb Clear ::mouseWheelScreenRow after delay even if we don’t actually scroll 2015-02-03 15:05:29 -07:00
Nathan Sobo 37a040a620 Preserve line numbers in presenter based on ::mouseWheelScreenRow 2015-02-03 15:05:29 -07:00
Nathan Sobo 35d3690088 Preserve lines in TextEditorPresenter based on ::mouseWheelScreenRow 2015-02-03 15:05:29 -07:00
Nathan Sobo 578a76ba6b Make “mouse wheel” 2 words in presenter API
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:28 -07:00
Nathan Sobo da5ee3fa86 Add TextEditorPresenter::state.mousewheelScreenRow 2015-02-03 15:05:28 -07:00
Nathan Sobo a88486e950 Use maxLineNumberDigits from presenter state in GutterComponent 2015-02-03 15:05:28 -07:00
Nathan Sobo 1a22952eda Only store backgroundColor and gutterBackgroundColor on presenter 2015-02-03 15:05:28 -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
Nathan Sobo ac25596002 Wait for required measurements before building some presenter state
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:27 -07:00
Max Brunsfeld 9cc7ecb1be Add maxLineNumberDigits to presenter state 2015-02-03 15:05:27 -07:00
Max Brunsfeld 60fca8d8b2 Use presenter state for gutter background color
Signed-off-by: Nathan Sobo <nathan@github.com>
2015-02-03 15:05:27 -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 1a61133def Remove unused local var
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:26 -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 d4517b1ab0 Add TextEditorPresenter::state.scrollingVertically
This is used by the view to defer measuring new lines until we stop
scrolling.
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 71a27de7ac Add TextEditorPresenter::state.content.backgroundColor 2015-02-03 15:05:25 -07:00
Nathan Sobo 96ba4cc6bd Remove unused React props and methods that build them 2015-02-03 15:05:25 -07:00
Nathan Sobo 9d7285d04a Use presenter for rendering overlay decorations
We’re still doing some sync DOM reads and computation in the view that
should eventually be made async and moved into the presenter, but I’m
going to leave it alone for now.
2015-02-03 15:05:25 -07:00
Nathan Sobo e4c95d8ac3 Add overlay decorations to TextEditorPresenter::state 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 c4b5a0f411 Honor the ‘onlyHead’ option for line and line-number decorations 2015-02-03 15:05:24 -07:00
Nathan Sobo af8c38ad80 🎨 2015-02-03 15:05:24 -07:00
Nathan Sobo 0802b9bdd1 Don’t decorate soft-wrapped lines/line numbers unless spanned by marker 2015-02-03 15:05:24 -07:00
Nathan Sobo b1fe567ce8 Build line numbers based on presenter state 2015-02-03 15:05:24 -07:00
Nathan Sobo 20838accc1 Key line numbers by buffer row and soft-wrap count
…instead of an array. This will make things simpler to diff in the
view.
2015-02-03 15:05:24 -07:00
Nathan Sobo 182531a010 Use presenter for gutter scrollHeight and scrollTop
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:23 -07:00
Max Brunsfeld f218e985cf Update presenter scrollHeight when clientHeight changes
Signed-off-by: Nathan Sobo <nathan@github.com>
2015-02-03 15:05:23 -07:00
Max Brunsfeld 33081cefda Move .lineNumbers onto .gutter property of presenter state
Signed-off-by: Nathan Sobo <nathan@github.com>
2015-02-03 15:05:23 -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 1ff0b20cea Add ‘foldable’ to line number presenter state 2015-02-03 15:05:23 -07:00
Nathan Sobo 66c35d6e3e Reflect changes to line number decorations in presenter state
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:22 -07:00
Nathan Sobo 5d2efc0469 Deprecate TextEditor::getGutterDecorations
Forgot to rename it when we renamed decorations of type ‘gutter’ to
‘line-number’. It’s not used in core or any packages at the time of
this commit.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:22 -07:00
Nathan Sobo 970936f96d Start on TextEditorPresenter::state.lineNumbers
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:22 -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 2f526c59c5 Add highlights state to TextEditorPresenter
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:21 -07:00
Nathan Sobo 764139c25e Fix spec organization
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:21 -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 500f992d32 Remove shouldComponentUpdate hook
Will be replaced by manual update logic anyway.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:21 -07:00
Nathan Sobo 3b93f3d71b Blink cursors based on presenter state
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:21 -07:00
Nathan Sobo b412c2642d Add TextEditorPresenter::onDidUpdateState
And ensure observers are invoked whenever the state changes in spec.
2015-02-03 15:05:20 -07:00
Nathan Sobo 3c6c385ec8 Add TextEditorPresenter::state.content.blinkCursorsOff 2015-02-03 15:05:20 -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 c8b58761ba Add TextEditorPresenter::state.content.cursors 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 f479e9d029 Add ::state.content.scrollTop/Left to TextEditorPresenter 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 2c5888e25a Add ::state.content.scrollHeight to TextEditorPresenter 2015-02-03 15:05:19 -07:00
Nathan Sobo de0b5c4c62 Reorganize specs on TextEditorPresenter to mirror structure of state 2015-02-03 15:05:18 -07:00
Nathan Sobo 59b109654e Fix spec 2015-02-03 15:05:18 -07:00
Nathan Sobo e9d6e36b6a Remove unused code 2015-02-03 15:05:18 -07:00
Nathan Sobo fe5ee524a8 Show/hide line decorations when TextEditor::mini changes 2015-02-03 15:05:18 -07:00
Nathan Sobo 9a496e62cb Don’t apply line decorations to mini editors 2015-02-03 15:05:18 -07:00
Nathan Sobo a513cf260c Don’t apply line decorations to last line if it ends at column 0 2015-02-03 15:05:17 -07:00
Nathan Sobo 62a1210604 Honor the ‘onlyEmpty’ and ‘onlyNonEmpty’ line decoration options 2015-02-03 15:05:17 -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 5d8f831136 Instantiate presenter with minimal parameters in specs 2015-02-03 15:05:17 -07:00
Nathan Sobo 9c1efb6ba0 Simplify assertions 2015-02-03 15:05:17 -07:00
Nathan Sobo 568b9f6999 Add lineStateForScreenRow helper
The access pattern is pretty noisy in the specs
2015-02-03 15:05:16 -07:00
Nathan Sobo 06ef0792ce Add .decorationClasses to line state on initial render 2015-02-03 15:05:16 -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 590391a0ce Update .content.indentGuidesVisible when editor’s grammar changes 2015-02-03 15:05:15 -07:00
Nathan Sobo d0b52538b2 Add content.indentGuidesVisible to TextEditorPresenter::state 2015-02-03 15:05:15 -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 115d764725 Handle scoped character widths in TextEditorPresenter
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2015-02-03 15:05:14 -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 a3fb8b3aaa Disable spec until presenter approach stabilizes 2015-02-03 15:05:14 -07:00
Nathan Sobo 9e6aa8f873 Include more fields in line state 2015-02-03 15:05:14 -07:00
Nathan Sobo e2693da225 Fix endRow calculation 2015-02-03 15:05:14 -07:00
Nathan Sobo 9a070e7f6d Include endOfLineInvisibles in presenter state 2015-02-03 15:05:14 -07:00
Nathan Sobo db5059626f Use getters in TextEditorPresenter internally for consistency
::clientHeight is conditionally computed in the getter, so lets use them
everywhere for consistency.
2015-02-03 15:05:13 -07:00
Nathan Sobo 7095ccd32b Make all lines visible if no external client height is assigned 2015-02-03 15:05:13 -07:00
Nathan Sobo ac463143dd Add 1 pixel to scrollWidth to account for cursor if not soft-wrapped 2015-02-03 15:05:13 -07:00
Nathan Sobo 2296d2d378 Account for overdrawMargin of startRow when computing the endRow 2015-02-03 15:05:13 -07:00
Nathan Sobo 143183aa25 🎨 2015-02-03 15:05:13 -07:00
Nathan Sobo 0f4bcac8d4 Add 1 to the last row to ensure it’s visible 2015-02-03 15:05:12 -07:00
Nathan Sobo b09b54800f Include line text in presenter state 2015-02-03 15:05:12 -07:00
Nathan Sobo 2120c3c298 Instantiate presenter in TextEditorComponent and update measurements 2015-02-03 15:05:12 -07:00
Nathan Sobo f4d8ef8315 Add width to lines state based on the computed scrollWidth
This is based on the ::baseCharacterWidth property for now. To be fully
correct, we need to base the scrollWidth on the actual width of
individual characters.
2015-02-03 15:05:12 -07:00
Nathan Sobo a1c2e1bb66 Update TextEditorPresenter when the editor’s content changes 2015-02-03 15:05:12 -07:00
Nathan Sobo 5a2bbc945b Handle changing ::lineHeight in TextEditorPresenter 2015-02-03 15:05:12 -07:00
Nathan Sobo 9c2ed478cd Handle changing ::clientHeight in TextEditorPresenter 2015-02-03 15:05:11 -07:00
Nathan Sobo 880e1ce1f0 Handle changing ::scrollTop in TextEditorPresenter 2015-02-03 15:05:11 -07:00
Nathan Sobo f0920bf63b Start on TextEditorPresenter with lines state 2015-02-03 15:05:11 -07:00
Kevin Sawicki 37a85bcdd0 ⬆️ language-css@0.27 2015-02-03 13:50:45 -08:00
Kevin Sawicki 47bd093d68 🐎 Load 6to5 version directly from package.json
This prevents the entire library from being required just to check the
cache so when 6to5 is being used and all files are cached it should shave
~250ms off startup.
2015-02-03 13:36:26 -08:00
Kevin Sawicki a788a7e9b7 ⬆️ language-xml@0.28 2015-02-03 10:53:29 -08:00
Kevin Sawicki 9101da11ce ⬆️ update-package-dependencies@0.8 2015-02-03 10:41:26 -08:00
Max Brunsfeld f7159181ac 📝 Tweak docs for new service APIs 2015-02-03 10:21:23 -08:00
Kevin Sawicki 1784a7f726 ⬆️ Upgrade one themes 2015-02-03 10:20:23 -08:00
Kevin Sawicki a28a8447a7 ⬆️ language-json@0.12 2015-02-03 10:18:25 -08:00
Kevin Sawicki 197e74f18d Prepare 0.178 2015-02-03 09:43:05 -08:00
Kevin Sawicki 5cae6f20c4 Merge pull request #5368 from atom/ld-jasmine-ref-fix
Fix link to wrong version of Jasmine
2015-02-03 09:06:11 -08:00
Kevin Sawicki 6ad704c1e4 Defer requiring 6to5 until it is used
It seems to have a require time of ~250ms
2015-02-03 09:05:34 -08:00
Ben Ogle 2b0cb11df3 Merge pull request #5374 from atom/ld-doc-composed-commands
Add section on "composed" commands to Advanced Keymap document
2015-02-03 09:04:29 -08:00
Lee Dohm 9aee7d4b38 📝 Add section about composed commands
Fix #5357

This is intended to address the commonly-asked question about making a keybinding execute multiple commands.
2015-02-03 04:50:38 -08:00
Lee Dohm b6c86ea217 📝 Update command example for CommandRegistry 2015-02-03 04:31:23 -08:00
Lee Dohm 0d169f0516 Fix link to wrong version of Jasmine
Applies to #5354
2015-02-02 20:26:35 -08:00
Kevin Sawicki 5dea6e7d12 Link to all guides
Closes #5332
2015-02-02 18:20:53 -08:00
Kevin Sawicki 312e4e0e8a Be graceful about pathsToOpen string value
Gently convert it to an array of strings before opening

Closes #5340
2015-02-02 18:17:15 -08:00
Kevin Sawicki 853ad9cee3 Re-throw stylesheet compile errors
This makes it consistent with other read errors. Previously a Notification
was returned in the error case causing errors downstream where the package's
stylesheets array was assumed to be a path/content tuple.

Closes atom/deprecation-cop#22
2015-02-02 17:55:36 -08:00
Max Brunsfeld a5ccfa6299 Merge pull request #5346 from atom/ld-doc-updates
Some documentation updates
2015-02-02 17:26:08 -08:00
Lee Dohm 800ca5a37a 📝 Add a missing comma 2015-02-02 17:22:53 -08:00
Lee Dohm 23b8b15261 📝 Fix broken json-schema.org link 2015-02-02 17:22:29 -08:00
Lee Dohm 959aa08d62 📝 Atom 1.0 API is now frozen 2015-02-02 17:22:29 -08:00
Lee Dohm 6eed4e461f 📝 Give stronger recommendation on deactivate
Many packages don't clean up properly on update, causing strange
behavior until restart. Simply stating that the `deactivate` method is
optional is enough to let people know that it isn't required for the
common case.
2015-02-02 17:22:29 -08:00
Lee Dohm 00b79e69f1 📝 activationEvents are now activationCommands 2015-02-02 17:22:29 -08:00
Max Brunsfeld 3739995ddb Merge pull request #5277 from atom/mb-package-json-services
Allow packages to specify services in their package.json files
2015-02-02 17:07:41 -08:00
Max Brunsfeld f942bafe54 📝 Fix typo in 'Creating Package' docs 2015-02-02 16:47:33 -08:00
Kevin Sawicki 5fa230e71a ⬆️ apm@0.134 2015-02-02 14:17:19 -08:00
Kevin Sawicki 9858916c31 🎨 2015-02-02 14:10:53 -08:00
Kevin Sawicki 18ed76f111 Add transpiler name dir segment 2015-02-02 14:09:49 -08:00
Kevin Sawicki feb35e710c Make 6to5 first cache segment
Makes it easier to blow away if needed.
2015-02-02 14:08:50 -08:00
Kevin Sawicki 2e989b502a Remove unneeded try/catch 2015-02-02 14:08:35 -08:00
Kevin Sawicki 434c9e60a8 Remove console logging 2015-02-02 14:08:00 -08:00
Kevin Sawicki 84453d5441 Ignore errors writing to the cache 2015-02-02 14:07:39 -08:00
Kevin Sawicki 9e11914b8b Add helper to cache without requiring 2015-02-02 14:07:11 -08:00
Kevin Sawicki f9f7cf6d34 Add more 6to5 specs 2015-02-02 13:29:20 -08:00
Kevin Sawicki c7b206f5ca Add core-js license override 2015-02-02 13:22:08 -08:00
Kevin Sawicki 3b8b569d0c 🎨 2015-02-02 13:13:39 -08:00
Kevin Sawicki 8365ccb064 Merge pull request #5299 from bolinfest/6to5
Transpile all .js files beginning with the "use 6to5"; pragma with 6to5.
2015-02-02 13:11:33 -08:00
Kevin Sawicki fee8e4a75a Merge pull request #5335 from xfq/semicolon
📝 Minor punctuation fix.
2015-02-02 11:29:48 -08:00
Max Brunsfeld edd8714bbf 📝 Document provision and consumption of services 2015-02-02 11:18:52 -08:00
Kevin Sawicki 56adf8cc32 ⬆️ markdown-preview@0.132 2015-02-02 10:31:59 -08:00
Kevin Sawicki d3956da8e5 ⬆️ event-kit@1.0.2 2015-02-02 10:10:55 -08:00
Max Brunsfeld b24b338b2c Add deprecated shim for atom.services global 2015-02-02 10:01:57 -08:00
Max Brunsfeld 14969c0522 Avoid using private serviceHub in package manager test
Signed-off-by: Nathan Sobo <nathan@github.com>
2015-02-02 10:01:56 -08:00
Max Brunsfeld 65f2ffa55e Rename service keys in package.json
* serviceProvisions -> providedServices
* serviceDependencies -> consumedServices

Signed-off-by: Nathan Sobo <nathan@github.com>
2015-02-02 10:01:50 -08:00
Max Brunsfeld 5638c7fb6a Remove atom.services global
Signed-off-by: Nathan Sobo <nathan@github.com>
2015-02-02 10:01:34 -08:00
Max Brunsfeld cb8b254502 Use version-ranges in fixture package with service deps 2015-02-02 10:00:53 -08:00
Max Brunsfeld 027ebc78c4 Respect service{Provisions,Dependencies} in packages' metadata 2015-02-02 10:00:53 -08:00
Max Brunsfeld d9fb54ad6f Reset atom.services between specs 2015-02-02 10:00:53 -08:00
Jason Woods 2e72790e72 🐛 Fix ident guides missing on whitespace only lines with invis chars 2015-02-01 18:13:39 +00:00
Paul Betts 8fcd71f207 Publish delta packages 2015-02-01 01:51:49 -08:00
Paul Betts 776eedd473 Set us up to download the current release so we can create deltas 2015-02-01 01:51:48 -08:00
Paul Betts 62c515e4e7 ⬆️ grunt-atom-shell-installer@0.21.0 2015-02-01 01:51:42 -08:00
Xue Fuqiao 2170e917bd 📝 Minor punctuation fix. 2015-01-31 23:59:35 +08:00
Ivan Žužak 7add4af585 Merge pull request #5334 from xfq/https
Change HTTP to HTTPS
2015-01-31 11:42:56 +01:00
Ivan Žužak 5076e2c8b3 Merge pull request #5333 from xfq/devtools-link
Update the URI of DevTools tutorial in docs
2015-01-31 11:41:52 +01:00
Ivan Žužak b56d73cd74 Merge pull request #5330 from xfq/broken-link
📝 Fix a broken link.
2015-01-31 11:40:37 +01:00
Ivan Žužak 6c5a0e3670 Merge pull request #5329 from xfq/install-theme
📝 Fix theme docs.
2015-01-31 11:39:42 +01:00
Ivan Žužak 791f89216b Merge pull request #5327 from xfq/osx-fix
Change Mac OS X to OS X.
2015-01-31 11:38:53 +01:00
Xue Fuqiao f6067cb629 📝 Fix previous change. 2015-01-31 18:08:13 +08:00
Xue Fuqiao 22158031bf Change HTTP to HTTPS.
Change HTTP to HTTPS to avoid plaintext HTTP connections.
2015-01-31 17:59:45 +08:00
Xue Fuqiao 8ac3fada4e 📝 Update the URI of DevTools tutorial. 2015-01-31 17:11:09 +08:00
Xue Fuqiao a03d5bc288 📝 Fix a broken link.
Fix a broken link in `docs/creating-a-theme.md`.
2015-01-31 14:10:39 +08:00
Xue Fuqiao cc489e5663 📝 Fix theme docs. 2015-01-31 13:51:40 +08:00
Xue Fuqiao cd3f7f73a0 Change Mac OS X to OS X.
Apple has renamed Mac OS X to OS X.
2015-01-31 12:36:35 +08:00
Ben Ogle 9cb67a6def 📝 Fix doc reference in config 2015-01-30 16:52:19 -08:00
Kevin Sawicki 786e8c558a Merge pull request #5314 from eestrada/master
Make rpm install package a little more flexible
2015-01-30 11:12:50 -08:00
Ethan Estrada bfeeddea4d Make rpm package installs relocatable 2015-01-29 22:55:41 -07:00
Ethan Estrada 1589b8b192 Make apm symlink relative for rpm spec 2015-01-29 22:35:11 -07:00
Ben Ogle b02d0e3df3 Merge pull request #5280 from atom/bo-schema-on-load
Reset all user config values when the schema changes
2015-01-29 18:06:18 -08:00
Ben Ogle d3f29c4580 🎨 Fix wording 2015-01-29 17:54:41 -08:00
Ben Ogle 7263ca8faa 🎨 Fix spec title 2015-01-29 17:54:41 -08:00
Ben Ogle cd812e7a65 Transact on resetting the settings when a schema changes 2015-01-29 17:54:41 -08:00
Ben Ogle 4e6e636b8b 🎨 Reorder args to be consistent with other methods 2015-01-29 17:54:41 -08:00
Ben Ogle 083bafdb33 Handle unschema’d items in objects.
This is required for packages that still use configDefaults
2015-01-29 17:54:41 -08:00
Ben Ogle adbe151c5d Fix up the linter error 2015-01-29 17:54:41 -08:00
Ben Ogle 26b450fe49 🎨 Clean up spec naming 2015-01-29 17:54:41 -08:00
Ben Ogle 5d273d0ee6 Add a bit more coverage to the specs 2015-01-29 17:54:41 -08:00
Ben Ogle b9b2b4bca2 Adhere to the schemas when loading the user’s config 2015-01-29 17:54:41 -08:00
Ben Ogle 79094ee889 Reset all user config values when the schema changes. 2015-01-29 17:54:40 -08:00
Michael Bolin 52f2c0ec69 rename esnext to 6to5 2015-01-29 17:29:02 -08:00
Kevin Sawicki d2f485a1ab ⬆️ deprecation-cop@0.34 2015-01-29 16:44:33 -08:00
Kevin Sawicki c12002a0ba ⬆️ bracket-matcher@0.71 2015-01-29 16:41:22 -08:00
Michael Bolin fed2bd6ab8 fixed a bug in updateDigestForJsonValue with how null was handled 2015-01-29 12:33:14 -08:00
Michael Bolin d29b5b20cd Prefer Object.defineProperty() 2015-01-29 12:27:31 -08:00
Michael Bolin a0bb9d88e0 remove parens 2015-01-29 12:21:59 -08:00
Michael Bolin 32b3c4076f More fixes for @kevinsawicki 2015-01-29 12:15:10 -08:00
Michael Bolin acd1d31480 Address @kevinsawicki's comments. 2015-01-29 12:10:25 -08:00
Michael Bolin 242fce3d79 Transpile all .js files with 6to5.
In the spirit of supporting JavaScript development for Atom packages,
this adds default support for es.next transpilation support in the way
that Atom already has default support for CoffeeScript transpilation.
There are many new features in ES6+ that make JavaScript development
easier and more enjoyable, particularly in terms of support for async code.

For reference, this was a much faster way to iterate on this than running `./script/build`
each time:

```
cp /Users/mbolin/src/atom/static/index.js /Applications/Atom.app/Contents/Resources/app/static/index.js
coffee --output /Applications/Atom.app/Contents/Resources/app/src --compile /Users/mbolin/src/atom/src/esnext.coffee
```

Run the following in the console to see how warm the cache was after startup:

```
global.require('../src/esnext/').getCacheHits()
global.require('../src/esnext/').getCacheMisses()
```
2015-01-29 11:56:32 -08:00
Kevin Sawicki e0bac77fa5 ⬆️ season@5.1.2
Closes atom/snippets#101
2015-01-29 11:31:11 -08:00
Kevin Sawicki c4c13375e4 ⬆️ language-todo@0.16 2015-01-29 09:41:06 -08:00
Kevin Sawicki 83f0104c46 Merge pull request #5305 from mnquintana/patch-3
Fix broken npm package.json link in creating-a-package.md
2015-01-29 09:15:11 -08:00
Machiste N. Quintana a0a3c93b1d 📝 Fix broken npm package.json link
In creating-a-package.md
Fixes #5304
2015-01-29 10:52:46 -05:00
Nathan Sobo 98a874808e ⬆️ react-atom-fork for @bolinfest's changes 2015-01-29 08:24:00 -07:00
Ben Ogle e7b790c5b9 Merge pull request #5300 from nextPrime/patch-1
http://github.com -> https://github.com
2015-01-28 18:45:27 -08:00
nextPrime 4988293400 http://github.com -> https://github.com
Change http://github.com to https://github.com to avoid plaintext HTTP connections.
2015-01-28 21:17:29 -05:00
Kevin Sawicki 0d51c3b871 ⬆️ apm@0.133 2015-01-28 16:42:13 -08:00
Kevin Sawicki 8316183fa0 ⬇️ apm@0.131 2015-01-28 16:37:43 -08:00
simurai 8e617ff4e2 📝 Update Shadow DOM selector 2015-01-29 09:27:17 +09:00
Kevin Sawicki 3ca5495690 Merge pull request #5279 from paulcbetts/patch-1
Enable DirectWrite
2015-01-28 16:11:15 -08:00
Kevin Sawicki 5c47ae0cbc ⬆️ apm@0.132 2015-01-28 16:05:31 -08:00
Cheng Zhao 6a86a00c66 Merge pull request #5282 from atom/chrome40
Upgrade to Chrome40
2015-01-28 15:52:20 -08:00
Cheng Zhao 1abe64e73e styleguide@0.43.0 2015-01-28 14:35:45 -08:00
Cheng Zhao bb9150340d ⬆️ markdown-preview@0.131.0 2015-01-28 14:32:55 -08:00
Cheng Zhao c3f5c43694 ⬆️ link@0.30.0 2015-01-28 14:24:29 -08:00
Cheng Zhao 1678016ae4 ⬆️ image-view@0.48.0 2015-01-28 14:22:43 -08:00
Cheng Zhao f50e402de3 ⬆️ bracket-matcher@0.70.0 2015-01-28 14:20:08 -08:00
Cheng Zhao e6363150dd ⬆️ pathwatcher@3.1.0 2015-01-28 14:16:16 -08:00
Cheng Zhao 5f024bfd69 ⬆️ markdown-preview@0.130.0 2015-01-28 14:06:29 -08:00
Cheng Zhao 76adb58fea ⬆️ scandal@2.0.0 2015-01-28 14:06:15 -08:00
Cheng Zhao 53d5e61b23 ⬆️ atom-keymap@3.1.0 2015-01-28 14:06:15 -08:00
Cheng Zhao 499c09fc25 ⬆️ first-mate@3.0.0 2015-01-28 14:06:15 -08:00
Cheng Zhao 7891595fed ⬆️ text-buffer@4.0.0 2015-01-28 14:06:15 -08:00
Cheng Zhao 604f2a951f ⬆️ scroller-style@2.0.0 2015-01-28 14:06:15 -08:00
Cheng Zhao c1b6b716b1 ⬆️ archive-view@0.46.0 2015-01-28 14:06:15 -08:00
Cheng Zhao 4d861a68d1 ⬆️ dev-live-reload@0.41.0 2015-01-28 14:06:15 -08:00
Cheng Zhao a831688ce1 ⬆️ snippets@0.72.0 2015-01-28 14:06:15 -08:00
Cheng Zhao 1cbac24cee ⬆️ tree-view@0.154.0 2015-01-28 14:06:15 -08:00
Cheng Zhao afa5f73094 ⬆️ spell-check@0.54.0 2015-01-28 14:06:15 -08:00
Cheng Zhao a142e23f49 ⬆️ nslog@2.0.0 2015-01-28 14:06:14 -08:00
Cheng Zhao f1b7536d06 ⬆️ oniguruma@4.0.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 397e61a0d8 ⬆️ git-utils@3.0.0 2015-01-28 14:06:14 -08:00
Cheng Zhao af22e45f70 ⬆️ runas@2.0.0 2015-01-28 14:06:14 -08:00
Cheng Zhao e6a12530a1 ⬆️ symbols-view@0.81.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 896c98b7a0 ⬆️ pathwatcher@3.0.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 3201a05672 ⬆️ apm@0.131.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 93181d8a54 Array::find is undefined in Chrome 40 2015-01-28 14:06:14 -08:00
Cheng Zhao 661f1f822a ⬆️ atom-keymap@3.0.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 678306317d ⬆️ text-buffer@3.11.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 8dd5f17609 ⬆️ scrollbar-style@1.1.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 13e069b45d ⬆️ scandal@1.1.0 2015-01-28 14:06:14 -08:00
Cheng Zhao e61cc5eb13 ⬆️ tree-view@0.152.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 9e92952ad0 ⬆️ symbols-view@0.80.0 2015-01-28 14:06:14 -08:00
Cheng Zhao a8d778781c ⬆️ snippets@v0.71.0 2015-01-28 14:06:14 -08:00
Cheng Zhao da17679ec7 ⬆️ dev-live-preview@0.40.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 1cf663714e ⬆️ archive-view@0.45.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 05963c4e57 ⬆️ spell-check@0.53.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 965a18f7e2 ⬆️ nslog@1.1.0 2015-01-28 14:06:14 -08:00
Cheng Zhao 58c45f87e6 ⬆️ oniguruma@3.1.0 2015-01-28 14:06:13 -08:00
Cheng Zhao 21e609ffac ⬆️ pathwatcher@2.7.0 2015-01-28 14:06:13 -08:00
Cheng Zhao 93befc986f ⬆️ git-utils@2.3.0 2015-01-28 14:06:13 -08:00
Cheng Zhao 3321d77264 ⬆️ runas@1.2.0 2015-01-28 14:06:13 -08:00
Cheng Zhao 84761563f0 ⬆️ apm@0.129.0 2015-01-28 14:06:13 -08:00
Cheng Zhao 014cf19723 ⬆️ atom-shell@0.21.0 2015-01-28 14:06:13 -08:00
Cheng Zhao 2a42ed4aaa ⬆️ markdown-preview@0.129.0 2015-01-28 14:05:17 -08:00
Kevin Sawicki 34b1615782 Lower limit to 175 2015-01-28 12:09:43 -08:00
Kevin Sawicki 87db2760b8 ⬆️ autocomplete@0.44 2015-01-28 09:40:42 -08:00
Max Brunsfeld b4dd0f4f73 ⬆️ language-c 2015-01-28 09:35:20 -08:00
Max Brunsfeld 9d655fd642 ⬆️ language-javascript 2015-01-28 09:12:38 -08:00
Max Brunsfeld 4700edf439 ⬆️ markdown-preview 2015-01-28 08:50:32 -08:00
Cheng Zhao 87c2f4496f 🐧 Set window icon, fixes #5281 2015-01-27 20:34:36 -08:00
Ben Ogle 2741445d95 ⬆️ background-tips@0.22.0 2015-01-27 18:32:32 -08:00
Kevin Sawicki ed90c5e6c2 ⬆️ less-cache@0.21 2015-01-27 17:32:13 -08:00
Kevin Sawicki 0bf2a3f480 ⬆️ apm@0.130 2015-01-27 17:24:03 -08:00
Paul Betts a743e8d058 Enable DirectWrite
Chrome 39 proper now has DirectWrite as the default renderer, which makes a huge difference in text clarity, especially on High DPI monitors.
2015-01-27 14:38:50 -08:00
Kevin Sawicki ddc607c760 ⬆️ tree-view@0.151 2015-01-27 14:30:28 -08:00
Kevin Sawicki cbc8ad1467 Merge pull request #5201 from wyand/master
🍎 try ~/Applications before using mdfind
2015-01-27 14:09:52 -08:00
Kevin Sawicki 1a1eb4380a ⬆️ tabs@0.65 2015-01-27 14:06:28 -08:00
Kevin Sawicki 535b49f60c ⬆️ tree-view@0.150 2015-01-27 13:43:09 -08:00
Kevin Sawicki b5e60f7aa0 ⬆️ spell-check@0.52 2015-01-27 13:33:04 -08:00
Kevin Sawicki ce29060d2d ⬆️ first-mate@2.2.5 2015-01-27 09:30:24 -08:00
Ben Ogle 7d1c23b561 ⬆️ git-diff@0.50.0 2015-01-26 17:39:30 -08:00
Ben Ogle 9e2799db27 ⬆️ status-bar@0.58.0 2015-01-26 15:56:50 -08:00
Daniel Hengeveld 040f6deb1e Merge pull request #5263 from atom/bump-tree-view
⬆️ bump tree view for new sort option
2015-01-26 14:31:53 -08:00
Kevin Sawicki 33d2debf5f Prepare 0.177 2015-01-26 13:59:57 -08:00
Daniel Hengeveld 6de40e21c7 bump tree view to include version with new sort option 2015-01-26 13:05:37 -08:00
Cheng Zhao 6169caa1fb Merge pull request #5235 from atom/atom-shell-v0.20.7
Upgrade to atom-shell v0.20.7
2015-01-26 12:58:06 -08:00
Cheng Zhao b4e25137a2 "screen" is now a browser side module 2015-01-26 11:28:00 -08:00
Cheng Zhao 05aaace387 Do not set window icon, fixes #4811 2015-01-26 11:28:00 -08:00
Cheng Zhao a32daecf5f ⬆️ atom-shell@0.20.7 2015-01-26 11:28:00 -08:00
Kevin Sawicki 6db43d85c4 Remove CI node_modules cleaning 2015-01-26 11:01:42 -08:00
Kevin Sawicki 53e06b8680 Clean out node_modules on Linux CI 2015-01-26 10:44:06 -08:00
Kevin Sawicki 9ab2500970 Clean out node_modules on Windows CI 2015-01-26 10:15:37 -08:00
Kevin Sawicki 697e70d47c ⬆️ apm@0.128 2015-01-26 09:43:42 -08:00
Daniel Hengeveld ffd1f8520c Merge pull request #5240 from mnquintana/less-rename
📝 Rename LESS to Less
2015-01-25 11:48:12 -08:00
Machiste Quintana 9132859757 📝 LESS -> Less 2015-01-24 09:49:53 -05:00
Kevin Sawicki 6af2e1649c ⬆️ legal-eagle@0.9 2015-01-23 13:33:25 -08:00
Kevin Sawicki 0962918a82 ⬆️ timecop@0.28 2015-01-23 11:51:41 -08:00
Kevin Sawicki 6b963a562f Track coffee cache hits correctly 2015-01-23 11:48:19 -08:00
Ben Ogle db41b022c2 Merge pull request #5228 from atom/bo-fix-wait-promise
Make waitsForPromise() work with es6 promises as well as Q promises
2015-01-23 10:33:20 -08:00
Kevin Sawicki d4084b305b ⬆️ season@5.1.1 2015-01-23 09:57:48 -08:00
Kevin Sawicki b81c1f408f Track coffee cache hits/misses 2015-01-23 09:41:26 -08:00
Kevin Sawicki 97bdb84122 ⬆️ season@5.1 2015-01-23 09:41:26 -08:00
Kevin Sawicki 87e8720269 ⬆️ less-cache@0.20 2015-01-23 09:41:26 -08:00
Max Brunsfeld 160c32384c ⬆️ markdown-preview@0.126.0 2015-01-23 08:33:44 -08:00
Ben Ogle 33299ec774 ⬆️ notifications@0.26.0 2015-01-22 18:15:50 -08:00
Max Brunsfeld d4cc549a01 Add jasmine.useRealClock
This is the only way to unmock the _.now function uses
by _.debounce and _.throttle, since package specs don't
necessarily have access to core's copy of underscore-plus

Signed-off-by: Nathan Sobo <nathan@github.com>
2015-01-22 17:59:18 -08:00
Dan Wyand 3b13e4f502 🍎 try ~/Applications before using mdfind 2015-01-21 23:01:37 -05:00
75 arquivos alterados com 4057 adições e 1019 exclusões
+1 -1
Ver Arquivo
@@ -36,7 +36,7 @@ many packages and themes that are stored in other repos under the
[tabs](https://github.com/atom/tabs),
[find-and-replace](https://github.com/atom/find-and-replace),
[language-javascript](https://github.com/atom/language-javascript), and
[atom-light-ui](http://github.com/atom/atom-light-ui).
[atom-light-ui](https://github.com/atom/atom-light-ui).
For more information on how to work with Atom's official packages, see
[Contributing to Atom Packages](https://atom.io/docs/latest/contributing-to-packages.html)
+2 -2
Ver Arquivo
@@ -1,6 +1,6 @@
![Atom](https://cloud.githubusercontent.com/assets/72919/2874231/3af1db48-d3dd-11e3-98dc-6066f8bc766f.png)
Atom is a hackable text editor for the 21st century, built on [atom-shell](http://github.com/atom/atom-shell), and based on everything we love about our favorite editors. We designed it to be deeply customizable, but still approachable using the default configuration.
Atom is a hackable text editor for the 21st century, built on [atom-shell](https://github.com/atom/atom-shell), and based on everything we love about our favorite editors. We designed it to be deeply customizable, but still approachable using the default configuration.
Visit [atom.io](https://atom.io) to learn more or visit the [Atom forum](https://discuss.atom.io).
@@ -9,7 +9,7 @@ about the Atom 1.0 roadmap.
## Installing
### Mac OS X
### OS X
Download the latest [Atom release](https://github.com/atom/atom/releases/latest).
+1 -1
Ver Arquivo
@@ -6,6 +6,6 @@
"url": "https://github.com/atom/atom.git"
},
"dependencies": {
"atom-package-manager": "0.127.0"
"atom-package-manager": "0.134.0"
}
}
+15 -9
Ver Arquivo
@@ -45,18 +45,24 @@ if [ $REDIRECT_STDERR ]; then
fi
if [ $OS == 'Mac' ]; then
ATOM_PATH="${ATOM_PATH:-/Applications}" # Set ATOM_PATH unless it is already set
ATOM_APP_NAME=Atom.app
# If ATOM_PATH isn't a executable file, use spotlight to search for Atom
if [ ! -x "$ATOM_PATH/$ATOM_APP_NAME" ]; then
ATOM_PATH="$(mdfind "kMDItemCFBundleIdentifier == 'com.github.atom'" | grep -v ShipIt | head -1 | xargs -0 dirname)"
fi
if [ -z "${ATOM_PATH}" ]; then
# If ATOM_PATH isnt set, check /Applications and then ~/Applications for Atom.app
if [ -x "/Applications/$ATOM_APP_NAME" ]; then
ATOM_PATH="/Applications"
elif [ -x "$HOME/Applications/$ATOM_APP_NAME" ]; then
ATOM_PATH="$HOME/Applications"
else
# We havent found an Atom.app, use spotlight to search for Atom
ATOM_PATH="$(mdfind "kMDItemCFBundleIdentifier == 'com.github.atom'" | grep -v ShipIt | head -1 | xargs -0 dirname)"
# Exit if Atom can't be found
if [ -z "$ATOM_PATH" ]; then
echo "Cannot locate Atom.app, it is usually located in /Applications. Set the ATOM_PATH environment variable to the directory containing Atom.app."
exit 1
# Exit if Atom can't be found
if [ ! -x "$ATOM_PATH/$ATOM_APP_NAME" ]; then
echo "Cannot locate Atom.app, it is usually located in /Applications. Set the ATOM_PATH environment variable to the directory containing Atom.app."
exit 1
fi
fi
fi
if [ $EXPECT_OUTPUT ]; then
+1
Ver Arquivo
@@ -207,6 +207,7 @@ module.exports = (grunt) ->
loadingGif: path.resolve(__dirname, '..', 'resources', 'win', 'loading.gif')
iconUrl: 'https://raw.githubusercontent.com/atom/atom/master/resources/win/atom.ico'
setupIcon: path.resolve(__dirname, '..', 'resources', 'win', 'atom.ico')
remoteReleases: 'https://atom.io/api/updates'
shell:
'kill-atom':
+3 -3
Ver Arquivo
@@ -1,13 +1,13 @@
# VERSION: 0.1
# DESCRIPTION: Create the atom editor in a container
# DESCRIPTION: Create the atom editor in a container
# AUTHOR: Jessica Frazelle <jessie@docker.com>
# COMMENTS:
# This file describes how to build the atom editor
# This file describes how to build the atom editor
# in a container with all dependencies installed.
# Tested on Debian Jessie.
# USAGE:
# # Download atom Dockerfile
# wget http://raw.githubusercontent.com/atom/atom/master/Dockerfile
# wget https://raw.githubusercontent.com/atom/atom/master/Dockerfile
#
# # Build atom image
# docker build -t atom .
+2 -2
Ver Arquivo
@@ -12,7 +12,7 @@
"fs-plus": "2.x",
"github-releases": "~0.2.0",
"grunt": "~0.4.1",
"grunt-atom-shell-installer": "^0.20.0",
"grunt-atom-shell-installer": "^0.21.0",
"grunt-cli": "~0.1.9",
"grunt-coffeelint": "git+https://github.com/atom/grunt-coffeelint.git#cfb99aa99811d52687969532bd5a98011ed95bfe",
"grunt-contrib-coffee": "~0.12.0",
@@ -24,7 +24,7 @@
"grunt-peg": "~1.1.0",
"grunt-shell": "~0.3.1",
"harmony-collections": "~0.3.8",
"legal-eagle": "~0.8.0",
"legal-eagle": "~0.9.0",
"minidump": "~0.8",
"npm": "~1.4.5",
"rcedit": "~0.3.0",
+3
Ver Arquivo
@@ -79,3 +79,6 @@ module.exports =
LGPL
"""
'core-js@0.4.10':
license: 'MIT'
source: 'http://rock.mit-license.org linked in source files and bower.json says MIT'
+1 -1
Ver Arquivo
@@ -10,7 +10,7 @@ module.exports = (grunt) ->
fullPath = path.join(relativePath, fileName)
else
fullPath = fileName
longPaths.push(fullPath) if fullPath.length >= 200
longPaths.push(fullPath) if fullPath.length >= 175
longPaths.sort (longPath1, longPath2) -> longPath2.length - longPath1.length
+1 -1
Ver Arquivo
@@ -68,7 +68,7 @@ getAssets = ->
]
when 'win32'
assets = [{assetName: 'atom-windows.zip', sourcePath: 'Atom'}]
for squirrelAsset in ['AtomSetup.exe', 'RELEASES', "atom-#{version}-full.nupkg"]
for squirrelAsset in ['AtomSetup.exe', 'RELEASES', "atom-#{version}-full.nupkg", "atom-#{version}-delta.nupkg"]
cp path.join(buildDir, 'installer', squirrelAsset), path.join(buildDir, squirrelAsset)
assets.push({assetName: squirrelAsset, sourcePath: assetName})
assets
+31 -9
Ver Arquivo
@@ -49,19 +49,17 @@ can be expressed as keystroke patterns separated by spaces.
Commands are custom DOM events that are triggered when a keystroke matches a
binding. This allows user interface code to listen for named commands without
specifying the specific keybinding that triggers it. For example, the following
code sets up {EditorView} to listen for commands to move the cursor to the first
character of the current line:
code creates a command to insert the current date in an editor:
```coffee
class EditorView
listenForEvents: ->
@command 'editor:move-to-first-character-of-line', =>
@editor.moveToFirstCharacterOfLine()
atom.commands.add 'atom-text-editor',
'user:insert-date': (event) ->
editor = @getModel()
editor.insertText(new Date().toLocaleString())
```
The `::command` method is basically an enhanced version of jQuery's `::on`
method that listens for a custom DOM event and adds some metadata to the DOM,
which is read by the command palette.
`atom.commands` refers to the global {CommandRegistry} instance where all commands
are set and consequently picked up by the command palette.
When you are looking to bind new keys, it is often useful to use the command
palette (`ctrl-shift-p`) to discover what commands are being listened for in a
@@ -69,6 +67,30 @@ given focus context. Commands are "humanized" following a simple algorithm, so a
command like `editor:fold-current-row` would appear as "Editor: Fold Current
Row".
### "Composed" Commands
A common question is, "How do I make a single keybinding execute two or more
commands?" There isn't any direct support for this in Atom, but it can be
achieved by creating a custom command that performs the multiple actions
you desire and then creating a keybinding for that command. For example, let's
say I want to create a "composed" command that performs a Select Line followed
by Cut. You could add the following to your `init.coffee`:
```coffee
atom.commands.add 'atom-text-editor', 'custom:cut-line', ->
editor = atom.workspace.getActiveTextEditor()
editor.selectLinesContainingCursors()
editor.cutSelectedText()
```
Then let's say we want to map this custom command to `alt-ctrl-z`, you could
add the following to your keymap:
```coffee
'atom-text-editor':
'alt-ctrl-z': 'custom:cut-line'
```
### Specificity and Cascade Order
As is the case with CSS applying styles, when multiple bindings match for a
+1 -1
Ver Arquivo
@@ -8,7 +8,7 @@ Ubuntu LTS 12.04 64-bit is the recommended platform.
* C++ toolchain
* [Git](http://git-scm.com/)
* [Node.js](http://nodejs.org/download/) v0.10.x
* [npm](http://www.npmjs.org/) v1.4.x (bundled with Node.js)
* [npm](https://www.npmjs.com/) v1.4.x (bundled with Node.js)
* `npm -v` to check the version.
* `npm config set python /usr/bin/python2 -g` to ensure that gyp uses python2.
* You might need to run this command as `sudo`, depending on how you have set up [npm](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#ubuntu-mint-elementary-os).
+2 -2
Ver Arquivo
@@ -9,7 +9,7 @@
* For 64-bit builds of node and native modules you **must** have the
[Windows 7 64-bit SDK](http://www.microsoft.com/en-us/download/details.aspx?id=8279).
You may also need the [compiler update for the Windows SDK 7.1](http://www.microsoft.com/en-us/download/details.aspx?id=4422)
* [Python](http://www.python.org/download/) v2.7.
* [Python](https://www.python.org/downloads/) v2.7.
* The python.exe must be available at `%SystemDrive%\Python27\python.exe`.
If it is installed elsewhere, you can create a symbolic link to the
directory containing the python.exe using:
@@ -19,7 +19,7 @@
### On Windows 8
* [Visual Studio Express 2013 for Windows Desktop](http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs#DownloadFamilies_2)
* [node.js](http://nodejs.org/download/) v0.10.x
* [Python](http://www.python.org/download/) v2.7.x (required by [node-gyp](https://github.com/TooTallNate/node-gyp))
* [Python](https://www.python.org/downloads/) v2.7.x (required by [node-gyp](https://github.com/TooTallNate/node-gyp))
* [GitHub for Windows](http://windows.github.com/)
## Instructions
+4 -4
Ver Arquivo
@@ -44,9 +44,9 @@ the editor to see it in action!
on publishing the package you just created to [atom.io][atomio].
[atomio]: https://atom.io
[CSS]: http://en.wikipedia.org/wiki/Cascading_Style_Sheets
[LESS]: http://lesscss.org
[plist]: http://en.wikipedia.org/wiki/Property_list
[R]: http://en.wikipedia.org/wiki/R_(programming_language)
[CSS]: https://en.wikipedia.org/wiki/Cascading_Style_Sheets
[Less]: http://lesscss.org
[plist]: https://en.wikipedia.org/wiki/Property_list
[R]: https://en.wikipedia.org/wiki/R_(programming_language)
[TextMate]: http://macromates.com
[TextMateOrg]: https://github.com/textmate
+4 -4
Ver Arquivo
@@ -6,7 +6,7 @@ theme.
### Differences
TextMate themes use [plist][plist] files while Atom themes use [CSS][CSS] or
[LESS][LESS] to style the UI and syntax in the editor.
[Less][Less] to style the UI and syntax in the editor.
The utility that converts the theme first parses the theme's plist file and
then creates comparable CSS rules and properties that will style Atom similarly.
@@ -61,8 +61,8 @@ __Syntax Theme__ dropdown menu to enable your new theme.
on publishing the theme you just created to [atom.io][atomio].
[atomio]: https://atom.io
[CSS]: http://en.wikipedia.org/wiki/Cascading_Style_Sheets
[LESS]: http://lesscss.org
[plist]: http://en.wikipedia.org/wiki/Property_list
[CSS]: https://en.wikipedia.org/wiki/Cascading_Style_Sheets
[Less]: http://lesscss.org
[plist]: https://en.wikipedia.org/wiki/Property_list
[TextMate]: http://macromates.com
[TextMateThemes]: http://wiki.macromates.com/Themes/UserSubmittedThemes
+104 -15
Ver Arquivo
@@ -51,9 +51,24 @@ in the _menus_ directory are added alphabetically.
- `snippets` (**Optional**): an Array of Strings identifying the order of the
snippets your package needs to load. If not specified, snippets in the
_snippets_ directory are added alphabetically.
- `activationEvents` (**Optional**): an Array of Strings identifying events that
- `activationCommands` (**Optional**): an Array of Strings identifying commands that
trigger your package's activation. You can delay the loading of your package
until one of these events is triggered.
- `providedServices` (**Optional**): an Object describing the services that your
package provides, which can be used by other packages. The keys of this object
are the names of the services, and the values are Objects with the following
keys:
- `description` (**Optional**) a String describing the service
- `versions` (**Required**) an Object whose keys are Semver version strings,
and whose values are names of methods in your package's top-level module
that return a value implementing the service.
- `consumedServices` (**Optional**): an Object describing the services that your
package uses, which can be provided by other packages. The keys of this object
are the names of the services, and the values are Objects with the following
keys:
- `versions` (**Required**) an Object whose keys are Semver version ranges
and whose values are names of methods in your package's top-level module
that are called with values implementing the service.
## Source Code
@@ -83,9 +98,9 @@ module's `activate` method so you can restore your view to where the user left
off.
- `deactivate()`: This **optional** method is called when the window is shutting
down. If your package is watching any files or holding external resources in any
other way, release them here. If you're just subscribing to things on window,
you don't need to worry because that's getting torn down anyway.
down, or when your package is being updated or disabled. If your package is
watching any files, holding external resources, providing commands or subscribing
to events, release them here.
### Simple Package Code
@@ -112,19 +127,18 @@ module.exports =
serialize: -> # ...
```
Beyond this simple contract, your package has access to Atom's API. Be aware
that since we are early in development, APIs are subject to change and we have
not yet established clear boundaries between what is public and what is private.
Also, please collaborate with us if you need an API that doesn't exist. Our goal
is to build out Atom's API organically based on the needs of package authors
like you.
Beyond this simple contract, your package has access to [Atom's API][api]. Be aware
that the Atom 1.0 API is mostly frozen. Refer to the API documentation for what
is public. That said, please collaborate with us if you need an API that doesn't
exist. Our goal is to build out Atom's API organically based on the needs of
package authors like you.
## Style Sheets
Style sheets for your package should be placed in the _styles_ directory.
Any style sheets in this directory will be loaded and attached to the DOM when
your package is activated. Style sheets can be written as CSS or [LESS], but
LESS is recommended.
your package is activated. Style sheets can be written as CSS or [Less], but
Less is recommended.
Ideally, you won't need much in the way of styling. We've provided a standard
set of components which define both the colors and UI elements for any package
@@ -352,6 +366,79 @@ to indicate the type your value should be, its default, etc.
See the [Config API Docs](https://atom.io/docs/api/latest/Config) for more
details specifying your configuration.
## Interacting With Other Packages Via Services
Atom packages can interact with each other through versioned APIs called
*services*. To provide a service, in your `package.json`, specify one or more
version numbers, each paired with the name of a method on your package's main module:
```json
{
"providedServices": {
"my-service": {
"description": "Does a useful thing",
"versions": {
"1.2.3": "provideMyServiceV1",
"2.3.4": "provideMyServiceV2",
}
}
}
}
```
In your package's main module, implement the methods named above. These methods
will be called any time a package is activated that consumes their corresponding
service. They should return a value that implements the service's API.
```coffeescript
module.exports =
activate: -> # ...
provideMyServiceV1: ->
adaptToLegacyAPI(myService)
provideMyServiceV2: ->
myService
```
Similarly, to consume a service, specify one or more [version *ranges*][version-ranges],
each paired with the name of a method on the package's main module:
```json
{
"consumedServices": {
"another-service": {
"versions": {
"^1.2.3": "consumeAnotherServiceV1",
">=2.3.4 <2.5": "consumeAnotherServiceV2",
}
}
}
}
```
These methods will be called any time a package is activated that *provides* their
corresponding service. They will receive the service object as an argument. You
will usually need to perform some kind of cleanup in the event that the package
providing the service is deactivated. To do this, return a `Disposable` from
your service-consuming method:
```coffeescript
{Disposable} = require 'atom'
module.exports =
activate: -> # ...
consumeAnotherServiceV1: (service) ->
useService(adaptServiceFromLegacyAPI(service))
new Disposable -> stopUsingService(service)
consumeAnotherServiceV2: (service) ->
useService(service)
new Disposable -> stopUsingService(service)
```
## Bundle External Resources
It's common to ship external resources like images and fonts in the package, to
@@ -402,11 +489,12 @@ registry.
Run `apm help publish` to see all the available options and `apm help` to see
all the other available commands.
[api]: https://atom.io/docs/api/latest
[file-tree]: https://github.com/atom/tree-view
[status-bar]: https://github.com/atom/status-bar
[cs-syntax]: https://github.com/atom/language-coffee-script
[npm]: http://en.wikipedia.org/wiki/Npm_(software)
[npm-keys]: https://npmjs.org/doc/json.html
[npm]: https://en.wikipedia.org/wiki/Npm_(software)
[npm-keys]: https://docs.npmjs.com/files/package.json
[git-tag]: http://git-scm.com/book/en/Git-Basics-Tagging
[wrap-guide]: https://github.com/atom/wrap-guide/
[keymaps]: advanced/keymaps.md
@@ -418,9 +506,10 @@ all the other available commands.
[underscore]: http://underscorejs.org/
[jasmine]: http://jasmine.github.io
[cson]: https://github.com/atom/season
[LESS]: http://lesscss.org
[Less]: http://lesscss.org
[ui-variables]: https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less
[first-package]: your-first-package.html
[convert-bundle]: converting-a-text-mate-bundle.html
[convert-theme]: converting-a-text-mate-theme.html
[json-schema]: http://json-schema.org/
[version-ranges]: https://docs.npmjs.com/misc/semver#ranges
+10 -9
Ver Arquivo
@@ -1,7 +1,7 @@
# Creating a Theme
Atom's interface is rendered using HTML, and it's styled via [LESS] which is a
superset of CSS. Don't worry if you haven't heard of LESS before; it's just like
Atom's interface is rendered using HTML, and it's styled via [Less] which is a
superset of CSS. Don't worry if you haven't heard of Less before; it's just like
CSS, but with a few handy extensions.
Atom supports two types of themes: _UI_ and _syntax_. UI themes style
@@ -9,22 +9,23 @@ elements such as the tree view, the tabs, drop-down lists, and the status bar.
Syntax themes style the code inside the editor.
Themes can be installed and changed from the settings view which you can open
by selecting the _Atom > Preferences..._ menu and navigating to the _Themes_
section on the left hand side.
by selecting the _Atom > Preferences..._ menu and navigating to the _Install_
section and the _Themes_ section on the left hand side.
## Getting Started
Themes are pretty straightforward but it's still helpful to be familiar with
a few things before starting:
* LESS is a superset of CSS, but it has some really handy features like
* Less is a superset of CSS, but it has some really handy features like
variables. If you aren't familiar with its syntax, take a few minutes
to [familiarize yourself][less-tutorial].
* You may also want to review the concept of a _[package.json]_, too. This file
is used to help distribute your theme to Atom users.
* Your theme's _package.json_ must contain a `"theme"` key with a value
of `"ui"` or `"syntax"` for Atom to recognize and load it as a theme.
* You can find existing themes to install or fork on [atom.io](atomio).
* You can find existing themes to install or fork on
[atom.io][atomio-themes].
## Creating a Syntax Theme
@@ -130,13 +131,13 @@ _styleguide_, or use the shortcut `cmd-ctrl-shift-g`.
![styleguide-img]
[atomio]: http://atom.io/packages
[LESS]: http://lesscss.org/
[atomio-themes]: https://atom.io/themes
[Less]: http://lesscss.org/
[git]: http://git-scm.com/
[atom]: https://atom.io/
[package.json]: ./creating-a-package.html#package-json
[less-tutorial]: https://speakerdeck.com/danmatthews/less-css
[devtools-tutorial]: https://developers.google.com/chrome-developer-tools/docs/elements
[devtools-tutorial]: https://developer.chrome.com/devtools/docs/dom-and-styles
[ui-variables]: ./theme-variables.html
[livereload]: https://github.com/atom/dev-live-reload
[styleguide]: https://github.com/atom/styleguide
+3 -3
Ver Arquivo
@@ -169,17 +169,17 @@ For example, to change the color of the cursor, you could add the following
rule to your _~/.atom/styles.less_ file:
```less
atom-text-editor.is-focused .cursor {
atom-text-editor::shadow .cursor {
border-color: pink;
}
```
Unfamiliar with LESS? Read more about it [here][LESS].
Unfamiliar with Less? Read more about it [here][Less].
This file can also be named _styles.css_ and contain CSS.
[creating-a-package]: creating-a-package.md
[create-theme]: creating-a-theme.md
[LESS]: http://www.lesscss.org
[Less]: http://www.lesscss.org
[CSON]: https://github.com/atom/season
[CoffeeScript]: http://coffeescript.org/
+3
Ver Arquivo
@@ -11,6 +11,7 @@
* [Contributing](contributing.md)
* [Contributing to Core Packages](contributing-to-packages.md)
* [Debugging](debugging.md)
* [Your First Package](your-first-package.md)
### Advanced Topics
@@ -19,6 +20,8 @@
* [Keymaps](advanced/keymaps.md)
* [Serialization](advanced/serialization.md)
* [Scopes and Scope Descriptors](advanced/scopes-and-scope-descriptors.md)
* [Theme Variables](theme-variables.md)
* [apm REST API](apm-rest-api.md)
### Upgrading to 1.0 APIs
+3 -3
Ver Arquivo
@@ -47,7 +47,7 @@ If not, there are a few things you should check before publishing:
Before you publish a package it is a good idea to check ahead of time if
a package with the same name has already been published to atom.io. You can do
that by visiting `http://atom.io/packages/my-package` to see if the package
that by visiting `https://atom.io/packages/my-package` to see if the package
already exists. If it does, update your package's name to something that is
available before proceeding.
@@ -73,7 +73,7 @@ and you only need to enter this information the first time you publish. The
credentials are stored securely in your [keychain][keychain] once you login.
:tada: Your package is now published and available on atom.io. Head on over to
`http://atom.io/packages/my-package` to see your package's page.
`https://atom.io/packages/my-package` to see your package's page.
With `apm publish`, you can bump the version and publish by using
```sh
@@ -107,7 +107,7 @@ Use `patch` when you make a small change like a bug fix that does not add or rem
[atomio]: https://atom.io
[github]: https://github.com
[git-tag]: http://git-scm.com/book/en/Git-Basics-Tagging
[keychain]: http://en.wikipedia.org/wiki/Keychain_(Apple)
[keychain]: https://en.wikipedia.org/wiki/Keychain_(Apple)
[repo-guide]: http://guides.github.com/overviews/desktop
[semver]: http://semver.org
[your-first-package]: your-first-package.html
+1 -1
Ver Arquivo
@@ -24,7 +24,7 @@ Here's an example `.less` file that a package can define using theme variables:
```css
@import "ui-variables";
.my-selector{
.my-selector {
background-color: @base-background-color;
padding: @component-padding;
}
+2 -2
Ver Arquivo
@@ -1,6 +1,6 @@
# Writing specs
Atom uses [Jasmine](http://jasmine.github.io/2.0/introduction.html) as its spec framework. Any new functionality should have specs to guard against regressions.
Atom uses [Jasmine](http://jasmine.github.io/1.3/introduction.html) as its spec framework. Any new functionality should have specs to guard against regressions.
## Create a new spec
@@ -12,7 +12,7 @@ Atom uses [Jasmine](http://jasmine.github.io/2.0/introduction.html) as its spec
0. Add one or more `describe` methods
The `describe` method takes two arguments, a description and a function. If the description explains a behavior it typically begins with `when` if it is more like a unit test it begins with the method name.
The `describe` method takes two arguments, a description and a function. If the description explains a behavior it typically begins with `when`; if it is more like a unit test it begins with the method name.
```coffee
describe "when a test is written", ->
+4 -4
Ver Arquivo
@@ -1,7 +1,7 @@
# Create Your First Package
This tutorial will guide you though creating a simple command that replaces the
selected text with [ascii art](http://en.wikipedia.org/wiki/ASCII_art). When you
selected text with [ascii art](https://en.wikipedia.org/wiki/ASCII_art). When you
run our new command with the word "cool" selected, it will be replaced with:
```
@@ -72,12 +72,12 @@ command palette or by pressing `ctrl-alt-cmd-l`.
Now open the command panel and search for the `ascii-art:convert` command. But
it's not there! To fix this, open _package.json_ and find the property called
`activationEvents`. Activation Events speed up load time by allowing Atom to
`activationCommands`. Activation Events speed up load time by allowing Atom to
delay a package's activation until it's needed. So remove the existing command
and add `ascii-art:convert` to the `activationEvents` array:
and add `ascii-art:convert` to the `activationCommands` array:
```json
"activationEvents": ["ascii-art:convert"],
"activationCommands": ["ascii-art:convert"],
```
First, reload the window by running the command `window:reload`. Now when you
+45 -44
Ver Arquivo
@@ -1,7 +1,7 @@
{
"name": "atom",
"productName": "Atom",
"version": "0.176.0",
"version": "0.178.0",
"description": "A hackable text editor for the 21st Century.",
"main": "./src/browser/main.js",
"repository": {
@@ -17,10 +17,11 @@
"url": "http://github.com/atom/atom/raw/master/LICENSE.md"
}
],
"atomShellVersion": "0.20.5",
"atomShellVersion": "0.21.0",
"dependencies": {
"6to5-core": "^3.0.14",
"async": "0.2.6",
"atom-keymap": "^2.5.2",
"atom-keymap": "^3.1.0",
"bootstrap": "git+https://github.com/atom/bootstrap.git#6af81906189f1747fd6c93479e3d998ebe041372",
"clear-cut": "0.4.0",
"coffee-script": "1.8.0",
@@ -28,42 +29,42 @@
"color": "^0.7.3",
"delegato": "^1",
"emissary": "^1.3.1",
"event-kit": "^1.0.1",
"first-mate": "^2.2.4",
"event-kit": "^1.0.2",
"first-mate": "^3.0.0",
"fs-plus": "^2.3.2",
"fstream": "0.1.24",
"fuzzaldrin": "^2.1",
"git-utils": "^2.2",
"git-utils": "^3.0.0",
"grim": "1.1.0",
"guid": "0.0.10",
"jasmine-json": "~0.0",
"jasmine-tagged": "^1.1.2",
"jquery": "^2.1.1",
"less-cache": "0.19.0",
"less-cache": "0.21",
"marked": "^0.3",
"mixto": "^1",
"mkdirp": "0.3.5",
"nslog": "^1.0.1",
"oniguruma": "^3.0.6",
"nslog": "^2.0.0",
"oniguruma": "^4.0.0",
"optimist": "0.4.0",
"pathwatcher": "^2.6.1",
"pathwatcher": "^3.1.0",
"property-accessors": "^1",
"q": "^1.0.1",
"random-words": "0.0.1",
"react-atom-fork": "^0.11.4",
"react-atom-fork": "^0.11.5",
"reactionary-atom-fork": "^1.0.0",
"runas": "1.0.1",
"scandal": "1.0.3",
"runas": "2.0.0",
"scandal": "2.0.0",
"scoped-property-store": "^0.16.2",
"scrollbar-style": "^1.0.2",
"season": "^5.0.5",
"scrollbar-style": "^2.0.0",
"season": "^5.1.2",
"semver": "2.2.1",
"serializable": "^1",
"service-hub": "^0.2.0",
"space-pen": "3.8.2",
"stacktrace-parser": "0.1.1",
"temp": "0.7.0",
"text-buffer": "^3.10.1",
"text-buffer": "^4.0.0",
"theorist": "^1.0.2",
"underscore-plus": "^1.6.6",
"vm-compatibility-layer": "0.1.0"
@@ -75,64 +76,64 @@
"atom-light-ui": "0.40.0",
"base16-tomorrow-dark-theme": "0.25.0",
"base16-tomorrow-light-theme": "0.8.0",
"one-dark-ui": "0.2.0",
"one-dark-syntax": "0.2.0",
"one-light-syntax": "0.2.0",
"one-light-ui": "0.1.0",
"one-dark-ui": "0.3.0",
"one-dark-syntax": "0.3.0",
"one-light-syntax": "0.3.0",
"one-light-ui": "0.2.0",
"solarized-dark-syntax": "0.32.0",
"solarized-light-syntax": "0.19.0",
"archive-view": "0.44.0",
"autocomplete": "0.43.0",
"archive-view": "0.46.0",
"autocomplete": "0.44.0",
"autoflow": "0.21.0",
"autosave": "0.20.0",
"background-tips": "0.21.0",
"background-tips": "0.22.0",
"bookmarks": "0.35.0",
"bracket-matcher": "0.69.0",
"bracket-matcher": "0.71.0",
"command-palette": "0.34.0",
"deprecation-cop": "0.33.0",
"dev-live-reload": "0.39.0",
"deprecation-cop": "0.34.0",
"dev-live-reload": "0.41.0",
"encoding-selector": "0.17.0",
"exception-reporting": "0.21.0",
"find-and-replace": "0.156.0",
"fuzzy-finder": "0.65.0",
"git-diff": "0.49.0",
"git-diff": "0.50.0",
"go-to-line": "0.30.0",
"grammar-selector": "0.44.0",
"image-view": "0.47.0",
"image-view": "0.48.0",
"incompatible-packages": "0.21.0",
"keybinding-resolver": "0.27.0",
"link": "0.29.0",
"markdown-preview": "0.125.0",
"link": "0.30.0",
"markdown-preview": "0.132.0",
"metrics": "0.41.0",
"notifications": "0.25.0",
"notifications": "0.26.0",
"open-on-github": "0.32.0",
"package-generator": "0.37.0",
"release-notes": "0.47.0",
"settings-view": "0.174.0",
"snippets": "0.70.0",
"spell-check": "0.51.0",
"snippets": "0.72.0",
"spell-check": "0.54.0",
"status-bar": "0.57.0",
"styleguide": "0.42.0",
"symbols-view": "0.79.0",
"styleguide": "0.43.0",
"symbols-view": "0.81.0",
"tabs": "0.64.0",
"timecop": "0.27.0",
"tree-view": "0.148.0",
"update-package-dependencies": "0.7.0",
"timecop": "0.28.0",
"tree-view": "0.154.0",
"update-package-dependencies": "0.8.0",
"welcome": "0.21.0",
"whitespace": "0.28.0",
"wrap-guide": "0.31.0",
"language-c": "0.37.0",
"language-c": "0.38.0",
"language-clojure": "0.10.0",
"language-coffee-script": "0.39.0",
"language-css": "0.26.0",
"language-css": "0.27.0",
"language-gfm": "0.63.0",
"language-git": "0.10.0",
"language-go": "0.21.0",
"language-html": "0.28.0",
"language-hyperlink": "0.12.2",
"language-java": "0.14.0",
"language-javascript": "0.55.0",
"language-json": "0.11.0",
"language-javascript": "0.56.0",
"language-json": "0.12.0",
"language-less": "0.24.0",
"language-make": "0.13.0",
"language-mustache": "0.11.0",
@@ -148,9 +149,9 @@
"language-source": "0.9.0",
"language-sql": "0.14.0",
"language-text": "0.6.0",
"language-todo": "0.15.0",
"language-todo": "0.16.0",
"language-toml": "0.15.0",
"language-xml": "0.27.0",
"language-xml": "0.28.0",
"language-yaml": "0.22.0"
},
"private": true,
+2 -1
Ver Arquivo
@@ -5,6 +5,7 @@ Summary: Atom is a hackable text editor for the 21st century
License: MIT
URL: https://atom.io/
AutoReqProv: no # Avoid libchromiumcontent.so missing dependency
Prefix: /usr/local
%description
<%= description %>
@@ -13,7 +14,7 @@ AutoReqProv: no # Avoid libchromiumcontent.so missing dependency
mkdir -p %{buildroot}/usr/local/share/atom
cp -r /tmp/atom-build/Atom/* %{buildroot}/usr/local/share/atom
mkdir -p %{buildroot}/usr/local/bin/
ln -sf /usr/local/share/atom/resources/app/apm/node_modules/.bin/apm %{buildroot}/usr/local/bin/apm
ln -sf ../share/atom/resources/app/apm/node_modules/.bin/apm %{buildroot}/usr/local/bin/apm
cp atom.sh %{buildroot}/usr/local/bin/atom
chmod 755 atom.sh
mkdir -p %{buildroot}/usr/local/share/applications/
+41
Ver Arquivo
@@ -0,0 +1,41 @@
to5 = require '../src/6to5'
crypto = require 'crypto'
describe "6to5 transpiler support", ->
describe "::create6to5VersionAndOptionsDigest", ->
it "returns a digest for the library version and specified options", ->
defaultOptions =
blacklist: [
'useStrict'
]
experimental: true
optional: [
'asyncToGenerator'
]
reactCompat: true
sourceMap: 'inline'
version = '3.0.14'
shasum = crypto.createHash('sha1')
shasum.update('6to5-core', 'utf8')
shasum.update('\0', 'utf8')
shasum.update(version, 'utf8')
shasum.update('\0', 'utf8')
shasum.update('{"blacklist": ["useStrict",],"experimental": true,"optional": ["asyncToGenerator",],"reactCompat": true,"sourceMap": "inline",}')
expectedDigest = shasum.digest('hex')
observedDigest = to5.create6to5VersionAndOptionsDigest(version, defaultOptions)
expect(observedDigest).toEqual expectedDigest
describe "when a .js file starts with 'use 6to5';", ->
it "transpiles it using 6to5", ->
transpiled = require('./fixtures/6to5/single-quotes.js')
expect(transpiled(3)).toBe 4
describe 'when a .js file starts with "use 6to5";', ->
it "transpiles it using 6to5", ->
transpiled = require('./fixtures/6to5/double-quotes.js')
expect(transpiled(3)).toBe 4
describe "when a .js file does not start with 'use 6to6';", ->
it "does not transpile it using 6to5", ->
expect(-> require('./fixtures/6to5/invalid.js')).toThrow()
+1 -2
Ver Arquivo
@@ -47,9 +47,8 @@ describe "the `atom` global", ->
updateAvailableHandler.callCount > 0
runs ->
{releaseVersion, releaseNotes} = updateAvailableHandler.mostRecentCall.args[0]
{releaseVersion} = updateAvailableHandler.mostRecentCall.args[0]
expect(releaseVersion).toBe 'version'
expect(releaseNotes).toBe 'notes'
describe "loading default config", ->
it 'loads the default core config', ->
+76
Ver Arquivo
@@ -699,6 +699,26 @@ describe "Config", ->
expect(atom.config.get("foo.bar")).toBe 'baz'
expect(atom.config.get("foo.bar", scope: ['.source.ruby'])).toBe 'more-specific'
describe "when the config file does not conform to the schema", ->
beforeEach ->
fs.writeFileSync atom.config.configFilePath, """
'*':
foo:
bar: 'omg'
int: 'baz'
'.source.ruby':
foo:
bar: 'scoped'
int: 'nope'
"""
it "validates and does not load the incorrect values", ->
atom.config.loadUserConfig()
expect(atom.config.get("foo.int")).toBe 12
expect(atom.config.get("foo.bar")).toBe 'omg'
expect(atom.config.get("foo.int", scope: ['.source.ruby'])).toBe 12
expect(atom.config.get("foo.bar", scope: ['.source.ruby'])).toBe 'scoped'
describe "when the config file contains valid cson", ->
beforeEach ->
fs.writeFileSync(atom.config.configFilePath, "foo: bar: 'baz'")
@@ -1106,6 +1126,62 @@ describe "Config", ->
expect(atom.config.get('foo.bar.str', scope: ['.source.js'])).toBe 'omg'
expect(atom.config.get('foo.bar.str', scope: ['.source.coffee'])).toBe 'ok'
describe 'when a schema is added after config values have been set', ->
schema = null
beforeEach ->
schema =
type: 'object'
properties:
int:
type: 'integer'
default: 2
str:
type: 'string'
default: 'def'
it "respects the new schema when values are set", ->
expect(atom.config.set('foo.bar.str', 'global')).toBe true
expect(atom.config.set('foo.bar.str', 'scoped', scopeSelector: '.source.js')).toBe true
expect(atom.config.get('foo.bar.str')).toBe 'global'
expect(atom.config.get('foo.bar.str', scope: ['.source.js'])).toBe 'scoped'
expect(atom.config.set('foo.bar.noschema', 'nsGlobal')).toBe true
expect(atom.config.set('foo.bar.noschema', 'nsScoped', scopeSelector: '.source.js')).toBe true
expect(atom.config.get('foo.bar.noschema')).toBe 'nsGlobal'
expect(atom.config.get('foo.bar.noschema', scope: ['.source.js'])).toBe 'nsScoped'
expect(atom.config.set('foo.bar.int', 'nope')).toBe true
expect(atom.config.set('foo.bar.int', 'notanint', scopeSelector: '.source.js')).toBe true
expect(atom.config.set('foo.bar.int', 23, scopeSelector: '.source.coffee')).toBe true
expect(atom.config.get('foo.bar.int')).toBe 'nope'
expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 'notanint'
expect(atom.config.get('foo.bar.int', scope: ['.source.coffee'])).toBe 23
atom.config.setSchema('foo.bar', schema)
expect(atom.config.get('foo.bar.str')).toBe 'global'
expect(atom.config.get('foo.bar.str', scope: ['.source.js'])).toBe 'scoped'
expect(atom.config.get('foo.bar.noschema')).toBe 'nsGlobal'
expect(atom.config.get('foo.bar.noschema', scope: ['.source.js'])).toBe 'nsScoped'
expect(atom.config.get('foo.bar.int')).toBe 2
expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 2
expect(atom.config.get('foo.bar.int', scope: ['.source.coffee'])).toBe 23
it "sets all values that adhere to the schema", ->
expect(atom.config.set('foo.bar.int', 10)).toBe true
expect(atom.config.set('foo.bar.int', 15, scopeSelector: '.source.js')).toBe true
expect(atom.config.set('foo.bar.int', 23, scopeSelector: '.source.coffee')).toBe true
expect(atom.config.get('foo.bar.int')).toBe 10
expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 15
expect(atom.config.get('foo.bar.int', scope: ['.source.coffee'])).toBe 23
atom.config.setSchema('foo.bar', schema)
expect(atom.config.get('foo.bar.int')).toBe 10
expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 15
expect(atom.config.get('foo.bar.int', scope: ['.source.coffee'])).toBe 23
describe 'when the value has an "integer" type', ->
beforeEach ->
schema =
+3
Ver Arquivo
@@ -0,0 +1,3 @@
"use 6to5";
module.exports = v => v + 1
+3
Ver Arquivo
@@ -0,0 +1,3 @@
'use 6to6';
module.exports = v => v + 1
+3
Ver Arquivo
@@ -0,0 +1,3 @@
'use 6to5';
module.exports = v => v + 1
@@ -0,0 +1,10 @@
module.exports =
activate: ->
deactivate: ->
consumeFirstServiceV3: ->
consumeFirstServiceV4: ->
consumeSecondService: ->
@@ -0,0 +1,17 @@
{
"name": "package-with-consumed-services",
"consumedServices": {
"service-1": {
"versions": {
">=0.2 <=0.3.6": "consumeFirstServiceV3",
"^0.4.1": "consumeFirstServiceV4"
}
},
"service-2": {
"versions": {
"0.2.1 || 0.2.2": "consumeSecondService"
}
}
}
}
@@ -0,0 +1,4 @@
{
"name": "package-with-invalid-styles",
"version": "1.0.0"
}
@@ -0,0 +1 @@
{
@@ -0,0 +1,13 @@
module.exports =
activate: ->
deactivate: ->
provideFirstServiceV3: ->
'first-service-v3'
provideFirstServiceV4: ->
'first-service-v4'
provideSecondService: ->
'second-service'
@@ -0,0 +1,19 @@
{
"name": "package-with-provided-services",
"providedServices": {
"service-1": {
"description": "The first service",
"versions": {
"0.3.1": "provideFirstServiceV3",
"0.4.1": "provideFirstServiceV4"
}
},
"service-2": {
"description": "The second service",
"versions": {
"0.2.1": "provideSecondService"
}
}
}
}
+48
Ver Arquivo
@@ -1,5 +1,6 @@
{$, $$} = require '../src/space-pen-extensions'
Package = require '../src/package'
{Disposable} = require 'atom'
describe "PackageManager", ->
workspaceElement = null
@@ -22,6 +23,12 @@ describe "PackageManager", ->
expect(pack instanceof Package).toBe true
expect(pack.metadata.name).toBe "package-with-broken-keymap"
it "returns the package if it has an invalid stylesheet", ->
pack = atom.packages.loadPackage("package-with-invalid-styles")
expect(pack instanceof Package).toBe true
expect(pack.metadata.name).toBe "package-with-invalid-styles"
expect(pack.stylesheets.length).toBe 0
it "returns null if the package has an invalid package.json", ->
spyOn(console, 'warn')
expect(atom.packages.loadPackage("package-with-broken-package-json")).toBeNull()
@@ -445,6 +452,47 @@ describe "PackageManager", ->
runs ->
expect(atom.config.get 'editor.increaseIndentPattern', scope: ['.source.omg']).toBe '^a'
describe "service registration", ->
it "registers the package's provided and consumed services", ->
consumerModule = require "./fixtures/packages/package-with-consumed-services"
firstServiceV3Disposed = false
firstServiceV4Disposed = false
secondServiceDisposed = false
spyOn(consumerModule, 'consumeFirstServiceV3').andReturn(new Disposable -> firstServiceV3Disposed = true)
spyOn(consumerModule, 'consumeFirstServiceV4').andReturn(new Disposable -> firstServiceV4Disposed = true)
spyOn(consumerModule, 'consumeSecondService').andReturn(new Disposable -> secondServiceDisposed = true)
waitsForPromise ->
atom.packages.activatePackage("package-with-consumed-services")
waitsForPromise ->
atom.packages.activatePackage("package-with-provided-services")
runs ->
expect(consumerModule.consumeFirstServiceV3).toHaveBeenCalledWith('first-service-v3')
expect(consumerModule.consumeFirstServiceV4).toHaveBeenCalledWith('first-service-v4')
expect(consumerModule.consumeSecondService).toHaveBeenCalledWith('second-service')
consumerModule.consumeFirstServiceV3.reset()
consumerModule.consumeFirstServiceV4.reset()
consumerModule.consumeSecondService.reset()
atom.packages.deactivatePackage("package-with-provided-services")
expect(firstServiceV3Disposed).toBe true
expect(firstServiceV4Disposed).toBe true
expect(secondServiceDisposed).toBe true
atom.packages.deactivatePackage("package-with-consumed-services")
waitsForPromise ->
atom.packages.activatePackage("package-with-provided-services")
runs ->
expect(consumerModule.consumeFirstServiceV3).not.toHaveBeenCalled()
expect(consumerModule.consumeFirstServiceV4).not.toHaveBeenCalled()
expect(consumerModule.consumeSecondService).not.toHaveBeenCalled()
describe "::deactivatePackage(id)", ->
afterEach ->
atom.packages.unloadPackages()
+7
Ver Arquivo
@@ -17,6 +17,7 @@ Config = require '../src/config'
{Point} = require 'text-buffer'
Project = require '../src/project'
Workspace = require '../src/workspace'
ServiceHub = require 'service-hub'
TextEditor = require '../src/text-editor'
TextEditorView = require '../src/text-editor-view'
TextEditorElement = require '../src/text-editor-element'
@@ -77,6 +78,7 @@ beforeEach ->
projectPath = specProjectPath ? path.join(@specDirectory, 'fixtures')
atom.project = new Project(paths: [projectPath])
atom.workspace = new Workspace()
atom.packages.serviceHub = new ServiceHub
atom.keymaps.keyBindings = _.clone(keyBindingsToRestore)
atom.commands.restoreSnapshot(commandsToRestore)
atom.styles.restoreSnapshot(styleElementsToRestore)
@@ -213,6 +215,11 @@ jasmine.snapshotDeprecations = ->
jasmine.restoreDeprecationsSnapshot = ->
Grim.deprecations = deprecationsSnapshot
jasmine.useRealClock = ->
jasmine.unspy(window, 'setTimeout')
jasmine.unspy(window, 'clearTimeout')
jasmine.unspy(_._, 'now')
addCustomMatchers = (spec) ->
spec.addMatchers
toBeInstanceOf: (expected) ->
+54 -19
Ver Arquivo
@@ -135,7 +135,7 @@ describe "TextEditorComponent", ->
expect(newLineHeightInPixels).not.toBe initialLineHeightInPixels
expect(component.lineNodeForScreenRow(1).offsetTop).toBe 1 * newLineHeightInPixels
it "updates the top position of lines when the font family changes", ->
xit "updates the top position of lines when the font family changes", ->
# Can't find a font that changes the line height, but we think one might exist
linesComponent = component.refs.lines
spyOn(linesComponent, 'measureLineHeightAndDefaultCharWidth').andCallFake -> editor.setLineHeightInPixels(10)
@@ -301,7 +301,9 @@ describe "TextEditorComponent", ->
expect(component.lineNodeForScreenRow(10).textContent).toBe nbsp
it "interleaves invisible line-ending characters with indent guides on empty lines", ->
component.setShowIndentGuide(true)
atom.config.set "editor.showIndentGuide", true
nextAnimationFrame()
editor.setTextInBufferRange([[10, 0], [11, 0]], "\r\n", normalizeLineEndings: false)
nextAnimationFrame()
expect(component.lineNodeForScreenRow(10).innerHTML).toBe '<span class="indent-guide"><span class="invisible-character">C</span><span class="invisible-character">E</span></span>'
@@ -334,7 +336,8 @@ describe "TextEditorComponent", ->
describe "when indent guides are enabled", ->
beforeEach ->
component.setShowIndentGuide(true)
atom.config.set "editor.showIndentGuide", true
nextAnimationFrame()
it "adds an 'indent-guide' class to spans comprising the leading whitespace", ->
line1LeafNodes = getLeafNodes(component.lineNodeForScreenRow(1))
@@ -374,6 +377,22 @@ describe "TextEditorComponent", ->
expect(line2LeafNodes[2].textContent).toBe ' '
expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe true
it "renders indent guides correctly on lines containing only whitespace when invisibles are enabled", ->
atom.config.set 'editor.showInvisibles', true
atom.config.set 'editor.invisibles', space: '-', eol: 'x'
editor.getBuffer().insert([1, Infinity], '\n ')
nextAnimationFrame()
line2LeafNodes = getLeafNodes(component.lineNodeForScreenRow(2))
expect(line2LeafNodes.length).toBe 4
expect(line2LeafNodes[0].textContent).toBe '--'
expect(line2LeafNodes[0].classList.contains('indent-guide')).toBe true
expect(line2LeafNodes[1].textContent).toBe '--'
expect(line2LeafNodes[1].classList.contains('indent-guide')).toBe true
expect(line2LeafNodes[2].textContent).toBe '--'
expect(line2LeafNodes[2].classList.contains('indent-guide')).toBe true
expect(line2LeafNodes[3].textContent).toBe 'x'
it "does not render indent guides in trailing whitespace for lines containing non whitespace characters", ->
editor.getBuffer().setText " hi "
nextAnimationFrame()
@@ -410,7 +429,7 @@ describe "TextEditorComponent", ->
describe "when indent guides are disabled", ->
beforeEach ->
component.setShowIndentGuide(false)
expect(atom.config.get("editor.showIndentGuide")).toBe false
it "does not render indent guides on lines containing only whitespace", ->
editor.getBuffer().insert([1, Infinity], '\n ')
@@ -653,7 +672,7 @@ describe "TextEditorComponent", ->
expect(lineNumberHasClass(1, 'folded')).toBe false
describe "cursor rendering", ->
it "renders the currently visible cursors, translated relative to the scroll position", ->
it "renders the currently visible cursors", ->
cursor1 = editor.getLastCursor()
cursor1.setScreenPosition([0, 5])
@@ -690,9 +709,16 @@ describe "TextEditorComponent", ->
expect(cursorNodes[0].style['-webkit-transform']).toBe "translate(#{11 * charWidth}px, #{8 * lineHeightInPixels}px)"
expect(cursorNodes[1].style['-webkit-transform']).toBe "translate(#{10 * charWidth}px, #{4 * lineHeightInPixels}px)"
wrapperView.on 'cursor:moved', cursorMovedListener = jasmine.createSpy('cursorMovedListener')
cursor3.setScreenPosition([4, 11], autoscroll: false)
nextAnimationFrame()
expect(cursorNodes[1].style['-webkit-transform']).toBe "translate(#{11 * charWidth}px, #{4 * lineHeightInPixels}px)"
expect(cursorMovedListener).toHaveBeenCalled()
cursor3.destroy()
nextAnimationFrame()
cursorNodes = componentNode.querySelectorAll('.cursor')
expect(cursorNodes.length).toBe 1
expect(cursorNodes[0].style['-webkit-transform']).toBe "translate(#{11 * charWidth}px, #{8 * lineHeightInPixels}px)"
@@ -773,18 +799,23 @@ describe "TextEditorComponent", ->
cursorsNode = componentNode.querySelector('.cursors')
expect(cursorsNode.classList.contains('blink-off')).toBe false
advanceClock(component.props.cursorBlinkPeriod / 2)
nextAnimationFrame()
expect(cursorsNode.classList.contains('blink-off')).toBe true
advanceClock(component.props.cursorBlinkPeriod / 2)
nextAnimationFrame()
expect(cursorsNode.classList.contains('blink-off')).toBe false
# Stop blinking after moving the cursor
editor.moveRight()
nextAnimationFrame()
expect(cursorsNode.classList.contains('blink-off')).toBe false
advanceClock(component.props.cursorBlinkResumeDelay)
advanceClock(component.props.cursorBlinkPeriod / 2)
nextAnimationFrame()
expect(cursorsNode.classList.contains('blink-off')).toBe true
it "does not render cursors that are associated with non-empty selections", ->
@@ -915,7 +946,6 @@ describe "TextEditorComponent", ->
it "will flash the selection when flash:true is passed to editor::setSelectedBufferRange", ->
editor.setSelectedBufferRange([[1, 6], [1, 10]], flash: true)
nextAnimationFrame()
nextAnimationFrame() # flash starts on its own frame
selectionNode = componentNode.querySelector('.selection')
expect(selectionNode.classList.contains('flash')).toBe true
@@ -1089,14 +1119,14 @@ describe "TextEditorComponent", ->
nextAnimationFrame()
# Should not be rendering range containing the marker
expect(component.getRenderedRowRange()[1]).toBeLessThan 9
expect(component.presenter.computeEndRow()).toBeLessThan 9
regions = componentNode.querySelectorAll('.some-highlight .region')
# Nothing when outside the rendered row range
expect(regions.length).toBe 0
verticalScrollbarNode.scrollTop = 3.5 * lineHeightInPixels
verticalScrollbarNode.scrollTop = 4.5 * lineHeightInPixels
verticalScrollbarNode.dispatchEvent(new UIEvent('scroll'))
nextAnimationFrame()
@@ -1175,6 +1205,8 @@ describe "TextEditorComponent", ->
advanceClock(2)
decoration.flash('flash-class', 10)
nextAnimationFrame()
# Removed for 1 frame to force CSS transition to restart
expect(highlightNode.classList.contains('flash-class')).toBe false
@@ -1952,14 +1984,14 @@ describe "TextEditorComponent", ->
it "assigns the bottom/right of the scrollbars to the width of the opposite scrollbar if it is visible", ->
scrollbarCornerNode = componentNode.querySelector('.scrollbar-corner')
expect(verticalScrollbarNode.style.bottom).toBe ''
expect(horizontalScrollbarNode.style.right).toBe ''
expect(verticalScrollbarNode.style.bottom).toBe '0px'
expect(horizontalScrollbarNode.style.right).toBe '0px'
wrapperNode.style.height = 4.5 * lineHeightInPixels + 'px'
wrapperNode.style.width = '1000px'
component.measureHeightAndWidth()
nextAnimationFrame()
expect(verticalScrollbarNode.style.bottom).toBe ''
expect(verticalScrollbarNode.style.bottom).toBe '0px'
expect(horizontalScrollbarNode.style.right).toBe verticalScrollbarNode.offsetWidth + 'px'
expect(scrollbarCornerNode.style.display).toBe 'none'
@@ -1974,7 +2006,7 @@ describe "TextEditorComponent", ->
component.measureHeightAndWidth()
nextAnimationFrame()
expect(verticalScrollbarNode.style.bottom).toBe horizontalScrollbarNode.offsetHeight + 'px'
expect(horizontalScrollbarNode.style.right).toBe ''
expect(horizontalScrollbarNode.style.right).toBe '0px'
expect(scrollbarCornerNode.style.display).toBe 'none'
it "accounts for the width of the gutter in the scrollWidth of the horizontal scrollbar", ->
@@ -2059,7 +2091,7 @@ describe "TextEditorComponent", ->
componentNode.dispatchEvent(wheelEvent)
nextAnimationFrame()
expect(component.mouseWheelScreenRow).toBe null
expect(component.presenter.mouseWheelScreenRow).toBe null
it "clears the mouseWheelScreenRow after a delay even if the event does not cause scrolling", ->
expect(editor.getScrollTop()).toBe 0
@@ -2068,13 +2100,12 @@ describe "TextEditorComponent", ->
wheelEvent = new WheelEvent('mousewheel', wheelDeltaX: 0, wheelDeltaY: 10)
Object.defineProperty(wheelEvent, 'target', get: -> lineNode)
componentNode.dispatchEvent(wheelEvent)
expect(nextAnimationFrame).toBe noAnimationFrame
expect(editor.getScrollTop()).toBe 0
expect(component.mouseWheelScreenRow).toBe 0
advanceClock(component.mouseWheelScreenRowClearDelay)
expect(component.mouseWheelScreenRow).toBe null
expect(component.presenter.mouseWheelScreenRow).toBe 0
advanceClock(component.presenter.stoppedScrollingDelay)
expect(component.presenter.mouseWheelScreenRow).toBe null
it "does not preserve the line if it is on screen", ->
expect(componentNode.querySelectorAll('.line-number').length).toBe 14 # dummy line
@@ -2085,9 +2116,8 @@ describe "TextEditorComponent", ->
wheelEvent = new WheelEvent('mousewheel', wheelDeltaX: 0, wheelDeltaY: 100) # goes nowhere, we're already at scrollTop 0
Object.defineProperty(wheelEvent, 'target', get: -> lineNode)
componentNode.dispatchEvent(wheelEvent)
expect(nextAnimationFrame).toBe noAnimationFrame
expect(component.mouseWheelScreenRow).toBe 0
expect(component.presenter.mouseWheelScreenRow).toBe 0
editor.insertText("hello")
expect(componentNode.querySelectorAll('.line-number').length).toBe 14 # dummy line
expect(componentNode.querySelectorAll('.line').length).toBe 13
@@ -2508,6 +2538,7 @@ describe "TextEditorComponent", ->
it "does not assign a height on the component node", ->
wrapperNode.style.height = '200px'
component.measureHeightAndWidth()
nextAnimationFrame()
expect(componentNode.style.height).toBe ''
describe "when the wrapper view does not have an explicit height", ->
@@ -2565,6 +2596,7 @@ describe "TextEditorComponent", ->
it "works with the ::setEditorHeightInLines and ::setEditorWidthInChars helpers", ->
setEditorHeightInLines(wrapperView, 7)
nextAnimationFrame()
expect(componentNode.offsetHeight).toBe lineHeightInPixels * 7
setEditorWidthInChars(wrapperView, 10)
@@ -2698,6 +2730,7 @@ describe "TextEditorComponent", ->
beforeEach ->
atom.config.set 'editor.showIndentGuide', true, scopeSelector: '.source.js'
atom.config.set 'editor.showIndentGuide', false, scopeSelector: '.source.coffee'
nextAnimationFrame()
it "has an 'indent-guide' class when scoped editor.showIndentGuide is true, but not when scoped editor.showIndentGuide is false", ->
line1LeafNodes = getLeafNodes(component.lineNodeForScreenRow(1))
@@ -2706,6 +2739,7 @@ describe "TextEditorComponent", ->
expect(line1LeafNodes[1].classList.contains('indent-guide')).toBe false
editor.setGrammar(coffeeEditor.getGrammar())
nextAnimationFrame()
line1LeafNodes = getLeafNodes(component.lineNodeForScreenRow(1))
expect(line1LeafNodes[0].textContent).toBe ' '
@@ -2719,6 +2753,7 @@ describe "TextEditorComponent", ->
expect(line1LeafNodes[1].classList.contains('indent-guide')).toBe false
atom.config.set 'editor.showIndentGuide', false, scopeSelector: '.source.js'
nextAnimationFrame()
line1LeafNodes = getLeafNodes(component.lineNodeForScreenRow(1))
expect(line1LeafNodes[0].textContent).toBe ' '
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+2 -1
Ver Arquivo
@@ -364,12 +364,13 @@ describe "ThemeManager", ->
throw new Error('EACCES permission denied "styles.less"')
atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy()
it "creates an error notification", ->
it "creates an error notification and does not add the stylesheet", ->
themeManager.loadUserStylesheet()
expect(addErrorHandler).toHaveBeenCalled()
note = addErrorHandler.mostRecentCall.args[0]
expect(note.getType()).toBe 'error'
expect(note.getMessage()).toContain 'Error loading'
expect(atom.styles.styleElementsBySourcePath[atom.styles.getUserStyleSheetPath()]).toBeUndefined()
describe "when there is an error watching the user stylesheet", ->
addErrorHandler = null
+161
Ver Arquivo
@@ -0,0 +1,161 @@
###
Cache for source code transpiled by 6to5.
Inspired by https://github.com/atom/atom/blob/6b963a562f8d495fbebe6abdbafbc7caf705f2c3/src/coffee-cache.coffee.
###
crypto = require 'crypto'
fs = require 'fs-plus'
path = require 'path'
to5 = null # Defer until used
stats =
hits: 0
misses: 0
defaultOptions =
# The Chrome dev tools will show the original version of the file
# when the source map is inlined.
sourceMap: 'inline'
# Because Atom is currently packaged with a fork of React v0.11,
# it makes sense to use the --react-compat option so the React
# JSX transformer produces pre-v0.12 code.
reactCompat: true
# Blacklisted features do not get transpiled. Features that are
# natively supported in the target environment should be listed
# here. Because Atom uses a bleeding edge version of Node/io.js,
# I think this can include es6.arrowFunctions, es6.classes, and
# possibly others, but I want to be conservative.
blacklist: [
'useStrict'
]
# Includes support for es7 features listed at:
# http://6to5.org/docs/usage/transformers/#es7-experimental-.
experimental: true
optional: [
# Target a version of the regenerator runtime that
# supports yield so the transpiled code is cleaner/smaller.
'asyncToGenerator'
]
###
shasum - Hash with an update() method.
value - Must be a value that could be returned by JSON.parse().
###
updateDigestForJsonValue = (shasum, value) ->
# Implmentation is similar to that of pretty-printing a JSON object, except:
# * Strings are not escaped.
# * No effort is made to avoid trailing commas.
# These shortcuts should not affect the correctness of this function.
type = typeof value
if type is 'string'
shasum.update('"', 'utf8')
shasum.update(value, 'utf8')
shasum.update('"', 'utf8')
else if type in ['boolean', 'number']
shasum.update(value.toString(), 'utf8')
else if value is null
shasum.update('null', 'utf8')
else if Array.isArray value
shasum.update('[', 'utf8')
for item in value
updateDigestForJsonValue(shasum, item)
shasum.update(',', 'utf8')
shasum.update(']', 'utf8')
else
# value must be an object: be sure to sort the keys.
keys = Object.keys value
keys.sort()
shasum.update('{', 'utf8')
for key in keys
updateDigestForJsonValue(shasum, key)
shasum.update(': ', 'utf8')
updateDigestForJsonValue(shasum, value[key])
shasum.update(',', 'utf8')
shasum.update('}', 'utf8')
create6to5VersionAndOptionsDigest = (version, options) ->
shasum = crypto.createHash('sha1')
# Include the version of 6to5 in the hash.
shasum.update('6to5-core', 'utf8')
shasum.update('\0', 'utf8')
shasum.update(version, 'utf8')
shasum.update('\0', 'utf8')
updateDigestForJsonValue(shasum, options)
shasum.digest('hex')
jsCacheDir = null
getCachePath = (sourceCode) ->
digest = crypto.createHash('sha1').update(sourceCode, 'utf8').digest('hex')
unless jsCacheDir?
to5Version = require('6to5-core/package.json').version
cacheDir = path.join(fs.absolute('~/.atom'), 'compile-cache')
jsCacheDir = path.join(cacheDir, 'js', '6to5', create6to5VersionAndOptionsDigest(to5Version, defaultOptions))
path.join(jsCacheDir, "#{digest}.js")
getCachedJavaScript = (cachePath) ->
if fs.isFileSync(cachePath)
try
cachedJavaScript = fs.readFileSync(cachePath, 'utf8')
stats.hits++
return cachedJavaScript
null
# Returns the 6to5 options that should be used to transpile filePath.
createOptions = (filePath) ->
options = filename: filePath
for key, value of defaultOptions
options[key] = value
options
transpile = (sourceCode, filePath, cachePath) ->
options = createOptions(filePath)
to5 ?= require '6to5-core'
js = to5.transform(sourceCode, options).code
stats.misses++
try
fs.writeFileSync(cachePath, js)
js
# Function that obeys the contract of an entry in the require.extensions map.
# Returns the transpiled version of the JavaScript code at filePath, which is
# either generated on the fly or pulled from cache.
loadFile = (module, filePath) ->
sourceCode = fs.readFileSync(filePath, 'utf8')
unless sourceCode.startsWith('"use 6to5"') or sourceCode.startsWith("'use 6to5'")
return module._compile(sourceCode, filePath)
cachePath = getCachePath(sourceCode)
js = getCachedJavaScript(cachePath) ? transpile(sourceCode, filePath, cachePath)
module._compile(js, filePath)
register = ->
Object.defineProperty(require.extensions, '.js', {
writable: false
value: loadFile
})
module.exports =
register: register
getCacheMisses: -> stats.misses
getCacheHits: -> stats.hits
# Visible for testing.
create6to5VersionAndOptionsDigest: create6to5VersionAndOptionsDigest
addPathToCache: (filePath) ->
return if path.extname(filePath) isnt '.js'
sourceCode = fs.readFileSync(filePath, 'utf8')
cachePath = getCachePath(sourceCode)
transpile(sourceCode, filePath, cachePath)
+15 -6
Ver Arquivo
@@ -3,7 +3,6 @@ ipc = require 'ipc'
os = require 'os'
path = require 'path'
remote = require 'remote'
screen = require 'screen'
shell = require 'shell'
_ = require 'underscore-plus'
@@ -43,6 +42,12 @@ class Atom extends Model
which returns an HTMLElement.
"""
serviceHubDeprecationMessage = """
atom.services is no longer available. To register service providers and
consumers, use the `providedServices` and `consumedServices` fields in
your package's package.json.
"""
Object.defineProperty atom, 'workspaceView',
get: ->
deprecate(workspaceViewDeprecationMessage)
@@ -51,6 +56,14 @@ class Atom extends Model
deprecate(workspaceViewDeprecationMessage)
atom.__workspaceView = newValue
Object.defineProperty atom, 'services',
get: ->
deprecate(serviceHubDeprecationMessage)
atom.packages.serviceHub
set: (newValue) ->
deprecate(serviceHubDeprecationMessage)
atom.packages.serviceHub = newValue
atom
# Deserializes the Atom environment from a state object
@@ -134,9 +147,6 @@ class Atom extends Model
# Public: A {Clipboard} instance
clipboard: null
# A {ServiceHub} instance
services: null
# Public: A {ContextMenuManager} instance
contextMenu: null
@@ -236,7 +246,6 @@ class Atom extends Model
NotificationManager = require './notification-manager'
PackageManager = require './package-manager'
Clipboard = require './clipboard'
ServiceHub = require './service-hub'
GrammarRegistry = require './grammar-registry'
ThemeManager = require './theme-manager'
StyleManager = require './style-manager'
@@ -272,7 +281,6 @@ class Atom extends Model
@contextMenu = new ContextMenuManager({resourcePath, devMode})
@menu = new MenuManager({resourcePath})
@clipboard = new Clipboard()
@services = new ServiceHub
@grammars = @deserializers.deserialize(@state.grammars ? @state.syntax) ? new GrammarRegistry()
@@ -547,6 +555,7 @@ class Atom extends Model
if @isValidDimensions(dimensions)
dimensions
else
screen = remote.require 'screen'
{width, height} = screen.getPrimaryDisplay().workAreaSize
{x: 0, y: 0, width: Math.min(1024, width), height}
+2
Ver Arquivo
@@ -216,6 +216,8 @@ class AtomApplication
ipc.on 'open', (event, options) =>
window = @windowForEvent(event)
if options?
if typeof options.pathsToOpen is 'string'
options.pathsToOpen = [options.pathsToOpen]
if options.pathsToOpen?.length > 0
options.window = window
@openPaths(options)
+8 -3
Ver Arquivo
@@ -23,13 +23,18 @@ class AtomWindow
# Normalize to make sure drive letter case is consistent on Windows
@resourcePath = path.normalize(@resourcePath) if @resourcePath
@browserWindow = new BrowserWindow
options =
show: false
title: 'Atom'
icon: @constructor.iconPath
'web-preferences':
'direct-write': false
'direct-write': true
'subpixel-font-scaling': false
# Don't set icon on Windows so the exe's ico will be used as window and
# taskbar's icon. See https://github.com/atom/atom/issues/4811 for more.
if process.platform is 'linux'
options.icon = @constructor.iconPath
@browserWindow = new BrowserWindow options
global.atomApplication.addWindow(this)
@handleEvents()
+3 -3
Ver Arquivo
@@ -47,7 +47,7 @@ class AutoUpdateManager
@setState(ErrorState)
console.error "Error Downloading Update: #{message}"
autoUpdater.on 'update-downloaded', (event, @releaseNotes, @releaseVersion) =>
autoUpdater.on 'update-downloaded', (event, releaseNotes, @releaseVersion) =>
@setState(UpdateAvailableState)
@emitUpdateAvailableEvent(@getWindows()...)
@@ -61,9 +61,9 @@ class AutoUpdateManager
@setState(UnsupportedState)
emitUpdateAvailableEvent: (windows...) ->
return unless @releaseVersion? and @releaseNotes
return unless @releaseVersion?
for atomWindow in windows
atomWindow.sendMessage('update-available', {@releaseVersion, @releaseNotes})
atomWindow.sendMessage('update-available', {@releaseVersion})
setState: (state) ->
return if @state is state
+22 -8
Ver Arquivo
@@ -7,6 +7,10 @@ fs = require 'fs-plus'
cacheDir = path.join(fs.absolute('~/.atom'), 'compile-cache')
stats =
hits: 0
misses: 0
# Use separate compile cache when sudo'ing as root to avoid permission issues
if process.env.USER is 'root' and process.env.SUDO_USER and process.env.SUDO_USER isnt process.env.USER
cacheDir = path.join(cacheDir, 'root')
@@ -21,7 +25,10 @@ getCachePath = (coffee) ->
getCachedJavaScript = (cachePath) ->
if fs.isFileSync(cachePath)
try
fs.readFileSync(cachePath, 'utf8')
cachedJavaScript = fs.readFileSync(cachePath, 'utf8')
stats.hits++
return cachedJavaScript
return
convertFilePath = (filePath) ->
if process.platform is 'win32'
@@ -30,6 +37,7 @@ convertFilePath = (filePath) ->
compileCoffeeScript = (coffee, filePath, cachePath) ->
{js, v3SourceMap} = CoffeeScript.compile(coffee, filename: filePath, sourceMap: true)
stats.misses++
# Include source map in the web page environment.
if btoa? and JSON? and unescape? and encodeURIComponent?
js = "#{js}\n//# sourceMappingURL=data:application/json;base64,#{btoa unescape encodeURIComponent v3SourceMap}\n//# sourceURL=#{convertFilePath(filePath)}"
@@ -53,10 +61,16 @@ module.exports =
})
addPathToCache: (filePath) ->
extension = path.extname(filePath)
if extension is '.coffee'
content = fs.readFileSync(filePath, 'utf8')
cachePath = getCachePath(coffee)
compileCoffeeScript(coffee, filePath, cachePath)
else if extension is '.cson'
CSON.readFileSync(filePath)
switch path.extname(filePath)
when '.coffee'
content = fs.readFileSync(filePath, 'utf8')
cachePath = getCachePath(coffee)
compileCoffeeScript(coffee, filePath, cachePath)
when '.cson'
CSON.readFileSync(filePath)
when '.js'
require('./6to5').addPathToCache(filePath)
getCacheMisses: -> stats.misses
getCacheHits: -> stats.hits
+46 -14
Ver Arquivo
@@ -83,7 +83,7 @@ ScopeDescriptor = require './scope-descriptor'
#
# ## Config Schemas
#
# We use [json schema](json-schema.org) which allows you to define your value's
# We use [json schema](http://json-schema.org) which allows you to define your value's
# default, the type it should be, etc. A simple example:
#
# ```coffee
@@ -519,7 +519,7 @@ class Config
# * `options` (optional) {Object} see the `options` argument to {::get}
#
# Returns an {Array} of {Object}s with the following keys:
# * `scopeSelector` The scope-selector {String} with which the value is associated
# * `scopeDescriptor` The {ScopeDescriptor} with which the value is associated
# * `value` The value for the key-path
getAll: (keyPath, options) ->
{scope, sources} = options if options?
@@ -602,7 +602,7 @@ class Config
return false
if scopeSelector?
@setRawScopedValue(source, scopeSelector, keyPath, value)
@setRawScopedValue(keyPath, value, source, scopeSelector)
else
@setRawValue(keyPath, value)
@@ -797,6 +797,7 @@ class Config
_.extend rootSchema, schema
@setDefaults(keyPath, @extractDefaultsFromSchema(schema))
@setScopedDefaultsFromSchema(keyPath, schema)
@resetSettingsForSchemaChange()
load: ->
@initializeConfigDirectory()
@@ -998,9 +999,28 @@ class Config
defaults[key] = @extractDefaultsFromSchema(value) for key, value of properties
defaults
makeValueConformToSchema: (keyPath, value) ->
value = @constructor.executeSchemaEnforcers(keyPath, value, schema) if schema = @getSchema(keyPath)
value
makeValueConformToSchema: (keyPath, value, options) ->
if options?.suppressException
try
@makeValueConformToSchema(keyPath, value)
catch e
undefined
else
value = @constructor.executeSchemaEnforcers(keyPath, value, schema) if schema = @getSchema(keyPath)
value
# When the schema is changed / added, there may be values set in the config
# that do not conform to the schema. This will reset make them conform.
resetSettingsForSchemaChange: (source=@getUserConfigPath()) ->
@transact =>
@settings = @makeValueConformToSchema(null, @settings, suppressException: true)
priority = @priorityForSource(source)
selectorsAndSettings = @scopedSettingsStore.propertiesForSource(source)
@scopedSettingsStore.removePropertiesForSource(source)
for scopeSelector, settings of selectorsAndSettings
settings = @makeValueConformToSchema(null, settings, suppressException: true)
@setRawScopedValue(null, settings, source, scopeSelector)
return
###
Section: Private Scoped Settings
@@ -1017,8 +1037,15 @@ class Config
resetUserScopedSettings: (newScopedSettings) ->
source = @getUserConfigPath()
priority = @priorityForSource(source)
@scopedSettingsStore.removePropertiesForSource(source)
@scopedSettingsStore.addProperties(source, newScopedSettings, priority: @priorityForSource(source))
for scopeSelector, settings of newScopedSettings
settings = @makeValueConformToSchema(null, settings, suppressException: true)
validatedSettings = {}
validatedSettings[scopeSelector] = withoutEmptyObjects(settings)
@scopedSettingsStore.addProperties(source, validatedSettings, {priority}) if validatedSettings[scopeSelector]?
@emitChangeEvent()
addScopedSettings: (source, selector, value, options) ->
@@ -1031,7 +1058,7 @@ class Config
disposable.dispose()
@emitChangeEvent()
setRawScopedValue: (source, selector, keyPath, value) ->
setRawScopedValue: (keyPath, value, source, selector, options) ->
if keyPath?
newValue = {}
_.setValueForKeyPath(newValue, keyPath, value)
@@ -1118,12 +1145,17 @@ Config.addSchemaEnforcers
return value unless schema.properties?
newValue = {}
for prop, childSchema of schema.properties
continue unless value.hasOwnProperty(prop)
try
newValue[prop] = @executeSchemaEnforcers("#{keyPath}.#{prop}", value[prop], childSchema)
catch error
console.warn "Error setting item in object: #{error.message}"
for prop, propValue of value
childSchema = schema.properties[prop]
if childSchema?
try
newValue[prop] = @executeSchemaEnforcers("#{keyPath}.#{prop}", propValue, childSchema)
catch error
console.warn "Error setting item in object: #{error.message}"
else
# Just pass through un-schema'd values
newValue[prop] = propValue
newValue
'array':
+1 -5
Ver Arquivo
@@ -7,12 +7,8 @@ CursorComponent = React.createClass
displayName: 'CursorComponent'
render: ->
{pixelRect, defaultCharWidth} = @props
{pixelRect} = @props
{top, left, height, width} = pixelRect
width = defaultCharWidth if width is 0
WebkitTransform = "translate(#{left}px, #{top}px)"
div className: 'cursor', style: {height, width, WebkitTransform}
shouldComponentUpdate: (newProps) ->
not isEqualForProperties(newProps, @props, 'pixelRect', 'defaultCharWidth')
+5 -46
Ver Arquivo
@@ -7,55 +7,14 @@ CursorComponent = require './cursor-component'
module.exports =
CursorsComponent = React.createClass
displayName: 'CursorsComponent'
mixins: [SubscriberMixin]
cursorBlinkIntervalHandle: null
render: ->
{performedInitialMeasurement, cursorPixelRects, defaultCharWidth} = @props
{blinkOff} = @state
{presenter} = @props
className = 'cursors'
className += ' blink-off' if blinkOff
className += ' blink-off' if presenter.state.content.blinkCursorsOff
div {className},
if performedInitialMeasurement
for key, pixelRect of cursorPixelRects
CursorComponent({key, pixelRect, defaultCharWidth})
getInitialState: ->
blinkOff: false
componentDidMount: ->
@startBlinkingCursors()
componentWillUnmount: ->
@stopBlinkingCursors()
shouldComponentUpdate: (newProps, newState) ->
not newState.blinkOff is @state.blinkOff or
not isEqualForProperties(newProps, @props, 'cursorPixelRects', 'scrollTop', 'scrollLeft', 'defaultCharWidth', 'useHardwareAcceleration')
componentWillUpdate: (newProps) ->
cursorsMoved = @props.cursorPixelRects? and
isEqualForProperties(newProps, @props, 'defaultCharWidth', 'scopedCharacterWidthsChangeCount') and
not isEqual(newProps.cursorPixelRects, @props.cursorPixelRects)
@pauseCursorBlinking() if cursorsMoved
startBlinkingCursors: ->
@toggleCursorBlinkHandle = setInterval(@toggleCursorBlink, @props.cursorBlinkPeriod / 2) if @isMounted()
startBlinkingCursorsAfterDelay: null # Created lazily
stopBlinkingCursors: ->
clearInterval(@toggleCursorBlinkHandle)
toggleCursorBlink: ->
@setState(blinkOff: not @state.blinkOff)
pauseCursorBlinking: ->
@state.blinkOff = false
@stopBlinkingCursors()
@startBlinkingCursorsAfterDelay ?= debounce(@startBlinkingCursors, @props.cursorBlinkResumeDelay)
@startBlinkingCursorsAfterDelay()
if presenter.hasRequiredMeasurements()
for key, pixelRect of presenter.state.content.cursors
CursorComponent({key, pixelRect})
+2
Ver Arquivo
@@ -72,6 +72,8 @@ class Decoration
@emitter.emit 'did-destroy'
@emitter.dispose()
isDestroyed: -> @destroyed
###
Section: Event Subscription
###
+4 -4
Ver Arquivo
@@ -617,10 +617,10 @@ class DisplayBuffer extends Model
# bufferRange - The {Range} to convert
#
# Returns a {Range}.
screenRangeForBufferRange: (bufferRange) ->
screenRangeForBufferRange: (bufferRange, options) ->
bufferRange = Range.fromObject(bufferRange)
start = @screenPositionForBufferPosition(bufferRange.start)
end = @screenPositionForBufferPosition(bufferRange.end)
start = @screenPositionForBufferPosition(bufferRange.start, options)
end = @screenPositionForBufferPosition(bufferRange.end, options)
new Range(start, end)
# Given a screen range, this converts it into a buffer position.
@@ -897,7 +897,7 @@ class DisplayBuffer extends Model
getLineDecorations: (propertyFilter) ->
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('line')
getGutterDecorations: (propertyFilter) ->
getLineNumberDecorations: (propertyFilter) ->
@getDecorations(propertyFilter).filter (decoration) -> decoration.isType('line-number')
getHighlightDecorations: (propertyFilter) ->
+61 -129
Ver Arquivo
@@ -1,7 +1,8 @@
_ = require 'underscore-plus'
React = require 'react-atom-fork'
{div} = require 'reactionary-atom-fork'
{isEqual, isEqualForProperties, multiplyString, toArray} = require 'underscore-plus'
_ = require 'underscore-plus'
{isEqual, isEqualForProperties, multiplyString, toArray} = _
Decoration = require './decoration'
SubscriberMixin = require './subscriber-mixin'
@@ -12,23 +13,26 @@ GutterComponent = React.createClass
displayName: 'GutterComponent'
mixins: [SubscriberMixin]
maxLineNumberDigits: null
dummyLineNumberNode: null
measuredWidth: null
render: ->
{scrollHeight, scrollViewHeight, backgroundColor, gutterBackgroundColor} = @props
{presenter} = @props
@newState = presenter.state.gutter
@oldState ?= {lineNumbers: {}}
if gutterBackgroundColor isnt 'rbga(0, 0, 0, 0)'
backgroundColor = gutterBackgroundColor
{scrollHeight, backgroundColor} = @newState
div className: 'gutter',
div className: 'line-numbers', ref: 'lineNumbers', style:
height: Math.max(scrollHeight, scrollViewHeight)
WebkitTransform: @getTransform()
height: scrollHeight
WebkitTransform: @getTransform() if presenter.hasRequiredMeasurements()
backgroundColor: backgroundColor
getTransform: ->
{scrollTop, useHardwareAcceleration} = @props
{useHardwareAcceleration} = @props
{scrollTop} = @newState
if useHardwareAcceleration
"translate3d(0px, #{-scrollTop}px, 0px)"
@@ -37,141 +41,81 @@ GutterComponent = React.createClass
componentWillMount: ->
@lineNumberNodesById = {}
@lineNumberIdsByScreenRow = {}
@screenRowsByLineNumberId = {}
@renderedDecorationsByLineNumberId = {}
componentDidMount: ->
{@maxLineNumberDigits} = @newState
@appendDummyLineNumber()
@updateLineNumbers() if @props.performedInitialMeasurement
@updateLineNumbers()
node = @getDOMNode()
node.addEventListener 'click', @onClick
node.addEventListener 'mousedown', @onMouseDown
# Only update the gutter if the visible row range has changed or if a
# non-zero-delta change to the screen lines has occurred within the current
# visible row range.
shouldComponentUpdate: (newProps) ->
return true unless isEqualForProperties(newProps, @props,
'renderedRowRange', 'scrollTop', 'lineHeightInPixels', 'mouseWheelScreenRow', 'lineDecorations',
'scrollViewHeight', 'useHardwareAcceleration', 'backgroundColor', 'gutterBackgroundColor'
)
{renderedRowRange, pendingChanges, lineDecorations} = newProps
return false unless renderedRowRange?
for change in pendingChanges when Math.abs(change.screenDelta) > 0 or Math.abs(change.bufferDelta) > 0
return true unless change.end <= renderedRowRange.start or renderedRowRange.end <= change.start
false
componentDidUpdate: (oldProps) ->
return unless @props.performedInitialMeasurement
unless isEqualForProperties(oldProps, @props, 'maxLineNumberDigits')
{maxLineNumberDigits} = @newState
unless maxLineNumberDigits is @maxLineNumberDigits
@maxLineNumberDigits = maxLineNumberDigits
@updateDummyLineNumber()
@removeLineNumberNodes()
node.remove() for id, node of @lineNumberNodesById
@oldState = {lineNumbers: {}}
@lineNumberNodesById = {}
@clearScreenRowCaches() unless oldProps.lineHeightInPixels is @props.lineHeightInPixels
@updateLineNumbers()
clearScreenRowCaches: ->
@lineNumberIdsByScreenRow = {}
@screenRowsByLineNumberId = {}
# This dummy line number element holds the gutter to the appropriate width,
# since the real line numbers are absolutely positioned for performance reasons.
appendDummyLineNumber: ->
{maxLineNumberDigits} = @props
WrapperDiv.innerHTML = @buildLineNumberHTML(-1, false, maxLineNumberDigits)
WrapperDiv.innerHTML = @buildLineNumberHTML({bufferRow: -1})
@dummyLineNumberNode = WrapperDiv.children[0]
@refs.lineNumbers.getDOMNode().appendChild(@dummyLineNumberNode)
updateDummyLineNumber: ->
@dummyLineNumberNode.innerHTML = @buildLineNumberInnerHTML(0, false, @props.maxLineNumberDigits)
@dummyLineNumberNode.innerHTML = @buildLineNumberInnerHTML(0, false)
updateLineNumbers: ->
lineNumberIdsToPreserve = @appendOrUpdateVisibleLineNumberNodes()
@removeLineNumberNodes(lineNumberIdsToPreserve)
appendOrUpdateVisibleLineNumberNodes: ->
{editor, renderedRowRange, scrollTop, maxLineNumberDigits, lineDecorations} = @props
[startRow, endRow] = renderedRowRange
newLineNumberIds = null
newLineNumbersHTML = null
visibleLineNumberIds = new Set
wrapCount = 0
for bufferRow, index in editor.bufferRowsForScreenRows(startRow, endRow - 1)
screenRow = startRow + index
if bufferRow is lastBufferRow
id = "#{bufferRow}-#{wrapCount++}"
else
id = bufferRow.toString()
lastBufferRow = bufferRow
wrapCount = 0
visibleLineNumberIds.add(id)
if @hasLineNumberNode(id)
@updateLineNumberNode(id, bufferRow, screenRow, wrapCount > 0)
for id, lineNumberState of @newState.lineNumbers
if @oldState.lineNumbers.hasOwnProperty(id)
@updateLineNumberNode(id, lineNumberState)
else
newLineNumberIds ?= []
newLineNumbersHTML ?= ""
newLineNumberIds.push(id)
newLineNumbersHTML += @buildLineNumberHTML(bufferRow, wrapCount > 0, maxLineNumberDigits, screenRow)
@screenRowsByLineNumberId[id] = screenRow
@lineNumberIdsByScreenRow[screenRow] = id
@renderedDecorationsByLineNumberId[id] = lineDecorations[screenRow]
newLineNumbersHTML += @buildLineNumberHTML(lineNumberState)
@oldState.lineNumbers[id] = _.clone(lineNumberState)
if newLineNumberIds?
WrapperDiv.innerHTML = newLineNumbersHTML
newLineNumberNodes = toArray(WrapperDiv.children)
node = @refs.lineNumbers.getDOMNode()
for lineNumberId, i in newLineNumberIds
for id, i in newLineNumberIds
lineNumberNode = newLineNumberNodes[i]
@lineNumberNodesById[lineNumberId] = lineNumberNode
@lineNumberNodesById[id] = lineNumberNode
node.appendChild(lineNumberNode)
visibleLineNumberIds
for id, lineNumberState of @oldState.lineNumbers
unless @newState.lineNumbers.hasOwnProperty(id)
@lineNumberNodesById[id].remove()
delete @lineNumberNodesById[id]
delete @oldState.lineNumbers[id]
removeLineNumberNodes: (lineNumberIdsToPreserve) ->
{mouseWheelScreenRow} = @props
node = @refs.lineNumbers.getDOMNode()
for lineNumberId, lineNumberNode of @lineNumberNodesById when not lineNumberIdsToPreserve?.has(lineNumberId)
screenRow = @screenRowsByLineNumberId[lineNumberId]
if not screenRow? or screenRow isnt mouseWheelScreenRow
delete @lineNumberNodesById[lineNumberId]
delete @lineNumberIdsByScreenRow[screenRow] if @lineNumberIdsByScreenRow[screenRow] is lineNumberId
delete @screenRowsByLineNumberId[lineNumberId]
delete @renderedDecorationsByLineNumberId[lineNumberId]
node.removeChild(lineNumberNode)
buildLineNumberHTML: (bufferRow, softWrapped, maxLineNumberDigits, screenRow) ->
{editor, lineHeightInPixels, lineDecorations} = @props
buildLineNumberHTML: (lineNumberState) ->
{screenRow, bufferRow, softWrapped, top, decorationClasses} = lineNumberState
if screenRow?
style = "position: absolute; top: #{screenRow * lineHeightInPixels}px;"
style = "position: absolute; top: #{top}px;"
else
style = "visibility: hidden;"
innerHTML = @buildLineNumberInnerHTML(bufferRow, softWrapped, maxLineNumberDigits)
className = @buildLineNumberClassName(lineNumberState)
innerHTML = @buildLineNumberInnerHTML(bufferRow, softWrapped)
classes = ''
if lineDecorations? and decorations = lineDecorations[screenRow]
for id, decoration of decorations
if Decoration.isType(decoration, 'line-number')
classes += decoration.class + ' '
"<div class=\"#{className}\" style=\"#{style}\" data-buffer-row=\"#{bufferRow}\" data-screen-row=\"#{screenRow}\">#{innerHTML}</div>"
classes += "foldable " if bufferRow >= 0 and editor.isFoldableAtBufferRow(bufferRow)
classes += "line-number line-number-#{bufferRow}"
buildLineNumberInnerHTML: (bufferRow, softWrapped) ->
{maxLineNumberDigits} = @newState
"<div class=\"#{classes}\" style=\"#{style}\" data-buffer-row=\"#{bufferRow}\" data-screen-row=\"#{screenRow}\">#{innerHTML}</div>"
buildLineNumberInnerHTML: (bufferRow, softWrapped, maxLineNumberDigits) ->
if softWrapped
lineNumber = ""
else
@@ -181,46 +125,34 @@ GutterComponent = React.createClass
iconHTML = '<div class="icon-right"></div>'
padding + lineNumber + iconHTML
updateLineNumberNode: (lineNumberId, bufferRow, screenRow, softWrapped) ->
{editor, lineDecorations} = @props
updateLineNumberNode: (lineNumberId, newLineNumberState) ->
oldLineNumberState = @oldState.lineNumbers[lineNumberId]
node = @lineNumberNodesById[lineNumberId]
if editor.isFoldableAtBufferRow(bufferRow)
node.classList.add('foldable')
else
node.classList.remove('foldable')
unless oldLineNumberState.foldable is newLineNumberState.foldable and _.isEqual(oldLineNumberState.decorationClasses, newLineNumberState.decorationClasses)
node.className = @buildLineNumberClassName(newLineNumberState)
oldLineNumberState.foldable = newLineNumberState.foldable
oldLineNumberState.decorationClasses = _.clone(newLineNumberState.decorationClasses)
decorations = lineDecorations[screenRow]
previousDecorations = @renderedDecorationsByLineNumberId[lineNumberId]
unless oldLineNumberState.top is newLineNumberState.top
node.style.top = newLineNumberState.top + 'px'
node.dataset.screenRow = newLineNumberState.screenRow
oldLineNumberState.top = newLineNumberState.top
oldLineNumberState.screenRow = newLineNumberState.screenRow
if previousDecorations?
for id, decoration of previousDecorations
if Decoration.isType(decoration, 'line-number') and not @hasDecoration(decorations, decoration)
node.classList.remove(decoration.class)
if decorations?
for id, decoration of decorations
if Decoration.isType(decoration, 'line-number') and not @hasDecoration(previousDecorations, decoration)
node.classList.add(decoration.class)
unless @screenRowsByLineNumberId[lineNumberId] is screenRow
{lineHeightInPixels} = @props
node.style.top = screenRow * lineHeightInPixels + 'px'
node.dataset.screenRow = screenRow
@screenRowsByLineNumberId[lineNumberId] = screenRow
@lineNumberIdsByScreenRow[screenRow] = lineNumberId
hasDecoration: (decorations, decoration) ->
decorations? and decorations[decoration.id] is decoration
hasLineNumberNode: (lineNumberId) ->
@lineNumberNodesById.hasOwnProperty(lineNumberId)
buildLineNumberClassName: ({bufferRow, foldable, decorationClasses}) ->
className = "line-number line-number-#{bufferRow}"
className += " " + decorationClasses.join(' ') if decorationClasses?
className += " foldable" if foldable
className
lineNumberNodeForScreenRow: (screenRow) ->
@lineNumberNodesById[@lineNumberIdsByScreenRow[screenRow]]
for id, lineNumberState of @oldState.lineNumbers
if lineNumberState.screenRow is screenRow
return @lineNumberNodesById[id]
null
onMouseDown: (event) ->
{editor} = @props
{target} = event
lineNumber = target.parentNode
+29 -77
Ver Arquivo
@@ -5,94 +5,46 @@ React = require 'react-atom-fork'
module.exports =
HighlightComponent = React.createClass
displayName: 'HighlightComponent'
currentFlashCount: 0
currentFlashClass: null
render: ->
{startPixelPosition, endPixelPosition, decoration} = @props
{state} = @props
className = 'highlight'
className += " #{decoration.class}" if decoration.class?
className += " #{state.class}" if state.class?
div {className},
if endPixelPosition.top is startPixelPosition.top
@renderSingleLineRegions(decoration.deprecatedRegionClass)
else
@renderMultiLineRegions(decoration.deprecatedRegionClass)
for region, i in state.regions
regionClassName = 'region'
regionClassName += " #{state.deprecatedRegionClass}" if state.deprecatedRegionClass?
div className: regionClassName, key: i, style: region
componentDidMount: ->
{editor, decoration} = @props
if decoration.id?
@decoration = editor.decorationForId(decoration.id)
@decorationDisposable = @decoration.onDidFlash @startFlashAnimation
@startFlashAnimation()
@flashIfRequested()
componentWillUnmount: ->
@decorationDisposable?.dispose()
@decorationDisposable = null
componentDidUpdate: ->
@flashIfRequested()
startFlashAnimation: ->
return unless flash = @decoration.consumeNextFlash()
flashIfRequested: ->
if @props.state.flashCount > @currentFlashCount
@currentFlashCount = @props.state.flashCount
node = @getDOMNode()
node.classList.remove(flash.class)
node = @getDOMNode()
{flashClass, flashDuration} = @props.state
requestAnimationFrame =>
node.classList.add(flash.class)
clearTimeout(@flashTimeoutId)
removeFlashClass = -> node.classList.remove(flash.class)
@flashTimeoutId = setTimeout(removeFlashClass, flash.duration)
addFlashClass = =>
node.classList.add(flashClass)
@currentFlashClass = flashClass
@flashTimeoutId = setTimeout(removeFlashClass, flashDuration)
renderSingleLineRegions: (regionClass) ->
{startPixelPosition, endPixelPosition, lineHeightInPixels} = @props
removeFlashClass = =>
node.classList.remove(@currentFlashClass)
@currentFlashClass = null
clearTimeout(@flashTimeoutId)
className = 'region'
className += " #{regionClass}" if regionClass?
[
div className: className, key: 0, style:
top: startPixelPosition.top
height: lineHeightInPixels
left: startPixelPosition.left
width: endPixelPosition.left - startPixelPosition.left
]
renderMultiLineRegions: (regionClass) ->
{startPixelPosition, endPixelPosition, lineHeightInPixels} = @props
className = 'region'
className += " #{regionClass}" if regionClass?
regions = []
index = 0
# First row, extending from selection start to the right side of screen
regions.push(
div className: className, key: index++, style:
top: startPixelPosition.top
left: startPixelPosition.left
height: lineHeightInPixels
right: 0
)
# Middle rows, extending from left side to right side of screen
if endPixelPosition.top - startPixelPosition.top > lineHeightInPixels
regions.push(
div className: className, key: index++, style:
top: startPixelPosition.top + lineHeightInPixels
height: endPixelPosition.top - startPixelPosition.top - lineHeightInPixels
left: 0
right: 0
)
# Last row, extending from left side of screen to selection end
regions.push(
div className: className, key: index, style:
top: endPixelPosition.top
height: lineHeightInPixels
left: 0
width: endPixelPosition.left
)
regions
shouldComponentUpdate: (newProps) ->
not isEqualForProperties(newProps, @props, 'startPixelPosition', 'endPixelPosition', 'lineHeightInPixels', 'decoration')
if @currentFlashClass?
removeFlashClass()
requestAnimationFrame(addFlashClass)
else
addFlashClass()
+4 -10
Ver Arquivo
@@ -9,16 +9,13 @@ HighlightsComponent = React.createClass
render: ->
div className: 'highlights',
@renderHighlights() if @props.performedInitialMeasurement
@renderHighlights()
renderHighlights: ->
{editor, highlightDecorations, lineHeightInPixels} = @props
{presenter} = @props
highlightComponents = []
for markerId, {startPixelPosition, endPixelPosition, decorations} of highlightDecorations
for decoration in decorations
highlightComponents.push(HighlightComponent({editor, key: "#{markerId}-#{decoration.id}", startPixelPosition, endPixelPosition, decoration, lineHeightInPixels}))
for key, state of presenter.state.content.highlights
highlightComponents.push(HighlightComponent({key, state}))
highlightComponents
componentDidMount: ->
@@ -26,6 +23,3 @@ HighlightsComponent = React.createClass
insertionPoint = document.createElement('content')
insertionPoint.setAttribute('select', '.underlayer')
@getDOMNode().appendChild(insertionPoint)
shouldComponentUpdate: (newProps) ->
not isEqualForProperties(newProps, @props, 'highlightDecorations', 'lineHeightInPixels', 'defaultCharWidth', 'scopedCharacterWidthsChangeCount')
+1 -1
Ver Arquivo
@@ -32,7 +32,7 @@ class LanguageMode
return unless commentStartEntry?
commentEndEntry = atom.config.getAll('editor.commentEnd', {scope}).find (entry) ->
commentEndEntry = _.find atom.config.getAll('editor.commentEnd', {scope}), (entry) ->
entry.scopeSelector is commentStartEntry.scopeSelector
commentStartString = commentStartEntry?.value
commentEndString = commentEndEntry?.value
+104 -146
Ver Arquivo
@@ -4,7 +4,6 @@ React = require 'react-atom-fork'
{debounce, isEqual, isEqualForProperties, multiplyString, toArray} = require 'underscore-plus'
{$$} = require 'space-pen'
Decoration = require './decoration'
CursorsComponent = require './cursors-component'
HighlightsComponent = require './highlights-component'
OverlayManager = require './overlay-manager'
@@ -18,33 +17,26 @@ LinesComponent = React.createClass
displayName: 'LinesComponent'
render: ->
{performedInitialMeasurement, cursorBlinkPeriod, cursorBlinkResumeDelay} = @props
{editor, presenter} = @props
@oldState ?= {lines: {}}
@newState = presenter.state.content
if performedInitialMeasurement
{editor, overlayDecorations, highlightDecorations, scrollHeight, scrollWidth, placeholderText, backgroundColor} = @props
{lineHeightInPixels, defaultCharWidth, scrollViewHeight, scopedCharacterWidthsChangeCount} = @props
{scrollTop, scrollLeft, cursorPixelRects} = @props
style =
height: Math.max(scrollHeight, scrollViewHeight)
width: scrollWidth
WebkitTransform: @getTransform()
backgroundColor: if editor.isMini() then null else backgroundColor
{scrollHeight, scrollWidth, backgroundColor, placeholderText} = @newState
style =
height: scrollHeight
width: scrollWidth
WebkitTransform: @getTransform()
backgroundColor: backgroundColor
div {className: 'lines', style},
div className: 'placeholder-text', placeholderText if placeholderText?
CursorsComponent {
cursorPixelRects, cursorBlinkPeriod, cursorBlinkResumeDelay, lineHeightInPixels,
defaultCharWidth, scopedCharacterWidthsChangeCount, performedInitialMeasurement
}
HighlightsComponent {
editor, highlightDecorations, lineHeightInPixels, defaultCharWidth,
scopedCharacterWidthsChangeCount, performedInitialMeasurement
}
CursorsComponent {presenter}
HighlightsComponent {presenter}
getTransform: ->
{scrollTop, scrollLeft, useHardwareAcceleration} = @props
{scrollTop, scrollLeft} = @newState
{useHardwareAcceleration} = @props
if useHardwareAcceleration
"translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)"
@@ -52,7 +44,7 @@ LinesComponent = React.createClass
"translate(#{-scrollLeft}px, #{-scrollTop}px)"
componentWillMount: ->
@measuredLines = new WeakSet
@measuredLines = new Set
@lineNodesByLineId = {}
@screenRowsByLineId = {}
@lineIdsByScreenRow = {}
@@ -71,124 +63,91 @@ LinesComponent = React.createClass
else
@overlayManager = new OverlayManager(@getDOMNode())
shouldComponentUpdate: (newProps) ->
return true unless isEqualForProperties(newProps, @props,
'renderedRowRange', 'lineDecorations', 'highlightDecorations', 'lineHeightInPixels', 'defaultCharWidth',
'overlayDecorations', 'scrollTop', 'scrollLeft', 'showIndentGuide', 'scrollingVertically', 'visible',
'scrollViewHeight', 'mouseWheelScreenRow', 'scopedCharacterWidthsChangeCount', 'lineWidth', 'useHardwareAcceleration',
'placeholderText', 'performedInitialMeasurement', 'backgroundColor', 'cursorPixelRects'
)
componentDidUpdate: ->
{visible, presenter} = @props
{renderedRowRange, pendingChanges} = newProps
return false unless renderedRowRange?
[renderedStartRow, renderedEndRow] = renderedRowRange
for change in pendingChanges
if change.screenDelta is 0
return true unless change.end < renderedStartRow or renderedEndRow <= change.start
else
return true unless renderedEndRow <= change.start
false
componentDidUpdate: (prevProps) ->
{visible, scrollingVertically, performedInitialMeasurement} = @props
return unless performedInitialMeasurement
@clearScreenRowCaches() unless prevProps.lineHeightInPixels is @props.lineHeightInPixels
@removeLineNodes() unless isEqualForProperties(prevProps, @props, 'showIndentGuide')
@updateLines(@props.lineWidth isnt prevProps.lineWidth)
@measureCharactersInNewLines() if visible and not scrollingVertically
@removeLineNodes() unless @oldState.indentGuidesVisible is @newState.indentGuidesVisible
@updateLineNodes()
@measureCharactersInNewLines() if visible and not @newState.scrollingVertically
@overlayManager?.render(@props)
@oldState.indentGuidesVisible = @newState.indentGuidesVisible
@oldState.scrollWidth = @newState.scrollWidth
clearScreenRowCaches: ->
@screenRowsByLineId = {}
@lineIdsByScreenRow = {}
updateLines: (updateWidth) ->
{tokenizedLines, renderedRowRange, showIndentGuide, selectionChanged, lineDecorations} = @props
[startRow] = renderedRowRange
removeLineNodes: ->
@removeLineNode(id) for id of @oldState.lines
@removeLineNodes(tokenizedLines)
@appendOrUpdateVisibleLineNodes(tokenizedLines, startRow, updateWidth)
removeLineNode: (id) ->
@lineNodesByLineId[id].remove()
delete @lineNodesByLineId[id]
delete @lineIdsByScreenRow[@screenRowsByLineId[id]]
delete @screenRowsByLineId[id]
delete @oldState.lines[id]
removeLineNodes: (visibleLines=[]) ->
{mouseWheelScreenRow} = @props
visibleLineIds = new Set
visibleLineIds.add(line.id.toString()) for line in visibleLines
node = @getDOMNode()
for lineId, lineNode of @lineNodesByLineId when not visibleLineIds.has(lineId)
screenRow = @screenRowsByLineId[lineId]
if not screenRow? or screenRow isnt mouseWheelScreenRow
delete @lineNodesByLineId[lineId]
delete @lineIdsByScreenRow[screenRow] if @lineIdsByScreenRow[screenRow] is lineId
delete @screenRowsByLineId[lineId]
delete @renderedDecorationsByLineId[lineId]
node.removeChild(lineNode)
updateLineNodes: ->
{presenter} = @props
appendOrUpdateVisibleLineNodes: (visibleLines, startRow, updateWidth) ->
{lineDecorations} = @props
for id of @oldState.lines
unless @newState.lines.hasOwnProperty(id)
@removeLineNode(id)
newLines = null
newLineIds = null
newLinesHTML = null
for line, index in visibleLines
screenRow = startRow + index
if @hasLineNode(line.id)
@updateLineNode(line, screenRow, updateWidth)
for id, lineState of @newState.lines
if @oldState.lines.hasOwnProperty(id)
@updateLineNode(id)
else
newLines ?= []
newLineIds ?= []
newLinesHTML ?= ""
newLines.push(line)
newLinesHTML += @buildLineHTML(line, screenRow)
@screenRowsByLineId[line.id] = screenRow
@lineIdsByScreenRow[screenRow] = line.id
newLineIds.push(id)
newLinesHTML += @buildLineHTML(id)
@screenRowsByLineId[id] = lineState.screenRow
@lineIdsByScreenRow[lineState.screenRow] = id
@oldState.lines[id] = _.clone(lineState)
@renderedDecorationsByLineId[line.id] = lineDecorations[screenRow]
return unless newLines?
return unless newLineIds?
WrapperDiv.innerHTML = newLinesHTML
newLineNodes = toArray(WrapperDiv.children)
node = @getDOMNode()
for line, i in newLines
for id, i in newLineIds
lineNode = newLineNodes[i]
@lineNodesByLineId[line.id] = lineNode
@lineNodesByLineId[id] = lineNode
node.appendChild(lineNode)
hasLineNode: (lineId) ->
@lineNodesByLineId.hasOwnProperty(lineId)
buildLineHTML: (line, screenRow) ->
{showIndentGuide, lineHeightInPixels, lineDecorations, lineWidth} = @props
{tokens, text, lineEnding, fold, isSoftWrapped, indentLevel} = line
buildLineHTML: (id) ->
{presenter} = @props
{scrollWidth} = @newState
{screenRow, tokens, text, top, lineEnding, fold, isSoftWrapped, indentLevel, decorationClasses} = @newState.lines[id]
classes = ''
if decorations = lineDecorations[screenRow]
for id, decoration of decorations
if Decoration.isType(decoration, 'line')
classes += decoration.class + ' '
if decorationClasses?
for decorationClass in decorationClasses
classes += decorationClass + ' '
classes += 'line'
top = screenRow * lineHeightInPixels
lineHTML = "<div class=\"#{classes}\" style=\"position: absolute; top: #{top}px; width: #{lineWidth}px;\" data-screen-row=\"#{screenRow}\">"
lineHTML = "<div class=\"#{classes}\" style=\"position: absolute; top: #{top}px; width: #{scrollWidth}px;\" data-screen-row=\"#{screenRow}\">"
if text is ""
lineHTML += @buildEmptyLineInnerHTML(line)
lineHTML += @buildEmptyLineInnerHTML(id)
else
lineHTML += @buildLineInnerHTML(line)
lineHTML += @buildLineInnerHTML(id)
lineHTML += '<span class="fold-marker"></span>' if fold
lineHTML += "</div>"
lineHTML
buildEmptyLineInnerHTML: (line) ->
{showIndentGuide} = @props
{indentLevel, tabLength, endOfLineInvisibles} = line
buildEmptyLineInnerHTML: (id) ->
{indentGuidesVisible} = @newState
{indentLevel, tabLength, endOfLineInvisibles} = @newState.lines[id]
if showIndentGuide and indentLevel > 0
if indentGuidesVisible and indentLevel > 0
invisibleIndex = 0
lineHTML = ''
for i in [0...indentLevel]
@@ -201,31 +160,30 @@ LinesComponent = React.createClass
lineHTML += "</span>"
while invisibleIndex < endOfLineInvisibles?.length
lineHTML += "<span class='invisible-character'>#{line.endOfLineInvisibles[invisibleIndex++]}</span>"
lineHTML += "<span class='invisible-character'>#{endOfLineInvisibles[invisibleIndex++]}</span>"
lineHTML
else
@buildEndOfLineHTML(line) or '&nbsp;'
@buildEndOfLineHTML(id) or '&nbsp;'
buildLineInnerHTML: (line) ->
{editor, showIndentGuide} = @props
{tokens, text} = line
buildLineInnerHTML: (id) ->
{editor} = @props
{indentGuidesVisible} = @newState
{tokens, text, isOnlyWhitespace} = @newState.lines[id]
innerHTML = ""
scopeStack = []
firstTrailingWhitespacePosition = text.search(/\s*$/)
lineIsWhitespaceOnly = firstTrailingWhitespacePosition is 0
for token in tokens
innerHTML += @updateScopeStack(scopeStack, token.scopes)
hasIndentGuide = not editor.isMini() and showIndentGuide and (token.hasLeadingWhitespace() or (token.hasTrailingWhitespace() and lineIsWhitespaceOnly))
hasIndentGuide = indentGuidesVisible and (token.hasLeadingWhitespace() or (token.hasTrailingWhitespace() and isOnlyWhitespace))
innerHTML += token.getValueAsHtml({hasIndentGuide})
innerHTML += @popScope(scopeStack) while scopeStack.length > 0
innerHTML += @buildEndOfLineHTML(line)
innerHTML += @buildEndOfLineHTML(id)
innerHTML
buildEndOfLineHTML: (line) ->
{endOfLineInvisibles} = line
buildEndOfLineHTML: (id) ->
{endOfLineInvisibles} = @newState.lines[id]
html = ''
if endOfLineInvisibles?
@@ -258,33 +216,30 @@ LinesComponent = React.createClass
scopeStack.push(scope)
"<span class=\"#{scope.replace(/\.+/g, ' ')}\">"
updateLineNode: (line, screenRow, updateWidth) ->
{lineHeightInPixels, lineDecorations, lineWidth} = @props
lineNode = @lineNodesByLineId[line.id]
updateLineNode: (id) ->
{scrollWidth} = @newState
{screenRow, top} = @newState.lines[id]
decorations = lineDecorations[screenRow]
previousDecorations = @renderedDecorationsByLineId[line.id]
lineNode = @lineNodesByLineId[id]
if previousDecorations?
for id, decoration of previousDecorations
if Decoration.isType(decoration, 'line') and not @hasDecoration(decorations, decoration)
lineNode.classList.remove(decoration.class)
newDecorationClasses = @newState.lines[id].decorationClasses
oldDecorationClasses = @oldState.lines[id].decorationClasses
if decorations?
for id, decoration of decorations
if Decoration.isType(decoration, 'line') and not @hasDecoration(previousDecorations, decoration)
lineNode.classList.add(decoration.class)
if oldDecorationClasses?
for decorationClass in oldDecorationClasses
unless newDecorationClasses? and decorationClass in newDecorationClasses
lineNode.classList.remove(decorationClass)
lineNode.style.width = lineWidth + 'px' if updateWidth
if newDecorationClasses?
for decorationClass in newDecorationClasses
unless oldDecorationClasses? and decorationClass in oldDecorationClasses
lineNode.classList.add(decorationClass)
unless @screenRowsByLineId[line.id] is screenRow
lineNode.style.top = screenRow * lineHeightInPixels + 'px'
lineNode.dataset.screenRow = screenRow
@screenRowsByLineId[line.id] = screenRow
@lineIdsByScreenRow[screenRow] = line.id
hasDecoration: (decorations, decoration) ->
decorations? and decorations[decoration.id] is decoration
lineNode.style.width = scrollWidth + 'px'
lineNode.style.top = top + 'px'
lineNode.dataset.screenRow = screenRow
@screenRowsByLineId[id] = screenRow
@lineIdsByScreenRow[screenRow] = id
lineNodeForScreenRow: (screenRow) ->
@lineNodesByLineId[@lineIdsByScreenRow[screenRow]]
@@ -296,26 +251,27 @@ LinesComponent = React.createClass
charWidth = DummyLineNode.firstChild.getBoundingClientRect().width
node.removeChild(DummyLineNode)
{editor} = @props
{editor, presenter} = @props
presenter.setLineHeight(lineHeightInPixels)
editor.setLineHeightInPixels(lineHeightInPixels)
presenter.setBaseCharacterWidth(charWidth)
editor.setDefaultCharWidth(charWidth)
remeasureCharacterWidths: ->
return unless @props.performedInitialMeasurement
return unless @props.presenter.hasRequiredMeasurements()
@clearScopedCharWidths()
@measureCharactersInNewLines()
measureCharactersInNewLines: ->
{editor, tokenizedLines, renderedRowRange} = @props
[visibleStartRow] = renderedRowRange
{editor} = @props
node = @getDOMNode()
editor.batchCharacterMeasurement =>
for tokenizedLine in tokenizedLines
unless @measuredLines.has(tokenizedLine)
lineNode = @lineNodesByLineId[tokenizedLine.id]
@measureCharactersInLine(tokenizedLine, lineNode)
for id, lineState of @oldState.lines
unless @measuredLines.has(id)
lineNode = @lineNodesByLineId[id]
@measureCharactersInLine(lineState, lineNode)
return
measureCharactersInLine: (tokenizedLine, lineNode) ->
@@ -358,11 +314,13 @@ LinesComponent = React.createClass
rangeForMeasurement.setEnd(textNode, i + charLength)
charWidth = rangeForMeasurement.getBoundingClientRect().width
editor.setScopedCharWidth(scopes, char, charWidth)
@props.presenter.setScopedCharWidth(scopes, char, charWidth)
charIndex += charLength
@measuredLines.add(tokenizedLine)
@measuredLines.add(tokenizedLine.id)
clearScopedCharWidths: ->
@measuredLines.clear()
@props.editor.clearScopedCharWidths()
@props.presenter.clearScopedCharWidths()
+1 -1
Ver Arquivo
@@ -176,7 +176,7 @@ class MenuManager
element?.classList.toString().split(' ') ? []
sortPackagesMenu: ->
packagesMenu = @template.find ({label}) -> MenuHelpers.normalizeLabel(label) is 'Packages'
packagesMenu = _.find @template, ({label}) -> MenuHelpers.normalizeLabel(label) is 'Packages'
return unless packagesMenu?.submenu?
packagesMenu.submenu.sort (item1, item2) ->
+23 -28
Ver Arquivo
@@ -1,46 +1,41 @@
module.exports =
class OverlayManager
constructor: (@container) ->
@overlays = {}
@overlayNodesById = {}
render: (props) ->
{editor, overlayDecorations, lineHeightInPixels} = props
{presenter} = props
existingDecorations = null
for markerId, {headPixelPosition, tailPixelPosition, decorations} of overlayDecorations
for decoration in decorations
pixelPosition =
if decoration.position is 'tail' then tailPixelPosition else headPixelPosition
for decorationId, {pixelPosition, item} of presenter.state.content.overlays
@renderOverlay(presenter, decorationId, item, pixelPosition)
@renderOverlay(editor, decoration, pixelPosition, lineHeightInPixels)
existingDecorations ?= {}
existingDecorations[decoration.id] = true
for id, overlay of @overlays
unless existingDecorations? and id of existingDecorations
@container.removeChild(overlay)
delete @overlays[id]
for id, overlayNode of @overlayNodesById
unless presenter.state.content.overlays.hasOwnProperty(id)
overlayNode.remove()
delete @overlayNodesById[id]
return
renderOverlay: (editor, decoration, pixelPosition, lineHeightInPixels) ->
item = atom.views.getView(decoration.item)
unless overlay = @overlays[decoration.id]
overlay = @overlays[decoration.id] = document.createElement('atom-overlay')
overlay.appendChild(item)
@container.appendChild(overlay)
renderOverlay: (presenter, decorationId, item, pixelPosition) ->
item = atom.views.getView(item)
unless overlayNode = @overlayNodesById[decorationId]
overlayNode = @overlayNodesById[decorationId] = document.createElement('atom-overlay')
overlayNode.appendChild(item)
@container.appendChild(overlayNode)
itemWidth = item.offsetWidth
itemHeight = item.offsetHeight
{scrollTop, scrollLeft} = presenter.state.content
left = pixelPosition.left
if left + itemWidth - editor.getScrollLeft() > editor.getWidth() and left - itemWidth >= editor.getScrollLeft()
if left + itemWidth - scrollLeft > presenter.contentFrameWidth and left - itemWidth >= scrollLeft
left -= itemWidth
top = pixelPosition.top + lineHeightInPixels
if top + itemHeight - editor.getScrollTop() > editor.getHeight() and top - itemHeight - lineHeightInPixels >= editor.getScrollTop()
top -= itemHeight + lineHeightInPixels
top = pixelPosition.top + presenter.lineHeight
if top + itemHeight - scrollTop > presenter.computeHeight() and top - itemHeight - presenter.lineHeight >= scrollTop
top -= itemHeight + presenter.lineHeight
overlay.style.top = top + 'px'
overlay.style.left = left + 'px'
overlayNode.style.top = top + 'px'
overlayNode.style.left = left + 'px'
+2
Ver Arquivo
@@ -7,6 +7,7 @@ fs = require 'fs-plus'
Q = require 'q'
Grim = require 'grim'
ServiceHub = require 'service-hub'
Package = require './package'
ThemePackage = require './theme-package'
@@ -40,6 +41,7 @@ class PackageManager
@loadedPackages = {}
@activePackages = {}
@packageStates = {}
@serviceHub = new ServiceHub
@packageActivators = []
@registerPackageActivator(this, ['atom', 'textmate'])
+10
Ver Arquivo
@@ -159,6 +159,7 @@ class Package
if @requireMainModule()
@mainModule.activate(atom.packages.getPackageState(@name) ? {})
@mainActivated = true
@activateServices()
catch e
console.warn "Failed to activate package named '#{@name}'", e.stack
@@ -209,6 +210,15 @@ class Package
settings.activate() for settings in @settings
@settingsActivated = true
activateServices: ->
for name, {versions} of @metadata.providedServices
for version, methodName of versions
@activationDisposables.add atom.packages.serviceHub.provide(name, version, @mainModule[methodName]())
for name, {versions} of @metadata.consumedServices
for version, methodName of versions
@activationDisposables.add atom.packages.serviceHub.consume(name, version, @mainModule[methodName].bind(@mainModule))
loadKeymaps: ->
if @bundledPackage and packagesCache[@name]?
@keymaps = (["#{atom.packages.resourcePath}#{path.sep}#{keymapPath}", keymapObject] for keymapPath, keymapObject of packagesCache[@name].keymaps)
+2 -2
Ver Arquivo
@@ -48,7 +48,7 @@ class PaneContainer extends Model
deserializeParams: (params) ->
params.root = atom.deserializers.deserialize(params.root, container: this)
params.destroyEmptyPanes = atom.config.get('core.destroyEmptyPanes')
params.activePane = params.root.getPanes().find (pane) -> pane.id is params.activePaneId
params.activePane = find params.root.getPanes(), (pane) -> pane.id is params.activePaneId
params
serializeParams: (params) ->
@@ -147,7 +147,7 @@ class PaneContainer extends Model
find @getPanes(), (pane) -> pane.itemForURI(uri)?
paneForItem: (item) ->
@getPanes().find (pane) -> item in pane.getItems()
find @getPanes(), (pane) -> item in pane.getItems()
saveAll: ->
pane.saveItems() for pane in @getPanes()
+18 -26
Ver Arquivo
@@ -7,28 +7,33 @@ ScrollbarComponent = React.createClass
displayName: 'ScrollbarComponent'
render: ->
{orientation, className, scrollHeight, scrollWidth, visible} = @props
{scrollableInOppositeDirection, horizontalScrollbarHeight, verticalScrollbarWidth} = @props
{useHardwareAcceleration} = @props
{presenter, orientation, className, useHardwareAcceleration} = @props
switch orientation
when 'vertical'
@newState = presenter.state.verticalScrollbar
when 'horizontal'
@newState = presenter.state.horizontalScrollbar
style = {}
style.display = 'none' unless visible
style.display = 'none' unless @newState.visible
style.transform = 'translateZ(0)' if useHardwareAcceleration # See atom/atom#3559
switch orientation
when 'vertical'
style.width = verticalScrollbarWidth
style.bottom = horizontalScrollbarHeight if scrollableInOppositeDirection
style.width = @newState.width
style.bottom = @newState.bottom
when 'horizontal'
style.left = 0
style.right = verticalScrollbarWidth if scrollableInOppositeDirection
style.height = horizontalScrollbarHeight
style.right = @newState.right
style.height = @newState.height
div {className, style},
switch orientation
when 'vertical'
div className: 'scrollbar-content', style: {height: scrollHeight}
div className: 'scrollbar-content', style: {height: @newState.scrollHeight}
when 'horizontal'
div className: 'scrollbar-content', style: {width: scrollWidth}
div className: 'scrollbar-content', style: {width: @newState.scrollWidth}
componentDidMount: ->
{orientation} = @props
@@ -41,26 +46,15 @@ ScrollbarComponent = React.createClass
componentWillUnmount: ->
@getDOMNode().removeEventListener 'scroll', @onScroll
shouldComponentUpdate: (newProps) ->
return true if newProps.visible isnt @props.visible
switch @props.orientation
when 'vertical'
not isEqualForProperties(newProps, @props, 'scrollHeight', 'scrollTop', 'scrollableInOppositeDirection', 'verticalScrollbarWidth')
when 'horizontal'
not isEqualForProperties(newProps, @props, 'scrollWidth', 'scrollLeft', 'scrollableInOppositeDirection', 'horizontalScrollbarHeight')
componentDidUpdate: ->
{orientation, scrollTop, scrollLeft} = @props
{orientation} = @props
node = @getDOMNode()
switch orientation
when 'vertical'
node.scrollTop = scrollTop
@props.scrollTop = node.scrollTop # Ensure scrollTop reflects actual DOM without triggering another update
node.scrollTop = @newState.scrollTop
when 'horizontal'
node.scrollLeft = scrollLeft
@props.scrollLeft = node.scrollLeft # Ensure scrollLeft reflects actual DOM without triggering another update
node.scrollLeft = @newState.scrollLeft
onScroll: ->
{orientation, onScroll} = @props
@@ -69,9 +63,7 @@ ScrollbarComponent = React.createClass
switch orientation
when 'vertical'
scrollTop = node.scrollTop
@props.scrollTop = scrollTop # Ensure scrollTop reflects actual DOM without triggering another update
onScroll(scrollTop)
when 'horizontal'
scrollLeft = node.scrollLeft
@props.scrollLeft = scrollLeft # Ensure scrollLeft reflects actual DOM without triggering another update
onScroll(scrollLeft)
+5 -4
Ver Arquivo
@@ -7,7 +7,11 @@ ScrollbarCornerComponent = React.createClass
displayName: 'ScrollbarCornerComponent'
render: ->
{visible, measuringScrollbars, width, height} = @props
{presenter, measuringScrollbars} = @props
visible = presenter.state.horizontalScrollbar.visible and presenter.state.verticalScrollbar.visible
width = presenter.state.verticalScrollbar.width
height = presenter.state.horizontalScrollbar.height
if measuringScrollbars
height = 25
@@ -19,6 +23,3 @@ ScrollbarCornerComponent = React.createClass
div style:
height: height + 1
width: width + 1
shouldComponentUpdate: (newProps) ->
not isEqualForProperties(newProps, @props, 'measuringScrollbars', 'visible', 'width', 'height')
-93
Ver Arquivo
@@ -1,93 +0,0 @@
_ServiceHub = require('service-hub')
# Experimental: This class facilitates communication between Atom packages
# through semantically-versioned services. If you want your package to provide
# an API for other packages to interact with, provide or consume a service via
# the global instance of this class available as `atom.services`.
#
# If you're providing an API for other packages, the most straightforward is to
# `provide` a module namespaced under your package's name as follows.
#
# ```coffee
# atom.services.provide "status-bar", "1.0.0",
# addRightItem: (item) -> # ...
# addLeftItem: (item) -> # ...
# ```
#
# Then other packages can interact with your package by consuming the provided
# service. Note that a service consumer can provide an npm-style version range
# string to express the required API version of the consumed service. The
# callback will be invoked with the service immediately or when the service
# becomes available. If multiple services match the provided key-path and
# version range, the callback will be invoked multiple times.
#
# ```coffee
# atom.services.consume "status-bar", "^1.0.0", (statusBar) ->
# statusBar.addLeftItem(new GrammarChanger)
# ```
#
# You can also provide multiple services end-points under the same namespace by
# passing a dot-separated key path. In this example, we also provide a global
# reference to the status bar's DOM element so other packages can modify it
# directly. Doing this via `atom.services` is superior to querying from the DOM
# manually because you can use semantic versioning to indicate when the DOM
# structure changes in a breaking way.
#
# ```coffee
# atom.services.provide "status-bar.view", "1.0.0", statusBarElement
# ```
#
# By convention, every package owns its package name in the services namespace.
# Your package can provide a service under another package's namespace, but you
# should always conform to that package's API. If you want to make additions to
# the API, add them under your own namespace.
#
# When upgrading your package's API, consider retaining previous versions with
# shims if at all possible to minimize breakage and to give the ecosystem time
# to catch up with your changes.
#
# You can also apply an inverted pattern, where your package consumes services
# under its own namespace. In this pattern, you would define a contract for
# services that other packages provide and your package consumes. For example,
# say we were adding the ability to add custom completion providers to
# autocomplete:
#
# ```coffee
# atom.services.consume "autocomplete", "1.0.0", (provider) ->
# addCompletionProvider(provider)
# ```
#
# In this use case, you would want to consume a specific version number rather
# than a range. You could consume multiple version numbers to provide backward
# compatibility.
module.exports =
class ServiceHub extends _ServiceHub
# Experimental: Provide a service by invoking the callback of all current and
# future consumers matching the given key path and version range.
#
# * `keyPath` A {String} of `.` separated keys indicating the services's
# location in the namespace of all services.
# * `version` A {String} containing a [semantic version](http://semver.org/)
# for the service's API.
# * `service` An object exposing the service API.
#
# Returns a {Disposable} on which `.dispose()` can be called to remove the
# provided service.
provide: (keyPath, version, service) ->
super
# Experimental: Consume a service by invoking the given callback for all
# current and future provided services matching the given key path and version
# range.
#
# * `keyPath` A {String} of `.` separated keys indicating the services's
# location in the namespace of all services.
# * `versionRange` A {String} containing a [semantic version range](https://www.npmjs.org/doc/misc/semver.html)
# that any provided services for the given key path must satisfy.
# * `callback` A {Function} to be called with current and future matching
# service objects.
#
# Returns a {Disposable} on which `.dispose()` can be called to remove the
# consumer.
consume: (keyPath, versionRange, callback) ->
super
+43 -253
Ver Arquivo
@@ -8,6 +8,7 @@ grim = require 'grim'
{CompositeDisposable} = require 'event-kit'
ipc = require 'ipc'
TextEditorPresenter = require './text-editor-presenter'
GutterComponent = require './gutter-component'
InputComponent = require './input-component'
LinesComponent = require './lines-component'
@@ -21,9 +22,6 @@ TextEditorComponent = React.createClass
mixins: [SubscriberMixin]
visible: false
autoHeight: false
backgroundColor: null
gutterBackgroundColor: null
pendingScrollTop: null
pendingScrollLeft: null
selectOnMouseMove: false
@@ -32,13 +30,9 @@ TextEditorComponent = React.createClass
updateRequestedWhilePaused: false
cursorMoved: false
selectionChanged: false
scrollingVertically: false
mouseWheelScreenRow: null
mouseWheelScreenRowClearDelay: 150
scrollSensitivity: 0.4
heightAndWidthMeasurementRequested: false
inputEnabled: true
scopedCharacterWidthsChangeCount: null
domPollingInterval: 100
domPollingIntervalId: null
domPollingPaused: false
@@ -47,46 +41,19 @@ TextEditorComponent = React.createClass
remeasureCharacterWidthsWhenShown: false
render: ->
{focused, showIndentGuide, showLineNumbers, visible} = @state
{focused, showLineNumbers} = @state
{editor, cursorBlinkPeriod, cursorBlinkResumeDelay, hostElement, useShadowDOM} = @props
maxLineNumberDigits = editor.getLineCount().toString().length
hasSelection = editor.getLastSelection()? and !editor.getLastSelection().isEmpty()
style = {}
@performedInitialMeasurement = false if editor.isDestroyed()
if @performedInitialMeasurement
renderedRowRange = @getRenderedRowRange()
[renderedStartRow, renderedEndRow] = renderedRowRange
cursorPixelRects = @getCursorPixelRects(renderedRowRange)
tokenizedLines = editor.tokenizedLinesForScreenRows(renderedStartRow, renderedEndRow - 1)
decorations = editor.decorationsForScreenRowRange(renderedStartRow, renderedEndRow)
highlightDecorations = @getHighlightDecorations(decorations)
overlayDecorations = @getOverlayDecorations(decorations)
lineDecorations = @getLineDecorations(decorations)
placeholderText = editor.getPlaceholderText() if editor.isEmpty()
visible = @isVisible()
scrollHeight = editor.getScrollHeight()
scrollWidth = editor.getScrollWidth()
scrollTop = editor.getScrollTop()
scrollLeft = editor.getScrollLeft()
lineHeightInPixels = editor.getLineHeightInPixels()
defaultCharWidth = editor.getDefaultCharWidth()
scrollViewHeight = editor.getHeight()
lineWidth = Math.max(scrollWidth, editor.getWidth())
horizontalScrollbarHeight = editor.getHorizontalScrollbarHeight()
verticalScrollbarWidth = editor.getVerticalScrollbarWidth()
verticallyScrollable = editor.verticallyScrollable()
horizontallyScrollable = editor.horizontallyScrollable()
hiddenInputStyle = @getHiddenInputPosition()
hiddenInputStyle.WebkitTransform = 'translateZ(0)' if @useHardwareAcceleration
if @mouseWheelScreenRow? and not (renderedStartRow <= @mouseWheelScreenRow < renderedEndRow)
mouseWheelScreenRow = @mouseWheelScreenRow
style.height = scrollViewHeight if @autoHeight
style.height = @presenter.state.height if @presenter.state.height?
if useShadowDOM
className = 'editor-contents--private'
@@ -98,10 +65,8 @@ TextEditorComponent = React.createClass
div {className, style},
if @gutterVisible
GutterComponent {
ref: 'gutter', onMouseDown: @onGutterMouseDown, lineDecorations,
defaultCharWidth, editor, renderedRowRange, maxLineNumberDigits, scrollViewHeight,
scrollTop, scrollHeight, lineHeightInPixels, @pendingChanges, mouseWheelScreenRow,
@useHardwareAcceleration, @performedInitialMeasurement, @backgroundColor, @gutterBackgroundColor
ref: 'gutter', onMouseDown: @onGutterMouseDown,
@presenter, editor, @useHardwareAcceleration
}
div ref: 'scrollView', className: 'scroll-view',
@@ -111,53 +76,30 @@ TextEditorComponent = React.createClass
style: hiddenInputStyle
LinesComponent {
ref: 'lines',
editor, lineHeightInPixels, defaultCharWidth, tokenizedLines,
lineDecorations, highlightDecorations, overlayDecorations, hostElement,
showIndentGuide, renderedRowRange, @pendingChanges, scrollTop, scrollLeft,
@scrollingVertically, scrollHeight, scrollWidth, mouseWheelScreenRow,
visible, scrollViewHeight, @scopedCharacterWidthsChangeCount, lineWidth, @useHardwareAcceleration,
placeholderText, @performedInitialMeasurement, @backgroundColor, cursorPixelRects,
cursorBlinkPeriod, cursorBlinkResumeDelay, useShadowDOM
ref: 'lines', @presenter, editor, hostElement, @useHardwareAcceleration, useShadowDOM, visible
}
ScrollbarComponent
ref: 'horizontalScrollbar'
className: 'horizontal-scrollbar'
orientation: 'horizontal'
presenter: @presenter
onScroll: @onHorizontalScroll
scrollLeft: scrollLeft
scrollWidth: scrollWidth
visible: horizontallyScrollable
scrollableInOppositeDirection: verticallyScrollable
verticalScrollbarWidth: verticalScrollbarWidth
horizontalScrollbarHeight: horizontalScrollbarHeight
useHardwareAcceleration: @useHardwareAcceleration
ScrollbarComponent
ref: 'verticalScrollbar'
className: 'vertical-scrollbar'
orientation: 'vertical'
presenter: @presenter
onScroll: @onVerticalScroll
scrollTop: scrollTop
scrollHeight: scrollHeight
visible: verticallyScrollable
scrollableInOppositeDirection: horizontallyScrollable
verticalScrollbarWidth: verticalScrollbarWidth
horizontalScrollbarHeight: horizontalScrollbarHeight
useHardwareAcceleration: @useHardwareAcceleration
# Also used to measure the height/width of scrollbars after the initial render
ScrollbarCornerComponent
ref: 'scrollbarCorner'
visible: horizontallyScrollable and verticallyScrollable
presenter: @presenter
measuringScrollbars: @measuringScrollbars
height: horizontalScrollbarHeight
width: verticalScrollbarWidth
getPageRows: ->
{editor} = @props
Math.max(1, Math.ceil(editor.getHeight() / editor.getLineHeightInPixels()))
getInitialState: -> {}
@@ -167,11 +109,23 @@ TextEditorComponent = React.createClass
lineOverdrawMargin: 15
componentWillMount: ->
@pendingChanges = []
@props.editor.manageScrollPosition = true
@observeConfig()
@setScrollSensitivity(atom.config.get('editor.scrollSensitivity'))
{editor, lineOverdrawMargin, cursorBlinkPeriod, cursorBlinkResumeDelay} = @props
@presenter = new TextEditorPresenter
model: editor
scrollTop: editor.getScrollTop()
scrollLeft: editor.getScrollLeft()
lineOverdrawMargin: lineOverdrawMargin
cursorBlinkPeriod: cursorBlinkPeriod
cursorBlinkResumeDelay: cursorBlinkResumeDelay
stoppedScrollingDelay: 200
@presenter.onDidUpdateState(@requestUpdate)
componentDidMount: ->
{editor, stylesElement} = @props
@@ -202,7 +156,6 @@ TextEditorComponent = React.createClass
componentDidUpdate: (prevProps, prevState) ->
cursorMoved = @cursorMoved
selectionChanged = @selectionChanged
@pendingChanges.length = 0
@cursorMoved = false
@selectionChanged = false
@@ -215,10 +168,10 @@ TextEditorComponent = React.createClass
becameVisible: ->
@updatesPaused = true
@measureScrollbars() if @measureScrollbarsWhenShown
@sampleFontStyling()
@sampleBackgroundColors()
@measureHeightAndWidth()
@measureScrollbars() if @measureScrollbarsWhenShown
@measureLineHeightAndDefaultCharWidth() if @measureLineHeightAndDefaultCharWidthWhenShown
@remeasureCharacterWidths() if @remeasureCharacterWidthsWhenShown
@props.editor.setVisible(true)
@@ -257,13 +210,6 @@ TextEditorComponent = React.createClass
getTopmostDOMNode: ->
@props.hostElement
getRenderedRowRange: ->
{editor, lineOverdrawMargin} = @props
[visibleStartRow, visibleEndRow] = editor.getVisibleRowRange()
renderedStartRow = Math.max(0, visibleStartRow - lineOverdrawMargin)
renderedEndRow = Math.min(editor.getScreenLineCount(), visibleEndRow + lineOverdrawMargin)
[renderedStartRow, renderedEndRow]
getHiddenInputPosition: ->
{editor} = @props
{focused} = @state
@@ -277,117 +223,13 @@ TextEditorComponent = React.createClass
left = Math.max(0, Math.min(editor.getWidth() - width, left))
{top, left}
getCursorScreenRanges: (renderedRowRange) ->
{editor} = @props
[renderedStartRow, renderedEndRow] = renderedRowRange
cursorScreenRanges = {}
for selection in editor.getSelections() when selection.isEmpty()
{cursor} = selection
screenRange = cursor.getScreenRange()
if renderedStartRow <= screenRange.start.row < renderedEndRow
cursorScreenRanges[cursor.id] = screenRange
cursorScreenRanges
getCursorPixelRects: (renderedRowRange) ->
{editor} = @props
[renderedStartRow, renderedEndRow] = renderedRowRange
cursorPixelRects = {}
for selection in editor.getSelections() when selection.isEmpty()
{cursor} = selection
screenRange = cursor.getScreenRange()
if renderedStartRow <= screenRange.start.row < renderedEndRow
cursorPixelRects[cursor.id] = editor.pixelRectForScreenRange(screenRange)
cursorPixelRects
getLineDecorations: (decorationsByMarkerId) ->
{editor} = @props
return {} if editor.isMini()
decorationsByScreenRow = {}
for markerId, decorations of decorationsByMarkerId
marker = editor.getMarker(markerId)
screenRange = null
headScreenRow = null
if marker.isValid()
for decoration in decorations
if decoration.isType('line-number') or decoration.isType('line')
decorationParams = decoration.getProperties()
screenRange ?= marker.getScreenRange()
headScreenRow ?= marker.getHeadScreenPosition().row
startRow = screenRange.start.row
endRow = screenRange.end.row
endRow-- if not screenRange.isEmpty() and screenRange.end.column == 0
for screenRow in [startRow..endRow]
continue if decorationParams.onlyHead and screenRow isnt headScreenRow
if screenRange.isEmpty()
continue if decorationParams.onlyNonEmpty
else
continue if decorationParams.onlyEmpty
decorationsByScreenRow[screenRow] ?= {}
decorationsByScreenRow[screenRow][decoration.id] = decorationParams
decorationsByScreenRow
getHighlightDecorations: (decorationsByMarkerId) ->
{editor} = @props
filteredDecorations = {}
for markerId, decorations of decorationsByMarkerId
marker = editor.getMarker(markerId)
screenRange = marker.getScreenRange()
if marker.isValid() and not screenRange.isEmpty()
for decoration in decorations
if decoration.isType('highlight')
decorationParams = decoration.getProperties()
filteredDecorations[markerId] ?=
id: markerId
startPixelPosition: editor.pixelPositionForScreenPosition(screenRange.start, true)
endPixelPosition: editor.pixelPositionForScreenPosition(screenRange.end, true)
decorations: []
filteredDecorations[markerId].decorations.push decorationParams
filteredDecorations
getOverlayDecorations: (decorationsByMarkerId) ->
{editor} = @props
filteredDecorations = {}
for markerId, decorations of decorationsByMarkerId
marker = editor.getMarker(markerId)
headScreenPosition = marker.getHeadScreenPosition()
tailScreenPosition = marker.getTailScreenPosition()
if marker.isValid()
for decoration in decorations
if decoration.isType('overlay')
decorationParams = decoration.getProperties()
filteredDecorations[markerId] ?=
id: markerId
headPixelPosition: editor.pixelPositionForScreenPosition(headScreenPosition, true)
tailPixelPosition: editor.pixelPositionForScreenPosition(tailScreenPosition, true)
decorations: []
filteredDecorations[markerId].decorations.push decorationParams
filteredDecorations
observeEditor: ->
{editor} = @props
@subscribe editor.onDidChange(@onScreenLinesChanged)
@subscribe editor.onDidChangeGutterVisible(@updateGutterVisible)
@subscribe editor.onDidChangeMini(@setMini)
@subscribe editor.observeGrammar(@onGrammarChanged)
@subscribe editor.observeCursors(@onCursorAdded)
@subscribe editor.observeSelections(@onSelectionAdded)
@subscribe editor.observeDecorations(@onDecorationAdded)
@subscribe editor.onDidRemoveDecoration(@onDecorationRemoved)
@subscribe editor.onDidChangeCharacterWidths(@onCharacterWidthsChanged)
@subscribe editor.onDidChangePlaceholderText(@onPlaceholderTextChanged)
@subscribe editor.$scrollTop.changes, @onScrollTopChanged
@subscribe editor.$scrollLeft.changes, @requestUpdate
@subscribe editor.$verticalScrollbarWidth.changes, @requestUpdate
@subscribe editor.$horizontalScrollbarHeight.changes, @requestUpdate
@subscribe editor.$height.changes, @requestUpdate
@subscribe editor.$width.changes, @requestUpdate
@subscribe editor.$defaultCharWidth.changes, @requestUpdate
@subscribe editor.$lineHeightInPixels.changes, @requestUpdate
listenForDOMEvents: ->
node = @getDOMNode()
@@ -458,7 +300,7 @@ TextEditorComponent = React.createClass
scopeDescriptor = editor.getRootScopeDescriptor()
subscriptions.add atom.config.observe 'editor.showIndentGuide', scope: scopeDescriptor, @setShowIndentGuide
subscriptions.add atom.config.observe 'editor.showIndentGuide', scope: scopeDescriptor, @requestUpdate
subscriptions.add atom.config.observe 'editor.showLineNumbers', scope: scopeDescriptor, @updateGutterVisible
subscriptions.add atom.config.observe 'editor.scrollSensitivity', scope: scopeDescriptor, @setScrollSensitivity
@@ -505,7 +347,7 @@ TextEditorComponent = React.createClass
@requestAnimationFrame =>
pendingScrollTop = @pendingScrollTop
@pendingScrollTop = null
@props.editor.setScrollTop(pendingScrollTop)
@presenter.setScrollTop(pendingScrollTop)
onHorizontalScroll: (scrollLeft) ->
{editor} = @props
@@ -516,7 +358,7 @@ TextEditorComponent = React.createClass
@pendingScrollLeft = scrollLeft
unless animationFramePending
@requestAnimationFrame =>
@props.editor.setScrollLeft(@pendingScrollLeft)
@presenter.setScrollLeft(@pendingScrollLeft)
@pendingScrollLeft = null
onMouseWheel: (event) ->
@@ -537,15 +379,13 @@ TextEditorComponent = React.createClass
if Math.abs(wheelDeltaX) > Math.abs(wheelDeltaY)
# Scrolling horizontally
previousScrollLeft = editor.getScrollLeft()
editor.setScrollLeft(previousScrollLeft - Math.round(wheelDeltaX * @scrollSensitivity))
@presenter.setScrollLeft(previousScrollLeft - Math.round(wheelDeltaX * @scrollSensitivity))
event.preventDefault() unless previousScrollLeft is editor.getScrollLeft()
else
# Scrolling vertically
@mouseWheelScreenRow = @screenRowForNode(event.target)
@clearMouseWheelScreenRowAfterDelay ?= debounce(@clearMouseWheelScreenRow, @mouseWheelScreenRowClearDelay)
@clearMouseWheelScreenRowAfterDelay()
previousScrollTop = editor.getScrollTop()
editor.setScrollTop(previousScrollTop - Math.round(wheelDeltaY * @scrollSensitivity))
@presenter.setMouseWheelScreenRow(@screenRowForNode(event.target))
previousScrollTop = @presenter.scrollTop
@presenter.setScrollTop(previousScrollTop - Math.round(wheelDeltaY * @scrollSensitivity))
event.preventDefault() unless previousScrollTop is editor.getScrollTop()
onScrollViewScroll: ->
@@ -682,11 +522,6 @@ TextEditorComponent = React.createClass
@sampleBackgroundColors()
@remeasureCharacterWidths()
onScreenLinesChanged: (change) ->
{editor} = @props
@pendingChanges.push(change)
@requestUpdate() if editor.intersectsVisibleRowRange(change.start, change.end + 1) # TODO: Use closed-open intervals for change events
onSelectionAdded: (selection) ->
{editor} = @props
@@ -705,21 +540,6 @@ TextEditorComponent = React.createClass
@selectionChanged = true
@requestUpdate()
onScrollTopChanged: ->
@scrollingVertically = true
@requestUpdate()
@onStoppedScrollingAfterDelay ?= debounce(@onStoppedScrolling, 200)
@onStoppedScrollingAfterDelay()
onStoppedScrolling: ->
return unless @isMounted()
@scrollingVertically = false
@mouseWheelScreenRow = null
@requestUpdate()
onStoppedScrollingAfterDelay: null # created lazily
onCursorAdded: (cursor) ->
@subscribe cursor.onDidChangePosition @onCursorMoved
@@ -727,23 +547,6 @@ TextEditorComponent = React.createClass
@cursorMoved = true
@requestUpdate()
onDecorationAdded: (decoration) ->
@subscribe decoration.onDidChangeProperties(@onDecorationChanged)
@subscribe decoration.getMarker().onDidChange(@onDecorationChanged)
@requestUpdate()
onDecorationChanged: ->
@requestUpdate()
onDecorationRemoved: ->
@requestUpdate()
onCharacterWidthsChanged: (@scopedCharacterWidthsChangeCount) ->
@requestUpdate()
onPlaceholderTextChanged: ->
@requestUpdate()
handleDragUntilMouseUp: (event, dragHandler) ->
{editor} = @props
dragging = false
@@ -840,20 +643,19 @@ TextEditorComponent = React.createClass
{height} = hostElement.style
if position is 'absolute' or height
if @autoHeight
@autoHeight = false
@forceUpdate() if not @updatesPaused and @canUpdate()
clientHeight = scrollViewNode.clientHeight
editor.setHeight(clientHeight) if clientHeight > 0
@presenter.setAutoHeight(false)
height = hostElement.offsetHeight
if height > 0
@presenter.setExplicitHeight(height)
else
editor.setHeight(null)
@autoHeight = true
@presenter.setAutoHeight(true)
@presenter.setExplicitHeight(null)
clientWidth = scrollViewNode.clientWidth
paddingLeft = parseInt(getComputedStyle(scrollViewNode).paddingLeft)
clientWidth -= paddingLeft
editor.setWidth(clientWidth) if clientWidth > 0
if clientWidth > 0
@presenter.setContentFrameWidth(clientWidth)
sampleFontStyling: ->
oldFontSize = @fontSize
@@ -870,18 +672,13 @@ TextEditorComponent = React.createClass
sampleBackgroundColors: (suppressUpdate) ->
{hostElement} = @props
{showLineNumbers} = @state
{backgroundColor} = getComputedStyle(hostElement)
if backgroundColor isnt @backgroundColor
@backgroundColor = backgroundColor
@requestUpdate() unless suppressUpdate
@presenter.setBackgroundColor(backgroundColor)
if @refs.gutter?
gutterBackgroundColor = getComputedStyle(@refs.gutter.getDOMNode()).backgroundColor
if gutterBackgroundColor isnt @gutterBackgroundColor
@gutterBackgroundColor = gutterBackgroundColor
@requestUpdate() unless suppressUpdate
@presenter.setGutterBackgroundColor(gutterBackgroundColor)
measureLineHeightAndDefaultCharWidth: ->
if @isVisible()
@@ -909,8 +706,8 @@ TextEditorComponent = React.createClass
width = (cornerNode.offsetWidth - cornerNode.clientWidth) or 15
height = (cornerNode.offsetHeight - cornerNode.clientHeight) or 15
editor.setVerticalScrollbarWidth(width)
editor.setHorizontalScrollbarHeight(height)
@presenter.setVerticalScrollbarWidth(width)
@presenter.setHorizontalScrollbarHeight(height)
cornerNode.style.display = originalDisplayValue
@@ -955,13 +752,6 @@ TextEditorComponent = React.createClass
horizontalNode.style.display = originalHorizontalDisplayValue
cornerNode.style.display = originalCornerDisplayValue
clearMouseWheelScreenRow: ->
if @mouseWheelScreenRow?
@mouseWheelScreenRow = null
@requestUpdate()
clearMouseWheelScreenRowAfterDelay: null # created lazily
consolidateSelections: (e) ->
e.abortKeyBinding() unless @props.editor.consolidateSelections()
@@ -995,7 +785,7 @@ TextEditorComponent = React.createClass
@sampleFontStyling()
setShowIndentGuide: (showIndentGuide) ->
@setState({showIndentGuide})
atom.config.set("editor.showIndentGuide", showIndentGuide)
setMini: ->
@updateGutterVisible()
+831
Ver Arquivo
@@ -0,0 +1,831 @@
{CompositeDisposable, Emitter} = require 'event-kit'
{Point, Range} = require 'text-buffer'
_ = require 'underscore-plus'
module.exports =
class TextEditorPresenter
toggleCursorBlinkHandle: null
startBlinkingCursorsAfterDelay: null
stoppedScrollingTimeoutId: null
mouseWheelScreenRow: null
constructor: (params) ->
{@model, @autoHeight, @explicitHeight, @contentFrameWidth, @scrollTop, @scrollLeft} = params
{@horizontalScrollbarHeight, @verticalScrollbarWidth} = params
{@lineHeight, @baseCharacterWidth, @lineOverdrawMargin, @backgroundColor, @gutterBackgroundColor} = params
{@cursorBlinkPeriod, @cursorBlinkResumeDelay, @stoppedScrollingDelay} = params
@disposables = new CompositeDisposable
@emitter = new Emitter
@charWidthsByScope = {}
@transferMeasurementsToModel()
@observeModel()
@observeConfig()
@buildState()
@startBlinkingCursors()
destroy: ->
@disposables.dispose()
onDidUpdateState: (callback) ->
@emitter.on 'did-update-state', callback
transferMeasurementsToModel: ->
@model.setHeight(@explicitHeight) if @explicitHeight?
@model.setWidth(@contentFrameWidth) if @contentFrameWidth?
@model.setLineHeightInPixels(@lineHeight) if @lineHeight?
@model.setDefaultCharWidth(@baseCharacterWidth) if @baseCharacterWidth?
@model.setScrollTop(@scrollTop) if @scrollTop?
@model.setScrollLeft(@scrollLeft) if @scrollLeft?
@model.setVerticalScrollbarWidth(@verticalScrollbarWidth) if @verticalScrollbarWidth?
@model.setHorizontalScrollbarHeight(@horizontalScrollbarHeight) if @horizontalScrollbarHeight?
observeModel: ->
@disposables.add @model.onDidChange =>
@updateHeightState()
@updateVerticalScrollState()
@updateHorizontalScrollState()
@updateScrollbarsState()
@updateContentState()
@updateDecorations()
@updateLinesState()
@updateGutterState()
@updateLineNumbersState()
@disposables.add @model.onDidChangeGrammar(@updateContentState.bind(this))
@disposables.add @model.onDidChangePlaceholderText(@updateContentState.bind(this))
@disposables.add @model.onDidChangeMini =>
@updateContentState()
@updateDecorations()
@updateLinesState()
@updateLineNumbersState()
@disposables.add @model.onDidAddDecoration(@didAddDecoration.bind(this))
@disposables.add @model.onDidAddCursor(@didAddCursor.bind(this))
@disposables.add @model.onDidChangeScrollTop(@setScrollTop.bind(this))
@disposables.add @model.onDidChangeScrollLeft(@setScrollLeft.bind(this))
@observeDecoration(decoration) for decoration in @model.getDecorations()
@observeCursor(cursor) for cursor in @model.getCursors()
observeConfig: ->
@disposables.add atom.config.onDidChange 'editor.showIndentGuide', scope: @model.getRootScopeDescriptor(), @updateContentState.bind(this)
buildState: ->
@state =
horizontalScrollbar: {}
verticalScrollbar: {}
content:
scrollingVertically: false
blinkCursorsOff: false
lines: {}
highlights: {}
overlays: {}
gutter:
lineNumbers: {}
@updateState()
updateState: ->
@updateHeightState()
@updateVerticalScrollState()
@updateHorizontalScrollState()
@updateScrollbarsState()
@updateContentState()
@updateDecorations()
@updateLinesState()
@updateCursorsState()
@updateOverlaysState()
@updateGutterState()
@updateLineNumbersState()
updateHeightState: ->
if @autoHeight
@state.height = @computeContentHeight()
else
@state.height = null
@emitter.emit 'did-update-state'
updateVerticalScrollState: ->
scrollHeight = @computeScrollHeight()
@state.content.scrollHeight = scrollHeight
@state.gutter.scrollHeight = scrollHeight
@state.verticalScrollbar.scrollHeight = scrollHeight
scrollTop = @computeScrollTop()
@state.content.scrollTop = scrollTop
@state.gutter.scrollTop = scrollTop
@state.verticalScrollbar.scrollTop = scrollTop
@emitter.emit 'did-update-state'
updateHorizontalScrollState: ->
scrollWidth = @computeScrollWidth()
@state.content.scrollWidth = scrollWidth
@state.horizontalScrollbar.scrollWidth = scrollWidth
scrollLeft = @computeScrollLeft()
@state.content.scrollLeft = scrollLeft
@state.horizontalScrollbar.scrollLeft = scrollLeft
@emitter.emit 'did-update-state'
updateScrollbarsState: ->
horizontalScrollbarHeight = @computeHorizontalScrollbarHeight()
verticalScrollbarWidth = @computeVerticalScrollbarWidth()
@state.horizontalScrollbar.visible = horizontalScrollbarHeight > 0
@state.horizontalScrollbar.height = @horizontalScrollbarHeight
@state.horizontalScrollbar.right = verticalScrollbarWidth
@state.verticalScrollbar.visible = verticalScrollbarWidth > 0
@state.verticalScrollbar.width = @verticalScrollbarWidth
@state.verticalScrollbar.bottom = horizontalScrollbarHeight
@emitter.emit 'did-update-state'
updateContentState: ->
@state.content.scrollWidth = @computeScrollWidth()
@state.content.scrollLeft = @scrollLeft
@state.content.indentGuidesVisible = not @model.isMini() and atom.config.get('editor.showIndentGuide', scope: @model.getRootScopeDescriptor())
@state.content.backgroundColor = if @model.isMini() then null else @backgroundColor
@state.content.placeholderText = if @model.isEmpty() then @model.getPlaceholderText() else null
@emitter.emit 'did-update-state'
updateLinesState: ->
return unless @hasRequiredMeasurements()
visibleLineIds = {}
startRow = @computeStartRow()
endRow = @computeEndRow()
row = startRow
while row < endRow
line = @model.tokenizedLineForScreenRow(row)
visibleLineIds[line.id] = true
if @state.content.lines.hasOwnProperty(line.id)
@updateLineState(row, line)
else
@buildLineState(row, line)
row++
if @mouseWheelScreenRow?
preservedLine = @model.tokenizedLineForScreenRow(@mouseWheelScreenRow)
visibleLineIds[preservedLine.id] = true
for id, line of @state.content.lines
unless visibleLineIds.hasOwnProperty(id)
delete @state.content.lines[id]
@emitter.emit 'did-update-state'
updateLineState: (row, line) ->
lineState = @state.content.lines[line.id]
lineState.screenRow = row
lineState.top = row * @lineHeight
lineState.decorationClasses = @lineDecorationClassesForRow(row)
buildLineState: (row, line) ->
@state.content.lines[line.id] =
screenRow: row
text: line.text
tokens: line.tokens
isOnlyWhitespace: line.isOnlyWhitespace()
endOfLineInvisibles: line.endOfLineInvisibles
indentLevel: line.indentLevel
tabLength: line.tabLength
fold: line.fold
top: row * @lineHeight
decorationClasses: @lineDecorationClassesForRow(row)
updateCursorsState: ->
@state.content.cursors = {}
return unless @hasRequiredMeasurements()
startRow = @computeStartRow()
endRow = @computeEndRow()
for cursor in @model.getCursors()
if cursor.isVisible() and startRow <= cursor.getScreenRow() < endRow
pixelRect = @pixelRectForScreenRange(cursor.getScreenRange())
pixelRect.width = @baseCharacterWidth if pixelRect.width is 0
@state.content.cursors[cursor.id] = pixelRect
@emitter.emit 'did-update-state'
updateOverlaysState: ->
return unless @hasRequiredMeasurements()
visibleDecorationIds = {}
for decoration in @model.getOverlayDecorations()
continue unless decoration.getMarker().isValid()
{item, position} = decoration.getProperties()
if position is 'tail'
screenPosition = decoration.getMarker().getTailScreenPosition()
else
screenPosition = decoration.getMarker().getHeadScreenPosition()
@state.content.overlays[decoration.id] ?= {item}
@state.content.overlays[decoration.id].pixelPosition = @pixelPositionForScreenPosition(screenPosition)
visibleDecorationIds[decoration.id] = true
for id of @state.content.overlays
delete @state.content.overlays[id] unless visibleDecorationIds[id]
@emitter.emit "did-update-state"
updateGutterState: ->
@state.gutter.maxLineNumberDigits = @model.getLineCount().toString().length
@state.gutter.backgroundColor = if @gutterBackgroundColor isnt "rgba(0, 0, 0, 0)"
@gutterBackgroundColor
else
@backgroundColor
@emitter.emit "did-update-state"
updateLineNumbersState: ->
startRow = @computeStartRow()
endRow = @computeEndRow()
visibleLineNumberIds = {}
if startRow > 0
rowBeforeStartRow = startRow - 1
lastBufferRow = @model.bufferRowForScreenRow(rowBeforeStartRow)
wrapCount = rowBeforeStartRow - @model.screenRowForBufferRow(lastBufferRow)
else
lastBufferRow = null
wrapCount = 0
for bufferRow, i in @model.bufferRowsForScreenRows(startRow, endRow - 1)
if bufferRow is lastBufferRow
wrapCount++
id = bufferRow + '-' + wrapCount
softWrapped = true
else
id = bufferRow
wrapCount = 0
lastBufferRow = bufferRow
softWrapped = false
screenRow = startRow + i
top = screenRow * @lineHeight
decorationClasses = @lineNumberDecorationClassesForRow(screenRow)
foldable = @model.isFoldableAtScreenRow(screenRow)
@state.gutter.lineNumbers[id] = {screenRow, bufferRow, softWrapped, top, decorationClasses, foldable}
visibleLineNumberIds[id] = true
if @mouseWheelScreenRow?
bufferRow = @model.bufferRowForScreenRow(@mouseWheelScreenRow)
wrapCount = @mouseWheelScreenRow - @model.screenRowForBufferRow(bufferRow)
id = bufferRow
id += '-' + wrapCount if wrapCount > 0
visibleLineNumberIds[id] = true
for id of @state.gutter.lineNumbers
delete @state.gutter.lineNumbers[id] unless visibleLineNumberIds[id]
@emitter.emit 'did-update-state'
buildHighlightRegions: (screenRange) ->
lineHeightInPixels = @lineHeight
startPixelPosition = @pixelPositionForScreenPosition(screenRange.start, true)
endPixelPosition = @pixelPositionForScreenPosition(screenRange.end, true)
spannedRows = screenRange.end.row - screenRange.start.row + 1
if spannedRows is 1
[
top: startPixelPosition.top
height: lineHeightInPixels
left: startPixelPosition.left
width: endPixelPosition.left - startPixelPosition.left
]
else
regions = []
# First row, extending from selection start to the right side of screen
regions.push(
top: startPixelPosition.top
left: startPixelPosition.left
height: lineHeightInPixels
right: 0
)
# Middle rows, extending from left side to right side of screen
if spannedRows > 2
regions.push(
top: startPixelPosition.top + lineHeightInPixels
height: endPixelPosition.top - startPixelPosition.top - lineHeightInPixels
left: 0
right: 0
)
# Last row, extending from left side of screen to selection end
if screenRange.end.column > 0
regions.push(
top: endPixelPosition.top
height: lineHeightInPixels
left: 0
width: endPixelPosition.left
)
regions
computeStartRow: ->
startRow = Math.floor(@computeScrollTop() / @lineHeight) - @lineOverdrawMargin
Math.max(0, startRow)
computeEndRow: ->
startRow = Math.floor(@computeScrollTop() / @lineHeight)
visibleLinesCount = Math.ceil(@computeHeight() / @lineHeight) + 1
endRow = startRow + visibleLinesCount + @lineOverdrawMargin
Math.min(@model.getScreenLineCount(), endRow)
computeScrollWidth: ->
Math.max(@computeContentWidth(), @contentFrameWidth)
computeScrollHeight: ->
Math.max(@computeContentHeight(), @computeHeight())
computeContentWidth: ->
contentWidth = @pixelPositionForScreenPosition([@model.getLongestScreenRow(), Infinity]).left
contentWidth += 1 unless @model.isSoftWrapped() # account for cursor width
contentWidth
computeContentHeight: ->
@lineHeight * @model.getScreenLineCount()
computeClientHeight: ->
@computeHeight() - @computeHorizontalScrollbarHeight()
computeClientWidth: ->
@contentFrameWidth - @computeVerticalScrollbarWidth()
computeScrollTop: ->
@scrollTop = @constrainScrollTop(@scrollTop)
constrainScrollTop: (scrollTop) ->
if @hasRequiredMeasurements()
Math.max(0, Math.min(scrollTop, @computeScrollHeight() - @computeClientHeight()))
else
Math.max(0, scrollTop) if scrollTop?
computeScrollLeft: ->
@scrollLeft = @constrainScrollLeft(@scrollLeft)
constrainScrollLeft: (scrollLeft) ->
if @hasRequiredMeasurements()
Math.max(0, Math.min(scrollLeft, @computeScrollWidth() - @computeClientWidth()))
else
Math.max(0, scrollLeft) if scrollLeft?
computeHorizontalScrollbarHeight: ->
contentWidth = @computeContentWidth()
contentHeight = @computeContentHeight()
clientWidthWithoutVerticalScrollbar = @contentFrameWidth
clientWidthWithVerticalScrollbar = clientWidthWithoutVerticalScrollbar - @verticalScrollbarWidth
clientHeightWithoutHorizontalScrollbar = @computeHeight()
clientHeightWithHorizontalScrollbar = clientHeightWithoutHorizontalScrollbar - @horizontalScrollbarHeight
horizontalScrollbarVisible =
contentWidth > clientWidthWithoutVerticalScrollbar or
contentWidth > clientWidthWithVerticalScrollbar and contentHeight > clientHeightWithoutHorizontalScrollbar
if horizontalScrollbarVisible
@horizontalScrollbarHeight
else
0
computeVerticalScrollbarWidth: ->
contentWidth = @computeContentWidth()
contentHeight = @computeContentHeight()
clientWidthWithoutVerticalScrollbar = @contentFrameWidth
clientWidthWithVerticalScrollbar = clientWidthWithoutVerticalScrollbar - @verticalScrollbarWidth
clientHeightWithoutHorizontalScrollbar = @computeHeight()
clientHeightWithHorizontalScrollbar = clientHeightWithoutHorizontalScrollbar - @horizontalScrollbarHeight
verticalScrollbarVisible =
contentHeight > clientHeightWithoutHorizontalScrollbar or
contentHeight > clientHeightWithHorizontalScrollbar and contentWidth > clientWidthWithoutVerticalScrollbar
if verticalScrollbarVisible
@verticalScrollbarWidth
else
0
lineDecorationClassesForRow: (row) ->
return null if @model.isMini()
decorationClasses = null
for id, decoration of @lineDecorationsByScreenRow[row]
decorationClasses ?= []
decorationClasses.push(decoration.getProperties().class)
decorationClasses
lineNumberDecorationClassesForRow: (row) ->
return null if @model.isMini()
decorationClasses = null
for id, decoration of @lineNumberDecorationsByScreenRow[row]
decorationClasses ?= []
decorationClasses.push(decoration.getProperties().class)
decorationClasses
getCursorBlinkPeriod: -> @cursorBlinkPeriod
getCursorBlinkResumeDelay: -> @cursorBlinkResumeDelay
hasRequiredMeasurements: ->
@lineHeight? and
@baseCharacterWidth? and
@scrollTop? and
@contentFrameWidth? and
@scrollLeft? and
@verticalScrollbarWidth? and
@horizontalScrollbarHeight?
setScrollTop: (scrollTop) ->
scrollTop = @constrainScrollTop(scrollTop)
unless @scrollTop is scrollTop
@scrollTop = scrollTop
@model.setScrollTop(scrollTop)
@didStartScrolling()
@updateVerticalScrollState()
@updateDecorations()
@updateLinesState()
@updateCursorsState()
@updateLineNumbersState()
didStartScrolling: ->
if @stoppedScrollingTimeoutId?
clearTimeout(@stoppedScrollingTimeoutId)
@stoppedScrollingTimeoutId = null
@stoppedScrollingTimeoutId = setTimeout(@didStopScrolling.bind(this), @stoppedScrollingDelay)
@state.content.scrollingVertically = true
@emitter.emit 'did-update-state'
didStopScrolling: ->
@state.content.scrollingVertically = false
if @mouseWheelScreenRow?
@mouseWheelScreenRow = null
@updateLinesState()
@updateLineNumbersState()
else
@emitter.emit 'did-update-state'
setScrollLeft: (scrollLeft) ->
scrollLeft = @constrainScrollLeft(scrollLeft)
unless @scrollLeft is scrollLeft
@scrollLeft = scrollLeft
@model.setScrollLeft(scrollLeft)
@updateHorizontalScrollState()
setHorizontalScrollbarHeight: (horizontalScrollbarHeight) ->
unless @horizontalScrollbarHeight is horizontalScrollbarHeight
@horizontalScrollbarHeight = horizontalScrollbarHeight
@model.setHorizontalScrollbarHeight(horizontalScrollbarHeight)
@updateScrollbarsState()
@updateVerticalScrollState()
setVerticalScrollbarWidth: (verticalScrollbarWidth) ->
unless @verticalScrollbarWidth is verticalScrollbarWidth
@verticalScrollbarWidth = verticalScrollbarWidth
@model.setVerticalScrollbarWidth(verticalScrollbarWidth)
@updateScrollbarsState()
@updateHorizontalScrollState()
setAutoHeight: (autoHeight) ->
unless @autoHeight is autoHeight
@autoHeight = autoHeight
@updateHeightState()
setExplicitHeight: (explicitHeight) ->
unless @explicitHeight is explicitHeight
@explicitHeight = explicitHeight
@model.setHeight(explicitHeight)
@updateVerticalScrollState()
@updateScrollbarsState()
@updateDecorations()
@updateLinesState()
@updateCursorsState()
@updateLineNumbersState()
computeHeight: ->
@explicitHeight ? @computeContentHeight()
setContentFrameWidth: (contentFrameWidth) ->
unless @contentFrameWidth is contentFrameWidth
@contentFrameWidth = contentFrameWidth
@model.setWidth(contentFrameWidth)
@updateVerticalScrollState()
@updateHorizontalScrollState()
@updateScrollbarsState()
@updateContentState()
@updateDecorations()
@updateLinesState()
setBackgroundColor: (backgroundColor) ->
unless @backgroundColor is backgroundColor
@backgroundColor = backgroundColor
@updateContentState()
setGutterBackgroundColor: (gutterBackgroundColor) ->
unless @gutterBackgroundColor is gutterBackgroundColor
@gutterBackgroundColor = gutterBackgroundColor
@updateGutterState()
setLineHeight: (lineHeight) ->
unless @lineHeight is lineHeight
@lineHeight = lineHeight
@updateHeightState()
@updateVerticalScrollState()
@updateDecorations()
@updateLinesState()
@updateCursorsState()
@updateLineNumbersState()
@updateOverlaysState()
setMouseWheelScreenRow: (mouseWheelScreenRow) ->
unless @mouseWheelScreenRow is mouseWheelScreenRow
@mouseWheelScreenRow = mouseWheelScreenRow
@didStartScrolling()
setBaseCharacterWidth: (baseCharacterWidth) ->
unless @baseCharacterWidth is baseCharacterWidth
@baseCharacterWidth = baseCharacterWidth
@model.setDefaultCharWidth(baseCharacterWidth)
@characterWidthsChanged()
getScopedCharWidth: (scopeNames, char) ->
@getScopedCharWidths(scopeNames)[char]
getScopedCharWidths: (scopeNames) ->
scope = @charWidthsByScope
for scopeName in scopeNames
scope[scopeName] ?= {}
scope = scope[scopeName]
scope.charWidths ?= {}
scope.charWidths
batchCharacterMeasurement: (fn) ->
oldChangeCount = @scopedCharacterWidthsChangeCount
@batchingCharacterMeasurement = true
fn()
@batchingCharacterMeasurement = false
@characterWidthsChanged() if oldChangeCount isnt @scopedCharacterWidthsChangeCount
setScopedCharWidth: (scopeNames, char, width) ->
@getScopedCharWidths(scopeNames)[char] = width
@scopedCharacterWidthsChangeCount++
@characterWidthsChanged() unless @batchingCharacterMeasurement
characterWidthsChanged: ->
@updateHorizontalScrollState()
@updateContentState()
@updateDecorations()
@updateLinesState()
@updateCursorsState()
@updateOverlaysState()
clearScopedCharWidths: ->
@charWidthsByScope = {}
pixelPositionForScreenPosition: (screenPosition, clip=true) ->
screenPosition = Point.fromObject(screenPosition)
screenPosition = @model.clipScreenPosition(screenPosition) if clip
targetRow = screenPosition.row
targetColumn = screenPosition.column
baseCharacterWidth = @baseCharacterWidth
top = targetRow * @lineHeight
left = 0
column = 0
for token in @model.tokenizedLineForScreenRow(targetRow).tokens
charWidths = @getScopedCharWidths(token.scopes)
valueIndex = 0
while valueIndex < token.value.length
if token.hasPairedCharacter
char = token.value.substr(valueIndex, 2)
charLength = 2
valueIndex += 2
else
char = token.value[valueIndex]
charLength = 1
valueIndex++
return {top, left} if column is targetColumn
left += charWidths[char] ? baseCharacterWidth unless char is '\0'
column += charLength
{top, left}
pixelRectForScreenRange: (screenRange) ->
if screenRange.end.row > screenRange.start.row
top = @pixelPositionForScreenPosition(screenRange.start).top
left = 0
height = (screenRange.end.row - screenRange.start.row + 1) * @lineHeight
width = @computeScrollWidth()
else
{top, left} = @pixelPositionForScreenPosition(screenRange.start, false)
height = @lineHeight
width = @pixelPositionForScreenPosition(screenRange.end, false).left - left
{top, left, width, height}
observeDecoration: (decoration) ->
decorationDisposables = new CompositeDisposable
decorationDisposables.add decoration.getMarker().onDidChange(@decorationMarkerDidChange.bind(this, decoration))
if decoration.isType('highlight')
decorationDisposables.add decoration.onDidChangeProperties(@updateHighlightState.bind(this, decoration))
decorationDisposables.add decoration.onDidFlash(@highlightDidFlash.bind(this, decoration))
decorationDisposables.add decoration.onDidDestroy =>
@disposables.remove(decorationDisposables)
decorationDisposables.dispose()
@didDestroyDecoration(decoration)
@disposables.add(decorationDisposables)
decorationMarkerDidChange: (decoration, change) ->
if decoration.isType('line') or decoration.isType('line-number')
intersectsVisibleRowRange = false
startRow = @computeStartRow()
endRow = @computeEndRow()
oldRange = new Range(change.oldTailScreenPosition, change.oldHeadScreenPosition)
newRange = new Range(change.newTailScreenPosition, change.newHeadScreenPosition)
if oldRange.intersectsRowRange(startRow, endRow - 1)
@removeFromLineDecorationCaches(decoration, oldRange)
intersectsVisibleRowRange = true
if newRange.intersectsRowRange(startRow, endRow - 1)
@addToLineDecorationCaches(decoration, newRange)
intersectsVisibleRowRange = true
if intersectsVisibleRowRange
@updateLinesState() if decoration.isType('line')
@updateLineNumbersState() if decoration.isType('line-number')
if decoration.isType('highlight')
@updateHighlightState(decoration)
if decoration.isType('overlay')
@updateOverlaysState()
didDestroyDecoration: (decoration) ->
if decoration.isType('line') or decoration.isType('line-number')
@removeFromLineDecorationCaches(decoration, decoration.getMarker().getScreenRange())
@updateLinesState() if decoration.isType('line')
@updateLineNumbersState() if decoration.isType('line-number')
if decoration.isType('highlight')
@updateHighlightState(decoration)
if decoration.isType('overlay')
@updateOverlaysState()
highlightDidFlash: (decoration) ->
flash = decoration.consumeNextFlash()
if decorationState = @state.content.highlights[decoration.id]
decorationState.flashCount++
decorationState.flashClass = flash.class
decorationState.flashDuration = flash.duration
@emitter.emit "did-update-state"
didAddDecoration: (decoration) ->
@observeDecoration(decoration)
if decoration.isType('line') or decoration.isType('line-number')
@addToLineDecorationCaches(decoration, decoration.getMarker().getScreenRange())
@updateLinesState() if decoration.isType('line')
@updateLineNumbersState() if decoration.isType('line-number')
else if decoration.isType('highlight')
@updateHighlightState(decoration)
else if decoration.isType('overlay')
@updateOverlaysState()
updateDecorations: ->
@lineDecorationsByScreenRow = {}
@lineNumberDecorationsByScreenRow = {}
@highlightDecorationsById = {}
visibleHighlights = {}
startRow = @computeStartRow()
endRow = @computeEndRow()
return unless 0 <= startRow <= endRow <= Infinity
for markerId, decorations of @model.decorationsForScreenRowRange(startRow, endRow - 1)
range = @model.getMarker(markerId).getScreenRange()
for decoration in decorations
if decoration.isType('line') or decoration.isType('line-number')
@addToLineDecorationCaches(decoration, range)
else if decoration.isType('highlight')
visibleHighlights[decoration.id] = @updateHighlightState(decoration)
for id of @state.content.highlights
unless visibleHighlights[id]
delete @state.content.highlights[id]
@emitter.emit 'did-update-state'
removeFromLineDecorationCaches: (decoration, range) ->
for row in [range.start.row..range.end.row] by 1
delete @lineDecorationsByScreenRow[row]?[decoration.id]
delete @lineNumberDecorationsByScreenRow[row]?[decoration.id]
addToLineDecorationCaches: (decoration, range) ->
marker = decoration.getMarker()
properties = decoration.getProperties()
return unless marker.isValid()
if range.isEmpty()
return if properties.onlyNonEmpty
else
return if properties.onlyEmpty
omitLastRow = range.end.column is 0
for row in [range.start.row..range.end.row] by 1
continue if properties.onlyHead and row isnt marker.getHeadScreenPosition().row
continue if omitLastRow and row is range.end.row
if decoration.isType('line')
@lineDecorationsByScreenRow[row] ?= {}
@lineDecorationsByScreenRow[row][decoration.id] = decoration
if decoration.isType('line-number')
@lineNumberDecorationsByScreenRow[row] ?= {}
@lineNumberDecorationsByScreenRow[row][decoration.id] = decoration
updateHighlightState: (decoration) ->
return unless @hasRequiredMeasurements()
startRow = @computeStartRow()
endRow = @computeEndRow()
properties = decoration.getProperties()
marker = decoration.getMarker()
range = marker.getScreenRange()
if decoration.isDestroyed() or not marker.isValid() or range.isEmpty() or not range.intersectsRowRange(startRow, endRow - 1)
delete @state.content.highlights[decoration.id]
@emitter.emit 'did-update-state'
return
if range.start.row < startRow
range.start.row = startRow
range.start.column = 0
if range.end.row >= endRow
range.end.row = endRow
range.end.column = 0
if range.isEmpty()
delete @state.content.highlights[decoration.id]
@emitter.emit 'did-update-state'
return
highlightState = @state.content.highlights[decoration.id] ?= {
flashCount: 0
flashDuration: null
flashClass: null
}
highlightState.class = properties.class
highlightState.deprecatedRegionClass = properties.deprecatedRegionClass
highlightState.regions = @buildHighlightRegions(range)
@emitter.emit 'did-update-state'
true
observeCursor: (cursor) ->
didChangePositionDisposable = cursor.onDidChangePosition =>
@pauseCursorBlinking()
@updateCursorsState()
didChangeVisibilityDisposable = cursor.onDidChangeVisibility(@updateCursorsState.bind(this))
didDestroyDisposable = cursor.onDidDestroy =>
@disposables.remove(didChangePositionDisposable)
@disposables.remove(didChangeVisibilityDisposable)
@disposables.remove(didDestroyDisposable)
@updateCursorsState()
@disposables.add(didChangePositionDisposable)
@disposables.add(didChangeVisibilityDisposable)
@disposables.add(didDestroyDisposable)
didAddCursor: (cursor) ->
@observeCursor(cursor)
@pauseCursorBlinking()
@updateCursorsState()
startBlinkingCursors: ->
@toggleCursorBlinkHandle = setInterval(@toggleCursorBlink.bind(this), @getCursorBlinkPeriod() / 2)
stopBlinkingCursors: ->
clearInterval(@toggleCursorBlinkHandle)
toggleCursorBlink: ->
@state.content.blinkCursorsOff = not @state.content.blinkCursorsOff
@emitter.emit 'did-update-state'
pauseCursorBlinking: ->
@state.content.blinkCursorsOff = false
@stopBlinkingCursors()
@startBlinkingCursorsAfterDelay ?= _.debounce(@startBlinkingCursors, @getCursorBlinkResumeDelay())
@startBlinkingCursorsAfterDelay()
@emitter.emit 'did-update-state'
+1 -1
Ver Arquivo
@@ -283,7 +283,7 @@ class TextEditorView extends View
setShowIndentGuide: (showIndentGuide) ->
deprecate 'This is going away. Use atom.config.set("editor.showIndentGuide", true|false) instead'
@component.setShowIndentGuide(showIndentGuide)
atom.config.set("editor.showIndentGuide", showIndentGuide)
setSoftWrap: (softWrapped) ->
deprecate 'Use TextEditor::setSoftWrapped instead. You can get the editor via editorView.getModel()'
+11 -2
Ver Arquivo
@@ -717,9 +717,13 @@ class TextEditor extends Model
# {Delegates to: DisplayBuffer.bufferRowsForScreenRows}
bufferRowsForScreenRows: (startRow, endRow) -> @displayBuffer.bufferRowsForScreenRows(startRow, endRow)
screenRowForBufferRow: (row) -> @displayBuffer.screenRowForBufferRow(row)
# {Delegates to: DisplayBuffer.getMaxLineLength}
getMaxScreenLineLength: -> @displayBuffer.getMaxLineLength()
getLongestScreenRow: -> @displayBuffer.getLongestScreenRow()
# Returns the range for the given buffer row.
#
# * `row` A row {Number}.
@@ -1349,14 +1353,19 @@ class TextEditor extends Model
getLineDecorations: (propertyFilter) ->
@displayBuffer.getLineDecorations(propertyFilter)
# Soft-deprecated (forgot to deprecated this pre 1.0)
getGutterDecorations: (propertyFilter) ->
deprecate("Use ::getLineNumberDecorations instead")
@getLineNumberDecorations(propertyFilter)
# Extended: Get all decorations of type 'line-number'.
#
# * `propertyFilter` (optional) An {Object} containing key value pairs that
# the returned decorations' properties must match.
#
# Returns an {Array} of {Decoration}s.
getGutterDecorations: (propertyFilter) ->
@displayBuffer.getGutterDecorations(propertyFilter)
getLineNumberDecorations: (propertyFilter) ->
@displayBuffer.getLineNumberDecorations(propertyFilter)
# Extended: Get all decorations of type 'highlight'.
#
+6 -1
Ver Arquivo
@@ -266,7 +266,11 @@ class ThemeManager
"""
atom.notifications.addError(message, dismissable: true)
userStylesheetContents = @loadStylesheet(userStylesheetPath, true)
try
userStylesheetContents = @loadStylesheet(userStylesheetPath, true)
catch
return
@userStyleSheetDisposable = atom.styles.addStyleSheet(userStylesheetContents, sourcePath: userStylesheetPath, priority: 2)
loadBaseStylesheets: ->
@@ -320,6 +324,7 @@ class ThemeManager
detail = error.message
atom.notifications.addError(message, {detail, dismissable: true})
throw error
removeStylesheet: (stylesheetPath) ->
@styleSheetDisposablesBySourcePath[stylesheetPath]?.dispose()
+3 -7
Ver Arquivo
@@ -9,6 +9,7 @@ idCounter = 1
module.exports =
class TokenizedLine
endOfLineInvisibles: null
lineIsWhitespaceOnly: false
constructor: ({tokens, @lineEnding, @ruleStack, @startBufferColumn, @fold, @tabLength, @indentLevel, @invisibles}) ->
@startBufferColumn ?= 0
@@ -146,7 +147,7 @@ class TokenizedLine
markLeadingAndTrailingWhitespaceTokens: ->
firstNonWhitespaceIndex = @text.search(NonWhitespaceRegex)
firstTrailingWhitespaceIndex = @text.search(TrailingWhitespaceRegex)
lineIsWhitespaceOnly = firstTrailingWhitespaceIndex is 0
@lineIsWhitespaceOnly = firstTrailingWhitespaceIndex is 0
index = 0
for token in @tokens
if index < firstNonWhitespaceIndex
@@ -202,12 +203,7 @@ class TokenizedLine
false
isOnlyWhitespace: ->
if @text == ''
true
else
for token in @tokens
return false unless token.isOnlyWhitespace()
true
@lineIsWhitespaceOnly
tokenAtIndex: (index) ->
@tokens[index]
+2 -1
Ver Arquivo
@@ -1,3 +1,4 @@
{find} = require 'underscore-plus'
Grim = require 'grim'
{Disposable} = require 'event-kit'
@@ -148,4 +149,4 @@ class ViewRegistry
throw new Error("Can't create a view for #{object.constructor.name} instance. Please register a view provider.")
findProvider: (object) ->
@providers.find ({modelConstructor}) -> object instanceof modelConstructor
find @providers, ({modelConstructor}) -> object instanceof modelConstructor
+2 -2
Ver Arquivo
@@ -31,8 +31,8 @@ class WindowEventHandler
atom.updateAvailable(detail)
# FIXME: Remove this when deprecations are removed
{releaseVersion, releaseNotes} = detail
detail = [releaseVersion, releaseNotes]
{releaseVersion} = detail
detail = [releaseVersion]
if workspaceElement = atom.views.getView(atom.workspace)
atom.commands.dispatch workspaceElement, "window:update-available", detail
+10 -2
Ver Arquivo
@@ -1,3 +1,11 @@
function registerRuntimeTranspilers() {
// This sets require.extensions['.coffee'].
require('coffee-script').register();
// This redefines require.extensions['.js'].
require('../src/6to5').register();
}
window.onload = function() {
try {
var startTime = Date.now();
@@ -22,7 +30,7 @@ window.onload = function() {
// Require before the module cache in dev mode
if (devMode) {
require('coffee-script').register();
registerRuntimeTranspilers();
}
ModuleCache = require('../src/module-cache');
@@ -41,7 +49,7 @@ window.onload = function() {
require('vm-compatibility-layer');
if (!devMode) {
require('coffee-script').register();
registerRuntimeTranspilers();
}
require('../src/coffee-cache').register();