From 64bdb5968307427918da14f754c541497f4f3dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 17 Jun 2023 15:38:50 +0800 Subject: [PATCH] Display: print `*` for primary monitors Also `FF_FORMAT_ARG_VALUE_BOOL` was removed, which makes usages of `FF_FORMAT_ARG_VALUE_*` inconsistant --- src/common/format.c | 2 +- src/common/format.h | 2 -- src/modules/disk/disk.c | 6 ++++-- src/modules/display/display.c | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common/format.c b/src/common/format.c index 07f54f247..4ed096dc1 100644 --- a/src/common/format.c +++ b/src/common/format.c @@ -25,7 +25,7 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg) else if(formatarg->type == FF_FORMAT_ARG_TYPE_DOUBLE) ffStrbufAppendF(buffer, "%g", *(double*)formatarg->value); else if(formatarg->type == FF_FORMAT_ARG_TYPE_BOOL) - ffStrbufAppendS(buffer, formatarg->value != NULL ? "true" : "false"); + ffStrbufAppendS(buffer, *(bool*)formatarg->value ? "true" : "false"); else if(formatarg->type == FF_FORMAT_ARG_TYPE_LIST) { const FFlist* list = formatarg->value; diff --git a/src/common/format.h b/src/common/format.h index cc7e29e6d..57c8c680f 100644 --- a/src/common/format.h +++ b/src/common/format.h @@ -27,6 +27,4 @@ typedef struct FFformatarg void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg); void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments); -#define FF_FORMAT_ARG_VALUE_BOOL(xpr) ((xpr) ? (const void*) 1 : NULL) - #endif diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 4ff74d129..ec2478e72 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -76,6 +76,8 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk { uint8_t filesPercentage = disk->filesTotal > 0 ? (uint8_t) (((double) disk->filesUsed / (double) disk->filesTotal) * 100.0) : 0; + bool isExternal = !!(disk->type & FF_DISK_TYPE_EXTERNAL_BIT); + bool isHidden = !!(disk->type & FF_DISK_TYPE_HIDDEN_BIT); ffPrintFormatString(instance, key.chars, 0, NULL, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, @@ -83,8 +85,8 @@ static void printDisk(FFinstance* instance, FFDiskOptions* options, const FFDisk {FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed}, {FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal}, {FF_FORMAT_ARG_TYPE_UINT8, &filesPercentage}, - {FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_EXTERNAL_BIT)}, - {FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_HIDDEN_BIT)}, + {FF_FORMAT_ARG_TYPE_BOOL, &isExternal}, + {FF_FORMAT_ARG_TYPE_BOOL, &isHidden}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem}, {FF_FORMAT_ARG_TYPE_STRBUF, &disk->name} }); diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 72e1fd9bd..354b0061d 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -89,6 +89,9 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) result->scaledHeight > 0 && result->scaledHeight != result->height) printf(" (as %ix%i)", result->scaledWidth, result->scaledHeight); + if(moduleIndex > 0 && result->primary) + printf(" *"); + putchar('\n'); } else @@ -102,6 +105,7 @@ void ffPrintDisplay(FFinstance* instance, FFDisplayOptions* options) {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, {FF_FORMAT_ARG_TYPE_STRING, displayType}, {FF_FORMAT_ARG_TYPE_UINT, &result->rotation}, + {FF_FORMAT_ARG_TYPE_BOOL, &result->primary}, }); } }