mirror of
https://github.com/atom/atom.git
synced 2026-02-15 17:15:24 -05:00
Merge remote-tracking branch 'origin/dev' into better-anchors
This commit is contained in:
@@ -350,7 +350,7 @@ class EditSession
|
||||
foldedRows = []
|
||||
rows = [selection.start.row..selection.end.row]
|
||||
if selection.start.row isnt selection.end.row and selection.end.column is 0
|
||||
rows.pop() unless @isFoldedAtScreenRow(@screenPositionForBufferPosition(selection.end).row)
|
||||
rows.pop() unless @isFoldedAtBufferRow(selection.end.row)
|
||||
for row in rows
|
||||
screenRow = @screenPositionForBufferPosition([row]).row
|
||||
if @isFoldedAtScreenRow(screenRow)
|
||||
@@ -371,9 +371,7 @@ class EditSession
|
||||
|
||||
@foldBufferRow(foldedRow) for foldedRow in foldedRows
|
||||
|
||||
newStartPosition = [selection.start.row - 1, selection.start.column]
|
||||
newEndPosition = [selection.end.row - 1, selection.end.column]
|
||||
@setSelectedBufferRange([newStartPosition, newEndPosition], preserveFolds: true)
|
||||
@setSelectedBufferRange(selection.translate([-1]), preserveFolds: true)
|
||||
|
||||
moveLineDown: ->
|
||||
selection = @getSelectedBufferRange()
|
||||
@@ -385,7 +383,7 @@ class EditSession
|
||||
foldedRows = []
|
||||
rows = [selection.end.row..selection.start.row]
|
||||
if selection.start.row isnt selection.end.row and selection.end.column is 0
|
||||
rows.shift() unless @isFoldedAtScreenRow(@screenPositionForBufferPosition(selection.end).row)
|
||||
rows.shift() unless @isFoldedAtBufferRow(selection.end.row)
|
||||
for row in rows
|
||||
screenRow = @screenPositionForBufferPosition([row]).row
|
||||
if @isFoldedAtScreenRow(screenRow)
|
||||
@@ -410,9 +408,7 @@ class EditSession
|
||||
|
||||
@foldBufferRow(foldedRow) for foldedRow in foldedRows
|
||||
|
||||
newStartPosition = [selection.start.row + 1, selection.start.column]
|
||||
newEndPosition = [selection.end.row + 1, selection.end.column]
|
||||
@setSelectedBufferRange([newStartPosition, newEndPosition], preserveFolds: true)
|
||||
@setSelectedBufferRange(selection.translate([1]), preserveFolds: true)
|
||||
|
||||
|
||||
mutateSelectedText: (fn) ->
|
||||
|
||||
@@ -14,12 +14,13 @@ _ = require 'underscore'
|
||||
module.exports =
|
||||
class Editor extends View
|
||||
@configDefaults:
|
||||
fontFamily: "Inconsolata, Monaco, Courier"
|
||||
fontSize: 20
|
||||
showInvisibles: false
|
||||
autosave: false
|
||||
autoIndent: true
|
||||
autoIndentOnPaste: false
|
||||
nonWordCharacters: "./\\()\"’-_:,.;<>~!@#$%^&*|+=[]{}`~?"
|
||||
nonWordCharacters: "./\\()\"'-_:,.;<>~!@#$%^&*|+=[]{}`~?"
|
||||
|
||||
@content: (params) ->
|
||||
@div class: @classes(params), tabindex: -1, =>
|
||||
@@ -341,6 +342,7 @@ class Editor extends View
|
||||
@observeConfig 'editor.showInvisibles', (showInvisibles) => @setShowInvisibles(showInvisibles)
|
||||
@observeConfig 'editor.invisibles', (invisibles) => @setInvisibles(invisibles)
|
||||
@observeConfig 'editor.fontSize', (fontSize) => @setFontSize(fontSize)
|
||||
@observeConfig 'editor.fontFamily', (fontFamily) => @setFontFamily(fontFamily)
|
||||
|
||||
handleEvents: ->
|
||||
@on 'focus', =>
|
||||
@@ -681,16 +683,37 @@ class Editor extends View
|
||||
autosave: ->
|
||||
@save() if @getPath()?
|
||||
|
||||
setFontSize: (@fontSize) ->
|
||||
if fontSize?
|
||||
@css('font-size', fontSize + 'px')
|
||||
return unless @attached
|
||||
@calculateDimensions()
|
||||
@updatePaddingOfRenderedLines()
|
||||
@updateLayerDimensions()
|
||||
@requestDisplayUpdate()
|
||||
setFontSize: (fontSize) ->
|
||||
headTag = $("head")
|
||||
styleTag = headTag.find("style.font-size")
|
||||
if styleTag.length == 0
|
||||
styleTag = $$ -> @style class: 'font-size'
|
||||
headTag.append styleTag
|
||||
|
||||
getFontSize: -> @fontSize
|
||||
styleTag.text(".editor {font-size: #{fontSize}px}")
|
||||
@redraw()
|
||||
|
||||
getFontSize: ->
|
||||
parseInt(@css("font-size"))
|
||||
|
||||
setFontFamily: (fontFamily) ->
|
||||
headTag = $("head")
|
||||
styleTag = headTag.find("style.font-family")
|
||||
if styleTag.length == 0
|
||||
styleTag = $$ -> @style class: 'font-family'
|
||||
headTag.append styleTag
|
||||
|
||||
styleTag.text(".editor {font-family: #{fontFamily}}")
|
||||
@redraw()
|
||||
|
||||
getFontFamily: -> @css("font-family")
|
||||
|
||||
redraw: ->
|
||||
return unless @attached
|
||||
@calculateDimensions()
|
||||
@updatePaddingOfRenderedLines()
|
||||
@updateLayerDimensions()
|
||||
@requestDisplayUpdate()
|
||||
|
||||
newSplitEditor: (editSession) ->
|
||||
new Editor { editSession: editSession ? @activeEditSession.copy() }
|
||||
|
||||
@@ -34,6 +34,10 @@ class Point
|
||||
|
||||
new Point(row, column)
|
||||
|
||||
translate: (other) ->
|
||||
other = Point.fromObject(other)
|
||||
new Point(@row + other.row, @column + other.column)
|
||||
|
||||
splitAt: (column) ->
|
||||
if @row == 0
|
||||
rightColumn = @column - column
|
||||
|
||||
@@ -48,6 +48,9 @@ class Range
|
||||
add: (point) ->
|
||||
new Range(@start.add(point), @end.add(point))
|
||||
|
||||
translate: (startPoint, endPoint=startPoint) ->
|
||||
new Range(@start.translate(startPoint), @end.translate(endPoint))
|
||||
|
||||
intersectsWith: (otherRange) ->
|
||||
if @start.isLessThanOrEqual(otherRange.start)
|
||||
@end.isGreaterThanOrEqual(otherRange.start)
|
||||
|
||||
Reference in New Issue
Block a user