ncurses.pp 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895
  1. {
  2. Interface to the ncurses library. Original ncurses library copyright:
  3. ****************************************************************************
  4. * Copyright (c) 1998-2012,2013 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. {$MODE OBJFPC}
  31. unit ncurses;
  32. interface
  33. uses
  34. unixtype;
  35. {$PACKRECORDS C}
  36. {$LINKLIB ncursesw}
  37. {$LINKLIB c} // should be uses initc ?
  38. {$DEFINE USE_FPC_BYTEBOOL}
  39. const
  40. libncurses = 'ncursesw';
  41. type
  42. PFILE = Pointer;
  43. {$IFDEF USE_FPC_BYTEBOOL}
  44. Bool = ByteBool;
  45. {$ELSE USE_FPC_BYTEBOOL}
  46. Bool = Byte;
  47. {$ENDIF USE_FPC_BYTEBOOL}
  48. const
  49. {$IFDEF USE_FPC_BYTEBOOL}
  50. NC_FPC_TRUE = true;
  51. NC_FPC_FALSE = false;
  52. {$ELSE USE_FPC_BYTEBOOL}
  53. NC_FPC_TRUE = 1;
  54. NC_FPC_FALSE = 0;
  55. {$ENDIF USE_FPC_BYTEBOOL}
  56. const
  57. NCURSES_VERSION_MAJOR = 5;
  58. NCURSES_VERSION_MINOR = 6;
  59. NCURSES_VERSION_PATCH = 20061217;
  60. NCURSES_VERSION = '5.6';
  61. NCURSES_MOUSE_VERSION = 1;
  62. type
  63. pchtype = ^chtype;
  64. chtype = culong;
  65. pmmask_t = ^mmask_t;
  66. mmask_t = culong;
  67. { colors }
  68. var
  69. {$IFNDEF darwin}
  70. COLORS : cint cvar; external;
  71. COLOR_PAIRS : cint cvar; external;
  72. {$ELSE darwin}
  73. COLORS : cint external libncurses name 'COLORS';
  74. COLOR_PAIRS : cint external libncurses name 'COLOR_PAIRS';
  75. {$ENDIF darwin}
  76. const
  77. COLOR_BLACK = 0;
  78. COLOR_RED = 1;
  79. COLOR_GREEN = 2;
  80. COLOR_YELLOW = 3;
  81. COLOR_BLUE = 4;
  82. COLOR_MAGENTA = 5;
  83. COLOR_CYAN = 6;
  84. COLOR_WHITE = 7;
  85. type
  86. pNC_FPC_COLOR = ^NC_FPC_COLOR;
  87. NC_FPC_COLOR = Smallint;
  88. { line graphics }
  89. type
  90. tacs_map = array [char] of chtype;
  91. pacs_map = ^tacs_map;
  92. var
  93. {$IFNDEF darwin}
  94. acs_map : tacs_map cvar; external;
  95. {$ELSE darwin}
  96. acs_map : tacs_map external libncurses name 'acs_map';
  97. {$ENDIF darwin}
  98. //function NCURSES_ACS(c : Longint) : Longint;
  99. (* VT100 symbols begin here *)
  100. function ACS_ULCORNER : chtype; inline; { upper left corner }
  101. function ACS_LLCORNER : chtype; inline; { lower left corner }
  102. function ACS_URCORNER : chtype; inline; { upper right corner }
  103. function ACS_LRCORNER : chtype; inline; { lower right corner }
  104. function ACS_LTEE : chtype; inline; { tee pointing right }
  105. function ACS_RTEE : chtype; inline; { tee pointing left }
  106. function ACS_BTEE : chtype; inline; { tee pointing up }
  107. function ACS_TTEE : chtype; inline; { tee pointing down }
  108. function ACS_HLINE : chtype; inline; { horizontal line }
  109. function ACS_VLINE : chtype; inline; { vertical line }
  110. function ACS_PLUS : chtype; inline; { large plus or crossover }
  111. function ACS_S1 : chtype; inline; { scan line 1 }
  112. function ACS_S9 : chtype; inline; { scan line 9 }
  113. function ACS_DIAMOND : chtype; inline; { diamond }
  114. function ACS_CKBOARD : chtype; inline; { checker board (stipple) }
  115. function ACS_DEGREE : chtype; inline; { degree symbol }
  116. function ACS_PLMINUS : chtype; inline; { plus/minus }
  117. function ACS_BULLET : chtype; inline; { bullet }
  118. (* Teletype 5410v1 symbols begin here *)
  119. function ACS_LARROW : chtype; inline; { arrow pointing left }
  120. function ACS_RARROW : chtype; inline; { arrow pointing right }
  121. function ACS_DARROW : chtype; inline; { arrow pointing down }
  122. function ACS_UARROW : chtype; inline; { arrow pointing up }
  123. function ACS_BOARD : chtype; inline; { board of squares }
  124. function ACS_LANTERN : chtype; inline; { lantern symbol }
  125. function ACS_BLOCK : chtype; inline; { solid square block }
  126. (*
  127. * These aren't documented, but a lot of System Vs have them anyway
  128. * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
  129. * The ACS_names may not match AT&T's, our source didn't know them.
  130. *)
  131. function ACS_S3 : chtype; inline; { scan line 3 }
  132. function ACS_S7 : chtype; inline; { scan line 7 }
  133. function ACS_LEQUAL : chtype; inline; { less/equal }
  134. function ACS_GEQUAL : chtype; inline; { greater/equal }
  135. function ACS_PI : chtype; inline; { Pi }
  136. function ACS_NEQUAL : chtype; inline; { not equal }
  137. function ACS_STERLING : chtype; inline; { UK pound sign }
  138. (*
  139. * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
  140. * is the right, b is the bottom, and l is the left. t, r, b, and l might
  141. * be B (blank), S (single), D (double), or T (thick). The subset defined
  142. * here only uses B and S.
  143. *)
  144. {$IFDEF FPC_OBJFPC}
  145. property ACS_BSSB : chtype read ACS_ULCORNER;
  146. property ACS_SSBB : chtype read ACS_LLCORNER;
  147. property ACS_BBSS : chtype read ACS_URCORNER;
  148. property ACS_SBBS : chtype read ACS_LRCORNER;
  149. property ACS_SBSS : chtype read ACS_RTEE;
  150. property ACS_SSSB : chtype read ACS_LTEE;
  151. property ACS_SSBS : chtype read ACS_BTEE;
  152. property ACS_BSSS : chtype read ACS_TTEE;
  153. property ACS_BSBS : chtype read ACS_HLINE;
  154. property ACS_SBSB : chtype read ACS_VLINE;
  155. property ACS_SSSS : chtype read ACS_PLUS;
  156. {$ENDIF FPC_OBJFPC}
  157. const
  158. ERR = -(1);
  159. OK = 0;
  160. _SUBWIN = $01; { is this a sub-window? }
  161. _ENDLINE = $02; { is the window flush right? }
  162. _FULLWIN = $04; { is the window full-screen? }
  163. _SCROLLWIN = $08; { bottom edge is at screen bottom? }
  164. _ISPAD = $10; { is this window a pad? }
  165. _HASMOVED = $20; { has cursor moved since last refresh? }
  166. _WRAPPED = $40; { cursor was just wrappped }
  167. _NOCHANGE = -(1);
  168. {
  169. this value is used in the firstchar and lastchar fields to mark
  170. unchanged lines
  171. }
  172. _NEWINDEX = -(1);
  173. CCHARW_MAX = 5;
  174. type
  175. pattr_t = ^attr_t;
  176. attr_t = chtype; { ...must be at least as wide as chtype }
  177. pcchar_t = ^cchar_t;
  178. cchar_t = record
  179. attr : attr_t;
  180. chars : array[0..CCHARW_MAX - 1] of wchar_t;
  181. {$IFDEF NCURSES_EXT_COLORS}
  182. ext_color : cint; { color pair, must be more than 16-bits }
  183. {$ENDIF NCURSES_EXT_COLORS}
  184. end;
  185. ldat = record
  186. text : pcchar_t; { text of the line }
  187. firstchar : Smallint; { first changed character in the line }
  188. lastchar : Smallint; { last changed character in the line }
  189. oldindex : Smallint; { index of the line at last update }
  190. end;
  191. PWINDOW = ^TWINDOW;
  192. _win_st = record
  193. _cury, _curx : Smallint; { current cursor position }
  194. { window location and size }
  195. _maxy, _maxx : Smallint; { maximums of x and y, NOT window size }
  196. _begy, _begx : Smallint; { screen coords of upper-left-hand corner }
  197. _flags : Smallint; { window state flags }
  198. { attribute tracking }
  199. _attrs : attr_t; { current attribute for non-space character }
  200. _bkgd : chtype; { current background char/attribute pair }
  201. { option values set by user }
  202. _notimeout : Bool; { no time out on function-key entry? }
  203. _clear : Bool; { consider all data in the window invalid? }
  204. _leaveok : Bool; { OK to not reset cursor on exit? }
  205. _scroll : Bool; { OK to scroll this window? }
  206. _idlok : Bool; { OK to use insert/delete line? }
  207. _idcok : Bool; { OK to use insert/delete char? }
  208. _immed : Bool; { window in immed mode? (not yet used) }
  209. _sync : Bool; { window in sync mode? }
  210. _use_keypad : Bool; { process function keys into KEY_ symbols? }
  211. _delay : cint; { 0 = nodelay, <0 = blocking, >0 = delay }
  212. _line : ^ldat; { the actual line data }
  213. { global screen state }
  214. _regtop : Smallint; { top line of scrolling region }
  215. _regbottom : Smallint; { bottom line of scrolling region }
  216. { these are used only if this is a sub-window }
  217. _parx : cint; { x coordinate of this window in parent }
  218. _pary : cint; { y coordinate of this window in parent }
  219. _parent : PWINDOW; { pointer to parent if a sub-window }
  220. { these are used only if this is a pad }
  221. _pad : record
  222. _pad_y : Smallint;
  223. _pad_x : Smallint;
  224. _pad_top : Smallint;
  225. _pad_left : Smallint;
  226. _pad_bottom : Smallint;
  227. _pad_right : Smallint;
  228. end;
  229. _yoffset : Smallint; { real begy is _begy + _yoffset }
  230. _bkgrnd : cchar_t; { current background char/attribute pair }
  231. {$IFDEF NCURSES_EXT_COLORS}
  232. _color : cint; { current color-pair for non-space character }
  233. {$ENDIF NCURSES_EXT_COLORS}
  234. end;
  235. TWINDOW = _win_st;
  236. TSCREEN = TWINDOW;
  237. PSCREEN = ^TSCREEN;
  238. var
  239. {$IFNDEF darwin}
  240. stdscr : PWINDOW cvar; external;
  241. curscr : PWINDOW cvar; external;
  242. newscr : PWINDOW cvar; external;
  243. LINES : Longint cvar; external;
  244. COLS : Longint cvar; external;
  245. TABSIZE : Longint cvar; external;
  246. ESCDELAY: Longint cvar; external; { ESC expire time in milliseconds }
  247. {$ELSE darwin}
  248. stdscr : PWINDOW external libncurses name 'stdscr';
  249. curscr : PWINDOW external libncurses name 'curscr';
  250. newscr : PWINDOW external libncurses name 'newscr';
  251. LINES : Longint external libncurses name 'LINES';
  252. COLS : Longint external libncurses name 'COLS';
  253. TABSIZE : Longint external libncurses name 'TABSIZE';
  254. ESCDELAY: Longint external libncurses name 'ESCDELAY';
  255. {$ENDIF darwin}
  256. (*
  257. * These functions are extensions - not in XSI Curses.
  258. *)
  259. function is_term_resized(_para1:Longint; _para2:Longint):Bool;cdecl;external libncurses;
  260. function keybound(_para1:Longint; _para2:Longint):PChar;cdecl;external libncurses;
  261. function curses_version:PChar;cdecl;external libncurses;
  262. function assume_default_colors(_para1:Longint; _para2:Longint):Longint; cdecl;external libncurses;
  263. function define_key(_para1:PChar; _para2:Longint):Longint; cdecl;external libncurses;
  264. function key_defined(_para1:PChar):Longint; cdecl;external libncurses;
  265. function keyok(_para1:Longint; _para2:Bool):Longint; cdecl;external libncurses;
  266. function resize_term(_para1:Longint; _para2:Longint):Longint; cdecl;external libncurses;
  267. function resizeterm(_para1:Longint; _para2:Longint):Longint; cdecl;external libncurses;
  268. function use_default_colors:Longint;cdecl;external libncurses;
  269. function use_extended_names(_para1:Bool):Longint; cdecl;external libncurses;
  270. function use_legacy_coding(_para1:Longint):Longint; cdecl;external libncurses;
  271. function wresize(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
  272. procedure nofilter;cdecl;external libncurses;
  273. (*
  274. * Function prototypes. This is the complete XSI Curses list of required
  275. * functions.
  276. *)
  277. function baudrate:Longint; cdecl;external libncurses;
  278. function beep:Longint; cdecl;external libncurses;
  279. function can_change_color:Bool;cdecl;external libncurses;
  280. function cbreak:Longint; cdecl;external libncurses;
  281. //function color_content(_para1:Smallint; _para2:PSmallint; _para3:PSmallint; _para4:PSmallInt):Longint; cdecl;external libncurses;
  282. function color_content(color: NC_FPC_COLOR; r, g, b: PSmallint):Longint; cdecl;external libncurses;
  283. function copywin(_para1:PWINDOW; _para2:PWINDOW; _para3:Longint; _para4:Longint; _para5:Longint;
  284. _para6:Longint; _para7:Longint; _para8:Longint; _para9:Longint):Longint; cdecl;external libncurses;
  285. function curs_set(_para1:Longint):Longint; cdecl;external libncurses;
  286. function def_prog_mode:Longint; cdecl;external libncurses;
  287. function def_shell_mode:Longint; cdecl;external libncurses;
  288. function delay_output(_para1:Longint):Longint; cdecl;external libncurses;
  289. procedure delscreen(_para1:PSCREEN);cdecl;external libncurses;
  290. function delwin(_para1:PWINDOW):Longint; cdecl;external libncurses;
  291. function derwin(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint):PWINDOW;cdecl;external libncurses;
  292. function doupdate:Longint; cdecl;external libncurses;
  293. function dupwin(_para1:PWINDOW):PWINDOW;cdecl;external libncurses;
  294. function echo:Longint; cdecl;external libncurses;
  295. function endwin:Longint; cdecl;external libncurses;
  296. function erasechar:PChar;cdecl;external libncurses;
  297. procedure filter;cdecl;external libncurses;
  298. function flash:Longint; cdecl;external libncurses;
  299. function flushinp:Longint; cdecl;external libncurses;
  300. function getwin(_para1:PFILE):PWINDOW;cdecl;external libncurses;
  301. function halfdelay(_para1:Longint):Longint; cdecl;external libncurses;
  302. function has_colors:Bool;cdecl;external libncurses;
  303. function has_ic:Bool;cdecl;external libncurses;
  304. function has_il:Bool;cdecl;external libncurses;
  305. procedure idcok(_para1:PWINDOW; _para2:Bool);cdecl;external libncurses;
  306. function idlok(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  307. procedure immedok(_para1:PWINDOW; _para2:Bool);cdecl;external libncurses;
  308. function initscr:PWINDOW;cdecl;external libncurses;
  309. //function init_color(_para1:Smallint; _para2:Smallint; _para3:Smallint; _para4:Smallint):Longint; cdecl;external libncurses;
  310. function init_color(color: NC_FPC_COLOR; r, g, b: Smallint):Longint; cdecl;external libncurses;
  311. //function init_pair(_para1:Smallint; _para2:Smallint; _para3:Smallint):Longint; cdecl;external libncurses;
  312. function init_pair(pair: Smallint; f, b: NC_FPC_COLOR):Longint; cdecl;external libncurses; overload;
  313. function intrflush(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  314. function isendwin:Bool;cdecl;external libncurses;
  315. function is_linetouched(_para1:PWINDOW; _para2:Longint):Bool;cdecl;external libncurses;
  316. function is_wintouched(_para1:PWINDOW):Bool;cdecl;external libncurses;
  317. function keyname(_para1:Longint):PChar;cdecl;external libncurses;
  318. function keypad(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  319. function killchar:PChar;cdecl;external libncurses;
  320. function leaveok(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  321. function longname:PChar;cdecl;external libncurses;
  322. function meta(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  323. function mvcur(_para1:Longint; _para2:Longint; _para3:Longint; _para4:Longint):Longint; cdecl;external libncurses;
  324. function mvderwin(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
  325. function mvwin(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
  326. function napms(_para1:Longint):Longint; cdecl;external libncurses;
  327. function newpad(_para1:Longint; _para2:Longint):PWINDOW;cdecl;external libncurses;
  328. function newterm(_para1:PChar; _para2:PFILE; _para3:PFILE):PSCREEN;cdecl;external libncurses;
  329. function newwin(_para1:Longint; _para2:Longint; _para3:Longint; _para4:Longint):PWINDOW;cdecl;external libncurses;
  330. function nl:Longint; cdecl;external libncurses;
  331. function nocbreak:Longint; cdecl;external libncurses;
  332. function nodelay(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  333. function noecho:Longint; cdecl;external libncurses;
  334. function nonl:Longint; cdecl;external libncurses;
  335. procedure noqiflush;cdecl;external libncurses;
  336. function noraw:Longint; cdecl;external libncurses;
  337. function notimeout(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  338. function overlay(_para1:PWINDOW; _para2:PWINDOW):Longint; cdecl;external libncurses;
  339. function overwrite(_para1:PWINDOW; _para2:PWINDOW):Longint; cdecl;external libncurses;
  340. //function pair_content(_para1:Smallint; _para2:PSmallint; _para3:PSmallInt):Longint; cdecl;external libncurses;
  341. function pair_content(pair: Smallint; f, b: pNC_FPC_COLOR):Longint; cdecl;external libncurses;
  342. function pechochar(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
  343. function pnoutrefresh(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint;
  344. _para6:Longint; _para7:Longint):Longint; cdecl;external libncurses;
  345. function prefresh(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint;
  346. _para6:Longint; _para7:Longint):Longint; cdecl;external libncurses;
  347. function putwin(_para1:PWINDOW; _para2:PFILE):Longint; cdecl;external libncurses;
  348. procedure qiflush;cdecl;external libncurses;
  349. function raw:Longint; cdecl;external libncurses;
  350. function resetty:Longint; cdecl;external libncurses;
  351. function reset_prog_mode:Longint; cdecl;external libncurses;
  352. function reset_shell_mode:Longint; cdecl;external libncurses;
  353. type TWinInit = function (win: PWINDOW; ncols: Longint): Longint; cdecl;
  354. function ripoffline(line: Longint; init: TWinInit):Longint; cdecl;external libncurses;
  355. function savetty:Longint; cdecl;external libncurses;
  356. function scr_dump(_para1:PChar):Longint; cdecl;external libncurses;
  357. function scr_init(_para1:PChar):Longint; cdecl;external libncurses;
  358. function scrollok(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  359. function scr_restore(_para1:PChar):Longint; cdecl;external libncurses;
  360. function scr_set(_para1:PChar):Longint; cdecl;external libncurses;
  361. function set_term(_para1:PSCREEN):PSCREEN;cdecl;external libncurses;
  362. function slk_attroff(_para1:chtype):Longint; cdecl;external libncurses;
  363. function slk_attron(_para1:chtype):Longint; cdecl;external libncurses;
  364. function slk_attrset(_para1:chtype):Longint; cdecl;external libncurses;
  365. function slk_attr:attr_t;cdecl;external libncurses;
  366. function slk_attr_set(_para1:attr_t; _para2:Smallint; _para3:Pointer):Longint; cdecl;external libncurses;
  367. function slk_clear:Longint; cdecl;external libncurses;
  368. function slk_color(_para1:Smallint):Longint; cdecl;external libncurses;
  369. function slk_init(_para1:Longint):Longint; cdecl;external libncurses;
  370. function slk_label(_para1:Longint):PChar;cdecl;external libncurses;
  371. function slk_noutrefresh:Longint; cdecl;external libncurses;
  372. function slk_refresh:Longint; cdecl;external libncurses;
  373. function slk_restore:Longint; cdecl;external libncurses;
  374. function slk_set(_para1:Longint; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
  375. function slk_touch:Longint; cdecl;external libncurses;
  376. function start_color:Longint; cdecl;external libncurses;
  377. function subpad(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint):PWINDOW;cdecl;external libncurses;
  378. function subwin(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint):PWINDOW;cdecl;external libncurses;
  379. function syncok(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
  380. function termattrs:chtype;cdecl;external libncurses;
  381. function termname:PChar;cdecl;external libncurses;
  382. function typeahead(_para1:Longint):Longint; cdecl;external libncurses;
  383. function ungetch(_para1:Longint):Longint; cdecl;external libncurses;
  384. procedure use_env(_para1:Bool);cdecl;external libncurses;
  385. function vidattr(_para1:chtype):Longint; cdecl;external libncurses;
  386. function waddch(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
  387. function waddchnstr(_para1:PWINDOW; _para2:Pchtype; _para3:Longint):Longint; cdecl;external libncurses;
  388. function waddnstr(_para1:PWINDOW; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
  389. function wattr_on(_para1:PWINDOW; _para2:attr_t; _para3:Pointer):Longint; cdecl;external libncurses;
  390. function wattr_off(_para1:PWINDOW; _para2:attr_t; _para3:Pointer):Longint; cdecl;external libncurses;
  391. function wbkgd(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
  392. procedure wbkgdset(_para1:PWINDOW; _para2:chtype);cdecl;external libncurses;
  393. function wborder(_para1:PWINDOW; _para2:chtype; _para3:chtype; _para4:chtype; _para5:chtype;
  394. _para6:chtype; _para7:chtype; _para8:chtype; _para9:chtype):Longint; cdecl;external libncurses;
  395. function wchgat(_para1:PWINDOW; _para2:Longint; _para3:attr_t; _para4:Smallint; _para5:Pointer):Longint; cdecl;external libncurses;
  396. function wclear(_para1:PWINDOW):Longint; cdecl;external libncurses;
  397. function wclrtobot(_para1:PWINDOW):Longint; cdecl;external libncurses;
  398. function wclrtoeol(_para1:PWINDOW):Longint; cdecl;external libncurses;
  399. function wcolor_set(_para1:PWINDOW; _para2:Smallint; _para3:Pointer):Longint; cdecl;external libncurses;
  400. procedure wcursyncup(_para1:PWINDOW);cdecl;external libncurses;
  401. function wdelch(_para1:PWINDOW):Longint; cdecl;external libncurses;
  402. function wechochar(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
  403. function werase(_para1:PWINDOW):Longint; cdecl;external libncurses;
  404. function wgetch(_para1:PWINDOW):Longint; cdecl;external libncurses;
  405. function wgetnstr(_para1:PWINDOW; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
  406. function whline(_para1:PWINDOW; _para2:chtype; _para3:Longint):Longint; cdecl;external libncurses;
  407. function winch(_para1:PWINDOW):chtype;cdecl;external libncurses;
  408. function winchnstr(_para1:PWINDOW; _para2:Pchtype; _para3:Longint):Longint; cdecl;external libncurses;
  409. function winnstr(_para1:PWINDOW; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
  410. function winsch(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
  411. function winsdelln(_para1:PWINDOW; _para2:Longint):Longint; cdecl;external libncurses;
  412. function winsnstr(_para1:PWINDOW; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
  413. { realised as inline function }
  414. //function wmove(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
  415. function wnoutrefresh(_para1:PWINDOW):Longint; cdecl;external libncurses;
  416. function wredrawln(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
  417. function wrefresh(_para1:PWINDOW):Longint; cdecl;external libncurses;
  418. function wscrl(_para1:PWINDOW; _para2:Longint):Longint; cdecl;external libncurses;
  419. function wsetscrreg(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
  420. procedure wsyncdown(_para1:PWINDOW);cdecl;external libncurses;
  421. procedure wsyncup(_para1:PWINDOW);cdecl;external libncurses;
  422. procedure wtimeout(_para1:PWINDOW; _para2:Longint);cdecl;external libncurses;
  423. function wtouchln(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint):Longint; cdecl;external libncurses;
  424. function wvline(_para1:PWINDOW; _para2:chtype; _para3:Longint):Longint; cdecl;external libncurses;
  425. (*
  426. * These are also declared in <ncursesw/term.h>:
  427. *)
  428. function tigetflag(_para1:PChar):Longint; cdecl;external libncurses;
  429. function tigetnum(_para1:PChar):Longint; cdecl;external libncurses;
  430. function tigetstr(_para1:PChar):PChar;cdecl;external libncurses;
  431. function putp(_para1:PChar):Longint; cdecl;external libncurses;
  432. var
  433. {$IFNDEF darwin}
  434. ttytype : array of PChar cvar; external; { needed for backward compatibility }
  435. {$ELSE darwin}
  436. ttytype : array of PChar external libncurses name 'ttytype';
  437. {$ENDIF darwin}
  438. (*
  439. * Function prototypes for wide-character operations.
  440. *)
  441. {function vid_puts(_para1:attr_t; _para2:Smallint; _para3:pointer; _para4:function (_para1:cint):cint):longint; cdecl;external libncurses;
  442. function vidputs(_para1:chtype; _para2:function (_para1:Longint):Longint):Longint; cdecl;external libncurses;}
  443. type TPutc = function(arg:Longint):Longint; cdecl;
  444. function vid_puts(attrs:attr_t; pair:Smallint; opts:Pointer; _putc:TPutc):Longint; cdecl;external libncurses;
  445. function vidputs(attrs:chtype; _putc:TPutc):Longint; cdecl;external libncurses;
  446. function erasewchar(_para1:Pwchar_t):Longint; cdecl;external libncurses;
  447. function getcchar(_para1:Pcchar_t; _para2:Pwchar_t; _para3:Pattr_t; _para4:PSmallInt; _para5:Pointer):Longint; cdecl;external libncurses;
  448. function key_name(_para1:wchar_t):PChar;cdecl;external libncurses;
  449. function killwchar(_para1:Pwchar_t):Longint; cdecl;external libncurses;
  450. function pecho_wchar(_para1:PWINDOW; _para2:Pcchar_t):Longint; cdecl;external libncurses;
  451. function setcchar(_para1:Pcchar_t; _para2:Pwchar_t; _para3:attr_t; _para4:Smallint; _para5:Pointer):Longint; cdecl;external libncurses;
  452. function slk_wset(_para1:Longint; _para2:Pwchar_t; _para3:Longint):Longint; cdecl;external libncurses;
  453. function term_attrs:attr_t;cdecl;external libncurses;
  454. function unget_wch(_para1:wchar_t):longint; cdecl;external libncurses;
  455. function vid_attr(_para1:attr_t; _para2:Smallint; _para3:pointer):longint; cdecl;external libncurses;
  456. function wadd_wch(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
  457. function wadd_wchnstr(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
  458. function waddnwstr(_para1:PWINDOW; _para2:Pwchar_t; _para3:Longint):longint; cdecl;external libncurses;
  459. function wbkgrnd(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
  460. procedure wbkgrndset(_para1:PWINDOW; _para2:Pcchar_t);cdecl;external libncurses;
  461. function wborder_set(_para1:PWINDOW; _para2:Pcchar_t; _para3:Pcchar_t; _para4:Pcchar_t; _para5:Pcchar_t;
  462. _para6:Pcchar_t; _para7:Pcchar_t; _para8:Pcchar_t; _para9:Pcchar_t):longint; cdecl;external libncurses;
  463. function wecho_wchar(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
  464. function wget_wch(_para1:PWINDOW; _para2:PLongint):longint; cdecl;external libncurses;
  465. function wgetbkgrnd(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
  466. function wgetn_wstr(_para1:PWINDOW; _para2:PLongint; _para3:Longint):longint; cdecl;external libncurses;
  467. function whline_set(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
  468. function win_wch(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
  469. function win_wchnstr(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
  470. function winnwstr(_para1:PWINDOW; _para2:Pwchar_t; _para3:Longint):longint; cdecl;external libncurses;
  471. function wins_nwstr(_para1:PWINDOW; _para2:Pwchar_t; _para3:Longint):longint; cdecl;external libncurses;
  472. function wins_wch(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
  473. function winwstr(_para1:PWINDOW; _para2:Pwchar_t):longint; cdecl;external libncurses;
  474. function wunctrl(_para1:Pcchar_t):Pwchar_t;cdecl;external libncurses;
  475. function wvline_set(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
  476. const
  477. A_NORMAL = 0;
  478. A_ATTRIBUTES = (not 0) shl 8;
  479. A_CHARTEXT=(1 shl (0 + 8)) - 1;
  480. A_COLOR=((1 shl 8) - 1) shl 8;
  481. A_STANDOUT = 1 shl (8 + 8);
  482. A_UNDERLINE = 1 shl (9 + 8);
  483. A_REVERSE = 1 shl (10 + 8);
  484. A_BLINK = 1 shl (11 + 8);
  485. A_DIM = 1 shl (12 + 8);
  486. A_BOLD = 1 shl (13 + 8);
  487. A_ALTCHARSET = 1 shl (14 + 8);
  488. A_INVIS = 1 shl (15 + 8);
  489. A_PROTECT = 1 shl (16 + 8);
  490. A_HORIZONTAL = 1 shl (17 + 8);
  491. A_LEFT = 1 shl (18 + 8);
  492. A_LOW = 1 shl (19 + 8);
  493. A_RIGHT = 1 shl (20 + 8);
  494. A_TOP = 1 shl (21 + 8);
  495. A_VERTICAL = 1 shl (22 + 8);
  496. const
  497. WA_ATTRIBUTES = A_ATTRIBUTES;
  498. WA_NORMAL = A_NORMAL;
  499. WA_STANDOUT = A_STANDOUT;
  500. WA_UNDERLINE = A_UNDERLINE;
  501. WA_REVERSE = A_REVERSE;
  502. WA_BLINK = A_BLINK;
  503. WA_DIM = A_DIM;
  504. WA_BOLD = A_BOLD;
  505. WA_ALTCHARSET = A_ALTCHARSET;
  506. WA_INVIS = A_INVIS;
  507. WA_PROTECT = A_PROTECT;
  508. WA_HORIZONTAL = A_HORIZONTAL;
  509. WA_LEFT = A_LEFT;
  510. WA_LOW = A_LOW;
  511. WA_RIGHT = A_RIGHT;
  512. WA_TOP = A_TOP;
  513. WA_VERTICAL = A_VERTICAL;
  514. function COLOR_PAIR(n: cint): cint; inline;
  515. function PAIR_NUMBER(attr: attr_t): longint; inline;
  516. function color_set(color_pair_number: Smallint; opts: Pointer): longint; inline;
  517. (* pseudo functions *)
  518. function wgetstr(win: PWINDOW; s: PChar): Longint;
  519. function getnstr(s: PChar;n: Longint): Longint; inline;
  520. function setterm(term: PChar): Longint; inline;
  521. function fixterm: Longint; inline;
  522. function resetterm: Longint; inline;
  523. function saveterm: Longint; inline;
  524. function crmode: Longint; inline;
  525. function nocrmode: Longint; inline;
  526. // formal parameter versions not endiansafe?
  527. procedure getyx (win: PWINDOW; var y,x: Smallint); inline; overload;
  528. procedure getbegyx(win: PWINDOW; var y,x: Smallint); inline; overload;
  529. procedure getmaxyx(win: PWINDOW; var y,x: Smallint); inline; overload;
  530. procedure getparyx(win: PWINDOW; var y,x: Smallint); inline; overload;
  531. procedure getsyx (var y,x: Smallint); inline; overload;
  532. procedure getyx (win: PWINDOW; var y,x: Longint); inline; overload;
  533. procedure getbegyx(win: PWINDOW; var y,x: Longint); inline; overload;
  534. procedure getmaxyx(win: PWINDOW; var y,x: Longint); inline; overload;
  535. procedure getparyx(win: PWINDOW; var y,x: Longint); inline; overload;
  536. procedure getsyx (var y,x: Longint); inline; overload;
  537. procedure setsyx (y,x: Smallint); inline;
  538. function getattrs(win: PWINDOW): attr_t; inline;
  539. function getcurx(win: PWINDOW): Smallint; inline;
  540. function getcury(win: PWINDOW): Smallint; inline;
  541. function getbegx(win: PWINDOW): Smallint; inline;
  542. function getbegy(win: PWINDOW): Smallint; inline;
  543. function getmaxx(win: PWINDOW): Smallint; inline;
  544. function getmaxy(win: PWINDOW): Smallint; inline;
  545. function getparx(win: PWINDOW): Smallint; inline;
  546. function getpary(win: PWINDOW): Smallint; inline;
  547. function wstandout(win: PWINDOW): Longint; inline;
  548. function wstandend(win: PWINDOW): Longint; inline;
  549. function wattr_set(win:PWINDOW; attrs:attr_t; pair:Smallint; opts:Pointer):Longint; inline;
  550. //function wattr_get(win: PWINDOW): longint;// original fpc ncurses?
  551. function wattr_get(win:PWINDOW; attrs:Pattr_t; pair:PSmallint; opts:Pointer):longint; // inline; breaks compilation on some architectures currently
  552. function wattron(win:PWINDOW; attrs: attr_t): Longint; inline;
  553. function wattroff(win:PWINDOW; attrs: attr_t): Longint; inline;
  554. function wattrset(win: PWINDOW; attrs: attr_t): longint; inline;
  555. function scroll(win: PWINDOW): longint; inline;
  556. function touchwin(win: PWINDOW): longint; inline;
  557. function touchline(win: PWINDOW;s,c: longint): longint; inline;
  558. function untouchwin(win: PWINDOW): longint; inline;
  559. function box(win:PWINDOW; v,h :chtype):Longint; inline;
  560. function border(ls,rs,ts,bs,tl,tr,bl,br: chtype): longint; inline;
  561. function hline(ch:chtype; n:longint): longint; inline;
  562. function vline(ch:chtype; n:longint): longint; inline;
  563. function winstr(win: PWINDOW;s: PChar): longint; inline;
  564. function winchstr(win: PWINDOW; chstr: pchtype): longint; inline;
  565. function winsstr(win: PWINDOW;s: PChar): longint; inline;
  566. function redrawwin(win: PWINDOW): longint; inline;
  567. function waddstr(win: PWINDOW;st: PChar): longint; inline;
  568. function waddchstr(win: PWINDOW; chstr: pchtype): longint; inline;
  569. {
  570. pseudo functions for standard screen
  571. }
  572. function addch(ch: chtype): longint; inline;
  573. function addchnstr(chstr: pchtype; n: longint): longint; inline;
  574. function addchstr(chstr: pchtype): longint; inline;
  575. function addnstr(str: PChar;n: longint): longint; inline;
  576. function addstr(str: PChar): longint; inline;
  577. function attroff(attrs: attr_t): longint; inline;
  578. function attron(attrs: attr_t): longint; inline;
  579. function attrset(attrs: attr_t): longint; inline;
  580. function bkgd(ch: chtype): longint; inline;
  581. procedure bkgdset(ch: chtype); inline;
  582. function clear: longint; inline;
  583. function clrtobot: longint; inline;
  584. function clrtoeol: longint; inline;
  585. function delch: longint; inline;
  586. function deleteln: longint; inline;
  587. function echochar(ch: chtype): longint; inline;
  588. function erase: longint; inline;
  589. function getch: longint; inline;
  590. function getstr(str: PChar): longint; inline;
  591. function inch: chtype; inline;
  592. function inchnstr(chstr: pchtype;n: longint): longint; inline;
  593. function inchstr(chstr: pchtype): longint; inline;
  594. function innstr(str: PChar;n: longint): longint; inline;
  595. function insch(ch: chtype): longint; inline;
  596. function insdelln(n: longint): longint; inline;
  597. function insertln: longint; inline;
  598. function insnstr(str: PChar;n: longint): longint; inline;
  599. function insstr(str: PChar): longint; inline;
  600. function instr(str: PChar): longint; inline;
  601. function move(y,x: Smallint): longint; inline;
  602. function refresh: longint; inline;
  603. function scrl(n: longint): longint; inline;
  604. function setscrreg(t,b: longint): longint; inline;
  605. function standend: longint; inline;
  606. function standout: longint; inline;
  607. procedure timeout(delay: longint); inline;
  608. function wdeleteln(win: PWINDOW): longint; inline;
  609. function winsertln(win: PWINDOW): longint; inline;
  610. {
  611. mv functions
  612. }
  613. function mvwaddch(win: PWINDOW;y,x: Smallint; ch: chtype): longint; inline;
  614. function mvwaddchnstr(win: PWINDOW;y,x: Smallint; chstr: pchtype; n: longint): longint; inline;
  615. function mvwaddchstr(win: PWINDOW;y,x: Smallint; chstr: pchtype): longint; inline;
  616. function mvwaddnstr(win: PWINDOW;y,x: Smallint; str: PChar; n: longint): longint; inline;
  617. function mvwaddstr(win: PWINDOW;y,x: Smallint; str: PChar): longint; inline;
  618. function mvwdelch(win: PWINDOW; y,x: Smallint): longint;
  619. function mvwchgat(win: PWINDOW;y, x: Smallint; n: Longint;attr: attr_t;
  620. color: Smallint; opts: Pointer): longint; inline;
  621. function mvwgetch(win: PWINDOW; y,x: Smallint): longint; inline;
  622. function mvwgetnstr(win: PWINDOW; y,x: Smallint; str: PChar; n: longint): longint; inline;
  623. function mvwgetstr(win: PWINDOW; y,x: Smallint; str: PChar): longint; inline;
  624. function mvwhline(win: PWINDOW; y,x: Smallint; ch: chtype; n: longint): longint; inline;
  625. function mvwinch(win: PWINDOW;y,x: Smallint): chtype; inline;
  626. function mvwinchnstr(win: PWINDOW;y,x: Smallint;chstr: pchtype; n: longint): longint; inline;
  627. function mvwinchstr(win: PWINDOW;y,x: Smallint;chstr: pchtype): longint; inline;
  628. function mvwinnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint; inline;
  629. function mvwinsch(win: PWINDOW;y,x: Smallint;ch: chtype): longint; inline;
  630. function mvwinsnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint; inline;
  631. function mvwinsstr(win: PWINDOW;y,x: Smallint;str: PChar): longint; inline;
  632. function mvwinstr(win: PWINDOW;y,x: Smallint;str: PChar): longint; inline;
  633. function mvwvline(win: PWINDOW;y,x: Smallint;ch: chtype;n: longint): longint; inline;
  634. function mvaddch(y,x: Smallint; ch: chtype): longint; inline;
  635. function mvaddchnstr(y,x: Smallint; chstr: pchtype;n: longint): longint; inline;
  636. function mvaddchstr(y,x: Smallint; chstr: pchtype): longint; inline;
  637. function mvaddnstr(y,x: Smallint; str: PChar;n: longint): longint; inline;
  638. function mvaddstr(y,x: Smallint; str: PChar): longint; inline;
  639. function mvdelch(y,x: Smallint): longint; inline;
  640. function mvgetch(y,x: Smallint): longint; inline;
  641. function mvgetnstr(y,x: Smallint; str: PChar;n: longint): longint; inline;
  642. function mvgetstr(y,x: Smallint; str: PChar): longint; inline;
  643. function mvhline(y,x: Smallint;ch: chtype;n: longint): longint; inline;
  644. function mvinch(y,x: Smallint): chtype; inline;
  645. function mvinchnstr(y,x: Smallint; chstr: pchtype;n: longint): longint; inline;
  646. function mvinchstr(y,x: Smallint; chstr: pchtype): longint; inline;
  647. function mvinnstr(y,x: Smallint; str: PChar;n: longint): longint; inline;
  648. function mvinsch(y,x: Smallint;ch: chtype): longint; inline;
  649. function mvinsnstr(y,x: Smallint; str: PChar;n: longint): longint; inline;
  650. function mvinsstr(y,x: Smallint; str: PChar): longint; inline;
  651. function mvinstr(y,x: Smallint; str: PChar): longint; inline;
  652. function mvvline(y,x: Smallint; ch:chtype; n:longint): longint; inline;
  653. function attr_get(attrs:Pattr_t; pair:PSmallint; opts:Pointer): longint; inline;
  654. function attr_off(attrs:attr_t; opts:Pointer): longint; inline;
  655. function attr_on(attrs:attr_t; opts:Pointer): longint; inline;
  656. function attr_set(attrs:attr_t; pair:Smallint; opts:Pointer): longint; inline;
  657. function chgat(n: Longint;attr: attr_t;color: Smallint; opts: Pointer): longint; inline;
  658. {not present in fpc ncurses}
  659. function mvchgat(y, x: Smallint; n: Longint;attr: attr_t;color: Smallint; opts: Pointer):Longint; inline;
  660. function getbkgd(win: PWINDOW): chtype; inline;
  661. function slk_attr_off(attrs: attr_t; opts: Pointer) : longint; inline;
  662. function slk_attr_on(attrs: attr_t; opts: Pointer): longint; inline;
  663. (*
  664. * Pseudo-character tokens outside ASCII range. The curses wgetch() function
  665. * will return any given one of these only if the corresponding k- capability
  666. * is defined in your terminal's terminfo entry.
  667. *
  668. * Some keys (KEY_A1, etc) are arranged like this:
  669. * a1 up a3
  670. * left b2 right
  671. * c1 down c3
  672. *
  673. * A few key codes do not depend upon the terminfo entry.
  674. *)
  675. const
  676. KEY_CODE_YES = 256; { A wchar_t contains a key code &0400 }
  677. KEY_MIN = 257; { Minimum curses key &0401 }
  678. KEY_BREAK = 257; { Break key (unreliable) &0401 }
  679. KEY_SRESET = 344; { Soft (partial) reset (unreliable) &0530 }
  680. KEY_RESET = 345; { Reset or hard reset (unreliable) &0531 }
  681. KEY_DOWN = 258; { down-arrow key &0402 }
  682. KEY_UP = 259; { up-arrow key &0403 }
  683. KEY_LEFT = 260; { left-arrow key &0404 }
  684. KEY_RIGHT = 261; { right-arrow key &0405 }
  685. KEY_HOME = 262; { home key &0406 }
  686. KEY_BACKSPACE = 263; { backspace key &0407 }
  687. KEY_F0 = 264; { Function keys. Space for 64 &0410 }
  688. { Manually Added KEY_F1 .. KEY_F12 }
  689. KEY_F1 = KEY_F0 + 1;
  690. KEY_F2 = KEY_F0 + 2;
  691. KEY_F3 = KEY_F0 + 3;
  692. KEY_F4 = KEY_F0 + 4;
  693. KEY_F5 = KEY_F0 + 5;
  694. KEY_F6 = KEY_F0 + 6;
  695. KEY_F7 = KEY_F0 + 7;
  696. KEY_F8 = KEY_F0 + 8;
  697. KEY_F9 = KEY_F0 + 9;
  698. KEY_F10 = KEY_F0 + 10;
  699. KEY_F11 = KEY_F0 + 11;
  700. KEY_F12 = KEY_F0 + 12;
  701. function KEY_F(n : Byte) : chtype; inline;
  702. const
  703. KEY_DL = 328; { delete-line key &0510 }
  704. KEY_IL = 329; { insert-line key &0511 }
  705. KEY_DC = 330; { delete-character key &0512 }
  706. KEY_IC = 331; { insert-character key &0513 }
  707. KEY_EIC = 332; { sent by rmir or smir in insert mode &0514 }
  708. KEY_CLEAR = 333; { clear-screen or erase key &0515 }
  709. KEY_EOS = 334; { clear-to-end-of-screen key &0516 }
  710. KEY_EOL = 335; { clear-to-end-of-line key &0517 }
  711. KEY_SF = 336; { scroll-forward key &0520 }
  712. KEY_SR = 337; { scroll-backward key &0521 }
  713. KEY_NPAGE = 338; { next-page key &0522 }
  714. KEY_PPAGE = 339; { previous-page key &0523 }
  715. KEY_STAB = 340; { set-tab key &0524 }
  716. KEY_CTAB = 341; { clear-tab key &0525 }
  717. KEY_CATAB = 342; { clear-all-tabs key &0526 }
  718. KEY_ENTER = 343; { enter/send key &0527 }
  719. KEY_PRINT = 346; { print key &0532 }
  720. KEY_LL = 347; { lower-left key (home down) &0533 }
  721. KEY_A1 = 348; { upper left of keypad &0534 }
  722. KEY_A3 = 349; { upper right of keypad &0535 }
  723. KEY_B2 = 350; { center of keypad &0536 }
  724. KEY_C1 = 351; { lower left of keypad &0537 }
  725. KEY_C3 = 352; { lower right of keypad &0540 }
  726. KEY_BTAB = 353; { back-tab key &0541 }
  727. KEY_BEG = 354; { begin key &0542 }
  728. KEY_CANCEL = 355; { cancel key &0543 }
  729. KEY_CLOSE = 356; { close key &0544 }
  730. KEY_COMMAND = 357; { command key &0545 }
  731. KEY_COPY = 358; { copy key &0546 }
  732. KEY_CREATE = 359; { create key &0547 }
  733. KEY_END = 360; { end key &0550 }
  734. KEY_EXIT = 361; { exit key &0551 }
  735. KEY_FIND = 362; { find key &0552 }
  736. KEY_HELP = 363; { help key &0553 }
  737. KEY_MARK = 364; { mark key &0554 }
  738. KEY_MESSAGE = 365; { message key &0555 }
  739. KEY_MOVE = 366; { move key &0556 }
  740. KEY_NEXT = 367; { next key &0557 }
  741. KEY_OPEN = 368; { open key &0560 }
  742. KEY_OPTIONS = 369; { options key &0561 }
  743. KEY_PREVIOUS = 370; { previous key &0562 }
  744. KEY_REDO = 371; { redo key &0563 }
  745. KEY_REFERENCE = 372; { reference key &0564 }
  746. KEY_REFRESH = 373; { refresh key &0565 }
  747. KEY_REPLACE = 374; { replace key &0566 }
  748. KEY_RESTART = 375; { restart key &0567 }
  749. KEY_RESUME = 376; { resume key &0570 }
  750. KEY_SAVE = 377; { save key &0571 }
  751. KEY_SBEG = 378; { shifted begin key &0572 }
  752. KEY_SCANCEL = 379; { shifted cancel key &0573 }
  753. KEY_SCOMMAND = 380; { shifted command key &0574 }
  754. KEY_SCOPY = 381; { shifted copy key &0575 }
  755. KEY_SCREATE = 382; { shifted create key &0576 }
  756. KEY_SDC = 383; { shifted delete-character key &0577 }
  757. KEY_SDL = 384; { shifted delete-line key &0600 }
  758. KEY_SELECT = 385; { select key &0601 }
  759. KEY_SEND = 386; { shifted end key &0602 }
  760. KEY_SEOL = 387; { shifted clear-to-end-of-line key &0603 }
  761. KEY_SEXIT = 388; { shifted exit key &0604 }
  762. KEY_SFIND = 389; { shifted find key &0605 }
  763. KEY_SHELP = 390; { shifted help key &0606 }
  764. KEY_SHOME = 391; { shifted home key &0607 }
  765. KEY_SIC = 392; { shifted insert-character key &0610 }
  766. KEY_SLEFT = 393; { shifted left-arrow key &0611 }
  767. KEY_SMESSAGE = 394; { shifted message key &0612 }
  768. KEY_SMOVE = 395; { shifted move key &0613 }
  769. KEY_SNEXT = 396; { shifted next key &0614 }
  770. KEY_SOPTIONS = 397; { shifted options key &0615 }
  771. KEY_SPREVIOUS = 398; { shifted previous key &0616 }
  772. KEY_SPRINT = 399; { shifted print key &0617 }
  773. KEY_SREDO = 400; { shifted redo key &0620 }
  774. KEY_SREPLACE = 401; { shifted replace key &0621 }
  775. KEY_SRIGHT = 402; { shifted right-arrow key &0622 }
  776. KEY_SRSUME = 403; { shifted resume key &0623 }
  777. KEY_SSAVE = 404; { shifted save key &0624 }
  778. KEY_SSUSPEND = 405; { shifted suspend key &0625 }
  779. KEY_SUNDO = 406; { shifted undo key &0626 }
  780. KEY_SUSPEND = 407; { suspend key &0627 }
  781. KEY_UNDO = 408; { undo key &0630}
  782. KEY_MOUSE = 409; { Mouse event has occurred &0631 }
  783. KEY_RESIZE = 410; { Terminal resize event &0632 }
  784. KEY_EVENT = 411; { We were interrupted by an event &0633 }
  785. KEY_MAX = 511; { Maximum key value is 0633 &0777 }
  786. type
  787. //tnc_wacs= array [char] of cchar_t;
  788. tnc_wacs= array of cchar_t;
  789. pnc_wacs = ^tacs_map;
  790. var
  791. {$IFNDEF darwin}
  792. //_nc_wacs : pcchar_t cvar; external;
  793. _nc_wacs : tnc_wacs cvar; external;
  794. {$ELSE darwin}
  795. //_nc_wacs : pcchar_t external libncurses name '_nc_wacs';
  796. _nc_wacs : tnc_wacs external libncurses name '_nc_wacs';
  797. {$ENDIF darwin}
  798. function NCURSES_WACS(c: chtype): cchar_t; inline;
  799. function WACS_BSSB: cchar_t; inline;
  800. function WACS_SSBB: cchar_t; inline;
  801. function WACS_BBSS: cchar_t; inline;
  802. function WACS_SBBS: cchar_t; inline;
  803. function WACS_SBSS: cchar_t; inline;
  804. function WACS_SSSB: cchar_t; inline;
  805. function WACS_SSBS: cchar_t; inline;
  806. function WACS_BSSS: cchar_t; inline;
  807. function WACS_BSBS: cchar_t; inline;
  808. function WACS_SBSB: cchar_t; inline;
  809. function WACS_SSSS: cchar_t; inline;
  810. function WACS_S1: cchar_t; inline;
  811. function WACS_S9: cchar_t; inline;
  812. function WACS_DIAMOND: cchar_t; inline;
  813. function WACS_CKBOARD: cchar_t; inline;
  814. function WACS_DEGREE: cchar_t; inline;
  815. function WACS_PLMINUS: cchar_t; inline;
  816. function WACS_BULLET: cchar_t; inline;
  817. function WACS_LARROW: cchar_t; inline;
  818. function WACS_RARROW: cchar_t; inline;
  819. function WACS_DARROW: cchar_t; inline;
  820. function WACS_UARROW: cchar_t; inline;
  821. function WACS_BOARD: cchar_t; inline;
  822. function WACS_LANTERN: cchar_t; inline;
  823. function WACS_BLOCK: cchar_t; inline;
  824. function WACS_S3: cchar_t; inline;
  825. function WACS_S7: cchar_t; inline;
  826. function WACS_LEQUAL: cchar_t; inline;
  827. function WACS_GEQUAL: cchar_t; inline;
  828. function WACS_PI: cchar_t; inline;
  829. function WACS_NEQUAL: cchar_t; inline;
  830. function WACS_STERLING: cchar_t; inline;
  831. {$IFDEF FPC_OBJFPC}
  832. property WACS_ULCORNER : cchar_t read WACS_BSSB;
  833. property WACS_LLCORNER : cchar_t read WACS_SSBB;
  834. property WACS_URCORNER : cchar_t read WACS_BBSS;
  835. property WACS_LRCORNER : cchar_t read WACS_SBBS;
  836. property WACS_RTEE : cchar_t read WACS_SBSS;
  837. property WACS_LTEE : cchar_t read WACS_SSSB;
  838. property WACS_BTEE : cchar_t read WACS_SSBS;
  839. property WACS_TTEE : cchar_t read WACS_BSSS;
  840. property WACS_HLINE : cchar_t read WACS_BSBS;
  841. property WACS_VLINE : cchar_t read WACS_SBSB;
  842. property WACS_PLUS : cchar_t read WACS_SSSS;
  843. {$ENDIF FPC_OBJFPC}
  844. (* mouse interface *)
  845. (* event masks *)
  846. const
  847. BUTTON1_RELEASED = 1;
  848. BUTTON1_PRESSED = 2;
  849. BUTTON1_CLICKED = 4;
  850. BUTTON1_DOUBLE_CLICKED = 8;
  851. BUTTON1_TRIPLE_CLICKED = 16;
  852. BUTTON2_RELEASED = 1 shl 6;
  853. BUTTON2_PRESSED = 2 shl 6;
  854. BUTTON2_CLICKED = 4 shl 6;
  855. BUTTON2_DOUBLE_CLICKED = 8 shl 6;
  856. BUTTON2_TRIPLE_CLICKED = 16 shl 6;
  857. BUTTON3_RELEASED = 1 shl (2 * 6);
  858. BUTTON3_PRESSED = 2 shl (2 * 6);
  859. BUTTON3_CLICKED = 4 shl (2 * 6);
  860. BUTTON3_DOUBLE_CLICKED = 8 shl (2 * 6);
  861. BUTTON3_TRIPLE_CLICKED = 16 shl (2 * 6);
  862. BUTTON4_RELEASED = 1 shl (3 * 6);
  863. BUTTON4_PRESSED = 2 shl (3 * 6);
  864. BUTTON4_CLICKED = 4 shl (3 * 6);
  865. BUTTON4_DOUBLE_CLICKED = 8 shl (3 * 6);
  866. BUTTON4_TRIPLE_CLICKED = 16 shl (3 * 6);
  867. BUTTON1_RESERVED_EVENT = 32;
  868. BUTTON2_RESERVED_EVENT = 32 shl 6;
  869. BUTTON3_RESERVED_EVENT = 32 shl (2 * 6);
  870. BUTTON4_RESERVED_EVENT = 32 shl (3 * 6);
  871. BUTTON_CTRL = 1 shl (4 * 6);
  872. BUTTON_SHIFT = 2 shl (4 * 6);
  873. BUTTON_ALT = 4 shl (4 * 6);
  874. REPORT_MOUSE_POSITION = 8 shl (4 * 6);
  875. ALL_MOUSE_EVENTS = REPORT_MOUSE_POSITION - 1;
  876. (* macros to extract single event-bits from masks *)
  877. function BUTTON_RELEASE(e,x: longint): longint; inline;
  878. function BUTTON_PRESS(e,x: longint): longint; inline;
  879. function BUTTON_CLICK(e,x: longint): longint; inline;
  880. function BUTTON_DOUBLE_CLICK(e,x: longint): longint; inline;
  881. function BUTTON_TRIPLE_CLICK(e,x: longint): longint; inline;
  882. function BUTTON_RESERVED_EVENT(e,x: longint): longint; inline;
  883. function mouse_trafo(pY,pX: PLongint; to_screen: Bool): Bool; inline;
  884. type
  885. PMEVENT = ^MEVENT;
  886. MEVENT = record
  887. id : Smallint; { ID to distinguish multiple devices }
  888. x, y, z : Longint; { event coordinates (character-cell) }
  889. bstate : mmask_t; { button state bits }
  890. end;
  891. function getmouse(_para1:PMEVENT):longint; cdecl;external libncurses;
  892. function ungetmouse(_para1:PMEVENT):longint; cdecl;external libncurses;
  893. function mousemask(_para1:mmask_t; _para2:Pmmask_t):mmask_t;cdecl;external;
  894. function wenclose(_para1:PWINDOW; _para2:Longint; _para3:Longint):Bool;cdecl;external;
  895. function mouseinterval(_para1:Longint):longint; cdecl;external libncurses;
  896. function wmouse_trafo(_para1:PWINDOW; _para2:PLongint; _para3:PLongint; _para4:Bool):Bool;cdecl;external;
  897. {
  898. wide-character (enhanced) functionality
  899. }
  900. function add_wch(wch: pcchar_t): longint; inline;
  901. function add_wchnstr(wchstr: pcchar_t; n: longint): longint; inline;
  902. function add_wchstr(wchstr: pcchar_t): longint; inline;
  903. function addnwstr(wchstr: pwchar_t; n : longint) : longint; inline;
  904. function addwstr(wchstr: pwchar_t): longint; inline;
  905. function bkgrnd(wch: pcchar_t): longint; inline;
  906. procedure bkgrndset(wch: pcchar_t); inline;
  907. function border_set(ls,rs,ts,bs,tl,tr,bl,br: pcchar_t): longint; inline;
  908. function box_set(win: PWINDOW; verch,horch: pcchar_t): longint; inline;
  909. function echo_wchar(wch: Pcchar_t): longint; inline;
  910. function get_wch(wch: Plongint): longint; inline;
  911. function get_wstr(wstr: PLongint): longint; inline;
  912. function getbkgrnd(wch: pcchar_t): longint; inline;
  913. function getn_wstr(wstr: PLongint; n: longint): longint; inline;
  914. function hline_set(wch: pcchar_t; n: longint): longint; inline;
  915. function in_wch(wch: pcchar_t) : longint; inline;
  916. function in_wchnstr(wchstr: pcchar_t; n: longint): longint; inline;
  917. function in_wchstr(wchstr: pcchar_t): longint; inline;
  918. function innwstr(wstr: pwchar_t; n: longint): longint; inline;
  919. function ins_nwstr(wstr: pwchar_t; n: longint): longint; inline;
  920. function ins_wch(wch: pcchar_t): longint; inline;
  921. function ins_wstr(wstr: pwchar_t): longint; inline;
  922. function inwstr(wstr: pwchar_t): longint; inline;
  923. function vline_set(wch: pcchar_t; n: longint): longint; inline;
  924. function wadd_wchstr(win: PWINDOW; wchstr: pcchar_t): longint; inline;
  925. function waddwstr(win: PWINDOW; wstr :pwchar_t): longint; inline;
  926. function wget_wstr(win: PWINDOW; wstr: PLongint): longint; inline;
  927. function win_wchstr(win: PWINDOW; wchstr: pcchar_t): longint; inline;
  928. function wins_wstr(win: PWINDOW; wstr: pwchar_t): longint; inline;
  929. function mvadd_wch(y,x: Smallint; wch: pcchar_t): longint; inline;
  930. function mvadd_wchnstr(y,x: Smallint; wchstr: pcchar_t; n: longint): longint; inline;
  931. function mvadd_wchstr(y,x: Smallint; wchstr: pcchar_t): longint; inline;
  932. function mvaddnwstr(y,x: Smallint; wstr: pwchar_t; n: longint): longint; inline;
  933. function mvaddwstr(y,x: Smallint; wstr: pwchar_t): longint; inline;
  934. function mvget_wch(y,x: Smallint; wch: Plongint): longint; inline;
  935. function mvget_wstr(y,x: Smallint; wstr: Plongint): longint; inline;
  936. function mvgetn_wstr(y,x: Smallint; wstr: Plongint; n: longint): longint; inline;
  937. function mvhline_set(y,x: Smallint; wch: pcchar_t; n: longint): longint; inline;
  938. function mvin_wch(y,x: Smallint; wch: pcchar_t) : longint; inline;
  939. function mvin_wchnstr(y,x: Smallint; wchstr: pcchar_t; n: longint): longint; inline;
  940. function mvin_wchstr(y,x: Smallint; wchstr: pcchar_t): longint; inline;
  941. function mvinnwstr(y,x: Smallint; wstr: pwchar_t; n : longint): longint; inline;
  942. function mvins_nwstr(y,x: Smallint; wstr: pwchar_t; n : longint): longint; inline;
  943. function mvins_wch(y,x: Smallint; wch: pcchar_t): longint; inline;
  944. function mvins_wstr(y,x: Smallint; wstr: pwchar_t): longint; inline;
  945. function mvinwstr(y,x: Smallint; wstr: pwchar_t): longint; inline;
  946. function mvvline_set(y,x: Smallint; wch: pcchar_t; n : longint): longint; inline;
  947. function mvwadd_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint; inline;
  948. function mvwadd_wchnstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t; n: longint): longint; inline;
  949. function mvwadd_wchstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t): longint; inline;
  950. function mvwaddnwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n: longint): longint; inline;
  951. function mvwaddwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t): longint; inline;
  952. function mvwget_wch(win: PWINDOW; y,x: Smallint; wch: Plongint): longint; inline;
  953. function mvwget_wstr(win: PWINDOW; y,x: Smallint; wstr: Plongint): longint; inline;
  954. function mvwgetn_wstr(win: PWINDOW; y,x: Smallint; wstr: Plongint; n: longint): longint; inline;
  955. function mvwhline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint): longint; inline;
  956. function mvwin_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint; inline;
  957. function mvwin_wchnstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t; n: longint): longint; inline;
  958. function mvwin_wchstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t): longint; inline;
  959. function mvwinnwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n : longint): longint; inline;
  960. function mvwins_nwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n: longint): longint; inline;
  961. function mvwins_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint; inline;
  962. function mvwins_wstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint; inline;
  963. function mvwinwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint; inline;
  964. function mvwvline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint) : longint; inline;
  965. function wmove(win: PWINDOW; y,x: Smallint): Longint; inline;
  966. (* C varargs procedures*)
  967. function tparm(_para1:PChar):PChar;cdecl; varargs; external libncurses; overload;
  968. function mvprintw(_para1:Longint; _para2:Longint; _para3:PChar):Longint; cdecl; varargs; external libncurses; overload;
  969. function mvscanw(_para1:Longint; _para2:Longint; _para3:PChar):Longint; cdecl; varargs;external libncurses; overload;
  970. function mvwprintw(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:PChar):Longint; cdecl; varargs; external libncurses; overload;
  971. function mvwscanw(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:PChar):Longint; cdecl; varargs; external libncurses; overload;
  972. function scanw(_para1:PChar):Longint; cdecl; varargs; external libncurses; overload;
  973. function wprintw(_para1:PWINDOW; _para2:PChar):Longint; cdecl; varargs; external libncurses; overload;
  974. function wscanw(_para1:PWINDOW; _para2:PChar):Longint; cdecl; varargs; external libncurses; overload;
  975. function printw(_para1:PChar):Longint; cdecl; varargs; external libncurses; overload;
  976. {function vwprintw(_para1:PWINDOW; _para2:PChar; _para3:va_list):Longint; cdecl;external libncurses;
  977. function vw_printw(_para1:PWINDOW; _para2:PChar; _para3:va_list):Longint; cdecl;external libncurses;
  978. function vwscanw(_para1:PWINDOW; _para2:PChar; _para3:va_list):Longint; cdecl;external libncurses;
  979. function vw_scanw(_para1:PWINDOW; _para2:PChar; _para3:va_list):Longint; cdecl;external libncurses;}
  980. {$IF DEFINED(FPC_OBJFPC) OR DEFINED(FPC_DELPHI)}
  981. {function tparm(_para1:PChar; args:array of const):PChar;cdecl;external libncurses; overload;
  982. function mvprintw(_para1:Longint; _para2:Longint; _para3:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
  983. function mvscanw(_para1:Longint; _para2:Longint; _para3:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
  984. function mvwprintw(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
  985. function mvwscanw(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
  986. function scanw(_para1:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
  987. function wprintw(_para1:PWINDOW; _para2:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
  988. function wscanw(_para1:PWINDOW; _para2:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
  989. function printw(_para1:PChar; args:array of const):Longint; cdecl;external libncurses; overload;}
  990. {$ENDIF}
  991. implementation
  992. function ACS_ULCORNER : chtype;
  993. begin
  994. ACS_ULCORNER:=acs_map['l'];
  995. end;
  996. function ACS_LLCORNER : chtype;
  997. begin
  998. ACS_LLCORNER:=acs_map['m'];
  999. end;
  1000. function ACS_URCORNER : chtype;
  1001. begin
  1002. ACS_URCORNER:=acs_map['k'];
  1003. end;
  1004. function ACS_LRCORNER : chtype;
  1005. begin
  1006. ACS_LRCORNER:=acs_map['j'];
  1007. end;
  1008. function ACS_LTEE : chtype;
  1009. begin
  1010. ACS_LTEE:=acs_map['t'];
  1011. end;
  1012. function ACS_RTEE : chtype;
  1013. begin
  1014. ACS_RTEE:=acs_map['u'];
  1015. end;
  1016. function ACS_BTEE : chtype;
  1017. begin
  1018. ACS_BTEE:=acs_map['v'];
  1019. end;
  1020. function ACS_TTEE : chtype;
  1021. begin
  1022. ACS_TTEE:=acs_map['w'];
  1023. end;
  1024. function ACS_HLINE : chtype;
  1025. begin
  1026. ACS_HLINE:=acs_map['q'];
  1027. end;
  1028. function ACS_VLINE : chtype;
  1029. begin
  1030. ACS_VLINE:=acs_map['x'];
  1031. end;
  1032. function ACS_PLUS : chtype;
  1033. begin
  1034. ACS_PLUS:=acs_map['n'];
  1035. end;
  1036. function ACS_S1 : chtype;
  1037. begin
  1038. ACS_S1 :=acs_map['o'];
  1039. end;
  1040. function ACS_S9 : chtype;
  1041. begin
  1042. ACS_S9 :=acs_map['s'];
  1043. end;
  1044. function ACS_DIAMOND : chtype;
  1045. begin
  1046. ACS_DIAMOND:=acs_map['`'];
  1047. end;
  1048. function ACS_CKBOARD : chtype;
  1049. begin
  1050. ACS_CKBOARD:=acs_map['a'];
  1051. end;
  1052. function ACS_DEGREE : chtype;
  1053. begin
  1054. ACS_DEGREE:=acs_map['f'];
  1055. end;
  1056. function ACS_PLMINUS : chtype;
  1057. begin
  1058. ACS_PLMINUS:=acs_map['g'];
  1059. end;
  1060. function ACS_BULLET : chtype;
  1061. begin
  1062. ACS_BULLET:=acs_map['~'];
  1063. end;
  1064. function ACS_LARROW : chtype;
  1065. begin
  1066. ACS_LARROW:=acs_map[','];
  1067. end;
  1068. function ACS_RARROW : chtype;
  1069. begin
  1070. ACS_RARROW:=acs_map['+'];
  1071. end;
  1072. function ACS_DARROW : chtype;
  1073. begin
  1074. ACS_DARROW:=acs_map['.'];
  1075. end;
  1076. function ACS_UARROW : chtype;
  1077. begin
  1078. ACS_UARROW:=acs_map['-'];
  1079. end;
  1080. function ACS_BOARD : chtype;
  1081. begin
  1082. ACS_BOARD:=acs_map['h'];
  1083. end;
  1084. function ACS_LANTERN : chtype;
  1085. begin
  1086. ACS_LANTERN:=acs_map['i'];
  1087. end;
  1088. function ACS_BLOCK : chtype;
  1089. begin
  1090. ACS_BLOCK:=acs_map['0'];
  1091. end;
  1092. function ACS_S3 : chtype;
  1093. begin
  1094. ACS_S3 :=acs_map['p'];
  1095. end;
  1096. function ACS_S7 : chtype;
  1097. begin
  1098. ACS_S7 :=acs_map['r'];
  1099. end;
  1100. function ACS_LEQUAL : chtype;
  1101. begin
  1102. ACS_LEQUAL:=acs_map['y'];
  1103. end;
  1104. function ACS_GEQUAL : chtype;
  1105. begin
  1106. ACS_GEQUAL:=acs_map['z'];
  1107. end;
  1108. function ACS_PI : chtype;
  1109. begin
  1110. ACS_PI :=acs_map['{'];
  1111. end;
  1112. function ACS_NEQUAL : chtype;
  1113. begin
  1114. ACS_NEQUAL:=acs_map['|'];
  1115. end;
  1116. function ACS_STERLING : chtype;
  1117. begin
  1118. ACS_STERLING:=acs_map['}'];
  1119. end;
  1120. function COLOR_PAIR(n : longint): longint;
  1121. begin
  1122. COLOR_PAIR:=n shl 8;
  1123. end;
  1124. function PAIR_NUMBER(attr: attr_t) : longint;
  1125. begin
  1126. PAIR_NUMBER := (attr AND A_COLOR) shr 8
  1127. //#define PAIR_NUMBER(a) (NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
  1128. end;
  1129. function color_set(color_pair_number: Smallint; opts: Pointer): longint; inline;
  1130. begin
  1131. color_set:=wcolor_set(stdscr,color_pair_number,opts);
  1132. end;
  1133. function wgetstr(win: PWINDOW; s: PChar): Longint;
  1134. begin
  1135. wgetstr := wgetnstr(win, s, -1);
  1136. end;
  1137. function getnstr(s: PChar;n: Longint): Longint;
  1138. begin
  1139. getnstr := wgetnstr(stdscr,s,n);
  1140. end;
  1141. {
  1142. setupterm are declared in <ncursesw/term.h>:
  1143. int setupterm(char *term, int fildes, int *errret);
  1144. }
  1145. function setupterm(term:PChar; fildes:Longint; errret:Plongint):Longint; cdecl;external libncurses;
  1146. function setterm(term: PChar): Longint;
  1147. begin
  1148. setterm:=setupterm(term,1,plongint(0));
  1149. end;
  1150. function fixterm: Longint;
  1151. begin
  1152. fixterm:=reset_prog_mode;
  1153. end;
  1154. function resetterm: Longint;
  1155. begin
  1156. resetterm:=reset_shell_mode;
  1157. end;
  1158. function saveterm: Longint;
  1159. begin
  1160. saveterm:=def_prog_mode;
  1161. end;
  1162. function crmode: Longint;
  1163. begin
  1164. crmode:=cbreak;
  1165. end;
  1166. function nocrmode: Longint;
  1167. begin
  1168. nocrmode:=nocbreak;
  1169. end;
  1170. procedure getyx(win: PWINDOW; var y,x: Smallint);
  1171. begin
  1172. if win<>nil then
  1173. begin
  1174. y := win^._cury; x := win^._curx
  1175. end
  1176. else
  1177. begin
  1178. y := ERR; x := ERR
  1179. end
  1180. end;
  1181. procedure getbegyx(win: PWINDOW; var y,x: Smallint);
  1182. begin
  1183. if win<>nil then
  1184. begin
  1185. y := win^._begy; x := win^._begx
  1186. end
  1187. else
  1188. begin
  1189. y := ERR; x := ERR
  1190. end
  1191. end;
  1192. procedure getmaxyx(win: PWINDOW; var y,x: Smallint);
  1193. begin
  1194. if win<>nil then
  1195. begin
  1196. y := win^._maxy+1; x := win^._maxx+1
  1197. end
  1198. else
  1199. begin
  1200. y := ERR; x := ERR
  1201. end
  1202. end;
  1203. procedure getparyx(win: PWINDOW; var y,x: Smallint);
  1204. begin
  1205. if win<>nil then
  1206. begin
  1207. y := win^._pary; x :=win^._parx
  1208. end
  1209. else
  1210. begin
  1211. y := ERR; x := ERR
  1212. end
  1213. end;
  1214. procedure getsyx(var y,x: Smallint);
  1215. begin
  1216. {$IFNDEF USE_FPC_BYTEBOOL}
  1217. if newscr^._leaveok = NC_FPC_TRUE then
  1218. {$ELSE USE_FPC_BYTEBOOL}
  1219. if newscr^._leaveok then
  1220. {$ENDIF USE_FPC_BYTEBOOL}
  1221. begin
  1222. y := -1; x := -1
  1223. end
  1224. else
  1225. begin
  1226. y := newscr^._cury; x := newscr^._curx
  1227. end
  1228. end;
  1229. procedure getyx(win: PWINDOW; var y,x: Longint);
  1230. begin
  1231. if win<>nil then
  1232. begin
  1233. y := win^._cury; x := win^._curx
  1234. end
  1235. else
  1236. begin
  1237. y := ERR; x := ERR
  1238. end
  1239. end;
  1240. procedure getbegyx(win: PWINDOW; var y,x: Longint);
  1241. begin
  1242. if win<>nil then
  1243. begin
  1244. y := win^._begy; x := win^._begx
  1245. end
  1246. else
  1247. begin
  1248. y := ERR; x := ERR
  1249. end
  1250. end;
  1251. procedure getmaxyx(win: PWINDOW; var y,x: Longint);
  1252. begin
  1253. if win<>nil then
  1254. begin
  1255. y := win^._maxy+1; x := win^._maxx+1
  1256. end
  1257. else
  1258. begin
  1259. y := ERR; x := ERR
  1260. end
  1261. end;
  1262. procedure getparyx(win: PWINDOW; var y,x: Longint);
  1263. begin
  1264. if win<>nil then
  1265. begin
  1266. y := win^._pary; x :=win^._parx
  1267. end
  1268. else
  1269. begin
  1270. y := ERR; x := ERR
  1271. end
  1272. end;
  1273. procedure getsyx(var y,x: Longint);
  1274. begin
  1275. {$IFNDEF USE_FPC_BYTEBOOL}
  1276. if newscr^._leaveok = NC_FPC_TRUE then
  1277. {$ELSE USE_FPC_BYTEBOOL}
  1278. if newscr^._leaveok then
  1279. {$ENDIF USE_FPC_BYTEBOOL}
  1280. begin
  1281. y := -1; x := -1
  1282. end
  1283. else
  1284. begin
  1285. y := newscr^._cury; x := newscr^._curx
  1286. end
  1287. end;
  1288. procedure setsyx(y,x: Smallint);
  1289. begin
  1290. (*
  1291. C macros:
  1292. #define setsyx(y,x) do { if((y)==-1 && (x)==-1) newscr->_leaveok=TRUE; \
  1293. else {newscr->_leaveok=FALSE;wmove(newscr,(y),(x));} \
  1294. } while(0)
  1295. *)
  1296. if (x>=0) and (y >=0) AND (x<=newscr^._maxx) AND (y<=newscr^._maxy) then
  1297. begin
  1298. newscr^._curx := x;
  1299. newscr^._cury := y;
  1300. newscr^._flags := newscr^._flags AND not _WRAPPED;
  1301. newscr^._flags := newscr^._flags OR _HASMOVED;
  1302. newscr^._leaveok := NC_FPC_FALSE;
  1303. end
  1304. else if (x OR y = -1) then
  1305. newscr^._leaveok := NC_FPC_TRUE
  1306. //stdscr^._cury := y; //fpc ncurses original
  1307. //stdscr^._curx := x;
  1308. end;
  1309. function getattrs(win: PWINDOW): attr_t;
  1310. begin
  1311. if win<>nil then
  1312. getattrs:=win^._attrs
  1313. else
  1314. getattrs:=A_NORMAL;
  1315. end;
  1316. function getcurx(win: PWINDOW): Smallint;
  1317. begin
  1318. if win<>nil then
  1319. getcurx:=win^._curx
  1320. else
  1321. getcurx:=ERR;
  1322. end;
  1323. function getcury(win: PWINDOW): Smallint;
  1324. begin
  1325. if win<>nil then
  1326. getcury:=win^._cury
  1327. else
  1328. getcury:=ERR;
  1329. end;
  1330. function getbegx(win: PWINDOW): Smallint;
  1331. begin
  1332. if win<>nil then
  1333. getbegx:=win^._begx
  1334. else
  1335. getbegx:=ERR;
  1336. end;
  1337. function getbegy(win: PWINDOW): Smallint;
  1338. begin
  1339. if win<>nil then
  1340. getbegy:=win^._begy
  1341. else
  1342. getbegy:=ERR;
  1343. end;
  1344. function getmaxx(win: PWINDOW): Smallint;
  1345. begin
  1346. if win<>nil then
  1347. getmaxx:=(win^._maxx) + 1
  1348. else
  1349. getmaxx:=ERR;
  1350. end;
  1351. function getmaxy(win: PWINDOW): Smallint;
  1352. begin
  1353. if win<>nil then
  1354. getmaxy:=(win^._maxy) + 1
  1355. else
  1356. getmaxy:=ERR;
  1357. end;
  1358. function getparx(win: PWINDOW): Smallint;
  1359. begin
  1360. if win<>nil then
  1361. getparx:=win^._parx
  1362. else
  1363. getparx:=ERR;
  1364. end;
  1365. function getpary(win: PWINDOW): Smallint;
  1366. begin
  1367. if win<>nil then
  1368. getpary:=win^._pary
  1369. else
  1370. getpary:=ERR;
  1371. end;
  1372. function wstandout(win: PWINDOW): Longint;
  1373. begin
  1374. wstandout:=wattrset(win,A_STANDOUT);
  1375. end;
  1376. function wstandend(win: PWINDOW): Longint;
  1377. begin
  1378. wstandend:=wattrset(win,A_NORMAL);
  1379. end;
  1380. function wattr_set(win: PWINDOW; attrs: attr_t; pair: Smallint; opts: Pointer): Longint;
  1381. begin
  1382. { The parameter opts is reserved for future use, applications must supply a null pointer. }
  1383. {
  1384. C macros
  1385. #define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
  1386. }
  1387. win^._attrs := (attrs AND not A_COLOR) OR COLOR_PAIR(pair);
  1388. wattr_set := OK
  1389. end;
  1390. function wattr_get(win:PWINDOW; attrs:Pattr_t; pair:PSmallint; opts:Pointer):longint;
  1391. begin
  1392. {
  1393. C macros
  1394. #define wattr_get(win,a,p,opts) ((void)((a) != 0 && (*(a) = (win)->_attrs)), \
  1395. (void)((p) != 0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
  1396. OK)
  1397. }
  1398. attrs^ := win^._attrs;
  1399. pair^ := PAIR_NUMBER(win^._attrs);
  1400. wattr_get := OK
  1401. end;
  1402. function wattron(win:PWINDOW; attrs: attr_t): Longint;
  1403. begin
  1404. wattron:=wattr_on(win, attrs, nil);
  1405. end;
  1406. function wattroff(win:PWINDOW; attrs: attr_t): longint;
  1407. begin
  1408. wattroff:=wattr_off(win, attrs, nil);
  1409. end;
  1410. function wattrset(win: PWINDOW; attrs: attr_t): longint;
  1411. begin
  1412. win^._attrs := attrs;
  1413. wattrset := OK
  1414. end;
  1415. function scroll(win: PWINDOW): longint;
  1416. begin
  1417. scroll:=wscrl(win,1);
  1418. end;
  1419. function touchwin(win: PWINDOW): longint;
  1420. begin
  1421. touchwin:=wtouchln(win,0,getmaxy(win),1);
  1422. end;
  1423. function touchline(win: PWINDOW;s,c: longint): longint;
  1424. begin
  1425. touchline:=wtouchln(win,s,c,1);
  1426. end;
  1427. function untouchwin(win: PWINDOW): longint;
  1428. begin
  1429. untouchwin:=wtouchln(win,0,getmaxy(win),0);
  1430. end;
  1431. function box(win:PWINDOW; v,h :chtype):Longint;
  1432. begin
  1433. box:=wborder(win,v,v,h,h,0,0,0,0);
  1434. end;
  1435. function border(ls,rs,ts,bs,tl,tr,bl,br: chtype): longint;
  1436. begin
  1437. border:=wborder(stdscr,ls,rs,ts,bs,tl,tr,bl,br);
  1438. end;
  1439. function hline(ch:chtype; n:longint): longint;
  1440. begin
  1441. hline:=whline(stdscr,ch,n);
  1442. end;
  1443. function vline(ch:chtype; n:longint): longint;
  1444. begin
  1445. vline:=wvline(stdscr,ch,n);
  1446. end;
  1447. function winstr(win: PWINDOW;s: PChar): longint;
  1448. begin
  1449. winstr:=winnstr(win,s,-(1));
  1450. end;
  1451. function winchstr(win: PWINDOW; chstr: pchtype): longint;
  1452. begin
  1453. winchstr:=winchnstr(win,chstr,-(1));
  1454. end;
  1455. function winsstr(win: PWINDOW;s: PChar): longint;
  1456. begin
  1457. winsstr:=winsnstr(win,s,-(1));
  1458. end;
  1459. function redrawwin(win: PWINDOW): longint;
  1460. begin
  1461. redrawwin:=wredrawln(win,0,(win^._maxy)+1);
  1462. end;
  1463. function waddstr(win: PWINDOW;st: PChar): longint;
  1464. begin
  1465. waddstr:=waddnstr(win,st,-(1));
  1466. end;
  1467. function waddchstr(win: PWINDOW; chstr: pchtype): longint;
  1468. begin
  1469. waddchstr:=waddchnstr(win,chstr,-(1));
  1470. end;
  1471. {
  1472. pseudo functions for standard screen
  1473. }
  1474. function addch(ch: chtype): longint;
  1475. begin
  1476. addch:=waddch(stdscr,ch);
  1477. end;
  1478. function addchnstr(chstr: pchtype; n: longint): longint;
  1479. begin
  1480. addchnstr:=waddchnstr(stdscr,chstr,n);
  1481. end;
  1482. function addchstr(chstr: pchtype): longint;
  1483. begin
  1484. addchstr:=waddchstr(stdscr,chstr);
  1485. end;
  1486. function addnstr(str: PChar;n: longint): longint;
  1487. begin
  1488. addnstr:=waddnstr(stdscr,str,n);
  1489. end;
  1490. function addstr(str: PChar): longint;
  1491. begin
  1492. addstr:=waddnstr(stdscr,str,-(1));
  1493. end;
  1494. function attroff(attrs: attr_t): longint;
  1495. begin
  1496. attroff:=wattroff(stdscr,attrs);
  1497. end;
  1498. function attron(attrs: attr_t): longint;
  1499. begin
  1500. attron:=wattron(stdscr,attrs);
  1501. end;
  1502. function attrset(attrs: attr_t): longint;
  1503. begin
  1504. //attrset:=wattrset(stdscr,attrs);
  1505. stdscr^._attrs := attrs;
  1506. attrset := OK
  1507. end;
  1508. function bkgd(ch: chtype): longint;
  1509. begin
  1510. bkgd:=wbkgd(stdscr,ch);
  1511. end;
  1512. procedure bkgdset(ch: chtype);
  1513. begin
  1514. wbkgdset(stdscr,ch);
  1515. end;
  1516. function clear: longint;
  1517. begin
  1518. clear:=wclear(stdscr);
  1519. end;
  1520. function clrtobot: longint;
  1521. begin
  1522. clrtobot:=wclrtobot(stdscr);
  1523. end;
  1524. function clrtoeol: longint;
  1525. begin
  1526. clrtoeol:=wclrtoeol(stdscr);
  1527. end;
  1528. function delch: longint;
  1529. begin
  1530. delch:=wdelch(stdscr);
  1531. end;
  1532. function deleteln: longint;
  1533. begin
  1534. deleteln:=winsdelln(stdscr,-(1));
  1535. end;
  1536. function echochar(ch: chtype): longint;
  1537. begin
  1538. echochar:=wechochar(stdscr,ch);
  1539. end;
  1540. function erase: longint;
  1541. begin
  1542. erase:=werase(stdscr);
  1543. end;
  1544. function getch: longint;
  1545. begin
  1546. getch:=wgetch(stdscr);
  1547. end;
  1548. function getstr(str: PChar): longint;
  1549. begin
  1550. getstr:=wgetstr(stdscr,str);
  1551. end;
  1552. function inch: chtype;
  1553. begin
  1554. inch:=winch(stdscr);
  1555. end;
  1556. function inchnstr(chstr: pchtype;n: longint): longint;
  1557. begin
  1558. inchnstr:=winchnstr(stdscr,chstr ,n);
  1559. end;
  1560. function inchstr(chstr: pchtype): longint;
  1561. begin
  1562. inchstr:=winchstr(stdscr,chstr);
  1563. end;
  1564. function innstr(str: PChar;n: longint): longint;
  1565. begin
  1566. innstr:=winnstr(stdscr,str,n);
  1567. end;
  1568. function insch(ch: chtype): longint;
  1569. begin
  1570. insch:=winsch(stdscr,ch);
  1571. end;
  1572. function insdelln(n: longint): longint;
  1573. begin
  1574. insdelln:=winsdelln(stdscr,n);
  1575. end;
  1576. function insertln: longint;
  1577. begin
  1578. insertln:=winsdelln(stdscr,1);
  1579. end;
  1580. function insnstr(str: PChar;n: longint): longint;
  1581. begin
  1582. insnstr:=winsnstr(stdscr,str,n);
  1583. end;
  1584. function insstr(str: PChar): longint;
  1585. begin
  1586. insstr:=winsstr(stdscr,str);
  1587. end;
  1588. function instr(str: PChar): longint;
  1589. begin
  1590. instr:=winstr(stdscr,str);
  1591. end;
  1592. function move(y,x: Smallint): longint;
  1593. begin
  1594. if (x OR y >=0)AND(x<=stdscr^._maxx)AND(y<=stdscr^._maxy) then
  1595. begin
  1596. stdscr^._curx := x;
  1597. stdscr^._cury := y;
  1598. stdscr^._flags := stdscr^._flags AND not _WRAPPED;
  1599. stdscr^._flags := stdscr^._flags OR _HASMOVED;
  1600. move := OK
  1601. end
  1602. else
  1603. move := ERR
  1604. end;
  1605. function refresh: longint;
  1606. begin
  1607. refresh:=wrefresh(stdscr);
  1608. end;
  1609. function scrl(n: longint): longint;
  1610. begin
  1611. scrl:=wscrl(stdscr,n);
  1612. end;
  1613. function setscrreg(t,b: longint): longint;
  1614. begin
  1615. setscrreg:=wsetscrreg(stdscr,t,b);
  1616. end;
  1617. function standend: longint;
  1618. begin
  1619. standend:=wstandend(stdscr);
  1620. end;
  1621. function standout: longint;
  1622. begin
  1623. standout:=wstandout(stdscr);
  1624. end;
  1625. procedure timeout(delay: longint);
  1626. begin
  1627. wtimeout(stdscr,delay);
  1628. end;
  1629. function wdeleteln(win: PWINDOW): longint;
  1630. begin
  1631. wdeleteln:=winsdelln(win,-(1));
  1632. end;
  1633. function winsertln(win: PWINDOW): longint;
  1634. begin
  1635. winsertln:=winsdelln(win,1);
  1636. end;
  1637. {
  1638. mv functions
  1639. }
  1640. function mvwaddch(win: PWINDOW;y,x: Smallint; ch: chtype): longint;
  1641. begin
  1642. if wmove(win,y,x) = ERR then
  1643. mvwaddch := ERR
  1644. else
  1645. mvwaddch := waddch(win,ch)
  1646. end;
  1647. function mvwaddchnstr(win: PWINDOW;y,x: Smallint;chstr: pchtype;n: longint): longint;
  1648. begin
  1649. if wmove(win,y,x) = ERR then
  1650. mvwaddchnstr := ERR
  1651. else
  1652. mvwaddchnstr := waddchnstr(win,chstr,n);
  1653. end;
  1654. function mvwaddchstr(win: PWINDOW;y,x: Smallint;chstr: pchtype): longint;
  1655. begin
  1656. if wmove(win,y,x) = ERR then
  1657. mvwaddchstr := ERR
  1658. else
  1659. mvwaddchstr := waddchnstr(win,chstr,-(1))
  1660. end;
  1661. function mvwaddnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint;
  1662. begin
  1663. if wmove(win,y,x) = ERR then
  1664. mvwaddnstr := ERR
  1665. else
  1666. mvwaddnstr := waddnstr(win,str,n);
  1667. end;
  1668. function mvwaddstr(win: PWINDOW;y,x: Smallint;str: PChar): longint;
  1669. begin
  1670. if wmove(win,y,x) = ERR then
  1671. mvwaddstr := ERR
  1672. else
  1673. mvwaddstr := waddnstr(win,str,-(1));
  1674. end;
  1675. function mvwdelch(win: PWINDOW;y,x: Smallint): longint;
  1676. begin
  1677. if wmove(win,y,x) = ERR then
  1678. mvwdelch := ERR
  1679. else
  1680. mvwdelch :=wdelch(win);
  1681. end;
  1682. function mvwchgat(win: PWINDOW;y, x: Smallint; n: Longint;attr: attr_t;
  1683. color: Smallint; opts: Pointer): longint;
  1684. begin
  1685. if wmove(win,y,x) = ERR then
  1686. mvwchgat := ERR
  1687. else
  1688. mvwchgat := wchgat(win,n,attr,color,opts);
  1689. end;
  1690. function mvwgetch(win: PWINDOW;y,x: Smallint): longint;
  1691. begin
  1692. if wmove(win,y,x) = ERR then
  1693. mvwgetch := ERR
  1694. else
  1695. mvwgetch := wgetch(win);
  1696. end;
  1697. function mvwgetnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint;
  1698. begin
  1699. if wmove(win,y,x) = ERR then
  1700. mvwgetnstr := ERR
  1701. else
  1702. mvwgetnstr := wgetnstr(win,str,n);
  1703. end;
  1704. function mvwgetstr(win: PWINDOW;y,x: Smallint;str: PChar): longint;
  1705. begin
  1706. if wmove(win,y,x) = ERR then
  1707. mvwgetstr := ERR
  1708. else
  1709. mvwgetstr := wgetstr(win,str);
  1710. end;
  1711. function mvwhline(win: PWINDOW;y,x: Smallint;ch: chtype;n: longint): longint;
  1712. begin
  1713. if wmove(win,y,x) = ERR then
  1714. mvwhline := ERR
  1715. else
  1716. mvwhline := whline(win,ch,n);
  1717. end;
  1718. function mvwinch(win: PWINDOW;y,x: Smallint): chtype;
  1719. begin
  1720. if wmove(win,y,x) = ERR then
  1721. mvwinch := chtype(ERR)
  1722. else
  1723. mvwinch := winch(win);
  1724. end;
  1725. function mvwinchnstr(win: PWINDOW;y,x: Smallint;chstr: pchtype; n: longint): longint;
  1726. begin
  1727. if wmove(win,y,x) = ERR then
  1728. mvwinchnstr := ERR
  1729. else
  1730. mvwinchnstr := winchnstr(win,chstr,n);
  1731. end;
  1732. function mvwinchstr(win: PWINDOW;y,x: Smallint;chstr: pchtype): longint;
  1733. begin
  1734. if wmove(win,y,x) = ERR then
  1735. mvwinchstr := ERR
  1736. else
  1737. mvwinchstr := winchnstr(win,chstr,-(1));
  1738. end;
  1739. function mvwinnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint;
  1740. begin
  1741. if wmove(win,y,x) = ERR then
  1742. mvwinnstr := ERR
  1743. else
  1744. mvwinnstr := winnstr(win,str,n);
  1745. end;
  1746. function mvwinsch(win: PWINDOW;y,x: Smallint;ch: chtype): longint;
  1747. begin
  1748. if wmove(win,y,x) = ERR then
  1749. mvwinsch := ERR
  1750. else
  1751. mvwinsch := winsch(win,ch);
  1752. end;
  1753. function mvwinsnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint;
  1754. begin
  1755. if wmove(win,y,x) = ERR then
  1756. mvwinsnstr := ERR
  1757. else
  1758. mvwinsnstr := winsnstr(win,str,n);
  1759. end;
  1760. function mvwinsstr(win: PWINDOW;y,x: Smallint;str: PChar): longint;
  1761. begin
  1762. if wmove(win,y,x) = ERR then
  1763. mvwinsstr := ERR
  1764. else
  1765. mvwinsstr := winsnstr(win,str,-(1));
  1766. end;
  1767. function mvwinstr(win: PWINDOW;y,x: Smallint;str: PChar): longint;
  1768. begin
  1769. if wmove(win,y,x) = ERR then
  1770. mvwinstr := ERR
  1771. else
  1772. mvwinstr := winnstr(win,str,-(1));
  1773. end;
  1774. function mvwvline(win: PWINDOW;y,x: Smallint;ch: chtype;n: longint): longint;
  1775. begin
  1776. if wmove(win,y,x) = ERR then
  1777. mvwvline := ERR
  1778. else
  1779. mvwvline := wvline(win,ch,n);
  1780. end;
  1781. function mvaddch(y,x: Smallint; ch: chtype): longint;
  1782. begin
  1783. if move(y,x) = ERR then
  1784. mvaddch := ERR
  1785. else
  1786. mvaddch := waddch(stdscr,ch)
  1787. end;
  1788. function mvaddchnstr(y,x: Smallint; chstr: pchtype;n: longint): longint;
  1789. begin
  1790. if move(y,x) = ERR then
  1791. mvaddchnstr := ERR
  1792. else
  1793. mvaddchnstr := waddchnstr(stdscr,chstr,n);
  1794. end;
  1795. function mvaddchstr(y,x: Smallint; chstr: pchtype): longint;
  1796. begin
  1797. if move(y,x) = ERR then
  1798. mvaddchstr := ERR
  1799. else
  1800. mvaddchstr := waddchnstr(stdscr,chstr,-(1));
  1801. end;
  1802. function mvaddnstr(y,x: Smallint; str: PChar;n: longint): longint;
  1803. begin
  1804. if move(y,x) = ERR then
  1805. mvaddnstr := ERR
  1806. else
  1807. mvaddnstr := waddnstr(stdscr,str,n);
  1808. end;
  1809. function mvaddstr(y,x: Smallint; str: PChar): longint;
  1810. begin
  1811. if move(y,x) = ERR then
  1812. mvaddstr := ERR
  1813. else
  1814. mvaddstr := waddnstr(stdscr,str,-(1));
  1815. end;
  1816. function mvdelch(y,x: Smallint): longint;
  1817. begin
  1818. if move(y,x) = ERR then
  1819. mvdelch := ERR
  1820. else
  1821. mvdelch := wdelch(stdscr);
  1822. end;
  1823. function mvgetch(y,x: Smallint): longint;
  1824. begin
  1825. if move(y,x) = ERR then
  1826. mvgetch := ERR
  1827. else
  1828. mvgetch := wgetch(stdscr);
  1829. end;
  1830. function mvgetnstr(y,x: Smallint; str: PChar;n: longint): longint;
  1831. begin
  1832. if move(y,x) = ERR then
  1833. mvgetnstr := ERR
  1834. else
  1835. mvgetnstr := wgetnstr(stdscr,str,n);
  1836. end;
  1837. function mvgetstr(y,x: Smallint; str: PChar): longint;
  1838. begin
  1839. if move(y,x) = ERR then
  1840. mvgetstr := ERR
  1841. else
  1842. mvgetstr := wgetnstr(stdscr,str,-(1));
  1843. end;
  1844. function mvhline(y,x: Smallint;ch: chtype;n: longint): longint;
  1845. begin
  1846. if move(y,x) = ERR then
  1847. mvhline := ERR
  1848. else
  1849. mvhline := whline(stdscr,ch,n);
  1850. end;
  1851. function mvinch(y,x: Smallint): chtype;
  1852. begin
  1853. if move(y,x) = ERR then
  1854. mvinch := chtype(ERR)
  1855. else
  1856. mvinch := winch(stdscr);
  1857. end;
  1858. function mvinchnstr(y,x: Smallint; chstr: pchtype;n: longint): longint;
  1859. begin
  1860. if move(y,x) = ERR then
  1861. mvinchnstr := ERR
  1862. else
  1863. mvinchnstr := winchnstr(stdscr,chstr,n);
  1864. end;
  1865. function mvinchstr(y,x: Smallint; chstr: pchtype): longint;
  1866. begin
  1867. if move(y,x) = ERR then
  1868. mvinchstr := ERR
  1869. else
  1870. mvinchstr := winchnstr(stdscr,chstr,-(1));
  1871. end;
  1872. function mvinnstr(y,x: Smallint; str: PChar;n: longint): longint;
  1873. begin
  1874. if move(y,x) = ERR then
  1875. mvinnstr := ERR
  1876. else
  1877. mvinnstr := winnstr(stdscr,str,n);
  1878. end;
  1879. function mvinsch(y,x: Smallint;ch: chtype): longint;
  1880. begin
  1881. if move(y,x) = ERR then
  1882. mvinsch := ERR
  1883. else
  1884. mvinsch := winsch(stdscr,ch);
  1885. end;
  1886. function mvinsnstr(y,x: Smallint; str: PChar;n: longint): longint;
  1887. begin
  1888. if move(y,x) = ERR then
  1889. mvinsnstr := ERR
  1890. else
  1891. mvinsnstr := winsnstr(stdscr,str,n);
  1892. end;
  1893. function mvinsstr(y,x: Smallint; str: PChar): longint;
  1894. begin
  1895. if move(y,x) = ERR then
  1896. mvinsstr := ERR
  1897. else
  1898. mvinsstr := winsstr(stdscr,str);
  1899. end;
  1900. function mvinstr(y,x: Smallint; str: PChar): longint;
  1901. begin
  1902. if move(y,x) = ERR then
  1903. mvinstr := ERR
  1904. else
  1905. mvinstr := winstr(stdscr,str);
  1906. end;
  1907. function mvvline(y,x: Smallint; ch:chtype; n:longint): longint;
  1908. begin
  1909. if move(y,x) = ERR then
  1910. mvvline := ERR
  1911. else
  1912. mvvline := wvline(stdscr,ch,n);
  1913. end;
  1914. function attr_get(attrs:Pattr_t; pair:PSmallint; opts:Pointer): longint;
  1915. begin
  1916. attr_get := wattr_get(stdscr,attrs,pair,opts);
  1917. end;
  1918. function attr_off(attrs:attr_t; opts:Pointer): longint;
  1919. begin
  1920. attr_off := wattr_off(stdscr,attrs,opts);
  1921. end;
  1922. function attr_on(attrs:attr_t; opts:Pointer): longint;
  1923. begin
  1924. attr_on := wattr_on(stdscr,attrs,opts);
  1925. end;
  1926. function attr_set(attrs:attr_t; pair:Smallint; opts:Pointer): longint;
  1927. begin
  1928. attr_set := wattr_set(stdscr,attrs,pair,opts);
  1929. end;
  1930. function chgat(n: Longint;attr: attr_t;color: Smallint; opts: Pointer): longint;
  1931. begin
  1932. chgat := wchgat(stdscr,n,attr,color,opts);
  1933. end;
  1934. function mvchgat(y, x: Smallint; n: Longint;attr: attr_t;color: Smallint; opts: Pointer):Longint;
  1935. begin
  1936. if move(y,x) = ERR then
  1937. mvchgat := ERR
  1938. else
  1939. mvchgat := wchgat(stdscr,n,attr,color,opts);
  1940. end;
  1941. function getbkgd(win: PWINDOW): chtype;
  1942. begin
  1943. getbkgd := win^._bkgd;
  1944. end;
  1945. function slk_attr_off(attrs: attr_t; opts: Pointer) : longint;
  1946. begin
  1947. slk_attr_off := slk_attroff(attrs);
  1948. end;
  1949. function slk_attr_on(attrs: attr_t; opts: Pointer): longint;
  1950. begin
  1951. slk_attr_on := slk_attron(attrs);
  1952. end;
  1953. function KEY_F(n : Byte) : chtype;
  1954. begin
  1955. KEY_F := KEY_F0 + n;
  1956. end;
  1957. function NCURSES_WACS(c: chtype): cchar_t;
  1958. begin
  1959. NCURSES_WACS := _nc_wacs[c];
  1960. end;
  1961. function WACS_BSSB: cchar_t;
  1962. begin
  1963. WACS_BSSB := _nc_wacs[chtype('l')];
  1964. end;
  1965. function WACS_SSBB: cchar_t;
  1966. begin
  1967. WACS_SSBB:= _nc_wacs[chtype('m')];
  1968. end;
  1969. function WACS_BBSS: cchar_t;
  1970. begin
  1971. WACS_BBSS:= _nc_wacs[chtype('k')];
  1972. end;
  1973. function WACS_SBBS: cchar_t;
  1974. begin
  1975. WACS_SBBS:= _nc_wacs[chtype('j')];
  1976. end;
  1977. function WACS_SBSS: cchar_t;
  1978. begin
  1979. WACS_SBSS:= _nc_wacs[chtype('u')];
  1980. end;
  1981. function WACS_SSSB: cchar_t;
  1982. begin
  1983. WACS_SSSB:= _nc_wacs[chtype('t')];
  1984. end;
  1985. function WACS_SSBS: cchar_t;
  1986. begin
  1987. WACS_SSBS:= _nc_wacs[chtype('v')];
  1988. end;
  1989. function WACS_BSSS: cchar_t;
  1990. begin
  1991. WACS_BSSS:= _nc_wacs[chtype('w')];
  1992. end;
  1993. function WACS_BSBS: cchar_t;
  1994. begin
  1995. WACS_BSBS:= _nc_wacs[chtype('q')];
  1996. end;
  1997. function WACS_SBSB: cchar_t;
  1998. begin
  1999. WACS_SBSB:= _nc_wacs[chtype('x')];
  2000. end;
  2001. function WACS_SSSS: cchar_t;
  2002. begin
  2003. WACS_SSSS:= _nc_wacs[chtype('n')];
  2004. end;
  2005. function WACS_S1: cchar_t;
  2006. begin
  2007. WACS_S1:= _nc_wacs[chtype('o')];
  2008. end;
  2009. function WACS_S9: cchar_t;
  2010. begin
  2011. WACS_S9:= _nc_wacs[chtype('s')];
  2012. end;
  2013. function WACS_DIAMOND: cchar_t;
  2014. begin
  2015. WACS_DIAMOND:= _nc_wacs[chtype('`')];
  2016. end;
  2017. function WACS_CKBOARD: cchar_t;
  2018. begin
  2019. WACS_CKBOARD:= _nc_wacs[chtype('a')];
  2020. end;
  2021. function WACS_DEGREE: cchar_t;
  2022. begin
  2023. WACS_DEGREE:= _nc_wacs[chtype('f')];
  2024. end;
  2025. function WACS_PLMINUS: cchar_t;
  2026. begin
  2027. WACS_PLMINUS:= _nc_wacs[chtype('g')];
  2028. end;
  2029. function WACS_BULLET: cchar_t;
  2030. begin
  2031. WACS_BULLET:= _nc_wacs[chtype('~')];
  2032. end;
  2033. function WACS_LARROW: cchar_t;
  2034. begin
  2035. WACS_LARROW:= _nc_wacs[chtype(',')];
  2036. end;
  2037. function WACS_RARROW: cchar_t;
  2038. begin
  2039. WACS_RARROW:= _nc_wacs[chtype('+')];
  2040. end;
  2041. function WACS_DARROW: cchar_t;
  2042. begin
  2043. WACS_DARROW:= _nc_wacs[chtype('.')];
  2044. end;
  2045. function WACS_UARROW: cchar_t;
  2046. begin
  2047. WACS_UARROW:= _nc_wacs[chtype('-')];
  2048. end;
  2049. function WACS_BOARD: cchar_t;
  2050. begin
  2051. WACS_BOARD:= _nc_wacs[chtype('h')];
  2052. end;
  2053. function WACS_LANTERN: cchar_t;
  2054. begin
  2055. WACS_LANTERN:= _nc_wacs[chtype('i')];
  2056. end;
  2057. function WACS_BLOCK: cchar_t;
  2058. begin
  2059. WACS_BLOCK:= _nc_wacs[chtype('0')];
  2060. end;
  2061. function WACS_S3: cchar_t;
  2062. begin
  2063. WACS_S3:= _nc_wacs[chtype('p')];
  2064. end;
  2065. function WACS_S7: cchar_t;
  2066. begin
  2067. WACS_S7:= _nc_wacs[chtype('r')];
  2068. end;
  2069. function WACS_LEQUAL: cchar_t;
  2070. begin
  2071. WACS_LEQUAL:= _nc_wacs[chtype('y')];
  2072. end;
  2073. function WACS_GEQUAL: cchar_t;
  2074. begin
  2075. WACS_GEQUAL:= _nc_wacs[chtype('z')];
  2076. end;
  2077. function WACS_PI: cchar_t;
  2078. begin
  2079. WACS_PI:= _nc_wacs[chtype('{')];
  2080. end;
  2081. function WACS_NEQUAL: cchar_t;
  2082. begin
  2083. WACS_NEQUAL:= _nc_wacs[chtype('|')];
  2084. end;
  2085. function WACS_STERLING: cchar_t;
  2086. begin
  2087. WACS_STERLING:= _nc_wacs[chtype('}')];
  2088. end;
  2089. function add_wch(wch: pcchar_t): longint;
  2090. begin
  2091. add_wch:=wadd_wch(stdscr,wch);
  2092. end;
  2093. function add_wchnstr(wchstr: pcchar_t; n: longint): longint;
  2094. begin
  2095. add_wchnstr:=wadd_wchnstr(stdscr,wchstr,n);
  2096. end;
  2097. function add_wchstr(wchstr: pcchar_t): longint;
  2098. begin
  2099. add_wchstr:=wadd_wchstr(stdscr,wchstr);
  2100. end;
  2101. function addnwstr(wchstr: pwchar_t; n : longint) : longint;
  2102. begin
  2103. addnwstr:=waddnwstr(stdscr,wchstr,n);
  2104. end;
  2105. function addwstr(wchstr: pwchar_t): longint;
  2106. begin
  2107. addwstr:=waddnwstr(stdscr,wchstr,-(1));
  2108. end;
  2109. function bkgrnd(wch: pcchar_t): longint;
  2110. begin
  2111. bkgrnd:=wbkgrnd(stdscr,wch);
  2112. end;
  2113. procedure bkgrndset(wch: pcchar_t);
  2114. begin
  2115. wbkgrndset(stdscr,wch);
  2116. end;
  2117. function border_set(ls,rs,ts,bs,tl,tr,bl,br: pcchar_t) : longint;
  2118. begin
  2119. border_set:=wborder_set(stdscr,ls,rs,ts,bs,tl,tr,bl,br);
  2120. end;
  2121. function box_set(win: PWINDOW; verch,horch: pcchar_t) : longint;
  2122. begin
  2123. //box_set:=wborder_set(win,verch,verch,horch,horch,0,0,0,0);
  2124. box_set:=wborder_set(win,verch,verch,horch,horch,nil,nil,nil,nil);
  2125. end;
  2126. function echo_wchar(wch: Pcchar_t): longint;
  2127. begin
  2128. echo_wchar:=wecho_wchar(stdscr,wch);
  2129. end;
  2130. function get_wch(wch: Plongint): longint;
  2131. begin
  2132. get_wch:=wget_wch(stdscr,wch);
  2133. end;
  2134. function get_wstr(wstr: PLongint): longint;
  2135. begin
  2136. get_wstr:=wget_wstr(stdscr,wstr);
  2137. end;
  2138. function getbkgrnd(wch: pcchar_t): longint;
  2139. begin
  2140. getbkgrnd := wgetbkgrnd(stdscr,wch);
  2141. end;
  2142. function getn_wstr(wstr: PLongint; n: longint): longint;
  2143. begin
  2144. getn_wstr := wgetn_wstr(stdscr,wstr,n);
  2145. end;
  2146. function hline_set(wch: pcchar_t; n: longint): longint;
  2147. begin
  2148. hline_set := whline_set(stdscr,wch,n);
  2149. end;
  2150. function in_wch(wch: pcchar_t) : longint;
  2151. begin
  2152. in_wch := win_wch(stdscr,wch);
  2153. end;
  2154. function in_wchnstr(wchstr: pcchar_t; n: longint): longint;
  2155. begin
  2156. in_wchnstr := win_wchnstr(stdscr,wchstr,n);
  2157. end;
  2158. function in_wchstr(wchstr: pcchar_t) : longint;
  2159. begin
  2160. in_wchstr := win_wchstr(stdscr,wchstr);
  2161. end;
  2162. function innwstr(wstr: pwchar_t; n : longint) : longint;
  2163. begin
  2164. innwstr:=winnwstr(stdscr,wstr,n);
  2165. end;
  2166. function ins_nwstr(wstr: pwchar_t; n: longint): longint;
  2167. begin
  2168. ins_nwstr:=wins_nwstr(stdscr,wstr,n);
  2169. end;
  2170. function ins_wch(wch: pcchar_t): longint;
  2171. begin
  2172. ins_wch:=wins_wch(stdscr,wch);
  2173. end;
  2174. function ins_wstr(wstr: pwchar_t): longint;
  2175. begin
  2176. ins_wstr:=wins_wstr(stdscr,wstr);
  2177. end;
  2178. function inwstr(wstr: pwchar_t): longint;
  2179. begin
  2180. inwstr:=winwstr(stdscr,wstr);
  2181. end;
  2182. function vline_set(wch: pcchar_t; n: longint): longint;
  2183. begin
  2184. vline_set:=wvline_set(stdscr,wch,n);
  2185. end;
  2186. function wadd_wchstr(win: PWINDOW; wchstr: pcchar_t): longint;
  2187. begin
  2188. wadd_wchstr:=wadd_wchnstr(win,wchstr,-(1));
  2189. end;
  2190. function waddwstr(win: PWINDOW; wstr: pwchar_t): longint;
  2191. begin
  2192. waddwstr:=waddnwstr(win,wstr,-(1));
  2193. end;
  2194. function wget_wstr(win: PWINDOW; wstr: PLongint): longint;
  2195. begin
  2196. wget_wstr:=wgetn_wstr(win,wstr,-(1));
  2197. end;
  2198. function win_wchstr(win: PWINDOW; wchstr: pcchar_t): longint;
  2199. begin
  2200. win_wchstr:=win_wchnstr(win,wchstr,-(1));
  2201. end;
  2202. function wins_wstr(win: PWINDOW; wstr: pwchar_t) : longint;
  2203. begin
  2204. wins_wstr:=wins_nwstr(win,wstr,-(1));
  2205. end;
  2206. function mvadd_wch(y,x: Smallint; wch: pcchar_t): longint;
  2207. begin
  2208. if move(y,x) = ERR then
  2209. mvadd_wch := ERR
  2210. else
  2211. mvadd_wch := wadd_wch(stdscr,wch);
  2212. end;
  2213. function mvadd_wchnstr(y,x: Smallint; wchstr: pcchar_t; n: longint): longint;
  2214. begin
  2215. if move(y,x) = ERR then
  2216. mvadd_wchnstr := ERR
  2217. else
  2218. mvadd_wchnstr := wadd_wchnstr(stdscr,wchstr,n);
  2219. end;
  2220. function mvadd_wchstr(y,x: Smallint; wchstr: pcchar_t): longint;
  2221. begin
  2222. if move(y,x) = ERR then
  2223. mvadd_wchstr := ERR
  2224. else
  2225. mvadd_wchstr := wadd_wchnstr(stdscr,wchstr,-(1));
  2226. end;
  2227. function mvaddnwstr(y,x: Smallint; wstr: pwchar_t; n: longint): longint;
  2228. begin
  2229. if move(y,x) = ERR then
  2230. mvaddnwstr := ERR
  2231. else
  2232. mvaddnwstr := waddnwstr(stdscr,wstr,n);
  2233. end;
  2234. function mvaddwstr(y,x: Smallint; wstr: pwchar_t) : longint;
  2235. begin
  2236. if move(y,x) = ERR then
  2237. mvaddwstr := ERR
  2238. else
  2239. mvaddwstr := waddnwstr(stdscr,wstr,-(1));
  2240. end;
  2241. function mvget_wch(y,x: Smallint; wch: Plongint) : longint;
  2242. begin
  2243. if move(y,x) = ERR then
  2244. mvget_wch := ERR
  2245. else
  2246. mvget_wch := wget_wch(stdscr,wch);
  2247. end;
  2248. function mvget_wstr(y,x: Smallint; wstr: Plongint): longint;
  2249. begin
  2250. if move(y,x) = ERR then
  2251. mvget_wstr := ERR
  2252. else
  2253. mvget_wstr := wgetn_wstr(stdscr,wstr,-(1));
  2254. end;
  2255. function mvgetn_wstr(y,x: Smallint; wstr: Plongint; n: longint): longint;
  2256. begin
  2257. if move(y,x) = ERR then
  2258. mvgetn_wstr := ERR
  2259. else
  2260. mvgetn_wstr := wgetn_wstr(stdscr,wstr,n);
  2261. end;
  2262. function mvhline_set(y,x: Smallint; wch: pcchar_t; n: longint): longint;
  2263. begin
  2264. if move(y,x) = ERR then
  2265. mvhline_set := ERR
  2266. else
  2267. mvhline_set := whline_set(stdscr,wch,n);
  2268. end;
  2269. function mvin_wch(y,x: Smallint; wch: pcchar_t) : longint;
  2270. begin
  2271. if move(y,x) = ERR then
  2272. mvin_wch := ERR
  2273. else
  2274. mvin_wch := win_wch(stdscr,wch);
  2275. end;
  2276. function mvin_wchnstr(y,x: Smallint; wchstr: pcchar_t; n: longint): longint;
  2277. begin
  2278. if move(y,x) = ERR then
  2279. mvin_wchnstr := ERR
  2280. else
  2281. mvin_wchnstr := win_wchnstr(stdscr,wchstr,n);
  2282. end;
  2283. function mvin_wchstr(y,x: Smallint; wchstr: pcchar_t): longint;
  2284. begin
  2285. if move(y,x) = ERR then
  2286. mvin_wchstr := ERR
  2287. else
  2288. mvin_wchstr := win_wchnstr(stdscr,wchstr,-(1));
  2289. end;
  2290. function mvinnwstr(y,x: Smallint; wstr: pwchar_t; n : longint): longint;
  2291. begin
  2292. if move(y,x) = ERR then
  2293. mvinnwstr := ERR
  2294. else
  2295. mvinnwstr := winnwstr(stdscr,wstr,n);
  2296. end;
  2297. function mvins_nwstr(y,x: Smallint; wstr: pwchar_t; n : longint): longint;
  2298. begin
  2299. if move(y,x) = ERR then
  2300. mvins_nwstr := ERR
  2301. else
  2302. mvins_nwstr := wins_nwstr(stdscr,wstr,n);
  2303. end;
  2304. function mvins_wch(y,x: Smallint; wch: pcchar_t): longint;
  2305. begin
  2306. if move(y,x) = ERR then
  2307. mvins_wch := ERR
  2308. else
  2309. mvins_wch := wins_wch(stdscr,wch);
  2310. end;
  2311. function mvins_wstr(y,x: Smallint; wstr: pwchar_t): longint;
  2312. begin
  2313. if move(y,x) = ERR then
  2314. mvins_wstr := ERR
  2315. else
  2316. mvins_wstr := wins_nwstr(stdscr,wstr,-(1));
  2317. end;
  2318. function mvinwstr(y,x: Smallint; wstr: pwchar_t): longint;
  2319. begin
  2320. if move(y,x) = ERR then
  2321. mvinwstr := ERR
  2322. else
  2323. mvinwstr := winwstr(stdscr,wstr);
  2324. end;
  2325. function mvvline_set(y,x: Smallint; wch: pcchar_t; n : longint) : longint;
  2326. begin
  2327. if move(y,x) = ERR then
  2328. mvvline_set := ERR
  2329. else
  2330. mvvline_set := wvline_set(stdscr,wch,n);
  2331. end;
  2332. function mvwadd_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint;
  2333. begin
  2334. if wmove(win,y,x) = ERR then
  2335. mvwadd_wch := ERR
  2336. else
  2337. mvwadd_wch := wadd_wch(win,wch);
  2338. end;
  2339. function mvwadd_wchnstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t; n: longint): longint;
  2340. begin
  2341. if wmove(win,y,x) = ERR then
  2342. mvwadd_wchnstr := ERR
  2343. else
  2344. mvwadd_wchnstr := wadd_wchnstr(win,wchstr,n);
  2345. end;
  2346. function mvwadd_wchstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t): longint;
  2347. begin
  2348. if wmove(win,y,x) = ERR then
  2349. mvwadd_wchstr := ERR
  2350. else
  2351. mvwadd_wchstr := wadd_wchnstr(win,wchstr,-(1));
  2352. end;
  2353. function mvwaddnwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n: longint): longint;
  2354. begin
  2355. if wmove(win,y,x) = ERR then
  2356. mvwaddnwstr := ERR
  2357. else
  2358. mvwaddnwstr := waddnwstr(win,wstr,n);
  2359. end;
  2360. function mvwaddwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t): longint;
  2361. begin
  2362. if wmove(win,y,x) = ERR then
  2363. mvwaddwstr := ERR
  2364. else
  2365. mvwaddwstr := waddnwstr(win,wstr,-(1));
  2366. end;
  2367. function mvwget_wch(win: PWINDOW; y,x: Smallint; wch: Plongint): longint;
  2368. begin
  2369. if wmove(win,y,x) = ERR then
  2370. mvwget_wch := ERR
  2371. else
  2372. mvwget_wch := wget_wch(win,wch);
  2373. end;
  2374. function mvwget_wstr(win: PWINDOW; y,x: Smallint; wstr: Plongint): longint;
  2375. begin
  2376. if wmove(win,y,x) = ERR then
  2377. mvwget_wstr := ERR
  2378. else
  2379. mvwget_wstr := wgetn_wstr(win,wstr,-(1));
  2380. end;
  2381. function mvwgetn_wstr(win: PWINDOW; y,x: Smallint; wstr: Plongint; n: longint): longint;
  2382. begin
  2383. if wmove(win,y,x) = ERR then
  2384. mvwgetn_wstr := ERR
  2385. else
  2386. mvwgetn_wstr := wgetn_wstr(win,wstr,n);
  2387. end;
  2388. function mvwhline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint): longint;
  2389. begin
  2390. if wmove(win,y,x) = ERR then
  2391. mvwhline_set := ERR
  2392. else
  2393. mvwhline_set := whline_set(win,wch,n);
  2394. end;
  2395. function mvwin_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint;
  2396. begin
  2397. if wmove(win,y,x) = ERR then
  2398. mvwin_wch := ERR
  2399. else
  2400. mvwin_wch := win_wch(win,wch);
  2401. end;
  2402. function mvwin_wchnstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t; n: longint): longint;
  2403. begin
  2404. if wmove(win,y,x) = ERR then
  2405. mvwin_wchnstr := ERR
  2406. else
  2407. mvwin_wchnstr := win_wchnstr(win,wchstr,n);
  2408. end;
  2409. function mvwin_wchstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t): longint;
  2410. begin
  2411. if wmove(win,y,x) = ERR then
  2412. mvwin_wchstr := ERR
  2413. else
  2414. mvwin_wchstr := win_wchstr(win,wchstr);
  2415. end;
  2416. function mvwinnwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n : longint): longint;
  2417. begin
  2418. if wmove(win,y,x) = ERR then
  2419. mvwinnwstr := ERR
  2420. else
  2421. mvwinnwstr := winnwstr(win,wstr,n);
  2422. end;
  2423. function mvwins_nwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n: longint): longint;
  2424. begin
  2425. if wmove(win,y,x) = ERR then
  2426. mvwins_nwstr := ERR
  2427. else
  2428. mvwins_nwstr := wins_nwstr(win,wstr,n);
  2429. end;
  2430. function mvwins_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint;
  2431. begin
  2432. if wmove(win,y,x) = ERR then
  2433. mvwins_wch := ERR
  2434. else
  2435. mvwins_wch := wins_wch(win,wch);
  2436. end;
  2437. function mvwins_wstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint;
  2438. begin
  2439. if wmove(win,y,x) = ERR then
  2440. mvwins_wstr := ERR
  2441. else
  2442. mvwins_wstr := wins_wstr(win,wstr);
  2443. end;
  2444. function mvwinwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint;
  2445. begin
  2446. if wmove(win,y,x) = ERR then
  2447. mvwinwstr := ERR
  2448. else
  2449. mvwinwstr := winwstr(stdscr,wstr);
  2450. end;
  2451. function mvwvline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint) : longint;
  2452. begin
  2453. if wmove(win,y,x) = ERR then
  2454. mvwvline_set := ERR
  2455. else
  2456. mvwvline_set := wvline_set(win,wch,n);
  2457. end;
  2458. function wmove(win: PWINDOW; y,x: Smallint): Longint;
  2459. begin
  2460. //if (win!=nil)AND(x>=0)AND(x<=win^._maxx)AND(y>=0)AND(y<=win^._maxy) then
  2461. if (x>=0) and ( y>=0)AND(x<=win^._maxx)AND(y<=win^._maxy) then
  2462. begin
  2463. win^._curx := x;
  2464. win^._cury := y;
  2465. win^._flags := win^._flags AND not _WRAPPED;
  2466. win^._flags := win^._flags OR _HASMOVED;
  2467. wmove := OK
  2468. end
  2469. else
  2470. wmove := ERR
  2471. end;
  2472. (* macros to extract single event-bits from masks *)
  2473. function BUTTON_RELEASE(e,x: longint): longint;
  2474. { #define BUTTON_RELEASE(e, x) ((e) & (001 << (6 * ((x) - 1)))) }
  2475. begin
  2476. BUTTON_RELEASE:=e AND (001 shl (6*(x-1)));
  2477. end;
  2478. function BUTTON_PRESS(e,x: longint): longint;
  2479. { #define BUTTON_PRESS(e, x) ((e) & (002 << (6 * ((x) - 1)))) }
  2480. begin
  2481. BUTTON_PRESS:=e AND (002 shl (6*(x-1)));
  2482. end;
  2483. function BUTTON_CLICK(e,x: longint): longint;
  2484. //#define BUTTON_CLICK(e, x) ((e) & (004 << (6 * ((x) - 1))))
  2485. begin
  2486. BUTTON_CLICK:=e AND (004 shl (6*(x-1)));
  2487. end;
  2488. function BUTTON_DOUBLE_CLICK(e,x: longint): longint;
  2489. //#define BUTTON_DOUBLE_CLICK(e, x) ((e) & (010 << (6 * ((x) - 1))))
  2490. begin
  2491. BUTTON_DOUBLE_CLICK:=e AND (8 shl (6*(x-1)));
  2492. end;
  2493. function BUTTON_TRIPLE_CLICK(e,x: longint): longint;
  2494. //#define BUTTON_TRIPLE_CLICK(e, x) ((e) & (020 << (6 * ((x) - 1))))
  2495. begin
  2496. BUTTON_TRIPLE_CLICK:=e AND (16 shl (6*(x-1)));
  2497. end;
  2498. function BUTTON_RESERVED_EVENT(e,x: longint): longint;
  2499. //#define BUTTON_RESERVED_EVENT(e, x) ((e) & (040 << (6 * ((x) - 1))))
  2500. begin
  2501. BUTTON_RESERVED_EVENT:=e AND (32 shl (6*(x-1)));
  2502. end;
  2503. function mouse_trafo(pY,pX: PLongint; to_screen: Bool): Bool;
  2504. begin
  2505. mouse_trafo:=wmouse_trafo(stdscr,pY,pX,to_screen);
  2506. end;
  2507. end.