From 14ca7509321df0b1c66dad7c6fb396bb3d675f20 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Tue, 25 Dec 2012 11:18:13 -0800 Subject: [PATCH 1/9] Changing around the status bar html --- src/packages/status-bar/src/status-bar.coffee | 18 +++--- static/status-bar.css | 62 +++++++++++-------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/packages/status-bar/src/status-bar.coffee b/src/packages/status-bar/src/status-bar.coffee index 744304287..ade0e798d 100644 --- a/src/packages/status-bar/src/status-bar.coffee +++ b/src/packages/status-bar/src/status-bar.coffee @@ -19,15 +19,15 @@ class StatusBar extends View @content: -> @div class: 'status-bar', => - @div class: 'file-info', => + @span class: 'git-branch', outlet: 'branchArea', => + @span class: 'octicons branch-icon' + @span class: 'branch-label', outlet: 'branchLabel' + @span class: 'git-status', outlet: 'gitStatusIcon' + @span class: 'cursor-position', outlet: 'cursorPosition' + @span class: 'file-info', => @span class: 'current-path', outlet: 'currentPath' @span class: 'buffer-modified', outlet: 'bufferModified' - @div class: 'cursor-position', => - @span outlet: 'gitStatusIcon' - @span outlet: 'branchArea', => - @span class: 'octicons branch-icon' - @span class: 'branch-label', outlet: 'branchLabel' - @span outlet: 'cursorPosition' + initialize: (@rootView, @editor) -> @updatePathText() @@ -76,7 +76,7 @@ class StatusBar extends View @gitStatusIcon.empty() return unless path - @gitStatusIcon.removeClass().addClass('octicons') + @gitStatusIcon.removeClass().addClass('git-status octicons') if @buffer.getGit()?.isPathModified(path) @gitStatusIcon.addClass('modified-status-icon') else if @buffer.getGit()?.isPathNew(path) @@ -90,4 +90,4 @@ class StatusBar extends View updateCursorPositionText: -> { row, column } = @editor.getCursorBufferPosition() - @cursorPosition.text("#{row + 1},#{column + 1}") + @cursorPosition.text("Line #{row + 1}, Column #{column + 1}") diff --git a/static/status-bar.css b/static/status-bar.css index 9554c0455..38011d579 100644 --- a/static/status-bar.css +++ b/static/status-bar.css @@ -1,37 +1,29 @@ .status-bar { - background: black; - color: white; - padding: 5px; + background-image: -webkit-linear-gradient(#303030, #252525); + border-top: 1px solid #454545; + padding: 4px 10px 3px; + font-size: 11px; + line-height: 14px; + color: #969696; position: relative; } -.status-bar .file-info { - float: left; - display: inline-block; -} - .status-bar .cursor-position { - position: absolute; - right: 5px; - top: 5px; + padding-right: 20px; } -.status-bar .modified-status-icon { - color: #6C6912; - padding-right: 5px; +.status-bar .git-branch { + float: right; } -.status-bar .modified-status-icon:before { - content: "\f26d"; +.status-bar .branch-label { + padding-left: 5px; + vertical-align: baseline; } -.status-bar .new-status-icon { - color: #269F81; - padding-right: 5px; -} - -.status-bar .new-status-icon:before { - content: "\f26b"; +.status-bar .git-status.octicons { + display: none; + padding-left: 10px; } .status-bar .octicons { @@ -39,13 +31,31 @@ font-size: 14px; width: 14px; height: 14px; + line-height: 14px; + -webkit-font-smoothing: antialiased; + display: inline-block; + vertical-align: middle; } .status-bar .branch-icon:before { content: "\f020"; } -.status-bar .branch-label { - padding-left: 5px; - padding-right: 10px; +.status-bar .git-status.octicons.modified-status-icon { + color: #6C6912; + display: inline-block; } + +.status-bar .modified-status-icon:before { + content: "\f26d"; +} + +.status-bar .git-status.octicons.new-status-icon { + color: #269F81; + display: inline-block; +} + +.status-bar .new-status-icon:before { + content: "\f26b"; +} + From cf66892b094cc2e52626ec8df105ff2b0f979ec6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 26 Dec 2012 11:36:35 -0800 Subject: [PATCH 2/9] :lipstick: --- spec/app/text-mate-grammar-spec.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/app/text-mate-grammar-spec.coffee b/spec/app/text-mate-grammar-spec.coffee index 16b15e5fa..96c860306 100644 --- a/spec/app/text-mate-grammar-spec.coffee +++ b/spec/app/text-mate-grammar-spec.coffee @@ -242,12 +242,12 @@ describe "TextMateGrammar", -> expect(tokens[0].value).toBe "//" expect(tokens[1].value).toBe " a singleLineComment" - it "does not loop infinitley (regression)", -> + it "does not loop infinitely (regression)", -> grammar = TextMateBundle.grammarForFilePath("hello.js") {tokens, ruleStack} = grammar.tokenizeLine("// line comment") {tokens, ruleStack} = grammar.tokenizeLine(" // second line comment with a single leading space", ruleStack) - describe "when inside an C block", -> + describe "when inside a C block", -> it "correctly parses a method. (regression)", -> grammar = TextMateBundle.grammarForFilePath("hello.c") {tokens, ruleStack} = grammar.tokenizeLine("if(1){m()}") From f592242737dddaf86d507816b27d6ba2fa715e44 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 26 Dec 2012 11:41:50 -0800 Subject: [PATCH 3/9] Terminate when no more tokens and at end of line This corrects a regression when pattern matching to the newline was added. If the newline is never matched the loop still needs to terminated so now when the position is before the newline and the last match had no tokens the loop is broken out of. --- spec/app/tokenized-buffer-spec.coffee | 17 +++++++++++++++++ spec/fixtures/hello.rb | 3 +++ src/app/text-mate-grammar.coffee | 1 + 3 files changed, 21 insertions(+) create mode 100644 spec/fixtures/hello.rb diff --git a/spec/app/tokenized-buffer-spec.coffee b/spec/app/tokenized-buffer-spec.coffee index 2eb7b74fb..7fbff436b 100644 --- a/spec/app/tokenized-buffer-spec.coffee +++ b/spec/app/tokenized-buffer-spec.coffee @@ -383,3 +383,20 @@ describe "TokenizedBuffer", -> expect(tokens[0].scopes).toEqual ["source.c++", "meta.preprocessor.c.include"] expect(tokens[1].value).toBe 'include' expect(tokens[1].scopes).toEqual ["source.c++", "meta.preprocessor.c.include", "keyword.control.import.include.c"] + + describe "when a Ruby source file is tokenized", -> + beforeEach -> + editSession = fixturesProject.buildEditSessionForPath('hello.rb', autoIndent: false) + buffer = editSession.buffer + tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer + editSession.setVisible(true) + fullyTokenize(tokenizedBuffer) + + afterEach -> + editSession.destroy() + + it "doesn't loop infinitely (regression)", -> + expect(tokenizedBuffer.lineForScreenRow(0).text).toBe 'a = {' + expect(tokenizedBuffer.lineForScreenRow(1).text).toBe ' "b" => "c",' + expect(tokenizedBuffer.lineForScreenRow(2).text).toBe '}' + expect(tokenizedBuffer.lineForScreenRow(3).text).toBe '' diff --git a/spec/fixtures/hello.rb b/spec/fixtures/hello.rb new file mode 100644 index 000000000..7cd6688c7 --- /dev/null +++ b/spec/fixtures/hello.rb @@ -0,0 +1,3 @@ +a = { + "b" => "c", +} diff --git a/src/app/text-mate-grammar.coffee b/src/app/text-mate-grammar.coffee index dbba03344..28c599528 100644 --- a/src/app/text-mate-grammar.coffee +++ b/src/app/text-mate-grammar.coffee @@ -53,6 +53,7 @@ class TextMateGrammar tokens.push(nextTokens...) position = tokensEndPosition + break if position is line.length and nextTokens.length is 0 else # push filler token for unmatched text at end of line if position < line.length From 4a46e9f32a444353322408c72b53d3c0ee49d0c3 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Wed, 26 Dec 2012 11:49:57 -0800 Subject: [PATCH 4/9] fuzzy finder is high on the z-index --- static/fuzzy-finder.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/fuzzy-finder.css b/static/fuzzy-finder.css index 5f3456371..cf297a948 100644 --- a/static/fuzzy-finder.css +++ b/static/fuzzy-finder.css @@ -1,3 +1,7 @@ +.fuzzy-finder { + z-index: 99; +} + .fuzzy-finder ol { overflow: hidden; margin-bottom: 5px; From ab407a297ad55aaf96c72adfaea096bc5de78fc3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 26 Dec 2012 11:51:22 -0800 Subject: [PATCH 5/9] Put z-index on select-list class --- static/fuzzy-finder.css | 4 ---- static/select-list.css | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/static/fuzzy-finder.css b/static/fuzzy-finder.css index cf297a948..5f3456371 100644 --- a/static/fuzzy-finder.css +++ b/static/fuzzy-finder.css @@ -1,7 +1,3 @@ -.fuzzy-finder { - z-index: 99; -} - .fuzzy-finder ol { overflow: hidden; margin-bottom: 5px; diff --git a/static/select-list.css b/static/select-list.css index a9b099bf9..7adc209ff 100644 --- a/static/select-list.css +++ b/static/select-list.css @@ -9,6 +9,7 @@ color: #eee; -webkit-box-shadow: 0 0 5px 5px #222; padding: 5px; + z-index: 99; } .select-list ol { From a9b9c09a86beeb5bc0952c6aadfe530c80855df1 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 26 Dec 2012 12:48:38 -0800 Subject: [PATCH 6/9] Only show wrap guide when enough space Previously the wrap guide would cause the editor to scroll if the editor was narrower than the wrap guide column without taking into account whether any lines actually reach the guide. Now the wrap guide only displays when either the wrap guide column is less than the minimum width of the editor layer or if the wrap guide column is less than the entire width of the editor. --- src/app/editor.coffee | 1 + .../wrap-guide/spec/wrap-guide-spec.coffee | 15 ++++++++++++--- src/packages/wrap-guide/src/wrap-guide.coffee | 18 ++++++++++++------ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 4e9e97cb0..446a82b1b 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -759,6 +759,7 @@ class Editor extends View @underlayer.css('min-width', minWidth) @overlayer.css('min-width', minWidth) @layerMinWidth = minWidth + @trigger 'editor:min-width-changed' clearRenderedLines: -> @renderedLines.empty() diff --git a/src/packages/wrap-guide/spec/wrap-guide-spec.coffee b/src/packages/wrap-guide/spec/wrap-guide-spec.coffee index 82129d6dd..1bc562624 100644 --- a/src/packages/wrap-guide/spec/wrap-guide-spec.coffee +++ b/src/packages/wrap-guide/spec/wrap-guide-spec.coffee @@ -10,6 +10,7 @@ describe "WrapGuide", -> rootView.attachToDom() editor = rootView.getActiveEditor() wrapGuide = rootView.find('.wrap-guide').view() + editor.width(editor.charWidth * wrapGuide.defaultColumn * 2) afterEach -> rootView.deactivate() @@ -27,6 +28,7 @@ describe "WrapGuide", -> width = editor.charWidth * wrapGuide.defaultColumn expect(width).toBeGreaterThan(0) expect(wrapGuide.position().left).toBe(width) + expect(wrapGuide).toBeVisible() describe "when the font size changes", -> it "updates the wrap guide position", -> @@ -34,6 +36,7 @@ describe "WrapGuide", -> expect(initial).toBeGreaterThan(0) rootView.trigger('window:increase-font-size') expect(wrapGuide.position().left).toBeGreaterThan(initial) + expect(wrapGuide).toBeVisible() describe "overriding getGuideColumn", -> it "invokes the callback with the editor path", -> @@ -41,7 +44,7 @@ describe "WrapGuide", -> wrapGuide.getGuideColumn = (path) -> editorPath = path 80 - wrapGuide.updateGuide(editor) + wrapGuide.updateGuide() expect(editorPath).toBe(require.resolve('fixtures/sample.js')) it "invokes the callback with a default value", -> @@ -51,7 +54,7 @@ describe "WrapGuide", -> column = defaultColumn defaultColumn - wrapGuide.updateGuide(editor) + wrapGuide.updateGuide() expect(column).toBeGreaterThan(0) # this is disabled because we no longer support passing config to an extension @@ -68,5 +71,11 @@ describe "WrapGuide", -> it "hides the guide when the column is less than 1", -> wrapGuide.getGuideColumn = (path) -> -1 - wrapGuide.updateGuide(editor) + wrapGuide.updateGuide() + expect(wrapGuide).toBeHidden() + + describe "when no lines exceed the guide column and the editor width is smaller than the guide column position", -> + it "hides the guide", -> + editor.width(10) + wrapGuide.updateGuide() expect(wrapGuide).toBeHidden() diff --git a/src/packages/wrap-guide/src/wrap-guide.coffee b/src/packages/wrap-guide/src/wrap-guide.coffee index 752443e95..8442cc736 100644 --- a/src/packages/wrap-guide/src/wrap-guide.coffee +++ b/src/packages/wrap-guide/src/wrap-guide.coffee @@ -1,4 +1,5 @@ {View} = require 'space-pen' +$ = require 'jquery' module.exports = class WrapGuide extends View @@ -28,13 +29,18 @@ class WrapGuide extends View else @getGuideColumn = (path, defaultColumn) -> defaultColumn - @observeConfig 'editor.fontSize', => @updateGuide(@editor) - @subscribe @editor, 'editor-path-change', => @updateGuide(@editor) - @subscribe @editor, 'before-remove', => @rootView.off('.wrap-guide') + @observeConfig 'editor.fontSize', => @updateGuide() + @subscribe @editor, 'editor-path-change', => @updateGuide() + @subscribe @editor, 'editor:min-width-changed', => @updateGuide() + @subscribe $(window), 'resize', => @updateGuide() - updateGuide: (editor) -> - column = @getGuideColumn(editor.getPath(), @defaultColumn) + updateGuide: -> + column = @getGuideColumn(@editor.getPath(), @defaultColumn) if column > 0 - @css('left', "#{editor.charWidth * column}px").show() + columnWidth = @editor.charWidth * column + if columnWidth < @editor.layerMinWidth or columnWidth < @editor.width() + @css('left', "#{columnWidth}px").show() + else + @hide() else @hide() From b737977c613c635b5479fe76dba4f95b6929be8e Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Wed, 26 Dec 2012 12:52:01 -0800 Subject: [PATCH 7/9] fixin spec tests --- src/packages/status-bar/spec/status-bar-spec.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packages/status-bar/spec/status-bar-spec.coffee b/src/packages/status-bar/spec/status-bar-spec.coffee index 3f9f47d11..4cb099e25 100644 --- a/src/packages/status-bar/spec/status-bar-spec.coffee +++ b/src/packages/status-bar/spec/status-bar-spec.coffee @@ -30,7 +30,7 @@ describe "StatusBar", -> it "displays the editor's buffer path, cursor buffer position, and buffer modified indicator", -> expect(statusBar.currentPath.text()).toBe 'sample.js' expect(statusBar.bufferModified.text()).toBe '' - expect(statusBar.cursorPosition.text()).toBe '1,1' + expect(statusBar.cursorPosition.text()).toBe 'Line 1, Column 1' describe "when associated with an unsaved buffer", -> it "displays 'untitled' instead of the buffer's path, but still displays the buffer position", -> @@ -41,7 +41,7 @@ describe "StatusBar", -> StatusBar.activate(rootView) statusBar = rootView.find('.status-bar').view() expect(statusBar.currentPath.text()).toBe 'untitled' - expect(statusBar.cursorPosition.text()).toBe '1,1' + expect(statusBar.cursorPosition.text()).toBe 'Line 1, Column 1' describe "when the associated editor's path changes", -> it "updates the path in the status bar", -> @@ -105,7 +105,7 @@ describe "StatusBar", -> describe "when the associated editor's cursor position changes", -> it "updates the cursor position in the status bar", -> editor.setCursorScreenPosition([1, 2]) - expect(statusBar.cursorPosition.text()).toBe '2,3' + expect(statusBar.cursorPosition.text()).toBe 'Line 2, Column 3' describe "git branch label", -> beforeEach -> From ca39b9dccb864b45b9dc0d0a245477066a704ce7 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Wed, 26 Dec 2012 13:06:27 -0800 Subject: [PATCH 8/9] re-organizing the cursor position text --- src/packages/status-bar/spec/status-bar-spec.coffee | 6 +++--- src/packages/status-bar/src/status-bar.coffee | 4 ++-- static/status-bar.css | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/packages/status-bar/spec/status-bar-spec.coffee b/src/packages/status-bar/spec/status-bar-spec.coffee index 4cb099e25..3f9f47d11 100644 --- a/src/packages/status-bar/spec/status-bar-spec.coffee +++ b/src/packages/status-bar/spec/status-bar-spec.coffee @@ -30,7 +30,7 @@ describe "StatusBar", -> it "displays the editor's buffer path, cursor buffer position, and buffer modified indicator", -> expect(statusBar.currentPath.text()).toBe 'sample.js' expect(statusBar.bufferModified.text()).toBe '' - expect(statusBar.cursorPosition.text()).toBe 'Line 1, Column 1' + expect(statusBar.cursorPosition.text()).toBe '1,1' describe "when associated with an unsaved buffer", -> it "displays 'untitled' instead of the buffer's path, but still displays the buffer position", -> @@ -41,7 +41,7 @@ describe "StatusBar", -> StatusBar.activate(rootView) statusBar = rootView.find('.status-bar').view() expect(statusBar.currentPath.text()).toBe 'untitled' - expect(statusBar.cursorPosition.text()).toBe 'Line 1, Column 1' + expect(statusBar.cursorPosition.text()).toBe '1,1' describe "when the associated editor's path changes", -> it "updates the path in the status bar", -> @@ -105,7 +105,7 @@ describe "StatusBar", -> describe "when the associated editor's cursor position changes", -> it "updates the cursor position in the status bar", -> editor.setCursorScreenPosition([1, 2]) - expect(statusBar.cursorPosition.text()).toBe 'Line 2, Column 3' + expect(statusBar.cursorPosition.text()).toBe '2,3' describe "git branch label", -> beforeEach -> diff --git a/src/packages/status-bar/src/status-bar.coffee b/src/packages/status-bar/src/status-bar.coffee index ade0e798d..83a3e4833 100644 --- a/src/packages/status-bar/src/status-bar.coffee +++ b/src/packages/status-bar/src/status-bar.coffee @@ -23,10 +23,10 @@ class StatusBar extends View @span class: 'octicons branch-icon' @span class: 'branch-label', outlet: 'branchLabel' @span class: 'git-status', outlet: 'gitStatusIcon' - @span class: 'cursor-position', outlet: 'cursorPosition' @span class: 'file-info', => @span class: 'current-path', outlet: 'currentPath' @span class: 'buffer-modified', outlet: 'bufferModified' + @span class: 'cursor-position', outlet: 'cursorPosition' initialize: (@rootView, @editor) -> @@ -90,4 +90,4 @@ class StatusBar extends View updateCursorPositionText: -> { row, column } = @editor.getCursorBufferPosition() - @cursorPosition.text("Line #{row + 1}, Column #{column + 1}") + @cursorPosition.text("#{row + 1},#{column + 1}") diff --git a/static/status-bar.css b/static/status-bar.css index 38011d579..97437e161 100644 --- a/static/status-bar.css +++ b/static/status-bar.css @@ -9,7 +9,7 @@ } .status-bar .cursor-position { - padding-right: 20px; + padding-left: 10px; } .status-bar .git-branch { From 7cdf12deadfe783a972b98620c00cd4912330537 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Wed, 26 Dec 2012 13:10:48 -0800 Subject: [PATCH 9/9] updating status bar colors --- static/status-bar.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/status-bar.css b/static/status-bar.css index 97437e161..b3e6c1069 100644 --- a/static/status-bar.css +++ b/static/status-bar.css @@ -24,6 +24,7 @@ .status-bar .git-status.octicons { display: none; padding-left: 10px; + margin-top:-2px; } .status-bar .octicons { @@ -42,7 +43,7 @@ } .status-bar .git-status.octicons.modified-status-icon { - color: #6C6912; + color: #f78a46; display: inline-block; } @@ -51,7 +52,7 @@ } .status-bar .git-status.octicons.new-status-icon { - color: #269F81; + color: #5293d8; display: inline-block; }