thirtythreeforty / bullycpp

A Bully Bootloader PC driver program
GNU General Public License v3.0
12 stars 6 forks source link

Enable paste of text to the InterceptPlainTextEdit #22

Closed bjones1 closed 7 years ago

bjones1 commented 7 years ago

This is a lazy pull request / feature request. For Micro, I'd like students to be able to paste text to the InterceptPlainTextEdit, to check how many characters sent produce an overflow. Here's a suggested patch to InterceptPlainTextEdit.h starting at line 41. That works for me, but I'd appreciate help in building the static version so I can distribute the updated version.

        // Look for a paste command. Since the QTextEdit has editing disabled,
        // this won't be detected by default. It would be nice if the context
        // menu also supplied a paste option.
        if (e->matches(QKeySequence::Paste)) {
            // Retrieve the text from the clipboard, then send that one
            // character at a time.
            QClipboard *clipboard = QApplication::clipboard();
            QString originalText = clipboard->text();
            for (int i = 0; i < originalText.size(); ++i) {
                // See emit below.
                emit keyPressed(originalText.at(i));
            }
        } else {
            // Do not forward this upward (we don't want local echo)
            emit keyPressed(e->text());
        }
thirtythreeforty commented 7 years ago

I like the paste idea. Why are you emitting the text one character at a time, instead of sending it all in one go as in the else block? (See also the implementation for insertFromMimeData which emits keyPressed with the entire block of data.)

bjones1 commented 7 years ago

Ignorance :). I'd just assumed keyPressed only worked on a character at a time. Replacing the for loop with emit keyPressed(originalText); works just fine based on a quick test, and is certainly better code.

thirtythreeforty commented 7 years ago

OK cool. I'll set this up when I get a chance. v1.1 should follow soon-ish, as time permits.

bjones1 commented 7 years ago

Great! Thanks.

bjones1 commented 7 years ago

Would you have time to build another release in the near future? I'd like students to install v1.1 of the bootloader in next week's lab, so they'll have a working paste option.

thirtythreeforty commented 7 years ago

Oh sure, sorry for delay. I'll see what I can do soon.

bjones1 commented 7 years ago

Thanks!