From f643b2a194c6ae23b94617f77bc157ee20df6743 Mon Sep 17 00:00:00 2001 From: Maxime Jacquemin <maxime2.jacquemin@gmail.com> Date: Mon, 21 Feb 2022 11:22:49 +0100 Subject: [PATCH] [ivette] Calls to useThemeColors at the beginning of functions Avoiding potential futur errors. --- ivette/src/frama-c/kernel/ASTinfo.tsx | 3 ++- ivette/src/ivette/prefs.tsx | 3 ++- ivette/src/renderer/Controller.tsx | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ivette/src/frama-c/kernel/ASTinfo.tsx b/ivette/src/frama-c/kernel/ASTinfo.tsx index 42d5488bfbc..9ae52f7ec89 100644 --- a/ivette/src/frama-c/kernel/ASTinfo.tsx +++ b/ivette/src/frama-c/kernel/ASTinfo.tsx @@ -40,6 +40,7 @@ import { getInfo } from 'frama-c/kernel/api/ast'; export default function ASTinfo(): JSX.Element { + const theme = Preferences.useThemeColors(); const buffer = React.useMemo(() => new RichTextBuffer(), []); const [selection, updateSelection] = States.useSelection(); const marker = selection?.current?.marker; @@ -65,7 +66,7 @@ export default function ASTinfo(): JSX.Element { <Text buffer={buffer} mode="text" - theme={Preferences.useThemeColors()} + theme={theme} onSelection={onTextSelection} readOnly /> diff --git a/ivette/src/ivette/prefs.tsx b/ivette/src/ivette/prefs.tsx index 0e9b3dece18..d71fab48e1d 100644 --- a/ivette/src/ivette/prefs.tsx +++ b/ivette/src/ivette/prefs.tsx @@ -95,12 +95,13 @@ export function useThemeColors() { export function useThemeButtons(props: ThemeProps): ThemeControls { const [fontSize, setFontSize] = Settings.useGlobalSettings(props.fontSize); const [wrapText, setWrapText] = Settings.useGlobalSettings(props.wrapText); + const theme = useThemeColors(); const zoomIn = () => fontSize < 48 && setFontSize(fontSize + 2); const zoomOut = () => fontSize > 4 && setFontSize(fontSize - 2); const flipWrapText = () => setWrapText(!wrapText); const { disabled = false } = props; return { - theme: useThemeColors(), + theme, fontSize, wrapText, buttons: [ diff --git a/ivette/src/renderer/Controller.tsx b/ivette/src/renderer/Controller.tsx index b7236c770d5..df50ecbcbc3 100644 --- a/ivette/src/renderer/Controller.tsx +++ b/ivette/src/renderer/Controller.tsx @@ -197,6 +197,7 @@ export const Control = () => { const editor = new RichTextBuffer(); const RenderConsole = () => { + const theme = Preferences.useThemeColors(); const scratch = React.useRef([] as string[]); const [cursor, setCursor] = React.useState(-1); const [isEmpty, setEmpty] = React.useState(true); @@ -331,7 +332,7 @@ const RenderConsole = () => { buffer={edited ? editor : Server.buffer} mode="text" readOnly={!edited} - theme={Preferences.useThemeColors()} + theme={theme} /> </> ); -- GitLab