[Gutter] Add add/get Gutter methods to TextEditor

This commit is contained in:
Jess Lin
2015-02-01 17:58:54 -08:00
parent fccc9ebee4
commit 20d3c07bf5
2 changed files with 25 additions and 0 deletions

View File

@@ -4242,3 +4242,14 @@ describe "TextEditor", ->
editor.checkoutHeadRevision()
waitsForPromise -> editor.checkoutHeadRevision()
describe 'gutters', ->
describe '::addGutter', ->
it 'can add a gutter', ->
expect(editor.getGutters().length).toBe 0
options =
name: 'test-gutter'
priority: 1
gutter = editor.addGutter options
expect(editor.getGutters().length).toBe 1
expect(editor.getGutters()[0]).toBe gutter

View File

@@ -12,6 +12,7 @@ Model = require './model'
Selection = require './selection'
TextMateScopeSelector = require('first-mate').ScopeSelector
{Directory} = require "pathwatcher"
GutterContainer = require './gutter-container'
# Public: This class represents all essential editing state for a single
# {TextBuffer}, including cursor and selection positions, folds, and soft wraps.
@@ -68,6 +69,7 @@ class TextEditor extends Model
suppressSelectionMerging: false
updateBatchDepth: 0
selectionFlashDuration: 500
gutterContainer: null
@delegatesMethods 'suggestedIndentForBufferRow', 'autoIndentBufferRow', 'autoIndentBufferRows',
'autoDecreaseIndentForBufferRow', 'toggleLineCommentForBufferRow', 'toggleLineCommentsForBufferRows',
@@ -112,6 +114,8 @@ class TextEditor extends Model
@emit 'scroll-left-changed', scrollLeft if includeDeprecatedAPIs
@emitter.emit 'did-change-scroll-left', scrollLeft
@gutterContainer = new GutterContainer
atom.workspace?.editorAdded(this) if registerEditor
serializeParams: ->
@@ -181,6 +185,7 @@ class TextEditor extends Model
@buffer.release()
@displayBuffer.destroy()
@languageMode.destroy()
@gutterContainer.destroy()
@emitter.emit 'did-destroy'
###
@@ -499,6 +504,15 @@ class TextEditor extends Model
onDidChangeLineNumberGutterVisible: (callback) ->
@emitter.on 'did-change-line-number-gutter-visible', callback
# Public: Creates and returns a {Gutter}.
# See {GutterContainer::addGutter} for more details.
addGutter: (options) ->
@gutterContainer.addGutter options
# Public: Returns the {Array} of all gutters on this editor.
getGutters: ->
@gutterContainer.getGutters()
# Set the number of characters that can be displayed horizontally in the
# editor.
#