updated to v1.6
This commit is contained in:
@ -1,3 +1,6 @@
|
|||||||
|
## Version 1.6
|
||||||
|
- added option to auto comment FIGlet converted output for CSS, HTML, Javascript, and PHP syntaxes
|
||||||
|
|
||||||
## Version 1.5.1
|
## Version 1.5.1
|
||||||
- added extension to 'formatters' category
|
- added extension to 'formatters' category
|
||||||
- added Repository link
|
- added Repository link
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
|
# Features
|
||||||
|
- convert selected text to FIGlet text
|
||||||
|
- select FIGlet font
|
||||||
|
- configure FIGlet text output options
|
||||||
|
- option to auto comment converted text (HTML, Javascript, and PHP syntaxes only)
|
||||||
|
- prepend/append new lines to converted text
|
||||||
|
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
## FIGlet
|
## FIGlet
|
||||||
FIGlet Text requires [FIGlet](http://www.figlet.org) to be installed locally. It is recommended to install FIGlet using [Homebrew](https://brew.sh). Once Homebrew is installed, simply run `brew install figlet`.
|
FIGlet Text requires [FIGlet](http://www.figlet.org) to be installed locally. It is recommended to install FIGlet using [Homebrew](https://brew.sh). Once Homebrew is installed, simply run `brew install figlet`.
|
||||||
|
|
||||||
## Monospaced Fonts
|
## Monospaced Fonts
|
||||||
It is recommended to only use a monospaced font in Nova. Not doing so will result in garbled looking FIGlet conversions.
|
It is recommended to only use a monospaced font in Nova. Not doing so will result in garbled looking FIGlet conversions.
|
||||||
|
|
||||||
# How to Use FIGlet Text
|
# How to Use FIGlet Text
|
||||||
FIGlet Text will add a 'Create FIGlet Text from Selection' menu item to the Editor menu. Make one or more selections in the editor and run the command.
|
FIGlet Text will add a 'Convert Selection to FIGlet' menu item to the Editor menu. Make one or more selections in the editor and run the command.
|
||||||
|
|
||||||
# TODO
|
|
||||||
- option to auto comment converted text
|
|
||||||
|
@ -31,8 +31,12 @@ nova.commands.register('figlet', (workspace, figletArgs, textToConvert, postConv
|
|||||||
let figTextStr = ''
|
let figTextStr = ''
|
||||||
process.onDidExit(status => {
|
process.onDidExit(status => {
|
||||||
if (status === 0) {
|
if (status === 0) {
|
||||||
// the converted text from FIGlet as a string
|
// trim any whitespace from the end of each line; FIGlet seems
|
||||||
figTextStr = figTextArr.join('').trimEnd()
|
// to add a single column of whitespace more than what is required
|
||||||
|
figTextArr = figTextArr.map(line => { return line.trimEnd() })
|
||||||
|
|
||||||
|
// convert to a string
|
||||||
|
figTextStr = figTextArr.join('\n')
|
||||||
postConversion(figTextStr)
|
postConversion(figTextStr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -41,18 +45,7 @@ nova.commands.register('figlet', (workspace, figletArgs, textToConvert, postConv
|
|||||||
})
|
})
|
||||||
|
|
||||||
// FIGlet convert the selected text in the editor
|
// FIGlet convert the selected text in the editor
|
||||||
nova.commands.register('createFigletText', editor => {
|
nova.commands.register('figletTextEditor', editor => {
|
||||||
// console.log(editor.document.syntax)
|
|
||||||
|
|
||||||
let printNewLines = numOfLines => {
|
|
||||||
let newLinesStr = ''
|
|
||||||
while (numOfLines > 0) {
|
|
||||||
newLinesStr += '\n'
|
|
||||||
numOfLines--
|
|
||||||
}
|
|
||||||
return newLinesStr
|
|
||||||
}
|
|
||||||
|
|
||||||
let figConfig = {
|
let figConfig = {
|
||||||
font: '-f' + nova.config.get('figlet_text.font', 'string'),
|
font: '-f' + nova.config.get('figlet_text.font', 'string'),
|
||||||
outputWidth: '-w' + nova.config.get('figlet_text.outputWidth', 'number'),
|
outputWidth: '-w' + nova.config.get('figlet_text.outputWidth', 'number'),
|
||||||
@ -60,6 +53,16 @@ nova.commands.register('createFigletText', editor => {
|
|||||||
justification: nova.config.get('figlet_text.justification', 'string'),
|
justification: nova.config.get('figlet_text.justification', 'string'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let syntax = editor.document.syntax
|
||||||
|
let comment = nova.config.get('figlet_text.comment', 'boolean')
|
||||||
|
let commentPadding = nova.config.get('figlet_text.commentPadding', 'number')
|
||||||
|
let commentPaddingStr = nova.config.get('figlet_text.commentPaddingStr', 'string')
|
||||||
|
let commentChars = {
|
||||||
|
css: {start: '/*', end: '*/'},
|
||||||
|
html: {start: '<!--', end: '-->'},
|
||||||
|
javascript: {start: '//', end: ''},
|
||||||
|
php: {start: '//', end: ''}
|
||||||
|
}
|
||||||
let prependNewLines = nova.config.get('figlet_text.prependNewLines', 'number')
|
let prependNewLines = nova.config.get('figlet_text.prependNewLines', 'number')
|
||||||
let appendNewLines = nova.config.get('figlet_text.appendNewLines', 'number')
|
let appendNewLines = nova.config.get('figlet_text.appendNewLines', 'number')
|
||||||
|
|
||||||
@ -69,15 +72,32 @@ nova.commands.register('createFigletText', editor => {
|
|||||||
let text = editor.getTextInRange(range)
|
let text = editor.getTextInRange(range)
|
||||||
|
|
||||||
nova.commands.invoke('figlet', figConfig, text, figletText => {
|
nova.commands.invoke('figlet', figConfig, text, figletText => {
|
||||||
// // prepend/append new lines
|
// comment each line if the option is selected
|
||||||
if (appendNewLines > 0) { figletText = figletText.concat(printNewLines(figConfig.appendNewLines)) }
|
if (comment && (syntax === 'css' || syntax === 'html' || syntax === 'javascript' || syntax === 'php')) {
|
||||||
if (prependNewLines > 0) { figletText = printNewLines(figConfig.prependNewLines).concat(figletText) }
|
let lines = figletText.split('\n')
|
||||||
|
|
||||||
// replace the selection with the converted FIGlet text
|
let longestLine = 0
|
||||||
editor.edit(e => {
|
lines.map(line => {
|
||||||
e.replace(range, figletText)
|
if (line.length > longestLine) longestLine = line.length
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let linesCommented = lines.map(line => {
|
||||||
|
let linePadding = 0
|
||||||
|
if (line.length < longestLine && (commentChars[syntax].end !== '')) linePadding = longestLine - line.length
|
||||||
|
return `${commentChars[syntax].start}${commentPaddingStr.repeat(commentPadding)}${line}${' '.repeat(linePadding)}${commentPaddingStr.repeat(commentPadding)}${commentChars[syntax].end}`.trimEnd()
|
||||||
|
})
|
||||||
|
|
||||||
|
figletText = linesCommented.join('\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepend/append new lines
|
||||||
|
if (prependNewLines > 0) figletText = `${'\n'.repeat(prependNewLines)}${figletText}`
|
||||||
|
if (appendNewLines > 0) figletText = `${figletText}${'\n'.repeat(appendNewLines)}`
|
||||||
|
|
||||||
|
// replace the selection with the converted/transformed FIGlet text
|
||||||
|
editor.edit(e => { e.replace(range, figletText) })
|
||||||
|
|
||||||
|
// deselect and position the cursor
|
||||||
editor.moveRight(1)
|
editor.moveRight(1)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "FIGlet Text",
|
"name": "FIGlet Text",
|
||||||
"organization": "Dan Remollino",
|
"organization": "Dan Remollino",
|
||||||
"description": "Convert selected text to FIGlet. Great for adding readable text to the Minimap, creating l33t text headers, and organizing files.",
|
"description": "Convert selected text to FIGlet. Great for adding readable text to the Minimap, creating l33t text headers, and organizing files.",
|
||||||
"version": "1.5.1",
|
"version": "1.6",
|
||||||
"categories": ["commands", "formatters"],
|
"categories": ["commands", "formatters"],
|
||||||
|
|
||||||
"entitlements": {
|
"entitlements": {
|
||||||
@ -199,7 +199,7 @@
|
|||||||
{
|
{
|
||||||
"type": "section",
|
"type": "section",
|
||||||
"required": false,
|
"required": false,
|
||||||
"title": "Output",
|
"title": "Text",
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"key": "figlet_text.outputWidth",
|
"key": "figlet_text.outputWidth",
|
||||||
@ -228,6 +228,35 @@
|
|||||||
"radio": false,
|
"radio": false,
|
||||||
"values": [["-x", "Auto"], ["-l", "Left"], ["-c", "Center"], ["-r", "Right"]],
|
"values": [["-x", "Auto"], ["-l", "Left"], ["-c", "Center"], ["-r", "Right"]],
|
||||||
"default": "-x"
|
"default": "-x"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"type": "section",
|
||||||
|
"required": false,
|
||||||
|
"title": "Transformation",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"key": "figlet_text.comment",
|
||||||
|
"title": "Comment FIGlet Output",
|
||||||
|
"description": "FIGlet Text will auto line comment the output. Currently supported in CSS, HTML, Javascript, and PHP syntaxes.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "figlet_text.commentPadding",
|
||||||
|
"title": "Comment Padding",
|
||||||
|
"description": "The number of Comment Padding Characters to add between the converted text and comment symbols.",
|
||||||
|
"type": "number",
|
||||||
|
"default": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "figlet_text.commentPaddingStr",
|
||||||
|
"title": "Comment Padding Character",
|
||||||
|
"description": "Text string to use as Comment Padding. Defaults to a single space.",
|
||||||
|
"type": "string",
|
||||||
|
"default": " "
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "figlet_text.prependNewLines",
|
"key": "figlet_text.prependNewLines",
|
||||||
@ -250,8 +279,8 @@
|
|||||||
"commands": {
|
"commands": {
|
||||||
"editor": [
|
"editor": [
|
||||||
{
|
{
|
||||||
"title": "Create FIGlet Text from Selection",
|
"title": "Convert Selection to FIGlet",
|
||||||
"command": "createFigletText",
|
"command": "figletTextEditor",
|
||||||
"shortcut": "ctrl-opt-cmd-f",
|
"shortcut": "ctrl-opt-cmd-f",
|
||||||
"when": "editorHasSelection"
|
"when": "editorHasSelection"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user