mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-06 23:26:25 +03:00
Status bar path and cursor position updates
This commit is contained in:
parent
798da4c79a
commit
37438c6da8
@ -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'
|
||||
|
@ -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}")
|
||||
|
||||
|
@ -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;
|
||||
|
@ -6,8 +6,10 @@
|
||||
color: white;
|
||||
cursor: default;
|
||||
-webkit-user-select: none;
|
||||
-webkit-box-flex: 1;
|
||||
}
|
||||
|
||||
|
||||
.editor.mini {
|
||||
height: auto;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user