def clear_history(self): if messagebox.askyesno("Clear History", "Delete all clipboard history?"): self.history = [] self.pinned.clear() self.save_history() self.update_history_display() self.status_var.set("History cleared")
def load_history(self): if os.path.exists(HISTORY_FILE): try: with open(HISTORY_FILE, "r", encoding="utf-8") as f: data = json.load(f) self.history = data.get("history", []) self.pinned = set(tuple(x) for x in data.get("pinned", [])) except: self.history = [] self.pinned = set() windows clipboard history
def get_filtered_history(self): search_term = self.search_var.get().lower() filtered = [item for item in self.history if search_term in item["text"].lower()] # Sort: pinned first, then by timestamp desc filtered.sort(key=lambda x: (x["text"], x["timestamp"]) not in self.pinned) return filtered def clear_history(self): if messagebox