Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
4c9adb69
Commit
4c9adb69
authored
3 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[ivette] Source code: adds a toolbar button to open the file in an editor.
parent
d4106611
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/frama-c/kernel/SourceCode.tsx
+19
-7
19 additions, 7 deletions
ivette/src/frama-c/kernel/SourceCode.tsx
with
19 additions
and
7 deletions
ivette/src/frama-c/kernel/SourceCode.tsx
+
19
−
7
View file @
4c9adb69
...
...
@@ -36,6 +36,7 @@ import * as Preferences from 'ivette/prefs';
import
{
functions
,
markerInfo
}
from
'
frama-c/api/kernel/ast
'
;
import
{
Code
}
from
'
dome/controls/labels
'
;
import
{
Hfill
}
from
'
dome/layout/boxes
'
;
import
{
IconButton
}
from
'
dome/controls/buttons
'
;
import
*
as
Path
from
'
path
'
;
import
*
as
Settings
from
'
dome/data/settings
'
;
import
*
as
Status
from
'
frama-c/kernel/Status
'
;
...
...
@@ -96,8 +97,12 @@ export default function SourceCode() {
React
.
useEffect
(()
=>
buffer
.
setValue
(
result
),
[
buffer
,
result
]);
React
.
useEffect
(()
=>
buffer
.
setCursorOnTop
(
line
),
[
buffer
,
line
,
result
]);
/* CodeMirror types used to bind callbacks to extraKeys. */
type
position
=
CodeMirror
.
Position
;
type
editor
=
CodeMirror
.
Editor
;
const
[
command
]
=
Settings
.
useGlobalSettings
(
Preferences
.
EditorCommand
);
async
function
launchEditor
(
_
:
CodeMirror
.
E
ditor
,
pos
?:
CodeMirror
.
P
osition
)
{
async
function
launchEditor
(
_
?
:
e
ditor
,
pos
?:
p
osition
)
{
if
(
file
!==
''
)
{
const
selectedLine
=
pos
?
(
pos
.
line
+
1
).
toString
()
:
'
1
'
;
const
selectedChar
=
pos
?
(
pos
.
ch
+
1
).
toString
()
:
'
1
'
;
...
...
@@ -116,11 +121,7 @@ export default function SourceCode() {
}
}
async
function
contextMenu
(
editor
:
CodeMirror
.
Editor
,
pos
?:
CodeMirror
.
Position
,
)
{
async
function
contextMenu
(
editor
?:
editor
,
pos
?:
position
)
{
if
(
file
!==
''
)
{
const
items
=
[
{
...
...
@@ -132,11 +133,22 @@ export default function SourceCode() {
}
}
const
externalEditorTitle
=
'
Open the source file in an external editor.
\n
A Ctrl-click
'
+
'
in the source code opens the editor at the selected location.
'
+
'
\n
The editor used can be configured in Ivette settings.
'
;
// Building the React component.
return
(
<>
<
TitleBar
>
<
Code
title
=
{
file
}
>
{
filename
}
</
Code
>
<
IconButton
icon
=
"DUPLICATE"
visible
=
{
file
!==
''
}
onClick
=
{
launchEditor
}
title
=
{
externalEditorTitle
}
/>
<
Code
title
=
{
file
}
style
=
{
{
padding
:
'
5px
'
}
}
>
{
filename
}
</
Code
>
<
Hfill
/>
{
themeButtons
}
</
TitleBar
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment