mirror of
https://github.com/atom/atom.git
synced 2026-02-15 09:05:58 -05:00
[Gutter] Add decorateMarker method to Gutter model
This commit is contained in:
@@ -7,8 +7,11 @@ Gutter = require './gutter'
|
||||
module.exports =
|
||||
class GutterContainer
|
||||
Subscriber.includeInto(this)
|
||||
constructor: ->
|
||||
|
||||
# * `textEditor` The {TextEditor} to which this {GutterContainer} belongs.
|
||||
constructor: (textEditor) ->
|
||||
@gutters = []
|
||||
@textEditor = textEditor
|
||||
@emitter = new Emitter
|
||||
|
||||
destroy: ->
|
||||
@@ -76,3 +79,12 @@ class GutterContainer
|
||||
else
|
||||
throw new Error 'The given gutter cannot be removed because it is not ' +
|
||||
'within this GutterContainer.'
|
||||
|
||||
# The public interface is Gutter::decorateMarker or TextEditor::decorateMarker.
|
||||
addGutterDecoration: (gutter, marker, options) ->
|
||||
if gutter.name is 'line-number'
|
||||
options.type = 'line-number'
|
||||
else
|
||||
options.type = 'gutter'
|
||||
options.gutterName = gutter.name
|
||||
@textEditor.decorateMarker marker, options
|
||||
|
||||
@@ -43,6 +43,14 @@ class Gutter
|
||||
isVisible: ->
|
||||
@visible
|
||||
|
||||
# * `marker` (required) A Marker object.
|
||||
# * `options` (optional) An object with the following fields:
|
||||
# * `class` (optional)
|
||||
# * `item` (optional) A model {Object} with a corresponding view registered,
|
||||
# or an {HTMLElement}.
|
||||
decorateMarker: (marker, options) ->
|
||||
@gutterContainer.addGutterDecoration this, marker, options
|
||||
|
||||
# Calls your `callback` when the {Gutter}'s' visibility changes.
|
||||
#
|
||||
# * `callback` {Function}
|
||||
|
||||
@@ -114,7 +114,7 @@ class TextEditor extends Model
|
||||
@emit 'scroll-left-changed', scrollLeft if includeDeprecatedAPIs
|
||||
@emitter.emit 'did-change-scroll-left', scrollLeft
|
||||
|
||||
@gutterContainer = new GutterContainer
|
||||
@gutterContainer = new GutterContainer this
|
||||
@lineNumberGutter = @gutterContainer.addGutter
|
||||
name: 'line-number'
|
||||
priority: 0
|
||||
|
||||
Reference in New Issue
Block a user