From b49bb082d82a6be969be89a0169401c7cc64ab2f Mon Sep 17 00:00:00 2001 From: kseitz Date: Tue, 22 May 2001 18:24:17 +0000 Subject: [PATCH] * library/interface.tcl (gdbtk_tcl_file_changed): Handle the case of empty-string files, sent by gdb when the user requests to reset the file. (_close_file): New proc to deal with closing an exe. * library/srcbar.itcl (create_file_menu): Add "Close" menu option. (create_view_menu): Change key binding for Watch Window to Ctrl+T to accomodate "Close" going to Ctrl+W. * library/srctextwin.itb (config_win): Update key binding for Watch Window. Add key binding for Close. (do_key): Add "close". (_clear_cache): Finally implement. I think this works now. --- gdb/gdbtk/ChangeLog | 16 +++++++++++++++ gdb/gdbtk/library/interface.tcl | 43 ++++++++++++++++++++++++++++++++++++++-- gdb/gdbtk/library/srcbar.itcl | 5 ++++- gdb/gdbtk/library/srctextwin.itb | 25 +++++++++++++++-------- 4 files changed, 78 insertions(+), 11 deletions(-) diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog index cf0eee7fac..d09a0af42a 100644 --- a/gdb/gdbtk/ChangeLog +++ b/gdb/gdbtk/ChangeLog @@ -1,5 +1,21 @@ 2001-05-22 Keith Seitz + * library/interface.tcl (gdbtk_tcl_file_changed): Handle + the case of empty-string files, sent by gdb when the + user requests to reset the file. + (_close_file): New proc to deal with closing an exe. + * library/srcbar.itcl (create_file_menu): Add "Close" menu + option. + (create_view_menu): Change key binding for Watch Window to + Ctrl+T to accomodate "Close" going to Ctrl+W. + * library/srctextwin.itb (config_win): Update key binding + for Watch Window. + Add key binding for Close. + (do_key): Add "close". + (_clear_cache): Finally implement. I think this works now. + +2001-05-22 Keith Seitz + * library/variables.tcl (postMenu): Add mysterious workaround for popup menu bug in Tk for windows. Highlight the selection, too. diff --git a/gdb/gdbtk/library/interface.tcl b/gdb/gdbtk/library/interface.tcl index 4e508a615a..ca046e86dc 100644 --- a/gdb/gdbtk/library/interface.tcl +++ b/gdb/gdbtk/library/interface.tcl @@ -705,8 +705,17 @@ proc gdbtk_tcl_post_add_symbol {} { # ------------------------------------------------------------------ proc gdbtk_tcl_file_changed {filename} { - SrcWin::point_to_main - run_hooks file_changed_hook + if {$filename == ""} { + gdb_clear_file + run_hooks gdb_clear_file_hook + set ::gdb_exe_name "" + set ::gdb_loaded 0 + set ::gdb_running 0 + gdbtk_update + } else { + SrcWin::point_to_main + run_hooks file_changed_hook + } } # ------------------------------------------------------------------ @@ -916,6 +925,36 @@ proc _open_file {{file ""}} { } # ------------------------------------------------------------------ +# _close_file - close the current executable and prepare for +# another executable. +# ------------------------------------------------------------------ +proc _close_file {} { + + # If there is already an inferior, ask him if he wants to close + # the file. If there is already an exec file loaded (and not run) + # also ask, but don't ask twice. + set okay 1 + if {[gdb_target_has_execution]} { + set okay [gdbtk_tcl_query "Program is already running.\nClose file anyway?"] + } elseif {$::gdb_exe_name != ""} { + set okay [gdbtk_tcl_query "Program already loaded.\nClose file anyway?"] + } else { + # No exec file yet + return + } + + if {$okay} { + gdb_clear_file + gdbtk_tcl_file_changed "" + + # Print out a little message to all console windows + foreach cw [ManagedWin::find Console] { + $cw insert "No executable file now.\n" + } + } +} + +# ------------------------------------------------------------------ # PROC: set_target_name - Update the target name. # # This function will prompt for a new target and update diff --git a/gdb/gdbtk/library/srcbar.itcl b/gdb/gdbtk/library/srcbar.itcl index 880a31ba6c..337ef14231 100644 --- a/gdb/gdbtk/library/srcbar.itcl +++ b/gdb/gdbtk/library/srcbar.itcl @@ -139,6 +139,9 @@ class SrcBar { $Menu add command Other "Open..." \ "_open_file" -underline 0 -accelerator "Ctrl+O" + $Menu add command Other "Close" \ + "_close_file" -underline 0 -accelerator "Ctrl+W" + $Menu add command Other "Source..." \ "source_file" -underline 0 @@ -266,7 +269,7 @@ class SrcBar { $Menu add command Other "Watch Expressions" \ {ManagedWin::open WatchWin} \ - -underline 0 -accelerator "Ctrl+W" + -underline 0 -accelerator "Ctrl+T" $Menu add command Other "Local Variables" \ {ManagedWin::open LocalsWin} \ -underline 0 -accelerator "Ctrl+L" diff --git a/gdb/gdbtk/library/srctextwin.itb b/gdb/gdbtk/library/srctextwin.itb index 8f04181212..857dc86351 100644 --- a/gdb/gdbtk/library/srctextwin.itb +++ b/gdb/gdbtk/library/srctextwin.itb @@ -595,7 +595,8 @@ body SrcTextWin::config_win {win {asm S}} { bind_plain_key $win Control-u "$this do_key debug; break" bind_plain_key $win Control-o [list $this do_key open] bind_plain_key $win Control-a [list $this do_key attach] - + bind_plain_key $win Control-w [code $this do_key close] + if {!$Browsing && [pref get gdb/control_target]} { # Ctrl+F5 is another accelerator for Run bind_plain_key $win Control-F5 "$this do_key run" @@ -654,7 +655,7 @@ body SrcTextWin::config_win {win {asm S}} { bind_plain_key $win Control-s "$this do_key stack" bind_plain_key $win Control-r "$this do_key registers" bind_plain_key $win Control-m "$this do_key memory" - bind_plain_key $win Control-w "$this do_key watch" + bind_plain_key $win Control-t "$this do_key watch" bind_plain_key $win Control-l "$this do_key locals" bind_plain_key $win Control-k "$this do_key kod" if { !$Tracing } { @@ -2185,6 +2186,7 @@ body SrcTextWin::do_key {key} { tfind_line { catch {gdb_immediate "tfind line"} } tfind_tp { catch {gdb_immediate "tfind tracepoint"} } open { catch {_open_file} } + close { catch {_close_file} } browser { catch {ManagedWin::open BrowserWin} } thread_list { catch {ManagedWin::open ProcessWin} } debug { catch {ManagedWin::open DebugWin} } @@ -2921,9 +2923,6 @@ body SrcTextWin::_initialize_srctextwin {} { # METHOD: _clear_cache - Clear the cache # ------------------------------------------------------------------ body SrcTextWin::_clear_cache {} { - # This doesn't work, and it's so darn entangled that it's nearly - # impossible. - return # display empty scratch frame set pane $Stwc(gdbtk_scratch_widget:pane) @@ -2935,9 +2934,19 @@ body SrcTextWin::_clear_cache {} { foreach p [array names Stwc *:pane] { set p [lindex [split $p :] 0] if {$p != "gdbtk_scratch_widget"} { - catch {$itk_interior.p delete $Stwc($p:pane)} - unset Stwc($p:pane) - unset Stwc($p:mtime) + catch { + #debug "clearing cache: \"$p\"" + $itk_interior.p delete $Stwc($p:pane) + unset Stwc($p:pane) + unset Stwc($p:mtime) + } } } + + _initialize_srctextwin + set filenum 0 + set Cname "" + set _tpane pane$filenum + incr filenum + set _bpane "" } -- 2.11.0