Skip to content

Commit

Permalink
custom <Shift-Button-1> key binding (#453)
Browse files Browse the repository at this point in the history
* custom <Shift-Button-1> key binding

* delete unnecessary quotes pygments/pygments#1742
  • Loading branch information
Akuli committed Jun 5, 2021
1 parent 79a95fe commit af8cb25
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions porcupine/default_keybindings.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,31 @@ bind Text <<Paste>> {+
set scroll_amount 2
bind Text <Alt-Up> {
%W yview scroll -$scroll_amount units
%W mark set insert "@0,[expr [winfo height %W] / 2]"
%W mark set insert @0,[expr [winfo height %W] / 2]
}
bind Text <Alt-Down> {
%W yview scroll $scroll_amount units
%W mark set insert "@0,[expr [winfo height %W] / 2]"
%W mark set insert @0,[expr [winfo height %W] / 2]
}

# Do not do weird stuff when selecting text with shift+click. See #429
bind Text <Shift-Button-1> {
if {[%W tag ranges sel] == ""} {
set select_between_clicked_and_this [%W index insert]
} else {
# Something already selected, keep the end of selection where cursor is not
if {[%W index insert] == [%W index sel.first]} {
set select_between_clicked_and_this [%W index sel.last]
} else {
set select_between_clicked_and_this [%W index sel.first]
}
}

%W mark set insert @%x,%y
%W tag remove sel 1.0 end
if {[%W compare insert < $select_between_clicked_and_this]} {
%W tag add sel insert $select_between_clicked_and_this
} else {
%W tag add sel $select_between_clicked_and_this insert
}
}

0 comments on commit af8cb25

Please sign in to comment.