use psdk_father::args::{ArgContext, PsdkArgBase, PsdkEasyArg};
use psdk_father::command::{CommandClause, PsdkTextCommand};
use psdk_father::errors::PsdkFatherResult;
use std::sync::{Arc, Mutex};
use crate::args::{CForm, CGap, CPageWidth, CPageWidthOptions, CPrint, CPrintOptions};
#[derive(Clone, Debug)]
pub struct CFeed {
ctx: Arc<Mutex<ArgContext>>,
}
impl Default for CFeed {
fn default() -> Self {
Self::new()
}
}
impl CFeed {
pub fn new() -> Self {
Self {
ctx: Default::default(),
}
}
}
impl PsdkEasyArg<String> for CFeed {
fn context(&self) -> Arc<Mutex<ArgContext>> {
self.ctx.clone()
}
}
impl PsdkArgBase<String> for CFeed {
fn header(&self) -> String {
"! 0 200 200 0 1".to_string()
}
fn clause(&self) -> PsdkFatherResult<CommandClause> {
self
.append(&CPageWidth::new(CPageWidthOptions { width: 576 }))?
.append(&CGap::new())?
.append(&CForm::new())?
.append(&CPrint::new(CPrintOptions { mode: None }))?;
let ptc = PsdkTextCommand::with_header_format_cpcl(self.header());
Ok(ptc.clause())
}
}
psdk_father::impl_psdk_arg_to_easy_arg!(String, CFeed, true);