メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

oct-rl-edit.c

解説を見る。
00001 /*
00002 
00003 Copyright (C) 2000 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 2, or (at your option) any
00010 later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #if defined (USE_READLINE)
00028 
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 
00032 #include <readline/readline.h>
00033 
00034 #include "oct-rl-edit.h"
00035 
00036 #define OCTAVE_RL_SAVE_STRING(ss, s) \
00037   static char *ss = 0; \
00038  \
00039   if (ss) \
00040     { \
00041       free (ss); \
00042       ss = 0; \
00043     } \
00044  \
00045   ss = malloc (strlen (s) + 1); \
00046  \
00047   strcpy (ss, s)
00048 
00049 int
00050 octave_rl_screen_height (void)
00051 {
00052   int rows, cols;
00053   rl_get_screen_size (&rows, &cols);
00054   return rows;
00055 }
00056 
00057 int
00058 octave_rl_screen_width (void)
00059 {
00060   int rows, cols;
00061   rl_get_screen_size (&rows, &cols);
00062   return cols;
00063 }
00064 
00065 void
00066 octave_rl_enable_paren_matching (int val)
00067 {
00068   rl_variable_bind ("blink-matching-paren", val ? "1" : "0");
00069 }
00070 
00071 /* It would be much simpler if we could just call _rl_clear_screen to
00072    only clear the screen, but it is not a public function, and on some
00073    systems, it is not exported from shared library versions of
00074    readline, so we can't use it.
00075 
00076    Instead, temporarily redefine the redisplay function to do nothing.
00077 
00078    XXX FIXME XXX -- It would be safer to do this when protected from
00079    interrupts... */
00080 
00081 static void
00082 no_redisplay (void)
00083 {
00084 }
00085 
00086 void
00087 octave_rl_clear_screen (void)
00088 {
00089   int ignore1 = 0;
00090   int ignore2 = 0;
00091 
00092   rl_voidfunc_t *saved_redisplay_function = rl_redisplay_function;
00093   rl_redisplay_function = no_redisplay;
00094 
00095   rl_clear_screen (ignore1, ignore2);
00096 
00097   rl_redisplay_function = saved_redisplay_function;
00098 }
00099 
00100 void
00101 octave_rl_resize_terminal (void)
00102 {
00103   rl_resize_terminal ();
00104 }
00105 
00106 void
00107 octave_rl_restore_terminal_state ()
00108 {
00109   if (rl_deprep_term_function)
00110     rl_deprep_term_function ();
00111 }
00112 
00113 void
00114 octave_rl_insert_text (const char *s)
00115 {
00116   rl_insert_text (s);
00117 }
00118 
00119 void
00120 octave_rl_newline (void)
00121 {
00122   rl_newline (1, '\n');
00123 }
00124 
00125 void
00126 octave_rl_clear_undo_list (void)
00127 {
00128   if (rl_undo_list)
00129     {
00130       rl_free_undo_list ();
00131 
00132       rl_undo_list = 0;
00133     }
00134 }
00135 
00136 void
00137 octave_rl_set_name (const char *n)
00138 {
00139   OCTAVE_RL_SAVE_STRING (nm, n);
00140 
00141   rl_readline_name = nm;
00142 
00143   /* Since we've already called rl_initialize, we need to re-read the
00144      init file to take advantage of the conditional parsing feature
00145      based on rl_readline_name; */
00146 
00147   rl_re_read_init_file (0, 0);
00148 }
00149 
00150 char *
00151 octave_rl_readline (const char *prompt)
00152 {
00153   return readline (prompt);
00154 }
00155 
00156 void
00157 octave_rl_set_input_stream (FILE *f)
00158 {
00159   rl_instream = f;
00160 }
00161 
00162 FILE *
00163 octave_rl_get_input_stream (void)
00164 {
00165   return rl_instream;
00166 }
00167 
00168 void
00169 octave_rl_set_output_stream (FILE *f)
00170 {
00171   rl_outstream = f;
00172 }
00173 
00174 FILE *
00175 octave_rl_get_output_stream (void)
00176 {
00177   return rl_outstream;
00178 }
00179 
00180 void
00181 octave_rl_read_init_file (const char *f)
00182 {
00183   if (f && *f)
00184     rl_read_init_file (f);
00185   else
00186     rl_re_read_init_file (0, 0);
00187 }
00188 
00189 int
00190 octave_rl_filename_completion_desired (int arg)
00191 {
00192   int retval = rl_filename_completion_desired;
00193   rl_filename_completion_desired = arg;
00194   return retval;
00195 }
00196 
00197 char *
00198 octave_rl_filename_completion_function (const char *text, int state)
00199 {
00200   return rl_filename_completion_function (text, state);
00201 }
00202 
00203 void
00204 octave_rl_set_basic_word_break_characters (const char *s)
00205 {
00206   OCTAVE_RL_SAVE_STRING (ss, s);
00207 
00208   rl_basic_word_break_characters = ss;
00209 }
00210 
00211 void
00212 octave_rl_set_completer_word_break_characters (const char *s)
00213 {
00214   OCTAVE_RL_SAVE_STRING (ss, s);
00215 
00216   rl_completer_word_break_characters = ss;
00217 }
00218 
00219 void
00220 octave_rl_set_basic_quote_characters (const char *s)
00221 {
00222   OCTAVE_RL_SAVE_STRING (ss, s);
00223 
00224   rl_basic_quote_characters = ss;
00225 }
00226 
00227 void
00228 octave_rl_set_completion_append_character (char c)
00229 {
00230   rl_completion_append_character = c;
00231 }
00232 
00233 void
00234 octave_rl_set_completion_function (rl_attempted_completion_fcn_ptr f)
00235 {
00236   rl_attempted_completion_function = f;
00237 }
00238 
00239 void
00240 octave_rl_set_startup_hook (rl_startup_hook_fcn_ptr f)
00241 {
00242   rl_startup_hook = f;
00243 }
00244 
00245 rl_startup_hook_fcn_ptr
00246 octave_rl_get_startup_hook (void)
00247 {
00248   return rl_startup_hook;
00249 }
00250 
00251 void
00252 octave_rl_set_event_hook (rl_event_hook_fcn_ptr f)
00253 {
00254   rl_event_hook = f;
00255 }
00256 
00257 rl_event_hook_fcn_ptr
00258 octave_rl_get_event_hook (void)
00259 {
00260   return rl_event_hook;
00261 }
00262 
00263 char **
00264 octave_rl_completion_matches (const char *text, rl_completer_fcn_ptr f)
00265 {
00266   return rl_completion_matches (text, f);
00267 }
00268 
00269 char
00270 octave_rl_prompt_start_ignore (void)
00271 {
00272   return RL_PROMPT_START_IGNORE;
00273 }
00274 
00275 char
00276 octave_rl_prompt_end_ignore (void)
00277 {
00278   return RL_PROMPT_END_IGNORE;
00279 }
00280 
00281 void
00282 octave_rl_add_defun (const char *name, rl_fcn_ptr f, char key)
00283 {
00284   rl_add_defun (name, f, key);
00285 }
00286 
00287 void
00288 octave_rl_set_terminal_name (const char *term)
00289 {
00290   rl_terminal_name = (char *) term;
00291 }
00292 
00293 void
00294 octave_rl_initialize (void)
00295 {
00296   rl_initialize ();
00297 }
00298 
00299 int
00300 octave_rl_history_search_forward (int count, int ignore)
00301 {
00302   return rl_history_search_forward (count, ignore);
00303 }
00304 
00305 int
00306 octave_rl_history_search_backward (int count, int ignore)
00307 {
00308   return rl_history_search_backward (count, ignore);
00309 }
00310 
00311 char
00312 octave_rl_ctrl (char c)
00313 {
00314   return CTRL (c);
00315 }
00316 
00317 char
00318 octave_rl_meta (char c)
00319 {
00320   return META (c);
00321 }
00322 
00323 #endif
00324 
00325 /*
00326 ;;; Local Variables: ***
00327 ;;; mode: C++ ***
00328 ;;; End: ***
00329 */

Wed Dec 29 11:52:10 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送