aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtk.tcl
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>1996-02-07 17:44:58 +0000
committerTom Tromey <tromey@redhat.com>1996-02-07 17:44:58 +0000
commitf0b0d91597b0b939fa9a198aff33bfdd59b819af (patch)
tree9a7180f52ee5490f9b2dbdf1b77160f56f8974c3 /gdb/gdbtk.tcl
parentb0ee0cf2aafde864dc87b19b4222bd33528d8474 (diff)
downloadgdb-f0b0d91597b0b939fa9a198aff33bfdd59b819af.zip
gdb-f0b0d91597b0b939fa9a198aff33bfdd59b819af.tar.gz
gdb-f0b0d91597b0b939fa9a198aff33bfdd59b819af.tar.bz2
* gdbtk.tcl (create_file_win): Eliminate text widget B1 binding so
double-clicking will work again. (create_asm_win): Put "break" at end of all B1 bindings. (create_file_win): Lower "sel" tag, don't raise it. (ensure_line_visible): New proc. (update_listing, update_assembly): Use it. (create_copyright_window): Destroy window on Leave event. (create_command_window): Put "break" at end of all B2 bindings.
Diffstat (limited to 'gdb/gdbtk.tcl')
-rw-r--r--gdb/gdbtk.tcl63
1 files changed, 54 insertions, 9 deletions
diff --git a/gdb/gdbtk.tcl b/gdb/gdbtk.tcl
index 5ec2fb4..148517f 100644
--- a/gdb/gdbtk.tcl
+++ b/gdb/gdbtk.tcl
@@ -98,6 +98,37 @@ proc bind_widget_after_class {widget} {
bindtags $widget $newList
}
+#
+# Make sure line number $LINE is visible in the text widget. But be
+# more clever than the "see" command: if LINE is not currently
+# displayed, arrange for LINE to be centered. There are cases in
+# which this does not work, so as a last resort we revert to "see".
+#
+# This is inefficient, but probably not slow enough to actually
+# notice.
+#
+proc ensure_line_visible {text line} {
+ set pixHeight [winfo height $text]
+ # Compute height of widget in lines. This fails if a line is wider
+ # than the screen. FIXME.
+ set topLine [lindex [split [$text index @0,0] .] 0]
+ set botLine [lindex [split [$text index @0,${pixHeight}] .] 0]
+
+ if {$line > $topLine && $line < $botLine} then {
+ # Onscreen, and not on the very edge.
+ return
+ }
+
+ set newTop [expr {$line - ($botLine - $topLine)}]
+ if {$newTop < 0} then {
+ set newTop 0
+ }
+ $text yview moveto $newTop
+
+ # In case the above failed.
+ $text see ${line}.0
+}
+
if {[info exists env(EDITOR)]} then {
set editor $env(EDITOR)
} else {
@@ -1245,10 +1276,19 @@ proc create_file_win {filename debug_file} {
%W tag remove sel $last end
%W tag add sel anchor @%x,%y
}
- $win tag bind sel <1> do_nothing
- $win tag bind sel <Double-Button-1> {display_expression [selection get]}
- $win tag raise sel
+ $win tag bind sel <1> break
+ $win tag bind sel <Double-Button-1> {
+ display_expression [selection get]
+ break
+ }
+ $win tag bind sel <B1-Motion> break
+ $win tag lower sel
+ # Make these bindings do nothing on the text window -- they
+ # are completely handled by the tag bindings above.
+ bind $win <1> break
+ bind $win <B1-Motion> break
+ bind $win <Double-Button-1> break
# Scan though the breakpoint data base and install any destined for this file
@@ -1300,8 +1340,9 @@ proc create_asm_win {funcname pc} {
# Setup all the bindings
bind $win <Enter> {focus %W}
- bind $win <1> {asm_window_button_1 %W %X %Y %x %y}
- bind $win <B1-Motion> do_nothing
+ bind $win <1> {asm_window_button_1 %W %X %Y %x %y; break}
+ bind $win <B1-Motion> break
+ bind $win <Double-Button-1> break
bind $win <Key-Alt_R> do_nothing
bind $win <Key-Alt_L> do_nothing
@@ -1431,7 +1472,8 @@ proc update_listing {linespec} {
.src.scroll configure -command "$wins($cfile) yview"
- $wins($cfile) see "${line}.0 linestart"
+ # $wins($cfile) see "${line}.0 linestart"
+ ensure_line_visible $wins($cfile) $line
}
# Update the label widget in case the filename or function name has changed
@@ -1458,7 +1500,7 @@ proc update_listing {linespec} {
$wins($cfile) delete $pointer_pos "$pointer_pos + 2 char"
$wins($cfile) insert $pointer_pos "->"
- $wins($cfile) see "${line}.0 linestart"
+ ensure_line_visible $wins($cfile) $line
$wins($cfile) configure -state disabled
}
}
@@ -1837,7 +1879,7 @@ proc update_assembly {linespec} {
-after .asm.scroll
.asm.scroll configure -command "$win yview"
set line [pc_to_line $pclist($cfunc) $pc]
- $win see "${line}.0 linestart"
+ ensure_line_visible $win $line
update
}
@@ -1872,7 +1914,7 @@ proc update_assembly {linespec} {
$win delete $pointer_pos "$pointer_pos + 2 char"
$win insert $pointer_pos "->"
- $win yview "${line}.0 linestart"
+ ensure_line_visible $win $line
$win configure -state disabled
}
}
@@ -2293,6 +2335,8 @@ proc create_command_window {} {
append command_line [selection get]
break
}
+ bind .cmd.text <B2-Motion> break
+ bind .cmd.text <ButtonRelease-2> break
bind .cmd.text <Key-Tab> {
set choices [gdb_cmd "complete $command_line"]
set choices [string trimright $choices \n]
@@ -3022,6 +3066,7 @@ proc create_copyright_window {} {
pack .c.m
bind .c.m <1> {destroy .c}
+ bind .c <Leave> {destroy .c}
# "suitable period" currently means "15 seconds".
after 15000 {
if {[winfo exists .c]} then {