diff --git a/spec/app/status-bar-spec.coffee b/spec/app/status-bar-spec.coffee index b1e7063ed..4d0bc3120 100644 --- a/spec/app/status-bar-spec.coffee +++ b/spec/app/status-bar-spec.coffee @@ -2,27 +2,28 @@ $ = require 'jquery' RootView = require 'root-view' StatusBar = require 'status-bar' -fdescribe "StatusBar", -> - [rootView, statusBar] = [] +describe "StatusBar", -> + [rootView, editor, statusBar] = [] beforeEach -> rootView = new RootView(pathToOpen: require.resolve('fixtures/sample.js')) rootView.simulateDomAttachment() StatusBar.activate(rootView) + editor = rootView.activeEditor() statusBar = rootView.find('.status-bar').view() describe "@initialize", -> it "appends a status bar to all existing and new editors", -> expect(rootView.panes.find('.pane').length).toBe 1 expect(rootView.panes.find('.pane > .status-bar').length).toBe 1 - rootView.activeEditor().splitRight() + editor.splitRight() expect(rootView.find('.pane').length).toBe 2 expect(rootView.panes.find('.pane > .status-bar').length).toBe 2 describe ".initialize(editor)", -> it "displays the editor's buffer path and cursor buffer position", -> expect(statusBar.currentPath.text()).toBe 'sample.js' - expect(statusBar.cursorPosition.text()).toBe '0,0' + 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", -> @@ -31,4 +32,14 @@ fdescribe "StatusBar", -> StatusBar.activate(rootView) statusBar = rootView.find('.status-bar').view() expect(statusBar.currentPath.text()).toBe 'untitled' - expect(statusBar.cursorPosition.text()).toBe '0,0' + expect(statusBar.cursorPosition.text()).toBe '1,1' + + describe "when the associated editor's path changes", -> + it "updates the path in the status bar", -> + rootView.open(require.resolve 'fixtures/sample.txt') + expect(statusBar.currentPath.text()).toBe 'sample.txt' + + 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' diff --git a/src/app/status-bar.coffee b/src/app/status-bar.coffee index 5b477357b..bc21fc5fb 100644 --- a/src/app/status-bar.coffee +++ b/src/app/status-bar.coffee @@ -21,11 +21,20 @@ class StatusBar extends View @div class: 'cursor-position', outlet: 'cursorPosition' initialize: (@rootView, @editor) -> + @updatePathText() + @editor.on 'editor-path-change', => @updatePathText() + + @updateCursorPositionText() + @editor.on 'cursor-move', => @updateCursorPositionText() + + updatePathText: -> path = @editor.buffer.path if path @currentPath.text(@rootView.project.relativize(path)) else @currentPath.text('untitled') - position = @editor.getCursorBufferPosition() - @cursorPosition.text("#{position.row},#{position.column}") + updateCursorPositionText: -> + { row, column } = @editor.getCursorBufferPosition() + @cursorPosition.text("#{row + 1},#{column + 1}") + diff --git a/static/atom.css b/static/atom.css index 2554b1d1a..caa836427 100644 --- a/static/atom.css +++ b/static/atom.css @@ -42,6 +42,8 @@ body { #root-view #panes .pane { position: absolute; + display: -webkit-box; + -webkit-box-orient: vertical; width: 100%; height: 100%; box-sizing: border-box; diff --git a/static/editor.css b/static/editor.css index d4c54f180..f31524bbf 100644 --- a/static/editor.css +++ b/static/editor.css @@ -6,8 +6,10 @@ color: white; cursor: default; -webkit-user-select: none; + -webkit-box-flex: 1; } + .editor.mini { height: auto; } diff --git a/static/status-bar.css b/static/status-bar.css index aa8847337..cbe86bb1f 100644 --- a/static/status-bar.css +++ b/static/status-bar.css @@ -1,11 +1,8 @@ .status-bar { - position: absolute; - bottom: 0; - left: 0; - right: 0; background: black; color: white; padding: 5px; + position: relative; } .status-bar .cursor-position {