From a83460452e33b147774b80da145de2660f0e0c8f Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 15 Jan 2013 16:21:55 -0800 Subject: [PATCH 01/24] add config option for setting the font family --- src/app/editor.coffee | 23 ++++++++++++++++++----- static/editor.css | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 7d4ee0382..74b3e8765 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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() } diff --git a/static/editor.css b/static/editor.css index bdd9f2825..0b8cfb452 100644 --- a/static/editor.css +++ b/static/editor.css @@ -103,4 +103,4 @@ position: absolute; pointer-events: none; z-index: -1; -} \ No newline at end of file +} From f138a29a879ffd356419058b1de85c18e40a07bb Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 15 Jan 2013 16:23:02 -0800 Subject: [PATCH 02/24] add config option for line height This renames the original lineHeight variable to rowHeight to avoid collision --- src/app/editor.coffee | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 74b3e8765..75396cd2a 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -16,6 +16,7 @@ class Editor extends View @configDefaults: fontFamily: "Inconsolata, Monaco, Courier" fontSize: 20 + lineHeight: 1.5 showInvisibles: false autosave: false autoIndent: true @@ -308,7 +309,7 @@ class Editor extends View @scrollTop(newScrollTop, adjustVerticalScrollbar: true) getPageRows: -> - Math.max(1, Math.ceil(@scrollView[0].clientHeight / @lineHeight)) + Math.max(1, Math.ceil(@scrollView[0].clientHeight / @rowHeight)) setShowInvisibles: (showInvisibles) -> return if showInvisibles == @showInvisibles @@ -342,6 +343,7 @@ class Editor extends View @observeConfig 'editor.invisibles', (invisibles) => @setInvisibles(invisibles) @observeConfig 'editor.fontSize', (fontSize) => @setFontSize(fontSize) @observeConfig 'editor.fontFamily', (fontFamily) => @setFontFamily(fontFamily) + @observeConfig 'editor.lineHeight', (lineHeight) => @setLineHeight(lineHeight) handleEvents: -> @on 'focus', => @@ -575,7 +577,7 @@ class Editor extends View @scrollTop() + @scrollView.height() scrollToBottom: -> - @scrollBottom(@screenLineCount() * @lineHeight) + @scrollBottom(@screenLineCount() * @rowHeight) scrollToBufferPosition: (bufferPosition, options) -> @scrollToPixelPosition(@pixelPositionForBufferPosition(bufferPosition), options) @@ -597,12 +599,12 @@ class Editor extends View unless scrollTop < pixelPosition.top < scrollBottom @scrollTop(pixelPosition.top - (scrollViewHeight / 2)) else - linesInView = @scrollView.height() / @lineHeight + linesInView = @scrollView.height() / @rowHeight maxScrollMargin = Math.floor((linesInView - 1) / 2) scrollMargin = Math.min(@vScrollMargin, maxScrollMargin) - margin = scrollMargin * @lineHeight + margin = scrollMargin * @rowHeight desiredTop = pixelPosition.top - margin - desiredBottom = pixelPosition.top + @lineHeight + margin + desiredBottom = pixelPosition.top + @rowHeight + margin if desiredBottom > scrollBottom @scrollTop(desiredBottom - scrollViewHeight) else if desiredTop < scrollTop @@ -696,6 +698,12 @@ class Editor extends View getFontFamily: -> @fontFamily + setLineHeight: (@lineHeight) -> + if lineHeight? + @css('line-height', "#{lineHeight}em") + @redraw() + + getLineHeight: -> @lineHeight redraw: -> return unless @attached @@ -798,16 +806,16 @@ class Editor extends View lineRect = fragment[0].getBoundingClientRect() charRect = fragment.find('span')[0].getBoundingClientRect() - @lineHeight = lineRect.height + @rowHeight = lineRect.height @charWidth = charRect.width @charHeight = charRect.height - @height(@lineHeight) if @mini + @height(@rowHeight) if @mini fragment.remove() updateLayerDimensions: -> @gutter.calculateWidth() - height = @lineHeight * @screenLineCount() + height = @rowHeight * @screenLineCount() unless @layerHeight == height @renderedLines.height(height) @underlayer.css('min-height', height) @@ -1015,19 +1023,19 @@ class Editor extends View row++ updatePaddingOfRenderedLines: -> - paddingTop = @firstRenderedScreenRow * @lineHeight + paddingTop = @firstRenderedScreenRow * @rowHeight @renderedLines.css('padding-top', paddingTop) @gutter.lineNumbers.css('padding-top', paddingTop) - paddingBottom = (@getLastScreenRow() - @lastRenderedScreenRow) * @lineHeight + paddingBottom = (@getLastScreenRow() - @lastRenderedScreenRow) * @rowHeight @renderedLines.css('padding-bottom', paddingBottom) @gutter.lineNumbers.css('padding-bottom', paddingBottom) getFirstVisibleScreenRow: -> - Math.floor(@scrollTop() / @lineHeight) + Math.floor(@scrollTop() / @rowHeight) getLastVisibleScreenRow: -> - Math.max(0, Math.ceil((@scrollTop() + @scrollView.height()) / @lineHeight) - 1) + Math.max(0, Math.ceil((@scrollTop() + @scrollView.height()) / @rowHeight) - 1) isScreenRowVisible: (row) -> @getFirstVisibleScreenRow() <= row <= @getLastVisibleScreenRow() @@ -1126,7 +1134,7 @@ class Editor extends View pixelPositionForScreenPosition: (position) -> position = Point.fromObject(position) - { top: position.row * @lineHeight, left: position.column * @charWidth } + { top: position.row * @rowHeight, left: position.column * @charWidth } pixelOffsetForScreenPosition: (position) -> {top, left} = @pixelPositionForScreenPosition(position) @@ -1134,7 +1142,7 @@ class Editor extends View {top: top + offset.top, left: left + offset.left} screenPositionFromPixelPosition: ({top, left}) -> - screenPosition = new Point(Math.floor(top / @lineHeight), Math.floor(left / @charWidth)) + screenPosition = new Point(Math.floor(top / @rowHeight), Math.floor(left / @charWidth)) screenPositionFromMouseEvent: (e) -> { pageX, pageY } = e From e17387e7f0f6f6279286fefda72ea1b90409a23c Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Thu, 24 Jan 2013 11:36:25 -0800 Subject: [PATCH 03/24] Remove lineHeight example from docs --- docs/configuring-and-extending.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/configuring-and-extending.md b/docs/configuring-and-extending.md index 7ecd60a04..35ece3c59 100644 --- a/docs/configuring-and-extending.md +++ b/docs/configuring-and-extending.md @@ -55,8 +55,8 @@ Or you can use `observeConfig` to track changes from a view object. ```coffeescript class MyView extends View initialize: -> - @observeConfig 'editor.lineHeight', (lineHeight) => - @adjustLineHeight(lineHeight) + @observeConfig 'editor.fontSize', () => + @adjustFontSize() ``` The `observeConfig` method will call the given callback immediately with the From 129b574df4f44650c928d9e250e9b3d29127128d Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Thu, 24 Jan 2013 11:37:23 -0800 Subject: [PATCH 04/24] Remove lineHeight config option and rename @rowHeight back to @lineHeight --- src/app/editor.coffee | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 75396cd2a..875e4163a 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -16,7 +16,6 @@ class Editor extends View @configDefaults: fontFamily: "Inconsolata, Monaco, Courier" fontSize: 20 - lineHeight: 1.5 showInvisibles: false autosave: false autoIndent: true @@ -309,7 +308,7 @@ class Editor extends View @scrollTop(newScrollTop, adjustVerticalScrollbar: true) getPageRows: -> - Math.max(1, Math.ceil(@scrollView[0].clientHeight / @rowHeight)) + Math.max(1, Math.ceil(@scrollView[0].clientHeight / @lineHeight)) setShowInvisibles: (showInvisibles) -> return if showInvisibles == @showInvisibles @@ -343,7 +342,6 @@ class Editor extends View @observeConfig 'editor.invisibles', (invisibles) => @setInvisibles(invisibles) @observeConfig 'editor.fontSize', (fontSize) => @setFontSize(fontSize) @observeConfig 'editor.fontFamily', (fontFamily) => @setFontFamily(fontFamily) - @observeConfig 'editor.lineHeight', (lineHeight) => @setLineHeight(lineHeight) handleEvents: -> @on 'focus', => @@ -577,7 +575,7 @@ class Editor extends View @scrollTop() + @scrollView.height() scrollToBottom: -> - @scrollBottom(@screenLineCount() * @rowHeight) + @scrollBottom(@screenLineCount() * @lineHeight) scrollToBufferPosition: (bufferPosition, options) -> @scrollToPixelPosition(@pixelPositionForBufferPosition(bufferPosition), options) @@ -599,12 +597,12 @@ class Editor extends View unless scrollTop < pixelPosition.top < scrollBottom @scrollTop(pixelPosition.top - (scrollViewHeight / 2)) else - linesInView = @scrollView.height() / @rowHeight + linesInView = @scrollView.height() / @lineHeight maxScrollMargin = Math.floor((linesInView - 1) / 2) scrollMargin = Math.min(@vScrollMargin, maxScrollMargin) - margin = scrollMargin * @rowHeight + margin = scrollMargin * @lineHeight desiredTop = pixelPosition.top - margin - desiredBottom = pixelPosition.top + @rowHeight + margin + desiredBottom = pixelPosition.top + @lineHeight + margin if desiredBottom > scrollBottom @scrollTop(desiredBottom - scrollViewHeight) else if desiredTop < scrollTop @@ -698,13 +696,6 @@ class Editor extends View getFontFamily: -> @fontFamily - setLineHeight: (@lineHeight) -> - if lineHeight? - @css('line-height', "#{lineHeight}em") - @redraw() - - getLineHeight: -> @lineHeight - redraw: -> return unless @attached @calculateDimensions() @@ -806,16 +797,16 @@ class Editor extends View lineRect = fragment[0].getBoundingClientRect() charRect = fragment.find('span')[0].getBoundingClientRect() - @rowHeight = lineRect.height + @lineHeight = lineRect.height @charWidth = charRect.width @charHeight = charRect.height - @height(@rowHeight) if @mini + @height(@lineHeight) if @mini fragment.remove() updateLayerDimensions: -> @gutter.calculateWidth() - height = @rowHeight * @screenLineCount() + height = @lineHeight * @screenLineCount() unless @layerHeight == height @renderedLines.height(height) @underlayer.css('min-height', height) @@ -1023,19 +1014,19 @@ class Editor extends View row++ updatePaddingOfRenderedLines: -> - paddingTop = @firstRenderedScreenRow * @rowHeight + paddingTop = @firstRenderedScreenRow * @lineHeight @renderedLines.css('padding-top', paddingTop) @gutter.lineNumbers.css('padding-top', paddingTop) - paddingBottom = (@getLastScreenRow() - @lastRenderedScreenRow) * @rowHeight + paddingBottom = (@getLastScreenRow() - @lastRenderedScreenRow) * @lineHeight @renderedLines.css('padding-bottom', paddingBottom) @gutter.lineNumbers.css('padding-bottom', paddingBottom) getFirstVisibleScreenRow: -> - Math.floor(@scrollTop() / @rowHeight) + Math.floor(@scrollTop() / @lineHeight) getLastVisibleScreenRow: -> - Math.max(0, Math.ceil((@scrollTop() + @scrollView.height()) / @rowHeight) - 1) + Math.max(0, Math.ceil((@scrollTop() + @scrollView.height()) / @lineHeight) - 1) isScreenRowVisible: (row) -> @getFirstVisibleScreenRow() <= row <= @getLastVisibleScreenRow() @@ -1134,7 +1125,7 @@ class Editor extends View pixelPositionForScreenPosition: (position) -> position = Point.fromObject(position) - { top: position.row * @rowHeight, left: position.column * @charWidth } + { top: position.row * @lineHeight, left: position.column * @charWidth } pixelOffsetForScreenPosition: (position) -> {top, left} = @pixelPositionForScreenPosition(position) @@ -1142,7 +1133,7 @@ class Editor extends View {top: top + offset.top, left: left + offset.left} screenPositionFromPixelPosition: ({top, left}) -> - screenPosition = new Point(Math.floor(top / @rowHeight), Math.floor(left / @charWidth)) + screenPosition = new Point(Math.floor(top / @lineHeight), Math.floor(left / @charWidth)) screenPositionFromMouseEvent: (e) -> { pageX, pageY } = e From e7c3282f53ec3bd92894cbbed871bf0d5db4f321 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 30 Jan 2013 10:15:34 -0800 Subject: [PATCH 05/24] Add font-family spec --- spec/app/editor-spec.coffee | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 9dcffb4cf..2660b14fa 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -516,6 +516,30 @@ describe "Editor", -> editor.getBuffer().saveAs(path) expect(editor.getGrammar().name).toBe 'Plain Text' + describe "font family", -> + beforeEach -> + expect(editor.css('font-family')).not.toBe 'monaco' + + it "sets the initial font family based on the value from config", -> + config.set("editor.fontFamily", "monaco") + newEditor = editor.splitRight() + expect(editor.css('font-family')).toBe 'monaco' + expect(newEditor.css('font-family')).toBe 'monaco' + + describe "when the font family changes on the view", -> + it "updates the font family of editors and recalculates dimensions critical to cursor positioning", -> + rootView.attachToDom() + rootView.height(200) + rootView.width(200) + + lineHeightBefore = editor.lineHeight + charWidthBefore = editor.charWidth + editor.setCursorScreenPosition [5, 6] + config.set("editor.fontFamily", "monaco") + expect(editor.charWidth).not.toBe charWidthBefore + expect(editor.getCursorView().position()).toEqual { top: 5 * editor.lineHeight, left: 6 * editor.charWidth } + expect(editor.verticalScrollbarContent.height()).toBe buffer.getLineCount() * editor.lineHeight + describe "font size", -> it "sets the initial font size based on the value from config", -> config.set("editor.fontSize", 20) From 9ea29b2899884fa8be2603a32ad584347535e3c4 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 30 Jan 2013 10:29:17 -0800 Subject: [PATCH 06/24] Set font-family css property using style tag --- spec/app/editor-spec.coffee | 24 +++++++++++++++++------- src/app/editor.coffee | 11 ++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 2660b14fa..eb7494738 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -518,15 +518,25 @@ describe "Editor", -> describe "font family", -> beforeEach -> - expect(editor.css('font-family')).not.toBe 'monaco' + expect(editor.css('font-family')).not.toBe 'Courier' it "sets the initial font family based on the value from config", -> - config.set("editor.fontFamily", "monaco") - newEditor = editor.splitRight() - expect(editor.css('font-family')).toBe 'monaco' - expect(newEditor.css('font-family')).toBe 'monaco' + expect($("head style.font-family")).toExist() + expect($("head style.font-family").text()).toMatch "{font-family: #{config.get('editor.fontFamily')}}" + + describe "when the font family changes", -> + it "updates the font family on new and existing editors", -> + rootView.attachToDom() + rootView.height(200) + rootView.width(200) + + config.set("editor.fontFamily", "Courier") + newEditor = editor.splitRight() + + expect($("head style.font-family").text()).toMatch "{font-family: Courier}" + expect(editor.css('font-family')).toBe 'Courier' + expect(newEditor.css('font-family')).toBe 'Courier' - describe "when the font family changes on the view", -> it "updates the font family of editors and recalculates dimensions critical to cursor positioning", -> rootView.attachToDom() rootView.height(200) @@ -534,8 +544,8 @@ describe "Editor", -> lineHeightBefore = editor.lineHeight charWidthBefore = editor.charWidth + config.set("editor.fontFamily", "Courier") editor.setCursorScreenPosition [5, 6] - config.set("editor.fontFamily", "monaco") expect(editor.charWidth).not.toBe charWidthBefore expect(editor.getCursorView().position()).toEqual { top: 5 * editor.lineHeight, left: 6 * editor.charWidth } expect(editor.verticalScrollbarContent.height()).toBe buffer.getLineCount() * editor.lineHeight diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 875e4163a..a45e1c636 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -690,9 +690,14 @@ class Editor extends View getFontSize: -> @fontSize setFontFamily: (@fontFamily) -> - if fontFamily? - @css('font-family', fontFamily) - @redraw() + headTag = $("head") + styleTag = headTag.find("style.font-family") + if styleTag.length == 0 + styleTag = $$ -> @style class: 'font-family' + headTag.append styleTag + + styleTag.text(".editor {font-family: #{@fontFamily}}") + @redraw() getFontFamily: -> @fontFamily From 29ccd271de3424e854f201f2a1cf35f83c605cd2 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 30 Jan 2013 12:11:17 -0800 Subject: [PATCH 07/24] Set font-size css property using style tag --- spec/app/editor-spec.coffee | 25 +++++++++++++++++++------ src/app/editor.coffee | 11 ++++++++--- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index eb7494738..8a9811704 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -551,13 +551,26 @@ describe "Editor", -> expect(editor.verticalScrollbarContent.height()).toBe buffer.getLineCount() * editor.lineHeight describe "font size", -> - it "sets the initial font size based on the value from config", -> - config.set("editor.fontSize", 20) - newEditor = editor.splitRight() - expect(editor.css('font-size')).toBe '20px' - expect(newEditor.css('font-size')).toBe '20px' + beforeEach -> + expect(editor.css('font-size')).not.toBe "20px" + + it "sets the initial font size based on the value from config", -> + expect($("head style.font-size")).toExist() + expect($("head style.font-size").text()).toMatch "{font-size: #{config.get('editor.fontSize')}px}" + + describe "when the font size changes", -> + it "updates the font family on new and existing editors", -> + rootView.attachToDom() + rootView.height(200) + rootView.width(200) + + config.set("editor.fontSize", 20) + newEditor = editor.splitRight() + + expect($("head style.font-size").text()).toMatch "{font-size: 20px}" + expect(editor.css('font-size')).toBe '20px' + expect(newEditor.css('font-size')).toBe '20px' - describe "when the font size changes on the view", -> it "updates the font sizes of editors and recalculates dimensions critical to cursor positioning", -> rootView.attachToDom() rootView.height(200) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a45e1c636..a4dd22579 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -683,9 +683,14 @@ class Editor extends View @save() if @getPath()? setFontSize: (@fontSize) -> - if fontSize? - @css('font-size', fontSize + 'px') - @redraw() + headTag = $("head") + styleTag = headTag.find("style.font-size") + if styleTag.length == 0 + styleTag = $$ -> @style class: 'font-size' + headTag.append styleTag + + styleTag.text(".editor {font-size: #{@fontSize}px}") + @redraw() getFontSize: -> @fontSize From 9b1cb29e1f693aed0aad3e287bd9631f4ee0ae5c Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 30 Jan 2013 12:13:20 -0800 Subject: [PATCH 08/24] Don't store fontSize and fontFamily as instance variables --- spec/app/root-view-spec.coffee | 2 +- src/app/editor.coffee | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 20b5bca36..b046bef30 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -567,9 +567,9 @@ describe "RootView", -> editor = null beforeEach -> editor = rootView.getActiveEditor() + editor.attachToDom() it "increases/decreases font size when increase/decrease-font-size events are triggered", -> - editor = rootView.getActiveEditor() fontSizeBefore = editor.getFontSize() rootView.trigger 'window:increase-font-size' expect(editor.getFontSize()).toBe fontSizeBefore + 1 diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a4dd22579..47517e043 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -682,29 +682,30 @@ class Editor extends View autosave: -> @save() if @getPath()? - setFontSize: (@fontSize) -> + setFontSize: (fontSize) -> headTag = $("head") styleTag = headTag.find("style.font-size") if styleTag.length == 0 styleTag = $$ -> @style class: 'font-size' headTag.append styleTag - styleTag.text(".editor {font-size: #{@fontSize}px}") + styleTag.text(".editor {font-size: #{fontSize}px}") @redraw() - getFontSize: -> @fontSize + getFontSize: -> + parseInt(@css("font-size")) - setFontFamily: (@fontFamily) -> + setFontFamily: (fontFamily) -> headTag = $("head") styleTag = headTag.find("style.font-family") if styleTag.length == 0 styleTag = $$ -> @style class: 'font-family' headTag.append styleTag - styleTag.text(".editor {font-family: #{@fontFamily}}") + styleTag.text(".editor {font-family: #{fontFamily}}") @redraw() - getFontFamily: -> @fontFamily + getFontFamily: -> @css("font-family") redraw: -> return unless @attached From 14f761ec37432f03e91a085848f8606b721062ff Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 12:20:24 -0800 Subject: [PATCH 09/24] =?UTF-8?q?small=20doc=20tweak=E2=80=A6hopefully=20f?= =?UTF-8?q?ixes=20bold=20formatting=20on=20docs=20tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/packages/intro.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/packages/intro.md b/docs/packages/intro.md index 4f37c9446..7e4d20bfd 100644 --- a/docs/packages/intro.md +++ b/docs/packages/intro.md @@ -18,9 +18,9 @@ my-package/ index.coffee ``` -**NOTE: NPM behavior is partially implemented until we get a working Node.js +**NOTE:** NPM behavior is partially implemented until we get a working Node.js API built into Atom. The goal is to make Atom packages be a superset of NPM -packages** +packages #### package.json From 74cec989bb558e2d15b229e43971f98dfe2169a7 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 30 Jan 2013 13:19:09 -0800 Subject: [PATCH 10/24] Use getFontSize() --- src/packages/command-panel/src/command-panel-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/command-panel/src/command-panel-view.coffee b/src/packages/command-panel/src/command-panel-view.coffee index 7ccb74a48..d27711a70 100644 --- a/src/packages/command-panel/src/command-panel-view.coffee +++ b/src/packages/command-panel/src/command-panel-view.coffee @@ -51,7 +51,7 @@ class CommandPanelView extends View @previewList.hide() @previewCount.hide() @errorMessages.hide() - @prompt.iconSize(@miniEditor.fontSize) + @prompt.iconSize(@miniEditor.getFontSize()) serialize: -> text: @miniEditor.getText() From 06f64b55725e1020e5e0a30dcec5807ac9c747ad Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 13:23:40 -0800 Subject: [PATCH 11/24] Use rotated locate icon for folded line marker --- themes/Atom - Dark/editor.css | 5 +++-- themes/Atom - Light/editor.css | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/themes/Atom - Dark/editor.css b/themes/Atom - Dark/editor.css index d15b4a7e0..b2daa3586 100644 --- a/themes/Atom - Dark/editor.css +++ b/themes/Atom - Dark/editor.css @@ -53,10 +53,11 @@ } .editor .fold-marker:before { - content: '\f25e'; + content: '\f060'; + -webkit-transform: rotate(90deg); font-family: 'Octicons Regular'; display: inline-block; - margin-left: .5em; + margin-left: .3em; margin-top: .1em; line-height: .8em; -webkit-font-smoothing: antialiased; diff --git a/themes/Atom - Light/editor.css b/themes/Atom - Light/editor.css index 14e16fbc5..26dec9cb1 100644 --- a/themes/Atom - Light/editor.css +++ b/themes/Atom - Light/editor.css @@ -56,10 +56,11 @@ } .editor .fold-marker:before { - content: '\f25e'; + content: '\f060'; + -webkit-transform: rotate(90deg); font-family: 'Octicons Regular'; display: inline-block; - margin-left: .5em; + margin-left: .3em; margin-top: .1em; line-height: .8em; -webkit-font-smoothing: antialiased; From 1acf0b870f3a04e53ac36d4c5b0ee2ca24c37481 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 13:48:36 -0800 Subject: [PATCH 12/24] Support translating points and ranges --- spec/app/point-spec.coffee | 6 ++++++ spec/app/range-spec.coffee | 5 +++++ src/app/edit-session.coffee | 8 ++------ src/app/point.coffee | 4 ++++ src/app/range.coffee | 3 +++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/spec/app/point-spec.coffee b/spec/app/point-spec.coffee index 322bac5f2..d4d78715c 100644 --- a/spec/app/point-spec.coffee +++ b/spec/app/point-spec.coffee @@ -25,3 +25,9 @@ describe "Point", -> expect(new Point(5, 0).compare(new Point(6, 1))).toBe -1 expect(new Point(5, 5).compare(new Point(4, 1))).toBe 1 expect(new Point(5, 5).compare(new Point(5, 3))).toBe 1 + + describe ".translate(other)", -> + it "returns a translated point", -> + expect(new Point(1,2).translate([2,4])).toEqual [3,6] + expect(new Point(1,2).translate([-1])).toEqual [0,2] + expect(new Point(1,2).translate([0,-2])).toEqual [1,0] diff --git a/spec/app/range-spec.coffee b/spec/app/range-spec.coffee index 780962a5f..c73111ace 100644 --- a/spec/app/range-spec.coffee +++ b/spec/app/range-spec.coffee @@ -32,3 +32,8 @@ describe "Range", -> expect(new Range([2, 1], [3, 10]).union(new Range([1, 1], [2, 10]))).toEqual [[1, 1], [3, 10]] expect(new Range([2, 1], [3, 10]).union(new Range([2, 5], [3, 1]))).toEqual [[2, 1], [3, 10]] expect(new Range([2, 5], [3, 1]).union(new Range([2, 1], [3, 10]))).toEqual [[2, 1], [3, 10]] + + describe ".translate(startPoint, endPoint)", -> + it "returns a range translates by the specified start and end points", -> + expect(new Range([1, 1], [2, 10]).translate([1])).toEqual [[2, 1], [3, 10]] + expect(new Range([1, 1], [2, 10]).translate([1,2], [3,4])).toEqual [[2, 3], [5, 14]] diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index f0be412a5..c3eaa685a 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -369,9 +369,7 @@ class EditSession @foldBufferRow(foldedRow) for foldedRow in foldedRows - newStartPosition = [selection.start.row - 1, selection.start.column] - newEndPosition = [selection.end.row - 1, selection.end.column] - @setSelectedBufferRange([newStartPosition, newEndPosition], preserveFolds: true) + @setSelectedBufferRange(selection.translate([-1]), preserveFolds: true) moveLineDown: -> selection = @getSelectedBufferRange() @@ -408,9 +406,7 @@ class EditSession @foldBufferRow(foldedRow) for foldedRow in foldedRows - newStartPosition = [selection.start.row + 1, selection.start.column] - newEndPosition = [selection.end.row + 1, selection.end.column] - @setSelectedBufferRange([newStartPosition, newEndPosition], preserveFolds: true) + @setSelectedBufferRange(selection.translate([1]), preserveFolds: true) mutateSelectedText: (fn) -> diff --git a/src/app/point.coffee b/src/app/point.coffee index b740027f6..e471ad6c6 100644 --- a/src/app/point.coffee +++ b/src/app/point.coffee @@ -34,6 +34,10 @@ class Point new Point(row, column) + translate: (other) -> + other = Point.fromObject(other) + new Point(@row + other.row, @column + other.column) + splitAt: (column) -> if @row == 0 rightColumn = @column - column diff --git a/src/app/range.coffee b/src/app/range.coffee index 3464a3bce..136f52f15 100644 --- a/src/app/range.coffee +++ b/src/app/range.coffee @@ -48,6 +48,9 @@ class Range add: (point) -> new Range(@start.add(point), @end.add(point)) + translate: (startPoint, endPoint=startPoint) -> + new Range(@start.translate(startPoint), @end.translate(endPoint)) + intersectsWith: (otherRange) -> if @start.isLessThanOrEqual(otherRange.start) @end.isGreaterThanOrEqual(otherRange.start) From 5f343d74b21dd4658d562084eeadcea388ba4ebd Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 13:54:26 -0800 Subject: [PATCH 13/24] Use new EditSession.isFoldedAtBufferRow method when moving lines --- src/app/edit-session.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index c3eaa685a..e3a906e8a 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -348,7 +348,7 @@ class EditSession foldedRows = [] rows = [selection.start.row..selection.end.row] if selection.start.row isnt selection.end.row and selection.end.column is 0 - rows.pop() unless @isFoldedAtScreenRow(@screenPositionForBufferPosition(selection.end).row) + rows.pop() unless @isFoldedAtBufferRow(selection.end.row) for row in rows screenRow = @screenPositionForBufferPosition([row]).row if @isFoldedAtScreenRow(screenRow) @@ -381,7 +381,7 @@ class EditSession foldedRows = [] rows = [selection.end.row..selection.start.row] if selection.start.row isnt selection.end.row and selection.end.column is 0 - rows.shift() unless @isFoldedAtScreenRow(@screenPositionForBufferPosition(selection.end).row) + rows.shift() unless @isFoldedAtBufferRow(selection.end.row) for row in rows screenRow = @screenPositionForBufferPosition([row]).row if @isFoldedAtScreenRow(screenRow) From ed824469c15301584f479c17471f121ec69b92e8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 14:25:36 -0800 Subject: [PATCH 14/24] Add initial CONTRIBUTING.md Refs #189 --- CONTRIBUTING.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..ac09dc3e8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,20 @@ +# :rotating_light: Contributing to Atom :rotating_light: + +## Issues + * Include screenshots and animated GIFs whenever possible, they are immensely + helpful + * Include the behavior you expected to happen and other places you've seen + that behavior such as Emacs, vi, Xcode, etc. + * Check the Console app for stack traces to include if reporting a crash + * Check the Dev tools (`alt-cmd-i`) for errors and stack traces to include + +## Code + * Follow the [JavaScript](https://github.com/styleguide/javascript), + [CSS](https://github.com/styleguide/css), + and [Objective-C](https://github.com/github/objective-c-conventions) + styleguides + * Include thoughtfully worded [Jasmine](http://pivotal.github.com/jasmine/) + specs + * New packages go in `src/packages/` + * Add 3rd-party packages by submoduling in `vendor/packages/` + * Commit messages are in the present tense From d30532c6aacf4f46bb6282890468260f8fc1ec22 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 15:05:36 -0800 Subject: [PATCH 15/24] Show directory in tab when duplicate names are open Closes #181 --- src/packages/tabs/spec/tabs-spec.coffee | 18 ++++++++++++++++++ src/packages/tabs/src/tab.coffee | 16 ++++++++++++++-- src/packages/tabs/src/tabs-view.coffee | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index c3055d081..76558b301 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -118,3 +118,21 @@ describe "Tabs", -> tabs.find('.tab .close-icon:eq(1)').click() expect(editor.getActiveEditSessionIndex()).toBe 0 expect(editor.activeEditSession).toBe firstSession + + describe "when two tabs have the same file name", -> + [tempPath] = [] + + beforeEach -> + tempPath = '/tmp/sample.js' + fs.write(tempPath, 'sample') + + afterEach -> + fs.remove(tempPath) if fs.exists(tempPath) + + it "displays the parent folder name after the file name", -> + expect(tabs.find('.tab:eq(0) .file-name').text()).toBe 'sample.js' + rootView.open(tempPath) + expect(tabs.find('.tab:eq(0) .file-name').text()).toBe 'sample.js - fixtures' + expect(tabs.find('.tab:last .file-name').text()).toBe 'sample.js - tmp' + editor.destroyActiveEditSession() + expect(tabs.find('.tab:eq(0) .file-name').text()).toBe 'sample.js' diff --git a/src/packages/tabs/src/tab.coffee b/src/packages/tabs/src/tab.coffee index 6a26a114f..7bc1a8828 100644 --- a/src/packages/tabs/src/tab.coffee +++ b/src/packages/tabs/src/tab.coffee @@ -1,4 +1,5 @@ {View} = require 'space-pen' +fs = require 'fs' module.exports = class Tab extends View @@ -7,12 +8,14 @@ class Tab extends View @span class: 'file-name', outlet: 'fileName' @span class: 'close-icon' - initialize: (@editSession) -> + initialize: (@editSession, @editor) -> @buffer = @editSession.buffer @subscribe @buffer, 'path-changed', => @updateFileName() @subscribe @buffer, 'contents-modified', => @updateModifiedStatus() @subscribe @buffer, 'saved', => @updateModifiedStatus() @subscribe @buffer, 'git-status-changed', => @updateModifiedStatus() + @subscribe @editor, 'editor:edit-session-added', => @updateFileName() + @subscribe @editor, 'editor:edit-session-removed', => @updateFileName() @updateFileName() @updateModifiedStatus() @@ -25,4 +28,13 @@ class Tab extends View @isModified = false updateFileName: -> - @fileName.text(@editSession.buffer.getBaseName() ? 'untitled') + fileNameText = @editSession.buffer.getBaseName() + if fileNameText? + duplicates = @editor.getEditSessions().filter (session) -> fileNameText is session.buffer.getBaseName() + if duplicates.length > 1 + directory = fs.base(fs.directory(@editSession.getPath())) + fileNameText = "#{fileNameText} - #{directory}" if directory + else + fileNameText = 'untitled' + + @fileName.text(fileNameText) diff --git a/src/packages/tabs/src/tabs-view.coffee b/src/packages/tabs/src/tabs-view.coffee index e7322dc64..d2b21fa7c 100644 --- a/src/packages/tabs/src/tabs-view.coffee +++ b/src/packages/tabs/src/tabs-view.coffee @@ -34,7 +34,7 @@ class Tabs extends View false addTabForEditSession: (editSession) -> - @append(new Tab(editSession)) + @append(new Tab(editSession, @editor)) setActiveTab: (index) -> @find(".tab.active").removeClass('active') From 034281a6388fee9f94ac1b83d9bdc43df992f417 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 15:06:57 -0800 Subject: [PATCH 16/24] :lipstick: --- src/packages/tabs/spec/tabs-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index 76558b301..c36922a38 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -5,7 +5,7 @@ Tabs = require 'tabs' fs = require 'fs' describe "Tabs", -> - [rootView, editor, statusBar, buffer, tabs] = [] + [rootView, editor, buffer, tabs] = [] beforeEach -> rootView = new RootView(require.resolve('fixtures/sample.js')) From 8b3ade290406ee4881bc3aeb95acb1906f86766d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 15:08:23 -0800 Subject: [PATCH 17/24] Set path as tab title attribute --- src/packages/tabs/src/tab.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/packages/tabs/src/tab.coffee b/src/packages/tabs/src/tab.coffee index 7bc1a8828..6a8ba4338 100644 --- a/src/packages/tabs/src/tab.coffee +++ b/src/packages/tabs/src/tab.coffee @@ -38,3 +38,4 @@ class Tab extends View fileNameText = 'untitled' @fileName.text(fileNameText) + @fileName.attr('title', @editSession.getPath()) From 45d5e714fa43788cca4aa86a93daca02d9dfb0d9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 15:25:03 -0800 Subject: [PATCH 18/24] Make snippets keymaps valid CSON Closes #209 --- src/packages/snippets/keymaps/snippets-1.cson | 2 +- src/packages/snippets/keymaps/snippets-2.cson | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/snippets/keymaps/snippets-1.cson b/src/packages/snippets/keymaps/snippets-1.cson index c8bf63c51..ce982b6a2 100644 --- a/src/packages/snippets/keymaps/snippets-1.cson +++ b/src/packages/snippets/keymaps/snippets-1.cson @@ -1,2 +1,2 @@ -window.keymap.bindKeys '.editor' +'.editor': 'tab': 'snippets:expand' diff --git a/src/packages/snippets/keymaps/snippets-2.cson b/src/packages/snippets/keymaps/snippets-2.cson index 6b660c6fd..9cf7b49e5 100644 --- a/src/packages/snippets/keymaps/snippets-2.cson +++ b/src/packages/snippets/keymaps/snippets-2.cson @@ -1,6 +1,6 @@ # it's critical that these bindings be loaded after those snippets-1 so they # are later in the cascade, hence breaking the keymap into 2 files -window.keymap.bindKeys '.editor' +'.editor': 'tab': 'snippets:next-tab-stop' 'shift-tab': 'snippets:previous-tab-stop' From aeb1e3fd3ccdb91f0896fa55e18145875d1bd7c9 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 30 Jan 2013 16:53:36 -0700 Subject: [PATCH 19/24] Add a script to fix the author w/ git-filter-branch --- script/fix-author | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 script/fix-author diff --git a/script/fix-author b/script/fix-author new file mode 100755 index 000000000..bbbd3b3da --- /dev/null +++ b/script/fix-author @@ -0,0 +1,17 @@ +#!/bin/sh + +usage() { + echo "usage: $0 sha name email" + exit 1 +} + +if [ ! $3 ]; then + usage +fi + +git filter-branch -f --env-filter " +export GIT_AUTHOR_NAME='$2' +export GIT_AUTHOR_EMAIL='$3' +export GIT_COMMITTER_NAME='$2' +export GIT_COMMITTER_EMAIL='$3' +" -- $1..HEAD \ No newline at end of file From 4e7b1888b4789b03e79fb18b0eb08cf26c0c7811 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 30 Jan 2013 16:03:55 -0800 Subject: [PATCH 20/24] include ' in editor.nonWordCharacters --- src/app/editor.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 2234ece09..2769b6cba 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -20,7 +20,7 @@ class Editor extends View autosave: false autoIndent: true autoIndentOnPaste: false - nonWordCharacters: "./\\()\"’-_:,.;<>~!@#$%^&*|+=[]{}`~?" + nonWordCharacters: "./\\()\"'-_:,.;<>~!@#$%^&*|+=[]{}`~?" @content: (params) -> @div class: @classes(params), tabindex: -1, => From 45dfea055943ab025527ae63b5d452e3f672ff60 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 16:12:14 -0800 Subject: [PATCH 21/24] Start tracking commands when package is activated When the command logger was moved to a deferred package the custom trigger to track events wasn't registered until the instance was created causing most events to go untracked. Now the custom trigger is registered in the index.coffee file and passed to the view instance when toggling. --- src/packages/command-logger/index.coffee | 24 ++++++++++++++++++- .../src/command-logger-view.coffee | 24 +++---------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/packages/command-logger/index.coffee b/src/packages/command-logger/index.coffee index 39dd9ad68..027035980 100644 --- a/src/packages/command-logger/index.coffee +++ b/src/packages/command-logger/index.coffee @@ -1,4 +1,5 @@ DeferredAtomPackage = require 'deferred-atom-package' +$ = require 'jquery' module.exports = class CommandLogger extends DeferredAtomPackage @@ -7,4 +8,25 @@ class CommandLogger extends DeferredAtomPackage instanceClass: 'command-logger/src/command-logger-view' - onLoadEvent: (event, instance) -> instance.toggle() + activate: (rootView, state={})-> + super + + @eventLog = state.eventLog ? {} + rootView.command 'command-logger:clear-data', => @eventLog = {} + + registerTriggeredEvent = (eventName) => + eventNameLog = @eventLog[eventName] + unless eventNameLog + eventNameLog = + count: 0 + name: eventName + @eventLog[eventName] = eventNameLog + eventNameLog.count++ + eventNameLog.lastRun = new Date().getTime() + originalTrigger = $.fn.trigger + $.fn.trigger = (eventName) -> + eventName = eventName.type if eventName.type + registerTriggeredEvent(eventName) if $(this).events()[eventName] + originalTrigger.apply(this, arguments) + + onLoadEvent: (event, instance) -> instance.toggle(@eventLog) diff --git a/src/packages/command-logger/src/command-logger-view.coffee b/src/packages/command-logger/src/command-logger-view.coffee index 01496a2d0..4a5f89df5 100644 --- a/src/packages/command-logger/src/command-logger-view.coffee +++ b/src/packages/command-logger/src/command-logger-view.coffee @@ -1,12 +1,11 @@ {$$$} = require 'space-pen' ScrollView = require 'scroll-view' -$ = require 'jquery' _ = require 'underscore' module.exports = class CommandLoggerView extends ScrollView @activate: (rootView, state) -> - @instance = new CommandLoggerView(rootView, state?.eventLog) + @instance = new CommandLoggerView(rootView) @content: (rootView) -> @div class: 'command-logger', tabindex: -1, => @@ -31,29 +30,12 @@ class CommandLoggerView extends ScrollView 'tree-view:directory-modified' ] - initialize: (@rootView, @eventLog={}) -> + initialize: (@rootView) -> super - @rootView.command 'command-logger:clear-data', => @eventLog = {} @command 'core:cancel', => @detach() - registerEvent = (eventName) => - eventNameLog = @eventLog[eventName] - unless eventNameLog - eventNameLog = - count: 0 - name: eventName - @eventLog[eventName] = eventNameLog - eventNameLog.count++ - eventNameLog.lastRun = new Date().getTime() - - originalTrigger = $.fn.trigger - $.fn.trigger = (eventName) -> - eventName = eventName.type if eventName.type - registerEvent(eventName) if $(this).events()[eventName] - originalTrigger.apply(this, arguments) - - toggle: -> + toggle: (@eventLog={}) -> if @hasParent() @detach() else From 9a2db263932a238bc6ded6e79cd656c2a0c54093 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 17:54:16 -0800 Subject: [PATCH 22/24] Set white-space property to nowrap on editor lines Allows inline-block elements adding to the line to no be wrapped when the window is resized. Closes #211 --- static/editor.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/editor.css b/static/editor.css index 0b8cfb452..66d71d345 100644 --- a/static/editor.css +++ b/static/editor.css @@ -104,3 +104,7 @@ pointer-events: none; z-index: -1; } + +.editor .line { + white-space: nowrap; +} From 983f1ab18b08cd226e7dd29b6b048347cb7f80ea Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 18:32:08 -0800 Subject: [PATCH 23/24] Bind meta-~ to focus previous window Closes #212 --- native/atom_cef_client.cpp | 2 ++ native/atom_cef_client.h | 1 + native/atom_cef_client_mac.mm | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/native/atom_cef_client.cpp b/native/atom_cef_client.cpp index 38c25470b..3acb53951 100644 --- a/native/atom_cef_client.cpp +++ b/native/atom_cef_client.cpp @@ -141,6 +141,8 @@ bool AtomCefClient::OnKeyEvent(CefRefPtr browser, ToggleDevTools(browser); } else if (event.modifiers == EVENTFLAG_COMMAND_DOWN && event.unmodified_character == '`') { FocusNextWindow(); + } else if (event.modifiers == (EVENTFLAG_COMMAND_DOWN | EVENTFLAG_SHIFT_DOWN) && event.unmodified_character == '~') { + FocusPreviousWindow(); } else { return false; diff --git a/native/atom_cef_client.h b/native/atom_cef_client.h index 75b787138..d1961d8d3 100644 --- a/native/atom_cef_client.h +++ b/native/atom_cef_client.h @@ -105,6 +105,7 @@ class AtomCefClient : public CefClient, bool m_HandlePasteboardCommands = false; void FocusNextWindow(); + void FocusPreviousWindow(); void Open(std::string path); void Open(); void OpenUnstable(std::string path); diff --git a/native/atom_cef_client_mac.mm b/native/atom_cef_client_mac.mm index c20bd5fbe..be4879d97 100644 --- a/native/atom_cef_client_mac.mm +++ b/native/atom_cef_client_mac.mm @@ -23,6 +23,24 @@ void AtomCefClient::FocusNextWindow() { } } +void AtomCefClient::FocusPreviousWindow() { + NSArray *windows = [NSApp windows]; + int count = [windows count]; + int start = [windows indexOfObject:[NSApp keyWindow]]; + + int i = start; + while (true) { + i = i - 1; + if (i == 0) i = count -1; + if (i == start) break; + NSWindow *window = [windows objectAtIndex:i]; + if ([window isVisible] && ![window isExcludedFromWindowsMenu]) { + [window makeKeyAndOrderFront:nil]; + break; + } + } +} + void AtomCefClient::Open(std::string path) { NSString *pathString = [NSString stringWithCString:path.c_str() encoding:NSUTF8StringEncoding]; [(AtomApplication *)[AtomApplication sharedApplication] open:pathString]; From f126f589210a5e6e359efa1ff9e74395a7f670fb Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 30 Jan 2013 19:18:10 -0800 Subject: [PATCH 24/24] Revert "Set white-space property to nowrap on editor lines" This reverts commit 9a2db263932a238bc6ded6e79cd656c2a0c54093. --- static/editor.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/static/editor.css b/static/editor.css index 66d71d345..0b8cfb452 100644 --- a/static/editor.css +++ b/static/editor.css @@ -104,7 +104,3 @@ pointer-events: none; z-index: -1; } - -.editor .line { - white-space: nowrap; -}