Mercurial > hg > octave-lyh
diff 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 |
line wrap: on
line diff
--- a/liboctave/cmd-edit.cc +++ b/liboctave/cmd-edit.cc @@ -105,6 +105,9 @@ completion_fcn do_get_completion_function (void) const; + string_vector + do_generate_filename_completions (const std::string& text); + void do_insert_text (const std::string& text); void do_newline (void); @@ -320,6 +323,45 @@ return completion_function; } +string_vector +gnu_readline::do_generate_filename_completions (const std::string& text) +{ + string_vector retval; + + int n = 0; + int count = 0; + + char *fn = 0; + + while (1) + { + fn = ::octave_rl_filename_completion_function (text.c_str (), count); + + if (fn) + { + if (count == n) + { + // Famous last words: Most large directories will not + // have more than a few hundred files, so we should not + // resize too many times even if the growth is linear... + + n += 100; + retval.resize (n); + } + + retval[count++] = fn; + + free (fn); + } + else + break; + } + + retval.resize (count); + + return retval; +} + void gnu_readline::do_insert_text (const std::string& text) { @@ -467,6 +509,8 @@ FILE *do_get_output_stream (void); + string_vector do_generate_filename_completions (const std::string& text); + void do_insert_text (const std::string&); void do_newline (void); @@ -511,6 +555,13 @@ return output_stream; } +string_vector +default_command_editor::do_generate_filename_completions (const std::string& text) +{ + // XXX FIXME XXX + return string_vector (); +} + void default_command_editor::do_insert_text (const std::string&) { @@ -714,6 +765,13 @@ ? instance->do_get_completion_function () : 0; } +string_vector +command_editor::generate_filename_completions (const std::string& text) +{ + return (instance_ok ()) + ? instance->do_generate_filename_completions (text) : string_vector (); +} + void command_editor::insert_text (const std::string& text) {