Move autoIndent, tabText, softTabs and softWrap to project

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-06-19 17:55:51 -07:00
parent 4e78b29e81
commit d1c1f3cfce
4 changed files with 55 additions and 34 deletions

View File

@@ -40,11 +40,8 @@ class Editor extends View
cursorViews: null
selectionViews: null
buffer: null
autoIndent: true
lineCache: null
isFocused: false
softTabs: true
tabText: ' '
activeEditSession: null
editSessions: null
attached: false
@@ -76,11 +73,11 @@ class Editor extends View
@setActiveEditSessionIndex(0)
else if @mini
editSession = new EditSession
softWrapColumn: @calcSoftWrapColumn()
buffer: new Buffer()
tabText: @tabText
autoIndent: @autoIndent
softTabs: @softTabs
softWrapColumn: null
tabText: " "
autoIndent: false
softTabs: true
@editSessions.push editSession
@setActiveEditSessionIndex(0)
@@ -233,15 +230,13 @@ class Editor extends View
isFoldedAtScreenRow: (screenRow) -> @activeEditSession.isFoldedAtScreenRow(screenRow)
unfoldCurrentRow: -> @activeEditSession.unfoldCurrentRow()
setAutoIndent: (@autoIndent) -> @activeEditSession.setAutoIndent(@autoIndent)
setSoftTabs: (@softTabs) -> @activeEditSession.setSoftTabs(@softTabs)
lineForScreenRow: (screenRow) -> @activeEditSession.lineForScreenRow(screenRow)
linesForScreenRows: (start, end) -> @activeEditSession.linesForScreenRows(start, end)
screenLineCount: -> @activeEditSession.screenLineCount()
setSoftWrapColumn: (softWrapColumn) ->
softWrapColumn ?= @calcSoftWrapColumn()
@activeEditSession.setSoftWrapColumn(softWrapColumn) if softWrapColumn
lineForScreenRow: (screenRow) -> @activeEditSession.lineForScreenRow(screenRow)
linesForScreenRows: (start, end) -> @activeEditSession.linesForScreenRows(start, end)
screenLineCount: -> @activeEditSession.screenLineCount()
maxScreenLineLength: -> @activeEditSession.maxScreenLineLength()
getLastScreenRow: -> @activeEditSession.getLastScreenRow()
clipScreenPosition: (screenPosition, options={}) -> @activeEditSession.clipScreenPosition(screenPosition, options)

View File

@@ -11,11 +11,19 @@ module.exports =
class Project
rootDirectory: null
editSessions: null
tabText: null
autoIndent: null
softTabs: null
softWrapColumn: null
constructor: (path) ->
@setPath(path)
@editSessions = []
@setTabText(' ')
@setAutoIndent(true)
@setSoftTabs(true)
getPath: ->
@rootDirectory?.path
@@ -56,6 +64,18 @@ class Project
relativize: (fullPath) ->
fullPath.replace(@getPath(), "").replace(/^\//, '')
getTabText: -> @tabText
setTabText: (@tabText) ->
getAutoIndent: -> @autoIndent
setAutoIndent: (@autoIndent) ->
getSoftTabs: -> @softTabs
setSoftTabs: (@softTabs) ->
getSoftWrapColumn: -> @softWrapColumn
setSoftWrapColumn: (@softWrapColumn) ->
open: (filePath) ->
if filePath?
filePath = @resolve(filePath)
@@ -63,7 +83,13 @@ class Project
else
buffer = @buildBuffer()
editSession = new EditSession({buffer, tabText: " ", autoIndent: true, softTabs: true, softWrapColumn: null})
editSession = new EditSession
buffer: buffer
tabText: @getTabText()
autoIndent: @getAutoIndent()
softTabs: @getSoftTabs()
softWrapColumn: @getSoftWrapColumn()
@editSessions.push editSession
editSession