]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/lib/status-bar-manager.coffee
82e35e1d361e2d8fd94463766fee18b3ad4b1f88
[rbdr/dotfiles] / atom / packages / vim-mode / lib / status-bar-manager.coffee
1 {Disposable, CompositeDisposable} = require 'event-kit'
2
3 ContentsByMode =
4 'insert': ["status-bar-vim-mode-insert", "Insert"]
5 'insert.replace': ["status-bar-vim-mode-insert", "Replace"]
6 'command': ["status-bar-vim-mode-command", "Command"]
7 'visual': ["status-bar-vim-mode-visual", "Visual"]
8 'visual.characterwise': ["status-bar-vim-mode-visual", "Visual"]
9 'visual.linewise': ["status-bar-vim-mode-visual", "Visual Line"]
10 'visual.blockwise': ["status-bar-vim-mode-visual", "Visual Block"]
11
12 module.exports =
13 class StatusBarManager
14 constructor: ->
15 @element = document.createElement("div")
16 @element.id = "status-bar-vim-mode"
17
18 @container = document.createElement("div")
19 @container.className = "inline-block"
20 @container.appendChild(@element)
21
22 initialize: (@statusBar) ->
23
24 update: (currentMode, currentSubmode) ->
25 currentMode = currentMode + "." + currentSubmode if currentSubmode?
26 if newContents = ContentsByMode[currentMode]
27 [klass, text] = newContents
28 @element.className = klass
29 @element.textContent = text
30
31 # Private
32
33 attach: ->
34 @tile = @statusBar.addRightTile(item: @container, priority: 20)
35
36 detach: ->
37 @tile.destroy()