mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Clear clipboard when copy process is closed
This commit is contained in:
+12
-1
@@ -2,6 +2,9 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/rwinkhart/go-boilerplate/back"
|
||||
"github.com/rwinkhart/go-boilerplate/front"
|
||||
@@ -36,6 +39,15 @@ func CopyMenu(targetLocation string) {
|
||||
}
|
||||
}
|
||||
|
||||
// set up signal handling for ctrl+c to clear clipboard
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-sigChan
|
||||
clip.ClipClearProcess("")
|
||||
os.Exit(0)
|
||||
}()
|
||||
|
||||
// copy selected field to clipboard
|
||||
for {
|
||||
choice := front.InputMenuGen("Field to copy:", fields)
|
||||
@@ -78,5 +90,4 @@ func CopyMenu(targetLocation string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO clear clipboard on exit!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user