mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add a nonfunctional gutter to editor layout.
This commit is contained in:
@@ -5,7 +5,7 @@ _ = require 'underscore'
|
||||
module.exports =
|
||||
class Cursor extends View
|
||||
@content: ->
|
||||
@pre class: 'cursor idle', style: 'position: absolute;', => @raw ' '
|
||||
@pre class: 'cursor idle', => @raw ' '
|
||||
|
||||
editor: null
|
||||
screenPosition: null
|
||||
@@ -128,15 +128,16 @@ class Cursor extends View
|
||||
@editor.scrollTop(desiredTop)
|
||||
|
||||
autoScrollHorizontally: (position) ->
|
||||
charsInView = @editor.width() / @width()
|
||||
charsInView = @editor.lines.width() / @width()
|
||||
maxScrollMargin = Math.floor((charsInView - 1) / 2)
|
||||
scrollMargin = Math.min(@editor.hScrollMargin, maxScrollMargin)
|
||||
margin = scrollMargin * @width()
|
||||
desiredRight = position.left + @width() + margin
|
||||
desiredLeft = position.left - margin
|
||||
cursorLeft = (position.left - @editor.linesPositionLeft())
|
||||
desiredRight = cursorLeft + @width() + margin
|
||||
desiredLeft = cursorLeft - margin
|
||||
|
||||
if desiredRight > @editor.scrollRight()
|
||||
@editor.scrollRight(desiredRight)
|
||||
else if desiredLeft < @editor.scrollLeft()
|
||||
@editor.scrollLeft(desiredLeft)
|
||||
if desiredRight > @editor.lines.scrollRight()
|
||||
@editor.lines.scrollRight(desiredRight)
|
||||
else if desiredLeft < @editor.lines.scrollLeft()
|
||||
@editor.lines.scrollLeft(desiredLeft)
|
||||
|
||||
|
||||
@@ -16,7 +16,12 @@ module.exports =
|
||||
class Editor extends View
|
||||
@content: ->
|
||||
@div class: 'editor', tabindex: -1, =>
|
||||
@div outlet: 'lines'
|
||||
@div class: 'content', outlet: 'content', =>
|
||||
@div class: 'gutter', outlet: 'gutter', =>
|
||||
@div '1'
|
||||
@div '2'
|
||||
@div '3'
|
||||
@div class: 'lines', outlet: 'lines'
|
||||
@input class: 'hidden-input', outlet: 'hiddenInput'
|
||||
|
||||
vScrollMargin: 2
|
||||
@@ -230,7 +235,10 @@ class Editor extends View
|
||||
@lineWrapper.clipScreenPosition(screenPosition, options)
|
||||
|
||||
pixelPositionForScreenPosition: ({row, column}) ->
|
||||
{ top: row * @lineHeight, left: column * @charWidth }
|
||||
{ top: row * @lineHeight, left: @linesPositionLeft() + column * @charWidth }
|
||||
|
||||
linesPositionLeft: ->
|
||||
@lines.position().left + @scrollLeft()
|
||||
|
||||
screenPositionFromPixelPosition: ({top, left}) ->
|
||||
screenPosition = new Point(Math.floor(top / @lineHeight), Math.floor(left / @charWidth))
|
||||
@@ -261,18 +269,6 @@ class Editor extends View
|
||||
@lineHeight = fragment.outerHeight()
|
||||
fragment.remove()
|
||||
|
||||
scrollBottom: (newValue) ->
|
||||
if newValue?
|
||||
@scrollTop(newValue - @height())
|
||||
else
|
||||
@scrollTop() + @height()
|
||||
|
||||
scrollRight: (newValue) ->
|
||||
if newValue?
|
||||
@scrollLeft(newValue - @width())
|
||||
else
|
||||
@scrollLeft() + @width()
|
||||
|
||||
getCursor: -> @cursor
|
||||
getSelection: -> @selection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user