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
2b7252e4
Commit
2b7252e4
authored
3 years ago
by
Loïc Correnson
Committed by
David Bühler
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[ivette] hooks on hovered selection
parent
5420e310
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ivette/src/dome/renderer/text/editors.tsx
+5
-0
5 additions, 0 deletions
ivette/src/dome/renderer/text/editors.tsx
ivette/src/frama-c/kernel/ASTview.tsx
+14
-1
14 additions, 1 deletion
ivette/src/frama-c/kernel/ASTview.tsx
ivette/src/frama-c/states.ts
+8
-1
8 additions, 1 deletion
ivette/src/frama-c/states.ts
with
27 additions
and
2 deletions
ivette/src/dome/renderer/text/editors.tsx
+
5
−
0
View file @
2b7252e4
...
...
@@ -72,6 +72,9 @@ export interface TextProps extends CodeMirror.EditorConfiguration {
/** The currently selected marker identifier. */
selection
?:
string
;
/** Callback on hovered marker, if some. */
onHover
?:
(
id
?:
string
)
=>
void
;
/** Callback on identified marker selection. */
onSelection
?:
MarkerCallback
;
...
...
@@ -311,6 +314,8 @@ class CodeMirrorWrapper extends React.Component<TextProps> {
if
(
newMarker
&&
newMarker
.
hover
)
this
.
_markElementsWith
(
newMarker
.
classNameId
,
CSS_HOVERED
);
this
.
marker
=
newMarker
;
const
callback
=
this
.
props
.
onHover
;
if
(
callback
)
callback
(
newMarker
?.
id
);
}
}
...
...
This diff is collapsed.
Click to expand it.
ivette/src/frama-c/kernel/ASTview.tsx
+
14
−
1
View file @
2b7252e4
...
...
@@ -161,9 +161,12 @@ export default function ASTview() {
const
buffer
=
React
.
useMemo
(()
=>
new
RichTextBuffer
(),
[]);
const
printed
=
React
.
useRef
<
string
|
undefined
>
();
const
[
selection
,
updateSelection
]
=
States
.
useSelection
();
const
[
hoveredLoc
]
=
States
.
useHovered
();
const
selfhover
=
React
.
useRef
(
false
);
const
multipleSelections
=
selection
?.
multiple
.
allSelections
;
const
theFunction
=
selection
?.
current
?.
fct
;
const
theMarker
=
selection
?.
current
?.
marker
;
const
hovered
=
hoveredLoc
?.
marker
;
const
[
fontSize
]
=
Settings
.
useGlobalSettings
(
Preferences
.
EditorFontSize
);
const
markersInfo
=
States
.
useSyncArray
(
Ast
.
markerInfo
);
...
...
@@ -220,16 +223,25 @@ export default function ASTview() {
return
'
dead-code
'
;
if
(
deadCode
?.
nonTerminating
?.
some
((
m
)
=>
m
===
marker
))
return
'
non-terminating
'
;
if
(
!
selfhover
.
current
&&
marker
===
hovered
)
return
'
hovered-marker
'
;
return
undefined
;
};
buffer
.
setDecorator
(
decorator
);
},
[
buffer
,
multipleSelections
,
deadCode
]);
},
[
buffer
,
multipleSelections
,
selfhover
,
hovered
,
deadCode
]);
// Hook: marker scrolling
React
.
useEffect
(()
=>
{
if
(
theMarker
)
buffer
.
scroll
(
theMarker
);
},
[
buffer
,
theMarker
]);
function
onHover
(
markerId
?:
string
)
{
const
marker
=
Ast
.
jMarker
(
markerId
);
const
fct
=
selection
?.
current
?.
fct
;
selfhover
.
current
=
(
marker
!==
undefined
);
States
.
setHovered
(
marker
?
{
fct
,
marker
}
:
undefined
);
}
function
onSelection
(
markerId
:
string
,
meta
=
false
)
{
const
fct
=
selection
?.
current
?.
fct
;
const
location
=
{
fct
,
marker
:
Ast
.
jMarker
(
markerId
)
};
...
...
@@ -303,6 +315,7 @@ export default function ASTview() {
mode
=
"text/x-csrc"
fontSize
=
{
fontSize
}
selection
=
{
theMarker
}
onHover
=
{
onHover
}
onSelection
=
{
onSelection
}
onContextMenu
=
{
onContextMenu
}
gutters
=
{
[
'
bullet
'
]
}
...
...
This diff is collapsed.
Click to expand it.
ivette/src/frama-c/states.ts
+
8
−
1
View file @
2b7252e4
...
...
@@ -188,7 +188,7 @@ export function useRequest<In, Out>(
}
});
const
signals
=
options
.
onSignals
??
rq
.
signals
;
const
signals
=
rq
.
signals
.
concat
(
options
.
onSignals
??
[])
;
React
.
useEffect
(()
=>
{
signals
.
forEach
((
s
)
=>
Server
.
onSignal
(
s
,
trigger
));
return
()
=>
{
...
...
@@ -767,11 +767,18 @@ const emptySelection = {
},
};
export
type
Hovered
=
Location
|
undefined
;
export
const
MetaSelection
=
new
Dome
.
Event
<
Location
>
(
'
frama-c-meta-selection
'
);
export
const
GlobalHovered
=
new
GlobalState
<
Hovered
>
(
undefined
);
export
const
GlobalSelection
=
new
GlobalState
<
Selection
>
(
emptySelection
);
Server
.
onShutdown
(()
=>
GlobalSelection
.
setValue
(
emptySelection
));
export
function
setHovered
(
h
:
Hovered
)
{
GlobalHovered
.
setValue
(
h
);
}
export
function
useHovered
():
[
Hovered
,
(
h
:
Hovered
)
=>
void
]
{
return
useGlobalState
(
GlobalHovered
);
}
export
function
setSelection
(
location
:
Location
,
meta
=
false
)
{
const
s
=
GlobalSelection
.
getValue
();
GlobalSelection
.
setValue
(
reducer
(
s
,
{
location
}));
...
...
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