cursesw.h 48 KB

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