mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Rename col to column
This commit is contained in:
@@ -30,24 +30,24 @@ class Buffer
|
||||
@trigger 'change', { preRange, postRange, string }
|
||||
|
||||
remove: (range) ->
|
||||
prefix = @lines[range.start.row][0...range.start.col]
|
||||
suffix = @lines[range.end.row][range.end.col..]
|
||||
prefix = @lines[range.start.row][0...range.start.column]
|
||||
suffix = @lines[range.end.row][range.end.column..]
|
||||
|
||||
@lines[range.start.row..range.end.row] = prefix + suffix
|
||||
|
||||
insert: ({row, col}, string) ->
|
||||
insert: ({row, column}, string) ->
|
||||
postRange =
|
||||
start: { row, col }
|
||||
end: { row, col }
|
||||
start: { row, column }
|
||||
end: { row, column }
|
||||
|
||||
prefix = @lines[row][0...col]
|
||||
suffix = @lines[row][col..]
|
||||
prefix = @lines[row][0...column]
|
||||
suffix = @lines[row][column..]
|
||||
|
||||
lines = string.split('\n')
|
||||
|
||||
if lines.length == 1
|
||||
@lines[row] = prefix + string + suffix
|
||||
postRange.end.col += string.length
|
||||
postRange.end.column += string.length
|
||||
else
|
||||
for line, i in lines
|
||||
curRow = row + i
|
||||
@@ -58,20 +58,20 @@ class Buffer
|
||||
else # insert last line
|
||||
@lines[curRow...curRow] = line + suffix
|
||||
postRange.end.row = curRow
|
||||
postRange.end.col = line.length
|
||||
postRange.end.column = line.length
|
||||
|
||||
postRange
|
||||
|
||||
backspace: ({row, col}) ->
|
||||
backspace: ({row, column}) ->
|
||||
range =
|
||||
start: { row, col }
|
||||
end: { row, col }
|
||||
start: { row, column }
|
||||
end: { row, column }
|
||||
|
||||
if col == 0
|
||||
range.start.col = @lines[row - 1].length
|
||||
if column == 0
|
||||
range.start.column = @lines[row - 1].length
|
||||
range.start.row--
|
||||
else
|
||||
range.start.col--
|
||||
range.start.column--
|
||||
|
||||
@change range, ''
|
||||
|
||||
|
||||
@@ -21,62 +21,62 @@ class Cursor extends Template
|
||||
|
||||
getPosition: -> @point
|
||||
|
||||
setColumn: (col) ->
|
||||
setColumn: (column) ->
|
||||
{ row } = @getPosition()
|
||||
@setPosition {row, col}
|
||||
@setPosition {row, column}
|
||||
|
||||
getColumn: ->
|
||||
@getPosition().col
|
||||
@getPosition().column
|
||||
|
||||
getRow: ->
|
||||
@getPosition().row
|
||||
|
||||
moveUp: ->
|
||||
{ row, col } = @getPosition()
|
||||
col = @goalColumn if @goalColumn?
|
||||
{ row, column } = @getPosition()
|
||||
column = @goalColumn if @goalColumn?
|
||||
if row > 0
|
||||
@setPosition({row: row - 1, col: col})
|
||||
@setPosition({row: row - 1, column: column})
|
||||
else
|
||||
@moveToLineStart()
|
||||
|
||||
@goalColumn = col
|
||||
@goalColumn = column
|
||||
|
||||
moveDown: ->
|
||||
{ row, col } = @getPosition()
|
||||
col = @goalColumn if @goalColumn?
|
||||
{ row, column } = @getPosition()
|
||||
column = @goalColumn if @goalColumn?
|
||||
if row < @editor.buffer.numLines() - 1
|
||||
@setPosition({row: row + 1, col: col})
|
||||
@setPosition({row: row + 1, column: column})
|
||||
else
|
||||
@moveToLineEnd()
|
||||
|
||||
@goalColumn = col
|
||||
@goalColumn = column
|
||||
|
||||
moveToLineEnd: ->
|
||||
{ row } = @getPosition()
|
||||
@setPosition({ row, col: @editor.buffer.getLine(row).length })
|
||||
@setPosition({ row, column: @editor.buffer.getLine(row).length })
|
||||
|
||||
moveToLineStart: ->
|
||||
{ row } = @getPosition()
|
||||
@setPosition({ row, col: 0 })
|
||||
@setPosition({ row, column: 0 })
|
||||
|
||||
moveRight: ->
|
||||
{ row, col } = @getPosition()
|
||||
if col < @editor.buffer.getLine(row).length
|
||||
col++
|
||||
{ row, column } = @getPosition()
|
||||
if column < @editor.buffer.getLine(row).length
|
||||
column++
|
||||
else if row < @editor.buffer.numLines() - 1
|
||||
row++
|
||||
col = 0
|
||||
@setPosition({row, col})
|
||||
column = 0
|
||||
@setPosition({row, column})
|
||||
|
||||
moveLeft: ->
|
||||
{ row, col } = @getPosition()
|
||||
if col > 0
|
||||
col--
|
||||
{ row, column } = @getPosition()
|
||||
if column > 0
|
||||
column--
|
||||
else if row > 0
|
||||
row--
|
||||
col = @editor.buffer.getLine(row).length
|
||||
column = @editor.buffer.getLine(row).length
|
||||
|
||||
@setPosition({row, col})
|
||||
@setPosition({row, column})
|
||||
|
||||
updateAbsolutePosition: ->
|
||||
position = @editor.pixelPositionFromPoint(@point)
|
||||
|
||||
@@ -67,7 +67,7 @@ class Editor extends Template
|
||||
for line in @buffer.getLines()
|
||||
@lines.append @buildLineElement(line)
|
||||
|
||||
@setPosition(row: 0, col: 0)
|
||||
@setPosition(row: 0, column: 0)
|
||||
|
||||
@buffer.on 'change', (e) =>
|
||||
{ preRange, postRange } = e
|
||||
@@ -103,12 +103,12 @@ class Editor extends Template
|
||||
getLineElement: (row) ->
|
||||
@lines.find("pre:eq(#{row})")
|
||||
|
||||
clipPosition: ({row, col}) ->
|
||||
clipPosition: ({row, column}) ->
|
||||
line = @buffer.getLine(row)
|
||||
{ row: row, col: Math.min(line.length, col) }
|
||||
{ row: row, column: Math.min(line.length, column) }
|
||||
|
||||
pixelPositionFromPoint: ({row, col}) ->
|
||||
{ top: row * @lineHeight, left: col * @charWidth }
|
||||
pixelPositionFromPoint: ({row, column}) ->
|
||||
{ top: row * @lineHeight, left: column * @charWidth }
|
||||
|
||||
calculateDimensions: ->
|
||||
fragment = $('<pre style="position: absolute; visibility: hidden;">x</pre>')
|
||||
|
||||
Reference in New Issue
Block a user