public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Patch: view menu -vs- multiple source windows
@ 2000-12-06 15:56 Tom Tromey
  2000-12-06 20:25 ` Syd Polk
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2000-12-06 15:56 UTC (permalink / raw)
  To: Insight List

This patch adds support for multiple source windows to the View menu.
It requires my earlier multiple source window patch (not yet
approved).

The idea here is that each available source window is listed on the
view menu.  Also, an "Open Another Source Window" command is added to
the view menu.

2000-12-06  Tom Tromey  <tromey@redhat.com>

	* toolbar.tcl (create_view_menu): Call _post_menu before View menu
	is posted.  Added command to open another source window.
	(_post_menu): New method.

Tom

Index: toolbar.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/toolbar.tcl,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 toolbar.tcl
--- toolbar.tcl	2000/02/07 00:19:42	1.1.1.1
+++ toolbar.tcl	2000/12/06 23:53:57
@@ -605,7 +605,8 @@
   # ------------------------------------------------------------------
   
   method create_view_menu {} {
-    new_menu view "View" 0
+    set vmenu [new_menu view "View" 0]
+    $vmenu configure -postcommand [code $this _post_menu $vmenu]
 
     add_menu_command Other "Stack" {ManagedWin::open StackWin} \
       -underline 0 -accelerator "Ctrl+S" 
@@ -638,7 +639,7 @@
 
     add_menu_command Other "Console" {ManagedWin::open Console} \
       -underline 2 -accelerator "Ctrl+N" 
-      
+
     add_menu_command Other "Function Browser" {ManagedWin::open BrowserWin} \
       -underline 1 -accelerator "Ctrl+F" 
     add_menu_command Other "Thread List" {ManagedWin::open ProcessWin} \
@@ -648,6 +649,17 @@
       add_menu_command Other "Debug Window" {ManagedWin::open DebugWin} \
 	-underline 3 -accelerator "Ctrl+U"
     }
+
+    # Note that the layout from here down is relied on in _post_menu.
+    add_menu_separator
+    # This is a dummy entry that will be overwritten when the menu is
+    # posted for the first time.
+    add_menu_command Other "Source Window" \
+      {ManagedWin::open SrcWin}
+
+    add_menu_separator
+    add_menu_command Other "Open Another Source Window" \
+      {ManagedWin::open SrcWin -force} -underline 0
   }
 
   # ------------------------------------------------------------------
@@ -771,6 +783,43 @@
 
       global gdb_kod_cmd
       set gdb_kod_cmd $value
+    }
+  }
+
+  # ------------------------------------------------------------------
+  #  METHOD:  _post_menu - Called when View menu posted
+  # ------------------------------------------------------------------  
+  method _post_menu {menu} {
+    # We search from the bottom of the window.  Source window entries
+    # appear between the last two separators.
+    set index [$menu index end]
+    set firstSep -1
+    set lastSep -1
+    while {$index >= 0} {
+      if {[$menu type $index] == "separator"} {
+	if {$lastSep == -1} {
+	  set lastSep [expr {$index - 1}]
+	} else {
+	  set firstSep [expr {$index + 1}]
+	  break
+	}
+      }
+      incr index -1
+    }
+
+    if {$index == -1} {
+      error "programming error in _post_menu"
+    }
+
+    $menu delete $firstSep $lastSep
+    foreach src [ManagedWin::find SrcWin] {
+      set file [$src get_file]
+      if {$file == ""} {
+	set file "Source Window"
+      }
+      $menu insert $firstSep command -label $file \
+	-command [list $src reveal]
+      incr firstSep
     }
   }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: view menu -vs- multiple source windows
  2000-12-06 15:56 Patch: view menu -vs- multiple source windows Tom Tromey
@ 2000-12-06 20:25 ` Syd Polk
  2000-12-06 23:37   ` Fernando Nasser
  2000-12-07 12:07   ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Syd Polk @ 2000-12-06 20:25 UTC (permalink / raw)
  To: tromey; +Cc: Insight List

I still think we need to use

	if {[string compare $foo $bar] == 0} {

rather than

	if {$foo == $bar} {

The reason is that if foo or bar start with "0" or "0x" they will be
converted to integers during the compare, which can generate incorrect
results.

However, if the rest of gdbtk does this, then I am fine. This is a
really cool feature. Thanks, Tom.

Tom Tromey wrote:
> 
> This patch adds support for multiple source windows to the View menu.
> It requires my earlier multiple source window patch (not yet
> approved).
> 
> The idea here is that each available source window is listed on the
> view menu.  Also, an "Open Another Source Window" command is added to
> the view menu.
> 
> 2000-12-06  Tom Tromey  <tromey@redhat.com>
> 
>         * toolbar.tcl (create_view_menu): Call _post_menu before View menu
>         is posted.  Added command to open another source window.
>         (_post_menu): New method.
> 
> Tom
> 
> Index: toolbar.tcl
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtk/library/toolbar.tcl,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 toolbar.tcl
> --- toolbar.tcl 2000/02/07 00:19:42     1.1.1.1
> +++ toolbar.tcl 2000/12/06 23:53:57
> @@ -605,7 +605,8 @@
>    # ------------------------------------------------------------------
> 
>    method create_view_menu {} {
> -    new_menu view "View" 0
> +    set vmenu [new_menu view "View" 0]
> +    $vmenu configure -postcommand [code $this _post_menu $vmenu]
> 
>      add_menu_command Other "Stack" {ManagedWin::open StackWin} \
>        -underline 0 -accelerator "Ctrl+S"
> @@ -638,7 +639,7 @@
> 
>      add_menu_command Other "Console" {ManagedWin::open Console} \
>        -underline 2 -accelerator "Ctrl+N"
> -
> +
>      add_menu_command Other "Function Browser" {ManagedWin::open BrowserWin} \
>        -underline 1 -accelerator "Ctrl+F"
>      add_menu_command Other "Thread List" {ManagedWin::open ProcessWin} \
> @@ -648,6 +649,17 @@
>        add_menu_command Other "Debug Window" {ManagedWin::open DebugWin} \
>         -underline 3 -accelerator "Ctrl+U"
>      }
> +
> +    # Note that the layout from here down is relied on in _post_menu.
> +    add_menu_separator
> +    # This is a dummy entry that will be overwritten when the menu is
> +    # posted for the first time.
> +    add_menu_command Other "Source Window" \
> +      {ManagedWin::open SrcWin}
> +
> +    add_menu_separator
> +    add_menu_command Other "Open Another Source Window" \
> +      {ManagedWin::open SrcWin -force} -underline 0
>    }
> 
>    # ------------------------------------------------------------------
> @@ -771,6 +783,43 @@
> 
>        global gdb_kod_cmd
>        set gdb_kod_cmd $value
> +    }
> +  }
> +
> +  # ------------------------------------------------------------------
> +  #  METHOD:  _post_menu - Called when View menu posted
> +  # ------------------------------------------------------------------
> +  method _post_menu {menu} {
> +    # We search from the bottom of the window.  Source window entries
> +    # appear between the last two separators.
> +    set index [$menu index end]
> +    set firstSep -1
> +    set lastSep -1
> +    while {$index >= 0} {
> +      if {[$menu type $index] == "separator"} {
> +       if {$lastSep == -1} {
> +         set lastSep [expr {$index - 1}]
> +       } else {
> +         set firstSep [expr {$index + 1}]
> +         break
> +       }
> +      }
> +      incr index -1
> +    }
> +
> +    if {$index == -1} {
> +      error "programming error in _post_menu"
> +    }
> +
> +    $menu delete $firstSep $lastSep
> +    foreach src [ManagedWin::find SrcWin] {
> +      set file [$src get_file]
> +      if {$file == ""} {
> +       set file "Source Window"
> +      }
> +      $menu insert $firstSep command -label $file \
> +       -command [list $src reveal]
> +      incr firstSep
>      }
>    }
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: view menu -vs- multiple source windows
  2000-12-06 20:25 ` Syd Polk
