mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-23 19:10:09 +03:00
Add get_help function
This commit is contained in:
parent
1275a9e73a
commit
680a986cf6
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mosaic-tile"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
authors = ["Brooks J Rady <b.j.rady@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "A small client-side library for writing mosaic plugins (tiles)"
|
||||
|
18
src/shim.rs
18
src/shim.rs
@ -1,4 +1,4 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use std::{io, path::Path};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
@ -24,9 +24,7 @@ pub enum Key {
|
||||
}
|
||||
|
||||
pub fn get_key() -> Key {
|
||||
let mut json = String::new();
|
||||
io::stdin().read_line(&mut json).unwrap();
|
||||
serde_json::from_str(&json).unwrap()
|
||||
deserialize_from_stdin().unwrap()
|
||||
}
|
||||
|
||||
pub fn open_file(path: &Path) {
|
||||
@ -39,8 +37,20 @@ pub fn set_selectable(selectable: bool) {
|
||||
unsafe { host_set_selectable(selectable) };
|
||||
}
|
||||
|
||||
pub fn get_help() -> Vec<String> {
|
||||
unsafe { host_get_help() };
|
||||
deserialize_from_stdin().unwrap_or_default()
|
||||
}
|
||||
|
||||
fn deserialize_from_stdin<T: DeserializeOwned>() -> Option<T> {
|
||||
let mut json = String::new();
|
||||
io::stdin().read_line(&mut json).unwrap();
|
||||
serde_json::from_str(&json).ok()
|
||||
}
|
||||
|
||||
#[link(wasm_import_module = "mosaic")]
|
||||
extern "C" {
|
||||
fn host_open_file();
|
||||
fn host_set_selectable(selectable: i32);
|
||||
fn host_get_help();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user