Action Directory / EnBox Single

Install

Add a box around selected text using box drawing characters

Shared by

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);