1 /****************************************************************************
2 * Copyright 2018,2020 Thomas E. Dickey *
3 * Copyright 2009-2012,2014 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Juergen Pfeifer *
33 ****************************************************************************/
35 #include <curses.priv.h>
37 MODULE_ID("$Id: lib_driver.c,v 1.9 2020/08/29 19:53:35 tom Exp $")
39 #ifndef EXP_WIN32_DRIVER
40 typedef struct DriverEntry {
45 static DRIVER_ENTRY DriverTable[] =
48 {"win32console", &_nc_WIN_DRIVER},
50 {"tinfo", &_nc_TINFO_DRIVER} /* must be last */
54 _nc_get_driver(TERMINAL_CONTROL_BLOCK * TCB, const char *name, int *errret)
58 TERM_DRIVER *res = (TERM_DRIVER *) 0;
61 T((T_CALLED("_nc_get_driver(%p, %s, %p)"),
62 (void *) TCB, NonNull(name), (void *) errret));
66 for (i = 0; i < SIZEOF(DriverTable); i++) {
67 res = DriverTable[i].driver;
68 if (strcmp(DriverTable[i].name, res->td_name(TCB)) == 0) {
69 if (res->td_CanHandle(TCB, name, errret)) {
81 #endif /* !EXP_WIN32_DRIVER */
84 NCURSES_SP_NAME(has_key) (SCREEN *sp, int keycode)
86 T((T_CALLED("has_key(%p, %d)"), (void *) sp, keycode));
87 returnCode(IsValidTIScreen(sp) ? CallDriver_1(sp, td_kyExist, keycode) : FALSE);
93 return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode);
97 NCURSES_SP_NAME(_nc_mcprint) (SCREEN *sp, char *data, int len)
101 if (0 != TerminalOf(sp))
102 code = CallDriver_2(sp, td_print, data, len);
107 mcprint(char *data, int len)
109 return NCURSES_SP_NAME(_nc_mcprint) (CURRENT_SCREEN, data, len);
113 NCURSES_SP_NAME(doupdate) (SCREEN *sp)
117 T((T_CALLED("doupdate(%p)"), (void *) sp));
119 if (IsValidScreen(sp))
120 code = CallDriver(sp, td_update);
128 return NCURSES_SP_NAME(doupdate) (CURRENT_SCREEN);
132 NCURSES_SP_NAME(mvcur) (SCREEN *sp, int yold, int xold, int ynew, int xnew)
135 TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%p,%d,%d,%d,%d)"),
136 (void *) sp, yold, xold, ynew, xnew));
137 if (HasTerminal(sp)) {
138 code = CallDriver_4(sp, td_hwcur, yold, xold, ynew, xnew);
144 mvcur(int yold, int xold, int ynew, int xnew)
145 /* optimized cursor move from (yold, xold) to (ynew, xnew) */
147 return NCURSES_SP_NAME(mvcur) (CURRENT_SCREEN, yold, xold, ynew, xnew);