menu.pp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. unit menu;
  2. {---------------------------------------------------------------------------
  3. CncWare
  4. ----------------------------------------------------------------------------
  5. Filename..: menu.pp
  6. Programmer: Ken J. Wright
  7. Date......: 07/12/2000
  8. Purpose - Link to the Linux 'menu' library for ncurses menuing
  9. functions.
  10. -------------------------------< Revisions >---------------------------------
  11. Revision| Date | Prog| Description
  12. -----------------------------------------------------------------------------
  13. 1.00 | 07/12/00 | kjw | Initial release.
  14. -----------------------------------------------------------------------------
  15. }
  16. { Automatically converted by H2PAS.EXE from menu.h
  17. Utility made by Florian Klaempfl 25th-28th september 96
  18. Improvements made by Mark A. Malakanov 22nd-25th may 97
  19. Further improvements by Michael Van Canneyt, April 1998
  20. define handling and error recovery by Pierre Muller, June 1998 }
  21. interface
  22. { C default packing is dword }
  23. {$PACKRECORDS 4}
  24. {
  25. Copyright (c) 1998 Free Software Foundation, Inc.
  26. Permission is hereby granted, free of charge, to any person obtaining a
  27. copy of this software and associated documentation files (the
  28. "Software"), to deal in the Software without restriction, including
  29. without limitation the rights to use, copy, modify, merge, publish,
  30. distribute, distribute with modifications, sublicense, and/or sell
  31. copies of the Software, and to permit persons to whom the Software is
  32. furnished to do so, subject to the following conditions:
  33. The above copyright notice and this permission notice shall be included
  34. in all copies or substantial portions of the Software.
  35. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  36. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  37. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  38. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  39. DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  40. OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
  41. THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  42. Except as contained in this notice, the name(s) of the above copyright
  43. holders shall not be used in advertising or otherwise to promote the
  44. sale, use or other dealings in this Software without prior written
  45. authorization.
  46. }
  47. {
  48. Author: Juergen Pfeifer <[email protected]> 1995,1997
  49. }
  50. {$linklib menu}
  51. uses ncurses;
  52. {$include eti.inc}
  53. const
  54. libmenu = 'menu';
  55. type
  56. Menu_Options = longint;
  57. Item_Options = longint;
  58. const
  59. { Menu options: }
  60. O_ONEVALUE = $01;
  61. O_SHOWDESC = $02;
  62. O_ROWMAJOR = $04;
  63. O_IGNORECASE = $08;
  64. O_SHOWMATCH = $10;
  65. O_NONCYCLIC = $20;
  66. { Item options: }
  67. O_SELECTABLE = $01;
  68. type
  69. tTEXT = record
  70. str : pchar;
  71. length : word;
  72. end;
  73. tITEM = record
  74. name : tTEXT; { name of menu item }
  75. description : tTEXT; { description of item, optional in display }
  76. imenu : ^tagMENU; { Pointer to parent menu }
  77. userptr : pointer; { Pointer to user defined per item data }
  78. opt : Item_Options; { Item options }
  79. index : integer; { Item number if connected to a menu }
  80. y : integer; { y and x location of item in menu }
  81. x : integer;
  82. value : bool; { Selection value }
  83. left : ^tagITEM; { neighbour items }
  84. right : ^tagITEM;
  85. up : ^tagITEM;
  86. down : ^tagITEM;
  87. end;
  88. pITEM = ^tITEM;
  89. ppITEM = ^pITEM;
  90. tagITEM = tITEM;
  91. Menu_Hook = procedure;cdecl;
  92. tMENU = record
  93. height : integer; { Nr. of chars high }
  94. width : integer; { Nr. of chars wide }
  95. rows : integer; { Nr. of items high }
  96. cols : integer; { Nr. of items wide }
  97. frows : integer; { Nr. of formatted items high }
  98. fcols : integer; { Nr. of formatted items wide }
  99. arows : integer; { Nr. of items high (actual) }
  100. namelen : integer; { Max. name length }
  101. desclen : integer; { Max. description length }
  102. marklen : integer; { Length of mark, if any }
  103. itemlen : integer; { Length of one item }
  104. spc_desc : integer; { Spacing for descriptor }
  105. spc_cols : integer; { Spacing for columns }
  106. spc_rows : integer; { Spacing for rows }
  107. pattern : ^char; { Buffer to store match chars }
  108. pindex : integer; { Index into pattern buffer }
  109. win : ^WINDOW; { Window containing menu }
  110. sub : ^WINDOW; { Subwindow for menu display }
  111. userwin : ^WINDOW; { User's window }
  112. usersub : ^WINDOW; { User's subwindow }
  113. items : ^pITEM; { array of items }
  114. nitems : integer; { Nr. of items in menu }
  115. curitem : pITEM; { Current item }
  116. toprow : integer; { Top row of menu }
  117. fore : chtype; { Selection attribute }
  118. back : chtype; { Nonselection attribute }
  119. grey : chtype; { Inactive attribute }
  120. pad : byte; { Pad character }
  121. menuinit : Menu_Hook; { User hooks }
  122. menuterm : Menu_Hook;
  123. iteminit : Menu_Hook;
  124. itemterm : Menu_Hook;
  125. userptr : pointer; { Pointer to menus user data }
  126. mark : pchar; { Pointer to marker string }
  127. opt : Menu_Options; { Menu options }
  128. status : word; { Internal state of menu }
  129. end;
  130. pMENU = ^tMENU;
  131. ppMENU = ^pMENU;
  132. tagMENU = tMENU;
  133. const
  134. { Define keys }
  135. REQ_LEFT_ITEM = KEY_MAX + 1;
  136. REQ_RIGHT_ITEM = KEY_MAX + 2;
  137. REQ_UP_ITEM = KEY_MAX + 3;
  138. REQ_DOWN_ITEM = KEY_MAX + 4;
  139. REQ_SCR_ULINE = KEY_MAX + 5;
  140. REQ_SCR_DLINE = KEY_MAX + 6;
  141. REQ_SCR_DPAGE = KEY_MAX + 7;
  142. REQ_SCR_UPAGE = KEY_MAX + 8;
  143. REQ_FIRST_ITEM = KEY_MAX + 9;
  144. REQ_LAST_ITEM = KEY_MAX + 10;
  145. REQ_NEXT_ITEM = KEY_MAX + 11;
  146. REQ_PREV_ITEM = KEY_MAX + 12;
  147. REQ_TOGGLE_ITEM = KEY_MAX + 13;
  148. REQ_CLEAR_PATTERN = KEY_MAX + 14;
  149. REQ_BACK_PATTERN = KEY_MAX + 15;
  150. REQ_NEXT_MATCH = KEY_MAX + 16;
  151. REQ_PREV_MATCH = KEY_MAX + 17;
  152. MIN_MENU_COMMAND = KEY_MAX + 1;
  153. MAX_MENU_COMMAND = KEY_MAX + 17;
  154. {
  155. Some AT&T code expects MAX_COMMAND to be out-of-band not
  156. just for menu commands but for forms ones as well.
  157. /
  158. #if defined(MAX_COMMAND)
  159. # if (MAX_MENU_COMMAND > MAX_COMMAND)
  160. # error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND
  161. # elif (MAX_COMMAND != (KEY_MAX + 128))
  162. # error Something is wrong -- MAX_COMMAND is already inconsistently defined.
  163. # endif
  164. #else
  165. # define MAX_COMMAND (KEY_MAX + 128)
  166. #endif
  167. }
  168. { --------- prototypes for libmenu functions ----------------------------- }
  169. function menu_items(_para1:pMENU):ppITEM;cdecl;external libmenu;
  170. function current_item(_para1:pMENU):pITEM;cdecl;external libmenu;
  171. function new_item(_para1:pchar; _para2:pchar):pITEM;cdecl;external libmenu;
  172. function new_menu(_para1:ppITEM):pMENU;cdecl;external libmenu;
  173. function item_opts(_para1:pITEM):Item_Options;cdecl;external libmenu;
  174. function menu_opts(_para1:pMENU):Menu_Options;cdecl;external libmenu;
  175. (*
  176. function item_init(_para1:pMENU):Menu_Hook;
  177. begin
  178. { You must implemented this function }
  179. end;
  180. function item_term(_para1:pMENU):Menu_Hook;
  181. begin
  182. { You must implemented this function }
  183. end;
  184. function menu_init(_para1:pMENU):Menu_Hook;
  185. begin
  186. { You must implemented this function }
  187. end;
  188. function menu_term(_para1:pMENU):Menu_Hook;
  189. begin
  190. { You must implemented this function }
  191. end;
  192. *)
  193. function menu_sub(_para1:pMENU):pWINDOW;cdecl;external libmenu;
  194. function menu_win(_para1:pMENU):pWINDOW;cdecl;external libmenu;
  195. function item_description(_para1:pITEM):pchar;cdecl;external libmenu;
  196. function item_name(_para1:pITEM):pchar;cdecl;external libmenu;
  197. function menu_mark(_para1:pMENU):pchar;cdecl;external libmenu;
  198. function menu_request_name(_para1:longint):pchar;cdecl;external libmenu;
  199. function menu_pattern(_para1:pMENU):pchar;cdecl;external libmenu;
  200. function menu_userptr(_para1:pMENU):pointer;cdecl;external libmenu;
  201. function item_userptr(_para1:pITEM):pointer;cdecl;external libmenu;
  202. function menu_back(_para1:pMENU):chtype;cdecl;external libmenu;
  203. function menu_fore(_para1:pMENU):chtype;cdecl;external libmenu;
  204. function menu_grey(_para1:pMENU):chtype;cdecl;external libmenu;
  205. function free_item(_para1:pITEM):longint;cdecl;external libmenu;
  206. function free_menu(_para1:pMENU):longint;cdecl;external libmenu;
  207. function item_count(_para1:pMENU):longint;cdecl;external libmenu;
  208. function item_index(_para1:pITEM):longint;cdecl;external libmenu;
  209. function item_opts_off(_para1:pITEM; _para2:Item_Options):longint;cdecl;external libmenu;
  210. function item_opts_on(_para1:pITEM; _para2:Item_Options):longint;cdecl;external libmenu;
  211. function menu_driver(_para1:pMENU; _para2:longint):longint;cdecl;external libmenu;
  212. function menu_opts_off(_para1:pMENU; _para2:Menu_Options):longint;cdecl;external libmenu;
  213. function menu_opts_on(_para1:pMENU; _para2:Menu_Options):longint;cdecl;external libmenu;
  214. function menu_pad(_para1:pMENU):longint;cdecl;external libmenu;
  215. function pos_menu_cursor(_para1:pMENU):longint;cdecl;external libmenu;
  216. function post_menu(_para1:pMENU):longint;cdecl;external libmenu;
  217. function scale_menu(_para1:pMENU; _para2:plongint; _para3:plongint):longint;cdecl;external libmenu;
  218. function set_current_item(menu:pMENU; item:pITEM):longint;cdecl;external libmenu;
  219. { function set_item_init(_para1:pMENU; _para2:Menu_Hook):longint;cdecl;external libmenu;}
  220. function set_item_opts(_para1:pITEM; _para2:Item_Options):longint;cdecl;external libmenu;
  221. { function set_item_term(_para1:pMENU; _para2:Menu_Hook):longint;cdecl;external libmenu;}
  222. function set_item_userptr(_para1:pITEM; _para2:pointer):longint;cdecl;external libmenu;
  223. function set_item_value(_para1:pITEM; _para2:bool):longint;cdecl;external libmenu;
  224. function set_menu_back(_para1:pMENU; _para2:chtype):longint;cdecl;external libmenu;
  225. function set_menu_fore(_para1:pMENU; _para2:chtype):longint;cdecl;external libmenu;
  226. function set_menu_format(_para1:pMENU; _para2:longint; _para3:longint):longint;cdecl;external libmenu;
  227. function set_menu_grey(_para1:pMENU; _para2:chtype):longint;cdecl;external libmenu;
  228. { function set_menu_init(_para1:pMENU; _para2:Menu_Hook):longint;cdecl;external libmenu;}
  229. function set_menu_items(_para1:pMENU; _para2:ppITEM):longint;cdecl;external libmenu;
  230. function set_menu_mark(_para1:pMENU; _para2:pchar):longint;cdecl;external libmenu;
  231. function set_menu_opts(_para1:pMENU; _para2:Menu_Options):longint;cdecl;external libmenu;
  232. function set_menu_pad(_para1:pMENU; _para2:longint):longint;cdecl;external libmenu;
  233. function set_menu_pattern(_para1:pMENU; _para2:pchar):longint;cdecl;external libmenu;
  234. function set_menu_sub(_para1:pMENU; _para2:pWINDOW):longint;cdecl;external libmenu;
  235. { function set_menu_term(_para1:pMENU; _para2:Menu_Hook):longint;cdecl;external libmenu;}
  236. function set_menu_userptr(_para1:pMENU; _para2:pointer):longint;cdecl;external libmenu;
  237. function set_menu_win(_para1:pMENU; _para2:pWINDOW):longint;cdecl;external libmenu;
  238. function set_top_row(_para1:pMENU; _para2:longint):longint;cdecl;external libmenu;
  239. function top_row(_para1:pMENU):longint;cdecl;external libmenu;
  240. function unpost_menu(_para1:pMENU):longint;cdecl;external libmenu;
  241. function menu_request_by_name(_para1:pchar):longint;cdecl;external libmenu;
  242. function set_menu_spacing(_para1:pMENU; _para2:longint; _para3:longint; _para4:longint):longint;cdecl;external libmenu;
  243. function menu_spacing(_para1:pMENU; _para2:plongint; _para3:plongint; _para4:plongint):longint;cdecl;external libmenu;
  244. function item_value(_para1:pITEM):bool;cdecl;external libmenu;
  245. function item_visible(_para1:pITEM):bool;cdecl;external libmenu;
  246. (*
  247. procedure menu_format(_para1:pMENU; _para2:plongint; _para3:plongint);
  248. begin
  249. { You must implemented this function }
  250. end;
  251. *)
  252. implementation
  253. begin
  254. end.