mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge remote-tracking branch 'origin/dev' into markers
Conflicts: src/app/editor.coffee
This commit is contained in:
@@ -111,6 +111,9 @@ _.extend atom,
|
||||
endTracing: ->
|
||||
@sendMessageToBrowserProcess('endTracing')
|
||||
|
||||
toggleFullScreen: ->
|
||||
@sendMessageToBrowserProcess('toggleFullScreen')
|
||||
|
||||
getRootViewStateForPath: (path) ->
|
||||
if json = localStorage[path]
|
||||
JSON.parse(json)
|
||||
|
||||
@@ -218,13 +218,15 @@ class Buffer
|
||||
range
|
||||
|
||||
clipPosition: (position) ->
|
||||
{ row, column } = Point.fromObject(position)
|
||||
row = 0 if row < 0
|
||||
column = 0 if column < 0
|
||||
row = Math.min(@getLastRow(), row)
|
||||
column = Math.min(@lineLengthForRow(row), column)
|
||||
|
||||
new Point(row, column)
|
||||
position = Point.fromObject(position)
|
||||
eofPosition = @getEofPosition()
|
||||
if position.isGreaterThan(eofPosition)
|
||||
eofPosition
|
||||
else
|
||||
row = Math.max(position.row, 0)
|
||||
column = Math.max(position.column, 0)
|
||||
column = Math.min(@lineLengthForRow(row), column)
|
||||
new Point(row, column)
|
||||
|
||||
clipRange: (range) ->
|
||||
range = Range.fromObject(range)
|
||||
|
||||
@@ -307,6 +307,9 @@ class EditSession
|
||||
fold.destroy()
|
||||
@setCursorBufferPosition([fold.startRow, 0])
|
||||
|
||||
isFoldedAtCursorRow: ->
|
||||
@isFoldedAtScreenRow(@getCursorScreenRow())
|
||||
|
||||
isFoldedAtBufferRow: (bufferRow) ->
|
||||
screenRow = @screenPositionForBufferPosition([bufferRow]).row
|
||||
@isFoldedAtScreenRow(screenRow)
|
||||
@@ -408,6 +411,28 @@ class EditSession
|
||||
|
||||
@setSelectedBufferRange(selection.translate([1]), preserveFolds: true)
|
||||
|
||||
duplicateLine: ->
|
||||
return unless @getSelection().isEmpty()
|
||||
|
||||
@transact =>
|
||||
cursorPosition = @getCursorBufferPosition()
|
||||
cursorRowFolded = @isFoldedAtCursorRow()
|
||||
if cursorRowFolded
|
||||
screenRow = @screenPositionForBufferPosition(cursorPosition).row
|
||||
bufferRange = @bufferRangeForScreenRange([[screenRow], [screenRow + 1]])
|
||||
else
|
||||
bufferRange = new Range([cursorPosition.row], [cursorPosition.row + 1])
|
||||
|
||||
insertPosition = new Point(bufferRange.end.row)
|
||||
if insertPosition.row >= @buffer.getLastRow()
|
||||
@unfoldCurrentRow() if cursorRowFolded
|
||||
@buffer.append("\n#{@getTextInBufferRange(bufferRange)}")
|
||||
@foldCurrentRow() if cursorRowFolded
|
||||
else
|
||||
@buffer.insert(insertPosition, @getTextInBufferRange(bufferRange))
|
||||
|
||||
@setCursorScreenPosition(@getCursorScreenPosition().translate([1]))
|
||||
@foldCurrentRow() if cursorRowFolded
|
||||
|
||||
mutateSelectedText: (fn) ->
|
||||
@transact => fn(selection) for selection in @getSelections()
|
||||
|
||||
@@ -186,6 +186,7 @@ class Editor extends View
|
||||
'editor:copy-path': @copyPathToPasteboard
|
||||
'editor:move-line-up': @moveLineUp
|
||||
'editor:move-line-down': @moveLineDown
|
||||
'editor:duplicate-line': @duplicateLine
|
||||
|
||||
documentation = {}
|
||||
for name, method of editorBindings
|
||||
@@ -210,6 +211,7 @@ class Editor extends View
|
||||
moveLineUp: -> @activeEditSession.moveLineUp()
|
||||
moveLineDown: -> @activeEditSession.moveLineDown()
|
||||
setCursorScreenPosition: (position, options) -> @activeEditSession.setCursorScreenPosition(position, options)
|
||||
duplicateLine: -> @activeEditSession.duplicateLine()
|
||||
getCursorScreenPosition: -> @activeEditSession.getCursorScreenPosition()
|
||||
getCursorScreenRow: -> @activeEditSession.getCursorScreenRow()
|
||||
setCursorBufferPosition: (position, options) -> @activeEditSession.setCursorBufferPosition(position, options)
|
||||
@@ -277,6 +279,7 @@ class Editor extends View
|
||||
destroyFoldsContainingBufferRow: (bufferRow) -> @activeEditSession.destroyFoldsContainingBufferRow(bufferRow)
|
||||
isFoldedAtScreenRow: (screenRow) -> @activeEditSession.isFoldedAtScreenRow(screenRow)
|
||||
isFoldedAtBufferRow: (bufferRow) -> @activeEditSession.isFoldedAtBufferRow(bufferRow)
|
||||
isFoldedAtCursorRow: -> @activeEditSession.isFoldedAtCursorRow()
|
||||
|
||||
lineForScreenRow: (screenRow) -> @activeEditSession.lineForScreenRow(screenRow)
|
||||
linesForScreenRows: (start, end) -> @activeEditSession.linesForScreenRows(start, end)
|
||||
@@ -355,8 +358,8 @@ class Editor extends View
|
||||
|
||||
@hiddenInput.on 'focusout', =>
|
||||
@isFocused = false
|
||||
@removeClass 'is-focused'
|
||||
@autosave() if config.get "editor.autosave"
|
||||
@removeClass 'is-focused'
|
||||
|
||||
@underlayer.on 'click', (e) =>
|
||||
return unless e.target is @underlayer[0]
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
'meta--': 'window:decrease-font-size'
|
||||
'ctrl-w w': 'window:focus-next-pane'
|
||||
'ctrl-tab': 'window:focus-next-pane'
|
||||
'ctrl-meta-f': 'window:toggle-full-screen'
|
||||
|
||||
'alt-meta-i': 'toggle-dev-tools'
|
||||
|
||||
|
||||
@@ -40,3 +40,4 @@
|
||||
'ctrl-C': 'editor:copy-path'
|
||||
'ctrl-meta-up': 'editor:move-line-up'
|
||||
'ctrl-meta-down': 'editor:move-line-down'
|
||||
'meta-D': 'editor:duplicate-line'
|
||||
|
||||
@@ -25,11 +25,14 @@ windowAdditions =
|
||||
@syntax = new Syntax
|
||||
@setUpKeymap()
|
||||
@pasteboard = new Pasteboard
|
||||
@setUpEventHandlers()
|
||||
|
||||
setUpEventHandlers: ->
|
||||
$(window).on 'core:close', => @close()
|
||||
$(window).command 'window:close', => @close()
|
||||
$(window).on 'focus', => $("body").addClass("is-focused")
|
||||
$(window).on 'blur', => $("body").removeClass("is-focused")
|
||||
$(window).command 'window:toggle-full-screen', => atom.toggleFullScreen()
|
||||
$(window).on 'focus', -> $("body").removeClass('is-blurred')
|
||||
$(window).on 'blur', -> $("body").addClass('is-blurred')
|
||||
|
||||
# This method is intended only to be run when starting a normal application
|
||||
# Note: RootView assigns itself on window on initialization so that
|
||||
@@ -51,8 +54,8 @@ windowAdditions =
|
||||
atom.setWindowState('pathToOpen', @rootView.project.getPath())
|
||||
@rootView.deactivate()
|
||||
@rootView = null
|
||||
$(window).unbind('focus')
|
||||
$(window).unbind('blur')
|
||||
$(window).off('focus')
|
||||
$(window).off('blur')
|
||||
$(window).off('before')
|
||||
|
||||
setUpKeymap: ->
|
||||
|
||||
Reference in New Issue
Block a user