SLGuiDocumentListener.sleela
lib/gui/version-mual/SLGuiDocumentListener.sleela · 101 line(s) · sleela
<< lib/gui/version-mual/SLGuiDocumentListener.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLGuiDocumentListener — the SLeeLa GUI document-change
listener option. Mirrors DocumentListener in gui/: watch 1..14 documents
and refresh the running GUI whenever any changes on an OS call. Detection
is OS-driven (WatchService over inotify / ReadDirectoryChangesW /
kqueue/FSEvents), not polling; an OS event that does not move a document's
revision is coalesced away. The 1..14 bound is a hard contract. >>
#sleela 2.5
material;
< SLeeLa gui front-end contract — the OS-backed 1..14 document watch. >
< Family: gui. The watch wakes on an OS call, re-reads each document's >
< revision, and emits only real changes; a host may also force a refresh. >
class SLGuiDocumentListener {
< ---- 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 = 11188;
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; }
< lower bound (inclusive) >
int MIN_DOCUMENTS = 1;
< upper bound (inclusive) >
int MAX_DOCUMENTS = 14;
< how many documents are attached (1..14) >
int watched;
< 1 while the OS watch loop is active >
int running;
< total real changes emitted >
int changes;
< OS wake cadence / coalescing window >
int pollMillis;
void configure(int documentCount) {
watched = documentCount; running = 0; changes = 0; pollMillis = 500;
}
int count() { return watched; }
int minDocuments() { return MIN_DOCUMENTS; }
int maxDocuments() { return MAX_DOCUMENTS; }
< The hard 1..14 contract, enforced at construction and on watch(). >
boolean withinBound() {
return watched >= MIN_DOCUMENTS && watched <= MAX_DOCUMENTS;
}
< Start the OS-backed watch; a no-op unless the bound holds and not running. >
boolean watch() {
if (!withinBound()) { return false; }
if (running == 1) { return true; }
running = 1;
return true;
}
boolean isRunning() { return running == 1; }
< One OS-call wake delivered `realChanges` revision moves (0 is coalesced >
< away and emits nothing). Returns the number emitted this wake. >
int onOsCall(int realChanges) {
if (running == 0 || realChanges <= 0) { return 0; }
changes = changes + realChanges;
return realChanges;
}
< Force an immediate re-evaluation (an explicit OS/lifecycle refresh). >
int refreshNow(int realChanges) { return onOsCall(realChanges); }
int totalChanges() { return changes; }
void setPollMillis(int ms) { if (ms > 0) { pollMillis = ms; } }
int getPollMillis() { return pollMillis; }
< Stop the watch and release the OS watch handle. Idempotent. >
void close() { running = 0; }
}