Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: PerlMonks Editor

by parv (Parson)
on Dec 01, 2006 at 07:09 UTC ( [id://587137]=note: print w/replies, xml ) Need Help??


in reply to Re^3: PerlMonks Editor
in thread PerlMonks Editor

Hey, happy to help. But my helping you is not done yet. ;}

Program stops after printing "bad event type" message .. .

bad event type or keysym "_" at PMEdit-001.000202-1.pl line 269, <DATA +> line 81.
... but that goes away (and a Tk window emerges) if I change _ to one of [a-zA-Z0-9] but not [-+].

Other minor problems ... (1) chomp fails to clear ^M in __DATA__ ...

1057 sub LoadConfig { 1058 my $ok = 1; 1059 1060 while (<DATA>) { 1061 # Load the default configuration stuff 1062 chomp; 1063 next if ! length; ... 1067 my ($tag, $htmlTag, $name, $flagsField, @options) = split + /\s*,\s*/; 1068 1069 if (! defined $flagsField) { 1070 print "Missing entries in tag line ($.): $_"; ...
... which causes above print() to act; line numbers reported are 32 & 58.

(2) Later in LoadConfig(), chomp() is rendered useless by use of s/\s+$//; ...

1136 while (<DATA>) { 1137 # Load key binding information 1138 next if /^#/; 1139 1140 chomp; 1141 s/^\s+//; 1142 s/\s+$//;
In both cases, I suggest just use s/\s+$// & chop the chomp().

(3) There seems to spurious tab characters on lines 228, 769, 771-772, 774-775.

diff -u output follows ...

--- PMEdit-001.000202-1.pl--ORIG Fri Dec 1 00:57:17 2006 +++ PMEdit-001.000202-1.pl Fri Dec 1 02:44:20 2006 @@ -225,7 +225,7 @@ my %commands = ( selAll => \&do_selAll, copy => \&do_copy, - paste => \&do_paste, + paste => \&do_paste, ); my $realText = $text->Subwidget ('scrolled'); @@ -766,13 +766,13 @@ sub about { my $versions = ''; for (@usedModules) { - my $name = $_->[1]; + my $name = $_->[1]; - $name =~ s/\..*//; - $name =~ s|[\\/]|::|g; + $name =~ s/\..*//; + $name =~ s|[\\/]|::|g; - my $version = $name->VERSION; - $versions .= "$name \t$version\n" if defined $version; + my $version = $name->VERSION; + $versions .= "$name \t$version\n" if defined $version; } my $msg = <<"MSG"; @@ -1059,7 +1059,7 @@ while (<DATA>) { # Load the default configuration stuff - chomp; + s/\s+$//; next if ! length; last if /^#key /; next if /^#/; @@ -1136,11 +1136,10 @@ while (<DATA>) { # Load key binding information next if /^#/; - - chomp; + s/^\s+//; s/\s+$//; - + next if ! length; my ($tag, $key, $menuItem, $toolbarItem, $rightClickItem) = s +plit /\s*,\s*/; @@ -1239,7 +1238,7 @@ strike,Control s,Format/Strike out,,Strike out sub,Control u,Format/Subscript,,Subscript super,Control s,Format/Superscript,,Superscript -underline,Control _,Format/Underline,,Underline +underline,Control 9,Format/Underline,,Underline -,-,Format/-,-, code,Control k,Format/Code,,Code quote,Control q,Format/Blockquote,,Blockquote @@ -1247,4 +1246,4 @@ #links - still bindings cpan,,Links/CPAN,,CPAN link id,Control d,Links/Node,,Node id link -name,Control n,Links/Name,,Node name link \ No newline at end of file +name,Control n,Links/Name,,Node name link

Replies are listed 'Best First'.
Re^5: PerlMonks Editor
by GrandFather (Saint) on Dec 01, 2006 at 11:00 UTC

    Again thank you! The first issue is related to different key binding support due either to OS differences or Tk version differences. I've now wrapped the troublesome code in an eval to trap the error and handle it in a rather friendlier manner.

    The ^M issue is a Windows/*nix line end issue I presume and I have used the fix you suggest - the two chomps are gone.

    I'm not sure where the tab characters came from, but they have now been removed.

    I'll sit on these changes for a day or two in case anything else comes to light. ;)


    DWIM is Perl's answer to Gödel
      The first issue is related to different key binding support due either to OS differences or Tk version differences.

      Yeah, that is really a downer, currently, that I could not use '_' in key binding. I will look into that some more, no doubt. Quite possibly that would have to do Tk installed here. I found a patch while searching for reason|solution for Tk dieing with sig 11 when compiled with Xft, which may or may not fix the this key binding issue.

      Anyway, please do ignore the change in __DATA__ related to underline key binding line. I should not have included that in the patch posted earlier.

Re^5: PerlMonks Editor
by parv (Parson) on Dec 02, 2006 at 23:01 UTC

    Program stops after printing "bad event type" message .. .

    bad event type or keysym "_" at PMEdit-001.000202-1.pl line 269, <DATA> line 81.

    ... but that goes away (and a Tk window emerges) if I change _ to one of [a-zA-Z0-9] but not [-+].

    So after source diving, I found that the key symbol is being retrieved, in Tk-804.027/pTk/mTk/generic/tkBind.c:TkKeysymToString(), via XStringToKeysym(3X11) which uses X11/keysymdef.h which does not have any X_[-+_] entry but does have X_(underscore|plus|minus). Needless to say, after changing '_' in the underline key binding to 'underscore', Ctrl-_ worked as expected.

Log In?
Username:
Password:

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

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

    No recent polls found