Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable paste of text to the InterceptPlainTextEdit #22

Closed
bjones1 opened this issue Nov 8, 2016 · 7 comments · Fixed by #23
Closed

Enable paste of text to the InterceptPlainTextEdit #22

bjones1 opened this issue Nov 8, 2016 · 7 comments · Fixed by #23
Milestone

Comments

@bjones1
Copy link

bjones1 commented Nov 8, 2016

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
Copy link
Owner

thirtythreeforty commented Nov 8, 2016

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.)

@thirtythreeforty thirtythreeforty added this to the v1.1 milestone Nov 8, 2016
@bjones1
Copy link
Author

bjones1 commented Nov 8, 2016

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
Copy link
Owner

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

@bjones1
Copy link
Author

bjones1 commented Nov 8, 2016

Great! Thanks.

@bjones1
Copy link
Author

bjones1 commented Jan 9, 2017

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
Copy link
Owner

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

@bjones1
Copy link
Author

bjones1 commented Jan 9, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants