26 #if ! defined (octave_cmd_edit_h)
27 #define octave_cmd_edit_h 1
29 #include "octave-config.h"
47 : m_command_number (1), m_rows (24), m_cols (80), m_interrupted (false),
48 m_interrupt_event_loop (false), m_initial_input ()
53 typedef int (*startup_hook_fcn) ();
55 typedef int (*pre_input_hook_fcn) ();
57 typedef int (*event_hook_fcn) ();
59 typedef std::string (*completion_fcn) (
const std::string&, int);
61 typedef char *(*completion_hook_fcn) ();
63 typedef std::string (*quoting_fcn) (
const std::string&, int, char);
65 typedef std::string (*dequoting_fcn) (
const std::string&, int);
67 typedef int (*char_is_quoted_fcn) (
const std::string&, int);
69 typedef void (*user_accept_line_fcn) (
const std::string&);
75 static
void set_name (const std::
string&
n);
77 static std::
string readline (const std::
string& prompt);
79 static std::
string readline (const std::
string& prompt,
bool& eof);
81 static
void set_input_stream (FILE *
f);
83 static FILE * get_input_stream ();
85 static
void set_output_stream (FILE *
f);
87 static FILE * get_output_stream ();
89 static
void redisplay ();
91 static
int terminal_rows ();
93 static
int terminal_cols ();
95 static
void clear_screen (
bool skip_redisplay = false);
97 static
void resize_terminal ();
99 static
void set_screen_size (
int ht,
int wd);
101 static std::
string decode_prompt_string (const std::
string& s);
103 static
void restore_terminal_state ();
105 static
void blink_matching_paren (
bool flag);
107 static
bool erase_empty_line (
bool flag);
109 static
void set_basic_word_break_characters (const std::
string& s);
111 static
void set_completer_word_break_characters (const std::
string& s);
113 static
void set_basic_quote_characters (const std::
string& s);
115 static
void set_filename_quote_characters (const std::
string& s);
117 static
void set_completer_quote_characters (const std::
string& s);
119 static
void set_completion_append_character (
char c);
121 static
void set_completion_function (completion_fcn
f);
123 static
void set_quoting_function (quoting_fcn
f);
125 static
void set_dequoting_function (dequoting_fcn
f);
127 static
void set_char_is_quoted_function (char_is_quoted_fcn
f);
129 static
void set_user_accept_line_function (user_accept_line_fcn
f);
131 static completion_fcn get_completion_function ();
133 static quoting_fcn get_quoting_function ();
135 static dequoting_fcn get_dequoting_function ();
137 static char_is_quoted_fcn get_char_is_quoted_function ();
139 static user_accept_line_fcn get_user_accept_line_function ();
142 generate_filename_completions (const std::
string&
text);
144 static std::
string get_line_buffer ();
146 static std::
string get_current_line ();
148 static
char get_prev_char (
int);
150 static
void replace_line (const std::
string&
text,
bool clear_undo = true);
152 static
void kill_full_line ();
154 static
void insert_text (const std::
string&
text);
156 static
void newline ();
158 static
void accept_line ();
162 static
void clear_undo_list ();
164 static
void add_startup_hook (startup_hook_fcn
f);
166 static
void remove_startup_hook (startup_hook_fcn
f);
168 static
void add_pre_input_hook (pre_input_hook_fcn
f);
170 static
void remove_pre_input_hook (pre_input_hook_fcn
f);
172 static
void add_event_hook (event_hook_fcn
f);
174 static
void remove_event_hook (event_hook_fcn
f);
176 static
void run_event_hooks ();
178 static
void read_init_file (const std::
string& file = "");
180 static
void re_read_init_file ();
182 static
bool filename_completion_desired (
bool);
184 static
bool filename_quoting_desired (
bool);
186 static
bool prefer_env_winsize (
bool);
188 static
bool interrupt (
bool = true);
190 static
void interrupt_event_loop (
bool flag = true);
192 static
bool event_loop_interrupted ();
194 static
int current_command_number ();
196 static
void reset_current_command_number (
int n);
198 static
void increment_current_command_number ();
200 static
void force_default_editor ();
202 static
void set_initial_input (const std::
string&
text);
204 static
int insert_initial_input ();
208 static
bool instance_ok ();
210 static
void make_command_editor ();
212 static
int startup_handler ();
214 static
int pre_input_handler ();
216 static
int event_handler ();
218 static
void cleanup_instance ()
221 s_instance =
nullptr;
224 static void handle_interrupt_signal ();
230 static std::set<startup_hook_fcn> s_startup_hook_set;
231 static std::set<pre_input_hook_fcn> s_pre_input_hook_set;
232 static std::set<event_hook_fcn> s_event_hook_set;
246 return do_readline (prompt, eof);
275 virtual std::string do_decode_prompt_string (
const std::string&);
377 {
return m_interrupt_event_loop; }
379 int do_insert_initial_input ();
381 int read_octal (
const std::string& s);
385 void error (
const std::string&);
400 OCTAVE_END_NAMESPACE(
octave)
virtual void do_resize_terminal()
virtual string_vector do_generate_filename_completions(const std::string &text)=0
virtual FILE * do_get_input_stream()=0
virtual std::string newline_chars()
virtual user_accept_line_fcn do_get_user_accept_line_function() const
virtual std::string do_get_current_line() const =0
virtual void do_set_screen_size(int ht, int wd)
virtual std::string do_get_line_buffer() const =0
virtual bool do_erase_empty_line(bool)
virtual void do_redisplay()
virtual void do_set_basic_quote_characters(const std::string &)
std::string do_readline(const std::string &prompt)
virtual void restore_event_hook()
virtual void do_kill_full_line()=0
virtual void do_set_user_accept_line_function(user_accept_line_fcn)
virtual completion_fcn do_get_completion_function() const
virtual FILE * do_get_output_stream()=0
virtual void do_set_name(const std::string &)
virtual char do_get_prev_char(int) const =0
virtual void do_set_filename_quote_characters(const std::string &)
virtual void do_set_completer_word_break_characters(const std::string &)
virtual void restore_startup_hook()
virtual void do_set_input_stream(FILE *)=0
std::string m_initial_input
virtual void do_read_init_file(const std::string &)
virtual void do_set_completion_append_character(char)
virtual dequoting_fcn do_get_dequoting_function() const
virtual int do_terminal_cols()
virtual bool do_filename_completion_desired(bool)
virtual char_is_quoted_fcn do_get_char_is_quoted_function() const
bool m_interrupt_event_loop
virtual void do_replace_line(const std::string &text, bool clear_undo)=0
virtual void do_re_read_init_file()
virtual void do_set_output_stream(FILE *)=0
void do_interrupt_event_loop(bool arg)
virtual void do_set_completer_word_break_hook(completion_hook_fcn)
virtual void do_set_quoting_function(quoting_fcn)
virtual quoting_fcn do_get_quoting_function() const
virtual void do_set_char_is_quoted_function(char_is_quoted_fcn)
virtual int do_terminal_rows()
virtual void do_interrupt(bool)
bool do_event_loop_interrupted() const
virtual void do_clear_screen(bool)
virtual void do_restore_terminal_state()
virtual void do_set_basic_word_break_characters(const std::string &)
virtual void do_set_completion_function(completion_fcn)
virtual void do_blink_matching_paren(bool)
virtual void restore_pre_input_hook()
virtual void do_clear_undo_list()
virtual void do_newline()=0
virtual void do_accept_line()=0
virtual void do_insert_text(const std::string &text)=0
virtual void set_pre_input_hook(pre_input_hook_fcn)
virtual bool do_prefer_env_winsize(bool)
virtual void do_set_completer_quote_characters(const std::string &)
virtual bool do_filename_quoting_desired(bool)
virtual void do_handle_interrupt_signal()
virtual void do_set_dequoting_function(dequoting_fcn)
virtual void set_event_hook(event_hook_fcn)
virtual std::string do_readline(const std::string &, bool &)=0
virtual void set_startup_hook(startup_hook_fcn)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)
F77_RET_T const F77_DBLE const F77_DBLE * f