textio: create callback typedef cb_textio_input_t

This commit is contained in:
Darryl L. Miles 2025-01-31 17:29:41 +00:00 committed by Tim Edwards
parent c8ca1d242e
commit 6ed8f17136
6 changed files with 34 additions and 23 deletions

View File

@ -175,10 +175,11 @@ NullTextSize(text, size, r)
* ----------------------------------------------------------------------------
*/
/** @typedef cb_textio_input_t */
void
nullStdin(fd, cdata)
int fd;
ClientData cdata;
nullStdin(
int fd,
ClientData cdata) /* notused */
{
int ch;
TxInputEvent *event;

View File

@ -64,7 +64,7 @@ extern void GrOGLClose(), GrOGLFlush();
extern void GrOGLDelete(), GrOGLConfigure(), GrOGLRaise(), GrOGLLower();
extern void GrOGLLock(), GrOGLUnlock(), GrOGLIconUpdate();
extern bool GrOGLInit(), GrOGLCreate();
extern void grOGLWStdin();
extern void grOGLWStdin(int fd, ClientData cdata); /* cb_textio_input_t (unused) */
/*---------------------------------------------------------
@ -418,8 +418,11 @@ oglSetProjection(llx, lly, width, height)
/* is a macro and can be re-implemented using XNextEvent() calls. */
/*----------------------------------------------------------------------*/
/** @typedef cb_textio_input_t */
void
pipehandler()
pipehandler(
int fd,
ClientData cdata) /* notused */
{
TxInputEvent *event;
XEvent xevent;
@ -757,12 +760,12 @@ oglSetDisplay (dispType, outFileName, mouseFileName)
*
* ----------------------------------------------------------------------------
*/
/*ARGSUSED*/
/*ARGSUSED*/
/** @typedef cb_textio_input_t */
void
grOGLWStdin(fd, cdata)
int fd;
ClientData cdata;
grOGLWStdin(
int fd,
ClientData cdata) /* notused */
{
int ch;
TxInputEvent *event;

View File

@ -118,7 +118,7 @@ extern void GrX11Close(), GrX11Flush();
extern bool GrX11Init(), GrX11Create();
extern void GrX11Delete(), GrX11Configure(), GrX11Raise(), GrX11Lower();
extern void GrX11Lock(), GrX11Unlock(), GrX11IconUpdate();
extern void grXWStdin();
extern void grXWStdin(int fd, ClientData cdata); /* cb_textio_input_t (unused) */
extern bool grx11GetCursorPos();
@ -739,7 +739,7 @@ GrX11Flush ()
/*
* ---------------------------------------------------------------------------
*
* grXStdin --
* grX11Stdin --
*
* Handle the stdin device for the X driver.
*
@ -752,8 +752,12 @@ GrX11Flush ()
* ---------------------------------------------------------------------------
*/
/*ARGSUSED*/
/** @typedef cb_textio_input_t */
void
grX11Stdin()
grX11Stdin(
int fd,
ClientData cdata) /* notused */
{
TxInputEvent *event;
XEvent xevent;
@ -1104,10 +1108,11 @@ x11SetDisplay (dispType, outFileName, mouseFileName)
* ----------------------------------------------------------------------------
*/
/** @typedef cb_textio_input_t */
void
grXWStdin(fd, cdata)
int fd;
ClientData cdata;
grXWStdin(
int fd,
ClientData cdata) /* notused */
{
int ch;
TxInputEvent *event;

View File

@ -32,7 +32,8 @@ typedef struct {
fd_set tx_fdmask; /* A mask of the file descriptors for this
* device.
*/
void (*tx_inputProc)(); /* A procedure that fetches events and stores
cb_textio_input_t tx_inputProc;
/* A procedure that fetches events and stores
* them in the input queue via TxAddEvent().
*/
ClientData tx_cdata; /* Data to be passed back to caller. */

View File

@ -457,7 +457,8 @@ TxAddInputDevice(
const fd_set *fdmask, /* A mask of file descriptors that this
* device will handle.
*/
void (*inputProc)(), /* A routine to call. This routine will
const cb_textio_input_t inputProc,
/* A routine to call. This routine will
* be passed a single file descriptor that
* is ready, and should read that file and
* add events(s) by calling TxNewEvent()
@ -484,7 +485,7 @@ TxAddInputDevice(
void
TxAdd1InputDevice(
int fd,
void (*inputProc)(),
const cb_textio_input_t inputProc,
ClientData cdata)
{
fd_set fs;
@ -975,7 +976,7 @@ TxGetInputEvent(
FD_ISSET(fd, &(txInputDevice[i].tx_fdmask))) {
lastNum = txNumInputEvents;
(*(txInputDevice[i].tx_inputProc))
(fd, txInputDevice[i].tx_cdata);
(fd, txInputDevice[i].tx_cdata); /** @invoke cb_textio_input_t */
FD_CLR(fd, &inputs);
/* Did this driver choose to add an event? */
if (txNumInputEvents != lastNum) gotSome = TRUE;

View File

@ -116,9 +116,9 @@ extern TxCommand TxCurCommand;
#define TX_KEY_DOWN 2
/* procedures to help in making device command routines */
extern void TxAddInputDevice(const fd_set *fdmask, void (*inputProc)(), ClientData cdata); /* Can read multiple file desc. */
extern void TxAdd1InputDevice(int fd, void (*inputProc)(), ClientData cdata); /* Can read only 1 file desc. */
typedef void (*cb_textio_input_t)(int fd, ClientData cdata);
extern void TxAddInputDevice(const fd_set *fdmask, const cb_textio_input_t inputProc, ClientData cdata); /* Can read multiple file desc. */
extern void TxAdd1InputDevice(int fd, const cb_textio_input_t inputProc, ClientData cdata); /* Can read only 1 file desc. */
extern void TxDeleteInputDevice(const fd_set *fdmask);
extern void TxDelete1InputDevice(int fd);