mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-01 10:32:35 +01:00
Fastfetch: add --no-buffer option
This commit is contained in:
+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