2021-02-18 22:25:36 +01:00
#include "fastfetch.h"
2021-04-15 18:59:26 +02:00
#define FF_TERMINAL_MODULE_NAME "Terminal"
#define FF_TERMINAL_NUM_FORMAT_ARGS 3
2021-03-11 17:21:18 +01:00
void ffPrintTerminal ( FFinstance * instance )
{
2021-04-16 20:22:38 +02:00
ffCalculateTerminal ( instance );
2021-03-19 20:57:07 +01:00
2021-04-16 20:22:38 +02:00
if ( instance -> state . terminal . error . length > 0 )
{
ffPrintError ( instance , FF_TERMINAL_MODULE_NAME , 0 , & instance -> config . terminalKey , & instance -> config . terminalFormat , FF_TERMINAL_NUM_FORMAT_ARGS , instance -> state . terminal . error . chars );
return ;
}
2021-04-02 16:21:52 +02:00
2021-04-16 20:22:38 +02:00
if ( instance -> state . terminal . exeName . length == 0 && instance -> state . terminal . processName . length == 0 )
2021-04-03 21:51:50 +02:00
{
2021-04-16 20:22:38 +02:00
ffPrintError ( instance , FF_TERMINAL_MODULE_NAME , 0 , & instance -> config . terminalKey , & instance -> config . terminalFormat , FF_TERMINAL_NUM_FORMAT_ARGS , "Terminal names not set" );
2021-04-03 21:51:50 +02:00
return ;
}
2021-04-02 16:21:52 +02:00
FFstrbuf * name ;
2021-04-16 20:22:38 +02:00
if ( ffStrbufStartsWith ( & instance -> state . terminal . exeName , & instance -> state . terminal . processName ))
name = & instance -> state . terminal . exeName ;
2021-04-02 16:21:52 +02:00
else
2021-04-16 20:22:38 +02:00
name = & instance -> state . terminal . 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-15 18:59:26 +02:00
ffPrintLogoAndKey ( instance , FF_TERMINAL_MODULE_NAME , 0 , & instance -> config . terminalKey );
2021-04-02 16:21:52 +02:00
ffStrbufPutTo ( name , stdout );
2021-03-11 17:21:18 +01:00
}
else
{
2021-04-15 18:59:26 +02:00
ffPrintFormatString ( instance , FF_TERMINAL_MODULE_NAME , 0 , & instance -> config . terminalKey , & instance -> config . terminalFormat , NULL , FF_TERMINAL_NUM_FORMAT_ARGS , ( FFformatarg []){
2021-04-16 20:22:38 +02:00
{ FF_FORMAT_ARG_TYPE_STRBUF , & instance -> state . terminal . exeName },
{ FF_FORMAT_ARG_TYPE_STRBUF , & instance -> state . terminal . processName },
2021-04-15 18:59:26 +02:00
{ FF_FORMAT_ARG_TYPE_STRBUF , name }
});
2021-03-11 17:21:18 +01:00
}
2021-02-18 22:25:36 +01:00
}