1 use system_error::SystemError; 2 3 use super::virtual_terminal::virtual_console::{ 4 CursorOperation, ScrollDir, VirtualConsoleData, VirtualConsoleIntensity, 5 }; 6 7 /// 终端切换相关的回调 8 pub trait ConsoleSwitch: Sync + Send { 9 /// 初始化,会对vc_data进行一系列初始化操作 con_init(&self, vc_data: &mut VirtualConsoleData, init: bool) -> Result<(), SystemError>10 fn con_init(&self, vc_data: &mut VirtualConsoleData, init: bool) -> Result<(), SystemError>; 11 12 /// 进行释放等系列操作,目前未使用 con_deinit(&self) -> Result<(), SystemError>13 fn con_deinit(&self) -> Result<(), SystemError>; 14 15 /// ## 清空console的一片区域 16 /// 该函数的所有参数对应的都是以字符为单位 17 /// ### 参数: 18 /// - vc_data: 对应的ConsoleData 19 /// - sy: 对应区域左上角的y轴 20 /// - sx: 对应区域左上角的x轴 21 /// - height: 区域高度 22 /// - width: 区域宽度 con_clear( &self, vc_data: &mut VirtualConsoleData, sy: usize, sx: usize, height: usize, width: usize, ) -> Result<(), SystemError>23 fn con_clear( 24 &self, 25 vc_data: &mut VirtualConsoleData, 26 sy: usize, 27 sx: usize, 28 height: usize, 29 width: usize, 30 ) -> Result<(), SystemError>; 31 32 /// ## 向console输出一个字符 33 /// ### 参数: 34 /// - vc_data: 对应的ConsoleData 35 /// - ch: 数据 36 /// - ypos: 起始y坐标 37 /// - xpos: 起始x坐标 con_putc( &self, vc_data: &VirtualConsoleData, ch: u16, ypos: u32, xpos: u32, ) -> Result<(), SystemError>38 fn con_putc( 39 &self, 40 vc_data: &VirtualConsoleData, 41 ch: u16, 42 ypos: u32, 43 xpos: u32, 44 ) -> Result<(), SystemError>; 45 46 /// ## 向console输出一串字符 47 /// ### 参数: 48 /// - vc_data: 对应的ConsoleData 49 /// - buf: 数据 50 /// - count: 输出字符数量 51 /// - ypos: 起始y坐标 52 /// - xpos: 起始x坐标 con_putcs( &self, vc_data: &VirtualConsoleData, buf: &[u16], count: usize, ypos: u32, xpos: u32, ) -> Result<(), SystemError>53 fn con_putcs( 54 &self, 55 vc_data: &VirtualConsoleData, 56 buf: &[u16], 57 count: usize, 58 ypos: u32, 59 xpos: u32, 60 ) -> Result<(), SystemError>; 61 62 /// ## 根据pos计算出对应xy 63 /// 64 /// ### 返回值: (下一行的起始偏移,x,y) con_getxy( &self, _vc_data: &VirtualConsoleData, _pos: usize, ) -> Result<(usize, usize, usize), SystemError>65 fn con_getxy( 66 &self, 67 _vc_data: &VirtualConsoleData, 68 _pos: usize, 69 ) -> Result<(usize, usize, usize), SystemError> { 70 return Err(SystemError::ENOSYS); 71 } 72 73 /// ## 对光标进行操作 74 /// ### 参数: 75 /// - vc_data: 对应的ConsoleData 76 /// - op: 对光标的操作 con_cursor(&self, vc_data: &VirtualConsoleData, op: CursorOperation)77 fn con_cursor(&self, vc_data: &VirtualConsoleData, op: CursorOperation); 78 79 /// ## 根据参数构建出对应的属性 80 /// ### 参数: 81 /// - vc_data: 对应的ConsoleData 82 /// - color: 颜色 83 /// - intensity: 字符强度 84 /// - blink: 是否闪烁 85 /// - underline: 下划线 86 /// - reverse: 颜色反转 87 /// - italic: 斜体 con_build_attr( &self, _vc_data: &VirtualConsoleData, _color: u8, _intensity: VirtualConsoleIntensity, _blink: bool, _underline: bool, _reverse: bool, _italic: bool, ) -> Result<u8, SystemError>88 fn con_build_attr( 89 &self, 90 _vc_data: &VirtualConsoleData, 91 _color: u8, 92 _intensity: VirtualConsoleIntensity, 93 _blink: bool, 94 _underline: bool, 95 _reverse: bool, 96 _italic: bool, 97 ) -> Result<u8, SystemError> { 98 return Err(SystemError::ENOSYS); 99 } 100 101 /// ## 设置调色板 102 /// ### 参数: 103 /// - vc_data: 对应的ConsoleData 104 /// - color_table: 颜色表 con_set_palette( &self, vc_data: &VirtualConsoleData, color_table: &[u8], ) -> Result<(), SystemError>105 fn con_set_palette( 106 &self, 107 vc_data: &VirtualConsoleData, 108 color_table: &[u8], 109 ) -> Result<(), SystemError>; 110 111 /// ## 滚动 112 /// ### 参数 113 /// - top:滚动范围顶部 114 /// - bottom: 滚动范围底部 115 /// - dir: 滚动方向 116 /// - nr: 滚动行数 con_scroll( &self, vc_data: &mut VirtualConsoleData, top: usize, bottom: usize, dir: ScrollDir, nr: usize, ) -> bool117 fn con_scroll( 118 &self, 119 vc_data: &mut VirtualConsoleData, 120 top: usize, 121 bottom: usize, 122 dir: ScrollDir, 123 nr: usize, 124 ) -> bool; 125 } 126