@ 2000-12-06 23:37   ` Fernando Nasser
  2000-12-07  8:38     ` Tom Tromey
  2000-12-07 12:07   ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: Fernando Nasser @ 2000-12-06 23:37 UTC (permalink / raw)
  To: Syd Polk; +Cc: tromey, Insight List

Unfortunately this change applies to an obsolete code.

Tom was not around when we were talking about some code restructuring
and I was not aware he was going to change anything in there.

I will try to incorporate this feature in the new code, but it may not
be in the first version.

Sorry,
Fernando





Syd Polk wrote:
> 
> I still think we need to use
> 
>         if {[string compare $foo $bar] == 0} {
> 
> rather than
> 
>         if {$foo == $bar} {
> 
> The reason is that if foo or bar start with "0" or "0x" they will be
> converted to integers during the compare, which can generate incorrect
> results.
> 
> However, if the rest of gdbtk does this, then I am fine. This is a
> really cool feature. Thanks, Tom.
> 
> Tom Tromey wrote:
> >
> > This patch adds support for multiple source windows to the View menu.
> > It requires my earlier multiple source window patch (not yet
> > approved).
> >
> > The idea here is that each available source window is listed on the
> > view menu.  Also, an "Open Another Source Window" command is added to
> > the view menu.
> >
> > 2000-12-06  Tom Tromey  <tromey@redhat.com>
> >
> >         * toolbar.tcl (create_view_menu): Call _post_menu before View menu
> >         is posted.  Added command to open another source window.
> >         (_post_menu): New method.
> >
> > Tom
> >
> > Index: toolbar.tcl
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/gdbtk/library/toolbar.tcl,v
> > retrieving revision 1.1.1.1
> > diff -u -r1.1.1.1 toolbar.tcl
> > --- toolbar.tcl 2000/02/07 00:19:42     1.1.1.1
> > +++ toolbar.tcl 2000/12/06 23:53:57
> > @@ -605,7 +605,8 @@
> >    # ------------------------------------------------------------------
> >
> >    method create_view_menu {} {
> > -    new_menu view "View" 0
> > +    set vmenu [new_menu view "View" 0]
> > +    $vmenu configure -postcommand [code $this _post_menu $vmenu]
> >
> >      add_menu_command Other "Stack" {ManagedWin::open StackWin} \
> >        -underline 0 -accelerator "Ctrl+S"
> > @@ -638,7 +639,7 @@
> >
> >      add_menu_command Other "Console" {ManagedWin::open Console} \
> >        -underline 2 -accelerator "Ctrl+N"
> > -
> > +
> >      add_menu_command Other "Function Browser" {ManagedWin::open BrowserWin} \
> >        -underline 1 -accelerator "Ctrl+F"
> >      add_menu_command Other "Thread List" {ManagedWin::open ProcessWin} \
> > @@ -648,6 +649,17 @@
> >        add_menu_command Other "Debug Window" {ManagedWin::open DebugWin} \
> >         -underline 3 -accelerator "Ctrl+U"
> >      }
> > +
> > +    # Note that the layout from here down is relied on in _post_menu.
> > +    add_menu_separator
> > +    # This is a dummy entry that will be overwritten when the menu is
> > +    # posted for the first time.
> > +    add_menu_command Other "Source Window" \
> > +      {ManagedWin::open SrcWin}
> > +
> > +    add_menu_separator
> > +    add_menu_command Other "Open Another Source Window" \
> > +      {ManagedWin::open SrcWin -force} -underline 0
> >    }
> >
> >    # ------------------------------------------------------------------
> > @@ -771,6 +783,43 @@
> >
> >        global gdb_kod_cmd
> >        set gdb_kod_cmd $value
> > +    }
> > +  }
> > +
> > +  # ------------------------------------------------------------------
> > +  #  METHOD:  _post_menu - Called when View menu posted
> > +  # ------------------------------------------------------------------
> > +  method _post_menu {menu} {
> > +    # We search from the bottom of the window.  Source window entries
> > +    # appear between the last two separators.
> > +    set index [$menu index end]
> > +    set firstSep -1
> > +    set lastSep -1
> > +    while {$index >= 0} {
> > +      if {[$menu type $index] == "separator"} {
> > +       if {$lastSep == -1} {
> > +         set lastSep [expr {$index - 1}]
> > +       } else {
> > +         set firstSep [expr {$index + 1}]
> > +         break
> > +       }
> > +      }
> > +      incr index -1
> > +    }
> > +
> > +    if {$index == -1} {
> > +      error "programming error in _post_menu"
> > +    }
> > +
> > +    $menu delete $firstSep $lastSep
> > +    foreach src [ManagedWin::find SrcWin] {
> > +      set file [$src get_file]
> > +      if {$file == ""} {
> > +       set file "Source Window"
> > +      }
> > +      $menu insert $firstSep command -label $file \
> > +       -command [list $src reveal]
> > +      incr firstSep
> >      }
> >    }
> >

