23 #if !defined (octave_cmd_edit_h)
24 #define octave_cmd_edit_h 1
40 : command_number (0), interrupted (false), initial_input () { }
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 std::string decode_prompt_string (
const std::string& s);
88 static void restore_terminal_state (
void);
90 static void blink_matching_paren (
bool flag);
92 static void set_basic_word_break_characters (
const std::string& s);
94 static void set_completer_word_break_characters (
const std::string& s);
96 static void set_basic_quote_characters (
const std::string& s);
98 static void set_filename_quote_characters (
const std::string& s);
100 static void set_completer_quote_characters (
const std::string& s);
102 static void set_completion_append_character (
char c);
104 static void set_completion_function (completion_fcn
f);
106 static void set_quoting_function (quoting_fcn
f);
108 static void set_dequoting_function (dequoting_fcn
f);
110 static void set_char_is_quoted_function (char_is_quoted_fcn
f);
112 static void set_user_accept_line_function (user_accept_line_fcn
f);
114 static completion_fcn get_completion_function (
void);
116 static quoting_fcn get_quoting_function (
void);
118 static dequoting_fcn get_dequoting_function (
void);
120 static char_is_quoted_fcn get_char_is_quoted_function (
void);
122 static user_accept_line_fcn get_user_accept_line_function (
void);
126 static std::string get_line_buffer (
void);
128 static std::string get_current_line (
void);
130 static void replace_line (
const std::string&
text,
bool clear_undo =
true);
132 static void insert_text (
const std::string&
text);
134 static void newline (
void);
136 static void accept_line (
void);
138 static bool undo (
void);
140 static void clear_undo_list (
void);
142 static void add_startup_hook (startup_hook_fcn
f);
144 static void remove_startup_hook (startup_hook_fcn
f);
146 static void add_pre_input_hook (pre_input_hook_fcn
f);
148 static void remove_pre_input_hook (pre_input_hook_fcn
f);
150 static void add_event_hook (event_hook_fcn
f);
152 static void remove_event_hook (event_hook_fcn
f);
154 static void run_event_hooks (
void);
156 static void read_init_file (
const std::string& file = std::string ());
158 static void re_read_init_file (
void);
160 static bool filename_completion_desired (
bool);
162 static bool filename_quoting_desired (
bool);
164 static bool interrupt (
bool =
true);
166 static int current_command_number (
void);
168 static void reset_current_command_number (
int n);
170 static void increment_current_command_number (
void);
172 static void force_default_editor (
void);
174 static void set_initial_input (
const std::string&
text);
176 static int insert_initial_input (
void);
186 static bool instance_ok (
void);
188 static void make_command_editor (
void);
190 static int startup_handler (
void);
192 static int pre_input_handler (
void);
194 static int event_handler (
void);
224 std::string do_readline (
const std::string& prompt)
228 return do_readline (prompt, eof);
231 virtual std::string do_readline (
const std::string&,
bool&) = 0;
233 virtual void do_set_input_stream (FILE *) = 0;
235 virtual FILE *do_get_input_stream (
void) = 0;
237 virtual void do_set_output_stream (FILE *) = 0;
239 virtual FILE *do_get_output_stream (
void) = 0;
251 virtual std::string do_decode_prompt_string (
const std::string&);
287 virtual char_is_quoted_fcn do_get_char_is_quoted_function (
void)
const
290 virtual user_accept_line_fcn do_get_user_accept_line_function (
void)
const
294 do_generate_filename_completions (
const std::string&
text) = 0;
296 virtual std::string do_get_line_buffer (
void)
const = 0;
298 virtual std::string do_get_current_line (
void)
const = 0;
300 virtual void do_replace_line (
const std::string&
text,
bool clear_undo) = 0;
302 virtual void do_insert_text (
const std::string&
text) = 0;
304 virtual void do_newline (
void) = 0;
306 virtual void do_accept_line (
void) = 0;
334 int do_insert_initial_input (
void);
336 int read_octal (
const std::string& s);
340 void error (
const std::string&);