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
8a09ece8
Commit
8a09ece8
authored
1 year ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[ivette/source] fixed global selection
Need to click in source code to select
parent
c4926cc3
No related branches found
No related tags found
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
+11
-11
11 additions, 11 deletions
ivette/src/frama-c/kernel/SourceCode.tsx
with
11 additions
and
11 deletions
ivette/src/frama-c/kernel/SourceCode.tsx
+
11
−
11
View file @
8a09ece8
...
@@ -106,7 +106,7 @@ type SourceCursor = { file: string, line: number, column: number };
...
@@ -106,7 +106,7 @@ type SourceCursor = { file: string, line: number, column: number };
type
SourceCallback
=
((
pos
:
Position
)
=>
void
)
|
null
;
type
SourceCallback
=
((
pos
:
Position
)
=>
void
)
|
null
;
const
noCursor
:
SourceCursor
=
{
file
:
''
,
line
:
0
,
column
:
0
};
const
noCursor
:
SourceCursor
=
{
file
:
''
,
line
:
0
,
column
:
0
};
const
On
Selection
=
Editor
.
OnSelection
;
const
On
Click
=
Editor
.
createField
<
SourceCallback
>
(
null
)
;
const
OnControlClick
=
Editor
.
createField
<
SourceCallback
>
(
null
);
const
OnControlClick
=
Editor
.
createField
<
SourceCallback
>
(
null
);
const
OnContextMenu
=
Editor
.
createField
<
SourceCallback
>
(
null
);
const
OnContextMenu
=
Editor
.
createField
<
SourceCallback
>
(
null
);
...
@@ -114,14 +114,16 @@ const OnContextMenu = Editor.createField<SourceCallback>(null);
...
@@ -114,14 +114,16 @@ const OnContextMenu = Editor.createField<SourceCallback>(null);
const
EventHandlers
=
createEventHandlers
();
const
EventHandlers
=
createEventHandlers
();
function
createEventHandlers
():
Editor
.
Extension
{
function
createEventHandlers
():
Editor
.
Extension
{
const
deps
=
{
const
deps
=
{
onClick
:
OnClick
,
onControlClick
:
OnControlClick
,
onControlClick
:
OnControlClick
,
onContextMenu
:
OnContextMenu
onContextMenu
:
OnContextMenu
};
};
return
Editor
.
createEventHandler
(
deps
,
{
return
Editor
.
createEventHandler
(
deps
,
{
// Control Click
// Control Click
mouseup
:
({
onControlClick
},
view
,
event
)
=>
{
mouseup
:
({
onClick
,
onControlClick
},
view
,
event
)
=>
{
const
pos
=
getCursorPosition
(
view
);
if
(
onClick
!==
null
)
onClick
(
pos
);
if
(
event
.
ctrlKey
&&
onControlClick
!==
null
)
{
if
(
event
.
ctrlKey
&&
onControlClick
!==
null
)
{
const
pos
=
getCursorPosition
(
view
);
onControlClick
(
pos
);
onControlClick
(
pos
);
}
}
},
},
...
@@ -164,7 +166,7 @@ const extensions: Editor.Extension[] = [
...
@@ -164,7 +166,7 @@ const extensions: Editor.Extension[] = [
Editor
.
LineNumbers
,
Editor
.
LineNumbers
,
Editor
.
LanguageHighlighter
,
Editor
.
LanguageHighlighter
,
Editor
.
HighlightActiveLine
,
Editor
.
HighlightActiveLine
,
On
Selection
,
On
Click
,
OnContextMenu
,
OnContextMenu
,
OnControlClick
,
OnControlClick
,
EventHandlers
,
EventHandlers
,
...
@@ -205,17 +207,15 @@ export default function SourceCode(): JSX.Element {
...
@@ -205,17 +207,15 @@ export default function SourceCode(): JSX.Element {
}]);
}]);
},
[
file
,
command
,
editFile
]
);
},
[
file
,
command
,
editFile
]
);
const
onSelect
=
React
.
useCallback
((
offset
,
endOffset
)
=>
{
const
onClick
=
React
.
useCallback
((
pos
:
Position
)
=>
{
if
(
!
view
||
!
file
||
endOffset
!==
offset
)
return
;
if
(
!
file
)
return
;
const
theLine
=
view
.
state
.
doc
.
lineAt
(
offset
);
const
{
line
,
column
}
=
pos
;
const
line
=
theLine
.
number
;
const
column
=
offset
-
theLine
.
from
;
setCursor
({
file
,
line
,
column
});
setCursor
({
file
,
line
,
column
});
},
[
view
,
file
]);
},
[
file
]);
React
.
useEffect
(()
=>
{
if
(
!
file
)
setCursor
(
noCursor
);
},
[
file
]);
React
.
useEffect
(()
=>
{
if
(
!
file
)
setCursor
(
noCursor
);
},
[
file
]);
React
.
useEffect
(()
=>
Source
.
set
(
view
,
source
),
[
view
,
source
]);
React
.
useEffect
(()
=>
Source
.
set
(
view
,
source
),
[
view
,
source
]);
React
.
useEffect
(()
=>
On
Selection
.
set
(
view
,
on
Select
),
[
view
,
on
Select
]);
React
.
useEffect
(()
=>
On
Click
.
set
(
view
,
on
Click
),
[
view
,
on
Click
]);
React
.
useEffect
(()
=>
OnContextMenu
.
set
(
view
,
menuPopup
),
[
view
,
menuPopup
]);
React
.
useEffect
(()
=>
OnContextMenu
.
set
(
view
,
menuPopup
),
[
view
,
menuPopup
]);
React
.
useEffect
(()
=>
OnControlClick
.
set
(
view
,
editFile
),
[
view
,
editFile
]);
React
.
useEffect
(()
=>
OnControlClick
.
set
(
view
,
editFile
),
[
view
,
editFile
]);
...
...
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