This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] gdb: Add completer for layout command.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a014503004ad016d754bc9a4b143973ee18b0bbf

commit a014503004ad016d754bc9a4b143973ee18b0bbf
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Thu Mar 26 14:13:57 2015 +0000

    gdb: Add completer for layout command.
    
    Add layout name completion for the layout command.
    
    gdb/ChangeLog:
    
    	* tui/tui-layout.c (layout_completer): New function.
    	(_initialize_tui_layout): Set completer on layout command.
    
    gdb/testsuite/ChangeLog:
    
    	* gdb.base/completion.exp: Add test for completion of layout
    	names.

Diff:
---
 gdb/ChangeLog                         |  5 +++++
 gdb/testsuite/ChangeLog               |  5 +++++
 gdb/testsuite/gdb.base/completion.exp | 19 +++++++++++++++++++
 gdb/tui/tui-layout.c                  | 18 +++++++++++++++++-
 4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5957824..84e6b25 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2015-05-21  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* tui/tui-layout.c (layout_completer): New function.
+	(_initialize_tui_layout): Set completer on layout command.
+
+2015-05-21  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* tui/tui-layout.c (tui_set_layout): Remove
 	tui_register_display_type parameter.  Remove all checking of this
 	parameter, and reindent function.  Update header comment.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3a947eb..49f56f4 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-21  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* gdb.base/completion.exp: Add test for completion of layout
+	names.
+
 2015-05-20  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* lib/gdb.exp (skip_tui_tests): New proc.
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index f77bfe2..4c31bfc 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -859,3 +859,22 @@ gdb_test_multiple "" "$test" {
 	pass "$test"
     }
 }
+
+gdb_test_no_output "set max-completions unlimited"
+
+if {![skip_tui_tests]} {
+    set test "test completion of layout names"
+    send_gdb "layout\t\t\t"
+    gdb_test_multiple "" "$test" {
+	-re "asm *next *prev *regs *split *src *\r\n$gdb_prompt layout $" {
+	    pass "$test"
+	}
+    }
+    send_gdb "\003"
+    set test "quit command input after testing layout completion"
+    gdb_test_multiple "" "$test" {
+	-re "$gdb_prompt $" {
+	    pass "$test"
+	}
+    }
+}
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 3a2be9b..e3993ab 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -350,6 +350,19 @@ tui_default_win_viewport_height (enum tui_win_type type,
   return h;
 }
 
+/* Complete possible layout names.  TEXT is the complete text entered so
+   far, WORD is the word currently being completed.  */
+
+static VEC (char_ptr) *
+layout_completer (struct cmd_list_element *ignore,
+		  const char *text, const char *word)
+{
+  static const char *layout_names [] =
+    { "src", "asm", "split", "regs", "next", "prev", NULL };
+
+  return complete_on_enum (layout_names, text, word);
+}
+
 /* Function to initialize gdb commands, for tui window layout
    manipulation.  */
 
@@ -359,7 +372,9 @@ extern initialize_file_ftype _initialize_tui_layout;
 void
 _initialize_tui_layout (void)
 {
-  add_com ("layout", class_tui, tui_layout_command, _("\
+  struct cmd_list_element *cmd;
+
+  cmd = add_com ("layout", class_tui, tui_layout_command, _("\
 Change the layout of windows.\n\
 Usage: layout prev | next | <layout_name> \n\
 Layout names are:\n\
@@ -372,6 +387,7 @@ Layout names are:\n\
            source/assembly/command (split) is displayed, \n\
            the register window is displayed with \n\
            the window that has current logical focus.\n"));
+  set_cmd_completer (cmd, layout_completer);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]