cursesw.h 49 KB

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