mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
StatusBar.initialize appends a status bar view to every current and future editor pane
This commit is contained in:
parent
5b67feff54
commit
a5a573d732
19
spec/app/status-bar-spec.coffee
Normal file
19
spec/app/status-bar-spec.coffee
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
$ = require 'jquery'
|
||||||
|
RootView = require 'root-view'
|
||||||
|
StatusBar = require 'status-bar'
|
||||||
|
|
||||||
|
describe "StatusBar", ->
|
||||||
|
rootView = null
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
rootView = new RootView
|
||||||
|
rootView.simulateDomAttachment()
|
||||||
|
StatusBar.initialize(rootView)
|
||||||
|
|
||||||
|
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()
|
||||||
|
expect(rootView.find('.pane').length).toBe 2
|
||||||
|
expect(rootView.panes.find('.pane > .status-bar').length).toBe 2
|
@ -124,6 +124,9 @@ $.fn.enableKeymap = ->
|
|||||||
$.fn.attachToDom = ->
|
$.fn.attachToDom = ->
|
||||||
$('#jasmine-content').append(this)
|
$('#jasmine-content').append(this)
|
||||||
|
|
||||||
|
$.fn.simulateDomAttachment = ->
|
||||||
|
$('<html>').append(this)
|
||||||
|
|
||||||
$.fn.textInput = (data) ->
|
$.fn.textInput = (data) ->
|
||||||
event = document.createEvent 'TextEvent'
|
event = document.createEvent 'TextEvent'
|
||||||
event.initTextEvent('textInput', true, true, window, data)
|
event.initTextEvent('textInput', true, true, window, data)
|
||||||
|
@ -39,6 +39,7 @@ class Editor extends View
|
|||||||
softTabs: true
|
softTabs: true
|
||||||
tabText: ' '
|
tabText: ' '
|
||||||
editSessions: null
|
editSessions: null
|
||||||
|
attached: false
|
||||||
|
|
||||||
@deserialize: (viewState) ->
|
@deserialize: (viewState) ->
|
||||||
new Editor(viewState)
|
new Editor(viewState)
|
||||||
@ -188,11 +189,14 @@ class Editor extends View
|
|||||||
else
|
else
|
||||||
@gutter.addClass('drop-shadow')
|
@gutter.addClass('drop-shadow')
|
||||||
|
|
||||||
@on 'attach', =>
|
@on 'attach', (e) =>
|
||||||
|
return if @attached or e.target != this[0]
|
||||||
|
@attached = true
|
||||||
@calculateDimensions()
|
@calculateDimensions()
|
||||||
@hiddenInput.width(@charWidth)
|
@hiddenInput.width(@charWidth)
|
||||||
@setMaxLineLength() if @softWrap
|
@setMaxLineLength() if @softWrap
|
||||||
@focus() if @isFocused
|
@focus() if @isFocused
|
||||||
|
@trigger 'editor-open', [this]
|
||||||
|
|
||||||
rootView: ->
|
rootView: ->
|
||||||
@parents('#root-view').view()
|
@parents('#root-view').view()
|
||||||
|
19
src/app/status-bar.coffee
Normal file
19
src/app/status-bar.coffee
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{View} = require 'space-pen'
|
||||||
|
|
||||||
|
module.exports =
|
||||||
|
class StatusBar extends View
|
||||||
|
@initialize: (rootView) ->
|
||||||
|
for editor in rootView.editors()
|
||||||
|
@appendToEditorPane(editor)
|
||||||
|
|
||||||
|
rootView.on 'editor-open', (e, editor) =>
|
||||||
|
@appendToEditorPane(editor)
|
||||||
|
|
||||||
|
@appendToEditorPane: (editor) ->
|
||||||
|
if pane = editor.pane()
|
||||||
|
pane.append(new StatusBar(editor))
|
||||||
|
|
||||||
|
@content: ->
|
||||||
|
@div class: 'status-bar'
|
||||||
|
|
||||||
|
initialize: (@editor) ->
|
Loading…
Reference in New Issue
Block a user