Mercurial > hg > octave-nkf
annotate liboctave/util/oct-rl-hist.c @ 16057:c3057d80cf91
Created common octave_dock_widget class
* octave_dock_widget.h : New class octave_dock_widget with common dock widget
methods, slots and signals
* file_editor_interface.h: Now inherit from octave_dock_widget, removed common
dock widget code
* file_editor.h: Now inherit from octave_dock_widget, removed common
dock widget code
* file_editor.cc: Now inherit from octave_dock_widget, removed common
dock widget code
* files_dockwidget.h: Now inherit from octave_dock_widget, removed common
dock widget code
* files_dockwidget.cc: Now inherit from octave_dock_widget, removed common
dock widget code
* history_dockwidget.h: Now inherit from octave_dock_widget, removed common
dock widget code
* history_dockwidget.cc: Now inherit from octave_dock_widget, removed common
dock widget methods
* terminal_dockwidget.h: Now inherit from octave_dock_widget, removed common
dock widget code
* terminal_dockwidget.cc: Now inherit from octave_dock_widget, removed common
dock widget code
* module.mk: Added octave_dock_widget
author | Richard Crozier <richard.crozier@yahoo.co.uk> |
---|---|
date | Wed, 06 Feb 2013 21:45:04 +0000 |
parents | 231d8d3b8225 |
children | 06824c3b1ff3 |
rev | line source |
---|---|
3519 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 2000-2012 John W. Eaton |
3519 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3519 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3519 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
27 #include "oct-rl-hist.h" |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
28 |
3519 | 29 #if defined (USE_READLINE) |
30 | |
31 #include <stdio.h> | |
32 #include <stdlib.h> | |
4587 | 33 #include <string.h> |
3519 | 34 |
35 #include <readline/history.h> | |
36 | |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
37 /* check_history_control, hc_erasedup, and the core of |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
38 octave_add_history were borrowed from Bash. */ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
39 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
40 /* Check LINE against what HISTCONTROL says to do. Returns 1 if the line |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
41 should be saved; 0 if it should be discarded. */ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
42 static int |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
43 check_history_control (const char *line, int history_control) |
3519 | 44 { |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
45 HIST_ENTRY *temp; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
46 int r; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
47 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
48 if (history_control == 0) |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
49 return 1; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
50 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
51 /* ignorespace or ignoreboth */ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
52 if ((history_control & HC_IGNSPACE) && *line == ' ') |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
53 return 0; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
54 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
55 /* ignoredups or ignoreboth */ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
56 if (history_control & HC_IGNDUPS) |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
57 { |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
58 using_history (); |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
59 temp = previous_history (); |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
60 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
61 r = (temp == 0 || strcmp (temp->line, line)); |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
62 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
63 using_history (); |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
64 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
65 if (r == 0) |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
66 return r; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
67 } |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
68 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
69 return 1; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
70 } |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
71 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
72 /* Remove all entries matching LINE from the history list. Triggered when |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
73 HISTCONTROL includes `erasedups'. */ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
74 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
75 static void |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
76 hc_erasedups (const char *line) |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
77 { |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
78 HIST_ENTRY *temp; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
79 int r; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
80 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
81 using_history (); |
11490
0a4dfc867e60
avoid GCC warning for oct-rl-hist.c
John W. Eaton <jwe@octave.org>
parents:
11486
diff
changeset
|
82 while ((temp = previous_history ())) |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
83 { |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
84 if (! strcmp (temp->line, line)) |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
85 { |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
86 r = where_history (); |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
87 remove_history (r); |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
88 } |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
89 } |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
90 using_history (); |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
91 } |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
92 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
93 /* Check LINE against HISTCONTROL and add it to the history if it's OK. |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
94 Returns 1 if the line was saved in the history, 0 otherwise. */ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
95 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
96 int |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
97 octave_add_history (const char *line, int history_control) |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
98 { |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
99 if (check_history_control (line, history_control)) |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
100 { |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
101 /* We're committed to saving the line. If the user has requested it, |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
102 remove other matching lines from the history. */ |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
103 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
104 if (history_control & HC_ERASEDUPS) |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
105 hc_erasedups (line); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
106 |
11486
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
107 add_history (line); |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
108 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
109 return 1; |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
110 } |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
111 |
a1deab9a6e71
bash-like history control
Pascal Dupuis <Pascal.Dupuis@worldonline.be> and John W. Eaton <jwe@octave.org>
parents:
10317
diff
changeset
|
112 return 0; |
3519 | 113 } |
114 | |
115 int | |
116 octave_where_history (void) | |
117 { | |
118 return where_history (); | |
119 } | |
120 | |
121 int | |
122 octave_history_length (void) | |
123 { | |
124 return history_length; | |
125 } | |
126 | |
127 int | |
128 octave_max_input_history (void) | |
129 { | |
130 return max_input_history; | |
131 } | |
132 | |
133 int | |
134 octave_history_base (void) | |
135 { | |
136 return history_base; | |
137 } | |
138 | |
139 void | |
140 octave_stifle_history (int n) | |
141 { | |
3520 | 142 stifle_history (n); |
3519 | 143 } |
144 | |
145 int | |
146 octave_unstifle_history (void) | |
147 { | |
148 return unstifle_history (); | |
149 } | |
150 | |
151 int | |
152 octave_history_is_stifled (void) | |
153 { | |
154 return history_is_stifled (); | |
155 } | |
156 | |
157 int | |
158 octave_history_set_pos (int n) | |
159 { | |
160 return history_set_pos (n); | |
161 } | |
162 | |
163 int | |
164 octave_read_history (const char *f) | |
165 { | |
166 return read_history (f); | |
167 } | |
168 | |
169 void | |
170 octave_using_history (void) | |
171 { | |
3520 | 172 using_history (); |
3519 | 173 } |
174 | |
175 int | |
176 octave_read_history_range (const char *f, int b, int e) | |
177 { | |
178 return read_history_range (f, b, e); | |
179 } | |
180 | |
181 int | |
182 octave_write_history (const char *f) | |
183 { | |
184 return write_history (f); | |
185 } | |
186 | |
187 int | |
188 octave_append_history (int n, const char *f) | |
189 { | |
190 return append_history (n, f); | |
191 } | |
192 | |
193 int | |
194 octave_history_truncate_file (const char *f, int n) | |
195 { | |
196 return history_truncate_file (f, n); | |
197 } | |
198 | |
199 void | |
200 octave_remove_history (int n) | |
201 { | |
202 HIST_ENTRY *discard = remove_history (n); | |
203 | |
204 if (discard) | |
205 { | |
206 if (discard->line) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
207 free (discard->line); |
3519 | 208 |
209 free (discard); | |
210 } | |
211 } | |
212 | |
15397
231d8d3b8225
provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
213 void |
231d8d3b8225
provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
214 octave_clear_history (void) |
231d8d3b8225
provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
215 { |
231d8d3b8225
provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
216 clear_history (); |
231d8d3b8225
provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
217 } |
231d8d3b8225
provide command_hist::clear_history function
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
218 |
3519 | 219 char * |
220 octave_history_goto_mark (int n) | |
221 { | |
222 HIST_ENTRY *h; | |
223 | |
224 char *retval = 0; | |
225 | |
226 if (history_set_pos (n)) | |
227 { | |
228 h = current_history (); | |
229 | |
230 if (h) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
231 retval = h->line; |
3519 | 232 } |
233 | |
234 return retval; | |
235 } | |
236 | |
237 char * | |
238 octave_history_get (int n) | |
239 { | |
240 char *retval = 0; | |
241 | |
242 HIST_ENTRY *h = history_get (n); | |
243 | |
244 if (h) | |
245 retval = h->line; | |
246 | |
247 return retval; | |
248 } | |
249 | |
250 char ** | |
251 octave_history_list (int limit, int number_lines) | |
252 { | |
253 static char **retval = 0; | |
254 | |
255 HIST_ENTRY **hlist = 0; | |
256 | |
257 if (retval) | |
258 { | |
259 char **p = retval; | |
260 | |
3598 | 261 while (*p) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
262 free (*p++); |
3519 | 263 |
264 free (retval); | |
265 | |
266 retval = 0; | |
267 } | |
268 | |
269 hlist = history_list (); | |
270 | |
271 if (hlist) | |
272 { | |
273 int i, k; | |
274 | |
275 int beg = 0; | |
276 int end = 0; | |
277 while (hlist[end]) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
278 end++; |
3519 | 279 |
280 beg = (limit < 0 || end < limit) ? 0 : (end - limit); | |
281 | |
282 retval = malloc ((end - beg + 1) * sizeof (char **)); | |
283 | |
284 k = 0; | |
285 for (i = beg; i < end; i++) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
286 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
287 char *line = hlist[i]->line; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
288 int len = line ? strlen (line) : 0; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
289 char *tmp = malloc (len + 64); |
3519 | 290 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
291 if (number_lines) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
292 sprintf (tmp, "%5d%c%s", i + history_base, |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
293 hlist[i]->data ? '*' : ' ', |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
294 line ? line : ""); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
295 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
296 sprintf (tmp, "%c%s", hlist[i]->data ? '*' : ' ', |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
297 line ? line : ""); |
3519 | 298 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
299 retval[k++] = tmp; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
300 } |
3519 | 301 |
302 retval[k] = 0; | |
303 } | |
304 | |
305 return retval; | |
306 } | |
307 | |
308 void | |
309 octave_replace_history_entry (int which, const char *line) | |
310 { | |
311 HIST_ENTRY *discard = replace_history_entry (which, line, 0); | |
312 | |
313 if (discard) | |
314 { | |
315 if (discard->line) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
316 free (discard->line); |
3519 | 317 |
318 free (discard); | |
319 } | |
320 } | |
321 | |
322 #endif |