1 /****************************************************************************
2 * Copyright 2018-2024,2025 Thomas E. Dickey *
3 * Copyright 2009-2012,2014 Free Software Foundation, Inc. *
4 * *
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: *
12 * *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
15 * *
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. *
23 * *
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 *
27 * authorization. *
28 ****************************************************************************/
29
30 /****************************************************************************
31 * Author: Juergen Pfeifer *
32 * *
33 ****************************************************************************/
34
35 #include <curses.priv.h>
36
37 MODULE_ID("$Id: lib_driver.c,v 1.12 2025/10/18 19:20:33 tom Exp $")
38
NCURSES_EXPORT(int)39 NCURSES_EXPORT(int)
40 NCURSES_SP_NAME(has_key) (SCREEN *sp, int keycode)
41 {
42 T((T_CALLED("has_key(%p, %d)"), (void *) sp, keycode));
43 returnCode(IsValidTIScreen(sp) ? CallDriver_1(sp, td_kyExist, keycode) : FALSE);
44 }
45
46 NCURSES_EXPORT(int)
has_key(int keycode)47 has_key(int keycode)
48 {
49 return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode);
50 }
51
52 NCURSES_EXPORT(int)
NCURSES_SP_NAME(_nc_mcprint)53 NCURSES_SP_NAME(_nc_mcprint) (SCREEN *sp, char *data, int len)
54 {
55 int code = ERR;
56
57 if (NULL != TerminalOf(sp))
58 code = CallDriver_2(sp, td_print, data, len);
59 return (code);
60 }
61
62 NCURSES_EXPORT(int)
mcprint(char * data,int len)63 mcprint(char *data, int len)
64 {
65 return NCURSES_SP_NAME(_nc_mcprint) (CURRENT_SCREEN, data, len);
66 }
67
68 NCURSES_EXPORT(int)
NCURSES_SP_NAME(doupdate)69 NCURSES_SP_NAME(doupdate) (SCREEN *sp)
70 {
71 int code = ERR;
72
73 T((T_CALLED("doupdate(%p)"), (void *) sp));
74
75 if (IsValidScreen(sp))
76 code = CallDriver(sp, td_update);
77
78 returnCode(code);
79 }
80
81 NCURSES_EXPORT(int)
doupdate(void)82 doupdate(void)
83 {
84 return NCURSES_SP_NAME(doupdate) (CURRENT_SCREEN);
85 }
86
87 NCURSES_EXPORT(int)
NCURSES_SP_NAME(mvcur)88 NCURSES_SP_NAME(mvcur) (SCREEN *sp, int yold, int xold, int ynew, int xnew)
89 {
90 int code = ERR;
91 TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%p,%d,%d,%d,%d)"),
92 (void *) sp, yold, xold, ynew, xnew));
93 if (HasTerminal(sp)) {
94 code = CallDriver_4(sp, td_hwcur, yold, xold, ynew, xnew);
95 }
96 returnCode(code);
97 }
98
99 NCURSES_EXPORT(int)
mvcur(int yold,int xold,int ynew,int xnew)100 mvcur(int yold, int xold, int ynew, int xnew)
101 /* optimized cursor move from (yold, xold) to (ynew, xnew) */
102 {
103 return NCURSES_SP_NAME(mvcur) (CURRENT_SCREEN, yold, xold, ynew, xnew);
104 }
105