updated to v1.12
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## Version 1.12
|
||||
- added option toggle margin output
|
||||
- added separate Comment Padding output options for block and inline comments
|
||||
|
||||
## Version 1.11
|
||||
- added option to use inline or block comments
|
||||
|
||||
|
@ -92,7 +92,10 @@ nova.commands.register('figletTextEditor', editor => {
|
||||
|
||||
let commentsEnabled = nova.config.get('figlet_text.comment', 'boolean')
|
||||
let commentType = nova.config.get('figlet_text.commentType', 'string')
|
||||
let commentPadding = nova.config.get('figlet_text.commentPadding', 'number')
|
||||
let commentPadding = {
|
||||
block: nova.config.get('figlet_text.commentPaddingBlock', 'number'),
|
||||
inline: nova.config.get('figlet_text.commentPaddingInline', 'number')
|
||||
}
|
||||
let commentPaddingStr = nova.config.get('figlet_text.commentPaddingStr', 'string')
|
||||
const getCommentChars = () => {
|
||||
switch (editor.document.syntax) {
|
||||
@ -110,6 +113,7 @@ nova.commands.register('figletTextEditor', editor => {
|
||||
}
|
||||
}
|
||||
|
||||
let marginsEnabled = nova.config.get('figlet_text.margins', 'boolean')
|
||||
let prependNewLines = nova.config.get('figlet_text.prependNewLines', 'number')
|
||||
let appendNewLines = nova.config.get('figlet_text.appendNewLines', 'number')
|
||||
|
||||
@ -132,7 +136,7 @@ nova.commands.register('figletTextEditor', editor => {
|
||||
// easier to modify line by line; order of transformations matter
|
||||
let figletTextArr = figletText.split('\n')
|
||||
|
||||
// add borders if the option is enabled
|
||||
// add borders/padding if the option is enabled
|
||||
if (bordersEnabled) {
|
||||
let longestLine = 0
|
||||
figletTextArr.map(line => { if (line.length > longestLine) longestLine = line.length })
|
||||
@ -230,7 +234,7 @@ nova.commands.register('figletTextEditor', editor => {
|
||||
if (!borderBuffer.widthBottom.empty) figletTextArr = figletTextArr.concat(borderBuffer.widthBottom)
|
||||
}
|
||||
|
||||
// comment each line if the option is selected and a
|
||||
// comment each line if the option is enabled and a
|
||||
// comment structure is defined for the current syntax
|
||||
if (commentsEnabled && getCommentChars() !== null) {
|
||||
switch (commentType) {
|
||||
@ -248,20 +252,26 @@ nova.commands.register('figletTextEditor', editor => {
|
||||
|
||||
// return the commented line if not whitespace
|
||||
if (/^\s+$/.test(line)) return '\n'
|
||||
return `${getCommentChars().inline.start}${commentPaddingStr.repeat(commentPadding)}${line}${' '.repeat(linePadding)}${commentPaddingStr.repeat(commentPadding)}${getCommentChars().inline.end}`.trimEnd()
|
||||
return `${getCommentChars().inline.start}${commentPaddingStr.repeat(commentPadding.inline)}${line}${' '.repeat(linePadding)}${commentPaddingStr.repeat(commentPadding.inline)}${getCommentChars().inline.end}`.trimEnd()
|
||||
})
|
||||
break
|
||||
case 'block':
|
||||
if (commentPadding.block > 0) {
|
||||
figletTextArr.unshift('\n'.repeat(commentPadding.block - 1))
|
||||
figletTextArr.push('\n'.repeat(commentPadding.block - 1))
|
||||
}
|
||||
figletTextArr.unshift(getCommentChars().block.start)
|
||||
figletTextArr.push(getCommentChars().block.end)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// prepend/append new lines
|
||||
// add margins if the option is enabled
|
||||
if (marginsEnabled) {
|
||||
// subtract one; Array.prototype.join('\n') before editor output
|
||||
if (prependNewLines > 0) figletTextArr = [`${'\n'.repeat(prependNewLines - 1)}`].concat(figletTextArr)
|
||||
if (appendNewLines > 0) figletTextArr = figletTextArr.concat([`${'\n'.repeat(appendNewLines - 1)}`])
|
||||
if (appendNewLines > 0) figletTextArr = figletTextArr.concat([`${'\n'.repeat(appendNewLines)}`])
|
||||
}
|
||||
|
||||
// indent subsequent lines after the first if
|
||||
// the line with the selection was indented
|
||||
|
@ -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.11",
|
||||
"version": "1.12",
|
||||
"categories": ["commands", "formatters"],
|
||||
|
||||
"entitlements": {
|
||||
@ -523,19 +523,26 @@
|
||||
"title": "Comment Type",
|
||||
"description": "Comment output line by line or as a single block.",
|
||||
"type": "enum",
|
||||
"values": [["inline", "Inline"], ["block", "Block"]],
|
||||
"values": [["block", "Block"], ["inline", "Inline"]],
|
||||
"default": "inline"
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.commentPadding",
|
||||
"title": "Comment Padding",
|
||||
"description": "The number of Comment Padding Characters to add between the converted text and comment symbols.",
|
||||
"key": "figlet_text.commentPaddingBlock",
|
||||
"title": "Block Comment Padding",
|
||||
"description": "The number of new lines to add between the converted text and comment symbols.",
|
||||
"type": "number",
|
||||
"default": 1
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.commentPaddingInline",
|
||||
"title": "Inline Comment Padding",
|
||||
"description": "The number of Comment Padding Characters to add between the converted text and comment symbols on each line.",
|
||||
"type": "number",
|
||||
"default": 4
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.commentPaddingStr",
|
||||
"title": "Comment Padding Character",
|
||||
"title": "Inline Comment Padding Character",
|
||||
"description": "Text string to use as Comment Padding. Defaults to a single space.",
|
||||
"type": "string",
|
||||
"default": " "
|
||||
@ -640,19 +647,26 @@
|
||||
"title": "Margins",
|
||||
"description": "Spacing between FIGlet text and your content.",
|
||||
"children": [
|
||||
{
|
||||
"key": "figlet_text.margins",
|
||||
"title": "Enable Margins",
|
||||
"description": "Toggle margin output without needing to change individual settings.",
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.prependNewLines",
|
||||
"title": "Top Margin",
|
||||
"description": "Amount of new lines to prepend to the converted text.",
|
||||
"type": "number",
|
||||
"default": 0
|
||||
"default": 4
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.appendNewLines",
|
||||
"title": "Bottom Margin",
|
||||
"description": "Amount of new lines to append to the converted text.",
|
||||
"description": "Amount of new lines to append to the converted text. The curser will be placed on the line after the appended lines.",
|
||||
"type": "number",
|
||||
"default": 0
|
||||
"default": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user