11#include "libxr_rw.hpp"
13#include "semaphore.hpp"
28template <
size_t READ_BUFF_SIZE = 32,
size_t MAX_LINE_SIZE = READ_BUFF_SIZE,
29 size_t MAX_ARG_NUMBER = 5,
size_t MAX_HISTORY_NUMBER = 5>
70 auto len = strlen(str);
71 for (
int i =
static_cast<int>(len - 1); i >= 0; i--)
122 ASSERT(read_port !=
nullptr);
123 ASSERT(write_port !=
nullptr);
124 ASSERT(read_port->Readable());
125 ASSERT(write_port->Writable());
174#include "display.hpp"
180#include "command.hpp"
互斥锁类,提供线程同步机制 (Mutex class providing thread synchronization mechanisms).
基于 BaseQueue 的泛型队列模板类 (Generic queue template class based on BaseQueue).
目录节点片段 / Directory-node fragment
轻量级内存文件系统 / Lightweight in-memory file system
ReadPort class for handling read operations.
static LibXR::WritePort::Stream * write_stream_
Optional externally owned write stream. 可选的外部托管写流。
static LibXR::Mutex * write_mutex_
Write port mutex. 写入端口互斥锁。
static ReadPort * read_
Read port instance. 读取端口。
static WritePort * write_
Write port instance. 写入端口。
线程安全的栈数据结构 / Thread-safe stack data structure
终端类,实现一个基于 RamFS 的基本命令行接口 Terminal class implementing a basic command-line interface based on RamFS
char * arg_tab_[MAX_ARG_NUMBER]
命令参数列表 Command argument list
WritePort * write_port_
写入端口 Write port
static constexpr char KEY_LEFT[]
左箭头键 Left arrow key
size_t arg_number_
参数数量 Number of arguments
uint8_t flag_ansi_
ANSI 控制字符状态 ANSI control character state.
Terminal(LibXR::RamFS &ramfs, RamFS::Dir *current_dir=nullptr, ReadPort *read_port=STDIO::read_, WritePort *write_port=STDIO::write_, Mode MODE=Mode::CRLF)
终端构造函数,初始化文件系统、I/O 端口和当前目录 Constructor to initialize the terminal with file system,...
char linefeed_char_
上一个换行字符 Previous line feed character
ReadPort * read_port_
读取端口 Read port
WriteOperation write_op_
终端写操作 Terminal write operation
Queue< HistoryLine > history_
历史命令 History of commands
static constexpr char KEY_LOAD[]
恢复光标位置 Restore cursor position
char read_buff_[READ_BUFF_SIZE]
读取缓冲区 Read buffer
int history_index_
当前历史索引 Current history index
RamFS & ramfs_
关联的文件系统 Associated file system
WritePort::Stream write_stream_
写入流 Write stream
char * StrchrRev(char *str, char c)
反向查找字符串中的特定字符 Finds a specific character in a string from the end
int offset_
光标偏移 Cursor offset
LibXR::Mutex * write_mutex_
写入端口互斥锁 Write port mutex
WriteOperation::OperationPollingStatus write_status_
当前读/写轮询状态 / Current polling status of the read / write side.
static constexpr char CLEAR_LINE[]
清除当前行命令 Clear current line command
static constexpr char DELETE_CHAR[]
退格删除字符 Backspace delete character
static constexpr char CLEAR_ALL[]
终端控制序列常量 Terminal control-sequence constants
static constexpr char CLEAR_BEHIND[]
清除光标后内容命令 Clear content after cursor command
RamFS::Dir * current_dir_
当前目录 Current directory
Stack< char > input_line_
输入行缓冲区 Input line buffer
size_t request_read_size_
本轮计划读取的字节数 / Byte count requested for the current read attempt.
static constexpr char KEY_SAVE[]
保存光标位置 Save cursor position
Mode
终端换行模式 Line feed modes for the terminal
@ CR
仅回车 Carriage Return (\r)
@ CRLF
回车换行 Carriage Return + Line Feed (\r )
bool linefeed_flag_
CRLF 抑制标志 CRLF suppression flag.
const Mode MODE
终端换行模式 Terminal line feed mode
std::array< char, MAX_LINE_SIZE+1 > HistoryLine
一条历史命令的固定存储单元 Fixed storage slot for one history command line
static constexpr char KEY_RIGHT[]
右箭头键 Right arrow key
WritePort class for handling write operations.