Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^5: Debugging a program

by hexcoder (Curate)
on Feb 20, 2019 at 12:48 UTC ( [id://1230241]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Debugging a program
in thread Debugging a program

With Strawberry Perl 5.26.2 (Windows 7) I got some complaints about unknown terminal window size when starting the debugger.
Unable to get Terminal Size. The Win32 GetConsoleScreenBufferInfo call + didn't work. The COLUMNS and LINES environment variables didn't work +. at C:/Strawberry/perl/vendor/lib/Term/ReadLine/readline.pm line 410 +.

These lines in sub afterinit take care of it:
my ($cols, $lines) = split ' ', (grep { m{^\s*\d+\s+\d+\s}xms } `p +owershell -command "&{\$H=get-host;\$H.ui.rawui.WindowSize;}"`)[0]; $ENV{'COLUMNS'} = $cols; $ENV{'LINES'} = $lines; print "COLUMNS and LINES are set ($cols,$lines).\n";

Powershell is used here to get the console property WindowSize. Then the environment variables COLUMNS and LINES are locally set and the readline.pm module is happy.

Replies are listed 'Best First'.
Re^6: Debugging a program
by jdporter (Paladin) on Feb 20, 2019 at 17:24 UTC

    Sweet!

    I'd prob do it this way:

    my( $cols, $lines ) = qx( powershell -command "&{ \$H=get-host; \$H.ui +.rawui.WindowSize.Width; \$H.ui.rawui.WindowSize.Height; }" ) =~ /(\d ++)/g;
    I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
Re^6: Debugging a program with Tk
by hexcoder (Curate) on Sep 19, 2019 at 09:08 UTC
    When using Tk, I observed that my custom debugging signal handler for $SIG{__WARN__} is overwritten by Tk :(.
    So I needed to reoverwrite it after use Tk; with my own one again.

    use Tk; ... # if running with debugger, reinstall signal handler if (defined $DB::single) { # avoid warning: '$DB::single' is only used once $DB::single = $DB::single; DB::afterinit(); }
    Unfortunately this requires modification of the script.

    Any suggestions for enhancements are welcome.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1230241]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-28 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found