Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/tty/tty-ncurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,15 @@ tty_print_string (const char *s)

/* --------------------------------------------------------------------------------------------- */

void
tty_putp (const char *s)
{
putp (s);
fflush (stdout);
}

/* --------------------------------------------------------------------------------------------- */

void
tty_printf (const char *fmt, ...)
{
Expand Down
27 changes: 27 additions & 0 deletions lib/tty/tty-slang.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,16 @@ tty_print_string (const char *s)

/* --------------------------------------------------------------------------------------------- */

void
tty_putp (const char *s)
{
// S-Lang has SLtt_tputs(), but it only passes the chars through one-by-one without any
// processing
SLtt_write_string ((char *) s);
}

/* --------------------------------------------------------------------------------------------- */

void
tty_printf (const char *fmt, ...)
{
Expand Down Expand Up @@ -723,6 +733,23 @@ tty_tigetstr (const char *terminfo_cap, const char *termcap_cap)

/* --------------------------------------------------------------------------------------------- */

// Warning: S-Lang doesn't support more than two parameters
char *
tty_tiparm (const char *str, ...)
{
va_list args;
int p1, p2;

va_start (args, str);
p1 = va_arg (args, int);
p2 = va_arg (args, int);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pulling a fixed number of arguments in a formally varargs function sounds like a recipe for disaster.

a cleaner solution would be overloaded macros: https://stackoverflow.com/a/11763277/3685191

va_end (args);

return SLtt_tgoto ((SLFUTURE_CONST char *) str, p2, p1);
}

/* --------------------------------------------------------------------------------------------- */

void
tty_refresh (void)
{
Expand Down
10 changes: 8 additions & 2 deletions lib/tty/tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,16 @@ typedef enum
// the values are either one of MCS_ACS_* or a character in the current locale.
extern mc_tty_char_t mc_tty_frm[];

/*** declarations of public functions ************************************************************/

extern int tty_tigetflag (const char *terminfo_cap, const char *termcap_cap);
extern int tty_tigetnum (const char *terminfo_cap, const char *termcap_cap);
extern char *tty_tigetstr (const char *terminfo_cap, const char *termcap_cap);

/*** declarations of public functions ************************************************************/
#ifdef HAVE_SLANG
extern char *tty_tiparm (const char *str, ...);
#else
#define tty_tiparm(str, ...) tiparm ((NCURSES_CONST char *) (str), __VA_ARGS__)
#endif

extern void tty_beep (void);

Expand Down Expand Up @@ -146,6 +151,7 @@ extern void tty_print_char (mc_tty_char_t c);
extern void tty_print_anychar (mc_tty_char_t c);
extern void tty_print_string (const char *s);
extern void tty_printf (const char *s, ...) G_GNUC_PRINTF (1, 2);
extern void tty_putp (const char *s);

extern void tty_print_one_vline (gboolean single);
extern void tty_print_one_hline (gboolean single);
Expand Down