use fusabi_host::{ExecutionContext, Result, Value, Error};
pub fn read_key(_args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
tracing::warn!("terminal.read_key: not yet implemented");
Err(Error::host_function("terminal.read_key: not yet implemented"))
}
pub fn size(_args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
tracing::debug!("terminal.size: returning default 80x24");
Ok(Value::List(vec![Value::Int(80), Value::Int(24)]))
}
pub fn clipboard_read(_args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
tracing::warn!("terminal.clipboard_read: not yet implemented");
Err(Error::host_function("terminal.clipboard_read: not yet implemented"))
}
pub fn clipboard_write(args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
let text = args
.first()
.and_then(|v| v.as_str())
.ok_or_else(|| Error::host_function("terminal.clipboard_write: missing text argument"))?;
tracing::warn!("terminal.clipboard_write: not yet implemented (text: {})", text);
Err(Error::host_function("terminal.clipboard_write: not yet implemented"))
}
pub fn colorize(args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
let text = args
.first()
.and_then(|v| v.as_str())
.ok_or_else(|| Error::host_function("terminal.colorize: missing text argument"))?;
let color = args
.get(1)
.and_then(|v| v.as_str())
.ok_or_else(|| Error::host_function("terminal.colorize: missing color argument"))?;
let color_code = match color.to_lowercase().as_str() {
"red" => "31",
"green" => "32",
"yellow" => "33",
"blue" => "34",
"magenta" => "35",
"cyan" => "36",
"white" => "37",
_ => return Err(Error::host_function(format!("terminal.colorize: unknown color '{}'", color))),
};
let colored = format!("\x1b[{}m{}\x1b[0m", color_code, text);
Ok(Value::String(colored))
}
pub fn clear(_args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
tracing::debug!("terminal.clear: not yet implemented");
Err(Error::host_function("terminal.clear: not yet implemented"))
}
pub fn set_cursor(args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
let _x = args
.first()
.and_then(|v| v.as_int())
.ok_or_else(|| Error::host_function("terminal.set_cursor: missing x argument"))?;
let _y = args
.get(1)
.and_then(|v| v.as_int())
.ok_or_else(|| Error::host_function("terminal.set_cursor: missing y argument"))?;
tracing::debug!("terminal.set_cursor: not yet implemented");
Err(Error::host_function("terminal.set_cursor: not yet implemented"))
}