synax highlight example on split multiple editor

editor-split
Fabien Benetou 2 years ago
parent 5240ab9ff9
commit 2ec6f31ac8
  1. 18
      index.html

@ -2203,6 +2203,15 @@ function highlight(code = `console.log("Here is your code."); var x = 5;`, langu
document.body.addEventListener( "highlighterready", (e) => { document.body.addEventListener( "highlighterready", (e) => {
//fetch("colorme.js").then(r=>r.text()).then( page => { addCodeEditor( page ) }) //fetch("colorme.js").then(r=>r.text()).then( page => { addCodeEditor( page ) })
fetch( 'colorme.js').then(r=>r.text()).then( src => {
let parts = 5 // can't handle odd splits...
let pl = src.length/parts
for (let n=0; n<parts; n++ ){
addCodeEditor( src.slice(n*pl,(n+1)*pl), 'javascript', '-0.22 '+(2-n/10)+' -.4' )
console.log( src.slice(n*pl,(n+1)*pl), 'javascript', '-0.22 '+(2-n/10)+' -.4' )
}
})
}, false); }, false);
function startExperience(){ function startExperience(){
@ -2542,6 +2551,8 @@ function addCodeEditor(page="jxr console.log('hello world')", language="javascri
let line = '' let line = ''
let parts = page.split(' ') let parts = page.split(' ')
let n = 0 let n = 0
/*
while ( pos < page.length ){ while ( pos < page.length ){
while ( line.length < width && parts[n]){ while ( line.length < width && parts[n]){
line += parts[n++] + ' ' line += parts[n++] + ' '
@ -2553,6 +2564,8 @@ function addCodeEditor(page="jxr console.log('hello world')", language="javascri
} }
codeEditor.page = forcedLines codeEditor.page = forcedLines
*/
codeEditor.page = page
codeEditor.line = codeEditor.startWindowRange codeEditor.line = codeEditor.startWindowRange
let numberOfLines = getNumberOfLinesFromCodeEditor(codeEditor, ) let numberOfLines = getNumberOfLinesFromCodeEditor(codeEditor, )
if (numberOfLines<codeEditor.lengthWindowRange) codeEditor.lengthWindowRange = numberOfLines if (numberOfLines<codeEditor.lengthWindowRange) codeEditor.lengthWindowRange = numberOfLines
@ -3045,14 +3058,15 @@ function tiltId(id, value){
// used for testing // used for testing
AFRAME.registerComponent('startfunctions', { AFRAME.registerComponent('startfunctions', {
init: function () { init: function () {
/*
fetch( 'https://webdav.benetou.fr/fot-demo-day/mobydick-extract.txt').then(r=>r.text()).then( src => { fetch( 'https://webdav.benetou.fr/fot-demo-day/mobydick-extract.txt').then(r=>r.text()).then( src => {
let parts = 4 // can't handle odd splits... let parts = 4 // can't handle odd splits...
let pl = src.length/parts let pl = src.length/parts
for (let n=0; n<parts; n++ ){ for (let n=0; n<parts; n++ ){
addCodeEditor( src.slice(n*pl,(n+1)*pl), '', '-0.22 '+(2-n/10)+' -.4' ) addCodeEditor( src.slice(n*pl,(n+1)*pl), 'javascript', '-0.22 '+(2-n/10)+' -.4' )
} }
}) })
*/
// should become a component instead // should become a component instead
//startExperience() //startExperience()
//doublePinchToScale() //doublePinchToScale()

Loading…
Cancel
Save