Skip to content

Conversation

@DanielVenturini
Copy link
Contributor

Hi, nice app.

This pull add a functionality that surrounds a selected text with a special key rather than replace it.

e.g.:
"This text is in editor now" -> select text and press ( -> "This (text) is in editor now"
"This text is in editor now" -> select text and press _ -> "This _text_ is in editor now"
"This text is in editor now" -> select text and press ' -> "This 'text' is in editor now"

It works as expected for the follow keys: *, _, ", ', (, [

@DanielVenturini
Copy link
Contributor Author

However, other special key, grave accent ( ` ), I could not capture it as an event by Qt

@mitya57
Copy link
Member

mitya57 commented Jul 16, 2020

Thanks for the PR! But what is the use case for it?

We already have Ctrl+B, Ctrl+I, Ctrl+U shortcuts that make text bold, italic and underline. We also have the Formatting menu that can turn text into a link, image or inline code.

Your PR is duplicating that functionality, isn't it?

@DanielVenturini
Copy link
Contributor Author

Yes, Retext already implements this functionality as shortcuts, but I think that my functionality is more intuitive in certain respects.
I really agree that my functionality migth not implement the _, *, but what do you thing about the ", ', ( and [?
Specially the ( and ", some others editors implements a functionality like it, that surrounds the text.

@mitya57
Copy link
Member

mitya57 commented Jul 16, 2020

Ok, I don't really oppose this change, just want to understand it. Can you name editors that are also doing it?

Also maybe you can try to add a simple test for this behavior to tests/test_editor.py?

@DanielVenturini
Copy link
Contributor Author

Code editors, like VSCode and Sublime, and Markdown editors, like typora, dillinger and pandao, have this functionality. In all of these markdown editors, it just works to the these keys ", ', ( and [. If you select a piece of text and click one of those keys, the piece of text is surrounded.

If you think that it'd be useful to Retext, I may remove the * and _ and insert some tests.

@mitya57
Copy link
Member

mitya57 commented Jul 16, 2020

Thanks. No need to remove anything, it doesn't complicate code so doesn't hurt. Please try to add tests and then I will merge it.

@DanielVenturini
Copy link
Contributor Author

Tests done.
Now, a piece of selected text is surrounded by these keys *, _, ", ', (, [ when they are pressed.

@mitya57 mitya57 merged commit 9d955a8 into retext-project:master Jul 16, 2020
@mitya57
Copy link
Member

mitya57 commented Jul 16, 2020

Merged. Thanks again!

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 this pull request may close these issues.

2 participants