Skip to content

Commit

Permalink
delete selected text in backspace key binding (fixes #373)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli committed Feb 22, 2021
1 parent 168eadf commit 7e36750
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions porcupine/default_keybindings.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ bind Text <$contmand-Delete> {
}

bind Text <BackSpace> {
set beforecursor [%W get {insert linestart} insert]
if {
[string length [bind %W <<Dedent>>]] != 0 &&
[string length $beforecursor] != 0 &&
[string is space $beforecursor]
} {
event generate %W <<Dedent>>
} else {
%W delete {insert - 1 char}
try {%W delete sel.first sel.last} on error {} {
set beforecursor [%W get {insert linestart} insert]
if {
[string length [bind %W <<Dedent>>]] != 0 &&
[string length $beforecursor] != 0 &&
[string is space $beforecursor]
} {
event generate %W <<Dedent>>
} else {
%W delete {insert - 1 char}
}
}
}

Expand Down Expand Up @@ -137,8 +139,7 @@ bind Text <Shift-$contmand-BackSpace> {
}
}

# When pasting, delete what was selected
# Here + adds to end of existing binding
# When pasting, delete what was selected. Here + adds to end of existing binding.
bind Text <<Paste>> {+
catch {%W delete sel.first sel.last}
}

0 comments on commit 7e36750

Please sign in to comment.