AutoYADM commit: 2025-05-31 17:03:17
This commit is contained in:
parent
f8ad692156
commit
f67239a888
1 changed files with 23 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
|||
provide-module byline %{
|
||||
|
||||
# helpers for shell-less boolean checks
|
||||
try %{ define-command -hidden true nop }
|
||||
try %{ define-command -hidden false fail }
|
||||
# used to store origina readonly status
|
||||
declare-option -hidden bool base_readonly false
|
||||
|
||||
# Mappings
|
||||
|
@ -11,7 +13,7 @@ provide-module byline %{
|
|||
|
||||
# High-level selection expanding and contracting, based on selection direction
|
||||
|
||||
define-command -hidden byline-drag-down %{
|
||||
define-command byline-drag-down %{
|
||||
evaluate-commands -itersel -no-hooks %{
|
||||
try %{
|
||||
byline-assert-selection-forwards
|
||||
|
@ -22,7 +24,7 @@ provide-module byline %{
|
|||
}
|
||||
}
|
||||
|
||||
define-command -hidden byline-drag-up %{
|
||||
define-command byline-drag-up %{
|
||||
evaluate-commands -itersel -no-hooks %{
|
||||
try %{
|
||||
byline-assert-selection-forwards
|
||||
|
@ -50,21 +52,40 @@ provide-module byline %{
|
|||
byline-assert-selection-reduced
|
||||
} catch %{
|
||||
evaluate-commands -no-hooks -draft -save-regs 'ab' %{
|
||||
# this "check" requires readonly to be false,
|
||||
# so we store its original value before changing it
|
||||
set-option buffer base_readonly %opt{readonly}
|
||||
# store current cursor pos
|
||||
set-register a %val{cursor_byte_offset}
|
||||
# force cursor forward
|
||||
execute-keys <a-:>
|
||||
# store second cursor pos
|
||||
set-register b %val{cursor_byte_offset}
|
||||
# check whether readonly is enabled
|
||||
try %{
|
||||
%opt{base_readonly}
|
||||
# disable temporarily
|
||||
set-option buffer readonly false
|
||||
}
|
||||
# if the sel faces forward, the cursor hasn't moved
|
||||
# So we paste reg a. the pasted content is now selected.
|
||||
# We can use <a-k> to check whether it matches register b.
|
||||
try %{
|
||||
execute-keys %exp{"aP<a-k>%reg{b}<ret>u}
|
||||
# only re-enable readme if it was originally on
|
||||
try %{
|
||||
%opt{base_readonly}
|
||||
set-option buffer readonly true
|
||||
}
|
||||
} catch %{
|
||||
# clean up the pasted content if the above
|
||||
# assertion failed
|
||||
execute-keys 'u'
|
||||
# only re-enable readme if it was originally on
|
||||
try %{
|
||||
%opt{base_readonly}
|
||||
set-option buffer readonly true
|
||||
}
|
||||
# propogate failure to caller
|
||||
fail
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue