• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

unrenamed / chatd / 10270375509

06 Aug 2024 04:28PM UTC coverage: 58.471% (+0.4%) from 58.101%
10270375509

push

github

unrenamed
chore: omit workflow generators from test coverage

1446 of 2473 relevant lines covered (58.47%)

1.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/server/session_workflow/emacs_key_exec.rs
1
use async_trait::async_trait;
2
use std::io::Write;
3
use terminal_keycode::KeyCode;
4

5
use crate::auth::Auth;
6
use crate::chat::ChatRoom;
7
use crate::terminal::{CloseHandle, Terminal};
8

9
use super::handler::WorkflowHandler;
10
use super::WorkflowContext;
11

12
pub struct EmacsKeyBindingExecutor<H>
13
where
14
    H: Clone + Write + CloseHandle + Send,
15
{
16
    key: KeyCode,
17
    next: Option<Box<dyn WorkflowHandler<H>>>,
18
}
19

20
impl<H> EmacsKeyBindingExecutor<H>
21
where
22
    H: Clone + Write + CloseHandle + Send,
23
{
24
    pub fn new(key: KeyCode) -> Self {
×
25
        Self { key, next: None }
26
    }
27
}
28

29
#[async_trait]
30
impl<H> WorkflowHandler<H> for EmacsKeyBindingExecutor<H>
31
where
32
    H: Clone + Write + CloseHandle + Send,
33
{
34
    #[allow(unused_variables)]
35
    async fn handle(
36
        &mut self,
37
        context: &mut WorkflowContext,
38
        terminal: &mut Terminal<H>,
39
        room: &mut ChatRoom,
40
        auth: &mut Auth,
41
    ) -> anyhow::Result<()> {
42
        match self.key {
×
43
            KeyCode::Backspace => {
×
44
                terminal.input.delete_prev_character();
×
45
                terminal.print_input_line()?;
×
46
            }
47
            KeyCode::CtrlD => {
×
48
                terminal.input.delete_next_character();
×
49
                terminal.print_input_line()?;
×
50
            }
51
            KeyCode::CtrlW => {
×
52
                terminal.input.kill_prev_word();
×
53
                terminal.print_input_line()?;
×
54
            }
55
            KeyCode::CtrlK => {
×
56
                terminal.input.kill_line_to_end();
×
57
                terminal.print_input_line()?;
×
58
            }
59
            KeyCode::CtrlY => {
×
60
                terminal.input.yank();
×
61
                terminal.print_input_line()?;
×
62
            }
63
            KeyCode::CtrlU => {
×
64
                terminal.clear_input()?;
×
65
            }
66
            KeyCode::CtrlA | KeyCode::CtrlArrowLeft | KeyCode::Home => {
×
67
                terminal.input.go_to_beginning();
×
68
                terminal.print_input_line()?;
×
69
            }
70
            KeyCode::CtrlE | KeyCode::CtrlArrowRight | KeyCode::End => {
×
71
                terminal.input.go_to_end();
×
72
                terminal.print_input_line()?;
×
73
            }
74
            KeyCode::ArrowLeft | KeyCode::CtrlB => {
×
75
                terminal.input.go_backwards_one_character();
×
76
                terminal.print_input_line()?;
×
77
            }
78
            KeyCode::ArrowRight | KeyCode::CtrlF => {
×
79
                terminal.input.go_forward_one_character();
×
80
                terminal.print_input_line()?;
×
81
            }
82
            KeyCode::ArrowUp => {
×
83
                terminal.input.set_history_prev();
×
84
                terminal.print_input_line()?;
×
85
            }
86
            KeyCode::ArrowDown => {
×
87
                terminal.input.set_history_next();
×
88
                terminal.print_input_line()?;
×
89
            }
90
            _ => {}
×
91
        }
92

93
        Ok(())
×
94
    }
95

96
    fn next(&mut self) -> &mut Option<Box<dyn WorkflowHandler<H>>> {
×
97
        &mut self.next
×
98
    }
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc