vt100/callbacks.rs
1/// This trait is used by the parser to handle extra escape sequences that
2/// don't have an impact on the terminal screen directly.
3pub trait Callbacks {
4 /// This callback is called when the terminal requests an audible bell
5 /// (typically with `^G`).
6 fn audible_bell(&mut self, _: &mut crate::Screen) {}
7 /// This callback is called when the terminal requests a visual bell
8 /// (typically with `\eg`).
9 fn visual_bell(&mut self, _: &mut crate::Screen) {}
10 /// This callback is called when the terminal requests a resize
11 /// (typically with `\e[8;<rows>;<cols>t`).
12 fn resize(&mut self, _: &mut crate::Screen, _request: (u16, u16)) {}
13 /// This callback is called when the terminal requests the window title
14 /// to be set (typically with `\e]1;<icon_name>\a`)
15 fn set_window_icon_name(
16 &mut self,
17 _: &mut crate::Screen,
18 _icon_name: &[u8],
19 ) {
20 }
21 /// This callback is called when the terminal requests the window title
22 /// to be set (typically with `\e]2;<title>\a`)
23 fn set_window_title(&mut self, _: &mut crate::Screen, _title: &[u8]) {}
24 /// This callback is called when the terminal requests data to be copied
25 /// to the system clipboard (typically with `\e]52;<ty>;<data>\a`). Note
26 /// that `data` will be encoded as base64.
27 fn copy_to_clipboard(
28 &mut self,
29 _: &mut crate::Screen,
30 _ty: &[u8],
31 _data: &[u8],
32 ) {
33 }
34 /// This callback is called when the terminal requests data to be pasted
35 /// from the system clipboard (typically with `\e]52;<ty>;?\a`).
36 fn paste_from_clipboard(&mut self, _: &mut crate::Screen, _ty: &[u8]) {}
37 /// This callback is called when the terminal receives an escape sequence
38 /// which is otherwise not implemented.
39 fn unhandled_char(&mut self, _: &mut crate::Screen, _c: char) {}
40 /// This callback is called when the terminal receives a control
41 /// character which is otherwise not implemented.
42 fn unhandled_control(&mut self, _: &mut crate::Screen, _b: u8) {}
43 /// This callback is called when the terminal receives an escape sequence
44 /// which is otherwise not implemented.
45 fn unhandled_escape(
46 &mut self,
47 _: &mut crate::Screen,
48 _i1: Option<u8>,
49 _i2: Option<u8>,
50 _b: u8,
51 ) {
52 }
53 /// This callback is called when the terminal receives a CSI sequence
54 /// (`\e[`) which is otherwise not implemented.
55 fn unhandled_csi(
56 &mut self,
57 _: &mut crate::Screen,
58 _i1: Option<u8>,
59 _i2: Option<u8>,
60 _params: &[&[u16]],
61 _c: char,
62 ) {
63 }
64 /// This callback is called when the terminal receives a OSC sequence
65 /// (`\e]`) which is otherwise not implemented.
66 fn unhandled_osc(&mut self, _: &mut crate::Screen, _params: &[&[u8]]) {}
67}
68
69impl Callbacks for () {}