mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
TerminalFont: add support for ConEmu
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "common/properties.h"
|
||||
#include "common/io.h"
|
||||
#include "detection/terminalshell/terminalshell.h"
|
||||
#include "terminalfont.h"
|
||||
|
||||
@@ -73,10 +74,64 @@ exit:
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
static void detectConEmu(const FFinstance* instance, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
FF_UNUSED(instance)
|
||||
|
||||
//https://conemu.github.io/en/ConEmuXml.html#search-sequence
|
||||
FFstrbuf path;
|
||||
ffStrbufInit(&path);
|
||||
|
||||
FFstrbuf fontName;
|
||||
ffStrbufInit(&fontName);
|
||||
|
||||
FFstrbuf fontSize;
|
||||
ffStrbufInit(&fontSize);
|
||||
|
||||
const char* paths[] = { "ConEmuDir", "ConEmuBaseDir", "APPDATA" };
|
||||
for (uint32_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i)
|
||||
{
|
||||
ffStrbufSetS(&path, getenv(paths[i]));
|
||||
if(path.length > 0)
|
||||
{
|
||||
ffStrbufAppendS(&path, "/ConEmu.xml");
|
||||
if(ffParsePropFileValues(path.chars, 2, (FFpropquery[]){
|
||||
{"<value name=\"FontName\" type=\"string\" data=\"", &fontName},
|
||||
{"<value name=\"FontSize\" type=\"ulong\" data=\"", &fontSize}
|
||||
}))
|
||||
break;
|
||||
}
|
||||
}
|
||||
ffStrbufDestroy(&path);
|
||||
|
||||
if(fontName.length == 0 && fontSize.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "Failed to parse ConEmu.xml");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fontName.length > 0)
|
||||
ffStrbufSubstrBeforeLastC(&fontName, '"');
|
||||
else
|
||||
ffStrbufAppendS(&fontName, "Consola");
|
||||
|
||||
if(fontSize.length > 0)
|
||||
ffStrbufSubstrBeforeLastC(&fontSize, '"');
|
||||
else
|
||||
ffStrbufAppendS(&fontSize, "14");
|
||||
|
||||
ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars);
|
||||
|
||||
ffStrbufDestroy(&fontName);
|
||||
ffStrbufDestroy(&fontSize);
|
||||
}
|
||||
|
||||
void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "mintty") == 0)
|
||||
detectMintty(instance, terminalFont);
|
||||
else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "conhost.exe") == 0)
|
||||
detectConhost(instance, terminalFont);
|
||||
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalProcessName, "ConEmuC"))
|
||||
detectConEmu(instance, terminalFont);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user