From acd85f0a3f58cab5d5e55e696a3f09f808da3b8b Mon Sep 17 00:00:00 2001 From: Sammi De Guzman Date: Wed, 21 Apr 2021 01:32:33 -0700 Subject: [PATCH] Implement word-ending operator --- src/translation.rs | 2 ++ src/translation_model.rs | 1 + src/translation_parse.rs | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/translation.rs b/src/translation.rs index 64336b9..f4ae5b2 100644 --- a/src/translation.rs +++ b/src/translation.rs @@ -218,6 +218,7 @@ fn operator(input: &str) -> IResult<&str, Object> { )), tag("}")))(input)?; Ok((input, match oper { "^" => Object::AttachRaw, + "$" => Object::WordEnd, "*" => Object::RetroToggleStar, "*+" => Object::RepeatLastStroke, "*?" => Object::RetroInsertSpace, @@ -370,6 +371,7 @@ pub fn format_plover_to_rtf(tl: &str) -> String { _ => match obj { Object::Noop => "{\\*\\cxplvrnop}", Object::Cancel => "{\\*\\cxplvrcancel}", + Object::WordEnd => "{\\*\\cxplvrwdend}", Object::DeleteStroke => "\\cxdstroke ", Object::RepeatLastStroke => "{\\*\\cxplvrrpt}", Object::RetroToggleStar => "{\\*\\cxplvrast}", diff --git a/src/translation_model.rs b/src/translation_model.rs index 4f1b5ad..586ec50 100644 --- a/src/translation_model.rs +++ b/src/translation_model.rs @@ -18,6 +18,7 @@ pub enum ParagraphMode { pub enum Object { Cancel, Noop, + WordEnd, DeleteStroke, RepeatLastStroke, RetroToggleStar, diff --git a/src/translation_parse.rs b/src/translation_parse.rs index eae6a0b..a6d8cd9 100644 --- a/src/translation_parse.rs +++ b/src/translation_parse.rs @@ -41,6 +41,7 @@ fn no_arg_group(input: &str) -> IResult<&str, Object> { Ok((input, match label { "cxplvrnop" => Object::Noop, "cxplvrcancel" => Object::Cancel, + "cxplvrwdend" => Object::WordEnd, "cxplvrast" => Object::RetroToggleStar, "cxplvrrpt" => Object::RepeatLastStroke, "cxplvrrtisp" => Object::RetroInsertSpace, @@ -280,6 +281,7 @@ pub fn format_rtf_to_plover(tl: &str) -> String { _ => match obj { Object::Cancel => "{}", Object::Noop => "{#}", + Object::WordEnd => "{$}", Object::DeleteStroke => "=undo", Object::RepeatLastStroke => "{*+}", Object::RetroToggleStar => "{*}",