mirror of
https://github.com/atom/atom.git
synced 2026-02-06 04:34:55 -05:00
Move atom.tabText to a property on Editor.prototype for more locality
This commit is contained in:
@@ -15,7 +15,7 @@ class AceOutdentAdaptor
|
||||
replace: (range, text) ->
|
||||
{row, column} = @editor.getCursorBufferPosition()
|
||||
start = range.start
|
||||
end = {row: range.start.row, column: range.start.column + atom.tabText.length}
|
||||
end = {row: range.start.row, column: range.start.column + @editor.tabText.length}
|
||||
@buffer.change(new Range(start, end), "")
|
||||
@editor.setCursorBufferPosition({row, column: column - atom.tabText.length})
|
||||
@editor.setCursorBufferPosition({row, column: column - @editor.tabText.length})
|
||||
|
||||
|
||||
@@ -9,13 +9,11 @@ module.exports =
|
||||
class Atom
|
||||
keymap: null
|
||||
windows: null
|
||||
tabText: null
|
||||
userConfigurationPath: null
|
||||
|
||||
constructor: (@loadPath, nativeMethods)->
|
||||
@windows = []
|
||||
@setUpKeymap()
|
||||
@tabText = " "
|
||||
@userConfigurationPath = fs.absolute "~/.atom/atom.coffee"
|
||||
|
||||
setUpKeymap: ->
|
||||
|
||||
@@ -38,6 +38,7 @@ class Editor extends View
|
||||
lineCache: null
|
||||
isFocused: false
|
||||
softTabs: true
|
||||
tabText: ' '
|
||||
|
||||
initialize: ({buffer}) ->
|
||||
requireStylesheet 'editor.css'
|
||||
@@ -199,7 +200,7 @@ class Editor extends View
|
||||
@trigger 'buffer-path-change'
|
||||
@buffer.on "path-change.editor#{@id}", => @trigger 'buffer-path-change'
|
||||
|
||||
@renderer = new Renderer(@buffer, { maxLineLength: @calcMaxLineLength() })
|
||||
@renderer = new Renderer(@buffer, { maxLineLength: @calcMaxLineLength(), tabText: @tabText })
|
||||
@renderLines()
|
||||
@gutter.renderLineNumbers()
|
||||
|
||||
@@ -409,7 +410,7 @@ class Editor extends View
|
||||
|
||||
insertTab: ->
|
||||
if @softTabs
|
||||
@compositeSelection.insertText(atom.tabText)
|
||||
@compositeSelection.insertText(@tabText)
|
||||
else
|
||||
@compositeSelection.insertText('\t')
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class Highlighter
|
||||
buffer: null
|
||||
screenLines: []
|
||||
|
||||
constructor: (@buffer) ->
|
||||
constructor: (@buffer, @tabText) ->
|
||||
@id = @constructor.idCounter++
|
||||
@screenLines = @buildLinesForScreenRows('start', 0, @buffer.getLastRow())
|
||||
@buffer.on "change.highlighter#{@id}", (e) => @handleBufferChange(e)
|
||||
@@ -59,7 +59,7 @@ class Highlighter
|
||||
tokenObjects = []
|
||||
for tokenProperties in tokens
|
||||
token = new Token(tokenProperties)
|
||||
tokenObjects.push(token.breakOutTabCharacters()...)
|
||||
tokenObjects.push(token.breakOutTabCharacters(@tabText)...)
|
||||
text = _.pluck(tokenObjects, 'value').join('')
|
||||
new ScreenLineFragment(tokenObjects, text, [1, 0], [1, 0], { state })
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class Renderer
|
||||
|
||||
constructor: (@buffer, options={}) ->
|
||||
@id = @constructor.idCounter++
|
||||
@highlighter = new Highlighter(@buffer)
|
||||
@highlighter = new Highlighter(@buffer, options.tabText ? ' ')
|
||||
@maxLineLength = options.maxLineLength ? Infinity
|
||||
@activeFolds = {}
|
||||
@foldsById = {}
|
||||
|
||||
@@ -111,7 +111,7 @@ class Selection extends View
|
||||
row = @cursor.getScreenPosition().row
|
||||
state = @editor.stateForScreenRow(row)
|
||||
if text[0] == "\n"
|
||||
indent = mode.getNextLineIndent(state, @cursor.getCurrentBufferLine(), atom.tabText)
|
||||
indent = mode.getNextLineIndent(state, @cursor.getCurrentBufferLine(), @editor.tabText)
|
||||
text = text[0] + indent + text[1..]
|
||||
else if mode.checkOutdent(state, @cursor.getCurrentBufferLine(), text)
|
||||
shouldOutdent = true
|
||||
|
||||
@@ -14,12 +14,12 @@ class Token
|
||||
value2 = @value.substring(splitIndex)
|
||||
[new Token(value: value1, type: @type), new Token(value: value2, type: @type)]
|
||||
|
||||
breakOutTabCharacters: ->
|
||||
breakOutTabCharacters: (tabText) ->
|
||||
for substring in @value.match(/([^\t]+|\t)/g)
|
||||
if substring == '\t'
|
||||
@buildTabToken()
|
||||
@buildTabToken(tabText)
|
||||
else
|
||||
new Token(value: substring, type: @type)
|
||||
|
||||
buildTabToken: ->
|
||||
new Token(value: atom.tabText, type: @type, isAtomic: true)
|
||||
buildTabToken: (tabText) ->
|
||||
new Token(value: tabText, type: @type, isAtomic: true)
|
||||
|
||||
Reference in New Issue
Block a user