1 /****************************************************************************
2 * Copyright (c) 2008-2012,2014 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Juergen Pfeifer *
32 ****************************************************************************/
34 #include <curses.priv.h>
36 MODULE_ID("$Id: lib_driver.c,v 1.6 2014/04/11 08:21:23 jpf Exp $")
38 typedef struct DriverEntry
{
43 static DRIVER_ENTRY DriverTable
[] =
46 {"win32console", &_nc_WIN_DRIVER
},
48 {"tinfo", &_nc_TINFO_DRIVER
} /* must be last */
52 _nc_get_driver(TERMINAL_CONTROL_BLOCK
* TCB
, const char *name
, int *errret
)
56 TERM_DRIVER
*res
= (TERM_DRIVER
*) 0;
59 T((T_CALLED("_nc_get_driver(%p, %s, %p)"),
60 (void *) TCB
, NonNull(name
), (void *) errret
));
64 for (i
= 0; i
< SIZEOF(DriverTable
); i
++) {
65 res
= DriverTable
[i
].driver
;
66 if (strcmp(DriverTable
[i
].name
, res
->td_name(TCB
)) == 0) {
67 if (res
->td_CanHandle(TCB
, name
, errret
)) {
81 NCURSES_SP_NAME(has_key
) (SCREEN
*sp
, int keycode
)
83 T((T_CALLED("has_key(%p, %d)"), (void *) sp
, keycode
));
84 returnCode(IsValidTIScreen(sp
) ? CallDriver_1(sp
, td_kyExist
, keycode
) : FALSE
);
90 return NCURSES_SP_NAME(has_key
) (CURRENT_SCREEN
, keycode
);
94 NCURSES_SP_NAME(_nc_mcprint
) (SCREEN
*sp
, char *data
, int len
)
98 if (0 != TerminalOf(sp
))
99 code
= CallDriver_2(sp
, td_print
, data
, len
);
104 mcprint(char *data
, int len
)
106 return NCURSES_SP_NAME(_nc_mcprint
) (CURRENT_SCREEN
, data
, len
);
110 NCURSES_SP_NAME(doupdate
) (SCREEN
*sp
)
114 T((T_CALLED("doupdate(%p)"), (void *) sp
));
116 if (IsValidScreen(sp
))
117 code
= CallDriver(sp
, td_update
);
125 return NCURSES_SP_NAME(doupdate
) (CURRENT_SCREEN
);
129 NCURSES_SP_NAME(mvcur
) (SCREEN
*sp
, int yold
, int xold
, int ynew
, int xnew
)
132 TR(TRACE_CALLS
| TRACE_MOVE
, (T_CALLED("mvcur(%p,%d,%d,%d,%d)"),
133 (void *) sp
, yold
, xold
, ynew
, xnew
));
134 if (HasTerminal(sp
)) {
135 code
= CallDriver_4(sp
, td_hwcur
, yold
, xold
, ynew
, xnew
);
141 mvcur(int yold
, int xold
, int ynew
, int xnew
)
142 /* optimized cursor move from (yold, xold) to (ynew, xnew) */
144 return NCURSES_SP_NAME(mvcur
) (CURRENT_SCREEN
, yold
, xold
, ynew
, xnew
);