Refinement, plugins, etc.
This commit is contained in:
14
plugins/rink/Cargo.toml
Normal file
14
plugins/rink/Cargo.toml
Normal 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
31
plugins/rink/src/lib.rs
Normal 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, ());
|
Reference in New Issue
Block a user