diff --git a/FIGlet Text.novaextension/CHANGELOG.md b/FIGlet Text.novaextension/CHANGELOG.md index 3c93220..9ae0a1e 100644 --- a/FIGlet Text.novaextension/CHANGELOG.md +++ b/FIGlet Text.novaextension/CHANGELOG.md @@ -1,3 +1,6 @@ +## Version 1.7 +- added 'Preview All Installed FIGlet Fonts' to Extensions menu + ## Version 1.6.4 - updated README.md diff --git a/FIGlet Text.novaextension/README.md b/FIGlet Text.novaextension/README.md index 829e6cf..6ff017b 100644 --- a/FIGlet Text.novaextension/README.md +++ b/FIGlet Text.novaextension/README.md @@ -6,6 +6,7 @@ - configure FIGlet text output options - auto comment converted text; supported syntaxes: CSS, HTML, Javascript, PHP, Typescript, and SCSS - prepend/append new lines to converted text +- generate a custom preview of all installed FIGlet fonts # Requirements @@ -20,4 +21,4 @@ FIGlet Text will add a 'Convert Selection to FIGlet' menu item to the Editor men # Planned Features - additional fonts -- all installed fonts preview +- borders diff --git a/FIGlet Text.novaextension/Scripts/main.js b/FIGlet Text.novaextension/Scripts/main.js index 1c9c41b..9ca2386 100644 --- a/FIGlet Text.novaextension/Scripts/main.js +++ b/FIGlet Text.novaextension/Scripts/main.js @@ -112,8 +112,8 @@ nova.commands.register('figletTextEditor', editor => { if (prependNewLines > 0) figletTextArr = Array.of(`${'\n'.repeat(prependNewLines)}`).concat(figletTextArr) if (appendNewLines > 0) figletTextArr = figletTextArr.concat(Array.of(`${'\n'.repeat(appendNewLines)}`)) - // indent subsequent lines after the line - // with an initial indented selection + // indent subsequent lines after the first if + // the line with the selection was indented if (!indentRange.empty) { figletTextArr = figletTextArr.map((line, index) => { if (index === 0) { @@ -160,3 +160,32 @@ nova.config.onDidChange('figlet_text.font', (newValue, oldValue) => { nova.config.onDidChange('figlet_text.previewText', (newValue, oldValue) => { nova.commands.invoke('figletTextFontPreview') }) + + +// preview all installed FIGlet fonts in an editor +nova.commands.register('figletTextFontPreviewAll', workspace => { + let message = 'Enter a custom preview text. Leave blank to use the font name for each font preview text output.' + let options = {label: 'Preview Text', placeholder: 'Use Font Name', prompt: 'Generate Previews'} + workspace.showInputPanel(message, options, value => { + if (typeof value !== 'undefined') { + const process = new Process('/usr/bin/env', {args: ['showfigfonts', value]}) + + let preview = '' + process.onStdout(line => { + preview += line + }) + + process.onDidExit(status => { + if (status === 0) { + workspace.openFile(nova.fs.tempdir + '/FIGlet Text | All Fonts Preview.txt') + .then(editor => { + editor.edit(e => { e.insert(0, preview) }) + editor.scrollToPosition(0) + }) + } + }) + + process.start() + } + }) +}) diff --git a/FIGlet Text.novaextension/extension.json b/FIGlet Text.novaextension/extension.json index 21c90c7..ed3532d 100644 --- a/FIGlet Text.novaextension/extension.json +++ b/FIGlet Text.novaextension/extension.json @@ -3,14 +3,14 @@ "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.6.4", + "version": "1.7", "categories": ["commands", "formatters"], "entitlements": { "clipboard": false, "process": true, "requests": false, - "filesystem": false + "filesystem": "readwrite" }, "main": "main.js", @@ -25,7 +25,6 @@ "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": [ @@ -190,7 +189,7 @@ { "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.", + "description": "Admittedly, this isn't the ideal preview as Nova uses a non-monospaced output for the Preview textbox above. Use the Extensions -> Preview All Installed FIGlet Fonts menu item to generate an accurate, custom text FIGlet font preview document.", "type": "text" } ] @@ -284,6 +283,12 @@ "shortcut": "ctrl-opt-cmd-f", "when": "editorHasSelection" } + ], + "extensions": [ + { + "title": "Preview All Installed FIGlet Fonts", + "command": "figletTextFontPreviewAll" + } ] },