add config option for setting the font family

This commit is contained in:
Justin Palmer
2013-01-15 16:21:55 -08:00
committed by Corey Johnson
parent 4db876aed1
commit a83460452e
2 changed files with 19 additions and 6 deletions

View File

@@ -14,6 +14,7 @@ _ = require 'underscore'
module.exports =
class Editor extends View
@configDefaults:
fontFamily: "Inconsolata, Monaco, Courier"
fontSize: 20
showInvisibles: false
autosave: false
@@ -340,6 +341,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', =>
@@ -683,14 +685,25 @@ class Editor extends View
setFontSize: (@fontSize) ->
if fontSize?
@css('font-size', fontSize + 'px')
return unless @attached
@calculateDimensions()
@updatePaddingOfRenderedLines()
@updateLayerDimensions()
@requestDisplayUpdate()
@redraw()
getFontSize: -> @fontSize
setFontFamily: (@fontFamily) ->
if fontFamily?
@css('font-family', fontFamily)
@redraw()
getFontFamily: -> @fontFamily
redraw: ->
return unless @attached
@calculateDimensions()
@updatePaddingOfRenderedLines()
@updateLayerDimensions()
@requestDisplayUpdate()
newSplitEditor: (editSession) ->
new Editor { editSession: editSession ? @activeEditSession.copy() }

View File

@@ -103,4 +103,4 @@
position: absolute;
pointer-events: none;
z-index: -1;
}
}