1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
#![deny(missing_docs)]
//! Preprocess keyboard events for an input method.
//!
//! Enables the generation of keyboard event responses from a keyboard input event in an input method
//! engine.
//! The `afrim-preprocessor` crate is built on the top of the [`afrim-memory`](afrim_memory) crate.
//!
//! # Example
//!
//! ```
//! use afrim_preprocessor::{utils, Command, Preprocessor};
//! use keyboard_types::{
//! webdriver::{self, Event},
//! Key::*,
//! };
//! use std::{collections::VecDeque, rc::Rc};
//!
//! // Prepares the memory.
//! let data = utils::load_data("cc ç");
//! let text_buffer = utils::build_map(data);
//! let memory = Rc::new(text_buffer);
//!
//! // Builds the preprocessor.
//! let mut preprocessor = Preprocessor::new(memory, 8);
//!
//! // Process an input.
//! let input = "cc";
//! webdriver::send_keys(input)
//! .into_iter()
//! .for_each(|event| {
//! match event {
//! // Triggers the generated keyboard input event.
//! Event::Keyboard(event) => preprocessor.process(event),
//! _ => unimplemented!(),
//! };
//! });
//!
//! // Now let's look at the generated commands.
//! // The expected results without `inhibit` feature.
//! #[cfg(not(feature = "inhibit"))]
//! let mut expecteds = VecDeque::from(vec![
//! Command::Pause,
//! Command::Delete,
//! Command::Delete,
//! Command::CommitText("ç".to_owned()),
//! Command::Resume,
//! ]);
//!
//! // The expected results with `inhibit` feature.
//! #[cfg(feature = "inhibit")]
//! let mut expecteds = VecDeque::from(vec![
//! Command::Pause,
//! Command::Delete,
//! Command::Resume,
//! Command::Pause,
//! Command::Delete,
//! Command::CommitText("ç".to_owned()),
//! Command::Resume,
//! ]);
//!
//! // Verification.
//! while let Some(command) = preprocessor.pop_queue() {
//! assert_eq!(command, expecteds.pop_front().unwrap());
//! }
//! ```
//! **Note**: When dealing with non latin languages. The `inhibit` feature allows for the removal of
//! unwanted characters typically latin characters, as much as posssible.
mod message;
pub use crate::message::Command;
pub use afrim_memory::utils;
use afrim_memory::{Cursor, Node};
pub use keyboard_types::{Key, KeyState, KeyboardEvent};
use std::{collections::VecDeque, rc::Rc};
/// The main structure of the preprocessor.
#[derive(Debug)]
pub struct Preprocessor {
cursor: Cursor,
queue: VecDeque<Command>,
}
impl Preprocessor {
/// Initializes a new preprocessor.
///
/// The preprocessor needs a memory to operate. You have two options to build this memory.
/// - Use the [`afrim-memory`](afrim_memory) crate.
/// - Use the [`utils`](crate::utils) module.
/// It also needs you set the capacity of his cursor. We recommend to set a capacity equal
/// or greater than N times the maximun sequence length that you want to handle.
/// Where N is the number of sequences that you want track in the cursor.
///
/// Note that the cursor is the internal memory of the `afrim_preprocessor`.
///
/// # Example
///
/// ```
/// use afrim_preprocessor::{Preprocessor, utils};
/// use std::rc::Rc;
///
/// // We prepare the memory.
/// let data = utils::load_data("uuaf3 ʉ̄ɑ̄");
/// let text_buffer = utils::build_map(data);
/// let memory = Rc::new(text_buffer);
///
/// // We initialize our preprocessor.
/// let preprocessor = Preprocessor::new(memory, 8);
/// ```
pub fn new(memory: Rc<Node>, buffer_size: usize) -> Self {
let cursor = Cursor::new(memory, buffer_size);
let queue = VecDeque::with_capacity(15);
Self { cursor, queue }
}
// Cancel the previous operation.
fn rollback(&mut self) -> bool {
if let Some(out) = self.cursor.undo() {
#[cfg(feature = "inhibit")]
let start = 0;
#[cfg(not(feature = "inhibit"))]
let start = 1;
let end = out.chars().count();
(start..end).for_each(|_| self.queue.push_back(Command::Delete));
// Clear the remaining code
while let (None, 1.., ..) = self.cursor.state() {
self.cursor.undo();
}
if let (Some(_in), ..) = self.cursor.state() {
self.queue.push_back(Command::CommitText(_in));
}
true
} else {
false
}
}
// Cancel the previous operation.
//
// Note that it handles the delete by itself.
#[cfg(not(feature = "inhibit"))]
fn hard_rollback(&mut self) -> bool {
self.queue.push_back(Command::Delete);
self.rollback()
}
// Cancel the previous opeartion.
//
// Note that the delete is supposed already executed.
fn soft_rollback(&mut self) -> bool {
self.queue.push_back(Command::CleanDelete);
self.rollback()
}
/// Preprocess the keyboard input event and returns infos on his internal changes (change on
/// the cursor and/or something to commit).
///
/// It's useful when you process keyboard input events in bulk. Whether there is something that
/// you want to do based on this information, you can decide how to continue.
///
/// # Example
///
/// ```
/// use afrim_preprocessor::{Command, Preprocessor, utils};
/// use keyboard_types::{Key::*, KeyboardEvent};
/// use std::{collections::VecDeque, rc::Rc};
///
/// // We prepare the memory.
/// let data = utils::load_data("i3 ī");
/// let text_buffer = utils::build_map(data);
/// let memory = Rc::new(text_buffer);
///
/// let mut preprocessor = Preprocessor::new(memory, 8);
///
/// // We process the input.
/// // let input = "si3";
///
/// let info = preprocessor.process(KeyboardEvent {
/// key: Character("s".to_string()),
/// ..Default::default()
/// });
/// assert_eq!(info, (true, false));
///
/// let info = preprocessor.process(KeyboardEvent {
/// key: Character("i".to_string()),
/// ..Default::default()
/// });
/// assert_eq!(info, (true, false));
///
/// let info = preprocessor.process(KeyboardEvent {
/// key: Character("3".to_string()),
/// ..Default::default()
/// });
/// assert_eq!(info, (true, true));
///
/// // The input inside the preprocessor.
/// assert_eq!(preprocessor.get_input(), "si3".to_owned());
///
/// // The generated commands.
/// // The expected results without inhibit feature.
/// #[cfg(not(feature = "inhibit"))]
/// let mut expecteds = VecDeque::from(vec![
/// Command::Pause,
/// Command::Delete,
/// Command::Delete,
/// Command::CommitText("ī".to_owned()),
/// Command::Resume,
/// ]);
///
/// // The expected results with inhibit feature.
/// #[cfg(feature = "inhibit")]
/// let mut expecteds = VecDeque::from(vec![
/// Command::Pause,
/// Command::Delete,
/// Command::Resume,
/// Command::Pause,
/// Command::Delete,
/// Command::Resume,
/// Command::Pause,
/// Command::Delete,
/// Command::CommitText("ī".to_owned()),
/// Command::Resume,
/// ]);
///
/// // Verification.
/// while let Some(command) = preprocessor.pop_queue() {
/// dbg!(command.clone());
/// assert_eq!(command, expecteds.pop_front().unwrap());
/// }
/// ```
pub fn process(&mut self, event: KeyboardEvent) -> (bool, bool) {
let (mut changed, mut committed) = (false, false);
match (event.state, event.key) {
(KeyState::Down, Key::Backspace) => {
#[cfg(not(feature = "inhibit"))]
{
self.pause();
committed = self.soft_rollback();
self.resume();
}
#[cfg(feature = "inhibit")]
self.cursor.clear();
changed = true;
}
(KeyState::Down, Key::Character(character))
if character
.chars()
.next()
.map(|e| e.is_alphanumeric() || e.is_ascii_punctuation())
.unwrap_or(false) =>
{
#[cfg(feature = "inhibit")]
self.pause();
#[cfg(feature = "inhibit")]
self.queue.push_back(Command::Delete);
let character = character.chars().next().unwrap();
if let Some(_in) = self.cursor.hit(character) {
#[cfg(not(feature = "inhibit"))]
self.pause();
let mut prev_cursor = self.cursor.clone();
prev_cursor.undo();
#[cfg(not(feature = "inhibit"))]
self.queue.push_back(Command::Delete);
// Remove the remaining code
while let (None, 1.., ..) = prev_cursor.state() {
prev_cursor.undo();
#[cfg(not(feature = "inhibit"))]
self.queue.push_back(Command::Delete);
}
if let (Some(out), ..) = prev_cursor.state() {
(0..out.chars().count()).for_each(|_| self.queue.push_back(Command::Delete))
}
self.queue.push_back(Command::CommitText(_in));
#[cfg(not(feature = "inhibit"))]
self.resume();
committed = true;
};
#[cfg(feature = "inhibit")]
self.resume();
changed = true;
}
(KeyState::Down, Key::Shift | Key::CapsLock) => (),
(KeyState::Down, _) => {
self.cursor.clear();
changed = true;
}
_ => (),
};
(changed, committed)
}
/// Commit a text.
///
/// Generate a command to ensure the commitment of this text.
/// Useful when you want deal with auto-completion.
///
/// **Note**: Before any commitment, the preprocessor make sure to discard the current input.
///
/// # Example
///
/// ```
/// use afrim_preprocessor::{Command, Preprocessor, utils};
/// use keyboard_types::{Key::*, KeyboardEvent};
/// use std::{collections::VecDeque, rc::Rc};
///
/// // We prepare the memory.
/// let data = utils::load_data("i3 ī");
/// let text_buffer = utils::build_map(data);
/// let memory = Rc::new(text_buffer);
///
/// let mut preprocessor = Preprocessor::new(memory, 8);
///
/// // We process the input.
/// // let input = "si3";
/// preprocessor.process(KeyboardEvent {
/// key: Character("s".to_string()),
/// ..Default::default()
/// });
///
/// preprocessor.commit("sī");
///
/// // The generated commands.
/// // The expected results without inhibit feature.
/// #[cfg(not(feature = "inhibit"))]
/// let mut expecteds = VecDeque::from(vec![
/// Command::Pause,
/// Command::Delete,
/// Command::CommitText("sī".to_owned()),
/// Command::Resume,
/// ]);
///
/// // The expected results with inhibit feature.
/// #[cfg(feature = "inhibit")]
/// let mut expecteds = VecDeque::from(vec![
/// Command::Pause,
/// Command::Delete,
/// Command::Resume,
/// Command::Pause,
/// Command::CleanDelete,
/// Command::CommitText("sī".to_owned()),
/// Command::Resume,
/// ]);
///
/// // Verification.
/// while let Some(command) = preprocessor.pop_queue() {
/// assert_eq!(command, expecteds.pop_front().unwrap());
/// }
/// ```
pub fn commit(&mut self, text: &str) {
self.pause();
while !self.cursor.is_empty() {
#[cfg(not(feature = "inhibit"))]
self.hard_rollback();
#[cfg(feature = "inhibit")]
self.soft_rollback();
}
#[cfg(feature = "inhibit")]
self.cursor.clear();
self.queue.push_back(Command::CommitText(text.to_owned()));
self.resume();
// We clear the buffer
self.cursor.clear();
}
// Pauses the keyboard event listerner.
fn pause(&mut self) {
self.queue.push_back(Command::Pause);
}
// Resumes the keyboard event listener.
fn resume(&mut self) {
self.queue.push_back(Command::Resume);
}
/// Returns the input present in the internal memory.
///
/// It's always useful to know what is inside the memory of the preprocessor for debugging.
/// **Note**: The input inside the preprocessor is not always the same than the original because
/// of the limited capacity of his internal cursor.
///
/// # Example
///
/// ```
/// use afrim_preprocessor::{Command, Preprocessor, utils};
/// use keyboard_types::{Key::*, webdriver::{self, Event}};
/// use std::{collections::VecDeque, rc::Rc};
///
/// // We prepare the memory.
/// let data = utils::load_data("i3 ī");
/// let text_buffer = utils::build_map(data);
/// let memory = Rc::new(text_buffer);
///
/// let mut preprocessor = Preprocessor::new(memory, 4);
///
/// // We process the input.
/// let input = "si3";
/// webdriver::send_keys(input)
/// .into_iter()
/// .for_each(|event| {
/// match event {
/// // Triggers the generated keyboard input event.
/// Event::Keyboard(event) => preprocessor.process(event),
/// _ => unimplemented!(),
/// };
/// });
///
/// // The input inside the processor.
/// assert_eq!(preprocessor.get_input(), "si3".to_owned());
pub fn get_input(&self) -> String {
self.cursor
.to_sequence()
.into_iter()
.filter(|c| *c != '\0')
.collect::<String>()
}
/// Returns the next command to be executed.
///
/// The next command is dropped from the queue and can't be returned anymore.
///
/// # Example
///
/// ```
/// use afrim_preprocessor::{Command, Preprocessor, utils};
/// use std::{collections::VecDeque, rc::Rc};
///
/// // We prepare the memory.
/// let text_buffer = utils::build_map(vec![]);
/// let memory = Rc::new(text_buffer);
///
/// let mut preprocessor = Preprocessor::new(memory, 8);
/// preprocessor.commit("hello");
///
/// // The expected results.
/// let mut expecteds = VecDeque::from(vec![
/// Command::Pause,
/// Command::CommitText("hello".to_owned()),
/// Command::Resume,
/// ]);
///
/// // Verification.
/// while let Some(command) = preprocessor.pop_queue() {
/// assert_eq!(command, expecteds.pop_front().unwrap());
/// }
pub fn pop_queue(&mut self) -> Option<Command> {
self.queue.pop_front()
}
/// Clears the queue.
///
/// # Example
///
/// ```
/// use afrim_preprocessor::{Preprocessor, utils};
/// use std::rc::Rc;
///
/// let data =
/// utils::load_data("n* ŋ");
/// let text_buffer = utils::build_map(data);
/// let memory = Rc::new(text_buffer);
///
/// let mut preprocessor = Preprocessor::new(memory, 8);
/// preprocessor.commit("hi");
/// preprocessor.clear_queue();
///
/// assert_eq!(preprocessor.pop_queue(), None);
/// ```
pub fn clear_queue(&mut self) {
self.queue.clear();
}
}
#[cfg(test)]
mod tests {
use crate::message::Command;
use crate::utils;
use crate::Preprocessor;
use keyboard_types::{
webdriver::{self, Event},
Key::*,
};
use std::collections::VecDeque;
#[test]
fn test_process() {
use std::rc::Rc;
let data = utils::load_data("ccced ç\ncc ç");
let memory = utils::build_map(data);
let mut preprocessor = Preprocessor::new(Rc::new(memory), 8);
webdriver::send_keys("ccced").into_iter().for_each(|e| {
match e {
Event::Keyboard(e) => preprocessor.process(e),
_ => unimplemented!(),
};
});
let mut expecteds = VecDeque::from(vec![
// c c
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::CommitText("ç".to_owned()),
Command::Resume,
// c e d
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::Delete,
Command::CommitText("ç".to_owned()),
Command::Resume,
]);
while let Some(command) = preprocessor.pop_queue() {
assert_eq!(command, expecteds.pop_front().unwrap());
}
}
#[test]
fn test_commit() {
use afrim_memory::Node;
use keyboard_types::KeyboardEvent;
let mut preprocessor = Preprocessor::new(Node::default().into(), 8);
preprocessor.process(KeyboardEvent {
key: Character("a".to_owned()),
..Default::default()
});
preprocessor.commit("word");
let mut expecteds = VecDeque::from(vec![
Command::Pause,
#[cfg(feature = "inhibit")]
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
#[cfg(feature = "inhibit")]
Command::CleanDelete,
#[cfg(not(feature = "inhibit"))]
Command::Delete,
Command::CommitText("word".to_owned()),
Command::Resume,
]);
while let Some(command) = preprocessor.pop_queue() {
assert_eq!(command, expecteds.pop_front().unwrap());
}
}
#[test]
fn test_rollback() {
use keyboard_types::KeyboardEvent;
use std::rc::Rc;
let data = utils::load_data("ccced ç\ncc ç");
let memory = utils::build_map(data);
let mut preprocessor = Preprocessor::new(Rc::new(memory), 8);
let backspace_event = KeyboardEvent {
key: Backspace,
..Default::default()
};
webdriver::send_keys("ccced").into_iter().for_each(|e| {
match e {
Event::Keyboard(e) => preprocessor.process(e),
_ => unimplemented!(),
};
});
preprocessor.clear_queue();
assert_eq!(preprocessor.get_input(), "ccced".to_owned());
preprocessor.process(backspace_event.clone());
#[cfg(not(feature = "inhibit"))]
assert_eq!(preprocessor.get_input(), "cc".to_owned());
#[cfg(not(feature = "inhibit"))]
preprocessor.process(backspace_event);
assert_eq!(preprocessor.get_input(), "".to_owned());
let mut expecteds = VecDeque::from(vec![
Command::Pause,
#[cfg(not(feature = "inhibit"))]
Command::CleanDelete,
Command::CommitText("ç".to_owned()),
Command::Resume,
#[cfg(not(feature = "inhibit"))]
Command::Pause,
#[cfg(not(feature = "inhibit"))]
Command::CleanDelete,
#[cfg(not(feature = "inhibit"))]
Command::Resume,
]);
while let Some(command) = preprocessor.pop_queue() {
assert_eq!(command, expecteds.pop_front().unwrap());
}
}
#[test]
fn test_advanced() {
use std::{fs, rc::Rc};
let data = fs::read_to_string("./data/sample.txt").unwrap();
let data = utils::load_data(&data);
let memory = utils::build_map(data);
let mut preprocessor = Preprocessor::new(Rc::new(memory), 64);
webdriver::send_keys(
"u\u{E003}uu\u{E003}uc_ceduuaf3afafaff3uu3\
\u{E003}\u{E003}\u{E003}\u{E003}\u{E003}\u{E003}\u{E003}\u{E003}\u{E003}\u{E003}\u{E003}\u{E003}"
).into_iter().for_each(|e| {
match e {
Event::Keyboard(e) => preprocessor.process(e),
_ => unimplemented!(),
};
});
let mut expecteds = VecDeque::from(vec![
// Process
// u backspace
Command::Pause,
#[cfg(feature = "inhibit")]
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(not(feature = "inhibit"))]
Command::CleanDelete,
#[cfg(not(feature = "inhibit"))]
Command::Resume,
// u u backspace
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::CommitText("ʉ".to_owned()),
Command::Resume,
#[cfg(not(feature = "inhibit"))]
Command::Pause,
#[cfg(not(feature = "inhibit"))]
Command::CleanDelete,
#[cfg(not(feature = "inhibit"))]
Command::Resume,
// u
#[cfg(feature = "inhibit")]
Command::Pause,
#[cfg(feature = "inhibit")]
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
// c _
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::CommitText("ç".to_owned()),
Command::Resume,
// c e d
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::Delete,
Command::CommitText("ç".to_owned()),
Command::Resume,
// u u
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::CommitText("ʉ".to_owned()),
Command::Resume,
// a f 3
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::Delete,
Command::CommitText("ʉ\u{304}ɑ\u{304}".to_owned()),
Command::Resume,
// a f
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::CommitText("ɑ".to_owned()),
Command::Resume,
// a f
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::CommitText("ɑ".to_owned()),
Command::Resume,
// a f
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::CommitText("ɑ".to_owned()),
Command::Resume,
// f
Command::Pause,
Command::Delete,
Command::Delete,
Command::CommitText("ɑɑ".to_owned()),
Command::Resume,
// 3
Command::Pause,
Command::Delete,
Command::Delete,
Command::Delete,
Command::CommitText("ɑ\u{304}ɑ\u{304}".to_owned()),
Command::Resume,
// uu
Command::Pause,
Command::Delete,
#[cfg(feature = "inhibit")]
Command::Resume,
#[cfg(feature = "inhibit")]
Command::Pause,
Command::Delete,
Command::CommitText("ʉ".to_owned()),
Command::Resume,
// 3
Command::Pause,
Command::Delete,
Command::Delete,
Command::CommitText("ʉ\u{304}".to_owned()),
Command::Resume,
// Rollback
Command::Pause,
Command::CleanDelete,
Command::Delete,
Command::CommitText("ʉ".to_owned()),
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Delete,
Command::Delete,
Command::Delete,
Command::CommitText("ɑɑ".to_owned()),
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Delete,
Command::CommitText("ɑ".to_owned()),
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Delete,
Command::Delete,
Command::Delete,
Command::CommitText("ʉ".to_owned()),
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::CommitText("ç".to_owned()),
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Resume,
Command::Pause,
Command::CleanDelete,
Command::Resume,
]);
while let Some(command) = preprocessor.pop_queue() {
assert_eq!(command, expecteds.pop_front().unwrap());
}
}
}