mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add support for Page Up and Page Down keys
This commit is contained in:
@@ -54,16 +54,16 @@ class Cursor
|
||||
refreshScreenPosition: ->
|
||||
@anchor.refreshScreenPosition()
|
||||
|
||||
moveUp: ->
|
||||
moveUp: (rowCount = 1) ->
|
||||
{ row, column } = @getScreenPosition()
|
||||
column = @goalColumn if @goalColumn?
|
||||
@setScreenPosition({row: row - 1, column: column})
|
||||
@setScreenPosition({row: row - rowCount, column: column})
|
||||
@goalColumn = column
|
||||
|
||||
moveDown: ->
|
||||
moveDown: (rowCount = 1) ->
|
||||
{ row, column } = @getScreenPosition()
|
||||
column = @goalColumn if @goalColumn?
|
||||
@setScreenPosition({row: row + 1, column: column})
|
||||
@setScreenPosition({row: row + rowCount, column: column})
|
||||
@goalColumn = column
|
||||
|
||||
moveLeft: ->
|
||||
|
||||
@@ -427,11 +427,11 @@ class EditSession
|
||||
getTextInBufferRange: (range) ->
|
||||
@buffer.getTextInRange(range)
|
||||
|
||||
moveCursorUp: ->
|
||||
@moveCursors (cursor) -> cursor.moveUp()
|
||||
moveCursorUp: (lineCount) ->
|
||||
@moveCursors (cursor) -> cursor.moveUp(lineCount)
|
||||
|
||||
moveCursorDown: ->
|
||||
@moveCursors (cursor) -> cursor.moveDown()
|
||||
moveCursorDown: (lineCount) ->
|
||||
@moveCursors (cursor) -> cursor.moveDown(lineCount)
|
||||
|
||||
moveCursorLeft: ->
|
||||
@moveCursors (cursor) -> cursor.moveLeft()
|
||||
|
||||
@@ -131,6 +131,8 @@ class Editor extends View
|
||||
'select-to-end-of-word': @selectToEndOfWord
|
||||
'select-to-beginning-of-word': @selectToBeginningOfWord
|
||||
'select-all': @selectAll
|
||||
'page-down': @pageDown
|
||||
'page-up': @pageUp
|
||||
|
||||
if not @mini
|
||||
_.extend editorBindings,
|
||||
@@ -246,6 +248,20 @@ class Editor extends View
|
||||
bufferRowsForScreenRows: (startRow, endRow) -> @activeEditSession.bufferRowsForScreenRows(startRow, endRow)
|
||||
stateForScreenRow: (row) -> @activeEditSession.stateForScreenRow(row)
|
||||
|
||||
pageDown: ->
|
||||
[top, rows] = @getPageSize()
|
||||
@activeEditSession.moveCursorDown(rows)
|
||||
@scrollTop(top, adjustVerticalScrollbar: true)
|
||||
pageUp: ->
|
||||
[top, rows] = @getPageSize()
|
||||
@activeEditSession.moveCursorUp(rows)
|
||||
@scrollTop(top, adjustVerticalScrollbar: true)
|
||||
getPageSize: ->
|
||||
scrollViewHeight = @scrollView[0].clientHeight
|
||||
newScrollTop = @scrollTop() + scrollViewHeight
|
||||
rows = Math.max(1, Math.ceil(scrollViewHeight / @lineHeight))
|
||||
[newScrollTop, rows]
|
||||
|
||||
setText: (text) -> @getBuffer().setText(text)
|
||||
getText: -> @getBuffer().getText()
|
||||
getPath: -> @getBuffer().getPath()
|
||||
|
||||
@@ -5,3 +5,5 @@ window.keymap.bindKeys '*'
|
||||
left: 'move-left'
|
||||
down: 'move-down'
|
||||
up: 'move-up'
|
||||
pagedown: 'page-down'
|
||||
pageup: 'page-up'
|
||||
|
||||
Reference in New Issue
Block a user