view/html: show `open` command in status bar

async-cursors
Manos Pitsidianakis 2023-07-13 23:02:10 +03:00
parent 4e55fbc90d
commit 369c1dbdac
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
1 changed files with 18 additions and 1 deletions

View File

@ -28,7 +28,6 @@ use melib::xdg_utils::query_default_app;
use super::*;
#[derive(Debug)]
pub struct HtmlView {
pager: Pager,
bytes: Vec<u8>,
@ -36,6 +35,17 @@ pub struct HtmlView {
id: ComponentId,
}
impl std::fmt::Debug for HtmlView {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
fmt.debug_struct(stringify!(HtmlView))
.field("pager", &self.pager)
.field("bytes", &self.bytes.len())
.field("coordinates", &self.coordinates)
.field("id", &self.id)
.finish()
}
}
impl HtmlView {
pub fn new(body: &Attachment, context: &mut Context) -> Self {
let id = ComponentId::default();
@ -140,6 +150,7 @@ impl Component for HtmlView {
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
self.pager.draw(grid, area, context);
}
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
if self.pager.process_event(event, context) {
return true;
@ -163,8 +174,14 @@ impl Component for HtmlView {
};
if let Some(command) = command {
let p = create_temp_file(&self.bytes, None, None, Some("html"), true);
context
.replies
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateSubStatus(
command.to_string(),
)));
let exec_cmd =
super::desktop_exec_to_command(&command, p.path.display().to_string(), false);
match Command::new("sh")
.args(["-c", &exec_cmd])
.stdin(Stdio::piped())