master
Michael Murtaugh 4 years ago
parent e57793cd6b
commit c5ef9b9eee

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

1199
dist/ticeditor.js vendored

File diff suppressed because one or more lines are too long

@ -6,7 +6,7 @@
<!-- <link rel="stylesheet" href="build/codemirror.css"> --> <!-- <link rel="stylesheet" href="build/codemirror.css"> -->
<!-- <link rel="stylesheet" href="node_modules/codemirror/theme/base16-dark.css"> --> <!-- <link rel="stylesheet" href="node_modules/codemirror/theme/base16-dark.css"> -->
<!-- <link rel="stylesheet" href="node_modules/codemirror/theme/monokai.css"> --> <!-- <link rel="stylesheet" href="node_modules/codemirror/theme/monokai.css"> -->
<link rel="stylesheet" href="node_modules/codemirror/lib/codemirror.css"> <link rel="stylesheet" href="dist/codemirror.css">
<style> <style>
#dialog { #dialog {
@ -48,6 +48,6 @@
</p> </p>
</div> </div>
</div> </div>
<script src="build/ticeditor.js"></script> <script src="dist/ticeditor.js"></script>
</body> </body>
</html> </html>

@ -90,7 +90,7 @@ function main () {
// current_cart.code.text = codesrc; // code.getValue(); // current_cart.code.text = codesrc; // code.getValue();
if (window._tic.filename && window._tic.cart) { if (window._tic.filename && window._tic.cart) {
let cart = window._tic.cart; let cart = window._tic.cart;
cart.code.text = window.code.getValue(); cart.code.text = editor.getValue();
// console.log("saving code", cart.code.text); // console.log("saving code", cart.code.text);
await ticdb.save_cart(window._tic.filename, cart, window._tic.item.mode); await ticdb.save_cart(window._tic.filename, cart, window._tic.item.mode);
listing.sync(); listing.sync();
@ -109,7 +109,7 @@ function main () {
if (!filename) { return; } if (!filename) { return; }
window._tic.filename = filename; window._tic.filename = filename;
let cart = window._tic.cart; let cart = window._tic.cart;
cart.code.text = window.code.getValue(); cart.code.text = editor.getValue();
// console.log("saving code", cart.code.text); // console.log("saving code", cart.code.text);
await ticdb.save_cart(filename, cart, window._tic.item.mode); await ticdb.save_cart(filename, cart, window._tic.item.mode);
listing.sync(); listing.sync();
@ -153,7 +153,9 @@ function main () {
}); });
let listing = new ListingWidget('Listing'); let listing = new ListingWidget('Listing');
window._tic.listing = listing;
let editor = new EditorWidget('Editor'); let editor = new EditorWidget('Editor');
window._tic.editor = editor;
let dock = new DockPanel(); let dock = new DockPanel();
dock.addWidget(listing); dock.addWidget(listing);

@ -37,7 +37,7 @@ export class EditorWidget extends Widget {
super({ node: EditorWidget.createNode() }); super({ node: EditorWidget.createNode() });
// let editor_div = this.node.getElementsByTagName('div')[0]; // let editor_div = this.node.getElementsByTagName('div')[0];
this.cm = CodeMirror(this.editorDiv, CM_OPTS); this.cm = CodeMirror(this.editorDiv, CM_OPTS);
window.code = this.cm; // window.code = this.cm;
this.setFlag(Widget.Flag.DisallowLayout); this.setFlag(Widget.Flag.DisallowLayout);
this.addClass('content'); this.addClass('content');
this.addClass(name.toLowerCase()); this.addClass(name.toLowerCase());
@ -53,8 +53,19 @@ export class EditorWidget extends Widget {
get inputNode() { get inputNode() {
return this.node.getElementsByTagName('input')[0]; return this.node.getElementsByTagName('input')[0];
} }
setValue (text) {
this.cm.setValue(text);
// this.cm.update();
}
getValue () {
return this.cm.getValue();
}
// onUpdateRequest (Message) {
// }
onAfterShow () {
//console.log("editor.onAfterShow");
this.cm.refresh();
}
onActivateRequest(Message) { onActivateRequest(Message) {
// if (this.isAttached) { // if (this.isAttached) {
// this.inputNode.focus(); // this.inputNode.focus();

@ -91,7 +91,7 @@ export class ListingWidget extends Widget {
// console.log("loaded item", window._tic.item); // console.log("loaded item", window._tic.item);
window._tic.cart = tic.parsetic(window._tic.item.contents.buffer); window._tic.cart = tic.parsetic(window._tic.item.contents.buffer);
// console.log("current_cart", current_cart); // console.log("current_cart", current_cart);
window.code.setValue(window._tic.cart.code.text); window._tic.editor.setValue(window._tic.cart.code.text);
} }
}); });
tr.append("td").attr("class", "size"); tr.append("td").attr("class", "size");

Loading…
Cancel
Save