Skip to content
Snippets Groups Projects
Commit 36ebd0a2 authored by David Bühler's avatar David Bühler Committed by Michele Alberti
Browse files

[ivette] ASTview: new contextual menu to go to a function definition.

Uses a synchronized array to get the kind of each marker. Only creates the menu
on function varinfos.
parent d446b232
No related branches found
No related tags found
No related merge requests found
...@@ -89,6 +89,7 @@ const ASTview = () => { ...@@ -89,6 +89,7 @@ const ASTview = () => {
const [theme, setTheme] = Dome.useGlobalSetting('ASTview.theme', 'default'); const [theme, setTheme] = Dome.useGlobalSetting('ASTview.theme', 'default');
const [fontSize, setFontSize] = Dome.useGlobalSetting('ASTview.fontSize', 12); const [fontSize, setFontSize] = Dome.useGlobalSetting('ASTview.fontSize', 12);
const [wrapText, setWrapText] = Dome.useSwitch('ASTview.wrapText', false); const [wrapText, setWrapText] = Dome.useSwitch('ASTview.wrapText', false);
const markers = States.useSyncArray('kernel.ast.markerKind');
const theFunction = select && select.function; const theFunction = select && select.function;
const theMarker = select && select.marker; const theMarker = select && select.marker;
...@@ -111,6 +112,17 @@ const ASTview = () => { ...@@ -111,6 +112,17 @@ const ASTview = () => {
const zoomOut = () => fontSize > 4 && setFontSize(fontSize - 2); const zoomOut = () => fontSize > 4 && setFontSize(fontSize - 2);
const onSelection = (marker: any) => setSelect({ marker }); const onSelection = (marker: any) => setSelect({ marker });
function contextMenu(id: string) {
const marker = markers[id];
if (marker && marker.kind === 'function') {
const item1 = {
label: `Go to definition of ${marker.name}`,
onClick: () => setSelect({ function: marker.name }),
};
Dome.popupMenu([item1]);
}
}
// Theme Popup // Theme Popup
const selectTheme = (id?: string) => id && setTheme(id); const selectTheme = (id?: string) => id && setTheme(id);
...@@ -155,6 +167,7 @@ const ASTview = () => { ...@@ -155,6 +167,7 @@ const ASTview = () => {
lineWrapping={wrapText} lineWrapping={wrapText}
selection={theMarker} selection={theMarker}
onSelection={onSelection} onSelection={onSelection}
onContextMenu={contextMenu}
readOnly readOnly
/> />
</> </>
......
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