Update coffee-fmt to v0.10.2 and beautify internal source code
This commit is contained in:
parent
94fc870b84
commit
5fd07cff9c
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"indent_size": 2,
|
||||
"indent_size": 4,
|
||||
"indent_char": " ",
|
||||
"indent_level": 0,
|
||||
"indent_with_tabs": false,
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
"atom-message-panel": "^1.2.4",
|
||||
"atom-space-pen-views": "^2.0.5",
|
||||
"bluebird": "^2.9.25",
|
||||
"coffee-fmt": "0.7.0",
|
||||
"coffee-fmt": "0.10.2",
|
||||
"coffee-formatter": "^0.1.2",
|
||||
"csscomb": "^3.0.4",
|
||||
"diff": "^1.4.0",
|
||||
|
|
|
@ -16,8 +16,8 @@ module.exports = class autopep8 extends Beautifier
|
|||
beautify: (text, language, options) ->
|
||||
# console.log('autopep8', options, text, language)
|
||||
@run("autopep8", [
|
||||
@tempFile("input", text)
|
||||
["--max-line-length", "#{options.max_line_length}"] if options.max_line_length?
|
||||
["--indent-size","#{options.indent_size}"] if options.indent_size?
|
||||
["--ignore","#{options.ignore.join(',')}"] if options.ignore?
|
||||
])
|
||||
@tempFile("input", text)
|
||||
["--max-line-length", "#{options.max_line_length}"] if options.max_line_length?
|
||||
["--indent-size","#{options.indent_size}"] if options.indent_size?
|
||||
["--ignore","#{options.ignore.join(',')}"] if options.ignore?
|
||||
])
|
||||
|
|
|
@ -9,7 +9,7 @@ readFile = Promise.promisify(fs.readFile)
|
|||
module.exports = class Beautifier
|
||||
|
||||
###
|
||||
|
||||
|
||||
###
|
||||
Promise: Promise
|
||||
|
||||
|
@ -111,10 +111,10 @@ module.exports = class Beautifier
|
|||
# executes the export command to get a list of environment variables.
|
||||
# We then use these to run the script:
|
||||
child = spawn process.env.SHELL, ['-ilc', 'env'],
|
||||
# This is essential for interactive shells, otherwise it never finishes:
|
||||
detached: true,
|
||||
# We don't care about stdin, stderr can go out the usual way:
|
||||
stdio: ['ignore', 'pipe', process.stderr]
|
||||
# This is essential for interactive shells, otherwise it never finishes:
|
||||
detached: true,
|
||||
# We don't care about stdin, stderr can go out the usual way:
|
||||
stdio: ['ignore', 'pipe', process.stderr]
|
||||
# We buffer stdout:
|
||||
buffer = ''
|
||||
child.stdout.on 'data', (data) -> buffer += data
|
||||
|
@ -130,7 +130,7 @@ module.exports = class Beautifier
|
|||
@_envCache = environment
|
||||
@_envCacheDate = new Date()
|
||||
resolve(environment)
|
||||
)
|
||||
)
|
||||
|
||||
###
|
||||
Run command-line interface command
|
||||
|
|
|
@ -46,6 +46,6 @@ module.exports = class JSBeautify extends Beautifier
|
|||
syntax: syntax
|
||||
})
|
||||
# console.log('processedCSS', processedCSS, syntax)
|
||||
|
||||
|
||||
resolve(processedCSS)
|
||||
)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,25 +20,25 @@ module.exports = class JSBeautify extends Beautifier
|
|||
try
|
||||
switch language
|
||||
when "JSON", "JavaScript"
|
||||
beautifyJS = require("js-beautify")
|
||||
text = beautifyJS(text, options)
|
||||
resolve text
|
||||
beautifyJS = require("js-beautify")
|
||||
text = beautifyJS(text, options)
|
||||
resolve text
|
||||
when "Handlebars", "Mustache"
|
||||
# jshint ignore: start
|
||||
options.indent_handlebars = true # Force jsbeautify to indent_handlebars
|
||||
# jshint ignore: end
|
||||
beautifyHTML = require("js-beautify").html
|
||||
text = beautifyHTML(text, options)
|
||||
resolve text
|
||||
# jshint ignore: start
|
||||
options.indent_handlebars = true # Force jsbeautify to indent_handlebars
|
||||
# jshint ignore: end
|
||||
beautifyHTML = require("js-beautify").html
|
||||
text = beautifyHTML(text, options)
|
||||
resolve text
|
||||
when "HTML (Liquid)", "HTML", "XML", "Marko", "Web Form/Control (C#)", "Web Handler (C#)"
|
||||
beautifyHTML = require("js-beautify").html
|
||||
text = beautifyHTML(text, options)
|
||||
@debug("Beautified HTML: #{text}")
|
||||
resolve text
|
||||
beautifyHTML = require("js-beautify").html
|
||||
text = beautifyHTML(text, options)
|
||||
@debug("Beautified HTML: #{text}")
|
||||
resolve text
|
||||
when "CSS"
|
||||
beautifyCSS = require("js-beautify").css
|
||||
text = beautifyCSS(text, options)
|
||||
resolve text
|
||||
beautifyCSS = require("js-beautify").css
|
||||
text = beautifyCSS(text, options)
|
||||
resolve text
|
||||
catch err
|
||||
@error("JS Beautify error: #{err}")
|
||||
reject(err)
|
||||
|
|
|
@ -6,17 +6,17 @@ Beautifier = require('./beautifier')
|
|||
|
||||
module.exports = class PerlTidy extends Beautifier
|
||||
name: "Perltidy"
|
||||
|
||||
|
||||
options: {
|
||||
Perl: true
|
||||
}
|
||||
|
||||
cli: (options) ->
|
||||
if not options.perltidy_path?
|
||||
return new Error("'Perl Perltidy Path' not set!" +
|
||||
" Please set this in the Atom Beautify package settings.")
|
||||
else
|
||||
return options.perltidy_path
|
||||
if not options.perltidy_path?
|
||||
return new Error("'Perl Perltidy Path' not set!" +
|
||||
" Please set this in the Atom Beautify package settings.")
|
||||
else
|
||||
return options.perltidy_path
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run("perltidy", [
|
||||
|
|
|
@ -14,8 +14,8 @@ module.exports = class Rubocop extends Beautifier
|
|||
|
||||
beautify: (text, language, options) ->
|
||||
@run("rubocop", [
|
||||
"--auto-correct"
|
||||
tempFile = @tempFile("temp", text)
|
||||
"--auto-correct"
|
||||
tempFile = @tempFile("temp", text)
|
||||
], {ignoreReturnCode: true})
|
||||
.then(=>
|
||||
# console.log('rubocop', arguments, tempFile)
|
||||
|
|
|
@ -15,5 +15,5 @@ module.exports = class RubyBeautify extends Beautifier
|
|||
beautify: (text, language, options) ->
|
||||
@deprecate("Ruby-Beautify has been deprecated in favour of Rubocop beautifier.")
|
||||
@run("rbeautify", [
|
||||
@tempFile("input", text)
|
||||
@tempFile("input", text)
|
||||
])
|
||||
|
|
|
@ -7,16 +7,16 @@ Beautifier = require('./beautifier')
|
|||
|
||||
module.exports = class sqlformat extends Beautifier
|
||||
name: "sqlformat"
|
||||
|
||||
|
||||
options: {
|
||||
SQL: true
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@run("sqlformat", [
|
||||
@tempFile("input", text)
|
||||
"--reindent"
|
||||
"--indent_width=#{options.indent_size}" if options.indent_size?
|
||||
"--keywords=#{options.keywords}" if options.keywords?
|
||||
"--identifiers=#{options.identifiers}" if options.identifiers?
|
||||
@tempFile("input", text)
|
||||
"--reindent"
|
||||
"--indent_width=#{options.indent_size}" if options.indent_size?
|
||||
"--keywords=#{options.keywords}" if options.keywords?
|
||||
"--identifiers=#{options.identifiers}" if options.identifiers?
|
||||
])
|
||||
|
|
|
@ -24,428 +24,428 @@ $ = null
|
|||
# return data;
|
||||
# }
|
||||
getCursors = (editor) ->
|
||||
cursors = editor.getCursors()
|
||||
posArray = []
|
||||
for cursor in cursors
|
||||
bufferPosition = cursor.getBufferPosition()
|
||||
posArray.push [
|
||||
bufferPosition.row
|
||||
bufferPosition.column
|
||||
]
|
||||
posArray
|
||||
cursors = editor.getCursors()
|
||||
posArray = []
|
||||
for cursor in cursors
|
||||
bufferPosition = cursor.getBufferPosition()
|
||||
posArray.push [
|
||||
bufferPosition.row
|
||||
bufferPosition.column
|
||||
]
|
||||
posArray
|
||||
setCursors = (editor, posArray) ->
|
||||
|
||||
# console.log "setCursors:
|
||||
for bufferPosition, i in posArray
|
||||
if i is 0
|
||||
editor.setCursorBufferPosition bufferPosition
|
||||
continue
|
||||
editor.addCursorAtBufferPosition bufferPosition
|
||||
return
|
||||
beautify = ({onSave}) ->
|
||||
console.log('beautify!!!')
|
||||
# Deprecation warning for beautify on save
|
||||
if atom.config.get("atom-beautify.beautifyOnSave") is true
|
||||
detail = """See issue https://github.com/Glavin001/atom-beautify/issues/308
|
||||
|
||||
To stop seeing this message:
|
||||
- Uncheck (disable) the deprecated \"Beautify On Save\" option
|
||||
|
||||
To enable Beautify on Save for a particular language:
|
||||
- Go to Atom Beautify's package settings
|
||||
- Find option for \"Language Config - <Your Language> - Beautify On Save\"
|
||||
- Check (enable) Beautify On Save option for that particular language
|
||||
|
||||
"""
|
||||
|
||||
atom?.notifications.addWarning("The option \"atom-beautify.beautifyOnSave\" has been deprecated", {detail, dismissable : true})
|
||||
|
||||
# Continue beautifying
|
||||
path ?= require("path")
|
||||
LoadingView ?= require "./views/loading-view"
|
||||
@loadingView ?= new LoadingView()
|
||||
@loadingView.show()
|
||||
forceEntireFile = onSave and atom.config.get("atom-beautify.beautifyEntireFileOnSave")
|
||||
|
||||
|
||||
# Show error
|
||||
showError = (error)=>
|
||||
@loadingView.hide()
|
||||
if not atom.config.get("atom-beautify.muteAllErrors")
|
||||
|
||||
# console.log(e)
|
||||
stack = error.stack
|
||||
detail = error.message
|
||||
atom.notifications?.addError(error.message, {
|
||||
stack, detail, dismissable : true})
|
||||
|
||||
# Get the path to the config file
|
||||
# All of the options
|
||||
# Listed in order from default (base) to the one with the highest priority
|
||||
# Left = Default, Right = Will override the left.
|
||||
# Atom Editor
|
||||
#
|
||||
# User's Home path
|
||||
# Project path
|
||||
# Asynchronously and callback-style
|
||||
beautifyCompleted = (text)=>
|
||||
|
||||
# console.log 'beautifyCompleted'
|
||||
if not text?
|
||||
|
||||
|
||||
# Do nothing, is undefined
|
||||
else if text instanceof Error
|
||||
showError(text)
|
||||
else if typeof text is "string"
|
||||
if oldText isnt text
|
||||
|
||||
# console.log "Replacing current editor's text with new text"
|
||||
posArray = getCursors(editor)
|
||||
|
||||
|
||||
# console.log "posArray:
|
||||
origScrollTop = editor.getScrollTop()
|
||||
|
||||
|
||||
# console.log "origScrollTop:
|
||||
if not forceEntireFile and isSelection
|
||||
selectedBufferRange = editor.getSelectedBufferRange()
|
||||
|
||||
|
||||
# console.log "selectedBufferRange:
|
||||
editor.setTextInBufferRange selectedBufferRange, text
|
||||
else
|
||||
|
||||
# console.log "setText"
|
||||
editor.setText text
|
||||
|
||||
# console.log "setCursors"
|
||||
setCursors editor, posArray
|
||||
|
||||
|
||||
# console.log "Done setCursors"
|
||||
# Let the scrollTop setting run after all the save related stuff is run,
|
||||
# otherwise setScrollTop is not working, probably because the cursor
|
||||
# addition happens asynchronously
|
||||
setTimeout ( ->
|
||||
|
||||
# console.log "setScrollTop"
|
||||
editor.setScrollTop origScrollTop
|
||||
return
|
||||
), 0
|
||||
else
|
||||
showError( new Error("Unsupported beautification result '#{text}'."))
|
||||
|
||||
# else
|
||||
# console.log "Already Beautiful!"
|
||||
@loadingView.hide()
|
||||
# console.log "setCursors:
|
||||
for bufferPosition, i in posArray
|
||||
if i is 0
|
||||
editor.setCursorBufferPosition bufferPosition
|
||||
continue
|
||||
editor.addCursorAtBufferPosition bufferPosition
|
||||
return
|
||||
beautify = ({onSave}) ->
|
||||
console.log('beautify!!!')
|
||||
# Deprecation warning for beautify on save
|
||||
if atom.config.get("atom-beautify.beautifyOnSave") is true
|
||||
detail = """See issue https://github.com/Glavin001/atom-beautify/issues/308
|
||||
|
||||
# console.log 'Beautify time!'
|
||||
#
|
||||
# Get current editor
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
To stop seeing this message:
|
||||
- Uncheck (disable) the deprecated \"Beautify On Save\" option
|
||||
|
||||
To enable Beautify on Save for a particular language:
|
||||
- Go to Atom Beautify's package settings
|
||||
- Find option for \"Language Config - <Your Language> - Beautify On Save\"
|
||||
- Check (enable) Beautify On Save option for that particular language
|
||||
|
||||
"""
|
||||
|
||||
atom?.notifications.addWarning("The option \"atom-beautify.beautifyOnSave\" has been deprecated", {detail, dismissable : true})
|
||||
|
||||
# Continue beautifying
|
||||
path ?= require("path")
|
||||
LoadingView ?= require "./views/loading-view"
|
||||
@loadingView ?= new LoadingView()
|
||||
@loadingView.show()
|
||||
forceEntireFile = onSave and atom.config.get("atom-beautify.beautifyEntireFileOnSave")
|
||||
|
||||
|
||||
# Check if there is an active editor
|
||||
if not editor?
|
||||
return showError( new Error("Active Editor not found. "
|
||||
"Please select a Text Editor first to beautify."))
|
||||
isSelection = !!editor.getSelectedText()
|
||||
# Show error
|
||||
showError = (error)=>
|
||||
@loadingView.hide()
|
||||
if not atom.config.get("atom-beautify.muteAllErrors")
|
||||
|
||||
# console.log(e)
|
||||
stack = error.stack
|
||||
detail = error.message
|
||||
atom.notifications?.addError(error.message, {
|
||||
stack, detail, dismissable : true})
|
||||
|
||||
# Get the path to the config file
|
||||
# All of the options
|
||||
# Listed in order from default (base) to the one with the highest priority
|
||||
# Left = Default, Right = Will override the left.
|
||||
# Atom Editor
|
||||
#
|
||||
# User's Home path
|
||||
# Project path
|
||||
# Asynchronously and callback-style
|
||||
beautifyCompleted = (text)=>
|
||||
|
||||
# console.log 'beautifyCompleted'
|
||||
if not text?
|
||||
|
||||
|
||||
# Get editor path and configurations for paths
|
||||
editedFilePath = editor.getPath()
|
||||
# Do nothing, is undefined
|
||||
else if text instanceof Error
|
||||
showError(text)
|
||||
else if typeof text is "string"
|
||||
if oldText isnt text
|
||||
|
||||
# console.log "Replacing current editor's text with new text"
|
||||
posArray = getCursors(editor)
|
||||
|
||||
|
||||
# Get all options
|
||||
allOptions = beautifier.getOptionsForPath(editedFilePath, editor)
|
||||
# console.log "posArray:
|
||||
origScrollTop = editor.getScrollTop()
|
||||
|
||||
|
||||
# Get current editor's text
|
||||
text = undefined
|
||||
if not forceEntireFile and isSelection
|
||||
text = editor.getSelectedText()
|
||||
else
|
||||
text = editor.getText()
|
||||
oldText = text
|
||||
# console.log "origScrollTop:
|
||||
if not forceEntireFile and isSelection
|
||||
selectedBufferRange = editor.getSelectedBufferRange()
|
||||
|
||||
|
||||
# Get Grammar
|
||||
grammarName = editor.getGrammar().name
|
||||
# console.log "selectedBufferRange:
|
||||
editor.setTextInBufferRange selectedBufferRange, text
|
||||
else
|
||||
|
||||
# console.log "setText"
|
||||
editor.setText text
|
||||
|
||||
# console.log "setCursors"
|
||||
setCursors editor, posArray
|
||||
|
||||
|
||||
# Finally, beautify!
|
||||
try
|
||||
beautifier.beautify(text, allOptions, grammarName, editedFilePath, onSave : onSave)
|
||||
.then(beautifyCompleted)
|
||||
.catch(beautifyCompleted)
|
||||
catch e
|
||||
showError(e)
|
||||
return
|
||||
# console.log "Done setCursors"
|
||||
# Let the scrollTop setting run after all the save related stuff is run,
|
||||
# otherwise setScrollTop is not working, probably because the cursor
|
||||
# addition happens asynchronously
|
||||
setTimeout ( ->
|
||||
|
||||
# console.log "setScrollTop"
|
||||
editor.setScrollTop origScrollTop
|
||||
return
|
||||
), 0
|
||||
else
|
||||
showError( new Error("Unsupported beautification result '#{text}'."))
|
||||
|
||||
# else
|
||||
# console.log "Already Beautiful!"
|
||||
@loadingView.hide()
|
||||
return
|
||||
|
||||
# console.log 'Beautify time!'
|
||||
#
|
||||
# Get current editor
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
|
||||
|
||||
# Check if there is an active editor
|
||||
if not editor?
|
||||
return showError( new Error("Active Editor not found. "
|
||||
"Please select a Text Editor first to beautify."))
|
||||
isSelection = !!editor.getSelectedText()
|
||||
|
||||
|
||||
# Get editor path and configurations for paths
|
||||
editedFilePath = editor.getPath()
|
||||
|
||||
|
||||
# Get all options
|
||||
allOptions = beautifier.getOptionsForPath(editedFilePath, editor)
|
||||
|
||||
|
||||
# Get current editor's text
|
||||
text = undefined
|
||||
if not forceEntireFile and isSelection
|
||||
text = editor.getSelectedText()
|
||||
else
|
||||
text = editor.getText()
|
||||
oldText = text
|
||||
|
||||
|
||||
# Get Grammar
|
||||
grammarName = editor.getGrammar().name
|
||||
|
||||
|
||||
# Finally, beautify!
|
||||
try
|
||||
beautifier.beautify(text, allOptions, grammarName, editedFilePath, onSave : onSave)
|
||||
.then(beautifyCompleted)
|
||||
.catch(beautifyCompleted)
|
||||
catch e
|
||||
showError(e)
|
||||
return
|
||||
beautifyFilePath = (filePath, callback) ->
|
||||
|
||||
# Show in progress indicate on file's tree-view entry
|
||||
$ ?= require("space-pen").$
|
||||
$el = $(".icon-file-text[data-path=\"#{filePath}\"]")
|
||||
$el.addClass('beautifying')
|
||||
|
||||
|
||||
# Cleanup and return callback function
|
||||
cb = (err, result) ->
|
||||
# Show in progress indicate on file's tree-view entry
|
||||
$ ?= require("space-pen").$
|
||||
$el = $(".icon-file-text[data-path=\"#{filePath}\"]")
|
||||
$el.removeClass('beautifying')
|
||||
return callback(err, result)
|
||||
|
||||
# Get contents of file
|
||||
fs ?= require "fs"
|
||||
fs.readFile(filePath, (err, data) ->
|
||||
return cb(err) if err
|
||||
input = data?.toString()
|
||||
grammar = atom.grammars.selectGrammar(filePath, input)
|
||||
grammarName = grammar.name
|
||||
$el.addClass('beautifying')
|
||||
|
||||
|
||||
# Get the options
|
||||
allOptions = beautifier.getOptionsForPath(filePath)
|
||||
# Cleanup and return callback function
|
||||
cb = (err, result) ->
|
||||
$el = $(".icon-file-text[data-path=\"#{filePath}\"]")
|
||||
$el.removeClass('beautifying')
|
||||
return callback(err, result)
|
||||
|
||||
# Get contents of file
|
||||
fs ?= require "fs"
|
||||
fs.readFile(filePath, (err, data) ->
|
||||
return cb(err) if err
|
||||
input = data?.toString()
|
||||
grammar = atom.grammars.selectGrammar(filePath, input)
|
||||
grammarName = grammar.name
|
||||
|
||||
|
||||
# Beautify File
|
||||
completionFun = (output) ->
|
||||
if output instanceof Error
|
||||
return cb(output, null ) # output == Error
|
||||
else if typeof output is "string"
|
||||
fs.writeFile(filePath, output, (err) ->
|
||||
return cb(err) if err
|
||||
return cb( null , output)
|
||||
# Get the options
|
||||
allOptions = beautifier.getOptionsForPath(filePath)
|
||||
|
||||
|
||||
# Beautify File
|
||||
completionFun = (output) ->
|
||||
if output instanceof Error
|
||||
return cb(output, null ) # output == Error
|
||||
else if typeof output is "string"
|
||||
fs.writeFile(filePath, output, (err) ->
|
||||
return cb(err) if err
|
||||
return cb( null , output)
|
||||
)
|
||||
else
|
||||
return cb( new Error("Unknown beautification result #{output}."), output)
|
||||
try
|
||||
beautifier.beautify(input, allOptions, grammarName, filePath)
|
||||
.then(completionFun)
|
||||
.catch(completionFun)
|
||||
catch e
|
||||
return cb(e)
|
||||
)
|
||||
else
|
||||
return cb( new Error("Unknown beautification result #{output}."), output)
|
||||
try
|
||||
beautifier.beautify(input, allOptions, grammarName, filePath)
|
||||
.then(completionFun)
|
||||
.catch(completionFun)
|
||||
catch e
|
||||
return cb(e)
|
||||
)
|
||||
beautifyFile = ({target}) ->
|
||||
filePath = target.dataset.path
|
||||
return unless filePath
|
||||
beautifyFilePath(filePath, (err, result) ->
|
||||
return console.error('beautifyFile error', err, result) if err
|
||||
filePath = target.dataset.path
|
||||
return unless filePath
|
||||
beautifyFilePath(filePath, (err, result) ->
|
||||
return console.error('beautifyFile error', err, result) if err
|
||||
|
||||
# console.log("Beautify File
|
||||
)
|
||||
return
|
||||
beautifyDirectory = ({target}) ->
|
||||
dirPath = target.dataset.path
|
||||
return unless dirPath
|
||||
|
||||
|
||||
# Show in progress indicate on directory's tree-view entry
|
||||
$ ?= require("space-pen").$
|
||||
$el = $(".icon-file-directory[data-path=\"#{dirPath}\"]")
|
||||
$el.addClass('beautifying')
|
||||
|
||||
|
||||
# Process Directory
|
||||
dir ?= require "node-dir"
|
||||
async ?= require "async"
|
||||
dir.files(dirPath, (err, files) ->
|
||||
return console.error('beautifyDirectory error', err) if err
|
||||
async.each(files, (filePath, callback) ->
|
||||
|
||||
# Ignore errors
|
||||
beautifyFilePath(filePath, -> callback())
|
||||
, (err) ->
|
||||
$el = $(".icon-file-directory[data-path=\"#{dirPath}\"]")
|
||||
$el.removeClass('beautifying')
|
||||
|
||||
# console.log('Completed beautifying directory!', dirPath)
|
||||
# console.log("Beautify File
|
||||
)
|
||||
)
|
||||
return
|
||||
return
|
||||
beautifyDirectory = ({target}) ->
|
||||
dirPath = target.dataset.path
|
||||
return unless dirPath
|
||||
|
||||
|
||||
# Show in progress indicate on directory's tree-view entry
|
||||
$ ?= require("space-pen").$
|
||||
$el = $(".icon-file-directory[data-path=\"#{dirPath}\"]")
|
||||
$el.addClass('beautifying')
|
||||
|
||||
|
||||
# Process Directory
|
||||
dir ?= require "node-dir"
|
||||
async ?= require "async"
|
||||
dir.files(dirPath, (err, files) ->
|
||||
return console.error('beautifyDirectory error', err) if err
|
||||
async.each(files, (filePath, callback) ->
|
||||
|
||||
# Ignore errors
|
||||
beautifyFilePath(filePath, -> callback())
|
||||
, (err) ->
|
||||
$el = $(".icon-file-directory[data-path=\"#{dirPath}\"]")
|
||||
$el.removeClass('beautifying')
|
||||
|
||||
# console.log('Completed beautifying directory!', dirPath)
|
||||
)
|
||||
)
|
||||
return
|
||||
debug = () ->
|
||||
|
||||
# Get current editor
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
# Get current editor
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
|
||||
|
||||
# Check if there is an active editor
|
||||
if not editor?
|
||||
return confirm("Active Editor not found.\n" +
|
||||
"Please select a Text Editor first to beautify.")
|
||||
return unless confirm('Are you ready to debug Atom Beautify?\n\n' +
|
||||
'Warning: This will change your current clipboard contents.')
|
||||
debugInfo = ""
|
||||
addInfo = (key, val) ->
|
||||
debugInfo += "**#{key}**: #{val}\n\n"
|
||||
addHeader = (level, title) ->
|
||||
debugInfo += "#{Array(level+1).join('#')} #{title}\n\n"
|
||||
addHeader(1, "Atom Beautify - Debugging information")
|
||||
debugInfo += "The following debugging information was " +
|
||||
"generated by `Atom Beautify` on `#{new Date()}`." +
|
||||
"\n\n---\n\n"
|
||||
# Check if there is an active editor
|
||||
if not editor?
|
||||
return confirm("Active Editor not found.\n" +
|
||||
"Please select a Text Editor first to beautify.")
|
||||
return unless confirm('Are you ready to debug Atom Beautify?\n\n' +
|
||||
'Warning: This will change your current clipboard contents.')
|
||||
debugInfo = ""
|
||||
addInfo = (key, val) ->
|
||||
debugInfo += "**#{key}**: #{val}\n\n"
|
||||
addHeader = (level, title) ->
|
||||
debugInfo += "#{Array(level+1).join('#')} #{title}\n\n"
|
||||
addHeader(1, "Atom Beautify - Debugging information")
|
||||
debugInfo += "The following debugging information was " +
|
||||
"generated by `Atom Beautify` on `#{new Date()}`." +
|
||||
"\n\n---\n\n"
|
||||
|
||||
# Platform
|
||||
addInfo('Platform', process.platform)
|
||||
addHeader(2, "Versions")
|
||||
# Platform
|
||||
addInfo('Platform', process.platform)
|
||||
addHeader(2, "Versions")
|
||||
|
||||
|
||||
# Atom Version
|
||||
addInfo('Atom Version', atom.appVersion)
|
||||
# Atom Version
|
||||
addInfo('Atom Version', atom.appVersion)
|
||||
|
||||
|
||||
# Atom Beautify Version
|
||||
addInfo('Atom Beautify Version', pkg.version)
|
||||
addHeader(2, "Original file to be beautified")
|
||||
# Atom Beautify Version
|
||||
addInfo('Atom Beautify Version', pkg.version)
|
||||
addHeader(2, "Original file to be beautified")
|
||||
|
||||
|
||||
# Original file
|
||||
#
|
||||
# Get editor path and configurations for paths
|
||||
filePath = editor.getPath()
|
||||
# Original file
|
||||
#
|
||||
# Get editor path and configurations for paths
|
||||
filePath = editor.getPath()
|
||||
|
||||
|
||||
# Path
|
||||
addInfo('Original File Path', "`#{filePath}`")
|
||||
# Path
|
||||
addInfo('Original File Path', "`#{filePath}`")
|
||||
|
||||
|
||||
# Get Grammar
|
||||
grammarName = editor.getGrammar().name
|
||||
# Get Grammar
|
||||
grammarName = editor.getGrammar().name
|
||||
|
||||
|
||||
# Grammar
|
||||
addInfo('Original File Grammar', grammarName)
|
||||
# Grammar
|
||||
addInfo('Original File Grammar', grammarName)
|
||||
|
||||
|
||||
# Get current editor's text
|
||||
text = editor.getText()
|
||||
# Get current editor's text
|
||||
text = editor.getText()
|
||||
|
||||
|
||||
# Contents
|
||||
codeBlockSyntax = grammarName.toLowerCase().split(' ')[0]
|
||||
addInfo('Original File Contents', "\n```#{codeBlockSyntax}\n#{text}\n```")
|
||||
addHeader(2, "Beautification options")
|
||||
# Contents
|
||||
codeBlockSyntax = grammarName.toLowerCase().split(' ')[0]
|
||||
addInfo('Original File Contents', "\n```#{codeBlockSyntax}\n#{text}\n```")
|
||||
addHeader(2, "Beautification options")
|
||||
|
||||
|
||||
# Beautification Options
|
||||
# Get all options
|
||||
allOptions = beautifier.getOptionsForPath(filePath, editor)
|
||||
[
|
||||
editorOptions
|
||||
configOptions
|
||||
homeOptions
|
||||
editorConfigOptions
|
||||
] = allOptions
|
||||
projectOptions = allOptions[4..]
|
||||
addInfo('Editor Options', "\n" +
|
||||
"Options from Atom Editor settings\n" +
|
||||
"```json\n#{JSON.stringify(editorOptions, undefined, 4)}\n```")
|
||||
addInfo('Config Options', "\n" +
|
||||
"Options from Atom Beautify package settings\n" +
|
||||
"```json\n#{JSON.stringify(configOptions, undefined, 4)}\n```")
|
||||
addInfo('Home Options', "\n" +
|
||||
"Options from `#{path.resolve(beautifier.getUserHome(), '.jsbeautifyrc')}`\n" +
|
||||
"```json\n#{JSON.stringify(homeOptions, undefined, 4)}\n```")
|
||||
addInfo('EditorConfig Options', "\n" +
|
||||
"Options from [EditorConfig](http://editorconfig.org/) file\n" +
|
||||
"```json\n#{JSON.stringify(editorConfigOptions, undefined, 4)}\n```")
|
||||
addInfo('Project Options', "\n" +
|
||||
"Options from `.jsbeautifyrc` files starting from directory `#{path.dirname(filePath)}` and going up to root\n" +
|
||||
"```json\n#{JSON.stringify(projectOptions, undefined, 4)}\n```")
|
||||
logs = ""
|
||||
logger = require('./logger')(__filename)
|
||||
subscription = logger.onLogging((msg) ->
|
||||
# Beautification Options
|
||||
# Get all options
|
||||
allOptions = beautifier.getOptionsForPath(filePath, editor)
|
||||
[
|
||||
editorOptions
|
||||
configOptions
|
||||
homeOptions
|
||||
editorConfigOptions
|
||||
] = allOptions
|
||||
projectOptions = allOptions[4..]
|
||||
addInfo('Editor Options', "\n" +
|
||||
"Options from Atom Editor settings\n" +
|
||||
"```json\n#{JSON.stringify(editorOptions, undefined, 4)}\n```")
|
||||
addInfo('Config Options', "\n" +
|
||||
"Options from Atom Beautify package settings\n" +
|
||||
"```json\n#{JSON.stringify(configOptions, undefined, 4)}\n```")
|
||||
addInfo('Home Options', "\n" +
|
||||
"Options from `#{path.resolve(beautifier.getUserHome(), '.jsbeautifyrc')}`\n" +
|
||||
"```json\n#{JSON.stringify(homeOptions, undefined, 4)}\n```")
|
||||
addInfo('EditorConfig Options', "\n" +
|
||||
"Options from [EditorConfig](http://editorconfig.org/) file\n" +
|
||||
"```json\n#{JSON.stringify(editorConfigOptions, undefined, 4)}\n```")
|
||||
addInfo('Project Options', "\n" +
|
||||
"Options from `.jsbeautifyrc` files starting from directory `#{path.dirname(filePath)}` and going up to root\n" +
|
||||
"```json\n#{JSON.stringify(projectOptions, undefined, 4)}\n```")
|
||||
logs = ""
|
||||
logger = require('./logger')(__filename)
|
||||
subscription = logger.onLogging((msg) ->
|
||||
|
||||
# console.log('logging', msg)
|
||||
logs += msg
|
||||
)
|
||||
cb = (result) ->
|
||||
subscription.dispose()
|
||||
addHeader(2, "Results")
|
||||
|
||||
|
||||
# Logs
|
||||
addInfo('Beautified File Contents', "\n```#{codeBlockSyntax}\n#{result}\n```")
|
||||
addInfo('Logs', "\n```\n#{logs}\n```")
|
||||
|
||||
|
||||
# Save to clipboard
|
||||
atom.clipboard.write(debugInfo)
|
||||
confirm('Atom Beautify debugging information is now in your clipboard.\n' +
|
||||
'You can now paste this into an Issue you are reporting here\n' +
|
||||
'https://github.com/Glavin001/atom-beautify/issues/ \n\n' +
|
||||
'Warning: Be sure to look over the debug info before you send it,
|
||||
to ensure you are not sharing undesirable private information.'
|
||||
# console.log('logging', msg)
|
||||
logs += msg
|
||||
)
|
||||
try
|
||||
beautifier.beautify(text, allOptions, grammarName, filePath)
|
||||
.then(cb)
|
||||
.catch(cb)
|
||||
catch e
|
||||
return cb(e)
|
||||
handleSaveEvent = =>
|
||||
atom.workspace.observeTextEditors (editor) =>
|
||||
buffer = editor.getBuffer()
|
||||
disposable = buffer.onDidSave(({path : filePath}) =>
|
||||
path ?= require('path')
|
||||
# Get Grammar
|
||||
grammar = editor.getGrammar().name
|
||||
# Get language
|
||||
fileExtension = path.extname(filePath)
|
||||
languages = beautifier.languages.getLanguages({grammar, fileExtension})
|
||||
if languages.length < 1
|
||||
return
|
||||
# TODO: select appropriate language
|
||||
language = languages[0]
|
||||
# Get language config
|
||||
beautifyOnSave = atom.config.get("atom-beautify.language_#{language.namespace}_beautify_on_save")
|
||||
if beautifyOnSave
|
||||
beautifyFilePath(filePath, ->
|
||||
buffer.reload()
|
||||
cb = (result) ->
|
||||
subscription.dispose()
|
||||
addHeader(2, "Results")
|
||||
|
||||
|
||||
# Logs
|
||||
addInfo('Beautified File Contents', "\n```#{codeBlockSyntax}\n#{result}\n```")
|
||||
addInfo('Logs', "\n```\n#{logs}\n```")
|
||||
|
||||
|
||||
# Save to clipboard
|
||||
atom.clipboard.write(debugInfo)
|
||||
confirm('Atom Beautify debugging information is now in your clipboard.\n' +
|
||||
'You can now paste this into an Issue you are reporting here\n' +
|
||||
'https://github.com/Glavin001/atom-beautify/issues/ \n\n' +
|
||||
'Warning: Be sure to look over the debug info before you send it,
|
||||
to ensure you are not sharing undesirable private information.'
|
||||
)
|
||||
)
|
||||
plugin.subscribe disposable
|
||||
try
|
||||
beautifier.beautify(text, allOptions, grammarName, filePath)
|
||||
.then(cb)
|
||||
.catch(cb)
|
||||
catch e
|
||||
return cb(e)
|
||||
handleSaveEvent = =>
|
||||
atom.workspace.observeTextEditors (editor) =>
|
||||
buffer = editor.getBuffer()
|
||||
disposable = buffer.onDidSave(({path : filePath}) =>
|
||||
path ?= require('path')
|
||||
# Get Grammar
|
||||
grammar = editor.getGrammar().name
|
||||
# Get language
|
||||
fileExtension = path.extname(filePath)
|
||||
languages = beautifier.languages.getLanguages({grammar, fileExtension})
|
||||
if languages.length < 1
|
||||
return
|
||||
# TODO: select appropriate language
|
||||
language = languages[0]
|
||||
# Get language config
|
||||
beautifyOnSave = atom.config.get("atom-beautify.language_#{language.namespace}_beautify_on_save")
|
||||
if beautifyOnSave
|
||||
beautifyFilePath(filePath, ->
|
||||
buffer.reload()
|
||||
)
|
||||
)
|
||||
plugin.subscribe disposable
|
||||
{Subscriber} = require path.join(atom.packages.resourcePath, 'node_modules', 'emissary')
|
||||
Subscriber.extend plugin
|
||||
plugin.config = _.merge(
|
||||
analytics :
|
||||
type : 'boolean'
|
||||
default : true
|
||||
description : "Automatically send usage information (NEVER CODE) to Google Analytics"
|
||||
_analyticsUserId :
|
||||
type : 'string'
|
||||
default : ""
|
||||
description : "Unique identifier for this user for tracking usage analytics"
|
||||
_loggerLevel :
|
||||
type : 'string'
|
||||
default : 'warn'
|
||||
description : 'Set the level for the logger'
|
||||
enum : ['verbose', 'debug', 'info', 'warn', 'error']
|
||||
beautifyOnSave :
|
||||
title : "DEPRECATED: Beautfy On Save"
|
||||
type : 'boolean'
|
||||
default : false
|
||||
description : "Beautify active editor on save"
|
||||
beautifyEntireFileOnSave :
|
||||
type : 'boolean'
|
||||
default : true
|
||||
description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
|
||||
muteUnsupportedLanguageErrors :
|
||||
type : 'boolean'
|
||||
default : false
|
||||
description : "Do not show \"Unsupported Language\" errors when they occur"
|
||||
muteAllErrors :
|
||||
type : 'boolean'
|
||||
default : false
|
||||
description : "Do not show any/all errors when they occur"
|
||||
analytics :
|
||||
type : 'boolean'
|
||||
default : true
|
||||
description : "Automatically send usage information (NEVER CODE) to Google Analytics"
|
||||
_analyticsUserId :
|
||||
type : 'string'
|
||||
default : ""
|
||||
description : "Unique identifier for this user for tracking usage analytics"
|
||||
_loggerLevel :
|
||||
type : 'string'
|
||||
default : 'warn'
|
||||
description : 'Set the level for the logger'
|
||||
enum : ['verbose', 'debug', 'info', 'warn', 'error']
|
||||
beautifyOnSave :
|
||||
title : "DEPRECATED: Beautfy On Save"
|
||||
type : 'boolean'
|
||||
default : false
|
||||
description : "Beautify active editor on save"
|
||||
beautifyEntireFileOnSave :
|
||||
type : 'boolean'
|
||||
default : true
|
||||
description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
|
||||
muteUnsupportedLanguageErrors :
|
||||
type : 'boolean'
|
||||
default : false
|
||||
description : "Do not show \"Unsupported Language\" errors when they occur"
|
||||
muteAllErrors :
|
||||
type : 'boolean'
|
||||
default : false
|
||||
description : "Do not show any/all errors when they occur"
|
||||
, defaultLanguageOptions)
|
||||
plugin.activate = ->
|
||||
handleSaveEvent()
|
||||
plugin.subscribe atom.config.observe("atom-beautify.beautifyOnSave", handleSaveEvent)
|
||||
atom.commands.add "atom-workspace", "atom-beautify:beautify-editor", beautify
|
||||
atom.commands.add "atom-workspace", "atom-beautify:help-debug-editor", debug
|
||||
atom.commands.add ".tree-view .file .name", "atom-beautify:beautify-file", beautifyFile
|
||||
atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory
|
||||
handleSaveEvent()
|
||||
plugin.subscribe atom.config.observe("atom-beautify.beautifyOnSave", handleSaveEvent)
|
||||
atom.commands.add "atom-workspace", "atom-beautify:beautify-editor", beautify
|
||||
atom.commands.add "atom-workspace", "atom-beautify:help-debug-editor", debug
|
||||
atom.commands.add ".tree-view .file .name", "atom-beautify:beautify-file", beautifyFile
|
||||
atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory
|
||||
|
|
|
@ -18,16 +18,16 @@ module.exports = do ->
|
|||
})
|
||||
|
||||
levels = {
|
||||
silly: 0,
|
||||
input: 1,
|
||||
verbose: 2,
|
||||
prompt: 3,
|
||||
debug: 4,
|
||||
info: 5,
|
||||
data: 6,
|
||||
help: 7,
|
||||
warn: 8,
|
||||
error: 9
|
||||
silly: 0,
|
||||
input: 1,
|
||||
verbose: 2,
|
||||
prompt: 3,
|
||||
debug: 4,
|
||||
info: 5,
|
||||
data: 6,
|
||||
help: 7,
|
||||
warn: 8,
|
||||
error: 9
|
||||
}
|
||||
|
||||
return (label) ->
|
||||
|
|
|
@ -3,37 +3,37 @@
|
|||
|
||||
module.exports =
|
||||
class LoadingView extends View
|
||||
@content: ->
|
||||
@div
|
||||
class: 'atom-beautify message-panel', =>
|
||||
@content: ->
|
||||
@div
|
||||
class: 'overlay from-top', =>
|
||||
@div class: "tool-panel panel-bottom", =>
|
||||
@div class: "inset-panel", =>
|
||||
@div class: "panel-heading", =>
|
||||
@div class: 'btn-toolbar pull-right', =>
|
||||
@button
|
||||
class: 'btn'
|
||||
click: 'hide'
|
||||
'Hide'
|
||||
@span
|
||||
class: 'text-primary'
|
||||
outlet: 'title'
|
||||
'Atom Beautify'
|
||||
class: 'atom-beautify message-panel', =>
|
||||
@div
|
||||
class: "panel-body padded select-list text-center"
|
||||
outlet: 'body'
|
||||
=>
|
||||
@div =>
|
||||
@span
|
||||
class: 'text-center loading loading-spinner-large inline-block'
|
||||
@div
|
||||
class: ''
|
||||
'Beautification in progress.'
|
||||
class: 'overlay from-top', =>
|
||||
@div class: "tool-panel panel-bottom", =>
|
||||
@div class: "inset-panel", =>
|
||||
@div class: "panel-heading", =>
|
||||
@div class: 'btn-toolbar pull-right', =>
|
||||
@button
|
||||
class: 'btn'
|
||||
click: 'hide'
|
||||
'Hide'
|
||||
@span
|
||||
class: 'text-primary'
|
||||
outlet: 'title'
|
||||
'Atom Beautify'
|
||||
@div
|
||||
class: "panel-body padded select-list text-center"
|
||||
outlet: 'body'
|
||||
=>
|
||||
@div =>
|
||||
@span
|
||||
class: 'text-center loading loading-spinner-large inline-block'
|
||||
@div
|
||||
class: ''
|
||||
'Beautification in progress.'
|
||||
|
||||
hide: (event, element) =>
|
||||
@detach()
|
||||
hide: (event, element) =>
|
||||
@detach()
|
||||
|
||||
show: =>
|
||||
if not @.hasParent()
|
||||
atom.workspace.addTopPanel(item: @)
|
||||
show: =>
|
||||
if not @.hasParent()
|
||||
atom.workspace.addTopPanel(item: @)
|
||||
|
|
|
@ -2,80 +2,80 @@
|
|||
|
||||
module.exports =
|
||||
class MessageView extends View
|
||||
messages: []
|
||||
@content: ->
|
||||
@div
|
||||
class: 'atom-beautify message-panel', =>
|
||||
messages: []
|
||||
@content: ->
|
||||
@div
|
||||
class: 'overlay from-top', =>
|
||||
@div class: "tool-panel panel-bottom", =>
|
||||
@div class: "inset-panel", =>
|
||||
@div class: "panel-heading", =>
|
||||
@div class: 'btn-toolbar pull-right', =>
|
||||
@button
|
||||
class: 'btn'
|
||||
click: 'clearMessages'
|
||||
'Clear'
|
||||
@span
|
||||
class: ''
|
||||
outlet: 'title'
|
||||
'Atom Beautify Message'
|
||||
class: 'atom-beautify message-panel', =>
|
||||
@div
|
||||
class: "panel-body padded select-list"
|
||||
outlet: 'body'
|
||||
=>
|
||||
@ol
|
||||
class: 'list-group',
|
||||
outlet: 'messageItems'
|
||||
=>
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'This is the title'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'This is the title Currently there is no way to display a message to the user, such as errors or warnings or deprecation notices (see #40). Let\'s put a little overlay on the top for displaying such information.'
|
||||
@div class: 'secondary-line no-icon', 'This is the title Currently there is no way to display a message to the user, such as errors or warnings or deprecation notices (see #40). Let\'s put a little overlay on the top for displaying such information.'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'test'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'This is the title'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'This is the title'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-added icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-file-text', 'Primary line'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
class: 'overlay from-top', =>
|
||||
@div class: "tool-panel panel-bottom", =>
|
||||
@div class: "inset-panel", =>
|
||||
@div class: "panel-heading", =>
|
||||
@div class: 'btn-toolbar pull-right', =>
|
||||
@button
|
||||
class: 'btn'
|
||||
click: 'clearMessages'
|
||||
'Clear'
|
||||
@span
|
||||
class: ''
|
||||
outlet: 'title'
|
||||
'Atom Beautify Message'
|
||||
@div
|
||||
class: "panel-body padded select-list"
|
||||
outlet: 'body'
|
||||
=>
|
||||
@ol
|
||||
class: 'list-group',
|
||||
outlet: 'messageItems'
|
||||
=>
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'This is the title'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'This is the title Currently there is no way to display a message to the user, such as errors or warnings or deprecation notices (see #40). Let\'s put a little overlay on the top for displaying such information.'
|
||||
@div class: 'secondary-line no-icon', 'This is the title Currently there is no way to display a message to the user, such as errors or warnings or deprecation notices (see #40). Let\'s put a little overlay on the top for displaying such information.'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'test'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'This is the title'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-removed icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-alert', 'This is the title'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
@li class: 'two-lines', =>
|
||||
@div class: 'status status-added icon icon-diff-added', ''
|
||||
@div class: 'primary-line icon icon-file-text', 'Primary line'
|
||||
@div class: 'secondary-line no-icon', 'Secondary line'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
destroy: ->
|
||||
destroy: ->
|
||||
|
||||
addMessage: (message) =>
|
||||
@messages.push(message);
|
||||
@refresh()
|
||||
addMessage: (message) =>
|
||||
@messages.push(message);
|
||||
@refresh()
|
||||
|
||||
clearMessages: =>
|
||||
@messages = []
|
||||
@refresh()
|
||||
clearMessages: =>
|
||||
@messages = []
|
||||
@refresh()
|
||||
|
||||
close: (event, element) =>
|
||||
@detach()
|
||||
close: (event, element) =>
|
||||
@detach()
|
||||
|
||||
show: =>
|
||||
if not @.hasParent()
|
||||
atom.workspaceView.appendToTop @
|
||||
show: =>
|
||||
if not @.hasParent()
|
||||
atom.workspaceView.appendToTop @
|
||||
|
||||
refresh: =>
|
||||
# If the messages list is empty, view should be closed.
|
||||
if @messages.length is 0
|
||||
@close()
|
||||
else
|
||||
@show()
|
||||
refresh: =>
|
||||
# If the messages list is empty, view should be closed.
|
||||
if @messages.length is 0
|
||||
@close()
|
||||
else
|
||||
@show()
|
||||
|
|
Loading…
Reference in New Issue