2017-04-25 14:41:48 +02:00
|
|
|
/*
|
|
|
|
|
* textio.h --
|
|
|
|
|
*
|
|
|
|
|
* Routines in the textio module
|
|
|
|
|
*
|
2020-05-23 23:13:14 +02:00
|
|
|
* *********************************************************************
|
|
|
|
|
* * Copyright (C) 1985, 1990 Regents of the University of California. *
|
|
|
|
|
* * Permission to use, copy, modify, and distribute this *
|
|
|
|
|
* * software and its documentation for any purpose and without *
|
|
|
|
|
* * fee is hereby granted, provided that the above copyright *
|
|
|
|
|
* * notice appear in all copies. The University of California *
|
|
|
|
|
* * makes no representations about the suitability of this *
|
|
|
|
|
* * software for any purpose. It is provided "as is" without *
|
|
|
|
|
* * express or implied warranty. Export of this software outside *
|
|
|
|
|
* * of the United States of America may require an export license. *
|
2017-04-25 14:41:48 +02:00
|
|
|
* *********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Needs:
|
|
|
|
|
* stdio.h
|
|
|
|
|
* magic.h
|
|
|
|
|
*
|
|
|
|
|
* rcsid $Header: /usr/cvsroot/magic-8.0/textio/textio.h,v 1.2 2008/02/18 01:01:35 tim Exp $
|
|
|
|
|
*/
|
|
|
|
|
|
2024-10-16 08:38:41 +02:00
|
|
|
#ifndef _MAGIC__TEXTIO__TEXTIO_H
|
|
|
|
|
#define _MAGIC__TEXTIO__TEXTIO_H
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
#include "utils/magic.h"
|
2025-01-31 18:11:07 +01:00
|
|
|
#include "utils/dqueue.h" /* DQueue */
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
#ifdef MAGIC_WRAPPER
|
|
|
|
|
extern char *TxBuffer;
|
|
|
|
|
extern unsigned char TxInputRedirect;
|
|
|
|
|
|
|
|
|
|
#define TX_INPUT_NORMAL 0 /* keys translated as macros */
|
|
|
|
|
#define TX_INPUT_REDIRECTED 1 /* keys redirected to terminal */
|
|
|
|
|
#define TX_INPUT_PROCESSING 2 /* executing a command via redirection */
|
|
|
|
|
#define TX_INPUT_PENDING_RESET 3 /* about to switch back to state 0 */
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-06-29 03:31:24 +02:00
|
|
|
#define TX_LOG_UPDATE 1 /* Update display after every log command */
|
|
|
|
|
#define TX_LOG_SUSPEND 2 /* Suspend output logging */
|
|
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
extern int TxCurButtons;
|
|
|
|
|
|
|
|
|
|
/* These should really be defined by the application, not hard-coded */
|
|
|
|
|
#define TX_LONG_CMD ':' /* Way of invoking a long command. */
|
|
|
|
|
#define TX_LONG_CMD2 ';' /* Alternate way of invoking a long command. */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Procedure to print text on stdout and stderr.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef MAGIC_WRAPPER
|
|
|
|
|
#define Vfprintf Tcl_printf
|
|
|
|
|
#else
|
|
|
|
|
#define Vfprintf vfprintf
|
|
|
|
|
#endif /* MAGIC_WRAPPER */
|
|
|
|
|
|
|
|
|
|
/* printing procedures */
|
2025-01-31 18:11:07 +01:00
|
|
|
extern bool TxPrintOn(void); /* enables TxPrintf output */
|
|
|
|
|
extern bool TxPrintOff(void); /* disables TxPrintf output */
|
|
|
|
|
extern void TxFlush(void);
|
|
|
|
|
extern void TxFlushOut(void);
|
|
|
|
|
extern void TxFlushErr(void);
|
|
|
|
|
extern void TxUseMore(void);
|
|
|
|
|
extern void TxStopMore(void);
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
/* printing procedures with variable arguments lists */
|
2024-10-03 23:47:50 +02:00
|
|
|
extern void TxError(const char *, ...) ATTR_FORMAT_PRINTF_1;
|
|
|
|
|
extern void TxErrorV(const char *, va_list args);
|
|
|
|
|
extern void TxPrintf(const char *, ...) ATTR_FORMAT_PRINTF_1;
|
|
|
|
|
extern char *TxPrintString(const char *, ...) ATTR_FORMAT_PRINTF_1;
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
/* input procedures */
|
2025-01-31 18:15:29 +01:00
|
|
|
extern char *TxGetLinePrompt(char *dest, int maxChars, const char *prompt);
|
2025-01-31 18:11:07 +01:00
|
|
|
extern char *TxGetLine(char *line, int len);
|
|
|
|
|
extern int TxGetChar(void);
|
2025-01-31 18:15:29 +01:00
|
|
|
extern int TxDialog(const char *prompt, const char * const *responses, int defresp);
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
/* prompting procedures */
|
2025-01-31 18:11:07 +01:00
|
|
|
extern void TxSetPrompt(char ch);
|
|
|
|
|
extern void TxPrompt(void);
|
|
|
|
|
extern void TxUnPrompt(void);
|
|
|
|
|
extern void TxRestorePrompt(void);
|
|
|
|
|
extern void TxReprint(void);
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
/* terminal-state procedures */
|
2025-01-31 18:11:07 +01:00
|
|
|
extern void TxSetTerminal(void);
|
2024-10-21 10:23:41 +02:00
|
|
|
extern void TxResetTerminal(bool force);
|
2017-04-25 14:41:48 +02:00
|
|
|
extern char TxEOFChar; /* The current EOF character */
|
|
|
|
|
extern char TxInterruptChar; /* The current interrupt character */
|
|
|
|
|
|
|
|
|
|
/* command procedures */
|
2025-01-31 18:11:07 +01:00
|
|
|
extern void TxDispatch(FILE *f);
|
2017-04-25 14:41:48 +02:00
|
|
|
|
2022-10-10 11:50:15 +02:00
|
|
|
/* C99 compat */
|
2025-01-31 18:15:29 +01:00
|
|
|
extern void TxMore(const char *mesg);
|
2025-01-31 18:11:07 +01:00
|
|
|
extern void txGetFileCommand(FILE *f, DQueue *queue);
|
2022-10-10 11:50:15 +02:00
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
/* variables that tell if stdin and stdout are to a terminal */
|
|
|
|
|
extern bool TxStdinIsatty;
|
|
|
|
|
extern bool TxStdoutIsatty;
|
|
|
|
|
#define TxInteractive (TxStdinIsatty && TxStdoutIsatty)
|
|
|
|
|
|
|
|
|
|
/* Misc procs */
|
2025-01-31 18:11:07 +01:00
|
|
|
extern void TxInit(void);
|
2017-04-25 14:41:48 +02:00
|
|
|
#ifdef USE_READLINE
|
2025-01-31 18:11:07 +01:00
|
|
|
extern void TxInitReadline(void);
|
2017-04-25 14:41:48 +02:00
|
|
|
#endif
|
|
|
|
|
|
2024-10-16 08:38:41 +02:00
|
|
|
#endif /* _MAGIC__TEXTIO__TEXTIO_H */
|