467de2235a
returning the results as objects seems to be a better approach, also, the new way of showing results doesn't work for some reason(i didn't discover it yet lol)
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import { Gtk } from "ags/gtk4";
|
|
import { Clipboard } from "../../scripts/clipboard";
|
|
import { Runner } from "../Runner";
|
|
import { jsx } from "ags/gtk4/jsx-runtime";
|
|
|
|
|
|
export const PluginClipboard = {
|
|
prefix: '>',
|
|
prioritize: true,
|
|
handle: (search) => {
|
|
if(Clipboard.getDefault().history.length < 1)
|
|
return {
|
|
icon: "edit-paste-symbolic",
|
|
title: "Clipboard is empty",
|
|
description: "Copy something and it will be shown right here!"
|
|
};
|
|
|
|
return Clipboard.getDefault().history.filter(item =>
|
|
// not the best way to search, but it works
|
|
Runner.regExMatch(search, item.id) || Runner.regExMatch(search, item.preview)).map((item) => ({
|
|
icon: jsx(Gtk.Label, {
|
|
label: `${item.id}`,
|
|
css: "font-size: 16px; margin-right: 8px; font-weight: 600;"
|
|
}),
|
|
title: item.preview,
|
|
actionClick: () => Clipboard.getDefault().selectItem(item).catch((err: Error) => {
|
|
console.error(`Runner(Plugin/Clipboard): An error occurred while selecting clipboard item. Stderr:\n${
|
|
err.message ? `${err.message}\n` : ""}Stack: ${err.stack}`
|
|
);
|
|
})
|
|
}));
|
|
}
|
|
} as Runner.Plugin;
|