diff --git a/ivette/src/frama-c/kernel/Locations.tsx b/ivette/src/frama-c/kernel/Locations.tsx index d41fd29e2c7c226b999661ab4bb0c75015054291..9907e21c2b73e71db685ef91ec588161ebe4dc15 100644 --- a/ivette/src/frama-c/kernel/Locations.tsx +++ b/ivette/src/frama-c/kernel/Locations.tsx @@ -60,15 +60,19 @@ export function useSelection(): MultiSelection { return s; } -export function setSelection(s: MultiSelection): void { +function updateSelection(s: MultiSelection): void { MultiSelection.setValue(s); const marker = s.index !== undefined ? s.markers[s.index] : undefined; if (marker) States.setSelected(marker); +} + +export function setSelection(s: MultiSelection): void { + updateSelection(s); if (s.plugin && s.markers.length > 0) { - const label = - `${s.plugin}: ${s.markers.length} locations selected, \ - listed in the 'Locations' panel`; - const title = `${s.label}: ${s.markers.length} locations selected`; + const label = `${s.plugin}: ${s.markers.length} locations selected`; + const title = + `${s.label}: ${s.markers.length} locations selected` + + `\nListed in the 'Locations' panel`; Display.showMessage({ label, title }); Display.alertComponent('fc.kernel.locations'); } @@ -78,7 +82,7 @@ Server.onShutdown(() => MultiSelection.setValue(emptySelection)); export function setIndex(index: number): void { const s = MultiSelection.getValue(); - setSelection({ ...s, index }); + updateSelection({ ...s, index }); } function sameMarkers(xs: Ast.marker[], ys: Ast.marker[]): boolean { @@ -104,9 +108,9 @@ export function setNextSelection(s: MultiSelection): void { const { index, markers } = selection; const target = index === undefined ? 0 : index + 1; const select = target < markers.length ? target : 0; - setSelection({ ...selection, index: select }); + updateSelection({ ...selection, index: select }); } else { - setSelection(s); + updateSelection(s); } } @@ -117,7 +121,7 @@ export function clearSelection(): void { function gotoIndex(index: number): void { const selection = MultiSelection.getValue(); if (0 <= index && index <= selection.markers.length) - setSelection({ ...selection, index }); + updateSelection({ ...selection, index }); } // -------------------------------------------------------------------------- diff --git a/ivette/src/ivette/display.tsx b/ivette/src/ivette/display.tsx index 6e7e68c4234b646ad3580a1f45ea6ffb1dd6c416..af1bdad3bd5bdcc017b609a56550e7d7129599bf 100644 --- a/ivette/src/ivette/display.tsx +++ b/ivette/src/ivette/display.tsx @@ -124,14 +124,15 @@ export function useComponentStatus( return Laboratory.getComponentStatus(state, id ?? ''); } -export type ShortMessage = undefined | null | string; -export type Message = ShortMessage | Laboratory.Notification; -export type Warning = ShortMessage | { label: string, title: string }; +export type Message = string | { label: string, title: string }; /** Message notification */ export function showMessage(msg: Message): void { if (!msg) return; - Laboratory.showMessage(typeof msg === 'string' ? { label: msg } : msg); + const short = typeof msg === 'string'; + const label = short ? msg : msg.label; + const title = short ? msg : msg.title; + Laboratory.showMessage({ kind: "message", label, title }); } /** Warning notification. */ @@ -139,7 +140,7 @@ export function showWarning(msg: Message): void { if (!msg) return; const short = typeof msg === 'string'; const label = short ? msg : msg.label; - const title = short ? msg : undefined; + const title = short ? msg : msg.title; Laboratory.showMessage({ kind: 'warning', label, title }); } @@ -148,7 +149,7 @@ export function showError(msg: Message): void { if (!msg) return; const short = typeof msg === 'string'; const label = short ? msg : msg.label; - const title = short ? msg : undefined; + const title = short ? msg : msg.title; Laboratory.showMessage({ kind: 'error', label, title }); } diff --git a/ivette/src/ivette/laboratory.tsx b/ivette/src/ivette/laboratory.tsx index 61eb3cb2a834c1cd38ed4d0da3c8c3f33bd63a38..c64b67e13852c48d19fd9858ca279ba8beafb177 100644 --- a/ivette/src/ivette/laboratory.tsx +++ b/ivette/src/ivette/laboratory.tsx @@ -913,7 +913,7 @@ function LayoutMenu(): JSX.Element | null { type NotificationKind = 'message' | 'warning' | 'error'; export interface Notification { - kind?: NotificationKind; + kind: NotificationKind; label: string; title?: string; } diff --git a/ivette/src/renderer/style.css b/ivette/src/renderer/style.css index c922803099d4e662c55eaf6f9b2011d8d93dbe59..20e48c21763cd26dfcc678858ea561239f2e106e 100644 --- a/ivette/src/renderer/style.css +++ b/ivette/src/renderer/style.css @@ -124,12 +124,11 @@ .labview-notification-item { flex: 1 1 auto; - max-width: 200px; + max-width: 400px; border: thin solid var(--border); border-radius: 8px; margin: 2px 1px 2px 0px; - padding: 2px 10px 3px 2px; - font-size: smaller; + padding: 3px 15px 1px 4px; } .labview-notification-message {