comparison liboctave/cmd-edit.h @ 2926:66ef74ee5d9f

[project @ 1997-05-05 03:20:52 by jwe]
author jwe
date Mon, 05 May 1997 03:40:21 +0000
parents
children b779a5b8aed4
comparison
equal deleted inserted replaced
2925:f0665dac8e33 2926:66ef74ee5d9f
1 /*
2
3 Copyright (C) 1996, 1997 John W. Eaton
4
5 This file is part of Octave.
6
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 */
22
23 #if !defined (octave_cmd_edit_h)
24 #define octave_cmd_edit_h 1
25
26 #include <cstdio>
27
28 #include <string>
29
30 class
31 command_editor
32 {
33 protected:
34
35 command_editor (void)
36 : command_number (0) { }
37
38 public:
39
40 typedef int (*fcn) (...);
41
42 virtual ~command_editor (void) { }
43
44 static void set_name (const string& n);
45
46 static string readline (const string& prompt);
47
48 static void set_input_stream (FILE *f);
49
50 static FILE *get_input_stream (void);
51
52 static void set_output_stream (FILE *f);
53
54 static FILE *get_output_stream (void);
55
56 static int terminal_rows (void);
57
58 static int terminal_cols (void);
59
60 static void clear_screen (void);
61
62 static string decode_prompt_string (const string& s);
63
64 static void restore_terminal_state (void);
65
66 static void blink_matching_paren (bool flag);
67
68 static void set_paren_string_delimiters (const string& s);
69
70 static void set_completion_append_character (char c);
71
72 static void set_attempted_completion_function (fcn f);
73
74 static void insert_text (const string& text);
75
76 static void newline (void);
77
78 static void clear_undo_list (void);
79
80 static void set_startup_hook (fcn f);
81
82 static void restore_startup_hook (void);
83
84 static int current_command_number (void);
85
86 static void reset_current_command_number (int n);
87
88 private:
89
90 // No copying!
91
92 command_editor (const command_editor&);
93
94 command_editor& operator = (const command_editor&);
95
96 static bool instance_ok (void);
97
98 static void make_command_editor (void);
99
100 // The real thing.
101 static command_editor *instance;
102
103 protected:
104
105 // To use something other than the GNU readline library, derive a new
106 // class from command_editor, overload these functions as
107 // necessary, and make instance point to the new class.
108
109 virtual void do_set_name (const string&) { }
110
111 virtual string do_readline (const string&) = 0;
112
113 virtual void do_set_input_stream (FILE *) = 0;
114
115 virtual FILE *do_get_input_stream (void) = 0;
116
117 virtual void do_set_output_stream (FILE *) = 0;
118
119 virtual FILE *do_get_output_stream (void) = 0;
120
121 virtual int do_terminal_rows (void) { return 24; }
122
123 virtual int do_terminal_cols (void) { return 80; }
124
125 virtual void do_clear_screen (void) { }
126
127 virtual string do_decode_prompt_string (const string&);
128
129 virtual string newline_chars (void) { return "\n"; }
130
131 virtual void do_restore_terminal_state (void) { }
132
133 virtual void do_blink_matching_paren (bool) { }
134
135 virtual void do_set_paren_string_delimiters (const string&) { }
136
137 virtual void do_set_completion_append_character (char) { }
138
139 virtual void do_set_attempted_completion_function (fcn) { }
140
141 virtual void do_insert_text (const string&) = 0;
142
143 virtual void do_newline (void) = 0;
144
145 virtual void do_clear_undo_list (void) { }
146
147 virtual void do_set_startup_hook (fcn) { }
148
149 virtual void do_restore_startup_hook (void) { }
150
151 int read_octal (const string& s);
152
153 void error (int);
154
155 void error (const string&);
156
157 // The current command number.
158 int command_number;
159 };
160
161 #endif
162
163 /*
164 ;;; Local Variables: ***
165 ;;; mode: C++ ***
166 ;;; End: ***
167 */