[Gutter][View Registry] Add Gutter view providers to the ViewRegistry

This commit is contained in:
Jess Lin 2015-03-31 14:29:16 -07:00
parent f3d2597bda
commit 6319c9722a
2 changed files with 15 additions and 0 deletions

View File

@ -1,6 +1,18 @@
# Helper methods shared among GutterComponent classes.
module.exports =
createGutterView: (gutterModel) ->
domNode = document.createElement('div')
domNode.classList.add('gutter')
domNode.setAttribute('gutter-name', gutterModel.name)
childNode = document.createElement('div')
if gutterModel.name is 'line-number'
childNode.classList.add('line-numbers')
else
childNode.classList.add('custom-decorations')
domNode.appendChild(childNode)
domNode
# Sets scrollHeight, scrollTop, and backgroundColor on the given domNode.
setDimensionsAndBackground: (oldState, newState, domNode) ->
if newState.scrollHeight isnt oldState.scrollHeight

View File

@ -2,6 +2,8 @@
Grim = require 'grim'
{Emitter, CompositeDisposable} = require 'event-kit'
Serializable = require 'serializable'
{createGutterView} = require './gutter-component-helpers'
Gutter = require './gutter'
Model = require './model'
Pane = require './pane'
PaneElement = require './pane-element'
@ -60,6 +62,7 @@ class PaneContainer extends Model
new PaneElement().initialize(model)
atom.views.addViewProvider TextEditor, (model) ->
new TextEditorElement().initialize(model)
atom.views.addViewProvider(Gutter, createGutterView)
onDidChangeRoot: (fn) ->
@emitter.on 'did-change-root', fn