lute-v3
lute-v3 copied to clipboard
Revision of the logic of copying a word and substring of text from the main panel
Is your feature request related to a problem? Please describe.
Revision of the logic of copying a word and substring of text from the main panel.
Table of Contents:
- Proposal for implementing the logic of copying a specific word from the main text panel.
- Proposal to change the current logic of copying multiple words from the main text panel.
- Context.
Content:
1. Proposal for implementing the logic of copying a specific word from the main text panel.
My proposal is to implement copying of one selected word from the main text panel using one of the following options:
- Hold for a few seconds. Click on the word. It becomes yellow. Hold until the copy is triggered. Similar to how it currently works when selecting multiple words with Shift held down. The timer activation time setting can be moved to general settings.
- Hold down Shift. Similar to how it currently works when selecting multiple words with Shift held down.
- Double-click (click or tap) on the word.
- Combinations of the three options above. Hold with Shift. Double-click with Shift. Although, I would get rid of Shift altogether. I describe the reason below, using my case as an example. Fewer keys - better. Simpler - better. You can use a timer instead of Shift or double-click, in my opinion.
2. Proposal to change the current logic of copying multiple words from the main text panel.
- Bring it in line with the logic accepted in point 1, for copying a single word. Currently, to copy, you need to hold down Shift and select multiple words. Selecting a single word does not copy it. This also applies if you move the selection between multiple words and end the selection on a single word that needs to be copied.
Context:
Solving issue #591, a solution was proposed in the form of selecting multiple words with the Shift key held down. It works.
The only thing is that I have to hold down an additional key, which is not particularly convenient in my processing.
I can try to explain in more detail. When working with text, I use a joystick in one hand and a manipulator (mouse or stylus) in the other. The joystick (8BitDo Zero 2) works in tandem with Key Mapper (JoyKey) and sends key combinations (Commands). For example, the Ctrl+C (Copy) command. The manipulator is necessary for selecting text. I would like to use the current key on the joystick, which is programmed to press Ctrl+C. A long press on the button immediately repeats the press of Ctrl+C and opens the dictionary. Yes, I must say that a double press of Ctrl+C opens the GoldenDict-ng dictionary sidebar and performs a search with the current text in the clipboard.
I cannot program an additional Shift press on one key, on one press on the joystick using the Key Mapper application. In this case, I will have to free up a separate key for this combination of presses. In fact, I can probably do it through an intermediate AutoHotKey script, but this complicates the process.
I apologize if the description turned out to be too voluminous and complex to understand. I hope I was able to convey the essence of the problem. Thank you for your attention and assistance.
Describe the solution you'd like
Look above.
Describe alternatives you've considered
Look above.
Additional context
If we summarize the current testing, then I would be inclined to implement the option of copying by selection without additional keys. Perhaps, with a timer that starts when you press a word and stops when you release it. It would be appropriate to add the function of copying as a flag to the general settings. There, it is also necessary to provide a field for specifying the timer setting for the handler of copying.
In my understanding, the ideal process looks like this:
- Selecting a word or several words with a manipulator. I press the left mouse button on the word. I hold down the button. I move the pointer. I select the necessary words or one word. They are highlighted in yellow (by default, the theme is highlighted). I release the held left mouse button.
- By timer or without (setting 0 by default), the selected text is copied by the Lute program to the clipboard.
- I can insert a word or several copied words into the dictionary for further processing. Or I can press Ctrl+C twice in my case or press and hold the button on the joystick to open the GoldenDict-ng side panel with automatic search for the current content of the clipboard.
Additionally, I recorded a video from the desktop to visually show the options described above. The video also shows working with the "Enable Scanning" option in GoldenDict-ng. When this option is enabled, GoldenDict-ng monitors copying to the clipboard. When copying is detected, the buffer is immediately read and a search is performed in the dictionary (translation). This works well with Lute, if the ability to copy the selected word when it is selected in the main window text was implemented. Clicked on the word. Held (without Shift). Waited. The word was copied by the timer or immediately. GoldenDict picked it up from the clipboard and displayed the results. The same goes for multiple words (with a substring).
https://github.com/user-attachments/assets/50deed61-f050-46ab-8beb-dd48345881c6
@jzohrab
Hi @voothi - thanks for all the notes. It's such a simple little problem, and yet I'm not sure how to do it well with the existing code and Lute's usage model.
Some background to explain the current "copy sentence/copy paragraph" stuff: with a Word doc you'd highlight a word and click "copy". This was sort of the idea behind the "copy sentence" and "copy paragraph" shortcuts -- I figured people would want to copy these units of text from the reading pane. At the time I didn't think "copy word" was needed, but it obviously is.
Before I give my thoughts about your suggestions, I wanted to thank you ery much for putting those together! UX is tough, so ideas are great, it helps move things forward. 👍
Some thoughts regarding your proposals. These are of course my own preferences, and others may prefer your suggestions -- unfortunately I can't code for all preferences, just for my sanity. So here we go:
Hold for a few seconds. Click on the word. It becomes yellow. Hold until the copy is triggered. Similar to how it currently works when selecting multiple words with Shift held down. The timer activation time setting can be moved to general settings.
This is an interesting idea but feels like an unusual user experience, and my initial reaction to this suggestion is that we shouldn't do it this way, just b/c it is so different.
Hold down Shift. Similar to how it currently works when selecting multiple words with Shift held down.
Currently shift is used to select multiple distinct terms on the same page, eg to bulk set statuses etc ... I don't think I can make this idea work.
Double-click (click or tap) on the word.
In my experience, screen browsers (not mobile) don't have double-tap functions. I do see and use context menus a lot, but I haven't gotten into those with Lute, for no real reason.
Combinations of the three options above. Hold with Shift. Double-click with Shift. Although, I would get rid of Shift altogether. I describe the reason below, using my case as an example. Fewer keys - better. Simpler - better. You can use a timer instead of Shift or double-click, in my opinion.
All possible ideas (and a repeated thank you for your effort putting this together).
Having thought about this as I type this out, it feels to me like the thing that fits best with Lute's current design/feel is to add a "copy selected word(s)" hotkey. The hotkeys are customizable, so users could do stuff like say: "c = copy word(s), shift + c = copy sentence, alt + c = copy paragraph." I believe this is the least finicky, at least at present.
Would something like that work for you, for copying a single word?
Another possibility would be to add a different kind of click interaction - eg "control + click", but that seems sort of clumsy, and as you said, lots of key combos.
For copying a substring of text -- hmmm, I'm not sure how things could be changed to accommodate your needs, with the current setup. I'm reluctant to hack too much on it, just due to the amount of other stuff to do! :-)
Thinking a bit more though, some things come to mind as I type:
- Lute disables arbitrary text selection, like you would have in a text document, because it responds to word clicks, shift click-and-drag etc. This is done with css,
span.textitem { ... user-select: none; ... }Maybe there could be a way to toggle that off for a moment, so people could select arbitrary text. - maybe there could be customizable hotkey to "start text selection", and then another to "stop text selection", which would then either be copied to the clipboard, or a new multiword term form opened. This would result in a more keyboard-friendly usage, instead of requiring people to use shift and mouse movements. This is a pretty big change from the current interaction model, but in some ways it feels like it would be quite natural, for people (like me) who prefer keyboard driven stuff.
Cheers!
Hello! @jzohrab I have great news. I found a workaround and have been working hard for several days to implement it and publish it to the public.
I created a utility that pretends to be an external dictionary working over HTTP, and then, after receiving the text, uses JS to highlight the passed text in the field and optionally copies this text to the clipboard.
This completely solves the problem for me. At the same time, it does not require any changes to the Lute project. Of course, I would not mind integrating this into the project if the idea proves to be good and stands the test of time.
I named it, of course, pompously not much according to the size of the code base:
Flexible Text Copy Adapter (FTCA) https://github.com/voothi/ftca
Cheers!
Hey @voothi that sounds great! Super that you hacked at it, I have other scripts that I use outside of Lute as well. See how it feels and then maybe there's a way to integrate it.
I've been thinking some more about the "start text selection" idea. It might solve another issue I have: I'd like to be able to sentence mine with Lute a bit more easily. If I can highlight arbitrary sections, and then hit "a" or whatever to export to anki, that might be nice. No plans yet to actually work on it, it's just another idea (I'd somehow like to also clip audio if available, but that gets really messy). Anyway, cheers!
Could I suggest the simplest option would be to just copy words to the clipboard automatically when they are selected? This is the experience that would be easiest and most intuitive for me. You could even hide it behind an "Enable Copy on Select" option if you wanted to preserve the existing experience for users.