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
4b6da262
Commit
4b6da262
authored
4 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome] update codemirror wrt fontSize
parent
4ae390bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ivette/src/dome/src/renderer/text/editors.js
+31
-18
31 additions, 18 deletions
ivette/src/dome/src/renderer/text/editors.js
ivette/src/renderer/ASTview.tsx
+2
-2
2 additions, 2 deletions
ivette/src/renderer/ASTview.tsx
with
33 additions
and
20 deletions
ivette/src/dome/src/renderer/text/editors.js
+
31
−
18
View file @
4b6da262
...
@@ -19,6 +19,15 @@ import 'codemirror/lib/codemirror.css' ;
...
@@ -19,6 +19,15 @@ import 'codemirror/lib/codemirror.css' ;
const
CSS_HOVERED
=
'
dome-xText-hover
'
;
const
CSS_HOVERED
=
'
dome-xText-hover
'
;
const
CSS_SELECTED
=
'
dome-xText-select
'
;
const
CSS_SELECTED
=
'
dome-xText-select
'
;
const
getConfig
=
({
buffer
,
selection
,
onSelection
,
onContextMenu
,
fontSize
,
...
config
})
=>
config
;
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- Code Mirror Instance Wrapper
// --- Code Mirror Instance Wrapper
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
@@ -53,15 +62,9 @@ class CodeMirrorWrapper extends React.Component {
...
@@ -53,15 +62,9 @@ class CodeMirrorWrapper extends React.Component {
this
.
rootElement
=
elt
;
this
.
rootElement
=
elt
;
if
(
elt
)
{
if
(
elt
)
{
// Mounting...
// Mounting...
const
{
buffer
,
const
{
buffer
}
=
this
.
props
;
selection
,
/* ignored */
const
config
=
getConfig
(
this
.
props
);
onSelection
,
/* ignored */
const
cm
=
this
.
codeMirror
=
new
CodeMirror
(
elt
,
{
value
:
''
});
onContextMenu
,
/* ignored */
fontSize
,
/* ignored */
className
,
/* ignored */
style
,
/* ignored */
...
config
}
=
this
.
props
;
const
cm
=
this
.
codeMirror
=
new
CodeMirror
(
elt
,
{
value
:
""
});
if
(
buffer
)
buffer
.
link
(
cm
);
if
(
buffer
)
buffer
.
link
(
cm
);
// Passing all options to constructor does not work (Cf. CodeMirror's BTS)
// Passing all options to constructor does not work (Cf. CodeMirror's BTS)
for
(
var
opt
in
config
)
cm
.
setOption
(
opt
,
config
[
opt
]
);
for
(
var
opt
in
config
)
cm
.
setOption
(
opt
,
config
[
opt
]
);
...
@@ -285,17 +288,23 @@ class CodeMirrorWrapper extends React.Component {
...
@@ -285,17 +288,23 @@ class CodeMirrorWrapper extends React.Component {
const
cm
=
this
.
codeMirror
;
const
cm
=
this
.
codeMirror
;
if
(
cm
)
{
if
(
cm
)
{
// Swap documents if necessary
// Swap documents if necessary
const
{
buffer
:
oldBuffer
,
const
{
selection
:
oldSelect
,
buffer
:
oldBuffer
,
...
oldConfig
}
=
this
.
props
;
selection
:
oldSelect
,
const
{
buffer
:
newBuffer
,
fontSize
:
oldFont
selection
:
newSelect
,
}
=
this
.
props
;
...
newConfig
}
=
newProps
;
const
{
buffer
:
newBuffer
,
selection
:
newSelect
,
fontSize
:
newFont
}
=
newProps
;
if
(
oldBuffer
!==
newBuffer
)
{
if
(
oldBuffer
!==
newBuffer
)
{
if
(
oldBuffer
)
oldBuffer
.
unlink
(
cm
);
if
(
oldBuffer
)
oldBuffer
.
unlink
(
cm
);
if
(
newBuffer
)
newBuffer
.
link
(
cm
);
if
(
newBuffer
)
newBuffer
.
link
(
cm
);
else
cm
.
clear
();
else
cm
.
clear
();
}
}
const
oldConfig
=
getConfig
(
this
.
props
);
const
newConfig
=
getConfig
(
newProps
);
// Incremental update options
// Incremental update options
var
opt
;
var
opt
;
for
(
opt
in
oldConfig
)
if
(
!
(
opt
in
newConfig
))
{
for
(
opt
in
oldConfig
)
if
(
!
(
opt
in
newConfig
))
{
...
@@ -315,6 +324,8 @@ class CodeMirrorWrapper extends React.Component {
...
@@ -315,6 +324,8 @@ class CodeMirrorWrapper extends React.Component {
if
(
oldSelect
)
this
.
_unmarkElementsWith
(
CSS_SELECTED
);
if
(
oldSelect
)
this
.
_unmarkElementsWith
(
CSS_SELECTED
);
if
(
newSelect
)
this
.
_markElementsWith
(
'
dome-xMark-
'
+
newSelect
,
CSS_SELECTED
);
if
(
newSelect
)
this
.
_markElementsWith
(
'
dome-xMark-
'
+
newSelect
,
CSS_SELECTED
);
}
}
// Refresh on new font
if
(
oldFont
!==
newFont
)
setImmediate
(
this
.
refresh
);
}
}
// Keep mounted node unchanged
// Keep mounted node unchanged
return
false
;
return
false
;
...
@@ -390,12 +401,14 @@ class CodeMirrorWrapper extends React.Component {
...
@@ -390,12 +401,14 @@ class CodeMirrorWrapper extends React.Component {
*/
*/
export
function
Text
(
props
)
{
export
function
Text
(
props
)
{
const
{
className
,
style
,
fontSize
,
...
config
}
=
props
;
let
{
className
,
style
,
fontSize
,
...
cmprops
}
=
props
;
if
(
fontSize
<
4
)
fontSize
=
4
;
if
(
fontSize
>
48
)
fontSize
=
48
;
const
theStyle
=
Object
.
assign
(
{}
,
style
);
const
theStyle
=
Object
.
assign
(
{}
,
style
);
if
(
fontSize
)
theStyle
.
fontSize
=
fontSize
;
theStyle
.
fontSize
=
fontSize
;
return
(
return
(
<
Vfill
className
=
{
className
}
style
=
{
theStyle
}
>
<
Vfill
className
=
{
className
}
style
=
{
theStyle
}
>
<
CodeMirrorWrapper
{...
config
}
/
>
<
CodeMirrorWrapper
fontSize
=
{
fontSize
}
{...
cmprops
}
/
>
<
/Vfill
>
<
/Vfill
>
);
);
}
}
...
...
This diff is collapsed.
Click to expand it.
ivette/src/renderer/ASTview.tsx
+
2
−
2
View file @
4b6da262
...
@@ -95,8 +95,8 @@ const ASTview = () => {
...
@@ -95,8 +95,8 @@ const ASTview = () => {
},
[
buffer
,
theMarker
]);
},
[
buffer
,
theMarker
]);
// Callbacks
// Callbacks
const
zoomIn
=
()
=>
setFontSize
(
fontSize
+
2
);
const
zoomIn
=
()
=>
fontSize
<
48
&&
setFontSize
(
fontSize
+
2
);
const
zoomOut
=
()
=>
setFontSize
(
fontSize
-
2
);
const
zoomOut
=
()
=>
fontSize
>
4
&&
setFontSize
(
fontSize
-
2
);
const
onSelection
=
(
marker
:
any
)
=>
setSelect
({
marker
});
const
onSelection
=
(
marker
:
any
)
=>
setSelect
({
marker
});
// Theme Popup
// Theme Popup
...
...
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