Skip to content
Snippets Groups Projects
Commit 0d55d220 authored by David Bühler's avatar David Bühler
Browse files

[ivette] Source code: adds a contextual menu to open the file in an editor.

parent 2ade528b
No related branches found
No related tags found
No related merge requests found
...@@ -97,7 +97,7 @@ export default function SourceCode() { ...@@ -97,7 +97,7 @@ export default function SourceCode() {
React.useEffect(() => buffer.setCursorOnTop(line), [buffer, line, result]); React.useEffect(() => buffer.setCursorOnTop(line), [buffer, line, result]);
const [command] = Settings.useGlobalSettings(Preferences.EditorCommand); const [command] = Settings.useGlobalSettings(Preferences.EditorCommand);
const launchEditor = (_: CodeMirror.Editor, pos?: CodeMirror.Position) => { async function launchEditor(_: CodeMirror.Editor, pos?: CodeMirror.Position) {
const selectedLine = pos ? (pos.line + 1).toString() : '1'; const selectedLine = pos ? (pos.line + 1).toString() : '1';
const selectedChar = pos ? (pos.ch + 1).toString() : '1'; const selectedChar = pos ? (pos.ch + 1).toString() : '1';
const cmd = command const cmd = command
...@@ -112,7 +112,21 @@ export default function SourceCode() { ...@@ -112,7 +112,21 @@ export default function SourceCode() {
kind: 'error', kind: 'error',
}); });
}); });
}; }
async function contextMenu(
editor: CodeMirror.Editor,
pos?: CodeMirror.Position,
)
{
const items = [
{
label: 'Open file in an external editor',
onClick: () => launchEditor(editor, pos),
},
];
Dome.popupMenu(items);
}
// Building the React component. // Building the React component.
return ( return (
...@@ -133,7 +147,8 @@ export default function SourceCode() { ...@@ -133,7 +147,8 @@ export default function SourceCode() {
styleActiveLine={!!theFunction} styleActiveLine={!!theFunction}
extraKeys={{ extraKeys={{
'Alt-F': 'findPersistent', 'Alt-F': 'findPersistent',
'Ctrl-LeftClick': launchEditor, 'Ctrl-LeftClick': launchEditor as (_: CodeMirror.Editor) => void,
RightClick: contextMenu as (_: CodeMirror.Editor) => void,
}} }}
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