Mercurial > hg > octave-nkf
comparison liboctave/cmd-edit.cc @ 4604:cba347c642e2
[project @ 2003-11-13 04:38:05 by jwe]
author | jwe |
---|---|
date | Thu, 13 Nov 2003 04:38:05 +0000 |
parents | c0a23a13eea2 |
children | bf7272f8ba8c |
comparison
equal
deleted
inserted
replaced
4603:15ddd40fee90 | 4604:cba347c642e2 |
---|---|
103 | 103 |
104 void do_set_completion_function (completion_fcn f); | 104 void do_set_completion_function (completion_fcn f); |
105 | 105 |
106 completion_fcn do_get_completion_function (void) const; | 106 completion_fcn do_get_completion_function (void) const; |
107 | 107 |
108 string_vector | |
109 do_generate_filename_completions (const std::string& text); | |
110 | |
108 void do_insert_text (const std::string& text); | 111 void do_insert_text (const std::string& text); |
109 | 112 |
110 void do_newline (void); | 113 void do_newline (void); |
111 | 114 |
112 void do_clear_undo_list (void); | 115 void do_clear_undo_list (void); |
316 | 319 |
317 gnu_readline::completion_fcn | 320 gnu_readline::completion_fcn |
318 gnu_readline::do_get_completion_function (void) const | 321 gnu_readline::do_get_completion_function (void) const |
319 { | 322 { |
320 return completion_function; | 323 return completion_function; |
324 } | |
325 | |
326 string_vector | |
327 gnu_readline::do_generate_filename_completions (const std::string& text) | |
328 { | |
329 string_vector retval; | |
330 | |
331 int n = 0; | |
332 int count = 0; | |
333 | |
334 char *fn = 0; | |
335 | |
336 while (1) | |
337 { | |
338 fn = ::octave_rl_filename_completion_function (text.c_str (), count); | |
339 | |
340 if (fn) | |
341 { | |
342 if (count == n) | |
343 { | |
344 // Famous last words: Most large directories will not | |
345 // have more than a few hundred files, so we should not | |
346 // resize too many times even if the growth is linear... | |
347 | |
348 n += 100; | |
349 retval.resize (n); | |
350 } | |
351 | |
352 retval[count++] = fn; | |
353 | |
354 free (fn); | |
355 } | |
356 else | |
357 break; | |
358 } | |
359 | |
360 retval.resize (count); | |
361 | |
362 return retval; | |
321 } | 363 } |
322 | 364 |
323 void | 365 void |
324 gnu_readline::do_insert_text (const std::string& text) | 366 gnu_readline::do_insert_text (const std::string& text) |
325 { | 367 { |
465 | 507 |
466 void do_set_output_stream (FILE *f); | 508 void do_set_output_stream (FILE *f); |
467 | 509 |
468 FILE *do_get_output_stream (void); | 510 FILE *do_get_output_stream (void); |
469 | 511 |
512 string_vector do_generate_filename_completions (const std::string& text); | |
513 | |
470 void do_insert_text (const std::string&); | 514 void do_insert_text (const std::string&); |
471 | 515 |
472 void do_newline (void); | 516 void do_newline (void); |
473 | 517 |
474 private: | 518 private: |
507 | 551 |
508 FILE * | 552 FILE * |
509 default_command_editor::do_get_output_stream (void) | 553 default_command_editor::do_get_output_stream (void) |
510 { | 554 { |
511 return output_stream; | 555 return output_stream; |
556 } | |
557 | |
558 string_vector | |
559 default_command_editor::do_generate_filename_completions (const std::string& text) | |
560 { | |
561 // XXX FIXME XXX | |
562 return string_vector (); | |
512 } | 563 } |
513 | 564 |
514 void | 565 void |
515 default_command_editor::do_insert_text (const std::string&) | 566 default_command_editor::do_insert_text (const std::string&) |
516 { | 567 { |
710 command_editor::completion_fcn | 761 command_editor::completion_fcn |
711 command_editor::get_completion_function (void) | 762 command_editor::get_completion_function (void) |
712 { | 763 { |
713 return (instance_ok ()) | 764 return (instance_ok ()) |
714 ? instance->do_get_completion_function () : 0; | 765 ? instance->do_get_completion_function () : 0; |
766 } | |
767 | |
768 string_vector | |
769 command_editor::generate_filename_completions (const std::string& text) | |
770 { | |
771 return (instance_ok ()) | |
772 ? instance->do_generate_filename_completions (text) : string_vector (); | |
715 } | 773 } |
716 | 774 |
717 void | 775 void |
718 command_editor::insert_text (const std::string& text) | 776 command_editor::insert_text (const std::string& text) |
719 { | 777 { |