8 // For storing multi cursor clipboard contents
9 type multiClipboard map[Register][]string
11 var multi multiClipboard
13 func (c multiClipboard) getAllText(r Register) string {
19 buf := &bytes.Buffer{}
20 for _, s := range content {
27 func (c multiClipboard) getText(r Register, num int) string {
29 if content == nil || len(content) <= num {
36 func hash(s string) uint32 {
42 // isValid checks if the text stored in this multi-clipboard is the same as the
43 // text stored in the system clipboard (provided as an argument), and therefore
44 // if it is safe to use the multi-clipboard for pasting instead of the system
46 func (c multiClipboard) isValid(r Register, ncursors int, clipboard string) bool {
48 if content == nil || len(content) != ncursors {
52 return hash(clipboard) == hash(c.getAllText(r))
55 func (c multiClipboard) writeText(text string, r Register, num int) {
57 if content == nil || num >= cap(content) {
58 content = make([]string, num+1, num+1)
65 multi = make(multiClipboard)