Merge pull request #1795 from atom/line-height-config

Line height config option
This commit is contained in:
Justin Palmer
2014-03-24 13:42:41 -07:00
2 changed files with 15 additions and 4 deletions

View File

@@ -2937,14 +2937,14 @@ describe "EditorView", ->
.editor { line-height: 2; }
"""
expect(editorView.pixelPositionForScreenPosition([1, 3])).toEqual {top: 32, left: 30}
expect(editorView.getCursorView().position()).toEqual {top: 32, left: 30}
expect(editorView.pixelPositionForScreenPosition([1, 3])).toEqual {top: 20, left: 30}
expect(editorView.getCursorView().position()).toEqual {top: 20, left: 30}
atom.themes.applyStylesheet 'char-width', """
.editor { letter-spacing: 2px; }
"""
expect(editorView.pixelPositionForScreenPosition([1, 3])).toEqual {top: 32, left: 36}
expect(editorView.getCursorView().position()).toEqual {top: 32, left: 36}
expect(editorView.pixelPositionForScreenPosition([1, 3])).toEqual {top: 20, left: 36}
expect(editorView.getCursorView().position()).toEqual {top: 20, left: 36}
describe "when the editor contains hard tabs", ->
it "correctly calculates the the position left for a column", ->

View File

@@ -44,6 +44,7 @@ class EditorView extends View
@configDefaults:
fontFamily: ''
fontSize: 16
lineHeight: 1.3
showInvisibles: false
showIndentGuide: false
showLineNumbers: true
@@ -340,6 +341,8 @@ class EditorView extends View
@subscribe atom.config.observe 'editor.invisibles', (invisibles) => @setInvisibles(invisibles)
@subscribe atom.config.observe 'editor.fontSize', (fontSize) => @setFontSize(fontSize)
@subscribe atom.config.observe 'editor.fontFamily', (fontFamily) => @setFontFamily(fontFamily)
@subscribe atom.config.observe 'editor.lineHeight', (lineHeight) => @setLineHeight(lineHeight)
handleEvents: ->
@on 'focus', =>
@@ -747,6 +750,14 @@ class EditorView extends View
# Returns a {String} identifying the CSS `font-family`.
getFontFamily: -> @css("font-family")
# Public: Sets the line height of the editor
#
# lineHeight - A {Number} without a unit suffix identifying the CSS
# `line-height`.
setLineHeight: (lineHeight) ->
@css('line-height', lineHeight)
@redraw()
# Public: Redraw the editor
redraw: ->
return unless @hasParent()