Rename references of 'draw' to 'render' for plugins

This commit is contained in:
Brooks J Rady 2021-03-23 16:26:34 +00:00
parent 1dd4045e23
commit a1e6171031
8 changed files with 17 additions and 15 deletions

View File

@ -236,7 +236,7 @@ impl ZellijTile for State {
set_max_height(1); set_max_height(1);
} }
fn draw(&mut self, _rows: usize, cols: usize) { fn render(&mut self, _rows: usize, cols: usize) {
let help = get_help(); let help = get_help();
let line_prefix = prefix(&help); let line_prefix = prefix(&help);
let key_path = key_path(&help); let key_path = key_path(&help);

View File

@ -12,7 +12,7 @@ impl ZellijTile for State {
refresh_directory(self); refresh_directory(self);
} }
fn draw(&mut self, rows: usize, cols: usize) { fn render(&mut self, rows: usize, cols: usize) {
for i in 0..rows { for i in 0..rows {
if self.selected() < self.scroll() { if self.selected() < self.scroll() {
*self.scroll_mut() = self.selected(); *self.scroll_mut() = self.selected();

View File

@ -44,7 +44,7 @@ impl ZellijTile for State {
self.new_name = String::new(); self.new_name = String::new();
} }
fn draw(&mut self, _rows: usize, cols: usize) { fn render(&mut self, _rows: usize, cols: usize) {
if self.tabs.is_empty() { if self.tabs.is_empty() {
return; return;
} }

View File

@ -120,7 +120,7 @@ impl Pane for PluginPane {
let (buf_tx, buf_rx) = channel(); let (buf_tx, buf_rx) = channel();
self.send_plugin_instructions self.send_plugin_instructions
.send(PluginInstruction::Draw( .send(PluginInstruction::Render(
buf_tx, buf_tx,
self.pid, self.pid,
self.rows(), self.rows(),

View File

@ -278,7 +278,7 @@ use crate::wasm_vm::PluginInstruction;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub enum PluginContext { pub enum PluginContext {
Load, Load,
Draw, Render,
Input, Input,
GlobalInput, GlobalInput,
Unload, Unload,
@ -290,7 +290,7 @@ impl From<&PluginInstruction> for PluginContext {
fn from(plugin_instruction: &PluginInstruction) -> Self { fn from(plugin_instruction: &PluginInstruction) -> Self {
match *plugin_instruction { match *plugin_instruction {
PluginInstruction::Load(..) => PluginContext::Load, PluginInstruction::Load(..) => PluginContext::Load,
PluginInstruction::Draw(..) => PluginContext::Draw, PluginInstruction::Render(..) => PluginContext::Render,
PluginInstruction::Input(..) => PluginContext::Input, PluginInstruction::Input(..) => PluginContext::Input,
PluginInstruction::GlobalInput(_) => PluginContext::GlobalInput, PluginInstruction::GlobalInput(_) => PluginContext::GlobalInput,
PluginInstruction::Unload(_) => PluginContext::Unload, PluginInstruction::Unload(_) => PluginContext::Unload,

View File

@ -522,12 +522,13 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
pid_tx.send(plugin_id).unwrap(); pid_tx.send(plugin_id).unwrap();
plugin_id += 1; plugin_id += 1;
} }
PluginInstruction::Draw(buf_tx, pid, rows, cols) => { PluginInstruction::Render(buf_tx, pid, rows, cols) => {
let (instance, plugin_env) = plugin_map.get(&pid).unwrap(); let (instance, plugin_env) = plugin_map.get(&pid).unwrap();
let draw = instance.exports.get_function("draw").unwrap(); let render = instance.exports.get_function("render").unwrap();
draw.call(&[Value::I32(rows as i32), Value::I32(cols as i32)]) render
.call(&[Value::I32(rows as i32), Value::I32(cols as i32)])
.unwrap(); .unwrap();
buf_tx.send(wasi_stdout(&plugin_env.wasi_env)).unwrap(); buf_tx.send(wasi_stdout(&plugin_env.wasi_env)).unwrap();

View File

@ -30,9 +30,9 @@ pub enum PluginInputType {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum PluginInstruction { pub enum PluginInstruction {
Load(Sender<u32>, PathBuf, Vec<NaughtyEventType>), Load(Sender<u32>, PathBuf, Vec<NaughtyEventType>),
Draw(Sender<String>, u32, usize, usize), // String buffer, plugin id, rows, cols Render(Sender<String>, u32, usize, usize), // String buffer, plugin id, rows, cols
Input(PluginInputType, Vec<u8>), // plugin id, input bytes Input(PluginInputType, Vec<u8>), // plugin id, input bytes
GlobalInput(Vec<u8>), // input bytes GlobalInput(Vec<u8>), // input bytes
Unload(u32), Unload(u32),
UpdateTabs(Vec<TabInfo>), // num tabs, active tab UpdateTabs(Vec<TabInfo>), // num tabs, active tab
Quit, Quit,

View File

@ -7,7 +7,8 @@ use data::*;
#[allow(unused_variables)] #[allow(unused_variables)]
pub trait ZellijTile { pub trait ZellijTile {
fn load(&mut self) {} fn load(&mut self) {}
fn draw(&mut self, rows: usize, cols: usize) {} fn render(&mut self, rows: usize, cols: usize) {}
// FIXME: Everything below this line should be purged
fn handle_key(&mut self, key: Key) {} fn handle_key(&mut self, key: Key) {}
fn handle_global_key(&mut self, key: Key) {} fn handle_global_key(&mut self, key: Key) {}
fn update_tabs(&mut self) {} fn update_tabs(&mut self) {}
@ -28,9 +29,9 @@ macro_rules! register_tile {
} }
#[no_mangle] #[no_mangle]
pub fn draw(rows: i32, cols: i32) { pub fn render(rows: i32, cols: i32) {
STATE.with(|state| { STATE.with(|state| {
state.borrow_mut().draw(rows as usize, cols as usize); state.borrow_mut().render(rows as usize, cols as usize);
}); });
} }