App icon 1Writer

EnBox Double

Shared by Ben Hendry

Enclose selected text in double box

Script

var SelectedText = editor.getSelectedText();  //get selected text
SelectedText = SelectedText.toUpperCase() //make all caps
var PaddedText = " " + SelectedText + " "; //pad selection with spaces
var Length = SelectedText.length;  //find length of selection plus padding

//create the top and bottom lines for the boxes
var Line = "═";
var Count = 0;
while (Count <= Length)
{
Line = "═" + Line;
++Count;
}
var TopLine = "╔" + Line + "╗";
var TextLine = "║" + PaddedText + "║"; //create the final text line
var BottomLine = "╚" + Line + "╝"

var FinalOutput = TopLine + "\n" + TextLine + "\n" + BottomLine;

editor.replaceSelection(FinalOutput);