terminfo.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. {
  2. $Id$
  3. An interface unit for the terminfo database
  4. Copyright (c) 1997 Balazs Scheidler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, write to the Free
  15. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. unit TermInfo;
  18. interface
  19. {$linklib ncurses}
  20. {$linklib c}
  21. const
  22. { boolean values }
  23. auto_left_margin = 0;
  24. auto_right_margin = 1;
  25. no_esc_ctlc = 2;
  26. ceol_standout_glitch = 3;
  27. eat_newline_glitch = 4;
  28. erase_overstrike = 5;
  29. generic_type = 6;
  30. hard_copy = 7;
  31. has_meta_key = 8;
  32. has_status_line = 9;
  33. insert_null_glitch = 10;
  34. memory_above = 11;
  35. memory_below = 12;
  36. move_insert_mode = 13;
  37. move_standout_mode = 14;
  38. over_strike = 15;
  39. status_line_esc_ok = 16;
  40. dest_tabs_magic_smso = 17;
  41. tilde_glitch = 18;
  42. transparent_underline = 19;
  43. xon_xoff = 20;
  44. needs_xon_xoff = 21;
  45. prtr_silent = 22;
  46. hard_cursor = 23;
  47. non_rev_rmcup = 24;
  48. no_pad_char = 25;
  49. non_dest_scroll_region = 26;
  50. can_change = 27;
  51. back_color_erase = 28;
  52. hue_lightness_saturation = 29;
  53. col_addr_glitch = 30;
  54. cr_cancels_micro_mode = 31;
  55. has_print_wheel = 32;
  56. row_addr_glitch = 33;
  57. semi_auto_right_margin = 34;
  58. cpi_changes_res = 35;
  59. lpi_changes_res = 36;
  60. { numbers ... }
  61. columns = 0;
  62. init_tabs = 1;
  63. lines = 2;
  64. lines_of_memory = 3;
  65. magic_cookie_glitch = 4;
  66. padding_baud_rate = 5;
  67. virtual_terminal = 6;
  68. width_status_line = 7;
  69. num_labels = 8;
  70. label_height = 9;
  71. label_width = 10;
  72. max_attributes = 11;
  73. maximum_windows = 12;
  74. max_colors = 13;
  75. max_pairs = 14;
  76. no_color_video = 15;
  77. buffer_capacity = 16;
  78. dot_vert_spacing = 17;
  79. dot_horz_spacing = 18;
  80. max_micro_address = 19;
  81. max_micro_jump = 20;
  82. micro_char_size = 21;
  83. micro_line_size = 22;
  84. number_of_pins = 23;
  85. output_res_char = 24;
  86. output_res_line = 25;
  87. output_res_horz_inch = 26;
  88. output_res_vert_inch = 27;
  89. print_rate = 28;
  90. wide_char_size = 29;
  91. buttons = 30;
  92. bit_image_entwining = 31;
  93. bit_image_type = 32;
  94. { strings }
  95. back_tab = 0;
  96. bell = 1;
  97. carriage_return = 2;
  98. change_scroll_region = 3;
  99. clear_all_tabs = 4;
  100. clear_screen = 5;
  101. clr_eol = 6;
  102. clr_eos = 7;
  103. column_address = 8;
  104. command_character = 9;
  105. cursor_address = 10;
  106. cursor_down = 11;
  107. cursor_home = 12;
  108. cursor_invisible = 13;
  109. cursor_left = 14;
  110. cursor_mem_address = 15;
  111. cursor_normal = 16;
  112. cursor_right = 17;
  113. cursor_to_ll = 18;
  114. cursor_up = 19;
  115. cursor_visible = 20;
  116. delete_character = 21;
  117. delete_line = 22;
  118. dis_status_line = 23;
  119. down_half_line = 24;
  120. enter_alt_charset_mode = 25;
  121. enter_blink_mode = 26;
  122. enter_bold_mode = 27;
  123. enter_ca_mode = 28;
  124. enter_delete_mode = 29;
  125. enter_dim_mode = 30;
  126. enter_insert_mode = 31;
  127. enter_secure_mode = 32;
  128. enter_protected_mode = 33;
  129. enter_reverse_mode = 34;
  130. enter_standout_mode = 35;
  131. enter_underline_mode = 36;
  132. erase_chars = 37;
  133. exit_alt_charset_mode = 38;
  134. exit_attribute_mode = 39;
  135. exit_ca_mode = 40;
  136. exit_delete_mode = 41;
  137. exit_insert_mode = 42;
  138. exit_standout_mode = 43;
  139. exit_underline_mode = 44;
  140. flash_screen = 45;
  141. form_feed = 46;
  142. from_status_line = 47;
  143. init_1string = 48;
  144. init_2string = 49;
  145. init_3string = 50;
  146. init_file = 51;
  147. insert_character = 52;
  148. insert_line = 53;
  149. insert_padding = 54;
  150. key_backspace = 55;
  151. key_catab = 56;
  152. key_clear = 57;
  153. key_ctab = 58;
  154. key_dc = 59;
  155. key_dl = 60;
  156. key_down = 61;
  157. key_eic = 62;
  158. key_eol = 63;
  159. key_eos = 64;
  160. key_f0 = 65;
  161. key_f1 = 66;
  162. key_f10 = 67;
  163. key_f2 = 68;
  164. key_f3 = 69;
  165. key_f4 = 70;
  166. key_f5 = 71;
  167. key_f6 = 72;
  168. key_f7 = 73;
  169. key_f8 = 74;
  170. key_f9 = 75;
  171. key_home = 76;
  172. key_ic = 77;
  173. key_il = 78;
  174. key_left = 79;
  175. key_ll = 80;
  176. key_npage = 81;
  177. key_ppage = 82;
  178. key_right = 83;
  179. key_sf = 84;
  180. key_sr = 85;
  181. key_stab = 86;
  182. key_up = 87;
  183. keypad_local = 88;
  184. keypad_xmit = 89;
  185. lab_f0 = 90;
  186. lab_f1 = 91;
  187. lab_f10 = 92;
  188. lab_f2 = 93;
  189. lab_f3 = 94;
  190. lab_f4 = 95;
  191. lab_f5 = 96;
  192. lab_f6 = 97;
  193. lab_f7 = 98;
  194. lab_f8 = 99;
  195. lab_f9 = 100;
  196. meta_off = 101;
  197. meta_on = 102;
  198. newline = 103;
  199. pad_char = 104;
  200. parm_dch = 105;
  201. parm_delete_line = 106;
  202. parm_down_cursor = 107;
  203. parm_ich = 108;
  204. parm_index = 109;
  205. parm_insert_line = 110;
  206. parm_left_cursor = 111;
  207. parm_right_cursor = 112;
  208. parm_rindex = 113;
  209. parm_up_cursor = 114;
  210. pkey_key = 115;
  211. pkey_local = 116;
  212. pkey_xmit = 117;
  213. print_screen = 118;
  214. prtr_off = 119;
  215. prtr_on = 120;
  216. repeat_char = 121;
  217. reset_1string = 122;
  218. reset_2string = 123;
  219. reset_3string = 124;
  220. reset_file = 125;
  221. restore_cursor = 126;
  222. row_address = 127;
  223. save_cursor = 128;
  224. scroll_forward = 129;
  225. scroll_reverse = 130;
  226. set_attributes = 131;
  227. set_tab = 132;
  228. set_window = 133;
  229. tab = 134;
  230. to_status_line = 135;
  231. underline_char = 136;
  232. up_half_line = 137;
  233. init_prog = 138;
  234. key_a1 = 139;
  235. key_a3 = 140;
  236. key_b2 = 141;
  237. key_c1 = 142;
  238. key_c3 = 143;
  239. prtr_non = 144;
  240. char_padding = 145;
  241. acs_chars = 146;
  242. plab_norm = 147;
  243. key_btab = 148;
  244. enter_xon_mode = 149;
  245. exit_xon_mode = 150;
  246. enter_am_mode = 151;
  247. exit_am_mode = 152;
  248. xon_character = 153;
  249. xoff_character = 154;
  250. ena_acs = 155;
  251. label_on = 156;
  252. label_off = 157;
  253. key_beg = 158;
  254. key_cancel = 159;
  255. key_close = 160;
  256. key_command = 161;
  257. key_copy = 162;
  258. key_create = 163;
  259. key_end = 164;
  260. key_enter = 165;
  261. key_exit = 166;
  262. key_find = 167;
  263. key_help = 168;
  264. key_mark = 169;
  265. key_message = 170;
  266. key_move = 171;
  267. key_next = 172;
  268. key_open = 173;
  269. key_options = 174;
  270. key_previous = 175;
  271. key_print = 176;
  272. key_redo = 177;
  273. key_reference = 178;
  274. key_refresh = 179;
  275. key_replace = 180;
  276. key_restart = 181;
  277. key_resume = 182;
  278. key_save = 183;
  279. key_suspend = 184;
  280. key_undo = 185;
  281. key_sbeg = 186;
  282. key_scancel = 187;
  283. key_scommand = 188;
  284. key_scopy = 189;
  285. key_screate = 190;
  286. key_sdc = 191;
  287. key_sdl = 192;
  288. key_select = 193;
  289. key_send = 194;
  290. key_seol = 195;
  291. key_sexit = 196;
  292. key_sfind = 197;
  293. key_shelp = 198;
  294. key_shome = 199;
  295. key_sic = 200;
  296. key_sleft = 201;
  297. key_smessage = 202;
  298. key_smove = 203;
  299. key_snext = 204;
  300. key_soptions = 205;
  301. key_sprevious = 206;
  302. key_sprint = 207;
  303. key_sredo = 208;
  304. key_sreplace = 209;
  305. key_sright = 210;
  306. key_srsume = 211;
  307. key_ssave = 212;
  308. key_ssuspend = 213;
  309. key_sundo = 214;
  310. req_for_input = 215;
  311. key_f11 = 216;
  312. key_f12 = 217;
  313. key_f13 = 218;
  314. key_f14 = 219;
  315. key_f15 = 220;
  316. key_f16 = 221;
  317. key_f17 = 222;
  318. key_f18 = 223;
  319. key_f19 = 224;
  320. key_f20 = 225;
  321. key_f21 = 226;
  322. key_f22 = 227;
  323. key_f23 = 228;
  324. key_f24 = 229;
  325. key_f25 = 230;
  326. key_f26 = 231;
  327. key_f27 = 232;
  328. key_f28 = 233;
  329. key_f29 = 234;
  330. key_f30 = 235;
  331. key_f31 = 236;
  332. key_f32 = 237;
  333. key_f33 = 238;
  334. key_f34 = 239;
  335. key_f35 = 240;
  336. key_f36 = 241;
  337. key_f37 = 242;
  338. key_f38 = 243;
  339. key_f39 = 244;
  340. key_f40 = 245;
  341. key_f41 = 246;
  342. key_f42 = 247;
  343. key_f43 = 248;
  344. key_f44 = 249;
  345. key_f45 = 250;
  346. key_f46 = 251;
  347. key_f47 = 252;
  348. key_f48 = 253;
  349. key_f49 = 254;
  350. key_f50 = 255;
  351. key_f51 = 256;
  352. key_f52 = 257;
  353. key_f53 = 258;
  354. key_f54 = 259;
  355. key_f55 = 260;
  356. key_f56 = 261;
  357. key_f57 = 262;
  358. key_f58 = 263;
  359. key_f59 = 264;
  360. key_f60 = 265;
  361. key_f61 = 266;
  362. key_f62 = 267;
  363. key_f63 = 268;
  364. clr_bol = 269;
  365. clear_margins = 270;
  366. set_left_margin = 271;
  367. set_right_margin = 272;
  368. label_format = 273;
  369. set_clock = 274;
  370. display_clock = 275;
  371. remove_clock = 276;
  372. create_window = 277;
  373. goto_window = 278;
  374. hangup = 279;
  375. dial_phone = 280;
  376. quick_dial = 281;
  377. tone = 282;
  378. pulse = 283;
  379. flash_hook = 284;
  380. fixed_pause = 285;
  381. wait_tone = 286;
  382. user0 = 287;
  383. user1 = 288;
  384. user2 = 289;
  385. user3 = 290;
  386. user4 = 291;
  387. user5 = 292;
  388. user6 = 293;
  389. user7 = 294;
  390. user8 = 295;
  391. user9 = 296;
  392. orig_pair = 297;
  393. orig_colors = 298;
  394. initialize_color = 299;
  395. initialize_pair = 300;
  396. set_color_pair = 301;
  397. set_foreground = 302;
  398. set_background = 303;
  399. change_char_pitch = 304;
  400. change_line_pitch = 305;
  401. change_res_horz = 306;
  402. change_res_vert = 307;
  403. define_char = 308;
  404. enter_doublewide_mode = 309;
  405. enter_draft_quality = 310;
  406. enter_italics_mode = 311;
  407. enter_leftward_mode = 312;
  408. enter_micro_mode = 313;
  409. enter_near_letter_quality = 314;
  410. enter_normal_quality = 315;
  411. enter_shadow_mode = 316;
  412. enter_subscript_mode = 317;
  413. enter_superscript_mode = 318;
  414. enter_upward_mode = 319;
  415. exit_doublewide_mode = 320;
  416. exit_italics_mode = 321;
  417. exit_leftward_mode = 322;
  418. exit_micro_mode = 323;
  419. exit_shadow_mode = 324;
  420. exit_subscript_mode = 325;
  421. exit_superscript_mode = 326;
  422. exit_upward_mode = 327;
  423. micro_column_address = 328;
  424. micro_down = 329;
  425. micro_left = 330;
  426. micro_right = 331;
  427. micro_row_address = 332;
  428. micro_up = 333;
  429. order_of_pins = 334;
  430. parm_down_micro = 335;
  431. parm_left_micro = 336;
  432. parm_right_micro = 337;
  433. parm_up_micro = 338;
  434. select_char_set = 339;
  435. set_bottom_margin = 340;
  436. set_bottom_margin_parm = 341;
  437. set_left_margin_parm = 342;
  438. set_right_margin_parm = 343;
  439. set_top_margin = 344;
  440. set_top_margin_parm = 345;
  441. start_bit_image = 346;
  442. start_char_set_def = 347;
  443. stop_bit_image = 348;
  444. stop_char_set_def = 349;
  445. subscript_characters = 350;
  446. superscript_characters = 351;
  447. these_cause_cr = 352;
  448. zero_motion = 353;
  449. char_set_names = 354;
  450. key_mouse = 355;
  451. mouse_info = 356;
  452. req_mouse_pos = 357;
  453. get_mouse = 358;
  454. set_a_foreground = 359;
  455. set_a_background = 360;
  456. pkey_plab = 361;
  457. device_type = 362;
  458. code_set_init = 363;
  459. set0_des_seq = 364;
  460. set1_des_seq = 365;
  461. set2_des_seq = 366;
  462. set3_des_seq = 367;
  463. set_lr_margin = 368;
  464. set_tb_margin = 369;
  465. bit_image_repeat = 370;
  466. bit_image_newline = 371;
  467. bit_image_carriage_return = 372;
  468. color_names = 373;
  469. define_bit_image_region = 374;
  470. end_bit_image_region = 375;
  471. set_color_band = 376;
  472. set_page_length = 377;
  473. display_pc_char = 378;
  474. enter_pc_charset_mode = 379;
  475. exit_pc_charset_mode = 380;
  476. enter_scancode_mode = 381;
  477. exit_scancode_mode = 382;
  478. pc_term_options = 383;
  479. scancode_escape = 384;
  480. alt_scancode_esc = 385;
  481. enter_horizontal_hl_mode = 386;
  482. enter_left_hl_mode = 387;
  483. enter_low_hl_mode = 388;
  484. enter_right_hl_mode = 389;
  485. enter_top_hl_mode = 390;
  486. enter_vertical_hl_mode = 391;
  487. { older synonyms for some booleans }
  488. beehive_glitch = no_esc_ctlc;
  489. teleray_glitch = dest_tabs_magic_smso;
  490. micro_col_size = micro_char_size;
  491. { internal }
  492. termcap_init2 = 392;
  493. termcap_reset = 393;
  494. magic_cookie_glitch_ul = 33;
  495. backspaces_with_bs = 37;
  496. crt_no_scrolling = 38;
  497. no_correctly_working_cr = 39;
  498. carriage_return_delay = 34;
  499. new_line_delay = 35;
  500. linefeed_if_not_lf = 394;
  501. backspace_if_not_bs = 395;
  502. gnu_has_meta_key = 40;
  503. linefeed_is_newline = 41;
  504. backspace_delay = 36;
  505. horizontal_tab_delay = 37;
  506. number_of_function_keys = 38;
  507. other_non_function_keys = 396;
  508. arrow_key_map = 397;
  509. has_hardware_tabs = 42;
  510. return_does_clr_eol = 43;
  511. acs_ulcorner = 398;
  512. acs_llcorner = 399;
  513. acs_urcorner = 400;
  514. acs_lrcorner = 401;
  515. acs_ltee = 402;
  516. acs_rtee = 403;
  517. acs_btee = 404;
  518. acs_ttee = 405;
  519. acs_hline = 406;
  520. acs_vline = 407;
  521. acs_plus = 408;
  522. memory_lock = 409;
  523. memory_unlock = 410;
  524. box_chars_1 = 411;
  525. const
  526. NCCS = 32;
  527. BoolCount = 44;
  528. NumCount = 39;
  529. StrCount = 412;
  530. type
  531. TCFlag_t = Longint;
  532. Speed_t = Longint;
  533. TermIOS = record
  534. c_iflag, c_oflag, c_cflag, c_lflag: TCFlag_t;
  535. c_line: Byte;
  536. c_cc: array [0..NCCS-1] of Char;
  537. c_ispeed, c_ospeed: Speed_t;
  538. Pad: word;
  539. end;
  540. TermType = record
  541. Term_Names: PChar;
  542. Str_Table: PChar;
  543. Booleans: array [0..BoolCount - 1] of Boolean;
  544. Numbers: array [0..NumCount - 1] of Word;
  545. Pad: Word;
  546. Strings: array [0..StrCount - 1] of PChar;
  547. end;
  548. Terminal_ptr = ^Terminal;
  549. Terminal = record
  550. TType: TermType;
  551. FileDes: Word;
  552. Ottyb, Nttyb: Termios;
  553. Pad: Word;
  554. end;
  555. WriterFunc = function (P: PChar): Longint;
  556. var
  557. cur_term : Terminal_ptr;external name 'cur_term';
  558. function set_curterm(term: Terminal_ptr): Terminal_ptr;cdecl;
  559. function del_curterm(term: Terminal_ptr): Longint;cdecl;
  560. { sets whether to use environment variables for LINES and COLUMNS }
  561. procedure use_env(B: Longint);cdecl;
  562. function putp(Ndx: Longint): Longint;
  563. { this function must be called before any terminal properties are accessed }
  564. function setupterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint;cdecl;
  565. { reinitialize lib }
  566. function restartterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint;cdecl;
  567. {function tgetent(P1, P2: PChar): Longint;
  568. function tgetflag(P: PChar): Longint;
  569. function tgetnum(P: PChar): Longint;
  570. function tgoto(P: PChar; L1, L2: Longint): PChar;
  571. function tgetstr(P: PChar; var R: PChar): PChar;
  572. function tigetflag(P: PChar): Longint;
  573. function tigetnum(P: PChar): Longint;
  574. function tigetstr(P: PChar): PChar;
  575. function tparm(P: PChar, ...): PChar;
  576. function tparam(const char *, char *, int, ...): PChar;}
  577. function tputs(Ndx: Word; L1: Longint; F: WriterFunc): Longint;
  578. implementation
  579. uses
  580. Linux;
  581. function putp(Ndx: Longint): Longint;
  582. var
  583. P: PChar;
  584. begin
  585. P := cur_term^.ttype.Strings[Ndx];
  586. putp := fdWrite(cur_term^.filedes, P, StrLen(P));
  587. end;
  588. function tputs(Ndx: Word; L1: Longint; F: WriterFunc): Longint;
  589. var
  590. P: PChar;
  591. begin
  592. L1 := L1;
  593. P := cur_term^.ttype.Strings[Ndx];
  594. tputs := F(P);
  595. end;
  596. function set_curterm(term: Terminal_ptr): Terminal_ptr; cdecl; external;
  597. function del_curterm(term: Terminal_ptr): Longint; cdecl; external;
  598. procedure use_env(B: Longint); cdecl; external;
  599. function restartterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint; cdecl; external;
  600. function setupterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint; cdecl; external;
  601. {function tgetent(P1, P2: PChar): Longint; cdecl; external;
  602. function tgetflag(P: PChar): Longint; cdecl; external;
  603. function tgetnum(P: PChar): Longint; cdecl; external;
  604. function tgoto(P: PChar; L1, L2: Longint): PChar; cdecl; external;
  605. function tgetstr(P: PChar; var R: PChar): PChar; cdecl; external;
  606. function tigetflag(P: PChar): Longint; cdecl; external;
  607. function tigetnum(P: PChar): Longint; cdecl; external;
  608. function tigetstr(P: PChar): PChar; cdecl; external;
  609. function tparm(P: PChar; ...): PChar; cdecl; external;
  610. function tparam(const char *, char *, int, ...): PChar; cdecl; external;}
  611. end.
  612. {
  613. $Log$
  614. Revision 1.1 2000-01-06 01:20:31 peter
  615. * moved out of packages/ back to topdir
  616. Revision 1.1 1999/11/24 23:36:38 peter
  617. * moved to packages dir
  618. Revision 1.3 1999/04/22 14:48:27 peter
  619. * remove asm
  620. Revision 1.2 1998/12/07 12:25:51 peter
  621. * link with ncurses which is more available the curses
  622. Revision 1.1 1998/12/04 12:48:30 peter
  623. * moved some dirs
  624. Revision 1.1 1998/10/26 11:31:47 peter
  625. + inital include files
  626. Revision 1.3 1998/10/26 09:36:26 peter
  627. * fixed cdecl
  628. Revision 1.2 1998/07/29 20:17:47 bazsi
  629. some updates to Video, it now uses terminfo. Some modifications for FreeVision.
  630. Revision 1.1 1998/06/13 12:38:54 bazsi
  631. }