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 fad78ea commit 8f48aff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 33 deletions.
53 changes: 22 additions & 31 deletions ble-edit.sh
Expand Up @@ -3079,46 +3079,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 @@ -6342,8 +6333,8 @@ function ble-decode/keymap:safe/bind-common {
ble-decode/keymap:safe/.bind 'C-@' '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 @@ -6358,10 +6349,10 @@ 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 'C-h' 'delete-region-or backward-char'
ble-decode/keymap:safe/.bind 'delete' 'delete-region-or forward-char'
ble-decode/keymap:safe/.bind 'DEL' 'delete-region-or backward-char'
ble-decode/keymap:safe/.bind 'C-d' 'delete-region-or delete-forward-char'
ble-decode/keymap:safe/.bind 'C-h' 'delete-region-or delete-backward-char'
ble-decode/keymap:safe/.bind 'delete' 'delete-region-or delete-forward-char'
ble-decode/keymap:safe/.bind 'DEL' 'delete-region-or delete-backward-char'
ble-decode/keymap:safe/.bind 'C-t' 'transpose-chars'

# wordwise operations
Expand Down Expand Up @@ -6438,7 +6429,7 @@ function ble-decode/keymap:safe/define {
ble-decode/keymap:safe/bind-common
ble-decode/keymap:safe/bind-history

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 'C-RET' history-expand-line
Expand Down
2 changes: 1 addition & 1 deletion keymap/emacs.sh
Expand Up @@ -150,7 +150,7 @@ function ble-decode/keymap:emacs/define {
ble-decode/keymap:safe/bind-history

# 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 'C-RET' history-expand-line
Expand Down
2 changes: 1 addition & 1 deletion keymap/vi.sh
Expand Up @@ -6758,7 +6758,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-h' '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'

Expand Down

0 comments on commit 8f48aff

Please sign in to comment.