Skip to content

Commit

Permalink
fixes and improves plugin dragdropselected (#258)
Browse files Browse the repository at this point in the history
* fixes and improves plugin dragdropselected

- Tighter and neater code
- Removed weird selection during drag
- Ctrl+drag works if gnome's "ctrl to show mouse" is turned off
- Added sticky mode to help against finger fatigue
- Copied selections can now be placed adjacent to the original selection
- Press Esc to abort a begun action
- Added toggles for settings gui to enable/disable plugin and sticky
mode during runtime

* move isInSelection to DocView.dnd_isInSelection

also adding boundry contraction algo and an alternative argument
signature

also renamed the selection vars for continuity throughout code

* disable blinking caret during moves

now caret is reliably rendered, great UX

thanks @Guldoman for the hint.

* update manifest.json

* select pasted text after action

and some comment updates

* update manifest.json

* add multi-selection support

and some other tweaks to tidy and improve code

* add custom get_selection_text

- drag-items on same line are separated with spaces
- also added local functions to dnd-table which is returned on load

* remove stray caret when abborting drag inside selection

if user drags selection but then releases mouse with cursor still in
selection, there used to be an extra caret remaining. This commit
removes it.

* preserve selection direction

* comment and typo fix in another comment

* update readme

at this point I think we can drop the 'basic'

* return true in on_* events

* disable text input during drag operations

* selection restore no longer needed here

since we return true in on_mouse_pressed, this is no longer needed

* restore selections on esc

* better to re-select anyway

I'm not sure, may have been another issue, but this seems safer to also
make sure there are no stray markers

* comment typo

* move escape key detection to command

This allows users to define to another key(-combo) but it disables
escape out of autocomplete suggestions.

* use function predicate

this ensures other commands get executed

* allow clearing selection in sticky mode by clicking in empty

* whitespace cleanup

* add commands for toggles

* check button on release

just in case

* clear out unused variable

* comments

* use Doc:position_offset

same result
maybe not as fast
the tighter and easier to understand code is hopefully worth it

* credits

* [dragdropselected] tweak commands

adding horrid dashes in command, makes them look prettier in
command-view

* [dragdropselected] add ghost of selection

optionally have a ghost of selected text follow pointer.
default is off and only 1 line
  • Loading branch information
SwissalpS authored Jan 5, 2025
1 parent ec63371 commit de093c3
Show file tree
Hide file tree
Showing 3 changed files with 539 additions and 132 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ to follow with `extra.follow_branch`.*

*Any entries marked with an asterisk are hosted on external repositories.*


<!-- DO NOT EDIT THIS FILE MANUALLY -->
<!-- This file is autogenerated from manifest.json, so edit that. -->
<!-- DO NOT EDIT THIS FILE MANUALLY -->
Expand Down
12 changes: 9 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,17 @@
"version": "0.2"
},
{
"description": "Provides basic drag and drop of selected text (in same document)",
"description": "Provides drag and drop of selected text (in same document)",
"version": "20230616.094245",
"path": "plugins/dragdropselected.lua",
"id": "dragdropselected",
"mod_version": "3",
"path": "plugins/dragdropselected.lua",
"version": "0.2"
"name": "Drag n' Drop Selected",
"tags": [ "DnD", "mouse", "copy", "duplicate", "move", "selection", "drag", "drop" ],
"extra": {
"author": "SwissalpS",
"license": "MIT"
}
},
{
"description": "Adds a popup that displays the curve of Penner-styled easing functions.",
Expand Down
Loading

0 comments on commit de093c3

Please sign in to comment.