freadlin.pp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. unit freadlin;
  2. {**********************************************************************
  3. Copyright (c) 2007 by Daniel Mantione
  4. A fake read line library which allows us to use libgdb in the IDE
  5. without linking the bloated and unused GNU readline library.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$calling cdecl}
  13. interface
  14. implementation
  15. uses ctypes;
  16. var rl_end:cint;public name 'rl_end'; {The number of characters in the readline buffer.}
  17. rl_point:cint;public name 'rl_point'; {The cursor position in the readline buffer.}
  18. rl_prompt:Pchar;public name 'rl_prompt'; {The prompt readline should use.}
  19. rl_instream:pointer;public name 'rl_instream'; {The FILE* for input.}
  20. rl_outstream:pointer;public name 'rl_outstream';{The FILE* for output.}
  21. rl_terminal_name:pointer;public name 'rl_terminal_name'; {The terminal (set by TERM) readline thinks it is using.}
  22. rl_prep_term_function:pointer;public name 'rl_prep_term_function'; {Procedure to initialize terminal.}
  23. rl_getc_function:pointer;public name 'rl_getc_function'; {The function to get a char from input.}
  24. rl_line_buffer:Pchar;public name 'rl_line_buffer'; {The buffer readline is currently reading into.}
  25. rl_completer_word_break_characters:Pchar;public name 'rl_completer_word_break_characters';
  26. rl_completer_quote_characters:Pchar;public name 'rl_completer_quote_characters';
  27. rl_already_prompted:cint;public name 'rl_already_prompted';
  28. readline_echoing_p:cint;public name 'readline_echoing_p';
  29. rl_startup_hook:pointer;public name 'rl_startup_hook';
  30. emacs_ctlx_keymap:pointer;public name 'emacs_ctlx_keymap';
  31. rl_readline_name:Pchar;public name 'rl_readline_name';
  32. rl_deprep_term_function:pointer;public name 'rl_deprep_term_function';
  33. rl_redisplay_function:pointer;public name 'rl_redisplay_function';
  34. rl_pre_input_hook:pointer;public name 'rl_pre_input_hook';
  35. rl_completion_entry_function:pointer;public name 'rl_completion_entry_function';
  36. rl_filename_completion_desired:cint;public name 'rl_filename_completion_desired';
  37. rl_completion_display_matches_hook:pointer;public name 'rl_completion_display_matches_hook';
  38. rl_completion_query_items:cint;public name 'rl_completion_query_items';
  39. rl_ignore_completion_duplicates:cint;public name 'rl_ignore_completion_duplicates';
  40. rl_print_completions_horizontally:cint;public name '_rl_print_completions_horizontally';
  41. function rl_initialize:cint;public;alias:'rl_initialize';
  42. {Should initialize readline and return 0 if successfull.}
  43. begin
  44. runerror(254);
  45. end;
  46. function rl_reset_terminal(terminal:Pchar):cint;public;alias:'rl_reset_terminal';
  47. begin
  48. {Called by gdb, do nothing.}
  49. end;
  50. function rl_tilde_expand(s:Pchar):Pchar;public;alias:'tilde_expand';
  51. begin
  52. {Called by gdb, don't expand, return original string.}
  53. rl_tilde_expand:=s;
  54. end;
  55. function rl_newline(count,key:cint):cint;public;alias:'rl_newline';
  56. begin
  57. runerror(254);
  58. end;
  59. procedure rl_get_screen_size(var rows,cols:cint);public;alias:'rl_get_screen_size';
  60. begin
  61. {Called by gdb. Fake a 80x25 screen.}
  62. {Gdb can call using nil pointers.}
  63. if @rows<>nil then
  64. rows:=25;
  65. if @cols<>nil then
  66. cols:=80;
  67. end;
  68. procedure rl_set_screen_size(rows,cols:cint);public;alias:'rl_set_screen_size';
  69. begin
  70. {Called by gdb, do nothing.}
  71. end;
  72. function rl_bind_key_in_map(key:cint;rl_command_func_t:pointer;map:pointer):cint;public;alias:'rl_bind_key_in_map';
  73. begin
  74. runerror(254);
  75. end;
  76. procedure rl_set_keymap(keymap:pointer);public;alias:'rl_set_keymap';
  77. begin
  78. runerror(254);
  79. end;
  80. function rl_get_keymap:pointer;public;alias:'rl_get_keymap';
  81. begin
  82. runerror(254);
  83. end;
  84. function rl_make_bare_keymap:pointer;public;alias:'rl_make_bare_keymap';
  85. begin
  86. runerror(254);
  87. end;
  88. function rl_add_defun(name:Pchar;rl_command_func_t:pointer;key:cint):cint;public;alias:'rl_add_defun';
  89. begin
  90. {Called by gdb, do nothing.}
  91. end;
  92. function rl_insert(count,c:cint):cint;public;alias:'rl_insert';
  93. begin
  94. runerror(254);
  95. end;
  96. function rl_kill_text(start,stop:cint):cint;public;alias:'rl_kill_text';
  97. begin
  98. runerror(254);
  99. end;
  100. procedure rl_prep_terminal(meta_flag:cint);public;alias:'rl_prep_terminal';
  101. begin
  102. runerror(254);
  103. end;
  104. procedure rl_deprep_terminal;public;alias:'rl_deprep_terminal';
  105. begin
  106. runerror(254);
  107. end;
  108. procedure rl_callback_handler_install(prompt:Pchar;lhandler:pointer);public;alias:'rl_callback_handler_install';
  109. begin
  110. runerror(254);
  111. end;
  112. procedure rl_callback_handler_remove;public;alias:'rl_callback_handler_remove';
  113. begin
  114. runerror(254);
  115. end;
  116. function rl_filename_completion_function(text:Pchar;state:cint):Pchar;public;alias:'rl_filename_completion_function';
  117. begin
  118. runerror(254);
  119. end;
  120. procedure rl_callback_read_char;public;alias:'rl_callback_read_char';
  121. begin
  122. runerror(254);
  123. end;
  124. procedure rl_redisplay;public;alias:'rl_redisplay';
  125. begin
  126. runerror(254);
  127. end;
  128. function rl_generic_bind(_type:cint;keyseq,data:Pchar;map:pointer):cint;public;alias:'rl_generic_bind';
  129. begin
  130. runerror(254);
  131. end;
  132. function rl_get_previous_history(count,key:cint):cint;public;alias:'rl_get_previous_history';
  133. begin
  134. runerror(254);
  135. end;
  136. function rl_read_key:cint;public;alias:'rl_read_key';
  137. begin
  138. runerror(254);
  139. end;
  140. function rl_abort_internal:cint;public;alias:'_rl_abort_internal';
  141. begin
  142. runerror(254);
  143. end;
  144. function readline(prompt:Pchar):Pchar;public;alias:'readline';
  145. begin
  146. runerror(254);
  147. end;
  148. function rl_qsort_string_compare(s1,s2:Pchar):cint;public;alias:'_rl_qsort_string_compare';
  149. begin
  150. runerror(254);
  151. end;
  152. begin
  153. rl_end:=0;
  154. rl_point:=0;
  155. rl_prompt:=nil;
  156. rl_instream:=nil;
  157. rl_outstream:=nil;
  158. rl_terminal_name:=nil;
  159. rl_already_prompted:=0;
  160. rl_completer_word_break_characters:=nil;
  161. rl_completer_quote_characters:=nil;
  162. rl_line_buffer:=nil;
  163. rl_getc_function:=nil;
  164. rl_prep_term_function:=nil;
  165. rl_startup_hook:=nil;
  166. readline_echoing_p:=0;
  167. emacs_ctlx_keymap:=nil;
  168. rl_readline_name:=nil;
  169. rl_deprep_term_function:=nil;
  170. rl_redisplay_function:=nil;
  171. rl_completion_entry_function:=nil;
  172. rl_filename_completion_desired:=0;
  173. rl_completion_display_matches_hook:=nil;
  174. rl_ignore_completion_duplicates:=0;
  175. rl_print_completions_horizontally:=0;
  176. end.