This is the mail archive of the insight@sourceware.cygnus.com mailing list for the Insight project.


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

Up and Down key patch for stack window


Hi all.

I got tired of always having to use the mouse to move up and down
the stack listbox, so I created this patch for the 8/16 snapshot.
It adds support for the up and down arrow keys in the Stack window.

Mo DeJong
dejong@cs.umn.edu



1999-08-22 Mo DeJong <dejong@cs.umn.edu>
        * gdb/gdbtcl2/stackwin.ith, gdb/gdbtcl2/stackwin.itb: added Up
	  and Down key bindings to the Stack window.



diff -r -u orig_insight-19990816/gdb/gdbtcl2/stackwin.itb insight-19990816/gdb/gdbtcl2/stackwin.itb
--- orig_insight-19990816/gdb/gdbtcl2/stackwin.itb	Sun Aug 22 14:30:19 1999
+++ insight-19990816/gdb/gdbtcl2/stackwin.itb	Sun Aug 22 16:28:40 1999
@@ -56,8 +56,20 @@
   $lb configure -width $maxwidth
 
   # bind mouse button 1 to change the stack frame
-  bind $lb <ButtonPress-1> [code $this change_frame %y]
-  bind $lb <ButtonRelease-1> break
+  tixBind $lb <ButtonPress-1> [code $this change_frame %y]
+  tixBind $lb <ButtonRelease-1> break
+
+  # bind up an down buttons to move the active frame up and down
+  tixBind $lb <Key-Up>   [code $this move_frame -1]
+  tixBind $lb <Key-Down> [code $this move_frame  1]
+
+  # Do not allow double or triple click bindings for up and down keys
+  tixBind $lb <Double-Key-Up>   break
+  tixBind $lb <Double-Key-Down> break
+  tixBind $lb <Triple-Key-Up>   break
+  tixBind $lb <Triple-Key-Down> break
+
+  focus $lb
 
   pack $itk_interior.s -side left -expand yes -fill both
 
@@ -116,16 +128,48 @@
 
 # ------------------------------------------------------------------
 #  METHOD:  change_frame - change the current frame
-#        This body StackWin::is currently ONLY called from the mouse binding
+#        This method is currently ONLY called from the mouse binding
 # ------------------------------------------------------------------
 body StackWin::change_frame {y} {
   set lb [$itk_interior.s subwidget listbox]
 
   if {!$Running && [$lb size] != 0} {
     gdbtk_busy
-    set lb [$itk_interior.s subwidget listbox] 
     set linenum [$lb nearest $y]
     set size [$lb size]
+    $lb activate $linenum
+    set linenum [expr {$size - $linenum - 1}]
+    catch {gdb_cmd "frame $linenum"}
+    # Run idle hooks and cause all widgets to update
+    set protect_me 1
+    gdbtk_update
+    set protect_me 0
+    gdbtk_idle
+  }
+}
+
+# ------------------------------------------------------------------
+#  METHOD:  move_frame - move the current frame up or down
+#        This method is currently ONLY called from the key binding
+# ------------------------------------------------------------------
+body StackWin::move_frame { incr } {
+  set lb [$itk_interior.s subwidget listbox]
+
+  if {!$Running && [$lb size] != 0} {
+    gdbtk_busy
+    set linenum [$lb curselection]
+    if {$linenum == {}} {
+        # If no frame is selected, do nothing
+	return
+    }
+    incr linenum $incr
+    set size [$lb size]
+    if {($linenum < 0) || ($linenum >= $size)} {
+        # Keep using the selected line number in this case
+        set linenum [$lb curselection]
+    }
+    $lb selection clear 0 end
+    $lb selection set $linenum
     set linenum [expr {$size - $linenum - 1}]
     catch {gdb_cmd "frame $linenum"}
     # Run idle hooks and cause all widgets to update
diff -r -u orig_insight-19990816/gdb/gdbtcl2/stackwin.ith insight-19990816/gdb/gdbtcl2/stackwin.ith
--- orig_insight-19990816/gdb/gdbtcl2/stackwin.ith	Sun Aug 22 14:55:57 1999
+++ insight-19990816/gdb/gdbtcl2/stackwin.ith	Sun Aug 22 14:58:33 1999
@@ -26,6 +26,7 @@
     method build_win {}
     method cursor {glyph}
     method change_frame {y}
+    method move_frame {incr}
     method update {}
     method busy {}
     method no_inferior {}




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