Some misc fixes and improvements
This commit is contained in:
parent
ec8b12d206
commit
dcf27a0cbf
5 changed files with 14 additions and 13 deletions
|
@ -30,7 +30,7 @@ pub fn initial_value(var: &ScriptVarDefinition) -> Result<DynVal> {
|
||||||
run_command(command).map_err(|e| anyhow!(create_script_var_failed_warn(*span, var.name(), &e.to_string())))
|
run_command(command).map_err(|e| anyhow!(create_script_var_failed_warn(*span, var.name(), &e.to_string())))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ScriptVarDefinition::Listen(_) => Ok(DynVal::from_string(String::new())),
|
ScriptVarDefinition::Listen(var) => Ok(var.initial_value.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,13 +196,13 @@ impl ListenVarHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn start(&mut self, var: ListenScriptVar) {
|
async fn start(&mut self, var: ListenScriptVar) {
|
||||||
log::debug!("starting poll var {}", &var.name);
|
log::debug!("starting listen-var {}", &var.name);
|
||||||
let cancellation_token = CancellationToken::new();
|
let cancellation_token = CancellationToken::new();
|
||||||
self.listen_process_handles.insert(var.name.clone(), cancellation_token.clone());
|
self.listen_process_handles.insert(var.name.clone(), cancellation_token.clone());
|
||||||
|
|
||||||
let evt_send = self.evt_send.clone();
|
let evt_send = self.evt_send.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
crate::try_logging_errors!(format!("Executing tail var command {}", &var.command) => {
|
crate::try_logging_errors!(format!("Executing listen var-command {}", &var.command) => {
|
||||||
let mut handle = tokio::process::Command::new("sh")
|
let mut handle = tokio::process::Command::new("sh")
|
||||||
.args(&["-c", &var.command])
|
.args(&["-c", &var.command])
|
||||||
.stdout(std::process::Stdio::piped())
|
.stdout(std::process::Stdio::piped())
|
||||||
|
|
|
@ -83,6 +83,10 @@ pub(super) fn resolve_widget_attrs(bargs: &mut BuilderArgs, gtk_widget: >k::Wi
|
||||||
prop(valign: as_string) { gtk_widget.set_valign(parse_align(&valign)?) },
|
prop(valign: as_string) { gtk_widget.set_valign(parse_align(&valign)?) },
|
||||||
// @prop halign - how to align this horizontally. possible values: $alignment
|
// @prop halign - how to align this horizontally. possible values: $alignment
|
||||||
prop(halign: as_string) { gtk_widget.set_halign(parse_align(&halign)?) },
|
prop(halign: as_string) { gtk_widget.set_halign(parse_align(&halign)?) },
|
||||||
|
// @prop vexpand - should this container expand vertically. Default: false.
|
||||||
|
prop(vexpand: as_bool = false) { gtk_widget.set_vexpand(vexpand) },
|
||||||
|
// @prop hexpand - should this widget expand horizontally. Default: false.
|
||||||
|
prop(hexpand: as_bool = false) { gtk_widget.set_hexpand(hexpand) },
|
||||||
// @prop width - width of this element. note that this can not restrict the size if the contents stretch it
|
// @prop width - width of this element. note that this can not restrict the size if the contents stretch it
|
||||||
prop(width: as_f64) { gtk_widget.set_size_request(width as i32, gtk_widget.get_allocated_height()) },
|
prop(width: as_f64) { gtk_widget.set_size_request(width as i32, gtk_widget.get_allocated_height()) },
|
||||||
// @prop height - height of this element. note that this can not restrict the size if the contents stretch it
|
// @prop height - height of this element. note that this can not restrict the size if the contents stretch it
|
||||||
|
@ -158,13 +162,8 @@ pub(super) fn resolve_widget_attrs(bargs: &mut BuilderArgs, gtk_widget: >k::Wi
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @widget !container
|
/// @widget !container
|
||||||
pub(super) fn resolve_container_attrs(bargs: &mut BuilderArgs, gtk_widget: >k::Container) {
|
pub(super) fn resolve_container_attrs(_bargs: &mut BuilderArgs, _gtk_widget: >k::Container) {
|
||||||
resolve_block!(bargs, gtk_widget, {
|
// resolve_block!(bargs, gtk_widget, {});
|
||||||
// @prop vexpand - should this container expand vertically
|
|
||||||
prop(vexpand: as_bool = false) { gtk_widget.set_vexpand(vexpand) },
|
|
||||||
// @prop hexpand - should this container expand horizontally
|
|
||||||
prop(hexpand: as_bool = false) { gtk_widget.set_hexpand(hexpand) },
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @widget !range
|
/// @widget !range
|
||||||
|
|
|
@ -85,6 +85,7 @@ impl FromAstElementContent for PollScriptVar {
|
||||||
pub struct ListenScriptVar {
|
pub struct ListenScriptVar {
|
||||||
pub name: VarName,
|
pub name: VarName,
|
||||||
pub command: String,
|
pub command: String,
|
||||||
|
pub initial_value: DynVal,
|
||||||
pub command_span: Span,
|
pub command_span: Span,
|
||||||
pub name_span: Span,
|
pub name_span: Span,
|
||||||
}
|
}
|
||||||
|
@ -94,10 +95,12 @@ impl FromAstElementContent for ListenScriptVar {
|
||||||
fn from_tail<I: Iterator<Item = Ast>>(span: Span, mut iter: AstIterator<I>) -> AstResult<Self> {
|
fn from_tail<I: Iterator<Item = Ast>>(span: Span, mut iter: AstIterator<I>) -> AstResult<Self> {
|
||||||
let result: AstResult<_> = try {
|
let result: AstResult<_> = try {
|
||||||
let (name_span, name) = iter.expect_symbol()?;
|
let (name_span, name) = iter.expect_symbol()?;
|
||||||
|
let mut attrs = iter.expect_key_values()?;
|
||||||
|
let initial_value = attrs.primitive_optional("initial")?.unwrap_or_else(|| DynVal::from_string(String::new()));
|
||||||
let (command_span, script) = iter.expect_literal()?;
|
let (command_span, script) = iter.expect_literal()?;
|
||||||
iter.expect_done()?;
|
iter.expect_done()?;
|
||||||
Self { name_span, name: VarName(name), command: script.to_string(), command_span }
|
Self { name_span, name: VarName(name), command: script.to_string(), initial_value, command_span }
|
||||||
};
|
};
|
||||||
result.note(r#"Expected format: `(deflisten name "tail -f /tmp/example")`"#)
|
result.note(r#"Expected format: `(deflisten name :initial "0" "tail -f /tmp/example")`"#)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,6 @@ impl Lexer {
|
||||||
toks.push((lo, tok, hi));
|
toks.push((lo, tok, hi));
|
||||||
}
|
}
|
||||||
Some(Err(err)) => {
|
Some(Err(err)) => {
|
||||||
dbg!(&simplexpr_lexer);
|
|
||||||
if simplexpr_lexer.continues_with('}') {
|
if simplexpr_lexer.continues_with('}') {
|
||||||
let start = toks.first().map(|x| x.0).unwrap_or(end);
|
let start = toks.first().map(|x| x.0).unwrap_or(end);
|
||||||
self.pos = end + 1;
|
self.pos = end + 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue