mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
Add ::state.content.scrollTop/Left to TextEditorPresenter
This commit is contained in:
parent
78d87d8f7c
commit
f479e9d029
@ -82,6 +82,20 @@ describe "TextEditorPresenter", ->
|
||||
editor.getBuffer().append("\n\n\n")
|
||||
expect(presenter.state.content.scrollHeight).toBe editor.getScreenLineCount() * 10
|
||||
|
||||
describe ".scrollTop", ->
|
||||
it "tracks the value of ::scrollTop", ->
|
||||
presenter = new TextEditorPresenter(model: editor, scrollTop: 10, lineHeight: 10, lineOverdrawMargin: 1)
|
||||
expect(presenter.state.content.scrollTop).toBe 10
|
||||
presenter.setScrollTop(50)
|
||||
expect(presenter.state.content.scrollTop).toBe 50
|
||||
|
||||
describe ".scrollLeft", ->
|
||||
it "tracks the value of ::scrollLeft", ->
|
||||
presenter = new TextEditorPresenter(model: editor, scrollLeft: 10, lineHeight: 10, lineOverdrawMargin: 1)
|
||||
expect(presenter.state.content.scrollLeft).toBe 10
|
||||
presenter.setScrollLeft(50)
|
||||
expect(presenter.state.content.scrollLeft).toBe 50
|
||||
|
||||
describe ".indentGuidesVisible", ->
|
||||
it "is initialized based on the editor.showIndentGuide config setting", ->
|
||||
presenter = new TextEditorPresenter(model: editor)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
module.exports =
|
||||
class TextEditorPresenter
|
||||
constructor: ({@model, @clientHeight, @clientWidth, @scrollTop, @lineHeight, @baseCharacterWidth, @lineOverdrawMargin}) ->
|
||||
constructor: ({@model, @clientHeight, @clientWidth, @scrollTop, @scrollLeft, @lineHeight, @baseCharacterWidth, @lineOverdrawMargin}) ->
|
||||
@disposables = new CompositeDisposable
|
||||
@charWidthsByScope = {}
|
||||
@observeModel()
|
||||
@ -44,6 +44,8 @@ class TextEditorPresenter
|
||||
updateContentState: ->
|
||||
@state.content.scrollWidth = @computeScrollWidth()
|
||||
@state.content.scrollHeight = @computeScrollHeight()
|
||||
@state.content.scrollTop = @getScrollTop()
|
||||
@state.content.scrollLeft = @getScrollLeft()
|
||||
@state.content.indentGuidesVisible = atom.config.get('editor.showIndentGuide', scope: @model.getRootScopeDescriptor())
|
||||
|
||||
updateLinesState: ->
|
||||
@ -122,10 +124,16 @@ class TextEditorPresenter
|
||||
decorationClasses
|
||||
|
||||
setScrollTop: (@scrollTop) ->
|
||||
@updateContentState()
|
||||
@updateLinesState()
|
||||
|
||||
getScrollTop: -> @scrollTop
|
||||
|
||||
setScrollLeft: (@scrollLeft) ->
|
||||
@updateContentState()
|
||||
|
||||
getScrollLeft: -> @scrollLeft
|
||||
|
||||
setClientHeight: (@clientHeight) ->
|
||||
@updateLinesState()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user