updated to v1.14

This commit is contained in:
Dan Remollino
2023-04-03 14:23:38 -04:00
parent 941844d99a
commit 6c0bf3cbf3
4 changed files with 64 additions and 37 deletions

View File

@ -1,3 +1,8 @@
## Version 1.14
- added Lua, Perl, Python, Ruby, SASS, XML, and YAML to list of supported languages for auto-commenting
- fixed top/bottom border outputting too long if respective border character setting was greater than one character in length
- fixed top/bottom border applying left border characters on the right border when a respective padding was set in conjuction with a left or right border
## Version 1.13
- added option to set how FIGcharacters are spaced

View File

@ -4,7 +4,7 @@
- convert selection to FIGlet text
- select FIGlet font
- configure FIGlet text output options
- auto comment converted text; supported syntaxes: CSS, HTML, Javascript, PHP, Typescript, and SCSS
- auto comment converted text; supported syntaxes: CSS, HTML, Javascript, Lua, Perl, PHP, Python, Sass, SCSS, Typescript, Ruby, XML, and YAML
- add padding, borders, and margins
- generate a custom previews of all Homebrew installed font collections

View File

@ -101,14 +101,26 @@ nova.commands.register('figletTextEditor', editor => {
const getCommentChars = () => {
switch (editor.document.syntax) {
case 'css':
case 'sass':
case 'scss':
return {block: {start: '/*', end: '*/'}, inline: {start: '/*', end: '*/'}}
case 'html':
case 'xml':
return {block: {start: '<!--', end: '-->'}, inline: {start: '<!--', end: '-->'}}
case 'javascript':
case 'typescript':
case 'php':
return {block: {start: '/*', end: '*/'}, inline: {start: '//', end: ''}}
case 'lua':
return {block: {start: '--[[', end: '--]]'}, inline: {start: '--', end: ''}}
case 'perl':
return {block: {start: '=', end: '=cut'}, inline: {start: '#', end: ''}}
case 'python':
return {block: {start: '"""', end: '"""'}, inline: {start: '#', end: ''}}
case 'ruby':
return {block: {start: '=begin', end: '=end'}, inline: {start: '#', end: ''}}
case 'yaml':
return {block: null, inline: {start: '#', end: ''}}
default:
return null
}
@ -142,7 +154,7 @@ nova.commands.register('figletTextEditor', editor => {
let longestLine = 0
figletTextArr.map(line => { if (line.length > longestLine) longestLine = line.length })
let additionalWidth = ((borders.left.width * borders.left.char.length) + borders.left.padding) + ((borders.right.width * borders.right.char.length) + borders.right.padding)
let outputLength = longestLine + (((borders.left.width * borders.left.char.length) + borders.left.padding) + ((borders.right.width * borders.right.char.length) + borders.right.padding))
// top/bottom transformations need to be buffered and applied
// after left/right transformations which are done line by and
@ -176,7 +188,7 @@ nova.commands.register('figletTextEditor', editor => {
} else {
for (let count = borders.top.padding; count; count--) {
borderBuffer.paddingTop.push(
borders.left.char.repeat(borders.left.width) + ' '.repeat(longestLine + borders.left.padding + borders.right.padding) + borders.left.char.repeat(borders.right.width)
borders.left.char.repeat(borders.left.width) + ' '.repeat(longestLine + borders.left.padding + borders.right.padding) + borders.right.char.repeat(borders.right.width)
)
}
}
@ -188,7 +200,7 @@ nova.commands.register('figletTextEditor', editor => {
} else {
for (let count = borders.bottom.padding; count; count--) {
borderBuffer.paddingBottom.push(
borders.left.char.repeat(borders.left.width) + ' '.repeat(longestLine + borders.left.padding + borders.right.padding) + borders.left.char.repeat(borders.right.width)
borders.left.char.repeat(borders.left.width) + ' '.repeat(longestLine + borders.left.padding + borders.right.padding) + borders.right.char.repeat(borders.right.width)
)
}
}
@ -217,12 +229,12 @@ nova.commands.register('figletTextEditor', editor => {
break
case 'top':
for (let count = 0; count < borders[border].width; count++) {
borderBuffer.widthTop.push(`${borders[border].char.repeat(longestLine + additionalWidth)}`)
borderBuffer.widthTop.push(`${borders[border].char.repeat(outputLength)}`.slice(0, outputLength))
}
break
case 'bottom':
for (let count = 0; count < borders[border].width; count++) {
borderBuffer.widthBottom.push(`${borders[border].char.repeat(longestLine + additionalWidth)}`)
borderBuffer.widthBottom.push(`${borders[border].char.repeat(outputLength)}`.slice(0, outputLength))
}
break
}
@ -235,8 +247,9 @@ nova.commands.register('figletTextEditor', editor => {
if (!borderBuffer.widthBottom.empty) figletTextArr = figletTextArr.concat(borderBuffer.widthBottom)
}
// comment each line if the option is enabled and a
// comment structure is defined for the current syntax
let addComments = () => {
// comment if the option is enabled and a
// structure is defined for the current syntax
if (commentsEnabled && getCommentChars() !== null) {
switch (commentType) {
case 'inline':
@ -257,6 +270,13 @@ nova.commands.register('figletTextEditor', editor => {
})
break
case 'block':
// if block comments are not available for syntax, use inline
if (getCommentChars().block === null) {
commentType = 'inline'
addComments()
break
}
if (commentPadding.block > 0) {
figletTextArr.unshift('\n'.repeat(commentPadding.block - 1))
figletTextArr.push('\n'.repeat(commentPadding.block - 1))
@ -266,6 +286,8 @@ nova.commands.register('figletTextEditor', editor => {
break
}
}
}
addComments()
// add margins if the option is enabled
if (marginsEnabled) {

View File

@ -3,7 +3,7 @@
"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.13",
"version": "1.14",
"categories": ["commands", "formatters"],
"entitlements": {
@ -524,14 +524,14 @@
{
"key": "figlet_text.comment",
"title": "Enable Comments",
"description": "FIGlet Text will auto line comment the output. Currently supported in CSS, HTML, Javascript, PHP, Typescript, and SCSS syntaxes.",
"description": "Auto comment the output. Supported in CSS, HTML, Javascript, Lua, Perl, PHP, Python, Sass, SCSS, Typescript, Ruby, XML, and YAML syntaxes.",
"type": "boolean",
"default": true
},
{
"key": "figlet_text.commentType",
"title": "Comment Type",
"description": "Comment output line by line or as a single block.",
"description": "Comment output as a single block or line by line.",
"type": "enum",
"values": [["block", "Block"], ["inline", "Inline"]],
"default": "inline"