diff options
author | David Robillard <d@drobilla.net> | 2022-05-27 15:32:24 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-05-27 15:32:24 -0400 |
commit | ba54d31cbdfd42ee41eb168b2d7ed8cee463079e (patch) | |
tree | bcd634744fe4765d6a1b11bc24946ad77c73192a | |
parent | aec7eff6112649205b85dc6ca364b52f14d29bb3 (diff) | |
download | jalv-ba54d31cbdfd42ee41eb168b2d7ed8cee463079e.tar.gz jalv-ba54d31cbdfd42ee41eb168b2d7ed8cee463079e.tar.bz2 jalv-ba54d31cbdfd42ee41eb168b2d7ed8cee463079e.zip |
Move platform-specific terminal code out of headers
-rw-r--r-- | src/control.c | 2 | ||||
-rw-r--r-- | src/jalv_internal.h | 30 | ||||
-rw-r--r-- | src/log.c | 29 |
3 files changed, 35 insertions, 26 deletions
diff --git a/src/control.c b/src/control.c index 5c60c16..9c48713 100644 --- a/src/control.c +++ b/src/control.c @@ -14,6 +14,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define _POSIX_C_SOURCE 200809L + #include "jalv_internal.h" #include "lilv/lilv.h" diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 33e214f..36b63ed 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -17,8 +17,6 @@ #ifndef JALV_INTERNAL_H #define JALV_INTERNAL_H -#define _POSIX_C_SOURCE 200809L - #include "jalv_config.h" #include "lv2_evbuf.h" #include "symap.h" @@ -45,10 +43,6 @@ #include "lv2/urid/urid.h" #include "lv2/worker/worker.h" -#ifdef HAVE_ISATTY -# include <unistd.h> -#endif - #include <stdarg.h> #include <stdbool.h> #include <stdint.h> @@ -531,27 +525,11 @@ JALV_LOG_FUNC(3, 0) int jalv_vprintf(LV2_Log_Handle handle, LV2_URID type, const char* fmt, va_list ap); -static inline bool -jalv_ansi_start(FILE* stream, int color) -{ -#if defined(HAVE_ISATTY) && defined(HAVE_FILENO) - if (isatty(fileno(stream))) { - return fprintf(stream, "\033[0;%dm", color); - } -#endif - return 0; -} +bool +jalv_ansi_start(FILE* stream, int color); -static inline void -jalv_ansi_reset(FILE* stream) -{ -#ifdef HAVE_ISATTY - if (isatty(fileno(stream))) { - fprintf(stream, "\033[0m"); - fflush(stream); - } -#endif -} +void +jalv_ansi_reset(FILE* stream); #ifdef __cplusplus } // extern "C" @@ -14,11 +14,18 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define _POSIX_C_SOURCE 200809L + +#include "jalv_config.h" #include "jalv_internal.h" #include "lv2/log/log.h" #include "lv2/urid/urid.h" +#ifdef HAVE_ISATTY +# include <unistd.h> +#endif + #include <stdarg.h> #include <stdbool.h> #include <stdio.h> @@ -60,3 +67,25 @@ jalv_vprintf(LV2_Log_Handle handle, LV2_URID type, const char* fmt, va_list ap) return st; } + +bool +jalv_ansi_start(FILE* stream, int color) +{ +#if defined(HAVE_ISATTY) && defined(HAVE_FILENO) + if (isatty(fileno(stream))) { + return fprintf(stream, "\033[0;%dm", color); + } +#endif + return 0; +} + +void +jalv_ansi_reset(FILE* stream) +{ +#ifdef HAVE_ISATTY + if (isatty(fileno(stream))) { + fprintf(stream, "\033[0m"); + fflush(stream); + } +#endif +} |