2024-11-20 22:12:36 +00:00
|
|
|
#include "printf.h"
|
|
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
#include <fx/term/tty.h>
|
2024-11-20 22:12:36 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
struct out_tty_args {
|
2026-03-16 10:35:43 +00:00
|
|
|
struct fx_tty *tty;
|
|
|
|
|
enum fx_tty_print_flags flags;
|
2024-11-20 22:12:36 +00:00
|
|
|
bool format_ch;
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-25 17:31:40 +01:00
|
|
|
static void out_tty(char c, void *argp)
|
2024-11-20 22:12:36 +00:00
|
|
|
{
|
|
|
|
|
if (c == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-25 17:31:40 +01:00
|
|
|
struct out_tty_args *args = argp;
|
2026-03-16 10:35:43 +00:00
|
|
|
enum fx_tty_print_flags flags = args->flags;
|
2024-11-20 22:12:36 +00:00
|
|
|
|
2026-05-25 17:31:40 +01:00
|
|
|
if (!args->format_ch
|
|
|
|
|
&& (flags & FX_TTY_DISABLE_INTERPOLATED_FORMATTING)) {
|
2026-03-16 10:35:43 +00:00
|
|
|
flags |= FX_TTY_DISABLE_FORMATTING;
|
2024-11-20 22:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
fx_tty_putc(args->tty, flags, c);
|
2024-11-20 22:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-05-25 17:31:40 +01:00
|
|
|
extern int z__fx_fctprintf(
|
|
|
|
|
void (*out)(char c, void *extra_arg),
|
|
|
|
|
void *extra_arg,
|
|
|
|
|
const char *format,
|
|
|
|
|
va_list arg);
|
|
|
|
|
|
2026-03-16 10:35:43 +00:00
|
|
|
int fx_tty_vprintf(
|
2026-05-25 17:31:40 +01:00
|
|
|
struct fx_tty *tty,
|
|
|
|
|
enum fx_tty_print_flags flags,
|
|
|
|
|
const char *format,
|
2024-11-22 22:29:40 +00:00
|
|
|
va_list args)
|
2024-11-20 22:12:36 +00:00
|
|
|
{
|
|
|
|
|
struct out_tty_args tty_args = {
|
|
|
|
|
.flags = flags,
|
|
|
|
|
.tty = tty,
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-25 17:31:40 +01:00
|
|
|
const int ret = z__fx_fctprintf(out_tty, &tty_args, format, args);
|
2024-11-20 22:12:36 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|