Refinement, plugins, etc.

This commit is contained in:
Kirottu
2022-12-31 12:51:46 +02:00
parent 990bf12b79
commit ce4b157160
17 changed files with 36037 additions and 223 deletions

14
plugins/rink/Cargo.toml Normal file
View File

@@ -0,0 +1,14 @@
[package]
name = "rink"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyrun-plugin = { path = "../../anyrun-plugin" }
abi_stable = "0.11.1"
rink-core = "0.6"

31
plugins/rink/src/lib.rs Normal file
View File

@@ -0,0 +1,31 @@
use abi_stable::std_types::{ROption, RString, RVec};
use anyrun_plugin::{anyrun_interface::HandleResult, plugin, Match, PluginInfo};
fn init(_config_dir: RString) {}
fn info() -> PluginInfo {
PluginInfo {
name: "Rink".into(),
icon: "accessories-calculator".into(),
}
}
fn get_matches(input: RString, _: &mut ()) -> RVec<Match> {
let mut ctx = rink_core::simple_context().unwrap();
match rink_core::one_line(&mut ctx, &input) {
Ok(result) => vec![Match {
title: result.into(),
icon: ROption::RNone,
description: ROption::RNone,
id: ROption::RNone,
}]
.into(),
Err(_) => RVec::new(),
}
}
fn handler(selection: Match, _: &mut ()) -> HandleResult {
HandleResult::Copy(selection.title.into_bytes())
}
plugin!(init, info, get_matches, handler, ());