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

cmd-edit.h

解説を見る。
00001 /*
00002 
00003 Copyright (C) 1996, 1997 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 #if !defined (octave_cmd_edit_h)
00024 #define octave_cmd_edit_h 1
00025 
00026 #include <cstdio>
00027 
00028 #include <string>
00029 
00030 #include "str-vec.h"
00031 
00032 class
00033 command_editor
00034 {
00035 protected:
00036 
00037   command_editor (void)
00038     : command_number (0) { }
00039 
00040 public:
00041 
00042   typedef int (*startup_hook_fcn) (void);
00043 
00044   typedef int (*event_hook_fcn) (void);
00045 
00046   typedef std::string (*completion_fcn) (const std::string&, int);
00047 
00048   virtual ~command_editor (void) { }
00049 
00050   static void set_name (const std::string& n);
00051 
00052   static std::string readline (const std::string& prompt);
00053 
00054   static std::string readline (const std::string& prompt, bool& eof);
00055 
00056   static void set_input_stream (FILE *f);
00057 
00058   static FILE *get_input_stream (void);
00059 
00060   static void set_output_stream (FILE *f);
00061 
00062   static FILE *get_output_stream (void);
00063 
00064   static int terminal_rows (void);
00065 
00066   static int terminal_cols (void);
00067 
00068   static void clear_screen (void);
00069 
00070   static void resize_terminal (void);
00071 
00072   static std::string decode_prompt_string (const std::string& s);
00073 
00074   static void restore_terminal_state (void);
00075 
00076   static void blink_matching_paren (bool flag);
00077 
00078   static void set_basic_word_break_characters (const std::string& s);
00079 
00080   static void set_completer_word_break_characters (const std::string& s);
00081 
00082   static void set_basic_quote_characters (const std::string& s);
00083 
00084   static void set_completion_append_character (char c);
00085 
00086   static void set_completion_function (completion_fcn f);
00087 
00088   static completion_fcn get_completion_function (void);
00089 
00090   static string_vector generate_filename_completions (const std::string& text);
00091 
00092   static void insert_text (const std::string& text);
00093 
00094   static void newline (void);
00095 
00096   static void clear_undo_list (void);
00097 
00098   static void set_startup_hook (startup_hook_fcn f);
00099 
00100   static void restore_startup_hook (void);
00101 
00102   static void set_event_hook (event_hook_fcn f);
00103 
00104   static void restore_event_hook (void);
00105 
00106   static void read_init_file (const std::string& file = std::string ());
00107 
00108   static bool filename_completion_desired (bool);
00109 
00110   static int current_command_number (void);
00111 
00112   static void reset_current_command_number (int n);
00113 
00114   static void increment_current_command_number (void);
00115 
00116 private:
00117 
00118   // No copying!
00119 
00120   command_editor (const command_editor&);
00121 
00122   command_editor& operator = (const command_editor&);
00123 
00124   static bool instance_ok (void);
00125 
00126   static void make_command_editor (void);
00127 
00128   // The real thing.
00129   static command_editor *instance;
00130 
00131 protected:
00132 
00133   // To use something other than the GNU readline library, derive a new
00134   // class from command_editor, overload these functions as
00135   // necessary, and make instance point to the new class.
00136 
00137   virtual void do_set_name (const std::string&) { }
00138 
00139   std::string do_readline (const std::string& prompt)
00140     {
00141       bool eof;
00142 
00143       return do_readline (prompt, eof);
00144     }
00145 
00146   virtual std::string do_readline (const std::string&, bool&) = 0;
00147 
00148   virtual void do_set_input_stream (FILE *) = 0;
00149 
00150   virtual FILE *do_get_input_stream (void) = 0;
00151 
00152   virtual void do_set_output_stream (FILE *) = 0;
00153 
00154   virtual FILE *do_get_output_stream (void) = 0;
00155 
00156   virtual int do_terminal_rows (void) { return 24; }
00157 
00158   virtual int do_terminal_cols (void) { return 80; }
00159 
00160   virtual void do_clear_screen (void) { }
00161 
00162   virtual void do_resize_terminal (void) { }
00163 
00164   virtual std::string do_decode_prompt_string (const std::string&);
00165 
00166   virtual std::string newline_chars (void) { return "\n"; } 
00167 
00168   virtual void do_restore_terminal_state (void) { }
00169 
00170   virtual void do_blink_matching_paren (bool) { }
00171 
00172   virtual void do_set_basic_word_break_characters (const std::string&) { }
00173 
00174   virtual void do_set_completer_word_break_characters (const std::string&) { }
00175 
00176   virtual void do_set_basic_quote_characters (const std::string&) { }
00177 
00178   virtual void do_set_completion_append_character (char) { }
00179 
00180   virtual void do_set_completion_function (completion_fcn) { }
00181 
00182   virtual completion_fcn do_get_completion_function (void) const { return 0; }
00183 
00184   virtual string_vector do_generate_filename_completions (const std::string& text) = 0;
00185 
00186   virtual void do_insert_text (const std::string&) = 0;
00187 
00188   virtual void do_newline (void) = 0;
00189 
00190   virtual void do_clear_undo_list (void) { }
00191 
00192   virtual void do_set_startup_hook (startup_hook_fcn) { }
00193 
00194   virtual void do_restore_startup_hook (void) { }
00195 
00196   virtual void do_set_event_hook (event_hook_fcn) { }
00197 
00198   virtual void do_restore_event_hook (void) { }
00199 
00200   virtual void do_read_init_file (const std::string&) { }
00201 
00202   virtual bool do_filename_completion_desired (bool) { return false; }
00203 
00204   int read_octal (const std::string& s);
00205 
00206   void error (int);
00207 
00208   void error (const std::string&);
00209 
00210   // The current command number.
00211   int command_number;
00212 };
00213 
00214 #endif
00215 
00216 /*
00217 ;;; Local Variables: ***
00218 ;;; mode: C++ ***
00219 ;;; End: ***
00220 */

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