mirror of
https://github.com/atom/atom.git
synced 2026-02-16 17:45:24 -05:00
Parameterize view registry on TextEditor
This commit is contained in:
@@ -77,6 +77,7 @@ class TextEditor extends Model
|
||||
state.config = atomEnvironment.config
|
||||
state.notificationManager = atomEnvironment.notifications
|
||||
state.clipboard = atomEnvironment.clipboard
|
||||
state.viewRegistry = atomEnvironment.views
|
||||
new this(state)
|
||||
|
||||
constructor: (params={}) ->
|
||||
@@ -85,7 +86,8 @@ class TextEditor extends Model
|
||||
{
|
||||
@softTabs, @scrollRow, @scrollColumn, initialLine, initialColumn, tabLength,
|
||||
softWrapped, @displayBuffer, buffer, suppressCursorCreation, @mini, @placeholderText,
|
||||
lineNumberGutterVisible, largeFileMode, @config, @notificationManager, @clipboard
|
||||
lineNumberGutterVisible, largeFileMode, @config, @notificationManager, @clipboard,
|
||||
@viewRegistry
|
||||
} = params
|
||||
|
||||
@emitter = new Emitter
|
||||
@@ -432,12 +434,12 @@ class TextEditor extends Model
|
||||
onDidChangeScrollTop: (callback) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::onDidChangeScrollTop instead.")
|
||||
|
||||
atom.views.getView(this).onDidChangeScrollTop(callback)
|
||||
@viewRegistry.getView(this).onDidChangeScrollTop(callback)
|
||||
|
||||
onDidChangeScrollLeft: (callback) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::onDidChangeScrollLeft instead.")
|
||||
|
||||
atom.views.getView(this).onDidChangeScrollLeft(callback)
|
||||
@viewRegistry.getView(this).onDidChangeScrollLeft(callback)
|
||||
|
||||
onDidRequestAutoscroll: (callback) ->
|
||||
@displayBuffer.onDidRequestAutoscroll(callback)
|
||||
@@ -461,7 +463,7 @@ class TextEditor extends Model
|
||||
softTabs = @getSoftTabs()
|
||||
newEditor = new TextEditor({
|
||||
@buffer, displayBuffer, @tabLength, softTabs, suppressCursorCreation: true,
|
||||
@config, @notificationManager, @clipboard
|
||||
@config, @notificationManager, @clipboard, @viewRegistry
|
||||
})
|
||||
for marker in @findMarkers(editorId: @id)
|
||||
marker.copy(editorId: newEditor.id, preserveFolds: true)
|
||||
@@ -2872,24 +2874,24 @@ class TextEditor extends Model
|
||||
scrollToTop: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::scrollToTop instead.")
|
||||
|
||||
atom.views.getView(this).scrollToTop()
|
||||
@viewRegistry.getView(this).scrollToTop()
|
||||
|
||||
scrollToBottom: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::scrollToTop instead.")
|
||||
|
||||
atom.views.getView(this).scrollToBottom()
|
||||
@viewRegistry.getView(this).scrollToBottom()
|
||||
|
||||
scrollToScreenRange: (screenRange, options) -> @displayBuffer.scrollToScreenRange(screenRange, options)
|
||||
|
||||
getHorizontalScrollbarHeight: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getHorizontalScrollbarHeight instead.")
|
||||
|
||||
atom.views.getView(this).getHorizontalScrollbarHeight()
|
||||
@viewRegistry.getView(this).getHorizontalScrollbarHeight()
|
||||
|
||||
getVerticalScrollbarWidth: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getVerticalScrollbarWidth instead.")
|
||||
|
||||
atom.views.getView(this).getVerticalScrollbarWidth()
|
||||
@viewRegistry.getView(this).getVerticalScrollbarWidth()
|
||||
|
||||
pageUp: ->
|
||||
@moveUp(@getRowsPerPage())
|
||||
@@ -2956,19 +2958,19 @@ class TextEditor extends Model
|
||||
|
||||
getFirstVisibleScreenRow: ->
|
||||
deprecate("This is now a view method. Call TextEditorElement::getFirstVisibleScreenRow instead.")
|
||||
atom.views.getView(this).getVisibleRowRange()[0]
|
||||
@viewRegistry.getView(this).getVisibleRowRange()[0]
|
||||
|
||||
getLastVisibleScreenRow: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getLastVisibleScreenRow instead.")
|
||||
atom.views.getView(this).getVisibleRowRange()[1]
|
||||
@viewRegistry.getView(this).getVisibleRowRange()[1]
|
||||
|
||||
pixelPositionForBufferPosition: (bufferPosition) ->
|
||||
Grim.deprecate("This method is deprecated on the model layer. Use `TextEditorElement::pixelPositionForBufferPosition` instead")
|
||||
atom.views.getView(this).pixelPositionForBufferPosition(bufferPosition)
|
||||
@viewRegistry.getView(this).pixelPositionForBufferPosition(bufferPosition)
|
||||
|
||||
pixelPositionForScreenPosition: (screenPosition) ->
|
||||
Grim.deprecate("This method is deprecated on the model layer. Use `TextEditorElement::pixelPositionForScreenPosition` instead")
|
||||
atom.views.getView(this).pixelPositionForScreenPosition(screenPosition)
|
||||
@viewRegistry.getView(this).pixelPositionForScreenPosition(screenPosition)
|
||||
|
||||
getSelectionMarkerAttributes: ->
|
||||
{type: 'selection', editorId: @id, invalidate: 'never', maintainHistory: true}
|
||||
@@ -2999,7 +3001,7 @@ class TextEditor extends Model
|
||||
@displayBuffer.setHeight(height)
|
||||
else
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::setHeight instead.")
|
||||
atom.views.getView(this).setHeight(height)
|
||||
@viewRegistry.getView(this).setHeight(height)
|
||||
|
||||
getHeight: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getHeight instead.")
|
||||
@@ -3012,7 +3014,7 @@ class TextEditor extends Model
|
||||
@displayBuffer.setWidth(width)
|
||||
else
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::setWidth instead.")
|
||||
atom.views.getView(this).setWidth(width)
|
||||
@viewRegistry.getView(this).setWidth(width)
|
||||
|
||||
getWidth: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getWidth instead.")
|
||||
@@ -3027,77 +3029,77 @@ class TextEditor extends Model
|
||||
getScrollTop: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollTop instead.")
|
||||
|
||||
atom.views.getView(this).getScrollTop()
|
||||
@viewRegistry.getView(this).getScrollTop()
|
||||
|
||||
setScrollTop: (scrollTop) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollTop instead.")
|
||||
|
||||
atom.views.getView(this).setScrollTop(scrollTop)
|
||||
@viewRegistry.getView(this).setScrollTop(scrollTop)
|
||||
|
||||
getScrollBottom: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollBottom instead.")
|
||||
|
||||
atom.views.getView(this).getScrollBottom()
|
||||
@viewRegistry.getView(this).getScrollBottom()
|
||||
|
||||
setScrollBottom: (scrollBottom) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollBottom instead.")
|
||||
|
||||
atom.views.getView(this).setScrollBottom(scrollBottom)
|
||||
@viewRegistry.getView(this).setScrollBottom(scrollBottom)
|
||||
|
||||
getScrollLeft: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollLeft instead.")
|
||||
|
||||
atom.views.getView(this).getScrollLeft()
|
||||
@viewRegistry.getView(this).getScrollLeft()
|
||||
|
||||
setScrollLeft: (scrollLeft) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollLeft instead.")
|
||||
|
||||
atom.views.getView(this).setScrollLeft(scrollLeft)
|
||||
@viewRegistry.getView(this).setScrollLeft(scrollLeft)
|
||||
|
||||
getScrollRight: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollRight instead.")
|
||||
|
||||
atom.views.getView(this).getScrollRight()
|
||||
@viewRegistry.getView(this).getScrollRight()
|
||||
|
||||
setScrollRight: (scrollRight) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollRight instead.")
|
||||
|
||||
atom.views.getView(this).setScrollRight(scrollRight)
|
||||
@viewRegistry.getView(this).setScrollRight(scrollRight)
|
||||
|
||||
getScrollHeight: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollHeight instead.")
|
||||
|
||||
atom.views.getView(this).getScrollHeight()
|
||||
@viewRegistry.getView(this).getScrollHeight()
|
||||
|
||||
getScrollWidth: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollWidth instead.")
|
||||
|
||||
atom.views.getView(this).getScrollWidth()
|
||||
@viewRegistry.getView(this).getScrollWidth()
|
||||
|
||||
getVisibleRowRange: ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::getVisibleRowRange instead.")
|
||||
|
||||
atom.views.getView(this).getVisibleRowRange()
|
||||
@viewRegistry.getView(this).getVisibleRowRange()
|
||||
|
||||
intersectsVisibleRowRange: (startRow, endRow) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::intersectsVisibleRowRange instead.")
|
||||
|
||||
atom.views.getView(this).intersectsVisibleRowRange(startRow, endRow)
|
||||
@viewRegistry.getView(this).intersectsVisibleRowRange(startRow, endRow)
|
||||
|
||||
selectionIntersectsVisibleRowRange: (selection) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::selectionIntersectsVisibleRowRange instead.")
|
||||
|
||||
atom.views.getView(this).selectionIntersectsVisibleRowRange(selection)
|
||||
@viewRegistry.getView(this).selectionIntersectsVisibleRowRange(selection)
|
||||
|
||||
screenPositionForPixelPosition: (pixelPosition) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::screenPositionForPixelPosition instead.")
|
||||
|
||||
atom.views.getView(this).screenPositionForPixelPosition(pixelPosition)
|
||||
@viewRegistry.getView(this).screenPositionForPixelPosition(pixelPosition)
|
||||
|
||||
pixelRectForScreenRange: (screenRange) ->
|
||||
Grim.deprecate("This is now a view method. Call TextEditorElement::pixelRectForScreenRange instead.")
|
||||
|
||||
atom.views.getView(this).pixelRectForScreenRange(screenRange)
|
||||
@viewRegistry.getView(this).pixelRectForScreenRange(screenRange)
|
||||
|
||||
###
|
||||
Section: Utility
|
||||
|
||||
Reference in New Issue
Block a user