public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: Moses DeJong <dejong@cs.umn.edu>
To: insight@sourceware.cygnus.com
Subject: Up and Down key patch for stack window
Date: Sun, 22 Aug 1999 14:52:00 -0000	[thread overview]
Message-ID: <Pine.GSO.4.05.9908221641500.1205-100000@brin.cs.umn.edu> (raw)

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 {}



                 reply	other threads:[~1999-08-22 14:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.05.9908221641500.1205-100000@brin.cs.umn.edu \
    --to=dejong@cs.umn.edu \
    --cc=insight@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).