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

[ivette] AST selection

parent 4d10441a
No related branches found
No related tags found
No related merge requests found
......@@ -434,7 +434,7 @@ const SELECTION = 'kernel.selection' ;
setStateDefault( SELECTION , {} );
/**
@sumamry Current selection state.
@summary Current selection state.
@return {array} `[selection,update]` for the current selection
@description
The selection is an object with many independant fields.
......
......@@ -43,26 +43,35 @@ const ASTview = () => {
const buffer = React.useMemo( () => new Buffer(), []);
const [ select, setSelect ] = States.useSelection();
const theFunction = select && select.function ;
const theMarker = select && select.marker ;
// Hook: async loading
React.useEffect( () => {
buffer.clear();
if (theFunction) {
buffer.log('Loading',theFunction,'');
buffer.log('// Loading',theFunction,'');
Server
.sendGET("kernel.ast.printFunction", theFunction)
.then(data => {
buffer.clear();
if (!data)
buffer.log('// No code for function ', theFunction);
return print(buffer,data);
});
}
}, [ theFunction ] );
// Callbacks
const onSelection = marker => setSelect({ marker });
// Component
return (
<Vfill>
<div>Function: {select && select.function}</div>
<div>Marker: {select && select.marker}</div>
<Text buffer={buffer}
mode='text/x-csrc'
theme='ambiance'
selection={theMarker}
onSelection={onSelection}
readOnly />
</Vfill>
);
......
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