eval line and eval block working

This commit is contained in:
ojack
2022-02-11 16:45:16 +01:00
parent 2c0fbfdc2f
commit d7501bde11
3 changed files with 26 additions and 4 deletions

View File

@@ -26038,6 +26038,7 @@ module.exports = function store (state, emitter) {
}) })
emitter.on('editor:randomize', function(evt) { emitter.on('editor:randomize', function(evt) {
const editor = state.editor.editor const editor = state.editor.editor
if (evt.shiftKey) { if (evt.shiftKey) {
@@ -26066,6 +26067,16 @@ module.exports = function store (state, emitter) {
}) })
}) })
emitter.on('editor:evalLine', (line) => {
console.log('EVALUATING', line)
repl.eval(line)
})
emitter.on('editor:evalBlock', (block) => {
console.log('evaluating block')
repl.eval(block)
})
emitter.on('gallery:shareSketch', function (editor) { emitter.on('gallery:shareSketch', function (editor) {
console.log('waiting to share', state.editor.editor.getValue()) console.log('waiting to share', state.editor.editor.getValue())
}) })
@@ -26109,8 +26120,8 @@ module.exports = class Editor extends Component {
load (element) { load (element) {
this.editor = new HydraEditor(this.textEl) this.editor = new HydraEditor(this.textEl)
this.editor.on("*", (e, t) => { this.editor.on("*", (e, args) => {
this.emit(e) this.emit(e, args)
}) })
// hacky, maybe not necessary // hacky, maybe not necessary
this.innerText = document.getElementsByClassName('CodeMirror')[0] this.innerText = document.getElementsByClassName('CodeMirror')[0]

View File

@@ -14,6 +14,7 @@ module.exports = function store (state, emitter) {
}) })
emitter.on('editor:randomize', function(evt) { emitter.on('editor:randomize', function(evt) {
const editor = state.editor.editor const editor = state.editor.editor
if (evt.shiftKey) { if (evt.shiftKey) {
@@ -42,6 +43,16 @@ module.exports = function store (state, emitter) {
}) })
}) })
emitter.on('editor:evalLine', (line) => {
console.log('EVALUATING', line)
repl.eval(line)
})
emitter.on('editor:evalBlock', (block) => {
console.log('evaluating block')
repl.eval(block)
})
emitter.on('gallery:shareSketch', function (editor) { emitter.on('gallery:shareSketch', function (editor) {
console.log('waiting to share', state.editor.editor.getValue()) console.log('waiting to share', state.editor.editor.getValue())
}) })

View File

@@ -12,8 +12,8 @@ module.exports = class Editor extends Component {
load (element) { load (element) {
this.editor = new HydraEditor(this.textEl) this.editor = new HydraEditor(this.textEl)
this.editor.on("*", (e, t) => { this.editor.on("*", (e, args) => {
this.emit(e) this.emit(e, args)
}) })
// hacky, maybe not necessary // hacky, maybe not necessary
this.innerText = document.getElementsByClassName('CodeMirror')[0] this.innerText = document.getElementsByClassName('CodeMirror')[0]