Skip to content
Snippets Groups Projects
Commit f643b2a1 authored by Maxime Jacquemin's avatar Maxime Jacquemin Committed by Loïc Correnson
Browse files

[ivette] Calls to useThemeColors at the beginning of functions

Avoiding potential futur errors.
parent 6caa2551
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,7 @@ import { getInfo } from 'frama-c/kernel/api/ast'; ...@@ -40,6 +40,7 @@ import { getInfo } from 'frama-c/kernel/api/ast';
export default function ASTinfo(): JSX.Element { export default function ASTinfo(): JSX.Element {
const theme = Preferences.useThemeColors();
const buffer = React.useMemo(() => new RichTextBuffer(), []); const buffer = React.useMemo(() => new RichTextBuffer(), []);
const [selection, updateSelection] = States.useSelection(); const [selection, updateSelection] = States.useSelection();
const marker = selection?.current?.marker; const marker = selection?.current?.marker;
...@@ -65,7 +66,7 @@ export default function ASTinfo(): JSX.Element { ...@@ -65,7 +66,7 @@ export default function ASTinfo(): JSX.Element {
<Text <Text
buffer={buffer} buffer={buffer}
mode="text" mode="text"
theme={Preferences.useThemeColors()} theme={theme}
onSelection={onTextSelection} onSelection={onTextSelection}
readOnly readOnly
/> />
......
...@@ -95,12 +95,13 @@ export function useThemeColors() { ...@@ -95,12 +95,13 @@ export function useThemeColors() {
export function useThemeButtons(props: ThemeProps): ThemeControls { export function useThemeButtons(props: ThemeProps): ThemeControls {
const [fontSize, setFontSize] = Settings.useGlobalSettings(props.fontSize); const [fontSize, setFontSize] = Settings.useGlobalSettings(props.fontSize);
const [wrapText, setWrapText] = Settings.useGlobalSettings(props.wrapText); const [wrapText, setWrapText] = Settings.useGlobalSettings(props.wrapText);
const theme = useThemeColors();
const zoomIn = () => fontSize < 48 && setFontSize(fontSize + 2); const zoomIn = () => fontSize < 48 && setFontSize(fontSize + 2);
const zoomOut = () => fontSize > 4 && setFontSize(fontSize - 2); const zoomOut = () => fontSize > 4 && setFontSize(fontSize - 2);
const flipWrapText = () => setWrapText(!wrapText); const flipWrapText = () => setWrapText(!wrapText);
const { disabled = false } = props; const { disabled = false } = props;
return { return {
theme: useThemeColors(), theme,
fontSize, fontSize,
wrapText, wrapText,
buttons: [ buttons: [
......
...@@ -197,6 +197,7 @@ export const Control = () => { ...@@ -197,6 +197,7 @@ export const Control = () => {
const editor = new RichTextBuffer(); const editor = new RichTextBuffer();
const RenderConsole = () => { const RenderConsole = () => {
const theme = Preferences.useThemeColors();
const scratch = React.useRef([] as string[]); const scratch = React.useRef([] as string[]);
const [cursor, setCursor] = React.useState(-1); const [cursor, setCursor] = React.useState(-1);
const [isEmpty, setEmpty] = React.useState(true); const [isEmpty, setEmpty] = React.useState(true);
...@@ -331,7 +332,7 @@ const RenderConsole = () => { ...@@ -331,7 +332,7 @@ const RenderConsole = () => {
buffer={edited ? editor : Server.buffer} buffer={edited ? editor : Server.buffer}
mode="text" mode="text"
readOnly={!edited} readOnly={!edited}
theme={Preferences.useThemeColors()} theme={theme}
/> />
</> </>
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment