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