Skip to content
Snippets Groups Projects
Commit 0c9de4f1 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette] ast scrolling to current marker

parent dbf3613f
No related branches found
No related tags found
No related merge requests found
...@@ -20,13 +20,12 @@ import 'codemirror/theme/ambiance.css' ; ...@@ -20,13 +20,12 @@ import 'codemirror/theme/ambiance.css' ;
// --- Rich Text Printer // --- Rich Text Printer
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
const print = async (buffer, text) => { const print = (buffer, text) => {
if (Array.isArray(text)) { if (Array.isArray(text)) {
const tag = text.shift(); const tag = text.shift();
if (tag !== '') if (tag !== '')
buffer.openTextMarker( { id:tag } ); buffer.openTextMarker( { id:tag } );
for (const k in text) text.forEach(txt => print(buffer, txt));
await print(buffer, text[k]);
if (tag !== '') if (tag !== '')
buffer.closeTextMarker(); buffer.closeTextMarker();
} else if (typeof(text)==='string') } else if (typeof(text)==='string')
...@@ -51,16 +50,22 @@ const ASTview = () => { ...@@ -51,16 +50,22 @@ const ASTview = () => {
if (theFunction) { if (theFunction) {
buffer.log('// Loading',theFunction,''); buffer.log('// Loading',theFunction,'');
Server Server
.sendGET("kernel.ast.printFunction", theFunction) .sendGET("kernel.ast.printFunction", theFunction)
.then(data => { .then(data => {
buffer.clear(); buffer.clear();
if (!data) if (!data)
buffer.log('// No code for function ', theFunction); buffer.log('// No code for function ', theFunction);
return print(buffer,data); print(buffer,data);
if (theMarker) buffer.scroll( theMarker );
}); });
} }
}, [ theFunction ] ); }, [ theFunction ] );
// Hook: scrolling
React.useEffect( () => {
if (theMarker) buffer.scroll( theMarker );
}, [ theMarker ] );
// Callbacks // Callbacks
const onSelection = marker => setSelect({ marker }); const onSelection = marker => setSelect({ marker });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment