-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
272 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,56 @@ | ||
use mlua::{Result, Table, TableExt}; | ||
use ratatui::layout; | ||
use mlua::{AnyUserData, Table, TableExt}; | ||
|
||
use crate::{layout::{Paragraph, Rect}, GLOBALS, LUA}; | ||
use crate::{layout::{List, Paragraph, Rect}, GLOBALS, LUA}; | ||
|
||
#[inline] | ||
fn layout(values: Vec<AnyUserData>, buf: &mut ratatui::prelude::Buffer) -> mlua::Result<()> { | ||
for value in values { | ||
if let Ok(c) = value.take::<Paragraph>() { | ||
c.render(buf) | ||
} else if let Ok(c) = value.take::<List>() { | ||
c.render(buf) | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
// --- Status | ||
pub struct Status; | ||
|
||
impl Status { | ||
pub fn render(area: layout::Rect) -> Result<Vec<Paragraph>> { | ||
pub fn render( | ||
self, | ||
area: ratatui::layout::Rect, | ||
buf: &mut ratatui::prelude::Buffer, | ||
) -> mlua::Result<()> { | ||
let comp: Table = GLOBALS.get("Status")?; | ||
comp.call_method::<_, _>("render", Rect(area)) | ||
let values: Vec<AnyUserData> = comp.call_method::<_, _>("render", Rect(area))?; | ||
|
||
layout(values, buf) | ||
} | ||
} | ||
|
||
// --- Folder | ||
pub struct Folder { | ||
pub kind: u8, | ||
} | ||
|
||
impl Folder { | ||
fn args(&self) -> Result<Table> { | ||
fn args(&self) -> mlua::Result<Table> { | ||
let tbl = LUA.create_table()?; | ||
tbl.set("kind", self.kind)?; | ||
Ok(tbl) | ||
} | ||
|
||
pub fn render(self, area: layout::Rect) -> Result<Vec<Paragraph>> { | ||
pub fn render( | ||
self, | ||
area: ratatui::layout::Rect, | ||
buf: &mut ratatui::prelude::Buffer, | ||
) -> mlua::Result<()> { | ||
let comp: Table = GLOBALS.get("Folder")?; | ||
comp.call_method::<_, _>("render", (Rect(area), self.args()?)) | ||
let values: Vec<AnyUserData> = | ||
comp.call_method::<_, _>("render", (Rect(area), self.args()?))?; | ||
|
||
layout(values, buf) | ||
} | ||
} |
Oops, something went wrong.