Add ignoreScrollPastEnd

This commit is contained in:
joshaber
2016-02-25 16:59:58 -05:00
parent 1b6325494d
commit ff0b9e30a9
4 changed files with 13 additions and 9 deletions

View File

@@ -43,7 +43,7 @@ class TextEditorComponent
@assert domNode?, "TextEditorComponent::domNode was set to null."
@domNodeValue = domNode
constructor: ({@editor, @hostElement, @rootElement, @stylesElement, @useShadowDOM, tileSize, @views, @themes, @config, @workspace, @assert, @grammars}) ->
constructor: ({@editor, @hostElement, @rootElement, @stylesElement, @useShadowDOM, tileSize, @views, @themes, @config, @workspace, @assert, @grammars, ignoreScrollPastEnd}) ->
@tileSize = tileSize if tileSize?
@disposables = new CompositeDisposable
@@ -61,6 +61,7 @@ class TextEditorComponent
stoppedScrollingDelay: 200
config: @config
lineTopIndex: lineTopIndex
ignoreScrollPastEnd: ignoreScrollPastEnd
@presenter.onDidUpdateState(@requestUpdate)

View File

@@ -17,6 +17,7 @@ class TextEditorElement extends HTMLElement
focusOnAttach: false
hasTiledRendering: true
logicalDisplayBuffer: true
ignoreScrollPastEnd: false
createdCallback: ->
# Use globals when the following instance variables aren't set.
@@ -86,7 +87,7 @@ class TextEditorElement extends HTMLElement
@subscriptions.add @component.onDidChangeScrollLeft =>
@emitter.emit("did-change-scroll-left", arguments...)
initialize: (model, {@views, @config, @themes, @workspace, @assert, @styles, @grammars}) ->
initialize: (model, {@views, @config, @themes, @workspace, @assert, @styles, @grammars}, @ignoreScrollPastEnd = false) ->
throw new Error("Must pass a config parameter when initializing TextEditorElements") unless @views?
throw new Error("Must pass a config parameter when initializing TextEditorElements") unless @config?
throw new Error("Must pass a themes parameter when initializing TextEditorElements") unless @themes?
@@ -143,6 +144,7 @@ class TextEditorElement extends HTMLElement
workspace: @workspace
assert: @assert
grammars: @grammars
ignoreScrollPastEnd: @ignoreScrollPastEnd
)
@rootElement.appendChild(@component.getDomNode())

View File

@@ -13,7 +13,7 @@ class TextEditorPresenter
minimumReflowInterval: 200
constructor: (params) ->
{@model, @config, @lineTopIndex} = params
{@model, @config, @lineTopIndex, @ignoreScrollPastEnd} = params
{@cursorBlinkPeriod, @cursorBlinkResumeDelay, @stoppedScrollingDelay, @tileSize} = params
{@contentFrameWidth} = params
@@ -661,7 +661,7 @@ class TextEditorPresenter
return unless @contentHeight? and @clientHeight?
contentHeight = @contentHeight
if @scrollPastEnd
if @scrollPastEnd and not @ignoreScrollPastEnd
extraScrollHeight = @clientHeight - (@lineHeight * 3)
contentHeight += extraScrollHeight if extraScrollHeight > 0
scrollHeight = Math.max(contentHeight, @height)

View File

@@ -97,7 +97,7 @@ class TextEditor extends Model
softWrapped, @displayBuffer, @selectionsMarkerLayer, buffer, suppressCursorCreation,
@mini, @placeholderText, lineNumberGutterVisible, largeFileMode, @config,
@notificationManager, @packageManager, @clipboard, @viewRegistry, @grammarRegistry,
@project, @assert, @applicationDelegate, @pending, grammarName, ignoreInvisibles, @autoHeight
@project, @assert, @applicationDelegate, @pending, grammarName, ignoreInvisibles, @autoHeight, @ignoreScrollPastEnd
} = params
throw new Error("Must pass a config parameter when constructing TextEditors") unless @config?
@@ -117,6 +117,7 @@ class TextEditor extends Model
@cursorsByMarkerId = new Map
@selections = []
@autoHeight ?= true
@ignoreScrollPastEnd ?= false
buffer ?= new TextBuffer
@displayBuffer ?= new DisplayBuffer({
@@ -3153,9 +3154,9 @@ class TextEditor extends Model
# Get the Element for the editor.
getElement: ->
if not @editorElement?
@editorElement = new TextEditorElement().initialize(this, atom)
if not @autoHeight
unless @editorElement?
@editorElement = new TextEditorElement().initialize(this, atom, @ignoreScrollPastEnd)
unless @autoHeight
@editorElement.disableAutoHeight()
@editorElement
@@ -3233,7 +3234,7 @@ class TextEditor extends Model
setFirstVisibleScreenRow: (screenRow, fromView) ->
unless fromView
maxScreenRow = @getScreenLineCount() - 1
unless @config.get('editor.scrollPastEnd')
unless @config.get('editor.scrollPastEnd') and not @ignoreScrollPastEnd
height = @displayBuffer.getHeight()
lineHeightInPixels = @displayBuffer.getLineHeightInPixels()
if height? and lineHeightInPixels?