Currently, everything copied will make its way to the clipboard manager as an item, even if it is done so by copying the same thing multiple times. Those duplicates are not really useful and only take up space. Could you implement an option that would allow discarding those duplicate entries before storing them?
I'm not sure whether there is a good way to recognize duplicate clipboard items. It's more complicated than it looks like. A clipboard item is not only represented by what BTT shows (e.g. a picture can be available in various formats for the same clipboard item and will paste depending on the application you are currently using). There is no identifier that uniquely identifies a clipboard item as far as I know.
Yes, I understand that.
I'm also quite new to Mac, so there're tons of things I don't know, I've been exclusively Windows until now. I haven't found any decent clipboard managers there that could do at least most of what I needed, so I had to write my own. I don't know how it is done on Mac, so I can only add my Win (lose? ) two cents. Upon triggering the clipboard event (that is, copy or cut), a copy of the current clipboard object was saved (first into a memory variable and later to a file so it could be retrieved later, sadly no easy moving clipboard data to/from SQLite there). Before adding that object to the list of the saved entries, I created a hash of it and compared that hash to the other hashes of the already saved clipboard entries and if there was a match, nothing was added to the list, just a notification/tooltip shown that it is already there. I see that you also save which app the clipboard item comes from, which I didn't do there, but it should be easy to include that in the hash as well so that duplicates from different apps are still saved. Provided that makes sense, of course. Hmm, I might even steal that idea and port it back to Win
I'll check again whether a hash does it. However if I remember correctly the hashes for these items change for some reason - haven't looked into it in detail though.
Well, the hash will definitely change if you include the app and/or the time. And while the app would not make much of a trouble, including the timestamp will render the hash useless. The question is, can you exclude the timestamp or not. If not, then this is unfortunately decided. Anyway thanks for looking into it.
Not sure if my use case is the same, but when copying the same item multiple times (bad habit from unresponsive clipboard tools I guess), the same entry will show up multiple times in a row. Would it be possible to just combine those duplicate entries that all follow one another into a single entry? Not sure if that is a simpler solution, or just as complex.
Only matching with the last entry might be a bit of a lesser task, for it only has to check once. However, checking every entry is only an iteration more, if I may say so (though it might take considerably more time, of course). Combining/collapsing them into a single entry is also a bit more overhead than not doing anything at all if it's already present.