initial commit
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# editor configs
|
||||
.nova
|
1
FIGlet Text.novaextension/.gitignore
vendored
Normal file
1
FIGlet Text.novaextension/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.DS_Store
|
27
FIGlet Text.novaextension/CHANGELOG.md
Normal file
27
FIGlet Text.novaextension/CHANGELOG.md
Normal file
@ -0,0 +1,27 @@
|
||||
## Version 1.5.1
|
||||
- added extension to 'formatters' category
|
||||
|
||||
## Version 1.5
|
||||
- check for and remove some FIGlet fonts adding lines containing only whitespace at conversion
|
||||
- refactored FIGlet conversion process
|
||||
|
||||
## Version 1.4
|
||||
- added font preview to Font options
|
||||
- removed unneeded filesystem entitlement
|
||||
|
||||
## Version 1.3
|
||||
- added option to prepend and append new lines after conversion
|
||||
- converted text is now automatically deselected and the cursor is moved to the end of conversion
|
||||
- updated extension configuration descriptions
|
||||
|
||||
## Version 1.2
|
||||
- added Output options to extension configuration
|
||||
|
||||
## Version 1.1.1
|
||||
- updated configuration storage keys
|
||||
|
||||
## Version 1.1
|
||||
- added Font options to extension configuration
|
||||
|
||||
## Version 1.0
|
||||
- initial release
|
12
FIGlet Text.novaextension/README.md
Normal file
12
FIGlet Text.novaextension/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Requirements
|
||||
|
||||
## 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
|
||||
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
|
||||
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.
|
||||
|
||||
# TODO
|
||||
- option to auto comment converted text
|
107
FIGlet Text.novaextension/Scripts/main.js
Normal file
107
FIGlet Text.novaextension/Scripts/main.js
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* Convert the supplied text to FIGlet format
|
||||
*
|
||||
* @param workspace - Workspace, default first argument, see Nova extension docs
|
||||
https://docs.nova.app/api-reference/commands-registry/#registername-callable-thisvalue
|
||||
* @param figletArgs - key/value obj, command line arguments for FIGlet configuration
|
||||
* @param textToConvert - str, the text to convert with FIGlet
|
||||
* @param postConversion - func, callback to run on the figlet converted text string,
|
||||
receives the FIGlet converted string as an argument;
|
||||
output/modification of the FIGlet text should be done here
|
||||
* @returns a Disposable, see Nova extension docs https://docs.nova.app/api-reference/disposable/
|
||||
*/
|
||||
nova.commands.register('figlet', (workspace, figletArgs, textToConvert, postConversion) => {
|
||||
let args = ['figlet']
|
||||
for (const arg in figletArgs) {
|
||||
args.push(figletArgs[arg])
|
||||
}
|
||||
args.push(textToConvert)
|
||||
|
||||
const process = new Process('/usr/bin/env', {args})
|
||||
|
||||
let figTextArr = []
|
||||
process.onStdout(line => {
|
||||
// test if a line contains only whitespace, some
|
||||
// FIGlet fonts will add a line or two for fun
|
||||
if (!/^\s+$/.test(line)) {
|
||||
figTextArr.push(line)
|
||||
}
|
||||
})
|
||||
|
||||
let figTextStr = ''
|
||||
process.onDidExit(status => {
|
||||
if (status === 0) {
|
||||
// the converted text from FIGlet as a string
|
||||
figTextStr = figTextArr.join('').trimEnd()
|
||||
postConversion(figTextStr)
|
||||
}
|
||||
})
|
||||
|
||||
process.start()
|
||||
})
|
||||
|
||||
// FIGlet convert the selected text in the editor
|
||||
nova.commands.register('createFigletText', editor => {
|
||||
// console.log(editor.document.syntax)
|
||||
|
||||
let printNewLines = numOfLines => {
|
||||
let newLinesStr = ''
|
||||
while (numOfLines > 0) {
|
||||
newLinesStr += '\n'
|
||||
numOfLines--
|
||||
}
|
||||
return newLinesStr
|
||||
}
|
||||
|
||||
let figConfig = {
|
||||
font: '-f' + nova.config.get('figlet_text.font', 'string'),
|
||||
outputWidth: '-w' + nova.config.get('figlet_text.outputWidth', 'number'),
|
||||
textDirection: nova.config.get('figlet_text.textDirection', 'string'),
|
||||
justification: nova.config.get('figlet_text.justification', 'string'),
|
||||
}
|
||||
|
||||
let prependNewLines = nova.config.get('figlet_text.prependNewLines', 'number')
|
||||
let appendNewLines = nova.config.get('figlet_text.appendNewLines', 'number')
|
||||
|
||||
let selectedRanges = editor.selectedRanges.reverse()
|
||||
|
||||
for (let range of selectedRanges) {
|
||||
let text = editor.getTextInRange(range)
|
||||
|
||||
nova.commands.invoke('figlet', figConfig, text, figletText => {
|
||||
// // prepend/append new lines
|
||||
if (appendNewLines > 0) { figletText = figletText.concat(printNewLines(figConfig.appendNewLines)) }
|
||||
if (prependNewLines > 0) { figletText = printNewLines(figConfig.prependNewLines).concat(figletText) }
|
||||
|
||||
// replace the selection with the converted FIGlet text
|
||||
editor.edit(e => {
|
||||
e.replace(range, figletText)
|
||||
})
|
||||
|
||||
editor.moveRight(1)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// FIGlet convert the preview text in the extension config
|
||||
nova.commands.register('figletTextFontPreview', workspace => {
|
||||
let figConfig = {
|
||||
kerning: '-k',
|
||||
outputWidth: '-w' + 2000,
|
||||
font: '-f' + nova.config.get('figlet_text.font', 'string')
|
||||
}
|
||||
|
||||
let text = nova.config.get('figlet_text.previewText', 'string')
|
||||
|
||||
nova.commands.invoke('figlet', figConfig, text, figletText => {
|
||||
nova.config.set('figlet_text.preview', figletText)
|
||||
})
|
||||
})
|
||||
// listen for changes to the Font selection dropdown in the extension config
|
||||
nova.config.onDidChange('figlet_text.font', (newValue, oldValue) => {
|
||||
nova.commands.invoke('figletTextFontPreview')
|
||||
})
|
||||
// listen for changes to the Preview Text input in the extension config
|
||||
nova.config.onDidChange('figlet_text.previewText', (newValue, oldValue) => {
|
||||
nova.commands.invoke('figletTextFontPreview')
|
||||
})
|
262
FIGlet Text.novaextension/extension.json
Normal file
262
FIGlet Text.novaextension/extension.json
Normal file
@ -0,0 +1,262 @@
|
||||
{
|
||||
"identifier": "dev.danremollino.figlettext",
|
||||
"name": "FIGlet Text",
|
||||
"organization": "Dan Remollino",
|
||||
"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",
|
||||
"categories": ["commands", "formatters"],
|
||||
|
||||
"entitlements": {
|
||||
"clipboard": false,
|
||||
"process": true,
|
||||
"requests": false,
|
||||
"filesystem": false
|
||||
},
|
||||
|
||||
"main": "main.js",
|
||||
|
||||
"config": [
|
||||
{
|
||||
"type": "section",
|
||||
"required": false,
|
||||
"title": "Font",
|
||||
"children": [
|
||||
{
|
||||
"key": "figlet_text.font",
|
||||
"title": "Font",
|
||||
"description": "The FIGlet font to use when converting text.",
|
||||
"link": "http://www.figlet.org/examples.html",
|
||||
"type": "enum",
|
||||
"radio": false,
|
||||
"values": [
|
||||
"3-d",
|
||||
"3x5",
|
||||
"5lineoblique",
|
||||
"acrobatic",
|
||||
"alligator",
|
||||
"alligator2",
|
||||
"alphabet",
|
||||
"avatar",
|
||||
"banner",
|
||||
"banner3-D",
|
||||
"banner3",
|
||||
"banner4",
|
||||
"barbwire",
|
||||
"basic",
|
||||
"bell",
|
||||
"big",
|
||||
"bigchief",
|
||||
"binary",
|
||||
"block",
|
||||
"bubble",
|
||||
"bulbhead",
|
||||
"calgphy2",
|
||||
"caligraphy",
|
||||
"catwalk",
|
||||
"chunky",
|
||||
"coinstak",
|
||||
"colossal",
|
||||
"computer",
|
||||
"contessa",
|
||||
"contrast",
|
||||
"cosmic",
|
||||
"cosmike",
|
||||
"cricket",
|
||||
"cursive",
|
||||
"cyberlarge",
|
||||
"cybermedium",
|
||||
"cybersmall",
|
||||
"diamond",
|
||||
"digital",
|
||||
"doh",
|
||||
"doom",
|
||||
"dotmatrix",
|
||||
"drpepper",
|
||||
"eftichess",
|
||||
"eftifont",
|
||||
"eftipiti",
|
||||
"eftirobot",
|
||||
"eftitalic",
|
||||
"eftiwall",
|
||||
"eftiwater",
|
||||
"epic",
|
||||
"fender",
|
||||
"fourtops",
|
||||
"fuzzy",
|
||||
"goofy",
|
||||
"gothic",
|
||||
"graffiti",
|
||||
"hollywood",
|
||||
"invita",
|
||||
"isometric1",
|
||||
"isometric2",
|
||||
"isometric3",
|
||||
"isometric4",
|
||||
"italic",
|
||||
"ivrit",
|
||||
"jazmine",
|
||||
"jerusalem",
|
||||
"katakana",
|
||||
"kban",
|
||||
"larry3d",
|
||||
"lcd",
|
||||
"lean",
|
||||
"letters",
|
||||
"linux",
|
||||
"lockergnome",
|
||||
"madrid",
|
||||
"marquee",
|
||||
"maxfour",
|
||||
"mike",
|
||||
"mini",
|
||||
"mirror",
|
||||
"mnemonic",
|
||||
"morse",
|
||||
"moscow",
|
||||
"nancyj-fancy",
|
||||
"nancyj-underlined",
|
||||
"nancyj",
|
||||
"nipples",
|
||||
"ntgreek",
|
||||
"o8",
|
||||
"ogre",
|
||||
"pawp",
|
||||
"peaks",
|
||||
"pebbles",
|
||||
"pepper",
|
||||
"poison",
|
||||
"puffy",
|
||||
"pyramid",
|
||||
"rectangles",
|
||||
"relief",
|
||||
"relief2",
|
||||
"rev",
|
||||
"roman",
|
||||
"rot13",
|
||||
"rounded",
|
||||
"rowancap",
|
||||
"rozzo",
|
||||
"runic",
|
||||
"runyc",
|
||||
"sblood",
|
||||
"script",
|
||||
"serifcap",
|
||||
"shadow",
|
||||
"short",
|
||||
"slant",
|
||||
"slide",
|
||||
"slscript",
|
||||
"small",
|
||||
"smisome1",
|
||||
"smkeyboard",
|
||||
"smscript",
|
||||
"smshadow",
|
||||
"smslant",
|
||||
"smtengwar",
|
||||
"speed",
|
||||
"stampatello",
|
||||
"standard",
|
||||
"starwars",
|
||||
"stellar",
|
||||
"stop",
|
||||
"straight",
|
||||
"tanja",
|
||||
"tengwar",
|
||||
"term",
|
||||
"thick",
|
||||
"thin",
|
||||
"threepoint",
|
||||
"ticks",
|
||||
"ticksslant",
|
||||
"tinker-toy",
|
||||
"tombstone",
|
||||
"trek",
|
||||
"tsalagi",
|
||||
"twopoint",
|
||||
"univers",
|
||||
"usaflag",
|
||||
"wavy",
|
||||
"weird"
|
||||
],
|
||||
"default": "banner3"
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.previewText",
|
||||
"title": "Preview Text",
|
||||
"description": "The text to output in the Preview textbox below.",
|
||||
"type": "string",
|
||||
"default": "FIGlet"
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.preview",
|
||||
"title": "Preview",
|
||||
"description": "Admittedly, this isn't the ideal preview as Nova uses a non-monospaced font for the Preview textbox above. Use the (?) link in the Font selection preference above to open the FIGlet examples webpage in an external browser, or copy the text above and paste it into an editor window.",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "section",
|
||||
"required": false,
|
||||
"title": "Output",
|
||||
"children": [
|
||||
{
|
||||
"key": "figlet_text.outputWidth",
|
||||
"title": "Output Width",
|
||||
"description": "The screen width FIGlet assumes when formatting its output. FIGlet will wrap text that is rendered larger than this value. An Output Width of 1 is a special value that tells FIGlet to print each non-space FIGcharacter on a separate line. This value will affect text justification.",
|
||||
"link": "http://www.figlet.org/figlet-man.html",
|
||||
"type": "number",
|
||||
"default": 80
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.textDirection",
|
||||
"title": "Text Direction",
|
||||
"description": "Controls whether FIGlet prints left-to-right or right-to-left. 'Auto' makes FIGlet use whichever is specified in the font file.",
|
||||
"link": "http://www.figlet.org/figlet-man.html",
|
||||
"type": "enum",
|
||||
"radio": false,
|
||||
"values": [["-X", "Auto"], ["-L", "Left-to-right"], ["-R", "Right-to-left"]],
|
||||
"default": "-X"
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.justification",
|
||||
"title": "Justification",
|
||||
"description": "Justification of FIGlet output. 'Auto' sets the justification according to the value of Text Direction.",
|
||||
"link": "http://www.figlet.org/figlet-man.html",
|
||||
"type": "enum",
|
||||
"radio": false,
|
||||
"values": [["-x", "Auto"], ["-l", "Left"], ["-c", "Center"], ["-r", "Right"]],
|
||||
"default": "-x"
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.prependNewLines",
|
||||
"title": "Prepend New Lines",
|
||||
"description": "Amount of new lines to prepend to the converted text.",
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.appendNewLines",
|
||||
"title": "Append New Lines",
|
||||
"description": "Amount of new lines to append to the converted text.",
|
||||
"type": "number",
|
||||
"default": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
"commands": {
|
||||
"editor": [
|
||||
{
|
||||
"title": "Create FIGlet Text from Selection",
|
||||
"command": "createFigletText",
|
||||
"shortcut": "ctrl-opt-cmd-f",
|
||||
"when": "editorHasSelection"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"bugs": "https://danremollino.dev"
|
||||
}
|
BIN
FIGlet Text.novaextension/extension.png
Normal file
BIN
FIGlet Text.novaextension/extension.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
FIGlet Text.novaextension/extension@2x.png
Normal file
BIN
FIGlet Text.novaextension/extension@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
icon.afdesign
Normal file
BIN
icon.afdesign
Normal file
Binary file not shown.
Reference in New Issue
Block a user