mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
Move status-bar to packages folder
This commit is contained in:
@@ -1,93 +0,0 @@
|
||||
_ = require 'underscore'
|
||||
{View, $$} = require 'space-pen'
|
||||
$ = require 'jquery'
|
||||
|
||||
module.exports =
|
||||
class StatusBar extends View
|
||||
@activate: (rootView) ->
|
||||
requireStylesheet 'status-bar.css'
|
||||
|
||||
for editor in rootView.getEditors()
|
||||
@appendToEditorPane(rootView, editor) if rootView.parents('html').length
|
||||
|
||||
rootView.on 'editor-open', (e, editor) =>
|
||||
@appendToEditorPane(rootView, editor)
|
||||
|
||||
@appendToEditorPane: (rootView, editor) ->
|
||||
if pane = editor.pane()
|
||||
pane.append(new StatusBar(rootView, editor))
|
||||
|
||||
@content: ->
|
||||
@div class: 'status-bar', =>
|
||||
@div 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()
|
||||
@editor.on 'editor-path-change', =>
|
||||
@subscribeToBuffer()
|
||||
@updatePathText()
|
||||
|
||||
@updateCursorPositionText()
|
||||
@editor.on 'cursor-move', => @updateCursorPositionText()
|
||||
$(window).on 'focus', => @updateStatusBar()
|
||||
|
||||
@subscribeToBuffer()
|
||||
|
||||
subscribeToBuffer: ->
|
||||
@buffer?.off '.status-bar'
|
||||
@buffer = @editor.getBuffer()
|
||||
@buffer.on 'contents-modified.status-bar', (e) => @updateBufferHasModifiedText(e.differsFromDisk)
|
||||
@buffer.on 'after-save.status-bar', => @updateStatusBar()
|
||||
@buffer.on 'git-status-change.status-bar', => @updateStatusBar()
|
||||
@updateStatusBar()
|
||||
|
||||
updateStatusBar: ->
|
||||
@updateBranchText()
|
||||
@updateBufferHasModifiedText(@buffer.isModified())
|
||||
@updateStatusText()
|
||||
|
||||
updateBufferHasModifiedText: (differsFromDisk)->
|
||||
if differsFromDisk
|
||||
@bufferModified.text('*') unless @isModified
|
||||
@isModified = true
|
||||
else
|
||||
@bufferModified.text('') if @isModified
|
||||
@isModified = false
|
||||
|
||||
updateBranchText: ->
|
||||
path = @editor.getPath()
|
||||
@branchArea.hide()
|
||||
return unless path
|
||||
|
||||
head = @buffer.getGit()?.getShortHead()
|
||||
@branchLabel.text(head)
|
||||
@branchArea.show() if head
|
||||
|
||||
updateStatusText: ->
|
||||
path = @editor.getPath()
|
||||
@gitStatusIcon.empty()
|
||||
return unless path
|
||||
|
||||
@gitStatusIcon.removeClass().addClass('octicons')
|
||||
if @buffer.getGit()?.isPathModified(path)
|
||||
@gitStatusIcon.addClass('modified-status-icon')
|
||||
else if @buffer.getGit()?.isPathNew(path)
|
||||
@gitStatusIcon.addClass('new-status-icon')
|
||||
|
||||
updatePathText: ->
|
||||
if path = @editor.getPath()
|
||||
@currentPath.text(@rootView.project.relativize(path))
|
||||
else
|
||||
@currentPath.text('untitled')
|
||||
|
||||
updateCursorPositionText: ->
|
||||
{ row, column } = @editor.getCursorBufferPosition()
|
||||
@cursorPosition.text("#{row + 1},#{column + 1}")
|
||||
Reference in New Issue
Block a user