mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Fastfetch: add --no-buffer option
This commit is contained in:
@@ -39,7 +39,7 @@ jobs:
|
||||
run: ctest
|
||||
|
||||
- name: run fastfetch
|
||||
run: ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: ./flashfetch
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
run: ./fastfetch --list-features
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: time ./flashfetch
|
||||
@@ -126,7 +126,7 @@ jobs:
|
||||
run: ./fastfetch --list-features
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: time ./flashfetch
|
||||
@@ -159,7 +159,7 @@ jobs:
|
||||
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
|
||||
cmake --build . --target package
|
||||
./fastfetch --list-features
|
||||
time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
|
||||
time ./flashfetch
|
||||
ctest
|
||||
|
||||
@@ -213,7 +213,7 @@ jobs:
|
||||
run: ./fastfetch --list-features
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: time ./flashfetch
|
||||
@@ -271,7 +271,7 @@ jobs:
|
||||
run: cp /clang32/bin/{OpenCL,vulkan-1}.dll .
|
||||
|
||||
- name: run fastfetch
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
|
||||
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
|
||||
|
||||
- name: run flashfetch
|
||||
run: time ./flashfetch
|
||||
|
||||
@@ -10,6 +10,7 @@ Features:
|
||||
* Support KDE / LXQT / MATE / Cinnamon wallpaper detection (Wallpaper, Linux)
|
||||
* Support QTerminal version & terminal font detection
|
||||
* Support MATE Terminal version & terminal font detection
|
||||
* Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled.
|
||||
|
||||
# 1.11.3
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
|
||||
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
|
||||
cmake_dependent_option(ENABLE_BUFFER "Enable stdout buffer" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
|
||||
|
||||
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
|
||||
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
|
||||
@@ -715,10 +714,6 @@ if(ENABLE_THREADS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_BUFFER)
|
||||
target_compile_definitions(libfastfetch PRIVATE FF_ENABLE_BUFFER)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "-framework Cocoa"
|
||||
@@ -791,11 +786,6 @@ target_link_libraries(flashfetch
|
||||
PRIVATE yyjson
|
||||
)
|
||||
|
||||
if(ENABLE_BUFFER) # FF_ENABLE_BUFFER is used in fastfetch.c
|
||||
target_compile_definitions(fastfetch PRIVATE FF_ENABLE_BUFFER)
|
||||
target_compile_definitions(flashfetch PRIVATE FF_ENABLE_BUFFER)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(TARGET_NAME fastfetch)
|
||||
target_sources(fastfetch
|
||||
|
||||
+4
-7
@@ -51,6 +51,7 @@ static void defaultConfig(FFinstance* instance)
|
||||
instance->config.pipe = false;
|
||||
instance->config.multithreading = true;
|
||||
instance->config.stat = false;
|
||||
instance->config.noBuffer = false;
|
||||
|
||||
ffInitTitleOptions(&instance->config.title);
|
||||
ffInitOSOptions(&instance->config.os);
|
||||
@@ -175,7 +176,7 @@ static void resetConsole()
|
||||
if(ffHideCursor)
|
||||
fputs("\033[?25h", stdout);
|
||||
|
||||
#if defined(_WIN32) && defined(FF_ENABLE_BUFFER)
|
||||
#if defined(_WIN32)
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
@@ -207,9 +208,7 @@ void ffStart(FFinstance* instance)
|
||||
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef FF_ENABLE_BUFFER
|
||||
setvbuf(stdout, NULL, _IOFBF, 4096);
|
||||
#endif
|
||||
if (!instance->config.noBuffer) setvbuf(stdout, NULL, _IOFBF, 4096);
|
||||
SetConsoleCtrlHandler(consoleHandler, TRUE);
|
||||
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DWORD mode = 0;
|
||||
@@ -217,9 +216,7 @@ void ffStart(FFinstance* instance)
|
||||
SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
#else
|
||||
#ifndef FF_ENABLE_BUFFER
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
#endif
|
||||
if (instance->config.noBuffer) setvbuf(stdout, NULL, _IONBF, 0);
|
||||
struct sigaction action = { .sa_handler = exitSignalHandler };
|
||||
sigaction(SIGINT, &action, NULL);
|
||||
sigaction(SIGTERM, &action, NULL);
|
||||
|
||||
@@ -266,8 +266,8 @@ static const char* printJsonConfig(FFinstance* instance)
|
||||
printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(FF_ENABLE_BUFFER)
|
||||
fflush(stdout);
|
||||
#if defined(_WIN32)
|
||||
if (!instance->config.noBuffer) fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -380,6 +380,8 @@ const char* ffParseDisplayJsonConfig(FFinstance* instance)
|
||||
}
|
||||
else if (strcasecmp(key, "percentType") == 0)
|
||||
config->percentType = (uint32_t) yyjson_get_uint(val);
|
||||
else if (strcasecmp(key, "noBuffer") == 0)
|
||||
config->noBuffer = yyjson_get_bool(val);
|
||||
else
|
||||
return "Unknown display property";
|
||||
}
|
||||
|
||||
@@ -146,6 +146,12 @@
|
||||
# Default is IEC.
|
||||
#--binary-prefix IEC
|
||||
|
||||
# Disable output buffer option:
|
||||
# Sets if the stdout application buffer should be disabled.
|
||||
# Must be true or false.
|
||||
# Default is false.
|
||||
#--no-buffer false
|
||||
|
||||
# Title FQDN option:
|
||||
# Sets if the title should use the fully qualified domain name.
|
||||
# Must be true or false.
|
||||
|
||||
+2
-1
@@ -62,7 +62,8 @@ Display options:
|
||||
--show-errors <?value>: Print occurring errors
|
||||
--disable-linewrap <?value>: Whether to disable line wrap during the run
|
||||
--hide-cursor <?value>: Whether to hide the cursor during the run
|
||||
--binary-prefix <value>: Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC.
|
||||
--binary-prefix <value>: Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC
|
||||
--no-buffer <?value>: Set if the stdout application buffer should be disabled. Default is false
|
||||
|
||||
General module options:
|
||||
--<module>-format <format>: Set the format string to use for each specific module.
|
||||
|
||||
+6
-4
@@ -884,6 +884,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
}
|
||||
else if(strcasecmp(key, "--percent-type") == 0)
|
||||
instance->config.percentType = ffOptionParseUInt32(key, value);
|
||||
else if(strcasecmp(key, "--no-buffer") == 0)
|
||||
instance->config.noBuffer = ffOptionParseBoolean(value);
|
||||
|
||||
///////////////////////
|
||||
//Module args options//
|
||||
@@ -1201,8 +1203,8 @@ int main(int argc, const char** argv)
|
||||
|
||||
ffStart(&instance);
|
||||
|
||||
#if defined(_WIN32) && defined(FF_ENABLE_BUFFER)
|
||||
fflush(stdout);
|
||||
#if defined(_WIN32)
|
||||
if (!instance.config.noBuffer) fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (instance.state.configDoc)
|
||||
@@ -1234,8 +1236,8 @@ int main(int argc, const char** argv)
|
||||
printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(FF_ENABLE_BUFFER)
|
||||
fflush(stdout);
|
||||
#if defined(_WIN32)
|
||||
if (!instance.config.noBuffer) fflush(stdout);
|
||||
#endif
|
||||
|
||||
startIndex = colonIndex + 1;
|
||||
|
||||
@@ -47,6 +47,7 @@ typedef struct FFconfig
|
||||
bool pipe; //disables logo and all escape sequences
|
||||
bool multithreading;
|
||||
bool stat;
|
||||
bool noBuffer;
|
||||
|
||||
// Module options that cannot be put in module option structure
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
|
||||
Reference in New Issue
Block a user