mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-03 11:44:18 +01:00
PhysicalDisplay: fix typo
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
#include "modules/localip/localip.h"
|
||||
#include "modules/media/media.h"
|
||||
#include "modules/memory/memory.h"
|
||||
#include "modules/phycialdisplay/phycialdisplay.h"
|
||||
#include "modules/physicaldisplay/physicaldisplay.h"
|
||||
#include "modules/opengl/opengl.h"
|
||||
#include "modules/opencl/opencl.h"
|
||||
#include "modules/os/os.h"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "modules/localip/option.h"
|
||||
#include "modules/media/option.h"
|
||||
#include "modules/memory/option.h"
|
||||
#include "modules/phycialdisplay/option.h"
|
||||
#include "modules/physicaldisplay/option.h"
|
||||
#include "modules/opengl/option.h"
|
||||
#include "modules/opencl/option.h"
|
||||
#include "modules/os/option.h"
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/phycialdisplay/phycialdisplay.h"
|
||||
#include "modules/phycialdisplay/phycialdisplay.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_PHYCIALDISPLAY_DISPLAY_NAME "Phycial Display"
|
||||
#define FF_PHYCIALDISPLAY_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhycialDisplayResult));
|
||||
|
||||
const char* error = ffDetectPhycialDisplay(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_PHYCIALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(FF_PHYCIALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "No phycial display detected");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_LIST_FOR_EACH(FFPhycialDisplayResult, display, result)
|
||||
{
|
||||
double inch = sqrt(display->phycialWidth * display->phycialWidth + display->phycialHeight * display->phycialHeight) / 25.4;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
if(options->moduleArgs.key.length == 0)
|
||||
{
|
||||
ffStrbufAppendF(&key, "%s (%s)", FF_PHYCIALDISPLAY_DISPLAY_NAME, display->name.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name},
|
||||
});
|
||||
}
|
||||
ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
|
||||
printf("%upx x %upx", display->width, display->height);
|
||||
if (inch > 0)
|
||||
printf(" - %umm x %umm (%.2f inches)\n", display->phycialWidth, display->phycialHeight, inch);
|
||||
else
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(FF_PHYCIALDISPLAY_DISPLAY_NAME, index, &options->moduleArgs, FF_PHYCIALDISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->width},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->height},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->phycialWidth},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->phycialHeight},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &inch},
|
||||
});
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&display->name);
|
||||
}
|
||||
}
|
||||
|
||||
void ffInitPhycialDisplayOptions(FFPhycialDisplayOptions* options)
|
||||
{
|
||||
options->moduleName = FF_PHYCIALDISPLAY_MODULE_NAME;
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffParsePhycialDisplayCommandOptions(FFPhycialDisplayOptions* options, const char* key, const char* value)
|
||||
{
|
||||
const char* subKey = ffOptionTestPrefix(key, FF_PHYCIALDISPLAY_MODULE_NAME);
|
||||
if (!subKey) return false;
|
||||
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffDestroyPhycialDisplayOptions(FFPhycialDisplayOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParsePhycialDisplayJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFPhycialDisplayOptions __attribute__((__cleanup__(ffDestroyPhycialDisplayOptions))) options;
|
||||
ffInitPhycialDisplayOptions(&options);
|
||||
|
||||
if (module)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_PHYCIALDISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintPhycialDisplay(&options);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_PHYCIALDISPLAY_MODULE_NAME "PhycialDisplay"
|
||||
|
||||
void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options);
|
||||
void ffInitPhycialDisplayOptions(FFPhycialDisplayOptions* options);
|
||||
bool ffParsePhycialDisplayCommandOptions(FFPhycialDisplayOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPhycialDisplayOptions(FFPhycialDisplayOptions* options);
|
||||
void ffParsePhycialDisplayJsonObject(yyjson_val* module);
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef struct FFPhycialDisplayOptions
|
||||
typedef struct FFPhysicalDisplayOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFPhycialDisplayOptions;
|
||||
} FFPhysicalDisplayOptions;
|
||||
@@ -0,0 +1,117 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/physicaldisplay/physicaldisplay.h"
|
||||
#include "modules/physicaldisplay/physicaldisplay.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_PHYSICALDISPLAY_DISPLAY_NAME "Physical Display"
|
||||
#define FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalDisplayResult));
|
||||
|
||||
const char* error = ffDetectPhysicalDisplay(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_PHYSICALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(FF_PHYSICALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "No physical display detected");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_LIST_FOR_EACH(FFPhysicalDisplayResult, display, result)
|
||||
{
|
||||
double inch = sqrt(display->physicalWidth * display->physicalWidth + display->physicalHeight * display->physicalHeight) / 25.4;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
if(options->moduleArgs.key.length == 0)
|
||||
{
|
||||
ffStrbufAppendF(&key, "%s (%s)", FF_PHYSICALDISPLAY_DISPLAY_NAME, display->name.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name},
|
||||
});
|
||||
}
|
||||
ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor);
|
||||
|
||||
printf("%upx x %upx", display->width, display->height);
|
||||
if (inch > 0)
|
||||
printf(" - %umm x %umm (%.2f inches)\n", display->physicalWidth, display->physicalHeight, inch);
|
||||
else
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(FF_PHYSICALDISPLAY_DISPLAY_NAME, index, &options->moduleArgs, FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &display->name},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->width},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->height},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->physicalWidth},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->physicalHeight},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &inch},
|
||||
});
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&display->name);
|
||||
}
|
||||
}
|
||||
|
||||
void ffInitPhysicalDisplayOptions(FFPhysicalDisplayOptions* options)
|
||||
{
|
||||
options->moduleName = FF_PHYSICALDISPLAY_MODULE_NAME;
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, const char* key, const char* value)
|
||||
{
|
||||
const char* subKey = ffOptionTestPrefix(key, FF_PHYSICALDISPLAY_MODULE_NAME);
|
||||
if (!subKey) return false;
|
||||
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffDestroyPhysicalDisplayOptions(FFPhysicalDisplayOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParsePhysicalDisplayJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFPhysicalDisplayOptions __attribute__((__cleanup__(ffDestroyPhysicalDisplayOptions))) options;
|
||||
ffInitPhysicalDisplayOptions(&options);
|
||||
|
||||
if (module)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_PHYSICALDISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintPhysicalDisplay(&options);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_PHYSICALDISPLAY_MODULE_NAME "PhysicalDisplay"
|
||||
|
||||
void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options);
|
||||
void ffInitPhysicalDisplayOptions(FFPhysicalDisplayOptions* options);
|
||||
bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPhysicalDisplayOptions(FFPhysicalDisplayOptions* options);
|
||||
void ffParsePhysicalDisplayJsonObject(yyjson_val* module);
|
||||
Reference in New Issue
Block a user