OSDN Git Service

* library/console.itb (Console::_operate_and_get_next): New method.
authorTom Tromey <tromey@redhat.com>
Fri, 28 Sep 2001 16:36:50 +0000 (16:36 +0000)
committerTom Tromey <tromey@redhat.com>
Fri, 28 Sep 2001 16:36:50 +0000 (16:36 +0000)
(Console::_setprompt): Insert next history element if requested.
(Console::_build_win): Bind C-o to _operate_and_get_next.
* library/console.ith (_operate_and_get_next): Declare.
(_pendingHistElement): New variable.

gdb/gdbtk/ChangeLog
gdb/gdbtk/library/console.itb
gdb/gdbtk/library/console.ith

index a8b5d7b..5fedca7 100644 (file)
@@ -1,3 +1,11 @@
+2001-09-28  Tom Tromey  <tromey@redhat.com>
+
+       * library/console.itb (Console::_operate_and_get_next): New method.
+       (Console::_setprompt): Insert next history element if requested.
+       (Console::_build_win): Bind C-o to _operate_and_get_next.
+       * library/console.ith (_operate_and_get_next): Declare.
+       (_pendingHistElement): New variable.
+
 2001-09-27  Elena Zannoni  <ezannoni@redhat.com>
 
        * library/targetselection.itb (build_win, default_port): Handle
index e6a89f5..8c2db2a 100644 (file)
@@ -65,9 +65,6 @@ body Console::_build_win {} {
   #
   bind $_twin <Return> "$this invoke; break"
 
-  # disable this
-  bind_plain_key $_twin Control-o "break"
-
   # History control.
   bind_plain_key $_twin Control-p "[code $this _previous]; break"
   bind $_twin <Up> "[code $this _previous]; break"
@@ -77,7 +74,8 @@ body Console::_build_win {} {
   bind $_twin <Home> "[code $this _first]; break"
   bind $_twin <Meta-greater> "[code $this _last]; break"
   bind $_twin <End> "[code $this _last]; break"
-  
+  bind_plain_key $_twin Control-o "[code $this _operate_and_get_next]; break"
+
   # Tab completion
   bind_plain_key $_twin KeyPress-Tab "[code $this _complete]; break"
   
@@ -243,6 +241,25 @@ body Console::einsert {line tag} {
   set _needNL 0
 }
 
+# ------------------------------------------------------------------
+#  NAME:         ConsoleWin::_operate_and_get_next
+#  DESCRIPTION:  Invokes the current command and, if this
+#                command came from the history, arrange for
+#                the next history command to be inserted once this
+#                command is finished.
+#
+#  ARGUMENTS:    None
+#  RETURNS:      Nothing
+# ------------------------------------------------------------------
+body Console::_operate_and_get_next {} {
+  if {$_histElement >= 0} {
+    # _pendingHistElement will be used after the new history element
+    # is pushed.  So we must increment it.
+    set _pendingHistElement [expr {$_histElement + 1}]
+  }
+  invoke
+}
+
 #-------------------------------------------------------------------
 #  METHOD:  _previous - recall the previous command
 # ------------------------------------------------------------------
@@ -368,6 +385,12 @@ body Console::_setprompt {{prompt {}}} {
   $_twin insert {insert linestart} $prompt prompt_tag
   $_twin mark set cmdmark "insert -1 char"
   $_twin see insert
+
+  if {$_pendingHistElement >= 0} {
+    set _histElement $_pendingHistElement
+    set _pendingHistElement -1
+    _next
+  }
 }
 
 #-------------------------------------------------------------------
index 4a361a7..cf4711b 100644 (file)
@@ -50,6 +50,7 @@ class Console {
     variable _saved_insertion ""
     variable _running 0
     variable _saw_tab 0
+    variable _pendingHistElement -1
 
     method _build_win {}
     method _complete {}
@@ -59,6 +60,7 @@ class Console {
     method _first {}
     method _last {}
     method _next {}
+    method _operate_and_get_next {}
     method _paste {{check_primary 1}}
     method _previous {}
     method _reset_tab {}