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

UX - buttons: copy at & copy to clipboard #19

Open
Blind4Basics opened this issue Mar 15, 2023 · 4 comments
Open

UX - buttons: copy at & copy to clipboard #19

Blind4Basics opened this issue Mar 15, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Blind4Basics
Copy link

Blind4Basics commented Mar 15, 2023

Request:
currently, there are a lot of clicks to do on user's side. For 2 lines snippets, this means there are no storng advantage to go through the snippets provider rather than just type the code. Here are some ideas to make the snippets provider quicker to use.

Copy to clipboard button

(currently automatically inherited from polyglot)

A button to be shown on each snippet code block

"Paste at cursor position" button

A second button, on each code block, that would paste the snippet directly at the current cursor position in the "parent" editor.
Things to consider:

  • add in the current line? (meaning, possibly right in the middle of the current instruction)
  • replace current line?
  • insert the snippet before or after current line
  • change the behavior if a selection exists? (=> replace the content with the snippet, in that case?)

"insert before current line" would have my preference, I believe (without selection).

Note: the context menu I was talking about in #14 could be of use to provide different options there. Especially, insert before vs replace

"Paste at cursor position" on double click

Same as above, but triggering it with a double click on the snippet code block. Most likely more useful than button ('cause, quicker), but the button still would be nice, to showcase the functionality (sort of...).

@Blind4Basics Blind4Basics added the enhancement New feature or request label Mar 15, 2023
@hobovsky
Copy link
Owner

For 2 lines snippets, this means there are no storng advantage to go through the snippets provider rather than just type the code.

One of the ideas behind the library is to have snippets at hand if you do not know how to type them in :) For example, I notoriously miss the name of std:mt19937 random generator in C++, or get the syntax of std::mt19937 rand { std::random_device {} () }; wrong because I confuse parentheses with braces, mistype some names, etc. I think that main strength of short snippets is to provide knowledge rather than save keystrokes.

But still the ideas are nice. I did not think of a double click, and it sounds cool. Thanks!

@Blind4Basics
Copy link
Author

yeah true, but as a mainly python/JS user, I'm mainly thinking about how to make it comfortable for me... XD

@hobovsky
Copy link
Owner

How to get access to a CodeMirror editor: document.querySelector('.CodeMirror').CodeMirror.replaceSelection("asd")
CodeMirror 5 editor commands: https://codemirror.net/5/doc/manual.html#commands

@hobovsky
Copy link
Owner

hobovsky commented Jul 5, 2023

Very basic support for "insert selection at cursor" has been added. Now we can think of other options and where to add them.

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

No branches or pull requests

2 participants