cursesw.h 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581
  1. // * This makes emacs happy -*-Mode: C++;-*-
  2. // vile:cppmode
  3. /****************************************************************************
  4. * Copyright 2019-2021,2022 Thomas E. Dickey *
  5. * Copyright 1998-2014,2017 Free Software Foundation, Inc. *
  6. * *
  7. * Permission is hereby granted, free of charge, to any person obtaining a *
  8. * copy of this software and associated documentation files (the *
  9. * "Software"), to deal in the Software without restriction, including *
  10. * without limitation the rights to use, copy, modify, merge, publish, *
  11. * distribute, distribute with modifications, sublicense, and/or sell *
  12. * copies of the Software, and to permit persons to whom the Software is *
  13. * furnished to do so, subject to the following conditions: *
  14. * *
  15. * The above copyright notice and this permission notice shall be included *
  16. * in all copies or substantial portions of the Software. *
  17. * *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
  21. * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
  24. * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
  25. * *
  26. * Except as contained in this notice, the name(s) of the above copyright *
  27. * holders shall not be used in advertising or otherwise to promote the *
  28. * sale, use or other dealings in this Software without prior written *
  29. * authorization. *
  30. ****************************************************************************/
  31. #ifndef NCURSES_CURSESW_H_incl
  32. #define NCURSES_CURSESW_H_incl 1
  33. // $Id: cursesw.h,v 1.59 2022/08/20 20:52:15 tom Exp $
  34. extern "C" {
  35. # include <ncursesw/curses.h>
  36. }
  37. #if defined(BUILDING_NCURSES_CXX)
  38. # define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
  39. #else
  40. # define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
  41. #endif
  42. #define NCURSES_CXX_WRAPPED_VAR(type,name) extern NCURSES_CXX_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
  43. #define NCURSES_CXX_EXPORT(type) NCURSES_CXX_IMPEXP type NCURSES_API
  44. #define NCURSES_CXX_EXPORT_VAR(type) NCURSES_CXX_IMPEXP type
  45. #include <ncursesw/etip.h>
  46. /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
  47. Undefine it here, because NCursesWindow uses lines as a method. */
  48. #undef lines
  49. /* "Convert" macros to inlines. We'll define it as another symbol to avoid
  50. * conflict with library symbols.
  51. */
  52. #undef UNDEF
  53. #define UNDEF(name) CUR_ ##name
  54. #ifdef addch
  55. inline int UNDEF(addch)(chtype ch) { return addch(ch); }
  56. #undef addch
  57. #define addch UNDEF(addch)
  58. #endif
  59. #ifdef addchstr
  60. inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); }
  61. #undef addchstr
  62. #define addchstr UNDEF(addchstr)
  63. #endif
  64. #ifdef addnstr
  65. inline int UNDEF(addnstr)(const char *str, int n)
  66. { return addnstr(str, n); }
  67. #undef addnstr
  68. #define addnstr UNDEF(addnstr)
  69. #endif
  70. #ifdef addstr
  71. inline int UNDEF(addstr)(const char * str) { return addstr(str); }
  72. #undef addstr
  73. #define addstr UNDEF(addstr)
  74. #endif
  75. #ifdef attroff
  76. inline int UNDEF(attroff)(chtype at) { return attroff(at); }
  77. #undef attroff
  78. #define attroff UNDEF(attroff)
  79. #endif
  80. #ifdef attron
  81. inline int UNDEF(attron)(chtype at) { return attron(at); }
  82. #undef attron
  83. #define attron UNDEF(attron)
  84. #endif
  85. #ifdef attrset
  86. inline chtype UNDEF(attrset)(chtype at) { return attrset(at); }
  87. #undef attrset
  88. #define attrset UNDEF(attrset)
  89. #endif
  90. #ifdef bkgd
  91. inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }
  92. #undef bkgd
  93. #define bkgd UNDEF(bkgd)
  94. #endif
  95. #ifdef bkgdset
  96. inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
  97. #undef bkgdset
  98. #define bkgdset UNDEF(bkgdset)
  99. #endif
  100. #ifdef border
  101. inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
  102. { return border(ls, rs, ts, bs, tl, tr, bl, br); }
  103. #undef border
  104. #define border UNDEF(border)
  105. #endif
  106. #ifdef box
  107. inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); }
  108. #undef box
  109. #define box UNDEF(box)
  110. #endif
  111. #ifdef chgat
  112. inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
  113. return chgat(n, attr, color, opts); }
  114. #undef chgat
  115. #define chgat UNDEF(chgat)
  116. #endif
  117. #ifdef clear
  118. inline int UNDEF(clear)() { return clear(); }
  119. #undef clear
  120. #define clear UNDEF(clear)
  121. #endif
  122. #ifdef clearok
  123. inline int UNDEF(clearok)(WINDOW* win, bool bf) { return clearok(win, bf); }
  124. #undef clearok
  125. #define clearok UNDEF(clearok)
  126. #else
  127. extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool);
  128. #endif
  129. #ifdef clrtobot
  130. inline int UNDEF(clrtobot)() { return clrtobot(); }
  131. #undef clrtobot
  132. #define clrtobot UNDEF(clrtobot)
  133. #endif
  134. #ifdef clrtoeol
  135. inline int UNDEF(clrtoeol)() { return clrtoeol(); }
  136. #undef clrtoeol
  137. #define clrtoeol UNDEF(clrtoeol)
  138. #endif
  139. #ifdef color_set
  140. inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); }
  141. #undef color_set
  142. #define color_set UNDEF(color_set)
  143. #endif
  144. #ifdef crmode
  145. inline int UNDEF(crmode)(void) { return crmode(); }
  146. #undef crmode
  147. #define crmode UNDEF(crmode)
  148. #endif
  149. #ifdef delch
  150. inline int UNDEF(delch)() { return delch(); }
  151. #undef delch
  152. #define delch UNDEF(delch)
  153. #endif
  154. #ifdef deleteln
  155. inline int UNDEF(deleteln)() { return deleteln(); }
  156. #undef deleteln
  157. #define deleteln UNDEF(deleteln)
  158. #endif
  159. #ifdef echochar
  160. inline int UNDEF(echochar)(chtype ch) { return echochar(ch); }
  161. #undef echochar
  162. #define echochar UNDEF(echochar)
  163. #endif
  164. #ifdef erase
  165. inline int UNDEF(erase)() { return erase(); }
  166. #undef erase
  167. #define erase UNDEF(erase)
  168. #endif
  169. #ifdef fixterm
  170. inline int UNDEF(fixterm)(void) { return fixterm(); }
  171. #undef fixterm
  172. #define fixterm UNDEF(fixterm)
  173. #endif
  174. #ifdef flushok
  175. inline int UNDEF(flushok)(WINDOW* _win, bool _bf) {
  176. return flushok(_win, _bf); }
  177. #undef flushok
  178. #define flushok UNDEF(flushok)
  179. #else
  180. #define _no_flushok
  181. #endif
  182. #ifdef getattrs
  183. inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); }
  184. #undef getattrs
  185. #define getattrs UNDEF(getattrs)
  186. #endif
  187. #ifdef getbegyx
  188. inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); }
  189. #undef getbegyx
  190. #define getbegyx UNDEF(getbegyx)
  191. #endif
  192. #ifdef getbkgd
  193. inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }
  194. #undef getbkgd
  195. #define getbkgd UNDEF(getbkgd)
  196. #endif
  197. #ifdef getch
  198. inline int UNDEF(getch)() { return getch(); }
  199. #undef getch
  200. #define getch UNDEF(getch)
  201. #endif
  202. #ifdef getmaxyx
  203. inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); }
  204. #undef getmaxyx
  205. #define getmaxyx UNDEF(getmaxyx)
  206. #endif
  207. #ifdef getnstr
  208. inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str, n); }
  209. #undef getnstr
  210. #define getnstr UNDEF(getnstr)
  211. #endif
  212. #ifdef getparyx
  213. inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); }
  214. #undef getparyx
  215. #define getparyx UNDEF(getparyx)
  216. #endif
  217. #ifdef getstr
  218. inline int UNDEF(getstr)(char *_str) { return getstr(_str); }
  219. #undef getstr
  220. #define getstr UNDEF(getstr)
  221. #endif
  222. #ifdef getyx
  223. inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
  224. getyx(win, y, x); }
  225. #undef getyx
  226. #define getyx UNDEF(getyx)
  227. #endif
  228. #ifdef hline
  229. inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); }
  230. #undef hline
  231. #define hline UNDEF(hline)
  232. #endif
  233. #ifdef inch
  234. inline chtype UNDEF(inch)() { return inch(); }
  235. #undef inch
  236. #define inch UNDEF(inch)
  237. #endif
  238. #ifdef inchstr
  239. inline int UNDEF(inchstr)(chtype *str) { return inchstr(str); }
  240. #undef inchstr
  241. #define inchstr UNDEF(inchstr)
  242. #endif
  243. #ifdef innstr
  244. inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str, n); }
  245. #undef innstr
  246. #define innstr UNDEF(innstr)
  247. #endif
  248. #ifdef insch
  249. inline int UNDEF(insch)(chtype c) { return insch(c); }
  250. #undef insch
  251. #define insch UNDEF(insch)
  252. #endif
  253. #ifdef insdelln
  254. inline int UNDEF(insdelln)(int n) { return insdelln(n); }
  255. #undef insdelln
  256. #define insdelln UNDEF(insdelln)
  257. #endif
  258. #ifdef insertln
  259. inline int UNDEF(insertln)() { return insertln(); }
  260. #undef insertln
  261. #define insertln UNDEF(insertln)
  262. #endif
  263. #ifdef insnstr
  264. inline int UNDEF(insnstr)(const char *_str, int n) {
  265. return insnstr(_str, n); }
  266. #undef insnstr
  267. #define insnstr UNDEF(insnstr)
  268. #endif
  269. #ifdef insstr
  270. inline int UNDEF(insstr)(const char *_str) {
  271. return insstr(_str); }
  272. #undef insstr
  273. #define insstr UNDEF(insstr)
  274. #endif
  275. #ifdef instr
  276. inline int UNDEF(instr)(char *_str) { return instr(_str); }
  277. #undef instr
  278. #define instr UNDEF(instr)
  279. #endif
  280. #ifdef intrflush
  281. inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); }
  282. #undef intrflush
  283. #define intrflush UNDEF(intrflush)
  284. #endif
  285. #ifdef is_linetouched
  286. inline int UNDEF(is_linetouched)(WINDOW *w, int l) { return is_linetouched(w,l); }
  287. #undef is_linetouched
  288. #define is_linetouched UNDEF(is_linetouched)
  289. #endif
  290. #ifdef leaveok
  291. inline int UNDEF(leaveok)(WINDOW* win, bool bf) { return leaveok(win, bf); }
  292. #undef leaveok
  293. #define leaveok UNDEF(leaveok)
  294. #else
  295. extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf);
  296. #endif
  297. #ifdef move
  298. inline int UNDEF(move)(int x, int y) { return move(x, y); }
  299. #undef move
  300. #define move UNDEF(move)
  301. #endif
  302. #ifdef mvaddch
  303. inline int UNDEF(mvaddch)(int y, int x, chtype ch)
  304. { return mvaddch(y, x, ch); }
  305. #undef mvaddch
  306. #define mvaddch UNDEF(mvaddch)
  307. #endif
  308. #ifdef mvaddnstr
  309. inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n)
  310. { return mvaddnstr(y, x, str, n); }
  311. #undef mvaddnstr
  312. #define mvaddnstr UNDEF(mvaddnstr)
  313. #endif
  314. #ifdef mvaddstr
  315. inline int UNDEF(mvaddstr)(int y, int x, const char * str)
  316. { return mvaddstr(y, x, str); }
  317. #undef mvaddstr
  318. #define mvaddstr UNDEF(mvaddstr)
  319. #endif
  320. #ifdef mvchgat
  321. inline int UNDEF(mvchgat)(int y, int x, int n,
  322. attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
  323. return mvchgat(y, x, n, attr, color, opts); }
  324. #undef mvchgat
  325. #define mvchgat UNDEF(mvchgat)
  326. #endif
  327. #ifdef mvdelch
  328. inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}
  329. #undef mvdelch
  330. #define mvdelch UNDEF(mvdelch)
  331. #endif
  332. #ifdef mvgetch
  333. inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}
  334. #undef mvgetch
  335. #define mvgetch UNDEF(mvgetch)
  336. #endif
  337. #ifdef mvgetnstr
  338. inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) {
  339. return mvgetnstr(y, x, str, n);}
  340. #undef mvgetnstr
  341. #define mvgetnstr UNDEF(mvgetnstr)
  342. #endif
  343. #ifdef mvgetstr
  344. inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
  345. #undef mvgetstr
  346. #define mvgetstr UNDEF(mvgetstr)
  347. #endif
  348. #ifdef mvinch
  349. inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
  350. #undef mvinch
  351. #define mvinch UNDEF(mvinch)
  352. #endif
  353. #ifdef mvinnstr
  354. inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
  355. return mvinnstr(y, x, _str, n); }
  356. #undef mvinnstr
  357. #define mvinnstr UNDEF(mvinnstr)
  358. #endif
  359. #ifdef mvinsch
  360. inline int UNDEF(mvinsch)(int y, int x, chtype c)
  361. { return mvinsch(y, x, c); }
  362. #undef mvinsch
  363. #define mvinsch UNDEF(mvinsch)
  364. #endif
  365. #ifdef mvinsnstr
  366. inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) {
  367. return mvinsnstr(y, x, _str, n); }
  368. #undef mvinsnstr
  369. #define mvinsnstr UNDEF(mvinsnstr)
  370. #endif
  371. #ifdef mvinsstr
  372. inline int UNDEF(mvinsstr)(int y, int x, const char *_str) {
  373. return mvinsstr(y, x, _str); }
  374. #undef mvinsstr
  375. #define mvinsstr UNDEF(mvinsstr)
  376. #endif
  377. #ifdef mvwaddch
  378. inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch)
  379. { return mvwaddch(win, y, x, ch); }
  380. #undef mvwaddch
  381. #define mvwaddch UNDEF(mvwaddch)
  382. #endif
  383. #ifdef mvwaddchnstr
  384. inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n)
  385. { return mvwaddchnstr(win, y, x, str, n); }
  386. #undef mvwaddchnstr
  387. #define mvwaddchnstr UNDEF(mvwaddchnstr)
  388. #endif
  389. #ifdef mvwaddchstr
  390. inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str)
  391. { return mvwaddchstr(win, y, x, str); }
  392. #undef mvwaddchstr
  393. #define mvwaddchstr UNDEF(mvwaddchstr)
  394. #endif
  395. #ifdef mvwaddnstr
  396. inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
  397. { return mvwaddnstr(win, y, x, str, n); }
  398. #undef mvwaddnstr
  399. #define mvwaddnstr UNDEF(mvwaddnstr)
  400. #endif
  401. #ifdef mvwaddstr
  402. inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str)
  403. { return mvwaddstr(win, y, x, str); }
  404. #undef mvwaddstr
  405. #define mvwaddstr UNDEF(mvwaddstr)
  406. #endif
  407. #ifdef mvwchgat
  408. inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
  409. attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
  410. return mvwchgat(win, y, x, n, attr, color, opts); }
  411. #undef mvwchgat
  412. #define mvwchgat UNDEF(mvwchgat)
  413. #endif
  414. #ifdef mvwdelch
  415. inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x)
  416. { return mvwdelch(win, y, x); }
  417. #undef mvwdelch
  418. #define mvwdelch UNDEF(mvwdelch)
  419. #endif
  420. #ifdef mvwgetch
  421. inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
  422. #undef mvwgetch
  423. #define mvwgetch UNDEF(mvwgetch)
  424. #endif
  425. #ifdef mvwgetnstr
  426. inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
  427. {return mvwgetnstr(win, y, x, str, n);}
  428. #undef mvwgetnstr
  429. #define mvwgetnstr UNDEF(mvwgetnstr)
  430. #endif
  431. #ifdef mvwgetstr
  432. inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str)
  433. {return mvwgetstr(win, y, x, str);}
  434. #undef mvwgetstr
  435. #define mvwgetstr UNDEF(mvwgetstr)
  436. #endif
  437. #ifdef mvwhline
  438. inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) {
  439. return mvwhline(win, y, x, c, n); }
  440. #undef mvwhline
  441. #define mvwhline UNDEF(mvwhline)
  442. #endif
  443. #ifdef mvwinch
  444. inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
  445. return mvwinch(win, y, x);}
  446. #undef mvwinch
  447. #define mvwinch UNDEF(mvwinch)
  448. #endif
  449. #ifdef mvwinchnstr
  450. inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n) { return mvwinchnstr(win, y, x, str, n); }
  451. #undef mvwinchnstr
  452. #define mvwinchnstr UNDEF(mvwinchnstr)
  453. #endif
  454. #ifdef mvwinchstr
  455. inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str) { return mvwinchstr(win, y, x, str); }
  456. #undef mvwinchstr
  457. #define mvwinchstr UNDEF(mvwinchstr)
  458. #endif
  459. #ifdef mvwinnstr
  460. inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
  461. return mvwinnstr(win, y, x, _str, n); }
  462. #undef mvwinnstr
  463. #define mvwinnstr UNDEF(mvwinnstr)
  464. #endif
  465. #ifdef mvwinsch
  466. inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
  467. { return mvwinsch(win, y, x, c); }
  468. #undef mvwinsch
  469. #define mvwinsch UNDEF(mvwinsch)
  470. #endif
  471. #ifdef mvwinsnstr
  472. inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) {
  473. return mvwinsnstr(w, y, x, _str, n); }
  474. #undef mvwinsnstr
  475. #define mvwinsnstr UNDEF(mvwinsnstr)
  476. #endif
  477. #ifdef mvwinsstr
  478. inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) {
  479. return mvwinsstr(w, y, x, _str); }
  480. #undef mvwinsstr
  481. #define mvwinsstr UNDEF(mvwinsstr)
  482. #endif
  483. #ifdef mvwvline
  484. inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) {
  485. return mvwvline(win, y, x, c, n); }
  486. #undef mvwvline
  487. #define mvwvline UNDEF(mvwvline)
  488. #endif
  489. #ifdef napms
  490. inline void UNDEF(napms)(unsigned long x) { napms(x); }
  491. #undef napms
  492. #define napms UNDEF(napms)
  493. #endif
  494. #ifdef nocrmode
  495. inline int UNDEF(nocrmode)(void) { return nocrmode(); }
  496. #undef nocrmode
  497. #define nocrmode UNDEF(nocrmode)
  498. #endif
  499. #ifdef nodelay
  500. inline void UNDEF(nodelay)() { nodelay(); }
  501. #undef nodelay
  502. #define nodelay UNDEF(nodelay)
  503. #endif
  504. #ifdef redrawwin
  505. inline int UNDEF(redrawwin)(WINDOW *win) { return redrawwin(win); }
  506. #undef redrawwin
  507. #define redrawwin UNDEF(redrawwin)
  508. #endif
  509. #ifdef refresh
  510. inline int UNDEF(refresh)() { return refresh(); }
  511. #undef refresh
  512. #define refresh UNDEF(refresh)
  513. #endif
  514. #ifdef resetterm
  515. inline int UNDEF(resetterm)(void) { return resetterm(); }
  516. #undef resetterm
  517. #define resetterm UNDEF(resetterm)
  518. #endif
  519. #ifdef saveterm
  520. inline int UNDEF(saveterm)(void) { return saveterm(); }
  521. #undef saveterm
  522. #define saveterm UNDEF(saveterm)
  523. #endif
  524. #ifdef scrl
  525. inline int UNDEF(scrl)(int l) { return scrl(l); }
  526. #undef scrl
  527. #define scrl UNDEF(scrl)
  528. #endif
  529. #ifdef scroll
  530. inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); }
  531. #undef scroll
  532. #define scroll UNDEF(scroll)
  533. #endif
  534. #ifdef scrollok
  535. inline int UNDEF(scrollok)(WINDOW* win, bool bf) { return scrollok(win, bf); }
  536. #undef scrollok
  537. #define scrollok UNDEF(scrollok)
  538. #else
  539. #if defined(__NCURSES_H)
  540. extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool);
  541. #else
  542. extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char);
  543. #endif
  544. #endif
  545. #ifdef setscrreg
  546. inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); }
  547. #undef setscrreg
  548. #define setscrreg UNDEF(setscrreg)
  549. #endif
  550. #ifdef standend
  551. inline int UNDEF(standend)() { return standend(); }
  552. #undef standend
  553. #define standend UNDEF(standend)
  554. #endif
  555. #ifdef standout
  556. inline int UNDEF(standout)() { return standout(); }
  557. #undef standout
  558. #define standout UNDEF(standout)
  559. #endif
  560. #ifdef subpad
  561. inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
  562. { return derwin(p, l, c, y, x); }
  563. #undef subpad
  564. #define subpad UNDEF(subpad)
  565. #endif
  566. #ifdef timeout
  567. inline void UNDEF(timeout)(int delay) { timeout(delay); }
  568. #undef timeout
  569. #define timeout UNDEF(timeout)
  570. #endif
  571. #ifdef touchline
  572. inline int UNDEF(touchline)(WINDOW *win, int s, int c)
  573. { return touchline(win, s, c); }
  574. #undef touchline
  575. #define touchline UNDEF(touchline)
  576. #endif
  577. #ifdef touchwin
  578. inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); }
  579. #undef touchwin
  580. #define touchwin UNDEF(touchwin)
  581. #endif
  582. #ifdef untouchwin
  583. inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); }
  584. #undef untouchwin
  585. #define untouchwin UNDEF(untouchwin)
  586. #endif
  587. #ifdef vline
  588. inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); }
  589. #undef vline
  590. #define vline UNDEF(vline)
  591. #endif
  592. #ifdef waddchstr
  593. inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); }
  594. #undef waddchstr
  595. #define waddchstr UNDEF(waddchstr)
  596. #endif
  597. #ifdef waddstr
  598. inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); }
  599. #undef waddstr
  600. #define waddstr UNDEF(waddstr)
  601. #endif
  602. #ifdef wattroff
  603. inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
  604. #undef wattroff
  605. #define wattroff UNDEF(wattroff)
  606. #endif
  607. #ifdef wattrset
  608. inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }
  609. #undef wattrset
  610. #define wattrset UNDEF(wattrset)
  611. #endif
  612. #ifdef winch
  613. inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }
  614. #undef winch
  615. #define winch UNDEF(winch)
  616. #endif
  617. #ifdef winchnstr
  618. inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n) { return winchnstr(win, str, n); }
  619. #undef winchnstr
  620. #define winchnstr UNDEF(winchnstr)
  621. #endif
  622. #ifdef winchstr
  623. inline int UNDEF(winchstr)(WINDOW *win, chtype *str) { return winchstr(win, str); }
  624. #undef winchstr
  625. #define winchstr UNDEF(winchstr)
  626. #endif
  627. #ifdef winsstr
  628. inline int UNDEF(winsstr)(WINDOW *w, const char *_str) {
  629. return winsstr(w, _str); }
  630. #undef winsstr
  631. #define winsstr UNDEF(winsstr)
  632. #endif
  633. #ifdef wstandend
  634. inline int UNDEF(wstandend)(WINDOW *win) { return wstandend(win); }
  635. #undef wstandend
  636. #define wstandend UNDEF(wstandend)
  637. #endif
  638. #ifdef wstandout
  639. inline int UNDEF(wstandout)(WINDOW *win) { return wstandout(win); }
  640. #undef wstandout
  641. #define wstandout UNDEF(wstandout)
  642. #endif
  643. /*
  644. *
  645. * C++ class for windows.
  646. *
  647. */
  648. extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int));
  649. extern "C" int _nc_xx_ripoff_init(WINDOW *, int);
  650. extern "C" int _nc_has_mouse(void);
  651. class NCURSES_CXX_IMPEXP NCursesWindow
  652. {
  653. friend class NCursesMenu;
  654. friend class NCursesForm;
  655. private:
  656. static bool b_initialized;
  657. static void initialize();
  658. void constructing();
  659. friend int _nc_xx_ripoff_init(WINDOW *, int);
  660. void set_keyboard();
  661. NCURSES_COLOR_T getcolor(int getback) const;
  662. NCURSES_PAIRS_T getPair() const;
  663. static int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair);
  664. static int colorInitialized;
  665. // This private constructor is only used during the initialization
  666. // of windows generated by ripoffline() calls.
  667. NCursesWindow(WINDOW* win, int ncols);
  668. protected:
  669. virtual void err_handler(const char *) const THROWS(NCursesException);
  670. // Signal an error with the given message text.
  671. static long count; // count of all active windows:
  672. // We rely on the c++ promise that
  673. // all otherwise uninitialized
  674. // static class vars are set to 0
  675. WINDOW* w; // the curses WINDOW
  676. bool alloced; // TRUE if we own the WINDOW
  677. NCursesWindow* par; // parent, if subwindow
  678. NCursesWindow* subwins; // head of subwindows list
  679. NCursesWindow* sib; // next subwindow of parent
  680. void kill_subwindows(); // disable all subwindows
  681. // Destroy all subwindows.
  682. /* Only for use by derived classes. They are then in charge to
  683. fill the member variables correctly. */
  684. NCursesWindow();
  685. public:
  686. explicit NCursesWindow(WINDOW* window); // useful only for stdscr
  687. NCursesWindow(int nlines, // number of lines
  688. int ncols, // number of columns
  689. int begin_y, // line origin
  690. int begin_x); // col origin
  691. NCursesWindow(NCursesWindow& par,// parent window
  692. int nlines, // number of lines
  693. int ncols, // number of columns
  694. int begin_y, // absolute or relative
  695. int begin_x, // origins:
  696. char absrel = 'a');// if `a', begin_y & begin_x are
  697. // absolute screen pos, else if `r', they are relative to par origin
  698. NCursesWindow(NCursesWindow& par,// parent window
  699. bool do_box = TRUE);
  700. // this is the very common case that we want to create the subwindow that
  701. // is two lines and two columns smaller and begins at (1,1).
  702. // We may automatically request the box around it.
  703. NCursesWindow& operator=(const NCursesWindow& rhs)
  704. {
  705. if (this != &rhs)
  706. *this = rhs;
  707. return *this;
  708. }
  709. NCursesWindow(const NCursesWindow& rhs)
  710. : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
  711. {
  712. }
  713. virtual ~NCursesWindow() THROWS(NCursesException);
  714. NCursesWindow Clone();
  715. // Make an exact copy of the window.
  716. // Initialization.
  717. static void useColors(void);
  718. // Call this routine very early if you want to have colors.
  719. static int ripoffline(int ripoff_lines,
  720. int (*init)(NCursesWindow& win));
  721. // This function is used to generate a window of ripped-of lines.
  722. // If the argument is positive, lines are removed from the top, if it
  723. // is negative lines are removed from the bottom. This enhances the
  724. // lowlevel ripoffline() function because it uses the internal
  725. // implementation that allows to remove more than just a single line.
  726. // This function must be called before any other ncurses function. The
  727. // creation of the window is deferred until ncurses gets initialized.
  728. // The initialization function is then called.
  729. // -------------------------------------------------------------------------
  730. // terminal status
  731. // -------------------------------------------------------------------------
  732. int lines() const { initialize(); return LINES; }
  733. // Number of lines on terminal, *not* window
  734. int cols() const { initialize(); return COLS; }
  735. // Number of cols on terminal, *not* window
  736. int tabsize() const { initialize(); return TABSIZE; }
  737. // Size of a tab on terminal, *not* window
  738. static int NumberOfColors();
  739. // Number of available colors
  740. int colors() const { return NumberOfColors(); }
  741. // Number of available colors
  742. // -------------------------------------------------------------------------
  743. // window status
  744. // -------------------------------------------------------------------------
  745. int height() const { return maxy() + 1; }
  746. // Number of lines in this window
  747. int width() const { return maxx() + 1; }
  748. // Number of columns in this window
  749. int begx() const { return getbegx(w); }
  750. // Column of top left corner relative to stdscr
  751. int begy() const { return getbegy(w); }
  752. // Line of top left corner relative to stdscr
  753. int curx() const { return getcurx(w); }
  754. // Column of top left corner relative to stdscr
  755. int cury() const { return getcury(w); }
  756. // Line of top left corner relative to stdscr
  757. int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
  758. // Largest x coord in window
  759. int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
  760. // Largest y coord in window
  761. NCURSES_PAIRS_T getcolor() const;
  762. // Actual color pair
  763. NCURSES_COLOR_T foreground() const { return getcolor(0); }
  764. // Actual foreground color
  765. NCURSES_COLOR_T background() const { return getcolor(1); }
  766. // Actual background color
  767. int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back);
  768. // Set color palette entry
  769. int setcolor(NCURSES_PAIRS_T pair);
  770. // Set actually used palette entry
  771. // -------------------------------------------------------------------------
  772. // window positioning
  773. // -------------------------------------------------------------------------
  774. virtual int mvwin(int begin_y, int begin_x) {
  775. return ::mvwin(w, begin_y, begin_x); }
  776. // Move window to new position with the new position as top left corner.
  777. // This is virtual because it is redefined in NCursesPanel.
  778. // -------------------------------------------------------------------------
  779. // coordinate positioning
  780. // -------------------------------------------------------------------------
  781. int move(int y, int x) { return ::wmove(w, y, x); }
  782. // Move cursor the this position
  783. void getyx(int& y, int& x) const { ::getyx(w, y, x); }
  784. // Get current position of the cursor
  785. void getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); }
  786. // Get beginning of the window
  787. void getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); }
  788. // Get size of the window
  789. void getparyx(int& y, int& x) const { ::getparyx(w, y, x); }
  790. // Get parent's beginning of the window
  791. int mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
  792. return ::mvcur(oldrow, oldcol, newrow, newcol); }
  793. // Perform lowlevel cursor motion that takes effect immediately.
  794. // -------------------------------------------------------------------------
  795. // input
  796. // -------------------------------------------------------------------------
  797. int getch() { return ::wgetch(w); }
  798. // Get a keystroke from the window.
  799. int getch(int y, int x) { return ::mvwgetch(w, y, x); }
  800. // Move cursor to position and get a keystroke from the window
  801. int getstr(char* str, int n=-1) {
  802. return ::wgetnstr(w, str, n); }
  803. // Read a series of characters into str until a newline or carriage return
  804. // is received. Read at most n characters. If n is negative, the limit is
  805. // ignored.
  806. int getstr(int y, int x, char* str, int n=-1) {
  807. return ::mvwgetnstr(w, y, x, str, n); }
  808. // Move the cursor to the requested position and then perform the getstr()
  809. // as described above.
  810. int instr(char *s, int n=-1) { return ::winnstr(w, s, n); }
  811. // Get a string of characters from the window into the buffer s. Retrieve
  812. // at most n characters, if n is negative retrieve all characters up to the
  813. // end of the current line. Attributes are stripped from the characters.
  814. int instr(int y, int x, char *s, int n=-1) {
  815. return ::mvwinnstr(w, y, x, s, n); }
  816. // Move the cursor to the requested position and then perform the instr()
  817. // as described above.
  818. int scanw(const char* fmt, ...)
  819. // Perform a scanw function from the window.
  820. #if __GNUG__ >= 2
  821. __attribute__ ((format (scanf, 2, 3)));
  822. #else
  823. ;
  824. #endif
  825. int scanw(const char*, va_list);
  826. // Perform a scanw function from the window.
  827. int scanw(int y, int x, const char* fmt, ...)
  828. // Move the cursor to the requested position and then perform a scanw
  829. // from the window.
  830. #if __GNUG__ >= 2
  831. __attribute__ ((format (scanf, 4, 5)));
  832. #else
  833. ;
  834. #endif
  835. int scanw(int y, int x, const char* fmt, va_list);
  836. // Move the cursor to the requested position and then perform a scanw
  837. // from the window.
  838. // -------------------------------------------------------------------------
  839. // output
  840. // -------------------------------------------------------------------------
  841. int addch(const chtype ch) { return ::waddch(w, ch); }
  842. // Put attributed character to the window.
  843. int addch(int y, int x, const chtype ch) {
  844. return ::mvwaddch(w, y, x, ch); }
  845. // Move cursor to the requested position and then put attributed character
  846. // to the window.
  847. int echochar(const chtype ch) { return ::wechochar(w, ch); }
  848. // Put attributed character to the window and refresh it immediately.
  849. int addstr(const char* str, int n=-1) {
  850. return ::waddnstr(w, str, n); }
  851. // Write the string str to the window, stop writing if the terminating
  852. // NUL or the limit n is reached. If n is negative, it is ignored.
  853. int addstr(int y, int x, const char * str, int n=-1) {
  854. return ::mvwaddnstr(w, y, x, str, n); }
  855. // Move the cursor to the requested position and then perform the addchstr
  856. // as described above.
  857. int addchstr(const chtype* str, int n=-1) {
  858. return ::waddchnstr(w, str, n); }
  859. // Write the string str to the window, stop writing if the terminating
  860. // NUL or the limit n is reached. If n is negative, it is ignored.
  861. int addchstr(int y, int x, const chtype * str, int n=-1) {
  862. return ::mvwaddchnstr(w, y, x, str, n); }
  863. // Move the cursor to the requested position and then perform the addchstr
  864. // as described above.
  865. int printw(const char* fmt, ...)
  866. // Do a formatted print to the window.
  867. #if (__GNUG__ >= 2) && !defined(printf)
  868. __attribute__ ((format (printf, 2, 3)));
  869. #else
  870. ;
  871. #endif
  872. int printw(int y, int x, const char * fmt, ...)
  873. // Move the cursor and then do a formatted print to the window.
  874. #if (__GNUG__ >= 2) && !defined(printf)
  875. __attribute__ ((format (printf, 4, 5)));
  876. #else
  877. ;
  878. #endif
  879. int printw(const char* fmt, va_list args);
  880. // Do a formatted print to the window.
  881. int printw(int y, int x, const char * fmt, va_list args);
  882. // Move the cursor and then do a formatted print to the window.
  883. chtype inch() const { return ::winch(w); }
  884. // Retrieve attributed character under the current cursor position.
  885. chtype inch(int y, int x) { return ::mvwinch(w, y, x); }
  886. // Move cursor to requested position and then retrieve attributed character
  887. // at this position.
  888. int inchstr(chtype* str, int n=-1) {
  889. return ::winchnstr(w, str, n); }
  890. // Read the string str from the window, stop reading if the terminating
  891. // NUL or the limit n is reached. If n is negative, it is ignored.
  892. int inchstr(int y, int x, chtype * str, int n=-1) {
  893. return ::mvwinchnstr(w, y, x, str, n); }
  894. // Move the cursor to the requested position and then perform the inchstr
  895. // as described above.
  896. int insch(chtype ch) { return ::winsch(w, ch); }
  897. // Insert attributed character into the window before current cursor
  898. // position.
  899. int insch(int y, int x, chtype ch) {
  900. return ::mvwinsch(w, y, x, ch); }
  901. // Move cursor to requested position and then insert the attributed
  902. // character before that position.
  903. int insertln() { return ::winsdelln(w, 1); }
  904. // Insert an empty line above the current line.
  905. int insdelln(int n=1) { return ::winsdelln(w, n); }
  906. // If n>0 insert that many lines above the current line. If n<0 delete
  907. // that many lines beginning with the current line.
  908. int insstr(const char *s, int n=-1) {
  909. return ::winsnstr(w, s, n); }
  910. // Insert the string into the window before the current cursor position.
  911. // Insert stops at end of string or when the limit n is reached. If n is
  912. // negative, it is ignored.
  913. int insstr(int y, int x, const char *s, int n=-1) {
  914. return ::mvwinsnstr(w, y, x, s, n); }
  915. // Move the cursor to the requested position and then perform the insstr()
  916. // as described above.
  917. int attron (chtype at) { return ::wattron (w, at); }
  918. // Switch on the window attributes;
  919. int attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
  920. // Switch off the window attributes;
  921. int attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
  922. // Set the window attributes;
  923. chtype attrget() { return ::getattrs(w); }
  924. // Get the window attributes;
  925. int color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) {
  926. return ::wcolor_set(w, color_pair_number, opts); }
  927. // Set the window color attribute;
  928. int chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
  929. return ::wchgat(w, n, attr, color, opts); }
  930. // Change the attributes of the next n characters in the current line. If
  931. // n is negative or greater than the number of remaining characters in the
  932. // line, the attributes will be changed up to the end of the line.
  933. int chgat(int y, int x,
  934. int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
  935. return ::mvwchgat(w, y, x, n, attr, color, opts); }
  936. // Move the cursor to the requested position and then perform chgat() as
  937. // described above.
  938. // -------------------------------------------------------------------------
  939. // background
  940. // -------------------------------------------------------------------------
  941. chtype getbkgd() const { return ::getbkgd(w); }
  942. // Get current background setting.
  943. int bkgd(const chtype ch) { return ::wbkgd(w, ch); }
  944. // Set the background property and apply it to the window.
  945. void bkgdset(chtype ch) { ::wbkgdset(w, ch); }
  946. // Set the background property.
  947. // -------------------------------------------------------------------------
  948. // borders
  949. // -------------------------------------------------------------------------
  950. int box(chtype vert=0, chtype hor=0) {
  951. return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); }
  952. // Draw a box around the window with the given vertical and horizontal
  953. // drawing characters. If you specify a zero as character, curses will try
  954. // to find a "nice" character.
  955. int border(chtype left=0, chtype right=0,
  956. chtype top =0, chtype bottom=0,
  957. chtype top_left =0, chtype top_right=0,
  958. chtype bottom_left =0, chtype bottom_right=0) {
  959. return ::wborder(w, left, right, top, bottom, top_left, top_right,
  960. bottom_left, bottom_right); }
  961. // Draw a border around the window with the given characters for the
  962. // various parts of the border. If you pass zero for a character, curses
  963. // will try to find "nice" characters.
  964. // -------------------------------------------------------------------------
  965. // lines and boxes
  966. // -------------------------------------------------------------------------
  967. int hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
  968. // Draw a horizontal line of len characters with the given character. If
  969. // you pass zero for the character, curses will try to find a "nice" one.
  970. int hline(int y, int x, int len, chtype ch=0) {
  971. return ::mvwhline(w, y, x, ch, len); }
  972. // Move the cursor to the requested position and then draw a horizontal line.
  973. int vline(int len, chtype ch=0) { return ::wvline(w, ch, len); }
  974. // Draw a vertical line of len characters with the given character. If
  975. // you pass zero for the character, curses will try to find a "nice" one.
  976. int vline(int y, int x, int len, chtype ch=0) {
  977. return ::mvwvline(w, y, x, ch, len); }
  978. // Move the cursor to the requested position and then draw a vertical line.
  979. // -------------------------------------------------------------------------
  980. // erasure
  981. // -------------------------------------------------------------------------
  982. int erase() { return ::werase(w); }
  983. // Erase the window.
  984. int clear() { return ::wclear(w); }
  985. // Clear the window.
  986. int clearok(bool bf) { return ::clearok(w, bf); }
  987. // Set/Reset the clear flag. If set, the next refresh() will clear the
  988. // screen.
  989. int clrtobot() { return ::wclrtobot(w); }
  990. // Clear to the end of the window.
  991. int clrtoeol() { return ::wclrtoeol(w); }
  992. // Clear to the end of the line.
  993. int delch() { return ::wdelch(w); }
  994. // Delete character under the cursor.
  995. int delch(int y, int x) { return ::mvwdelch(w, y, x); }
  996. // Move cursor to requested position and delete the character under the
  997. // cursor.
  998. int deleteln() { return ::winsdelln(w, -1); }
  999. // Delete the current line.
  1000. // -------------------------------------------------------------------------
  1001. // screen control
  1002. // -------------------------------------------------------------------------
  1003. int scroll(int amount=1) { return ::wscrl(w, amount); }
  1004. // Scroll amount lines. If amount is positive, scroll up, otherwise
  1005. // scroll down.
  1006. int scrollok(bool bf) { return ::scrollok(w, bf); }
  1007. // If bf is TRUE, window scrolls if cursor is moved off the bottom
  1008. // edge of the window or a scrolling region, otherwise the cursor is left
  1009. // at the bottom line.
  1010. int setscrreg(int from, int to) {
  1011. return ::wsetscrreg(w, from, to); }
  1012. // Define a soft scrolling region.
  1013. int idlok(bool bf) { return ::idlok(w, bf); }
  1014. // If bf is TRUE, use insert/delete line hardware support if possible.
  1015. // Otherwise do it in software.
  1016. void idcok(bool bf) { ::idcok(w, bf); }
  1017. // If bf is TRUE, use insert/delete character hardware support if possible.
  1018. // Otherwise do it in software.
  1019. int touchline(int s, int c) { return ::touchline(w, s, c); }
  1020. // Mark the given lines as modified.
  1021. int touchwin() { return ::wtouchln(w, 0, height(), 1); }
  1022. // Mark the whole window as modified.
  1023. int untouchwin() { return ::wtouchln(w, 0, height(), 0); }
  1024. // Mark the whole window as unmodified.
  1025. int touchln(int s, int cnt, bool changed=TRUE) {
  1026. return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
  1027. // Mark cnt lines beginning from line s as changed or unchanged, depending
  1028. // on the value of the changed flag.
  1029. bool is_linetouched(int line) const {
  1030. return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); }
  1031. // Return TRUE if line is marked as changed, FALSE otherwise
  1032. bool is_wintouched() const {
  1033. return (::is_wintouched(w) ? TRUE:FALSE); }
  1034. // Return TRUE if window is marked as changed, FALSE otherwise
  1035. int leaveok(bool bf) { return ::leaveok(w, bf); }
  1036. // If bf is TRUE, curses will leave the cursor after an update wherever
  1037. // it is after the update.
  1038. int redrawln(int from, int n) { return ::wredrawln(w, from, n); }
  1039. // Redraw n lines starting from the requested line
  1040. int redrawwin() { return ::wredrawln(w, 0, height()); }
  1041. // Redraw the whole window
  1042. int doupdate() { return ::doupdate(); }
  1043. // Do all outputs to make the physical screen looking like the virtual one
  1044. void syncdown() { ::wsyncdown(w); }
  1045. // Propagate the changes down to all descendant windows
  1046. void syncup() { ::wsyncup(w); }
  1047. // Propagate the changes up in the hierarchy
  1048. void cursyncup() { ::wcursyncup(w); }
  1049. // Position the cursor in all ancestor windows corresponding to our setting
  1050. int syncok(bool bf) { return ::syncok(w, bf); }
  1051. // If called with bf=TRUE, syncup() is called whenever the window is changed
  1052. #ifndef _no_flushok
  1053. int flushok(bool bf) { return ::flushok(w, bf); }
  1054. #endif
  1055. void immedok(bool bf) { ::immedok(w, bf); }
  1056. // If called with bf=TRUE, any change in the window will cause an
  1057. // automatic immediate refresh()
  1058. int intrflush(bool bf) { return ::intrflush(w, bf); }
  1059. int keypad(bool bf) { return ::keypad(w, bf); }
  1060. // If called with bf=TRUE, the application will interpret function keys.
  1061. int nodelay(bool bf) { return ::nodelay(w, bf); }
  1062. int meta(bool bf) { return ::meta(w, bf); }
  1063. // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
  1064. // 7-Bit characters are generated.
  1065. int standout() { return ::wstandout(w); }
  1066. // Enable "standout" attributes
  1067. int standend() { return ::wstandend(w); }
  1068. // Disable "standout" attributes
  1069. // -------------------------------------------------------------------------
  1070. // The next two are virtual, because we redefine them in the
  1071. // NCursesPanel class.
  1072. // -------------------------------------------------------------------------
  1073. virtual int refresh() { return ::wrefresh(w); }
  1074. // Propagate the changes in this window to the virtual screen and call
  1075. // doupdate(). This is redefined in NCursesPanel.
  1076. virtual int noutrefresh() { return ::wnoutrefresh(w); }
  1077. // Propagate the changes in this window to the virtual screen. This is
  1078. // redefined in NCursesPanel.
  1079. // -------------------------------------------------------------------------
  1080. // multiple window control
  1081. // -------------------------------------------------------------------------
  1082. int overlay(NCursesWindow& win) {
  1083. return ::overlay(w, win.w); }
  1084. // Overlay this window over win.
  1085. int overwrite(NCursesWindow& win) {
  1086. return ::overwrite(w, win.w); }
  1087. // Overwrite win with this window.
  1088. int copywin(NCursesWindow& win,
  1089. int sminrow, int smincol,
  1090. int dminrow, int dmincol,
  1091. int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
  1092. return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
  1093. dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
  1094. // Overlay or overwrite the rectangle in win given by dminrow,dmincol,
  1095. // dmaxrow,dmaxcol with the rectangle in this window beginning at
  1096. // sminrow,smincol.
  1097. // -------------------------------------------------------------------------
  1098. // Extended functions
  1099. // -------------------------------------------------------------------------
  1100. #if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0)
  1101. int wresize(int newLines, int newColumns) {
  1102. return ::wresize(w, newLines, newColumns); }
  1103. #endif
  1104. // -------------------------------------------------------------------------
  1105. // Mouse related
  1106. // -------------------------------------------------------------------------
  1107. bool has_mouse() const;
  1108. // Return TRUE if terminal supports a mouse, FALSE otherwise
  1109. // -------------------------------------------------------------------------
  1110. // traversal support
  1111. // -------------------------------------------------------------------------
  1112. NCursesWindow* child() { return subwins; }
  1113. // Get the first child window.
  1114. NCursesWindow* sibling() { return sib; }
  1115. // Get the next child of my parent.
  1116. NCursesWindow* parent() { return par; }
  1117. // Get my parent.
  1118. bool isDescendant(NCursesWindow& win);
  1119. // Return TRUE if win is a descendant of this.
  1120. };
  1121. // -------------------------------------------------------------------------
  1122. // We leave this here for compatibility reasons.
  1123. // -------------------------------------------------------------------------
  1124. class NCURSES_CXX_IMPEXP NCursesColorWindow : public NCursesWindow
  1125. {
  1126. public:
  1127. explicit NCursesColorWindow(WINDOW* &window) // useful only for stdscr
  1128. : NCursesWindow(window) {
  1129. useColors(); }
  1130. NCursesColorWindow(int nlines, // number of lines
  1131. int ncols, // number of columns
  1132. int begin_y, // line origin
  1133. int begin_x) // col origin
  1134. : NCursesWindow(nlines, ncols, begin_y, begin_x) {
  1135. useColors(); }
  1136. NCursesColorWindow(NCursesWindow& parentWin,// parent window
  1137. int nlines, // number of lines
  1138. int ncols, // number of columns
  1139. int begin_y, // absolute or relative
  1140. int begin_x, // origins:
  1141. char absrel = 'a') // if `a', by & bx are
  1142. : NCursesWindow(parentWin,
  1143. nlines, ncols, // absolute screen pos,
  1144. begin_y, begin_x, // else if `r', they are
  1145. absrel ) { // relative to par origin
  1146. useColors(); }
  1147. };
  1148. // These enum definitions really belong inside the NCursesPad class, but only
  1149. // recent compilers support that feature.
  1150. typedef enum {
  1151. REQ_PAD_REFRESH = KEY_MAX + 1,
  1152. REQ_PAD_UP,
  1153. REQ_PAD_DOWN,
  1154. REQ_PAD_LEFT,
  1155. REQ_PAD_RIGHT,
  1156. REQ_PAD_EXIT
  1157. } Pad_Request;
  1158. const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code
  1159. const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code
  1160. // -------------------------------------------------------------------------
  1161. // Pad Support. We allow an association of a pad with a "real" window
  1162. // through which the pad may be viewed.
  1163. // -------------------------------------------------------------------------
  1164. class NCURSES_CXX_IMPEXP NCursesPad : public NCursesWindow
  1165. {
  1166. private:
  1167. NCursesWindow* viewWin; // the "viewport" window
  1168. NCursesWindow* viewSub; // the "viewport" subwindow
  1169. int h_gridsize, v_gridsize;
  1170. protected:
  1171. int min_row, min_col; // top left row/col of the pads display area
  1172. NCursesWindow* Win(void) const {
  1173. // Get the window into which the pad should be copied (if any)
  1174. return (viewSub?viewSub:(viewWin?viewWin:0));
  1175. }
  1176. NCursesWindow* getWindow(void) const {
  1177. return viewWin;
  1178. }
  1179. NCursesWindow* getSubWindow(void) const {
  1180. return viewSub;
  1181. }
  1182. virtual int driver (int key); // Virtualize keystroke key
  1183. // The driver translates the keystroke c into an Pad_Request
  1184. virtual void OnUnknownOperation(int pad_req) {
  1185. (void) pad_req;
  1186. ::beep();
  1187. }
  1188. // This is called if the driver returns an unknown op-code
  1189. virtual void OnNavigationError(int pad_req) {
  1190. (void) pad_req;
  1191. ::beep();
  1192. }
  1193. // This is called if a navigation request couldn't be satisfied
  1194. virtual void OnOperation(int pad_req) {
  1195. (void) pad_req;
  1196. };
  1197. // OnOperation is called if a Pad_Operation was executed and just before
  1198. // the refresh() operation is done.
  1199. public:
  1200. NCursesPad(int nlines, int ncols);
  1201. // create a pad with the given size
  1202. NCursesPad& operator=(const NCursesPad& rhs)
  1203. {
  1204. if (this != &rhs) {
  1205. *this = rhs;
  1206. NCursesWindow::operator=(rhs);
  1207. }
  1208. return *this;
  1209. }
  1210. NCursesPad(const NCursesPad& rhs)
  1211. : NCursesWindow(rhs),
  1212. viewWin(rhs.viewWin),
  1213. viewSub(rhs.viewSub),
  1214. h_gridsize(rhs.h_gridsize),
  1215. v_gridsize(rhs.v_gridsize),
  1216. min_row(rhs.min_row),
  1217. min_col(rhs.min_col)
  1218. {
  1219. }
  1220. virtual ~NCursesPad() THROWS(NCursesException) {}
  1221. int echochar(const chtype ch) { return ::pechochar(w, ch); }
  1222. // Put the attributed character onto the pad and immediately do a
  1223. // prefresh().
  1224. int refresh() NCURSES_OVERRIDE;
  1225. // If a viewport is defined the pad is displayed in this window, otherwise
  1226. // this is a noop.
  1227. int refresh(int pminrow, int pmincol,
  1228. int sminrow, int smincol,
  1229. int smaxrow, int smaxcol) {
  1230. return ::prefresh(w, pminrow, pmincol,
  1231. sminrow, smincol, smaxrow, smaxcol);
  1232. }
  1233. // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
  1234. // on the screen. <b>refresh</b> copies a rectangle of this size beginning
  1235. // with top left corner pminrow,pmincol onto the screen and calls doupdate().
  1236. int noutrefresh() NCURSES_OVERRIDE;
  1237. // If a viewport is defined the pad is displayed in this window, otherwise
  1238. // this is a noop.
  1239. int noutrefresh(int pminrow, int pmincol,
  1240. int sminrow, int smincol,
  1241. int smaxrow, int smaxcol) {
  1242. return ::pnoutrefresh(w, pminrow, pmincol,
  1243. sminrow, smincol, smaxrow, smaxcol);
  1244. }
  1245. // Does the same as refresh() but without calling doupdate().
  1246. virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
  1247. // Add the window "view" as viewing window to the pad.
  1248. virtual void setSubWindow(NCursesWindow& sub);
  1249. // Use the subwindow "sub" of the viewport window for the actual viewing.
  1250. // The full viewport window is usually used to provide some decorations
  1251. // like frames, titles etc.
  1252. virtual void operator() (void);
  1253. // Perform Pad's operation
  1254. };
  1255. // A FramedPad is constructed always with a viewport window. This viewport
  1256. // will be framed (by a box() command) and the interior of the box is the
  1257. // viewport subwindow. On the frame we display scrollbar sliders.
  1258. class NCURSES_CXX_IMPEXP NCursesFramedPad : public NCursesPad
  1259. {
  1260. protected:
  1261. virtual void OnOperation(int pad_req) NCURSES_OVERRIDE;
  1262. public:
  1263. NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
  1264. int v_grid = 1, int h_grid = 1)
  1265. : NCursesPad(nlines, ncols) {
  1266. NCursesPad::setWindow(win, v_grid, h_grid);
  1267. NCursesPad::setSubWindow(*(new NCursesWindow(win)));
  1268. }
  1269. // Construct the FramedPad with the given Window win as viewport.
  1270. virtual ~NCursesFramedPad() THROWS(NCursesException) {
  1271. delete getSubWindow();
  1272. }
  1273. void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) NCURSES_OVERRIDE {
  1274. (void) view;
  1275. (void) v_grid;
  1276. (void) h_grid;
  1277. err_handler("Operation not allowed");
  1278. }
  1279. // Disable this call; the viewport is already defined
  1280. void setSubWindow(NCursesWindow& sub) NCURSES_OVERRIDE {
  1281. (void) sub;
  1282. err_handler("Operation not allowed");
  1283. }
  1284. // Disable this call; the viewport subwindow is already defined
  1285. };
  1286. #endif /* NCURSES_CURSESW_H_incl */