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