The Perl debugger will not run on a 19,000 line program for a specialized text editor that I am trying to refactor. I believe the program occurs when one custom widget delegates to another custom subwidget. The first widget is called TextUnicode based on TextEdit with special methods to handle Unicode files. The second is called LineNumberText based on ROText to provide line numbers down the right hand side of the screen. Does this diagnosis sound correct and is there a simple fix I could use? Or do I need to combine these two widgets into one to avoid teh double delegation issue? The code can be found here:http://guiguts.svn.sourceforge.net/viewvc/guiguts/branches/devel/lib/Guiguts/. Here is the beginning of the two widgets:
package TextUnicode; use base qw(Tk::TextEdit); use File::Temp qw/tempfile/; use File::Basename; Construct Tk::Widget 'TextUnicode'; sub Load {... sub SaveUTF {... ---------------------------- package Guiguts::LineNumberText; use Tk; use Tk::widgets qw(ROText); use base qw(Tk::Frame); Construct Tk::Widget 'LineNumberText'; sub Populate { my ( $self, $args ) = @_; $self->SUPER::Populate($args); $self->{'minwidth'} = 5; $self->{'linenumshowing'} = 0; my $widget; if ( $widget = delete $args->{-widget} ) { $widget = 'TextUnicode'; } else { $widget = 'Text'; } my $ltext = $self->ROText( -takefocus => 0, -cursor => 'X_cursor', -bd => 2, -relief => 'flat', -width => $self->{'minwidth'}, -wrap => 'none', ); $ltext->{_MENU_} = (); $self->{'ltext'} = $ltext; $ltext->tagConfigure( 'CURLINE', -data => 1 ); $ltext->tagConfigure( 'RIGHT', -justify => 'right' ); my $ftext = $self->Scrolled($widget) ->grid( -row => 0, -column => 1, -sticky => 'nsew' ); $self->{'rtext'} = my $rtext = $ftext->Subwidget('scrolled'); $self->gridColumnconfigure( 1, -weight => 1 ); $self->gridRowconfigure( 0, -weight => 1 ); $self->Advertise( 'yscrollbar', $ftext->Subwidget('yscrollbar') ); $self->Advertise( 'xscrollbar', $ftext->Subwidget('xscrollbar') ); $self->Advertise( 'corner', $ftext->Subwidget('corner') ); $self->Advertise( 'frame', $ftext ); $self->Advertise( 'scrolled', $rtext ); $self->Advertise( 'text', $rtext ); $self->Advertise( 'linenum', $ltext ); # Set scrolling command to run the lineupdate.. my $yscroll = $self->Subwidget('yscrollbar'); my $scrollcommand = $yscroll->cget( -command ); $yscroll->configure( -command => sub { $scrollcommand->Call(@_); $self->_lineupdate; } ); $self->ConfigSpecs( -linenumside => [ 'METHOD', undef, undef, 'left' ] +, -linenumbg => [ 'METHOD', 'numlinebg', 'numLinebg', '#eaeaea +' ], -linenumfg => [ 'METHOD', 'numlinefg', 'numLinefg', '#000000 +' ], -curlinehighlight => [ 'PASSIVE', undef, undef, 1 ], -curlinebg => [ 'METHOD', undef, undef, '#00ffff' ], -curlinefg => [ 'METHOD', undef, undef, '#000000' ], -background => [ $ftext, undef, undef, undef ], -foreground => [ $ftext, undef, undef, undef ], -scrollbars => [ $ftext, undef, undef, 'se' ], -font => ['CHILDREN'], -spacing1 => ['CHILDREN'], -spacing2 => ['CHILDREN'], -spacing3 => ['CHILDREN'], 'DEFAULT' => [$rtext], ); $self->Delegates( 'DEFAULT' => 'scrolled' ); #Bindings $ltext->bind( '<FocusIn>', sub { $rtext->focus } ); $ltext->bind( '<Map>', sub { $self->_lineupdate } ); $rtext->bind( '<Configure>', sub { $self->_lineupdate } ); $rtext->bind( '<KeyPress>', sub { $self->_lineupdate } ); $rtext->bind( '<ButtonPress>', sub { $self->{'rtext'}->{'origx'} = undef; $self->_lineupdate; } ); $rtext->bind( '<Return>', sub { $self->_lineupdate } ); $rtext->bind( '<ButtonRelease-2>', sub { $self->_lineupdate } ); $rtext->bind( '<B2-Motion>', sub { $self->_lineupdate } ); $rtext->bind( '<B1-Motion>', sub { $self->_lineupdate } ); $rtext->bind( '<<autoscroll>>', sub { $self->_lineupdate } ); $rtext->bind( '<MouseWheel>', sub { $self->_lineupdate } ); if ( $Tk::platform eq 'unix' ) { $rtext->bind( '<4>', sub { $self->_lineupdate } ); $rtext->bind( '<5>', sub { $self->_lineupdate } ); } my @textMethods = qw/insert delete Delete deleteBefore Contents deleteSelected deleteTextTaggedwith deleteToEndofLine FindAndReplaceAll GotoL +ineNumber Insert InsertKeypress InsertSelection insertTab openLine yview + ReplaceSelectionsWith Transpose see/; if ( ref($rtext) eq 'TextUnicode' ) { push( @textMethods, 'Load', 'SaveUTF', 'IncludeFile', 'ntinsert', 'ntdelete', 'replacewith' ); } for my $method (@textMethods) { no strict 'refs'; *{$method} = sub { my $cw = shift; my @arr = $cw->{'rtext'}->$method(@_); $cw->_lineupdate; @arr; }; } } # end Populate

In reply to Perl Debugger with Two Customs Tk Widgets by hmonroe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.