ncurses.pp 90 KB

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