Skip to content

Commit

Permalink
edit ({kill,copy,delete}-region-or): receive widgets as arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jul 9, 2022
1 parent 84184ce commit e222c48
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 40 deletions.
4 changes: 2 additions & 2 deletions keymap/emacs.rlfunc.txt
Expand Up @@ -4,7 +4,7 @@ alias-expand-line -
arrow-key-prefix -
backward-byte -
backward-char @nomarked backward-char
backward-delete-char delete-region-or backward-char
backward-delete-char delete-region-or delete-backward-char
backward-kill-line kill-backward-line
backward-kill-word kill-backward-cword
backward-word @nomarked backward-cword
Expand Down Expand Up @@ -62,7 +62,7 @@ insert-comment -
insert-completions complete insert_all
insert-last-argument -
kill-line kill-forward-line
kill-region kill-region-or uword
kill-region kill-region-or kill-uword
kill-whole-line -
kill-word kill-forward-cword
magic-space magic-space
Expand Down
2 changes: 1 addition & 1 deletion keymap/emacs.sh
Expand Up @@ -148,7 +148,7 @@ function ble-decode/keymap:emacs/define {
ble-decode/keymap:safe/bind-complete

# charwise operations
ble-bind -f 'C-d' 'delete-region-or forward-char-or-exit'
ble-bind -f 'C-d' 'delete-region-or delete-forward-char-or-exit'

# history
ble-bind -f 'M-^' history-expand-line
Expand Down
4 changes: 2 additions & 2 deletions keymap/vi.sh
Expand Up @@ -7509,7 +7509,7 @@ function ble-decode/keymap:vi_imap/define {
ble-bind -f paste_begin 'vi_imap/bracketed-paste'

# charwise operations
ble-bind -f 'C-d' 'delete-region-or forward-char-or-exit'
ble-bind -f 'C-d' 'delete-region-or delete-forward-char-or-exit'
ble-bind -f 'C-?' 'vi_imap/delete-region-or vi_imap/delete-backward-indent-or delete-backward-char'
ble-bind -f 'DEL' 'vi_imap/delete-region-or vi_imap/delete-backward-indent-or delete-backward-char'
ble-bind -f 'C-h' 'vi_imap/delete-region-or vi_imap/delete-backward-indent-or delete-backward-char'
Expand Down Expand Up @@ -7586,7 +7586,7 @@ function ble-decode/keymap:vi_imap/define-meta-bindings {
ble-bind -f 'M-C-m' 'newline'
ble-bind -f 'M-RET' 'newline'
ble-bind -f 'M-SP' 'set-mark'
ble-bind -f 'M-w' 'copy-region-or uword'
ble-bind -f 'M-w' 'copy-region-or copy-uword'
ble-bind -f 'M-\' 'delete-horizontal-space'

ble-bind -f 'M-right' '@nomarked forward-sword'
Expand Down
4 changes: 2 additions & 2 deletions keymap/vi_imap.rlfunc.txt
Expand Up @@ -25,7 +25,7 @@ complete-username complete context=username
complete-variable complete context=variable
copy-backward-word copy-backward-sword
copy-forward-word copy-forward-sword
copy-region-as-kill copy-region-or uword
copy-region-as-kill copy-region-or copy-uword
dabbrev-expand dabbrev-expand
delete-char vi_imap/delete-region-or delete-forward-char
delete-char-or-list -
Expand Down Expand Up @@ -62,7 +62,7 @@ insert-comment -
insert-completions complete insert_all
insert-last-argument -
kill-line kill-forward-line
kill-region kill-region-or uword
kill-region kill-region-or kill-uword
kill-whole-line -
kill-word kill-forward-uword
magic-space magic-space
Expand Down
57 changes: 24 additions & 33 deletions src/edit.sh
Expand Up @@ -2282,46 +2282,37 @@ function ble/widget/copy-region {
ble/widget/.copy-range "$_ble_edit_mark" "$_ble_edit_ind"
_ble_edit_mark_active=
}
## 関数 ble/widget/delete-region-or type
## 領域または引数に指定した単位を削除します。
## mark が active な場合には領域の削除を行います。
## それ以外の場合には第一引数に指定した単位の削除を実行します。
## @param[in] type
## mark が active でない場合に実行される削除の単位を指定します。
## 実際には ble-edit 関数 delete-type が呼ばれます。
## 関数 ble/widget/delete-region-or widget
## mark が active の時に領域を削除します。
## それ以外の時に編集関数 widget を実行します。
## @param[in] widget
function ble/widget/delete-region-or {
if [[ $_ble_edit_mark_active ]]; then
ble/widget/delete-region
else
"ble/widget/delete-$@"
"ble/widget/$@"
fi
}
## 関数 ble/widget/kill-region-or type
## 領域または引数に指定した単位を切り取ります。
## mark が active な場合には領域の切り取りを行います。
## それ以外の場合には第一引数に指定した単位の切り取りを実行します。
## @param[in] type
## mark が active でない場合に実行される切り取りの単位を指定します。
## 実際には ble-edit 関数 kill-type が呼ばれます。
## 関数 ble/widget/kill-region-or widget
## mark が active の時に領域を切り取ります。
## それ以外の時に編集関数 widget を実行します。
## @param[in] widget
function ble/widget/kill-region-or {
if [[ $_ble_edit_mark_active ]]; then
ble/widget/kill-region
else
"ble/widget/kill-$@"
"ble/widget/$@"
fi
}
## 関数 ble/widget/copy-region-or type
## 領域または引数に指定した単位を転写します。
## mark が active な場合には領域の転写を行います。
## それ以外の場合には第一引数に指定した単位の転写を実行します。
## @param[in] type
## mark が active でない場合に実行される転写の単位を指定します。
## 実際には ble-edit 関数 copy-type が呼ばれます。
## 関数 ble/widget/copy-region-or widget
## mark が active の時に領域を転写します。
## それ以外の時に編集関数 widget を実行します。
## @param[in] widget
function ble/widget/copy-region-or {
if [[ $_ble_edit_mark_active ]]; then
ble/widget/copy-region
else
"ble/widget/copy-$@"
"ble/widget/$@"
fi
}

Expand Down Expand Up @@ -6396,8 +6387,8 @@ function ble-decode/keymap:safe/bind-common {
ble-decode/keymap:safe/.bind 'NUL' 'set-mark'
ble-decode/keymap:safe/.bind 'M-SP' 'set-mark'
ble-decode/keymap:safe/.bind 'C-x C-x' 'exchange-point-and-mark'
ble-decode/keymap:safe/.bind 'C-w' 'kill-region-or backward-uword'
ble-decode/keymap:safe/.bind 'M-w' 'copy-region-or backward-uword'
ble-decode/keymap:safe/.bind 'C-w' 'kill-region-or kill-backward-uword'
ble-decode/keymap:safe/.bind 'M-w' 'copy-region-or copy-backward-uword'
ble-decode/keymap:safe/.bind 'C-y' 'yank'

# spaces
Expand All @@ -6412,12 +6403,12 @@ function ble-decode/keymap:safe/bind-common {
ble-decode/keymap:safe/.bind 'S-C-b' '@marked backward-char'
ble-decode/keymap:safe/.bind 'S-right' '@marked forward-char'
ble-decode/keymap:safe/.bind 'S-left' '@marked backward-char'
ble-decode/keymap:safe/.bind 'C-d' 'delete-region-or forward-char'
ble-decode/keymap:safe/.bind 'delete' 'delete-region-or forward-char'
ble-decode/keymap:safe/.bind 'C-?' 'delete-region-or backward-char'
ble-decode/keymap:safe/.bind 'DEL' 'delete-region-or backward-char'
ble-decode/keymap:safe/.bind 'C-h' 'delete-region-or backward-char'
ble-decode/keymap:safe/.bind 'BS' 'delete-region-or backward-char'
ble-decode/keymap:safe/.bind 'C-d' 'delete-region-or delete-forward-char'
ble-decode/keymap:safe/.bind 'delete' 'delete-region-or delete-forward-char'
ble-decode/keymap:safe/.bind 'C-?' 'delete-region-or delete-backward-char'
ble-decode/keymap:safe/.bind 'DEL' 'delete-region-or delete-backward-char'
ble-decode/keymap:safe/.bind 'C-h' 'delete-region-or delete-backward-char'
ble-decode/keymap:safe/.bind 'BS' 'delete-region-or delete-backward-char'
ble-decode/keymap:safe/.bind 'C-t' 'transpose-chars'

# wordwise operations
Expand Down Expand Up @@ -6537,7 +6528,7 @@ function ble-decode/keymap:safe/define {
ble-decode/keymap:safe/bind-history
ble-decode/keymap:safe/bind-complete

ble-bind -f 'C-d' 'delete-region-or forward-char-or-exit'
ble-bind -f 'C-d' 'delete-region-or delete-forward-char-or-exit'

ble-bind -f 'SP' magic-space
ble-bind -f 'M-^' history-expand-line
Expand Down

0 comments on commit e222c48

Please sign in to comment.