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
8433cb6a
Commit
8433cb6a
authored
4 years ago
by
Michele Alberti
Browse files
Options
Downloads
Patches
Plain Diff
[Dome][Ivette] Add function to print text with tags, and use in Ivette components.
parent
778180da
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/src/renderer/text/buffers.js
+31
-0
31 additions, 0 deletions
ivette/src/dome/src/renderer/text/buffers.js
ivette/src/renderer/ASTinfo.tsx
+1
-16
1 addition, 16 deletions
ivette/src/renderer/ASTinfo.tsx
ivette/src/renderer/ASTview.tsx
+3
-17
3 additions, 17 deletions
ivette/src/renderer/ASTview.tsx
with
35 additions
and
33 deletions
ivette/src/dome/src/renderer/text/buffers.js
+
31
−
0
View file @
8433cb6a
...
@@ -540,6 +540,37 @@ is blocked.
...
@@ -540,6 +540,37 @@ is blocked.
.
finally
(
endOperation
);
.
finally
(
endOperation
);
}
}
// --------------------------------------------------------------------------
// --- Print Utilities
// --------------------------------------------------------------------------
/**
@summary Print text containing tags into buffer (bound to `this`).
@param {string|string[]} text - Text to print.
@param {object} options - CodeMirror
[text marker](https://codemirror.net/doc/manual.html#api_marker) options.
*/
printTextWithTags
(
text
,
options
=
{})
{
if
(
Array
.
isArray
(
text
))
{
const
tag
=
text
.
shift
();
if
(
tag
!==
''
)
{
const
markerOptions
=
{
id
:
tag
,
...
options
};
this
.
openTextMarker
(
markerOptions
);
}
text
.
forEach
((
txt
)
=>
this
.
printTextWithTags
(
txt
,
options
));
if
(
tag
!==
''
)
{
this
.
closeTextMarker
();
}
}
else
if
(
typeof
(
text
)
===
'
string
'
)
{
this
.
append
(
text
);
}
else
{
// This case should be useless when using TS.
console
.
error
(
`Function 'printTextWithTags' accepts a parameter of `
+
`type string or string array: got '
${
typeof
text
}
'.`
);
}
}
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
ivette/src/renderer/ASTinfo.tsx
+
1
−
16
View file @
8433cb6a
...
@@ -14,21 +14,6 @@ import { Component } from 'frama-c/LabViews';
...
@@ -14,21 +14,6 @@ import { Component } from 'frama-c/LabViews';
// --- Information Panel
// --- Information Panel
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
const
printInfo
=
(
buffer
:
RichTextBuffer
,
text
:
string
|
string
[])
=>
{
if
(
Array
.
isArray
(
text
))
{
const
tag
=
text
.
shift
();
if
(
tag
!==
''
)
{
buffer
.
openTextMarker
({
id
:
tag
,
css
:
'
color: blue
'
});
}
text
.
forEach
((
txt
)
=>
printInfo
(
buffer
,
txt
));
if
(
tag
!==
''
)
{
buffer
.
closeTextMarker
();
}
}
else
{
buffer
.
append
(
text
);
}
};
const
ASTinfo
=
()
=>
{
const
ASTinfo
=
()
=>
{
const
buffer
=
React
.
useMemo
(()
=>
new
RichTextBuffer
(),
[]);
const
buffer
=
React
.
useMemo
(()
=>
new
RichTextBuffer
(),
[]);
...
@@ -39,7 +24,7 @@ const ASTinfo = () => {
...
@@ -39,7 +24,7 @@ const ASTinfo = () => {
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
buffer
.
clear
();
buffer
.
clear
();
if
(
data
)
{
if
(
data
)
{
printInfo
(
buffer
,
data
);
buffer
.
printTextWithTags
(
data
,
{
css
:
'
color: blue
'
}
);
}
}
},
[
buffer
,
data
]);
},
[
buffer
,
data
]);
...
...
This diff is collapsed.
Click to expand it.
ivette/src/renderer/ASTview.tsx
+
3
−
17
View file @
8433cb6a
...
@@ -33,21 +33,6 @@ const PP = new Dome.PP('AST View');
...
@@ -33,21 +33,6 @@ const PP = new Dome.PP('AST View');
// --- Rich Text Printer
// --- Rich Text Printer
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
const
printAST
=
(
buffer
:
RichTextBuffer
,
text
:
string
)
=>
{
if
(
Array
.
isArray
(
text
))
{
const
tag
=
text
.
shift
();
if
(
tag
!==
''
)
{
buffer
.
openTextMarker
({
id
:
tag
});
}
text
.
forEach
((
txt
)
=>
printAST
(
buffer
,
txt
));
if
(
tag
!==
''
)
{
buffer
.
closeTextMarker
();
}
}
else
if
(
typeof
(
text
)
===
'
string
'
)
{
buffer
.
append
(
text
);
}
};
async
function
loadAST
(
async
function
loadAST
(
buffer
:
RichTextBuffer
,
theFunction
?:
string
,
theMarker
?:
string
,
buffer
:
RichTextBuffer
,
theFunction
?:
string
,
theMarker
?:
string
,
)
{
)
{
...
@@ -62,9 +47,10 @@ async function loadAST(
...
@@ -62,9 +47,10 @@ async function loadAST(
});
});
buffer
.
operation
(()
=>
{
buffer
.
operation
(()
=>
{
buffer
.
clear
();
buffer
.
clear
();
if
(
!
data
)
if
(
!
data
)
{
buffer
.
log
(
'
// No code for function
'
,
theFunction
);
buffer
.
log
(
'
// No code for function
'
,
theFunction
);
printAST
(
buffer
,
data
);
}
buffer
.
printTextWithTags
(
data
);
if
(
theMarker
)
if
(
theMarker
)
buffer
.
scroll
(
theMarker
,
undefined
);
buffer
.
scroll
(
theMarker
,
undefined
);
});
});
...
...
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