Files
2026-05-03 04:14:04 -04:00

89 lines
1.8 KiB
Plaintext

function DrawWindow{
parameter x,y,w,h,title.
DrawBox(x, y, w, h).
PrintCentered(x,y, w, title).
}
function DrawBox{
parameter x,y,w,h.
if h < 0 or y + h >= terminal:height {
set h to max(1,min(terminal:height - 2 - y,h)).
}
DrawHorizontalLineCapped(x, y, w, "━", "┏", "┓").
DrawHorizontalLineCapped(x, y+h, w, "━", "┗", "┛").
set i to 0.
until i > h - 2 {
set i to i + 1.
print "┃" at (x, y + i).
print "┃" at (x + w, y + i).
}
}
function DrawHorizontalLine{
parameter x,y,w,lineChar is "━".
DrawHorizontalLineCapped(x,y,w,lineChar, lineChar, lineChar).
}
function DrawHorizontalLineCapped{
parameter x,y,w,lineChar is "━", capCharLeft is "┣", capCharRight is "┫".
set i to 0.
local line is "".
until i > w - 1 {
set line to line + lineChar.
set i to i + 1.
}
print line at (x, y).
print capCharLeft at (x, y).
print capCharRight at (x + w -1, y).
}
function DrawVerticalLineCapped{
parameter x,y,h,lineChar is "┃", capCharTop is "┳", capCharBottom is "┻".
if h < 0 or y + h >= terminal:height {
set h to max(1,min(terminal:height - 1 - y,h)).
}
set i to 1.
until i > h - 2 {
print lineChar at (x, y+i).
set i to i + 1.
}
print capCharTop at (x, y).
print capCharBottom at (x, y + h - 1).
}
function PrintCentered {
parameter x, y,
w,
text.
set l to text:length.
print text at (x + (w/2) - (l/2), y).
}
function PrintRightAligned {
parameter x, y, w, text.
set l to text:length.
print text at (x + w - l, y).
}
function ClearArea{
parameter x, y, w, h, clearChar is " ".
set j to 0.
local line is "".
until j > w - 1 {
set line to line + clearChar.
set j to j + 1.
}
set i to 0.
until i > h - 1 {
print line at (x,y + i).
set i to i + 1.
}
}