From 869891bbf0babf182f7d50623f1c05d2b81595c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 14 Oct 2025 09:53:13 +0200 Subject: [PATCH] Parse `press` and `release` ice instructions Fixes #3077 --- test/src/instruction.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/src/instruction.rs b/test/src/instruction.rs index 99d0d505..b87086c5 100644 --- a/test/src/instruction.rs +++ b/test/src/instruction.rs @@ -337,7 +337,7 @@ impl fmt::Display for Mouse { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Mouse::Move(target) => { - write!(f, "move cursor to {}", target) + write!(f, "move {}", target) } Mouse::Press { button, target } => { write!( @@ -548,10 +548,9 @@ mod parser { } fn mouse(input: &str) -> IResult<&str, Mouse> { - let mouse_move = - preceded(tag("move cursor to "), target).map(Mouse::Move); + let mouse_move = preceded(tag("move "), target).map(Mouse::Move); - alt((mouse_move, mouse_click)).parse(input) + alt((mouse_move, mouse_click, mouse_press, mouse_release)).parse(input) } fn mouse_click(input: &str) -> IResult<&str, Mouse> { @@ -562,6 +561,22 @@ mod parser { Ok((input, Mouse::Click { button, target })) } + fn mouse_press(input: &str) -> IResult<&str, Mouse> { + let (input, _) = tag("press ")(input)?; + + let (input, (button, target)) = mouse_button_at(input)?; + + Ok((input, Mouse::Press { button, target })) + } + + fn mouse_release(input: &str) -> IResult<&str, Mouse> { + let (input, _) = tag("release ")(input)?; + + let (input, (button, target)) = mouse_button_at(input)?; + + Ok((input, Mouse::Release { button, target })) + } + fn mouse_button_at( input: &str, ) -> IResult<&str, (mouse::Button, Option)> {