From f64bf732799c8b0c4221eaaf61d55e9ea8477193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 21 Aug 2023 20:24:15 +0800 Subject: [PATCH 1/4] Windows: fix compiling for GCC --- CHANGELOG.md | 7 ++ src/util/windows/wmi.hpp | 212 ++++++++++++++++++++------------------- 2 files changed, 116 insertions(+), 103 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9cf6773e..7aa6c602b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 2.0.2 + +Fix compiling for MSYS2, no functional changes. + +Bugfixes: +* Workarund [a compiler bug of GCC](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282) (Windows) + # 2.0.1 First stable release of Fastfetch V2 diff --git a/src/util/windows/wmi.hpp b/src/util/windows/wmi.hpp index 29ff621a0..f9719a664 100644 --- a/src/util/windows/wmi.hpp +++ b/src/util/windows/wmi.hpp @@ -14,6 +14,7 @@ extern "C" { #include #include #include +#include enum class FFWmiNamespace { CIMV2, @@ -36,115 +37,120 @@ struct FFWmiVariant: VARIANT { return this->hasValue(); } - template T get(); + template T get() + { + // boolean + if constexpr (std::is_same_v) { + assert(this->vt == VT_BOOL); + return this->boolVal != VARIANT_FALSE; + } - // boolean - template <> bool get() { - assert(this->vt == VT_BOOL); - return this->boolVal != VARIANT_FALSE; - } + // signed + else if constexpr (std::is_same_v) { + assert(this->vt == VT_I1); + return this->cVal; + } + else if constexpr (std::is_same_v) { + assert(vt == VT_I2); + return this->iVal; + } + else if constexpr (std::is_same_v) { + assert(this->vt == VT_I4 || vt == VT_INT); + return this->intVal; + } + else if constexpr (std::is_same_v) { + assert(this->vt == VT_I8); + return this->llVal; + } - // signed - template <> int8_t get() { - assert(this->vt == VT_I1); - return this->cVal; - } - template <> int16_t get() { - assert(vt == VT_I2); - return this->iVal; - } - template <> int32_t get() { - assert(this->vt == VT_I4 || vt == VT_INT); - return this->intVal; - } - template <> int64_t get() { - assert(this->vt == VT_I8); - return this->llVal; - } + // unsigned + else if constexpr (std::is_same_v) { + assert(this->vt == VT_UI1); + return this->bVal; + } + else if constexpr (std::is_same_v) { + assert(this->vt == VT_UI2); + return this->uiVal; + } + else if constexpr (std::is_same_v) { + assert(this->vt == VT_UI4 || vt == VT_UINT); + return this->uintVal; + } + else if constexpr (std::is_same_v) { + assert(this->vt == VT_UI8); + return this->ullVal; + } - // unsigned - template <> uint8_t get() { - assert(this->vt == VT_UI1); - return this->bVal; - } - template <> uint16_t get() { - assert(this->vt == VT_UI2); - return this->uiVal; - } - template <> uint32_t get() { - assert(this->vt == VT_UI4 || vt == VT_UINT); - return this->uintVal; - } - template <> uint64_t get() { - assert(this->vt == VT_UI8); - return this->ullVal; - } + // decimal + else if constexpr (std::is_same_v) { + assert(this->vt == VT_R4); + return this->fltVal; + } + else if constexpr (std::is_same_v) { + assert(this->vt == VT_R8); + return this->dblVal; + } - // decimal - template <> float get() { - assert(this->vt == VT_R4); - return this->fltVal; - } - template <> double get() { - assert(this->vt == VT_R8); - return this->dblVal; - } + // string + else if constexpr (std::is_same_v) { + assert(this->vt == VT_LPSTR); + return this->pcVal; + } + else if constexpr (std::is_same_v) { + assert(this->vt == VT_BSTR || this->vt == VT_LPWSTR); + if (this->vt == VT_LPWSTR) + return this->bstrVal; + else + return { this->bstrVal, SysStringLen(this->bstrVal) }; + } - // string - template <> std::string_view get() { - assert(this->vt == VT_LPSTR); - return this->pcVal; - } - template <> std::wstring_view get() { - assert(this->vt == VT_BSTR || this->vt == VT_LPWSTR); - if (this->vt == VT_LPWSTR) - return this->bstrVal; - else - return { this->bstrVal, SysStringLen(this->bstrVal) }; - } + // array signed + else if constexpr (std::is_same_v>) { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I1); + return std::make_pair((int8_t*)this->parray->pvData, this->parray->cDims); + } + else if constexpr (std::is_same_v>) { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I2); + return std::make_pair((int16_t*)this->parray->pvData, this->parray->cDims); + } + else if constexpr (std::is_same_v>) { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I4); + return std::make_pair((int32_t*)this->parray->pvData, this->parray->cDims); + } + else if constexpr (std::is_same_v>) { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_I8); + return std::make_pair((int64_t*)this->parray->pvData, this->parray->cDims); + } - // array signed - template <> std::pair get() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_I1); - return std::make_pair((int8_t*)this->parray->pvData, this->parray->cDims); - } - template <> std::pair get() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_I2); - return std::make_pair((int16_t*)this->parray->pvData, this->parray->cDims); - } - template <> std::pair get() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_I4); - return std::make_pair((int32_t*)this->parray->pvData, this->parray->cDims); - } - template <> std::pair get() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_I8); - return std::make_pair((int64_t*)this->parray->pvData, this->parray->cDims); - } - - // array unsigned - template <> std::pair get() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_UI1); - return std::make_pair((uint8_t*)this->parray->pvData, this->parray->cDims); - } - template <> std::pair get() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_UI2); - return std::make_pair((uint16_t*)this->parray->pvData, this->parray->cDims); - } - template <> std::pair get() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_UI4); - return std::make_pair((uint32_t*)this->parray->pvData, this->parray->cDims); - } - template <> std::pair get() { - assert(this->vt & VT_ARRAY); - assert((this->vt & ~VT_ARRAY) == VT_UI8); - return std::make_pair((uint64_t*)this->parray->pvData, this->parray->cDims); + // array unsigned + else if constexpr (std::is_same_v>) { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI1); + return std::make_pair((uint8_t*)this->parray->pvData, this->parray->cDims); + } + else if constexpr (std::is_same_v>) { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI2); + return std::make_pair((uint16_t*)this->parray->pvData, this->parray->cDims); + } + else if constexpr (std::is_same_v>) { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI4); + return std::make_pair((uint32_t*)this->parray->pvData, this->parray->cDims); + } + else if constexpr (std::is_same_v>) { + assert(this->vt & VT_ARRAY); + assert((this->vt & ~VT_ARRAY) == VT_UI8); + return std::make_pair((uint64_t*)this->parray->pvData, this->parray->cDims); + } + else { + assert(false && "unsupported type"); + __builtin_unreachable(); + } } }; From ef6af84ea11a5b904b837f9884dbf591b1f7d47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 21 Aug 2023 22:13:54 +0800 Subject: [PATCH 2/4] Fastfetch: fix presets not detected by file name (#529) --- CHANGELOG.md | 3 +-- src/fastfetch.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aa6c602b..20d4934c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,8 @@ # 2.0.2 -Fix compiling for MSYS2, no functional changes. - Bugfixes: * Workarund [a compiler bug of GCC](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282) (Windows) +* Fix presets not detected by file name (#529) # 2.0.1 diff --git a/src/fastfetch.c b/src/fastfetch.c index 213d37ec1..b06570ea1 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -758,7 +758,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateA(128); if (ffPathExpandEnv(value, &absolutePath)) { - bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, absolutePath.chars); + bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars); if(success) return; @@ -773,7 +773,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val ffStrbufAppendS(&absolutePath, "fastfetch/presets/"); ffStrbufAppendS(&absolutePath, value); - bool success = isJsonConfig ? parseJsoncFile(value) : parseConfigFile(data, absolutePath.chars); + bool success = isJsonConfig ? parseJsoncFile(absolutePath.chars) : parseConfigFile(data, absolutePath.chars); if(success) return; From fd5d2c84e854159d538b26d20518864389d0c9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 21 Aug 2023 22:46:50 +0800 Subject: [PATCH 3/4] Logo (Builtin): add Tuxedo OS --- CHANGELOG.md | 3 +++ README.md | 4 ++-- src/logo/ascii/tuxedo_os.txt | 16 ++++++++++++++++ src/logo/builtin.c | 9 +++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/logo/ascii/tuxedo_os.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d4934c4..fbe7e8026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Bugfixes: * Workarund [a compiler bug of GCC](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282) (Windows) * Fix presets not detected by file name (#529) +Logo: +* Add Tuxedo OS + # 2.0.1 First stable release of Fastfetch V2 diff --git a/README.md b/README.md index 271a91afd..a6257ecce 100644 --- a/README.md +++ b/README.md @@ -101,9 +101,9 @@ Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsa ##### Builtin logos - + ``` -AerOS, AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, Dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, GNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, Januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, LAST, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, MOS, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin +AerOS, AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, Dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, GNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, Januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, MOS, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, TuxedoOS, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin ``` Run `fastfetch --print-logos` to print them diff --git a/src/logo/ascii/tuxedo_os.txt b/src/logo/ascii/tuxedo_os.txt new file mode 100644 index 000000000..874bb4b4c --- /dev/null +++ b/src/logo/ascii/tuxedo_os.txt @@ -0,0 +1,16 @@ + #############################+ +.%#######################%@@@+ + . :#@%- + .#@%%%- =@@#. + *@%@@= +@@+ + =@@%@+.#@%- + -@@%@@@#: + .#@%%@- + :#@@%@@= + =@@+=@@%@+ + .#@@= -@@%@# + -%@#: :%@%@%: + *@@+ .#%%%%- + :%@%- . + +@@@%#%%%%%%%%%%%%%%%%%%%%%%%. + +######################******* diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 0246a77be..879328062 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -3657,6 +3657,15 @@ static const FFlogo T[] = { FF_COLOR_FG_CYAN, }, }, + // TuxedoOS + { + .names = {"Tuxedo OS"}, + .lines = FASTFETCH_DATATEXT_LOGO_TUXEDO_OS, + .colors = { + FF_COLOR_FG_WHITE, + FF_COLOR_FG_RED, + }, + }, // Twister { .names = {"Twister"}, From f77090070ca13476759c7abfe5484383f69b5f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 22 Aug 2023 15:31:10 +0800 Subject: [PATCH 4/4] Image: code cleanup; no functional change --- src/logo/image/image.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/logo/image/image.c b/src/logo/image/image.c index 2c31b8acc..9277ee3a5 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -3,6 +3,7 @@ #include "common/printing.h" #include +#include #ifdef __APPLE__ #include @@ -184,12 +185,6 @@ static inline bool checkAllocationResult(void* data, size_t length) return true; } -static inline uint32_t simpleCeil(double value) -{ - uint32_t result = (uint32_t) value; - return value == (double) result ? result : result + 1; -} - static void writeCacheStrbuf(FFLogoRequestData* requestData, const FFstrbuf* value, const char* cacheFileName) { uint32_t cacheDirLength = requestData->cacheDir.length; @@ -463,8 +458,8 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI else if(requestData->logoPixelHeight == 0) requestData->logoPixelHeight = (uint32_t) ((double) imageData.image->rows / (double) imageData.image->columns * requestData->logoPixelWidth); - requestData->logoCharacterWidth = simpleCeil((double) requestData->logoPixelWidth / requestData->characterPixelWidth); - requestData->logoCharacterHeight = simpleCeil((double) requestData->logoPixelHeight / requestData->characterPixelHeight); + requestData->logoCharacterWidth = (uint32_t) ceil((double) requestData->logoPixelWidth / requestData->characterPixelWidth); + requestData->logoCharacterHeight = (uint32_t) ceil((double) requestData->logoPixelHeight / requestData->characterPixelHeight); if(requestData->logoPixelWidth == 0 || requestData->logoPixelHeight == 0 || requestData->logoCharacterWidth == 0 || requestData->logoCharacterHeight == 0) { @@ -608,8 +603,7 @@ static bool printCachedPixel(FFLogoRequestData* requestData) instance.state.logoHeight = requestData->logoCharacterHeight + instance.config.logo.paddingTop; //Go to upper left corner - fputs("\033[9999999D", stdout); - printf("\033[%uA", instance.state.logoHeight); + printf("\033[9999999D\033[%uA", instance.state.logoHeight); return true; } @@ -674,8 +668,8 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError) return false; } - requestData.logoPixelWidth = simpleCeil((double) instance.config.logo.width * requestData.characterPixelWidth); - requestData.logoPixelHeight = simpleCeil((double) instance.config.logo.height * requestData.characterPixelHeight); + requestData.logoPixelWidth = (uint32_t) ceil((double) instance.config.logo.width * requestData.characterPixelWidth); + requestData.logoPixelHeight = (uint32_t) ceil((double) instance.config.logo.height * requestData.characterPixelHeight); ffStrbufInit(&requestData.cacheDir); ffStrbufAppend(&requestData.cacheDir, &instance.state.platform.cacheDir); @@ -692,11 +686,7 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError) } ffStrbufRecalculateLength(&requestData.cacheDir); ffStrbufEnsureEndsWithC(&requestData.cacheDir, '/'); - - ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelWidth); - ffStrbufAppendC(&requestData.cacheDir, '*'); - ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelHeight); - ffStrbufAppendC(&requestData.cacheDir, '/'); + ffStrbufAppendF(&requestData.cacheDir, "%u*%u/", requestData.logoPixelWidth, requestData.logoPixelHeight); if(!instance.config.logo.recache && printCached(&requestData)) {