Skip to content

Commit

Permalink
Refactor terminal copy and paste behavior
Browse files Browse the repository at this point in the history
Automatically copy selected text on mouse press and paste clipboard
contents on right-click. Removes redundant copy on right-click release
to streamline text interactions.
  • Loading branch information
mgazza committed Oct 23, 2024
1 parent 8a75938 commit 7fb2d08
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions term.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ func (t *Terminal) MinSize() fyne.Size {
// MouseDown handles the down action for desktop mouse events.
func (t *Terminal) MouseDown(ev *desktop.MouseEvent) {
if t.hasSelectedText() {
t.copySelectedText(fyne.CurrentApp().Driver().AllWindows()[0].Clipboard())
t.clearSelectedText()
} else {
if ev.Button == desktop.MouseButtonSecondary {
t.pasteText(fyne.CurrentApp().Driver().AllWindows()[0].Clipboard())
}
}

if t.onMouseDown == nil {
Expand All @@ -142,9 +147,6 @@ func (t *Terminal) MouseDown(ev *desktop.MouseEvent) {

// MouseUp handles the up action for desktop mouse events.
func (t *Terminal) MouseUp(ev *desktop.MouseEvent) {
if ev.Button == desktop.MouseButtonSecondary && t.hasSelectedText() {
t.copySelectedText(fyne.CurrentApp().Driver().AllWindows()[0].Clipboard())
}

if t.onMouseDown == nil {
return
Expand Down

0 comments on commit 7fb2d08

Please sign in to comment.