23 #if !defined (octave_cmd_edit_h)
24 #define octave_cmd_edit_h 1
40 : command_number (0), interrupted (false), initial_input () { }
44 typedef int (*startup_hook_fcn) (void);
46 typedef int (*pre_input_hook_fcn) (void);
48 typedef int (*event_hook_fcn) (void);
50 typedef std::string (*completion_fcn) (
const std::string&,
int);
52 typedef std::string (*quoting_fcn) (
const std::string&,
int,
char);
54 typedef std::string (*dequoting_fcn) (
const std::string&, int);
56 typedef int (*char_is_quoted_fcn) (
const std::string&, int);
58 typedef void (*user_accept_line_fcn) (
const std::string&);
62 static void set_name (
const std::string& n);
64 static std::string readline (
const std::string& prompt);
66 static std::string readline (
const std::string& prompt,
bool& eof);
68 static void set_input_stream (FILE *
f);
70 static FILE *get_input_stream (
void);
72 static void set_output_stream (FILE *
f);
74 static FILE *get_output_stream (
void);
76 static void redisplay (
void);
78 static int terminal_rows (
void);
80 static int terminal_cols (
void);
82 static void clear_screen (
bool skip_redisplay =
false);
84 static void resize_terminal (
void);
86 static void set_screen_size (
int ht,
int wd);
88 static std::string decode_prompt_string (
const std::string& s);
90 static void restore_terminal_state (
void);
92 static void blink_matching_paren (
bool flag);
94 static bool erase_empty_line (
bool flag);
96 static void set_basic_word_break_characters (
const std::string& s);
98 static void set_completer_word_break_characters (
const std::string& s);
100 static void set_basic_quote_characters (
const std::string& s);
102 static void set_filename_quote_characters (
const std::string& s);
104 static void set_completer_quote_characters (
const std::string& s);
106 static void set_completion_append_character (
char c);
108 static void set_completion_function (completion_fcn
f);
110 static void set_quoting_function (quoting_fcn
f);
112 static void set_dequoting_function (dequoting_fcn
f);
114 static void set_char_is_quoted_function (char_is_quoted_fcn
f);
116 static void set_user_accept_line_function (user_accept_line_fcn
f);
118 static completion_fcn get_completion_function (
void);
120 static quoting_fcn get_quoting_function (
void);
122 static dequoting_fcn get_dequoting_function (
void);
124 static char_is_quoted_fcn get_char_is_quoted_function (
void);
126 static user_accept_line_fcn get_user_accept_line_function (
void);
130 static std::string get_line_buffer (
void);
132 static std::string get_current_line (
void);
134 static void replace_line (
const std::string&
text,
bool clear_undo =
true);
136 static void kill_full_line (
void);
138 static void insert_text (
const std::string&
text);
140 static void newline (
void);
142 static void accept_line (
void);
144 static bool undo (
void);
146 static void clear_undo_list (
void);
148 static void add_startup_hook (startup_hook_fcn
f);
150 static void remove_startup_hook (startup_hook_fcn
f);
152 static void add_pre_input_hook (pre_input_hook_fcn
f);
154 static void remove_pre_input_hook (pre_input_hook_fcn
f);
156 static void add_event_hook (event_hook_fcn
f);
158 static void remove_event_hook (event_hook_fcn
f);
160 static void run_event_hooks (
void);
162 static void read_init_file (
const std::string& file = std::string ());
164 static void re_read_init_file (
void);
166 static bool filename_completion_desired (
bool);
168 static bool filename_quoting_desired (
bool);
170 static bool prefer_env_winsize (
bool);
172 static bool interrupt (
bool =
true);
174 static int current_command_number (
void);
176 static void reset_current_command_number (
int n);
178 static void increment_current_command_number (
void);
180 static void force_default_editor (
void);
182 static void set_initial_input (
const std::string&
text);
184 static int insert_initial_input (
void);
194 static bool instance_ok (
void);
196 static void make_command_editor (
void);
198 static int startup_handler (
void);
200 static int pre_input_handler (
void);
202 static int event_handler (
void);
236 return do_readline (prompt, eof);
239 virtual std::string do_readline (
const std::string&,
bool&) = 0;
241 virtual void do_set_input_stream (FILE *) = 0;
243 virtual FILE *do_get_input_stream (
void) = 0;
245 virtual void do_set_output_stream (FILE *) = 0;
247 virtual FILE *do_get_output_stream (
void) = 0;
261 virtual std::string do_decode_prompt_string (
const std::string&);
306 do_generate_filename_completions (
const std::string&
text) = 0;
308 virtual std::string do_get_line_buffer (
void)
const = 0;
310 virtual std::string do_get_current_line (
void)
const = 0;
312 virtual void do_replace_line (
const std::string&
text,
bool clear_undo) = 0;
314 virtual void do_kill_full_line (
void) = 0;
316 virtual void do_insert_text (
const std::string&
text) = 0;
318 virtual void do_newline (
void) = 0;
320 virtual void do_accept_line (
void) = 0;
350 int do_insert_initial_input (
void);
352 int read_octal (
const std::string& s);
356 void error (
const std::string&);
virtual bool do_undo(void)
virtual quoting_fcn do_get_quoting_function(void) const
virtual void do_set_filename_quote_characters(const std::string &)
virtual int do_terminal_cols(void)
virtual void restore_event_hook(void)
virtual void do_set_completion_function(completion_fcn)
virtual void do_set_quoting_function(quoting_fcn)
virtual void do_set_basic_quote_characters(const std::string &)
virtual void do_set_user_accept_line_function(user_accept_line_fcn)
static std::set< pre_input_hook_fcn > pre_input_hook_set
virtual dequoting_fcn do_get_dequoting_function(void) const
virtual ~command_editor(void)
virtual void set_pre_input_hook(pre_input_hook_fcn)
virtual void set_event_hook(event_hook_fcn)
std::set< startup_hook_fcn >::iterator startup_hook_set_iterator
void error(const char *fmt,...)
virtual void restore_pre_input_hook(void)
virtual void do_set_completer_word_break_characters(const std::string &)
virtual void do_restore_terminal_state(void)
virtual void do_set_basic_word_break_characters(const std::string &)
virtual bool do_prefer_env_winsize(bool)
virtual void do_read_init_file(const std::string &)
virtual void restore_startup_hook(void)
virtual void do_set_screen_size(int, int)
virtual void do_set_name(const std::string &)
static command_editor * instance
std::string do_readline(const std::string &prompt)
F77_RET_T const double const double * f
std::set< pre_input_hook_fcn >::const_iterator pre_input_hook_set_const_iterator
virtual std::string newline_chars(void)
virtual void do_redisplay(void)
std::set< pre_input_hook_fcn >::iterator pre_input_hook_set_iterator
virtual void do_clear_screen(bool)
virtual int do_terminal_rows(void)
virtual void do_set_dequoting_function(dequoting_fcn)
std::string initial_input
std::set< event_hook_fcn >::iterator event_hook_set_iterator
static std::set< event_hook_fcn > event_hook_set
static void cleanup_instance(void)
virtual void do_re_read_init_file(void)
virtual void set_startup_hook(startup_hook_fcn)
std::set< startup_hook_fcn >::const_iterator startup_hook_set_const_iterator
virtual void do_set_completion_append_character(char)
virtual void do_interrupt(bool)
virtual void do_resize_terminal(void)
virtual void do_blink_matching_paren(bool)
virtual bool do_filename_quoting_desired(bool)
std::set< event_hook_fcn >::const_iterator event_hook_set_const_iterator
virtual user_accept_line_fcn do_get_user_accept_line_function(void) const
virtual completion_fcn do_get_completion_function(void) const
static std::set< startup_hook_fcn > startup_hook_set
virtual void do_clear_undo_list(void)
virtual bool do_erase_empty_line(bool)
virtual bool do_filename_completion_desired(bool)
virtual void do_set_char_is_quoted_function(char_is_quoted_fcn)
virtual void do_set_completer_quote_characters(const std::string &)
virtual char_is_quoted_fcn do_get_char_is_quoted_function(void) const