From 8738264c58c035a32b539ea49885f4b655486bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loi=CC=88c=20Correnson?= <loic.correnson@cea.fr> Date: Thu, 17 Dec 2020 09:43:19 +0100 Subject: [PATCH] [ivette/eva] probe selection --- .../dome/src/renderer/controls/buttons.tsx | 3 +- ivette/src/frama-c/eva/Values.tsx | 39 ++++++++++++++----- ivette/src/frama-c/eva/probes.ts | 2 - 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/ivette/src/dome/src/renderer/controls/buttons.tsx b/ivette/src/dome/src/renderer/controls/buttons.tsx index 8404310393a..871c37c1221 100644 --- a/ivette/src/dome/src/renderer/controls/buttons.tsx +++ b/ivette/src/dome/src/renderer/controls/buttons.tsx @@ -239,7 +239,7 @@ export const CircButton = (props: ButtonProps) => { // -------------------------------------------------------------------------- export type IconButtonKind = - undefined | 'default' | 'negative' | 'positive' | 'warning'; + undefined | 'selected' | 'default' | 'negative' | 'positive' | 'warning'; export interface IconButtonProps { /** Icon identifier. Displayed on the left side of the label. */ @@ -266,6 +266,7 @@ export interface IconButtonProps { display?: boolean; /** Styled bytton: - `'default'`: normal button; + - `'selected'`: selection button, in blue; - `'warning'`: warning button, in orange; - `'positive'`: positive button, in green; - `'negative'`: negative button, in red. diff --git a/ivette/src/frama-c/eva/Values.tsx b/ivette/src/frama-c/eva/Values.tsx index 1a005761e88..c2580b78314 100644 --- a/ivette/src/frama-c/eva/Values.tsx +++ b/ivette/src/frama-c/eva/Values.tsx @@ -52,8 +52,10 @@ function ProbeEditor() { const rank = probe?.rank; const stmt = rank ? `@S${rank}` : undefined; const { cols, rows } = sizeof(code); + const visible = probe ? !!code : model.getRowCount() > 0; + const visibility = visible ? 'visible' : 'hidden'; return ( - <Hpack className="eva-probe"> + <Hpack style={{ visibility }} className="eva-probe"> <Label className="eva-probe-label">{label && `${label}:`}</Label> <div className="eva-probe-code"> <SizedArea cols={cols} rows={rows}>{code}</SizedArea> @@ -61,8 +63,7 @@ function ProbeEditor() { <Code className="eva-probe-stmt">{stmt}</Code> <IconButton className="eva-probe-button" - visible={!!code} - kind={transient ? 'positive' : 'negative'} + kind={transient ? 'selected' : 'warning'} icon={transient ? 'CIRC.CHECK' : 'CIRC.CLOSE'} onClick={() => { if (probe) probe.setTransient(!transient); }} title={transient ? 'Make the probe persistent' : 'Release the probe'} @@ -73,7 +74,7 @@ function ProbeEditor() { } // -------------------------------------------------------------------------- -// --- Table Cell +// --- Table Cell Layout // -------------------------------------------------------------------------- interface TableCellProps { @@ -85,10 +86,11 @@ const CELLPADDING = 4; function TableCell(props: TableCellProps) { const model = useModel(); + const [selection, setSelection] = States.useSelection(); const { probe, kind } = props; const minWidth = CELLPADDING + WSIZER.dimension(probe.minCols); const maxWidth = CELLPADDING + WSIZER.dimension(probe.maxCols); - const style = { minWidth, maxWidth }; + const style = { width: minWidth, maxWidth }; let styling = 'dome-text-code'; let contents: React.ReactNode = props.probe.marker; const { transient, label, code } = probe; @@ -96,7 +98,7 @@ function TableCell(props: TableCellProps) { case 'probes': if (transient) { styling = 'dome-text-label'; - contents = '« Current »'; + contents = '« Probe »'; } else if (label) { styling = 'dome-text-label'; contents = label; @@ -105,9 +107,15 @@ function TableCell(props: TableCellProps) { } break; case 'values': - contents = ( - model.cache.getValues(probe.marker).values - ); + { + const { values } = model.cache.getValues(probe.marker); + const { cols, rows } = sizeof(values); + contents = ( + <SizedArea cols={cols} rows={rows}> + {values} + </SizedArea> + ); + } break; } const isFocused = model.getFocused() === probe; @@ -117,8 +125,19 @@ function TableCell(props: TableCellProps) { transient && 'eva-transient', !transient && isFocused && 'eva-focused', ); + const onClick = () => { + if (probe) { + const fct = selection?.current?.function; + const location = { function: fct, marker: probe.marker }; + setSelection({ location }); + } + }; return ( - <div className={className} style={style}> + <div + className={className} + style={style} + onClick={onClick} + > {contents} </div> ); diff --git a/ivette/src/frama-c/eva/probes.ts b/ivette/src/frama-c/eva/probes.ts index b7e6186b0c7..3b121c23f0f 100644 --- a/ivette/src/frama-c/eva/probes.ts +++ b/ivette/src/frama-c/eva/probes.ts @@ -107,8 +107,6 @@ export class Probe { const rq = q.rank ?? 0; if (rp < rq) return (-1); if (rp > rq) return (+1); - if (p.transient && !q.transient) return (-1); - if (!p.transient && q.transient) return (+1); if (p.marker < q.marker) return (-1); if (p.marker > q.marker) return (+1); return 0; -- GitLab