diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8568809cbf..1fd873150a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -15,6 +15,19 @@ Tue Feb 6 18:38:51 1996 J.T. Conklin * nindy-share/nindy.c (say): Use stdarg.h macros when compiling with an ANSI compiler. +start-sanitize-gdbtk +Tue Feb 6 16:31:25 1996 Tom Tromey + + * 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. + +end-sanitize-gdbtk Mon Feb 5 18:24:28 1996 Steve Chamberlain From Michael_Snyder@NeXT.COM (Michael Snyder): diff --git a/gdb/gdbtk.tcl b/gdb/gdbtk.tcl index 5ec2fb4837..148517f4f6 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 {display_expression [selection get]} - $win tag raise sel + $win tag bind sel <1> break + $win tag bind sel { + display_expression [selection get] + break + } + $win tag bind sel 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 break + bind $win 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 {focus %W} - bind $win <1> {asm_window_button_1 %W %X %Y %x %y} - bind $win do_nothing + bind $win <1> {asm_window_button_1 %W %X %Y %x %y; break} + bind $win break + bind $win break bind $win do_nothing bind $win 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 break + bind .cmd.text break bind .cmd.text { 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 {destroy .c} # "suitable period" currently means "15 seconds". after 15000 { if {[winfo exists .c]} then {