Transpiled version (68771L) is out of date.
concept G22Text > ConceptWithChangeListeners { settableWithVar S description; // the script (last "saved" version) settableWithVar S text; // text currently being modified in an editor (or null) // Note that "" doesn't count as null. settableWithVar S editingText; // When imported from another project settableWithVar S importNote; S myType() { ret dropPrefix("G22", shortClassName(this)); } toString { ret colonCombine(myType() + id, description); } void initEditingText { editingText(unnull(or(editingText, text))); } void receiveEditingText(S text) { //printVars_shorten("receiveEditingText", +text); editingText(text); } S stableText() { ret text; } S latestText() { ret or(editingText, text); } void completeEdit aka save() { S t = editingText; //printVars_shorten("completeEdit", +t); if (t != null) { setTextWithHistory(t); //printVars_shorten("completeEdit", +editingText); } } void setTextWithHistory(S text) { if (eq(this.text, text)) ret; text(text); saveTextToHistory(); } void discardEdit { S text = editedText(); if (text == null) ret; saveFieldToHistory("discardingEdit", text); editingText(null); } S textForEditing() { initEditingText(); ret editingText; } File historyFile() { ret fileInConceptsDir("History/" + shortDynName(this) + id + ".history"); } void saveTextToHistory() { saveFieldToHistory(+text); } void saveFieldToHistory(S field, S value) { File historyFile = historyFile(); if (historyFile == null) ret; S contents = value == null ? " empty" : " (" + nLines(value) + ", " + nChars(value) + "):\n" + indentx(value) + "\n" + "\n"; appendToTextFile(historyFile, "\n===\n" + "Concept ID: " + id + "\n" + "Date: " + dateWithMSUTC() + "\n" + firstToUpper(field) + contents + "===" + "\n"); } bool isSaved() { ret text != null; } bool isEditing() { ret editedText() != null; } S editedText() { ret eq(editingText, text) ? null : editingText; } G22Utils g22utils() { ret assertNotNull(g22utils := main g22utils(_concepts())); } Set<S> allTexts() { ret asSet(llNonNulls(text(), editedText()); } }
Began life as a copy of #1034255
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1036607 |
Snippet name: | G22Text (text concept, with editing state) |
Eternal ID of this version: | #1036607/4 |
Text MD5: | 61ff60c4d554f4e674996be06858c9fc |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-07-26 21:46:32 |
Source code size: | 2395 bytes / 93 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 199 / 266 |
Version history: | 3 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |