Files
fastfetch/src/modules/terminal.c
T

38 lines
1007 B
C
Raw Normal View History

2021-02-18 22:25:36 +01:00
#include "fastfetch.h"
2021-03-11 17:21:18 +01:00
void ffPrintTerminal(FFinstance* instance)
{
2021-04-02 16:21:52 +02:00
FFstrbuf* exeName;
FFstrbuf* processName;
FFstrbuf* error;
2021-03-19 20:57:07 +01:00
2021-04-03 23:10:14 +02:00
ffCalculateTerminal(instance, &exeName, &processName, &error);
2021-04-02 16:21:52 +02:00
2021-04-03 21:51:50 +02:00
if(error->length > 0)
{
ffPrintError(instance, &instance->config.terminalKey, "Terminal", error->chars);
return;
}
2021-04-02 16:21:52 +02:00
FFstrbuf* name;
if(ffStrbufStartsWith(exeName, processName))
name = exeName;
else
name = processName;
2021-03-27 18:14:19 +01:00
2021-03-23 19:48:52 +01:00
if(instance->config.terminalFormat.length == 0)
2021-03-11 17:21:18 +01:00
{
2021-04-03 11:39:59 +02:00
ffPrintLogoAndKey(instance, &instance->config.terminalKey, "Terminal");
2021-04-02 16:21:52 +02:00
ffStrbufPutTo(name, stdout);
2021-03-11 17:21:18 +01:00
}
else
{
2021-04-03 11:39:59 +02:00
ffPrintFormatString(instance, &instance->config.terminalKey, "Terminal", &instance->config.terminalFormat, 3,
2021-04-02 16:21:52 +02:00
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, exeName},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, processName},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, name}
2021-03-19 20:57:07 +01:00
);
2021-03-11 17:21:18 +01:00
}
2021-02-18 22:25:36 +01:00
}