Skip to content

Commit 7a9d915

Browse files
exporting two flags for enabling and disabling via CLI
1 parent b20ad74 commit 7a9d915

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

code/logic/fossil/io/output.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
extern "C" {
2222
#endif
2323

24+
extern int32_t FOSSIL_IO_COLOR_ENABLE; // Flag to enable/disable color output
25+
extern int32_t FOSSIL_IO_ATTR_ENABLE; // Flag to enable/disable attribute output
26+
2427
/**
2528
* This code provides a robust set of functions for formatting and manipulating terminal output,
2629
* allowing developers to apply color, text attributes (like bold, underline, etc.), and cursor positioning
@@ -70,6 +73,16 @@ extern "C" {
7073
* needs of more complex applications.
7174
*/
7275

76+
/**
77+
* Redirects the output to a specified stream.
78+
*
79+
* This function allows you to change the default output destination to a custom stream.
80+
* It is useful when you want to redirect output to a file or another output stream.
81+
*
82+
* @param stream The output stream where subsequent output should be redirected.
83+
*/
84+
void fossil_io_redirect_output(fossil_fstream_t *stream);
85+
7386
/**
7487
* Prints a string to the output.
7588
*

code/logic/output.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include <string.h>
1919
#include <stdio.h>
2020

21+
int32_t FOSSIL_IO_COLOR_ENABLE = 1; // Flag to enable/disable color output
22+
int32_t FOSSIL_IO_ATTR_ENABLE = 1; // Flag to enable/disable attribute output
23+
2124
// Define color codes for output
2225
#define FOSSIL_IO_COLOR_RESET "\033[0m"
2326
#define FOSSIL_IO_COLOR_RED "\033[31m"
@@ -171,11 +174,11 @@ void fossil_io_print_with_attributes(const char *format, ...) {
171174
pos = color + 4; // Skip the "pos:" prefix
172175
fossil_io_apply_position(pos);
173176
} else {
174-
// Apply color and/or attribute
175-
if (color) {
177+
// Apply color and/or attribute based on flags
178+
if (FOSSIL_IO_COLOR_ENABLE && color) {
176179
fossil_io_apply_color(color);
177180
}
178-
if (attribute) {
181+
if (FOSSIL_IO_ATTR_ENABLE && attribute) {
179182
fossil_io_apply_attribute(attribute);
180183
}
181184
}

0 commit comments

Comments
 (0)