SLIdeEditor.sleela
lib/ide-workbench/SLIdeEditor.sleela · 120 line(s) · sleela
<< lib/ide-workbench/SLIdeEditor.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLIdeEditor — a real code-editor buffer for one open
source file. Where lib/ui/SLTextArea is a visibility stub, SLIdeEditor adds
the editor state an IDE needs: a text buffer, a dirty (unsaved) flag, a
caret offset, a selection span, and a revision marker that mirrors the
lib/gui SLGuiDocument revision fingerprint so external changes can be
reconciled. Presentation (actual glyphs, syntax colors) is still owned by
the Java/native host; SLeeLa owns the buffer and the meaning of edits. >>
#sleela 2.5
material;
< Family: ide-workbench. One editor == one open document buffer. >
class SLIdeEditor {
< ---- 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 = 11058;
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-13";
< 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; }
< stable IDE-facing identity (matches SLGuiDocument.id) >
String documentId;
< resolved host path, "" when untitled >
String path;
< "sleela" | "sst" | "c" | "cpp" | "java" >
String language;
< the live buffer contents >
String text;
< on-disk revision last synced ("lastModified:size" | "absent") >
String savedRevision;
< 1 when the buffer differs from the saved revision >
int dirty;
< caret offset into text >
int caret;
< selection start offset (== selEnd when no selection) >
int selStart;
< selection end offset >
int selEnd;
void configure(String docId, String docPath, String lang) {
documentId = docId; path = docPath; language = lang;
text = ""; savedRevision = "absent";
dirty = 0; caret = 0; selStart = 0; selEnd = 0;
}
String getId() { return documentId; }
String getPath() { return path; }
String getLanguage() { return language; }
boolean untitled() { return path == null || path == ""; }
< Replace the buffer (a load or a programmatic set); not itself a user edit. >
void loadText(String value, String revision) {
text = value; savedRevision = revision; dirty = 0;
caret = 0; selStart = 0; selEnd = 0;
}
< A user edit: set the buffer text and mark it dirty. >
void setText(String value) {
if (value != text) { text = value; dirty = 1; }
}
String getText() { return text; }
boolean isDirty() { return dirty == 1; }
< Mark the buffer clean against the revision the host just wrote to disk. >
void markSaved(String revision) { savedRevision = revision; dirty = 0; }
< Caret / selection (offsets are clamped to the buffer by the host). >
void moveCaret(int offset) { caret = offset; selStart = offset; selEnd = offset; }
int getCaret() { return caret; }
void select(int start, int end) {
selStart = start; selEnd = end; caret = end;
}
boolean hasSelection() { return selStart != selEnd; }
< True when an external (on-disk) revision no longer matches what we loaded, >
< i.e. the file changed underneath us (reconcile via the document listener). >
boolean staleAgainst(String diskRevision) {
if (diskRevision == null) { return false; }
return diskRevision != savedRevision;
}
boolean isSst() { return language == "sst"; }
boolean isSleela() { return language == "sleela"; }
}