SLGuiScriptCommand.sleela
lib/gui/version-gual/SLGuiScriptCommand.sleela · 126 line(s) · sleela
<< lib/gui/version-gual/SLGuiScriptCommand.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLGuiScriptCommand — one instruction of a /lib/gui UI
script. The scripting support is a small, safe, declarative command list
(not an arbitrary interpreter): each command is a verb plus up to four
string operands. The verbs mirror the DOM/event API so a script can build
and drive an interface without native code — create, append, text, attr,
style, show, hide, enable, on (bind a handler), fire (raise an event), and
call (cross the native bridge to a SLeeLa operation). An ordinal verb keeps
dispatch cheap; the operands are interpreted per verb by SLGuiScript.
Family: gui. Scripts describe UI intent; SLeeLa (via SLGuiScript) executes it
against the SLeeLa-owned DOM and event bus. >>
#sleela 2.5
material;
class SLGuiScriptCommand {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 11260;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-16";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
< Verb ordinals. >
< create <tag> <id> [parentId] >
static final int CREATE = 0;
< append <parentId> <childId> >
static final int APPEND = 1;
< text <id> <value> >
static final int TEXT = 2;
< attr <id> <name> <value> >
static final int ATTR = 3;
< style <id> <prop> <value> >
static final int STYLE = 4;
< show <id> >
static final int SHOW = 5;
< hide <id> >
static final int HIDE = 6;
< enable <id> <"1"|"0"> >
static final int ENABLE = 7;
< on <id> <eventName> <operation> >
static final int ON = 8;
< fire <id> <eventName> [value] >
static final int FIRE = 9;
< call <operation> [arguments] >
static final int CALL =10;
< remove <id> >
static final int REMOVE =11;
< no-op / comment >
static final int NOP =12;
int verb;
< operand 1 >
String a;
< operand 2 >
String b;
< operand 3 >
String c;
< operand 4 >
String d;
void configure(int v, String o1, String o2, String o3, String o4) {
verb = v; a = o1; b = o2; c = o3; d = o4;
}
int getVerb() { return verb; }
String op1() { return a; }
String op2() { return b; }
String op3() { return c; }
String op4() { return d; }
< Map a verb keyword to its ordinal (-1 when unknown). >
int verbOf(String word) {
if (word == "create") { return CREATE; }
if (word == "append") { return APPEND; }
if (word == "text") { return TEXT; }
if (word == "attr") { return ATTR; }
if (word == "style") { return STYLE; }
if (word == "show") { return SHOW; }
if (word == "hide") { return HIDE; }
if (word == "enable") { return ENABLE; }
if (word == "on") { return ON; }
if (word == "fire") { return FIRE; }
if (word == "call") { return CALL; }
if (word == "remove") { return REMOVE; }
if (word == "nop") { return NOP; }
return -1;
}
boolean valid() { return verb >= CREATE && verb <= NOP; }
}