diff --git a/ivette/src/frama-c/kernel/SourceCode.tsx b/ivette/src/frama-c/kernel/SourceCode.tsx index d219313e4cc1cd5aea8174b1ffcdcc0ac83af2a5..e01349ab1ef2ebe193492a45514b4e98a17513ec 100644 --- a/ivette/src/frama-c/kernel/SourceCode.tsx +++ b/ivette/src/frama-c/kernel/SourceCode.tsx @@ -39,6 +39,7 @@ import { Hfill } from 'dome/layout/boxes'; import * as Path from 'path'; import * as Settings from 'dome/data/settings'; +import CodeMirror from 'codemirror/lib/codemirror'; import 'codemirror/addon/selection/active-line'; import 'codemirror/addon/dialog/dialog.css'; import 'codemirror/addon/search/searchcursor'; @@ -94,8 +95,13 @@ export default function SourceCode() { React.useEffect(() => buffer.setCursorOnTop(line), [buffer, line, result]); const [command] = Settings.useGlobalSettings(Preferences.EditorCommand); - const launchEditor = () => { - const cmd = command.replace('%s', file).replace('%d', line.toString()); + const launchEditor = (_: CodeMirror.Editor, pos?: CodeMirror.Position) => { + const selectedLine = pos ? (pos.line + 1).toString() : '1'; + const selectedChar = pos ? (pos.ch + 1).toString() : '1'; + const cmd = command + .replace('%s', file) + .replace('%n', selectedLine) + .replace('%c', selectedChar); const args = cmd.split(' '); const prog = args.shift(); if (prog) System.spawn(prog, args).catch(/* TODO */); diff --git a/ivette/src/ivette/prefs.tsx b/ivette/src/ivette/prefs.tsx index ab9ece62a458305c6e99bd1c81f5719ad6259ada..645e90c1b2a30eff502430aa4fd9c3f48b4adaa0 100644 --- a/ivette/src/ivette/prefs.tsx +++ b/ivette/src/ivette/prefs.tsx @@ -131,7 +131,7 @@ export function useThemeButtons(props: ThemeProps): ThemeControls { // -------------------------------------------------------------------------- export const EditorCommand = - new Settings.GString('Editor.Command', 'emacs +%d %s'); + new Settings.GString('Editor.Command', 'emacs +%n:%c %s'); export interface EditorCommandProps { command: Settings.GlobalSettings<string>;