From 90050fa547360b006cc98b7e343aa6f4c8984d14 Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Wed, 24 May 2023 20:07:15 +0200 Subject: [PATCH] fixing gutters for code, example with syntax highligting --- index.html | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/index.html b/index.html index 23342a6..36674f4 100644 --- a/index.html +++ b/index.html @@ -2209,7 +2209,7 @@ document.body.addEventListener( "highlighterready", (e) => { let pl = src.length/parts for (let n=0; n { el.object3D.children[0].addEventListener("synccomplete", e => { // this can be used for resizing but without add the element @@ -2410,7 +2411,8 @@ function addBackdropToTroikaElement( codeEditor, el ){ }) } -function addGuttersToTroikaElement( codeEditor, el ){ +function addGuttersToTroikaElement( codeEditor ){ + let el = codeEditor.element el.addEventListener("object3dset", e => { el.object3D.children[0].addEventListener("synccomplete", e => { if (codeEditor.element.querySelector(".leftgutter")) return @@ -2420,7 +2422,7 @@ function addGuttersToTroikaElement( codeEditor, el ){ w = b[2]-b[0] h = b[3]-b[1] - gutterWidth = .2 * String(getNumberOfLinesFromCodeEditor()).length + gutterWidth = .2 * String(getNumberOfLinesFromCodeEditor(codeEditor)).length //should adjust width based on number of lines in total first g = new THREE.BoxGeometry( gutterWidth, h, .01 ); m = new THREE.MeshBasicMaterial( {color: 0x333333, opacity: 0.9, transparent: true} ); @@ -2435,7 +2437,7 @@ function addGuttersToTroikaElement( codeEditor, el ){ leftGutter.setAttribute("outline-color", "black" ) let lineNumbers = "\n" for (let i=codeEditor.line+1;i<=codeEditor.line+codeEditor.lengthWindowRange;i++){ - for (let pad=0;pad