From 5eb12e671bf477d94e379fd1b3cc22e37aac3dd6 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 18 Mar 2014 15:57:53 -0700 Subject: [PATCH 1/8] add config option for explicitly setting the editor line height --- src/editor-view.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/editor-view.coffee b/src/editor-view.coffee index a2148516e..8c58ded79 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -44,6 +44,7 @@ class EditorView extends View @configDefaults: fontFamily: '' fontSize: 16 + editorLineHeight: 1 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.editorLineHeight', (editorLineHeight) => @setEditorLineHeight(editorLineHeight) + handleEvents: -> @on 'focus', => @@ -742,6 +745,10 @@ class EditorView extends View @redraw() + setEditorLineHeight: (editorLineHeight) -> + @css('line-height', editorLineHeight) + @redraw() + # Public: Gets the font family for the editor. # # Returns a {String} identifying the CSS `font-family`. From 47f3b562b5300531fce842e1587451211d69299a Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 18 Mar 2014 16:03:42 -0700 Subject: [PATCH 2/8] add getter for editorLineHeight --- src/editor-view.coffee | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/editor-view.coffee b/src/editor-view.coffee index 8c58ded79..681e347b1 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -745,15 +745,25 @@ class EditorView extends View @redraw() - setEditorLineHeight: (editorLineHeight) -> - @css('line-height', editorLineHeight) - @redraw() - # Public: Gets the font family for the editor. # # Returns a {String} identifying the CSS `font-family`. getFontFamily: -> @css("font-family") + # Public: Sets the line height of the editor + # + # editorLineHeight - A {Number} without a unit suffix identifying the CSS + # `line-height`. + setEditorLineHeight: (editorLineHeight) -> + @css('line-height', editorLineHeight) + @redraw() + + # Public: Gets the line height for the editor + # + # Returns a {Float} identifying the CSS line-height. + getLineHeight: -> + parseFloat(@css('line-height')) + # Public: Redraw the editor redraw: -> return unless @hasParent() From 95d097dd7b2aaafc38e97f353cbc680e4c3274e9 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 18 Mar 2014 16:21:45 -0700 Subject: [PATCH 3/8] 1.3 best represents the previous default line height --- src/editor-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor-view.coffee b/src/editor-view.coffee index 681e347b1..abf47b036 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -44,7 +44,7 @@ class EditorView extends View @configDefaults: fontFamily: '' fontSize: 16 - editorLineHeight: 1 + editorLineHeight: 1.3 showInvisibles: false showIndentGuide: false showLineNumbers: true From d3d38c031271dc5d49b7abbb19f5b9155eb4a0f9 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 24 Mar 2014 11:28:15 -0700 Subject: [PATCH 4/8] rename editorLineHeight to lineHeight --- src/editor-view.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/editor-view.coffee b/src/editor-view.coffee index abf47b036..5caa92918 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -44,7 +44,7 @@ class EditorView extends View @configDefaults: fontFamily: '' fontSize: 16 - editorLineHeight: 1.3 + lineHeight: 1.3 showInvisibles: false showIndentGuide: false showLineNumbers: true @@ -341,7 +341,7 @@ 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.editorLineHeight', (editorLineHeight) => @setEditorLineHeight(editorLineHeight) + @subscribe atom.config.observe 'editor.lineHeight', (lineHeight) => @setLineHeight(lineHeight) handleEvents: -> @@ -752,10 +752,10 @@ class EditorView extends View # Public: Sets the line height of the editor # - # editorLineHeight - A {Number} without a unit suffix identifying the CSS + # lineHeight - A {Number} without a unit suffix identifying the CSS # `line-height`. - setEditorLineHeight: (editorLineHeight) -> - @css('line-height', editorLineHeight) + setLineHeight: (lineHeight) -> + @css('line-height', lineHeight) @redraw() # Public: Gets the line height for the editor From ce02dcf5a5e002e8b325dab38998c2d25cdc873a Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 24 Mar 2014 11:37:38 -0700 Subject: [PATCH 5/8] clarify docs around lineHeight --- src/editor-view.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/editor-view.coffee b/src/editor-view.coffee index 5caa92918..7b8ad82ab 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -760,6 +760,10 @@ class EditorView extends View # Public: Gets the line height for the editor # + # Note that this is different from `lineHeight`, which is the computed + # height of a line using the bounding box. This is the property value of + # CSS `line-height`. + # # Returns a {Float} identifying the CSS line-height. getLineHeight: -> parseFloat(@css('line-height')) From c389bccfa098e80150f606dead4eba90d51203bf Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 24 Mar 2014 11:37:58 -0700 Subject: [PATCH 6/8] update editor view specs to account for lineHeight --- spec/editor-view-spec.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/editor-view-spec.coffee b/spec/editor-view-spec.coffee index 9ef516613..26c52dbb5 100644 --- a/spec/editor-view-spec.coffee +++ b/spec/editor-view-spec.coffee @@ -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", -> From a604bfcdf1fbf54b860ca516b27812679abf37fa Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 24 Mar 2014 11:42:32 -0700 Subject: [PATCH 7/8] remove trailing whitespace --- src/editor-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor-view.coffee b/src/editor-view.coffee index 7b8ad82ab..152c46c35 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -762,7 +762,7 @@ class EditorView extends View # # Note that this is different from `lineHeight`, which is the computed # height of a line using the bounding box. This is the property value of - # CSS `line-height`. + # CSS `line-height`. # # Returns a {Float} identifying the CSS line-height. getLineHeight: -> From cf590685b9024d8734eef5a2789ea7556b36b6f3 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 24 Mar 2014 12:52:01 -0700 Subject: [PATCH 8/8] remove lineHeight getter Nothing is using it and we can add it back once the need arises. --- src/editor-view.coffee | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/editor-view.coffee b/src/editor-view.coffee index 152c46c35..ffd09dd92 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -758,16 +758,6 @@ class EditorView extends View @css('line-height', lineHeight) @redraw() - # Public: Gets the line height for the editor - # - # Note that this is different from `lineHeight`, which is the computed - # height of a line using the bounding box. This is the property value of - # CSS `line-height`. - # - # Returns a {Float} identifying the CSS line-height. - getLineHeight: -> - parseFloat(@css('line-height')) - # Public: Redraw the editor redraw: -> return unless @hasParent()