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