-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: view menu -vs- multiple source windows
  2000-12-06 23:37   ` Fernando Nasser
@ 2000-12-07  8:38     ` Tom Tromey
  2000-12-07  9:03       ` Fernando Nasser
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2000-12-07  8:38 UTC (permalink / raw)
  To: Fernando Nasser; +Cc: Syd Polk, Insight List

Fernando> I will try to incorporate this feature in the new code, but
Fernando> it may not be in the first version.

Are you saying I should just delete my patch or that I should check it
in?

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: view menu -vs- multiple source windows
  2000-12-07  8:38     ` Tom Tromey
@ 2000-12-07  9:03       ` Fernando Nasser
  0 siblings, 0 replies; 6+ messages in thread
From: Fernando Nasser @ 2000-12-07  9:03 UTC (permalink / raw)
  To: tromey; +Cc: Syd Polk, Insight List

Tom Tromey wrote:
> 
> Fernando> I will try to incorporate this feature in the new code, but
> Fernando> it may not be in the first version.
> 
> Are you saying I should just delete my patch or that I should check it
> in?
> 

Neither. :-) 

Don't check the View Menu changes in at this time though. 
I am not sure when I will be able to integrate it and I prefer 
not adding a feature and them removing it, even if for some relatively
short period of time.

But we have your patch so we can adapt it for the new code.
I will take care of adapting it as soon as I can (early next year I hope).

Maybe the better place to store it would be in the Gnats database.
It is supposed to work both as a bug report/enhancement request and as
a patch repository (this is also true for GDB).

I believe the fixes/enhancements you did to allow using the multiple
source windows (through the existing option on right-click)
are already a nice thing per se.


-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Patch: view menu -vs- multiple source windows
  2000-12-06 20:25 ` Syd Polk
  2000-12-06 23:37   ` Fernando Nasser
@ 2000-12-07 12:07   ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2000-12-07 12:07 UTC (permalink / raw)
  To: Syd Polk; +Cc: Insight List

>>>>> "Syd" == Syd Polk <spolk@redhat.com> writes:

Syd> I still think we need to use
Syd> 	if {[string compare $foo $bar] == 0} {
Syd> rather than
Syd> 	if {$foo == $bar} {

I made this change in the one place in my patch where it matters.

I'm going to put the revised patch into gnats per Fernando's request.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-12-07 12:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-06 15:56 Patch: view menu -vs- multiple source windows Tom Tromey
2000-12-06 20:25 ` Syd Polk
2000-12-06 23:37   ` Fernando Nasser
2000-12-07  8:38     ` Tom Tromey
2000-12-07  9:03       ` Fernando Nasser
2000-12-07 12:07   ` Tom Tromey

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).