Mercurial > hg > octave-avbm
changeset 9485:3cee58bf4acf
selectively complete filenames in some cases
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 04 Aug 2009 16:31:15 -0400 |
parents | bbe033dcfe13 |
children | d85a43495faa |
files | doc/interpreter/contributors.in liboctave/ChangeLog liboctave/cmd-edit.cc liboctave/cmd-edit.h src/ChangeLog src/input.cc |
diffstat | 6 files changed, 72 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/contributors.in +++ b/doc/interpreter/contributors.in @@ -178,6 +178,7 @@ Andrew Ross Mark van Rossum Kevin Ruland +Kristian Rumberg Ryan Rusaw Olli Saarela Toni Saarela
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,11 @@ +2009-08-04 Kristian Rumberg <kristianrumberg@gmail.com> + + * cmd-edit.cc (gnu_readline::do_get_line_buffer, + default_command_editor::do_get_line_buffer): New functions. + (command_editor::get_line_buffer): New function. + * cmd-edit.h (command_editor::get_line_buffer): Provide decls. + (command_editor::do_get_line_buffer): New pure virtual function. + 2009-07-31 Jaroslav Hajek <highegg@gmail.com> * idx-vector.h (idx_vector::is_range): New method.
--- a/liboctave/cmd-edit.cc +++ b/liboctave/cmd-edit.cc @@ -139,6 +139,8 @@ string_vector do_generate_filename_completions (const std::string& text); + std::string do_get_line_buffer (void) const; + void do_insert_text (const std::string& text); void do_newline (void); @@ -506,6 +508,12 @@ return retval; } +std::string +gnu_readline::do_get_line_buffer (void) const +{ + return ::octave_rl_line_buffer (); +} + void gnu_readline::do_insert_text (const std::string& text) { @@ -737,6 +745,8 @@ string_vector do_generate_filename_completions (const std::string& text); + std::string do_get_line_buffer (void) const; + void do_insert_text (const std::string&); void do_newline (void); @@ -790,6 +800,12 @@ return string_vector (); } +std::string +default_command_editor::do_get_line_buffer (void) const +{ + return ""; +} + void default_command_editor::do_insert_text (const std::string&) { @@ -1119,6 +1135,12 @@ ? instance->do_generate_filename_completions (text) : string_vector (); } +std::string +command_editor::get_line_buffer (void) +{ + return (instance_ok ()) ? instance->do_get_line_buffer () : ""; +} + void command_editor::insert_text (const std::string& text) {
--- a/liboctave/cmd-edit.h +++ b/liboctave/cmd-edit.h @@ -120,6 +120,8 @@ static string_vector generate_filename_completions (const std::string& text); + static std::string get_line_buffer (void); + static void insert_text (const std::string& text); static void newline (void); @@ -256,6 +258,8 @@ virtual string_vector do_generate_filename_completions (const std::string& text) = 0; + virtual std::string do_get_line_buffer (void) const = 0; + virtual void do_insert_text (const std::string&) = 0; virtual void do_newline (void) = 0;
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-08-04 Kristian Rumberg <kristianrumberg@gmail.com> + + * input.cc (is_completing_dirfns): New function. + (generate_completion): Use it to selectively complete file names. + 2009-08-04 John W. Eaton <jwe@octave.org> * debug.cc (Fdbwhere): Call octave_call_stack::goto_frame_relative @@ -6,6 +11,7 @@ * input.cc (Fkeyboard): Don't pass verbose flag to octave_call_stack::goto_frame_relative. (get_debug_input): Get line and column information from call stack. + * pt-eval.h, pt-eval.cc (tree_evaluator::debug_line, tree_evaluator::debug_column, tree_evaluator::db_line, tree_evaluator::db_column): Delete.
--- a/src/input.cc +++ b/src/input.cc @@ -474,6 +474,30 @@ return names; } +static bool +is_completing_dirfns (void) +{ + static std::string dirfns_commands[] = {"cd", "ls"}; + static const size_t dirfns_commands_length = 2; + + bool retval = false; + + std::string line = command_editor::get_line_buffer (); + + for (size_t i = 0; i < dirfns_commands_length; i++) + { + int index = line.find (dirfns_commands[i] + " "); + + if (index == 0) + { + retval = true; + break; + } + } + + return retval; +} + static std::string generate_completion (const std::string& text, int state) { @@ -500,7 +524,13 @@ hint = text; - name_list = generate_possible_completions (text, prefix, hint); + // No reason to display symbols while completing a + // file/directory operation. + + if (is_completing_dirfns ()) + name_list = string_vector (); + else + name_list = generate_possible_completions (text, prefix, hint); name_list_len = name_list.length ();