mirror of
https://github.com/hydra-synth/hydra.git
synced 2025-12-06 06:50:02 +01:00
editor in class
This commit is contained in:
@@ -76,13 +76,13 @@ function init () {
|
|||||||
})
|
})
|
||||||
menu.sketches = sketches
|
menu.sketches = sketches
|
||||||
|
|
||||||
keymaps.init ({
|
// keymaps.init ({
|
||||||
editor: editor,
|
// editor: editor,
|
||||||
gallery: sketches,
|
// gallery: sketches,
|
||||||
menu: menu,
|
// menu: menu,
|
||||||
repl: repl,
|
// repl: repl,
|
||||||
log: log
|
// log: log
|
||||||
})
|
// })
|
||||||
|
|
||||||
// define extra functions (eventually should be added to hydra-synth?)
|
// define extra functions (eventually should be added to hydra-synth?)
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -6,12 +6,15 @@ require('codemirror-minified/addon/hint/show-hint')
|
|||||||
require('codemirror-minified/addon/selection/mark-selection')
|
require('codemirror-minified/addon/selection/mark-selection')
|
||||||
require('codemirror-minified/addon/comment/comment')
|
require('codemirror-minified/addon/comment/comment')
|
||||||
|
|
||||||
|
const EventEmitter = require('events')
|
||||||
|
|
||||||
var Mutator = require('../randomizer/Mutator.js');
|
var Mutator = require('../randomizer/Mutator.js');
|
||||||
|
|
||||||
|
|
||||||
var isShowing = true
|
var isShowing = true
|
||||||
|
|
||||||
var EditorClass = function () {
|
module.exports = class Editor {
|
||||||
|
constructor() {
|
||||||
console.log("*** Editor class created");
|
console.log("*** Editor class created");
|
||||||
var self = this
|
var self = this
|
||||||
|
|
||||||
@@ -29,40 +32,38 @@ var EditorClass = function () {
|
|||||||
lineWrapping: true,
|
lineWrapping: true,
|
||||||
styleSelectedText: true
|
styleSelectedText: true
|
||||||
})
|
})
|
||||||
|
|
||||||
// console.log('code mirror', this.cm)
|
// console.log('code mirror', this.cm)
|
||||||
//this.cm.removeKeyMap()
|
//this.cm.removeKeyMap()
|
||||||
|
|
||||||
this.cm.refresh()
|
this.cm.refresh()
|
||||||
|
|
||||||
this.show()
|
this.show()
|
||||||
// TO DO: add show code param
|
// // TO DO: add show code param
|
||||||
let searchParams = new URLSearchParams(window.location.search)
|
let searchParams = new URLSearchParams(window.location.search)
|
||||||
let showCode = searchParams.get('show-code')
|
let showCode = searchParams.get('show-code')
|
||||||
|
|
||||||
if(showCode == "false") {
|
if (showCode === "false") {
|
||||||
// console.log("not showing code")
|
// console.log("not showing code")
|
||||||
var l = document.getElementsByClassName('CodeMirror-scroll')[0]
|
var l = document.getElementsByClassName('CodeMirror-scroll')[0]
|
||||||
l.style.display = 'none'
|
l.style.display = 'none'
|
||||||
// self.logElement.style.display = 'none'
|
// self.logElement.style.display = 'none'
|
||||||
isShowing = false
|
isShowing = false
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorClass.prototype.clear = function () {
|
clear() {
|
||||||
this.cm.setValue('\n \n // Type some code on a new line (such as "osc().out()"), and press CTRL+shift+enter')
|
this.cm.setValue('\n \n // Type some code on a new line (such as "osc().out()"), and press CTRL+shift+enter')
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorClass.prototype.setValue = function (val) {
|
setValue(val) {
|
||||||
this.cm.setValue(val)
|
this.cm.setValue(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorClass.prototype.getValue = function () {
|
getValue() {
|
||||||
return this.cm.getValue()
|
return this.cm.getValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorClass.prototype.hide = function () {
|
hide() {
|
||||||
var l = document.getElementsByClassName('CodeMirror-scroll')[0]
|
var l = document.getElementsByClassName('CodeMirror-scroll')[0]
|
||||||
var m = document.getElementById('modal-header')
|
var m = document.getElementById('modal-header')
|
||||||
// l.style.opacity = 0
|
// l.style.opacity = 0
|
||||||
@@ -73,7 +74,7 @@ m.style.display = 'none'
|
|||||||
this.isShowing = false
|
this.isShowing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorClass.prototype.show = function () {
|
show() {
|
||||||
var l = document.getElementsByClassName('CodeMirror-scroll')[0]
|
var l = document.getElementsByClassName('CodeMirror-scroll')[0]
|
||||||
var m = document.getElementById('modal-header')
|
var m = document.getElementById('modal-header')
|
||||||
// l.style.opacity= 1
|
// l.style.opacity= 1
|
||||||
@@ -84,7 +85,7 @@ EditorClass.prototype.show = function () {
|
|||||||
this.isShowing = true
|
this.isShowing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorClass.prototype.toggle = function () {
|
toggle() {
|
||||||
if (this.isShowing) {
|
if (this.isShowing) {
|
||||||
this.hide()
|
this.hide()
|
||||||
} else {
|
} else {
|
||||||
@@ -92,7 +93,7 @@ EditorClass.prototype.toggle = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorClass.prototype.getLine = function () {
|
getLine() {
|
||||||
var c = this.cm.getCursor()
|
var c = this.cm.getCursor()
|
||||||
var s = this.cm.getLine(c.line)
|
var s = this.cm.getLine(c.line)
|
||||||
// this.cm.markText({line: c.line, ch:0}, {line: c.line+1, ch:0}, {className: 'styled-background'})
|
// this.cm.markText({line: c.line, ch:0}, {line: c.line+1, ch:0}, {className: 'styled-background'})
|
||||||
@@ -100,7 +101,7 @@ EditorClass.prototype.getLine = function () {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorClass.prototype.flashCode = function (start, end) {
|
flashCode(start, end) {
|
||||||
if (!start) start = { line: this.cm.firstLine(), ch: 0 }
|
if (!start) start = { line: this.cm.firstLine(), ch: 0 }
|
||||||
if (!end) end = { line: this.cm.lastLine() + 1, ch: 0 }
|
if (!end) end = { line: this.cm.lastLine() + 1, ch: 0 }
|
||||||
var marker = this.cm.markText(start, end, { className: 'styled-background' })
|
var marker = this.cm.markText(start, end, { className: 'styled-background' })
|
||||||
@@ -108,7 +109,7 @@ EditorClass.prototype.flashCode = function (start, end) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EditorClass.prototype.getCurrentBlock = function () { // thanks to graham wakefield + gibber
|
getCurrentBlock() { // thanks to graham wakefield + gibber
|
||||||
var editor = this.cm
|
var editor = this.cm
|
||||||
var pos = editor.getCursor()
|
var pos = editor.getCursor()
|
||||||
var startline = pos.line
|
var startline = pos.line
|
||||||
@@ -138,6 +139,5 @@ EditorClass.prototype.getCurrentBlock = function () { // thanks to graham wakefi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = EditorClass
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const log = require('./log.js').log
|
const log = require('./editor/log.js').log
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
eval: (arg, callback) => {
|
eval: (arg, callback) => {
|
||||||
|
|||||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -43,6 +43,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/dct/-/dct-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/dct/-/dct-0.1.0.tgz",
|
||||||
"integrity": "sha512-/uUtEniuMq1aUxvLAoDtAduyl12oM1zhA/le2f83UFN/9+4KDHXFB6znEfoj5SDDLiTpUTr26NpxC7t8IFOYhQ=="
|
"integrity": "sha512-/uUtEniuMq1aUxvLAoDtAduyl12oM1zhA/le2f83UFN/9+4KDHXFB6znEfoj5SDDLiTpUTr26NpxC7t8IFOYhQ=="
|
||||||
},
|
},
|
||||||
|
"events": {
|
||||||
|
"version": "3.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
|
||||||
|
"integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q=="
|
||||||
|
},
|
||||||
"fftjs": {
|
"fftjs": {
|
||||||
"version": "0.0.4",
|
"version": "0.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/fftjs/-/fftjs-0.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/fftjs/-/fftjs-0.0.4.tgz",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"events": "^3.3.0",
|
||||||
"hydra-synth": "^1.3.11"
|
"hydra-synth": "^1.3.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
|
|||||||
@@ -1128,7 +1128,7 @@ events@^1.0.2:
|
|||||||
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
|
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
|
||||||
integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=
|
integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=
|
||||||
|
|
||||||
events@^3.0.0:
|
events@^3.0.0, events@^3.3.0:
|
||||||
version "3.3.0"
|
version "3.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400"
|
resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400"
|
||||||
integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==
|
integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==
|
||||||
|
|||||||
Reference in New Issue
Block a user