feat: Implement clipboard manager commands and history management

- Added command to clear clipboard history (`cmd_clear.go`).
- Implemented command to copy a history item back to the clipboard (`cmd_copy.go`).
- Created command to list clipboard history (`cmd_list.go`).
- Developed command to watch clipboard changes and store history (`cmd_watch.go`).
- Introduced configuration loading for logging and clipboard settings (`config.go`).
- Established main application logic with command registration and configuration handling (`main.go`).
- Implemented history management with loading, saving, and clearing functionality (`history.go`).
- Defined history item structure to store clipboard data (`history_item.go`).
- Added utility functions for hashing data and summarizing clipboard content (`hash.go`, `summary.go`).
- Updated dependencies in `go.sum`.
This commit is contained in:
2025-05-20 17:52:58 +02:00
commit 1dad8ca69b
22 changed files with 990 additions and 0 deletions

11
src/utils/hash.go Normal file
View File

@ -0,0 +1,11 @@
package utils
import (
"crypto/sha256"
)
// HashBytes returns a SHA256 hash of the given byte slice as a string.
func HashBytes(data []byte) string {
h := sha256.Sum256(data)
return string(h[:])
}

20
src/utils/summary.go Normal file
View File

@ -0,0 +1,20 @@
package utils
import (
"strconv"
"golang.design/x/clipboard"
)
func Summary(data []byte, format clipboard.Format) string {
if format == clipboard.FmtText {
if len(data) > 40 {
return string(data[:40]) + "..."
}
return string(data)
}
if format == clipboard.FmtImage {
return "[image] " + strconv.Itoa(len(data)) + " bytes"
}
return "[unknown format]"
}