You say: "So I need a way to replace the newline characters with something that will show up clearly."

The obvious thing to do would be to show what the Morse code guy would send in place of "\n", which would be the prosign {BT}. I used enclosing curly brackets to designate a prosign. When writing a prosign by hand, there would be a line atop the characters "BT". Instead of BT, move the underline to on top of the characters. If you send the characters: "BT", there will be 3 dots worth of time spacing between the B and the T. When sent as a prosign, there is no spacing and the two characters are run together. When someone runs characters together unintentionally, they are known as a "swing fist" and it is very hard to understand them!

Samuel Morse's historic message would have been sent: "WHAT HATH GOD WROUGHT {SK}", the prosign SK means the end of the message. There are a bunch of common prosigns: {BT} (change of thought/paragraph), {AS} (standby). {AA} (All After). {BK} ("over to you") among them.

You say you are teaching beginners. I would not teach the weirdo math characters +-*= as a first pass. I suggest you come up with a list of prosigns to teach - these will be heard far more often than these "math" characters. Another issue is how to represent the Error symbol. That is 8 dits in a row. I've never written a character for that because this is the "oops" character when you have botched the spelling of a word or other error. But I suppose if this is some test lesson script, you would want to include that so the students will know how to deal with it when they hear it.

For other UI possibilities, I think it would be possible to have the input refuse to enter any illegal character. Perhaps it looks to the user like nothing happens when he types "&". Some prototyping and extra thought are required to see if that idea pans out.

I did run your code. I had to install the TFrame module. For this demo, Frame would have sufficed. I see weird spaces in a number of places on my display. Like extra space before the highlighted "&" or when a space character precedes a "bad" character. This extra space is not composed of space characters since a "copy-n-paste" does not copy any extra spaces. I am puzzled by this behavior and I don't know if it is because of the ancient version of Perl that I run (5.24). I am still fiddling with a few ideas.

I suppose you could be teaching Morse as part of an HST (High Speed Telegraphy) competition? If so, I would read the rules on the universe of symbols that could be sent.

Update: Oh not all prosigns are 2 letters, {AAA} is a "full stop". Some old guy on the Titanic would have been familiar with that, but I don't hear that. Update- that's not right - just forget it.


In reply to Re^3: Tags in TK Text widgets by Marshall
in thread Tags in TK Text widgets by colintu

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.