mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge master
This commit is contained in:
@@ -178,6 +178,10 @@ class Cursor
|
||||
if position = @getEndOfCurrentWordBufferPosition()
|
||||
@setBufferPosition(position)
|
||||
|
||||
moveToBeginningOfNextWord: ->
|
||||
if position = @getBeginningOfNextWordBufferPosition()
|
||||
@setBufferPosition(position)
|
||||
|
||||
getBeginningOfCurrentWordBufferPosition: (options = {}) ->
|
||||
allowPrevious = options.allowPrevious ? true
|
||||
currentBufferPosition = @getBufferPosition()
|
||||
@@ -205,7 +209,20 @@ class Cursor
|
||||
if not endOfWordPosition?.isEqual(currentBufferPosition)
|
||||
stop()
|
||||
|
||||
endOfWordPosition or currentBufferPosition
|
||||
endOfWordPosition ? currentBufferPosition
|
||||
|
||||
getBeginningOfNextWordBufferPosition: (options = {}) ->
|
||||
currentBufferPosition = @getBufferPosition()
|
||||
start = if @isSurroundedByWhitespace() then currentBufferPosition else @getEndOfCurrentWordBufferPosition()
|
||||
scanRange = [start, @editSession.getEofBufferPosition()]
|
||||
|
||||
beginningOfNextWordPosition = null
|
||||
@editSession.scanInBufferRange (options.wordRegex ? @wordRegExp()), scanRange, ({range, stop}) =>
|
||||
beginningOfNextWordPosition = range.start
|
||||
stop()
|
||||
|
||||
beginningOfNextWordPosition or currentBufferPosition
|
||||
|
||||
# Public: Gets the word located under the cursor.
|
||||
#
|
||||
# options - An object with properties based on {Cursor.getBeginningOfCurrentWordBufferPosition}.
|
||||
|
||||
@@ -766,23 +766,23 @@ class EditSession
|
||||
# Internal:
|
||||
pushOperation: (operation) ->
|
||||
@buffer.pushOperation(operation, this)
|
||||
|
||||
|
||||
# Internal:
|
||||
markScreenRange: (args...) ->
|
||||
@displayBuffer.markScreenRange(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
markBufferRange: (args...) ->
|
||||
@displayBuffer.markBufferRange(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
markScreenPosition: (args...) ->
|
||||
@displayBuffer.markScreenPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
markBufferPosition: (args...) ->
|
||||
@displayBuffer.markBufferPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
destroyMarker: (args...) ->
|
||||
@displayBuffer.destroyMarker(args...)
|
||||
@@ -792,83 +792,83 @@ class EditSession
|
||||
# Returns a {Number}.
|
||||
getMarkerCount: ->
|
||||
@buffer.getMarkerCount()
|
||||
|
||||
|
||||
# Internal:
|
||||
getMarkerScreenRange: (args...) ->
|
||||
@displayBuffer.getMarkerScreenRange(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
setMarkerScreenRange: (args...) ->
|
||||
@displayBuffer.setMarkerScreenRange(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
getMarkerBufferRange: (args...) ->
|
||||
@displayBuffer.getMarkerBufferRange(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
setMarkerBufferRange: (args...) ->
|
||||
@displayBuffer.setMarkerBufferRange(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
getMarkerScreenPosition: (args...) ->
|
||||
@displayBuffer.getMarkerScreenPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
getMarkerBufferPosition: (args...) ->
|
||||
@displayBuffer.getMarkerBufferPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
getMarkerHeadScreenPosition: (args...) ->
|
||||
@displayBuffer.getMarkerHeadScreenPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
setMarkerHeadScreenPosition: (args...) ->
|
||||
@displayBuffer.setMarkerHeadScreenPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
getMarkerHeadBufferPosition: (args...) ->
|
||||
@displayBuffer.getMarkerHeadBufferPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
setMarkerHeadBufferPosition: (args...) ->
|
||||
@displayBuffer.setMarkerHeadBufferPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
getMarkerTailScreenPosition: (args...) ->
|
||||
@displayBuffer.getMarkerTailScreenPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
setMarkerTailScreenPosition: (args...) ->
|
||||
@displayBuffer.setMarkerTailScreenPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
getMarkerTailBufferPosition: (args...) ->
|
||||
@displayBuffer.getMarkerTailBufferPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
setMarkerTailBufferPosition: (args...) ->
|
||||
@displayBuffer.setMarkerTailBufferPosition(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
observeMarker: (args...) ->
|
||||
@displayBuffer.observeMarker(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
placeMarkerTail: (args...) ->
|
||||
@displayBuffer.placeMarkerTail(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
clearMarkerTail: (args...) ->
|
||||
@displayBuffer.clearMarkerTail(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
isMarkerReversed: (args...) ->
|
||||
@displayBuffer.isMarkerReversed(args...)
|
||||
|
||||
|
||||
# Internal:
|
||||
isMarkerRangeEmpty: (args...) ->
|
||||
@displayBuffer.isMarkerRangeEmpty(args...)
|
||||
|
||||
|
||||
# Public: Returns `true` if there are multiple cursors in the edit session.
|
||||
#
|
||||
# Returns a {Boolean}.
|
||||
@@ -1090,6 +1090,9 @@ class EditSession
|
||||
moveCursorToEndOfWord: ->
|
||||
@moveCursors (cursor) -> cursor.moveToEndOfWord()
|
||||
|
||||
moveCursorToBeginningOfNextWord: ->
|
||||
@moveCursors (cursor) -> cursor.moveToBeginningOfNextWord()
|
||||
|
||||
moveCursors: (fn) ->
|
||||
fn(cursor) for cursor in @getCursors()
|
||||
@mergeCursors()
|
||||
@@ -1184,6 +1187,10 @@ class EditSession
|
||||
selectToEndOfWord: ->
|
||||
@expandSelectionsForward (selection) => selection.selectToEndOfWord()
|
||||
|
||||
# Public: Selects all the text from the current cursor position to the beginning of the next word.
|
||||
selectToBeginningOfNextWord: ->
|
||||
@expandSelectionsForward (selection) => selection.selectToBeginningOfNextWord()
|
||||
|
||||
# Public: Selects the current word.
|
||||
selectWord: ->
|
||||
@expandSelectionsForward (selection) => selection.selectWord()
|
||||
|
||||
@@ -130,10 +130,12 @@ class Editor extends View
|
||||
'editor:move-to-first-character-of-line': @moveCursorToFirstCharacterOfLine
|
||||
'editor:move-to-beginning-of-word': @moveCursorToBeginningOfWord
|
||||
'editor:move-to-end-of-word': @moveCursorToEndOfWord
|
||||
'editor:move-to-beginning-of-next-word': @moveCursorToBeginningOfNextWord
|
||||
'editor:select-to-end-of-line': @selectToEndOfLine
|
||||
'editor:select-to-beginning-of-line': @selectToBeginningOfLine
|
||||
'editor:select-to-end-of-word': @selectToEndOfWord
|
||||
'editor:select-to-beginning-of-word': @selectToBeginningOfWord
|
||||
'editor:select-to-beginning-of-next-word': @selectToBeginningOfNextWord
|
||||
'editor:add-selection-below': @addSelectionBelow
|
||||
'editor:add-selection-above': @addSelectionAbove
|
||||
'editor:select-line': @selectLine
|
||||
@@ -211,7 +213,8 @@ class Editor extends View
|
||||
moveCursorToBeginningOfWord: -> @activeEditSession.moveCursorToBeginningOfWord()
|
||||
# Public: Moves every cursor to the end of the current word.
|
||||
moveCursorToEndOfWord: -> @activeEditSession.moveCursorToEndOfWord()
|
||||
# Public: Moves every cursor to the top of the buffer.
|
||||
# Public: Moves the cursor to the beginning of the next word.
|
||||
moveCursorToBeginningOfNextWord: -> @activeEditSession.moveCursorToBeginningOfNextWord()
|
||||
moveCursorToTop: -> @activeEditSession.moveCursorToTop()
|
||||
# Public: Moves every cursor to the bottom of the buffer.
|
||||
moveCursorToBottom: -> @activeEditSession.moveCursorToBottom()
|
||||
@@ -233,6 +236,7 @@ class Editor extends View
|
||||
setCursorScreenPosition: (position, options) -> @activeEditSession.setCursorScreenPosition(position, options)
|
||||
# Public: Duplicates the current line.
|
||||
duplicateLine: -> @activeEditSession.duplicateLine()
|
||||
joinLine: -> @activeEditSession.joinLine()
|
||||
getCursorScreenPosition: -> @activeEditSession.getCursorScreenPosition()
|
||||
# Public: Gets the current screen row.
|
||||
#
|
||||
@@ -292,7 +296,8 @@ class Editor extends View
|
||||
selectToBeginningOfWord: -> @activeEditSession.selectToBeginningOfWord()
|
||||
# Public: Selects all the text from the current cursor position to the end of the word.
|
||||
selectToEndOfWord: -> @activeEditSession.selectToEndOfWord()
|
||||
# Public: Selects the current word.
|
||||
# Public: Selects all the text from the current cursor position to the beginning of the next word.
|
||||
selectToBeginningOfNextWord: -> @activeEditSession.selectToBeginningOfNextWord()
|
||||
selectWord: -> @activeEditSession.selectWord()
|
||||
selectLine: -> @activeEditSession.selectLine()
|
||||
selectToScreenPosition: (position) -> @activeEditSession.selectToScreenPosition(position)
|
||||
@@ -342,7 +347,7 @@ class Editor extends View
|
||||
# options - A set of options equivalent to {Selection.indent}.
|
||||
indent: (options) -> @activeEditSession.indent(options)
|
||||
# Public: TODO
|
||||
autoIndent: -> @activeEditSession.autoIndentSelectedRows()
|
||||
autoIndent: (options) -> @activeEditSession.autoIndentSelectedRows()
|
||||
# Public: Indents the selected rows.
|
||||
indentSelectedRows: -> @activeEditSession.indentSelectedRows()
|
||||
# Public: Outdents the selected rows.
|
||||
|
||||
@@ -95,11 +95,7 @@ class Git
|
||||
@isStatusNew(@getPathStatus(path))
|
||||
|
||||
relativize: (path) ->
|
||||
workingDirectory = @getWorkingDirectory()
|
||||
if workingDirectory and path.indexOf("#{workingDirectory}/") is 0
|
||||
path.substring(workingDirectory.length + 1)
|
||||
else
|
||||
path
|
||||
@getRepo().relativize(path)
|
||||
|
||||
getShortHead: ->
|
||||
@getRepo().getShortHead()
|
||||
|
||||
@@ -152,6 +152,9 @@ class Selection
|
||||
selectToEndOfWord: ->
|
||||
@modifySelection => @cursor.moveToEndOfWord()
|
||||
|
||||
selectToBeginningOfNextWord: ->
|
||||
@modifySelection => @cursor.moveToBeginningOfNextWord()
|
||||
|
||||
addSelectionBelow: ->
|
||||
range = (@goalBufferRange ? @getBufferRange()).copy()
|
||||
nextRow = range.end.row + 1
|
||||
|
||||
@@ -25,12 +25,6 @@ window.setUpEnvironment = ->
|
||||
$(document).on 'keydown', keymap.handleKeyEvent
|
||||
keymap.bindDefaultKeys()
|
||||
|
||||
ignoreEvents = (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
$(document).on 'dragover', ignoreEvents
|
||||
$(document).on 'drop', ignoreEvents
|
||||
|
||||
requireStylesheet 'reset'
|
||||
requireStylesheet 'atom'
|
||||
requireStylesheet 'overlay'
|
||||
@@ -50,6 +44,7 @@ window.startup = ->
|
||||
console.warn "Failed to install `atom` binary"
|
||||
|
||||
handleWindowEvents()
|
||||
handleDragDrop()
|
||||
config.load()
|
||||
keymap.loadBundledKeymaps()
|
||||
atom.loadThemes()
|
||||
@@ -93,6 +88,18 @@ window.handleWindowEvents = ->
|
||||
$(window).command 'window:close', => confirmClose()
|
||||
$(window).command 'window:reload', => reload()
|
||||
|
||||
window.handleDragDrop = ->
|
||||
$(document).on 'dragover', (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
$(document).on 'drop', onDrop
|
||||
|
||||
window.onDrop = (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
for file in e.originalEvent.dataTransfer.files
|
||||
atom.open(file.path)
|
||||
|
||||
window.deserializeWindowState = ->
|
||||
RootView = require 'root-view'
|
||||
Project = require 'project'
|
||||
|
||||
Reference in New Issue
Block a user