Files
fx/fx.term/printf.c
T

50 lines
886 B
C
Raw Normal View History

#include "printf.h"
2026-03-16 10:35:43 +00:00
#include <fx/term/tty.h>
#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;
bool format_ch;
};
static void out_tty(char c, void *argp)
{
if (c == 0) {
return;
}
struct out_tty_args *args = argp;
2026-03-16 10:35:43 +00:00
enum fx_tty_print_flags flags = args->flags;
if (!args->format_ch
&& (flags & FX_TTY_DISABLE_INTERPOLATED_FORMATTING)) {
2026-03-16 10:35:43 +00:00
flags |= FX_TTY_DISABLE_FORMATTING;
}
2026-03-16 10:35:43 +00:00
fx_tty_putc(args->tty, flags, c);
}
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(
struct fx_tty *tty,
enum fx_tty_print_flags flags,
const char *format,
va_list args)
{
struct out_tty_args tty_args = {
.flags = flags,
.tty = tty,
};
const int ret = z__fx_fctprintf(out_tty, &tty_args, format, args);
return ret;
}