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 %{
|
provide-module byline %{
|
||||||
|
|
||||||
|
# helpers for shell-less boolean checks
|
||||||
try %{ define-command -hidden true nop }
|
try %{ define-command -hidden true nop }
|
||||||
try %{ define-command -hidden false fail }
|
try %{ define-command -hidden false fail }
|
||||||
|
# used to store origina readonly status
|
||||||
declare-option -hidden bool base_readonly false
|
declare-option -hidden bool base_readonly false
|
||||||
|
|
||||||
# Mappings
|
# Mappings
|
||||||
|
@ -11,7 +13,7 @@ provide-module byline %{
|
||||||
|
|
||||||
# High-level selection expanding and contracting, based on selection direction
|
# 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 %{
|
evaluate-commands -itersel -no-hooks %{
|
||||||
try %{
|
try %{
|
||||||
byline-assert-selection-forwards
|
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 %{
|
evaluate-commands -itersel -no-hooks %{
|
||||||
try %{
|
try %{
|
||||||
byline-assert-selection-forwards
|
byline-assert-selection-forwards
|
||||||
|
@ -50,21 +52,40 @@ provide-module byline %{
|
||||||
byline-assert-selection-reduced
|
byline-assert-selection-reduced
|
||||||
} catch %{
|
} catch %{
|
||||||
evaluate-commands -no-hooks -draft -save-regs 'ab' %{
|
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
|
# store current cursor pos
|
||||||
set-register a %val{cursor_byte_offset}
|
set-register a %val{cursor_byte_offset}
|
||||||
# force cursor forward
|
# force cursor forward
|
||||||
execute-keys <a-:>
|
execute-keys <a-:>
|
||||||
# store second cursor pos
|
# store second cursor pos
|
||||||
set-register b %val{cursor_byte_offset}
|
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
|
# if the sel faces forward, the cursor hasn't moved
|
||||||
# So we paste reg a. the pasted content is now selected.
|
# So we paste reg a. the pasted content is now selected.
|
||||||
# We can use <a-k> to check whether it matches register b.
|
# We can use <a-k> to check whether it matches register b.
|
||||||
try %{
|
try %{
|
||||||
execute-keys %exp{"aP<a-k>%reg{b}<ret>u}
|
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 %{
|
} catch %{
|
||||||
# clean up the pasted content if the above
|
# clean up the pasted content if the above
|
||||||
# assertion failed
|
# assertion failed
|
||||||
execute-keys 'u'
|
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
|
# propogate failure to caller
|
||||||
fail
|
fail
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue