Файли
openidea/src/platform/consoleFont.ts
T
l0ng-ai 00871ab971 fix(build): give build output more room and honor console fonts (#4536)
The Build tool window gives its output two thirds of the width by default, and the build console and message details use the console font (Tools > Terminal > Font, or the editor font) with its row height, like the Run and Debug consoles.
2026-11-19 21:40:05 +08:00

40 рядки
1.4 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
import { useProject } from "./project";
import { resolveMonoFont, type EditorFontChoice, type MonoFontChoice } from "./fonts";
import { useWorkflowSettings } from "./workflowSettings";
import { fontWeightOf } from "./editorSettings";
export interface ConsoleFont {
family: string;
size: number;
rowHeight: number;
weight: number;
boldWeight: number;
}
/**
* The font of the Build, Run and Debug consoles: Tools › Terminal › Font (which can follow
* Editor › Font), with the row height the consoles lay their lines out with. The
* weights match the terminal's: the editor's main and bold weights when the terminal
* uses the editor font, else regular and bold.
*/
export function consoleFontOf(
terminal: MonoFontChoice | undefined,
editor: (EditorFontChoice & { fontWeight?: number | null; boldFontWeight?: number | null }) | undefined,
): ConsoleFont {
const { family, size } = resolveMonoFont(terminal, editor);
const useEditor = !!terminal?.useEditorFont;
return {
family,
size,
rowHeight: Math.max(16, Math.round(size * 1.5)),
weight: useEditor ? fontWeightOf(editor?.fontWeight, 400) : 400,
boldWeight: useEditor ? fontWeightOf(editor?.boldFontWeight, 700) : 700,
};
}
export function useConsoleFont(): ConsoleFont {
const terminalFont = useWorkflowSettings((s) => s.terminal);
const editorFont = useProject((s) => s.settings?.editor);
return consoleFontOf(terminalFont, editorFont);
}