]>
Commit | Line | Data |
---|---|---|
7e2515e8 FB |
1 | /* |
2 | * QEMU readline utility | |
5fafdf24 | 3 | * |
7e2515e8 | 4 | * Copyright (c) 2003-2004 Fabrice Bellard |
5fafdf24 | 5 | * |
7e2515e8 FB |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
83c9089e PB |
24 | #include "monitor/readline.h" |
25 | #include "monitor/monitor.h" | |
7e2515e8 | 26 | |
7e2515e8 FB |
27 | #define IS_NORM 0 |
28 | #define IS_ESC 1 | |
29 | #define IS_CSI 2 | |
d34dc45d | 30 | #define IS_SS3 3 |
7e2515e8 | 31 | |
30bf5f46 | 32 | #undef printf |
7e2515e8 FB |
33 | #define printf do_not_use_printf |
34 | ||
4c36ba32 | 35 | void readline_show_prompt(ReadLineState *rs) |
7e2515e8 | 36 | { |
4c36ba32 AL |
37 | monitor_printf(rs->mon, "%s", rs->prompt); |
38 | monitor_flush(rs->mon); | |
39 | rs->last_cmd_buf_index = 0; | |
40 | rs->last_cmd_buf_size = 0; | |
41 | rs->esc_state = IS_NORM; | |
7e2515e8 FB |
42 | } |
43 | ||
7e2515e8 | 44 | /* update the displayed command line */ |
4c36ba32 | 45 | static void readline_update(ReadLineState *rs) |
7e2515e8 FB |
46 | { |
47 | int i, delta, len; | |
48 | ||
4c36ba32 AL |
49 | if (rs->cmd_buf_size != rs->last_cmd_buf_size || |
50 | memcmp(rs->cmd_buf, rs->last_cmd_buf, rs->cmd_buf_size) != 0) { | |
51 | for(i = 0; i < rs->last_cmd_buf_index; i++) { | |
52 | monitor_printf(rs->mon, "\033[D"); | |
7e2515e8 | 53 | } |
4c36ba32 AL |
54 | rs->cmd_buf[rs->cmd_buf_size] = '\0'; |
55 | if (rs->read_password) { | |
56 | len = strlen(rs->cmd_buf); | |
7e2515e8 | 57 | for(i = 0; i < len; i++) |
4c36ba32 | 58 | monitor_printf(rs->mon, "*"); |
7e2515e8 | 59 | } else { |
4c36ba32 | 60 | monitor_printf(rs->mon, "%s", rs->cmd_buf); |
7e2515e8 | 61 | } |
4c36ba32 AL |
62 | monitor_printf(rs->mon, "\033[K"); |
63 | memcpy(rs->last_cmd_buf, rs->cmd_buf, rs->cmd_buf_size); | |
64 | rs->last_cmd_buf_size = rs->cmd_buf_size; | |
65 | rs->last_cmd_buf_index = rs->cmd_buf_size; | |
7e2515e8 | 66 | } |
4c36ba32 AL |
67 | if (rs->cmd_buf_index != rs->last_cmd_buf_index) { |
68 | delta = rs->cmd_buf_index - rs->last_cmd_buf_index; | |
7e2515e8 FB |
69 | if (delta > 0) { |
70 | for(i = 0;i < delta; i++) { | |
4c36ba32 | 71 | monitor_printf(rs->mon, "\033[C"); |
7e2515e8 FB |
72 | } |
73 | } else { | |
74 | delta = -delta; | |
75 | for(i = 0;i < delta; i++) { | |
4c36ba32 | 76 | monitor_printf(rs->mon, "\033[D"); |
7e2515e8 FB |
77 | } |
78 | } | |
4c36ba32 | 79 | rs->last_cmd_buf_index = rs->cmd_buf_index; |
7e2515e8 | 80 | } |
4c36ba32 | 81 | monitor_flush(rs->mon); |
7e2515e8 FB |
82 | } |
83 | ||
4c36ba32 | 84 | static void readline_insert_char(ReadLineState *rs, int ch) |
7e2515e8 | 85 | { |
4c36ba32 AL |
86 | if (rs->cmd_buf_index < READLINE_CMD_BUF_SIZE) { |
87 | memmove(rs->cmd_buf + rs->cmd_buf_index + 1, | |
88 | rs->cmd_buf + rs->cmd_buf_index, | |
89 | rs->cmd_buf_size - rs->cmd_buf_index); | |
90 | rs->cmd_buf[rs->cmd_buf_index] = ch; | |
91 | rs->cmd_buf_size++; | |
92 | rs->cmd_buf_index++; | |
7e2515e8 FB |
93 | } |
94 | } | |
95 | ||
4c36ba32 | 96 | static void readline_backward_char(ReadLineState *rs) |
7e2515e8 | 97 | { |
4c36ba32 AL |
98 | if (rs->cmd_buf_index > 0) { |
99 | rs->cmd_buf_index--; | |
7e2515e8 FB |
100 | } |
101 | } | |
102 | ||
4c36ba32 | 103 | static void readline_forward_char(ReadLineState *rs) |
7e2515e8 | 104 | { |
4c36ba32 AL |
105 | if (rs->cmd_buf_index < rs->cmd_buf_size) { |
106 | rs->cmd_buf_index++; | |
7e2515e8 FB |
107 | } |
108 | } | |
109 | ||
4c36ba32 | 110 | static void readline_delete_char(ReadLineState *rs) |
7e2515e8 | 111 | { |
4c36ba32 AL |
112 | if (rs->cmd_buf_index < rs->cmd_buf_size) { |
113 | memmove(rs->cmd_buf + rs->cmd_buf_index, | |
114 | rs->cmd_buf + rs->cmd_buf_index + 1, | |
115 | rs->cmd_buf_size - rs->cmd_buf_index - 1); | |
116 | rs->cmd_buf_size--; | |
7e2515e8 FB |
117 | } |
118 | } | |
119 | ||
4c36ba32 | 120 | static void readline_backspace(ReadLineState *rs) |
7e2515e8 | 121 | { |
4c36ba32 AL |
122 | if (rs->cmd_buf_index > 0) { |
123 | readline_backward_char(rs); | |
124 | readline_delete_char(rs); | |
7e2515e8 FB |
125 | } |
126 | } | |
127 | ||
4c36ba32 | 128 | static void readline_backword(ReadLineState *rs) |
33fa11d4 TS |
129 | { |
130 | int start; | |
131 | ||
4c36ba32 | 132 | if (rs->cmd_buf_index == 0 || rs->cmd_buf_index > rs->cmd_buf_size) { |
33fa11d4 TS |
133 | return; |
134 | } | |
135 | ||
4c36ba32 | 136 | start = rs->cmd_buf_index - 1; |
33fa11d4 TS |
137 | |
138 | /* find first word (backwards) */ | |
139 | while (start > 0) { | |
4c36ba32 | 140 | if (!qemu_isspace(rs->cmd_buf[start])) { |
33fa11d4 TS |
141 | break; |
142 | } | |
143 | ||
144 | --start; | |
145 | } | |
146 | ||
147 | /* find first space (backwards) */ | |
148 | while (start > 0) { | |
4c36ba32 | 149 | if (qemu_isspace(rs->cmd_buf[start])) { |
33fa11d4 TS |
150 | ++start; |
151 | break; | |
152 | } | |
153 | ||
154 | --start; | |
155 | } | |
156 | ||
157 | /* remove word */ | |
4c36ba32 AL |
158 | if (start < rs->cmd_buf_index) { |
159 | memmove(rs->cmd_buf + start, | |
160 | rs->cmd_buf + rs->cmd_buf_index, | |
161 | rs->cmd_buf_size - rs->cmd_buf_index); | |
162 | rs->cmd_buf_size -= rs->cmd_buf_index - start; | |
163 | rs->cmd_buf_index = start; | |
33fa11d4 TS |
164 | } |
165 | } | |
166 | ||
4c36ba32 | 167 | static void readline_bol(ReadLineState *rs) |
7e2515e8 | 168 | { |
4c36ba32 | 169 | rs->cmd_buf_index = 0; |
7e2515e8 FB |
170 | } |
171 | ||
4c36ba32 | 172 | static void readline_eol(ReadLineState *rs) |
7e2515e8 | 173 | { |
4c36ba32 | 174 | rs->cmd_buf_index = rs->cmd_buf_size; |
7e2515e8 FB |
175 | } |
176 | ||
4c36ba32 | 177 | static void readline_up_char(ReadLineState *rs) |
7e2515e8 FB |
178 | { |
179 | int idx; | |
180 | ||
4c36ba32 | 181 | if (rs->hist_entry == 0) |
7e2515e8 | 182 | return; |
4c36ba32 | 183 | if (rs->hist_entry == -1) { |
7e2515e8 | 184 | /* Find latest entry */ |
4c36ba32 AL |
185 | for (idx = 0; idx < READLINE_MAX_CMDS; idx++) { |
186 | if (rs->history[idx] == NULL) | |
7e2515e8 FB |
187 | break; |
188 | } | |
4c36ba32 | 189 | rs->hist_entry = idx; |
7e2515e8 | 190 | } |
4c36ba32 AL |
191 | rs->hist_entry--; |
192 | if (rs->hist_entry >= 0) { | |
193 | pstrcpy(rs->cmd_buf, sizeof(rs->cmd_buf), | |
194 | rs->history[rs->hist_entry]); | |
195 | rs->cmd_buf_index = rs->cmd_buf_size = strlen(rs->cmd_buf); | |
7e2515e8 FB |
196 | } |
197 | } | |
198 | ||
4c36ba32 | 199 | static void readline_down_char(ReadLineState *rs) |
7e2515e8 | 200 | { |
5b0d2727 AL |
201 | if (rs->hist_entry == -1) |
202 | return; | |
203 | if (rs->hist_entry < READLINE_MAX_CMDS - 1 && | |
204 | rs->history[++rs->hist_entry] != NULL) { | |
4c36ba32 AL |
205 | pstrcpy(rs->cmd_buf, sizeof(rs->cmd_buf), |
206 | rs->history[rs->hist_entry]); | |
7e2515e8 | 207 | } else { |
5b0d2727 | 208 | rs->cmd_buf[0] = 0; |
4c36ba32 | 209 | rs->hist_entry = -1; |
7e2515e8 | 210 | } |
4c36ba32 | 211 | rs->cmd_buf_index = rs->cmd_buf_size = strlen(rs->cmd_buf); |
7e2515e8 FB |
212 | } |
213 | ||
4c36ba32 | 214 | static void readline_hist_add(ReadLineState *rs, const char *cmdline) |
7e2515e8 FB |
215 | { |
216 | char *hist_entry, *new_entry; | |
217 | int idx; | |
218 | ||
219 | if (cmdline[0] == '\0') | |
220 | return; | |
221 | new_entry = NULL; | |
4c36ba32 | 222 | if (rs->hist_entry != -1) { |
7e2515e8 | 223 | /* We were editing an existing history entry: replace it */ |
4c36ba32 AL |
224 | hist_entry = rs->history[rs->hist_entry]; |
225 | idx = rs->hist_entry; | |
7e2515e8 FB |
226 | if (strcmp(hist_entry, cmdline) == 0) { |
227 | goto same_entry; | |
228 | } | |
229 | } | |
230 | /* Search cmdline in history buffers */ | |
4c36ba32 AL |
231 | for (idx = 0; idx < READLINE_MAX_CMDS; idx++) { |
232 | hist_entry = rs->history[idx]; | |
7e2515e8 FB |
233 | if (hist_entry == NULL) |
234 | break; | |
235 | if (strcmp(hist_entry, cmdline) == 0) { | |
236 | same_entry: | |
237 | new_entry = hist_entry; | |
238 | /* Put this entry at the end of history */ | |
4c36ba32 | 239 | memmove(&rs->history[idx], &rs->history[idx + 1], |
8af42882 | 240 | (READLINE_MAX_CMDS - (idx + 1)) * sizeof(char *)); |
4c36ba32 AL |
241 | rs->history[READLINE_MAX_CMDS - 1] = NULL; |
242 | for (; idx < READLINE_MAX_CMDS; idx++) { | |
243 | if (rs->history[idx] == NULL) | |
7e2515e8 FB |
244 | break; |
245 | } | |
246 | break; | |
247 | } | |
248 | } | |
4c36ba32 | 249 | if (idx == READLINE_MAX_CMDS) { |
7e2515e8 | 250 | /* Need to get one free slot */ |
c3baa5f9 | 251 | g_free(rs->history[0]); |
7682e858 NZ |
252 | memmove(rs->history, &rs->history[1], |
253 | (READLINE_MAX_CMDS - 1) * sizeof(char *)); | |
4c36ba32 AL |
254 | rs->history[READLINE_MAX_CMDS - 1] = NULL; |
255 | idx = READLINE_MAX_CMDS - 1; | |
7e2515e8 FB |
256 | } |
257 | if (new_entry == NULL) | |
c3baa5f9 | 258 | new_entry = g_strdup(cmdline); |
4c36ba32 AL |
259 | rs->history[idx] = new_entry; |
260 | rs->hist_entry = -1; | |
7e2515e8 FB |
261 | } |
262 | ||
263 | /* completion support */ | |
264 | ||
4c36ba32 | 265 | void readline_add_completion(ReadLineState *rs, const char *str) |
7e2515e8 | 266 | { |
4c36ba32 | 267 | if (rs->nb_completions < READLINE_MAX_COMPLETIONS) { |
7267c094 | 268 | rs->completions[rs->nb_completions++] = g_strdup(str); |
7e2515e8 FB |
269 | } |
270 | } | |
271 | ||
4c36ba32 | 272 | void readline_set_completion_index(ReadLineState *rs, int index) |
376253ec | 273 | { |
4c36ba32 | 274 | rs->completion_index = index; |
376253ec AL |
275 | } |
276 | ||
4c36ba32 | 277 | static void readline_completion(ReadLineState *rs) |
7e2515e8 | 278 | { |
376253ec | 279 | Monitor *mon = cur_mon; |
b427c726 | 280 | int len, i, j, max_width, nb_cols, max_prefix; |
7e2515e8 FB |
281 | char *cmdline; |
282 | ||
4c36ba32 | 283 | rs->nb_completions = 0; |
3b46e624 | 284 | |
7267c094 | 285 | cmdline = g_malloc(rs->cmd_buf_index + 1); |
4c36ba32 AL |
286 | memcpy(cmdline, rs->cmd_buf, rs->cmd_buf_index); |
287 | cmdline[rs->cmd_buf_index] = '\0'; | |
288 | rs->completion_finder(cmdline); | |
7267c094 | 289 | g_free(cmdline); |
7e2515e8 FB |
290 | |
291 | /* no completion found */ | |
4c36ba32 | 292 | if (rs->nb_completions <= 0) |
7e2515e8 | 293 | return; |
4c36ba32 AL |
294 | if (rs->nb_completions == 1) { |
295 | len = strlen(rs->completions[0]); | |
296 | for(i = rs->completion_index; i < len; i++) { | |
297 | readline_insert_char(rs, rs->completions[0][i]); | |
7e2515e8 FB |
298 | } |
299 | /* extra space for next argument. XXX: make it more generic */ | |
4c36ba32 AL |
300 | if (len > 0 && rs->completions[0][len - 1] != '/') |
301 | readline_insert_char(rs, ' '); | |
7e2515e8 | 302 | } else { |
376253ec | 303 | monitor_printf(mon, "\n"); |
7e2515e8 | 304 | max_width = 0; |
b427c726 | 305 | max_prefix = 0; |
4c36ba32 AL |
306 | for(i = 0; i < rs->nb_completions; i++) { |
307 | len = strlen(rs->completions[i]); | |
b427c726 TS |
308 | if (i==0) { |
309 | max_prefix = len; | |
310 | } else { | |
311 | if (len < max_prefix) | |
312 | max_prefix = len; | |
313 | for(j=0; j<max_prefix; j++) { | |
4c36ba32 | 314 | if (rs->completions[i][j] != rs->completions[0][j]) |
b427c726 TS |
315 | max_prefix = j; |
316 | } | |
317 | } | |
7e2515e8 FB |
318 | if (len > max_width) |
319 | max_width = len; | |
320 | } | |
b427c726 | 321 | if (max_prefix > 0) |
4c36ba32 AL |
322 | for(i = rs->completion_index; i < max_prefix; i++) { |
323 | readline_insert_char(rs, rs->completions[0][i]); | |
b427c726 | 324 | } |
7e2515e8 FB |
325 | max_width += 2; |
326 | if (max_width < 10) | |
327 | max_width = 10; | |
328 | else if (max_width > 80) | |
329 | max_width = 80; | |
330 | nb_cols = 80 / max_width; | |
331 | j = 0; | |
4c36ba32 AL |
332 | for(i = 0; i < rs->nb_completions; i++) { |
333 | monitor_printf(rs->mon, "%-*s", max_width, rs->completions[i]); | |
334 | if (++j == nb_cols || i == (rs->nb_completions - 1)) { | |
335 | monitor_printf(rs->mon, "\n"); | |
7e2515e8 FB |
336 | j = 0; |
337 | } | |
338 | } | |
4c36ba32 | 339 | readline_show_prompt(rs); |
7e2515e8 | 340 | } |
fc9fa4bd SW |
341 | for (i = 0; i < rs->nb_completions; i++) { |
342 | g_free(rs->completions[i]); | |
343 | } | |
7e2515e8 FB |
344 | } |
345 | ||
346 | /* return true if command handled */ | |
4c36ba32 | 347 | void readline_handle_byte(ReadLineState *rs, int ch) |
7e2515e8 | 348 | { |
4c36ba32 | 349 | switch(rs->esc_state) { |
7e2515e8 FB |
350 | case IS_NORM: |
351 | switch(ch) { | |
352 | case 1: | |
4c36ba32 | 353 | readline_bol(rs); |
7e2515e8 FB |
354 | break; |
355 | case 4: | |
4c36ba32 | 356 | readline_delete_char(rs); |
7e2515e8 FB |
357 | break; |
358 | case 5: | |
4c36ba32 | 359 | readline_eol(rs); |
7e2515e8 FB |
360 | break; |
361 | case 9: | |
4c36ba32 | 362 | readline_completion(rs); |
7e2515e8 FB |
363 | break; |
364 | case 10: | |
365 | case 13: | |
4c36ba32 AL |
366 | rs->cmd_buf[rs->cmd_buf_size] = '\0'; |
367 | if (!rs->read_password) | |
368 | readline_hist_add(rs, rs->cmd_buf); | |
369 | monitor_printf(rs->mon, "\n"); | |
370 | rs->cmd_buf_index = 0; | |
371 | rs->cmd_buf_size = 0; | |
372 | rs->last_cmd_buf_index = 0; | |
373 | rs->last_cmd_buf_size = 0; | |
374 | rs->readline_func(rs->mon, rs->cmd_buf, rs->readline_opaque); | |
7e2515e8 | 375 | break; |
33fa11d4 TS |
376 | case 23: |
377 | /* ^W */ | |
4c36ba32 | 378 | readline_backword(rs); |
33fa11d4 | 379 | break; |
7e2515e8 | 380 | case 27: |
4c36ba32 | 381 | rs->esc_state = IS_ESC; |
7e2515e8 FB |
382 | break; |
383 | case 127: | |
384 | case 8: | |
4c36ba32 | 385 | readline_backspace(rs); |
7e2515e8 FB |
386 | break; |
387 | case 155: | |
4c36ba32 | 388 | rs->esc_state = IS_CSI; |
7e2515e8 FB |
389 | break; |
390 | default: | |
391 | if (ch >= 32) { | |
4c36ba32 | 392 | readline_insert_char(rs, ch); |
7e2515e8 FB |
393 | } |
394 | break; | |
395 | } | |
396 | break; | |
397 | case IS_ESC: | |
398 | if (ch == '[') { | |
4c36ba32 AL |
399 | rs->esc_state = IS_CSI; |
400 | rs->esc_param = 0; | |
d34dc45d KW |
401 | } else if (ch == 'O') { |
402 | rs->esc_state = IS_SS3; | |
403 | rs->esc_param = 0; | |
7e2515e8 | 404 | } else { |
4c36ba32 | 405 | rs->esc_state = IS_NORM; |
7e2515e8 FB |
406 | } |
407 | break; | |
408 | case IS_CSI: | |
409 | switch(ch) { | |
410 | case 'A': | |
411 | case 'F': | |
4c36ba32 | 412 | readline_up_char(rs); |
7e2515e8 FB |
413 | break; |
414 | case 'B': | |
415 | case 'E': | |
4c36ba32 | 416 | readline_down_char(rs); |
7e2515e8 FB |
417 | break; |
418 | case 'D': | |
4c36ba32 | 419 | readline_backward_char(rs); |
7e2515e8 FB |
420 | break; |
421 | case 'C': | |
4c36ba32 | 422 | readline_forward_char(rs); |
7e2515e8 FB |
423 | break; |
424 | case '0' ... '9': | |
4c36ba32 | 425 | rs->esc_param = rs->esc_param * 10 + (ch - '0'); |
7e2515e8 FB |
426 | goto the_end; |
427 | case '~': | |
4c36ba32 | 428 | switch(rs->esc_param) { |
7e2515e8 | 429 | case 1: |
4c36ba32 | 430 | readline_bol(rs); |
7e2515e8 FB |
431 | break; |
432 | case 3: | |
4c36ba32 | 433 | readline_delete_char(rs); |
7e2515e8 FB |
434 | break; |
435 | case 4: | |
4c36ba32 | 436 | readline_eol(rs); |
7e2515e8 FB |
437 | break; |
438 | } | |
439 | break; | |
440 | default: | |
441 | break; | |
442 | } | |
4c36ba32 | 443 | rs->esc_state = IS_NORM; |
7e2515e8 FB |
444 | the_end: |
445 | break; | |
d34dc45d KW |
446 | case IS_SS3: |
447 | switch(ch) { | |
448 | case 'F': | |
449 | readline_eol(rs); | |
450 | break; | |
451 | case 'H': | |
452 | readline_bol(rs); | |
453 | break; | |
454 | } | |
455 | rs->esc_state = IS_NORM; | |
456 | break; | |
7e2515e8 | 457 | } |
4c36ba32 | 458 | readline_update(rs); |
7e2515e8 FB |
459 | } |
460 | ||
4c36ba32 | 461 | void readline_start(ReadLineState *rs, const char *prompt, int read_password, |
7e2515e8 FB |
462 | ReadLineFunc *readline_func, void *opaque) |
463 | { | |
4c36ba32 AL |
464 | pstrcpy(rs->prompt, sizeof(rs->prompt), prompt); |
465 | rs->readline_func = readline_func; | |
466 | rs->readline_opaque = opaque; | |
467 | rs->read_password = read_password; | |
2724b180 AL |
468 | readline_restart(rs); |
469 | } | |
470 | ||
471 | void readline_restart(ReadLineState *rs) | |
472 | { | |
4c36ba32 AL |
473 | rs->cmd_buf_index = 0; |
474 | rs->cmd_buf_size = 0; | |
7e2515e8 FB |
475 | } |
476 | ||
4c36ba32 | 477 | const char *readline_get_history(ReadLineState *rs, unsigned int index) |
7e2515e8 | 478 | { |
4c36ba32 | 479 | if (index >= READLINE_MAX_CMDS) |
7e2515e8 | 480 | return NULL; |
4c36ba32 AL |
481 | return rs->history[index]; |
482 | } | |
483 | ||
484 | ReadLineState *readline_init(Monitor *mon, | |
485 | ReadLineCompletionFunc *completion_finder) | |
486 | { | |
7267c094 | 487 | ReadLineState *rs = g_malloc0(sizeof(*rs)); |
4c36ba32 | 488 | |
4c36ba32 AL |
489 | rs->hist_entry = -1; |
490 | rs->mon = mon; | |
491 | rs->completion_finder = completion_finder; | |
492 | ||
493 | return rs; | |
7e2515e8 | 494 | } |