pragma Singleton import QtQuick import Quickshell import Quickshell.Io // Emoji for the launcher's emoji mode, from assets/emoji.tsv (scripts/emoji-data). // The list is read the first time emoji mode opens and kept for the session. Singleton { id: root // Unicode order: {emoji, name, keywords} with lower-case search text. property var entries: [] property bool loaded: false function load() { if (!file.path) file.path = Qt.resolvedUrl("../assets/emoji.tsv").toString().replace("file://", ""); } // Space-separated terms, all required. Name matches come before keyword // matches; Unicode order is kept within each. function filter(query) { const terms = query.toLowerCase().split(/\s+/).filter(t => t); if (!terms.length) return entries; const named = [], tagged = []; for (const e of entries) { if (!terms.every(t => e.search.includes(t))) continue; (terms.every(t => e.lowerName.includes(t)) ? named : tagged).push(e); } return named.concat(tagged); } function copy(entry) { if (!entry) return false; Quickshell.execDetached(["wl-copy", "--", entry.emoji]); return true; } FileView { id: file onLoaded: { root.entries = text().split("\n").filter(line => line).map(line => { const [emoji, name, keywords] = line.split("\t"); const lowerName = name.toLowerCase(); return { emoji: emoji, name: name, lowerName: lowerName, search: lowerName + " " + (keywords || "") }; }); root.loaded = true; } } }