libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER > Class Template Reference

终端类,实现一个基于 RamFS 的基本命令行接口 Terminal class implementing a basic command-line interface based on RamFS More...

#include <terminal.hpp>

Collaboration diagram for LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >:

Public Types

enum class  Mode : uint8_t { CRLF = 0 , LF = 1 , CR = 2 }
 终端换行模式 Line feed modes for the terminal More...
 

Public Member Functions

 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, I/O ports, and current directory
 
void LineFeed ()
 执行换行操作 Performs a line feed operation
 
void UpdateDisplayPosition ()
 更新光标位置 Updates cursor position
 
bool CanDisplayChar ()
 检查是否可以显示字符 Checks if a character can be displayed
 
bool CanDeleteChar ()
 检查是否可以删除字符 Checks if a character can be deleted
 
void AddCharToInputLine (char data)
 向输入行中添加字符,支持在光标位置插入 Adds a character to the input line, supports insertion at the cursor position
 
void DisplayChar (char data)
 在终端上显示字符,并根据历史记录模式进行相应操作 Displays a character on the terminal and updates accordingly if history mode is active
 
void RemoveCharFromInputLine ()
 从输入行中删除字符,支持在光标位置删除 Removes a character from the input line, supports deletion at the cursor position
 
void DeleteChar ()
 处理删除字符操作,支持回退删除,并在历史模式下更新显示 Handles the delete character operation, supports backspace deletion, and updates display in history mode
 
void ShowHeader ()
 显示终端提示符,包括当前目录信息 Displays the terminal prompt, including the current directory information
 
void ClearLine ()
 清除当前行 Clears the current line
 
void Clear ()
 清除整个终端屏幕 Clears the entire terminal screen
 
void ShowHistory ()
 显示历史记录中的输入行,更新终端显示 Displays the input line from history and updates the terminal display
 
void CopyHistoryToInputLine ()
 将历史命令复制到输入行,并重置历史索引和光标偏移 Copies the history command to the input line and resets history index and cursor offset
 
void AddHistory ()
 将当前输入行添加到历史记录 Adds the current input line to the history
 
void GetArgs ()
 解析输入行,将其拆分为参数数组 Parses the input line and splits it into argument array
 
RamFS::DirPath2Dir (char *path)
 将路径字符串解析为目录对象 Converts a path string into a directory object
 
RamFS::File * Path2File (char *path)
 将路径字符串解析为文件对象 Converts a path string into a file object
 
void ExecuteCommand ()
 解析并执行输入的命令 Parses and executes the entered command
 
void Parse (RawData &raw_data)
 解析输入数据流,将其转换为字符并处理 Parses the input data stream, converting it into characters and processing them
 
void HandleAnsiCharacter (char data)
 解析输入数据流,将其转换为字符并处理 Parses the input data stream, converting it into characters and processing them
 
void AutoComplete ()
 实现命令自动补全,匹配目录或文件名 Implements command auto-completion by matching directories or file names
 
void HandleControlCharacter (char data)
 处理控制字符,包括换行、删除、制表符等 Handles control characters such as newline, delete, and tab
 
void HandleCharacter (char data)
 处理输入字符,根据类型调用相应的处理函数 Handles input characters, dispatching them to the appropriate handler
 

Static Public Member Functions

static void ThreadFun (Terminal *term)
 终端线程函数,以独立线程方式持续驱动终端 Terminal thread function, continuously drives the terminal as an independent thread
 
static void TaskFun (Terminal *term)
 终端任务函数,以定时器任务方式驱动终端 Terminal task function, drives the terminal using a scheduled task
 

Data Fields

ReadOperation::OperationPollingStatus read_status_
 
WriteOperation::OperationPollingStatus write_status_
 
const Mode MODE
 终端换行模式 Terminal line feed mode
 
WriteOperation write_op_
 终端写操作 Terminal write operation
 
ReadPortread_
 读取端口 Read port
 
WritePortwrite_
 写入端口 Write port
 
RamFSramfs_
 关联的文件系统 Associated file system
 
char read_buff_ [READ_BUFF_SIZE]
 读取缓冲区 Read buffer
 
RamFS::Dircurrent_dir_
 当前目录 Current directory
 
uint8_t flag_ansi_ = 0
 ANSI 控制字符状态 ANSI control character state.
 
int offset_ = 0
 光标偏移 Cursor offset
 
Stack< charinput_line_
 输入行缓冲区 Input line buffer
 
chararg_tab_ [MAX_ARG_NUMBER]
 命令参数列表 Command argument list
 
size_t arg_number_ = 0
 参数数量 Number of arguments
 
Queue< LibXR::String< MAX_LINE_SIZE > > history_
 历史命令 History of commands
 
int history_index_ = -1
 当前历史索引 Current history index
 
bool linefeed_flag_ = false
 换行标志 Line feed flag
 

Private Member Functions

charStrchrRev (char *str, char c)
 反向查找字符串中的特定字符 Finds a specific character in a string from the end
 

Static Private Attributes

static constexpr char CLEAR_ALL []
 清屏命令 Clear screen command
 
static constexpr char CLEAR_LINE []
 清除当前行命令 Clear current line command
 
static constexpr char CLEAR_BEHIND []
 清除光标后内容命令 Clear content after cursor command
 
static constexpr char KEY_RIGHT [] = "\033[C"
 右箭头键 Right arrow key
 
static constexpr char KEY_LEFT [] = "\033[D"
 左箭头键 Left arrow key
 
static constexpr char KEY_SAVE [] = "\033[s"
 保存光标位置 Save cursor position
 
static constexpr char KEY_LOAD [] = "\033[u"
 恢复光标位置 Restore cursor position
 
static constexpr char DELETE_CHAR []
 退格删除字符 Backspace delete character
 

Detailed Description

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
class LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >

终端类,实现一个基于 RamFS 的基本命令行接口 Terminal class implementing a basic command-line interface based on RamFS

Template Parameters
READ_BUFF_SIZE读取缓冲区大小 Read buffer size
MAX_LINE_SIZE最大输入行长度 Maximum input line size
MAX_ARG_NUMBER最大参数数量 Maximum number of arguments
MAX_HISTORY_NUMBER最大历史记录数量 Maximum number of command history records

Definition at line 30 of file terminal.hpp.

Member Enumeration Documentation

◆ Mode

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
enum class LibXR::Terminal::Mode : uint8_t
strong

终端换行模式 Line feed modes for the terminal

Enumerator
CRLF 

回车换行 Carriage Return + Line Feed (\r
)

LF 

仅换行 Line Feed (
)

CR 

仅回车 Carriage Return (\r)

Definition at line 73 of file terminal.hpp.

74 {
75 CRLF = 0,
76 LF = 1,
77 CR = 2
78 };
@ CR
仅回车 Carriage Return (\r)
@ CRLF
回车换行 Carriage Return + Line Feed (\r )
@ LF
仅换行 Line Feed ( )

Constructor & Destructor Documentation

◆ Terminal()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::Terminal ( LibXR::RamFS ramfs,
RamFS::Dir current_dir = nullptr,
ReadPort read_port = STDIO::read_,
WritePort write_port = STDIO::write_,
Mode  MODE = Mode::CRLF 
)
inline

终端构造函数,初始化文件系统、I/O 端口和当前目录 Constructor to initialize the terminal with file system, I/O ports, and current directory

Parameters
ramfs关联的 RamFS 文件系统 Associated RamFS file system
current_dir当前目录(默认为根目录)Current directory (default: root)
read_port读取端口(默认使用标准输入)Read port (default: standard input)
write_port写入端口(默认使用标准输出)Write port (default: standard output)
MODE终端换行模式(默认 CRLF)Terminal line feed mode (default: CRLF)

Definition at line 90 of file terminal.hpp.

93 : read_status_(ReadOperation::OperationPollingStatus::READY),
94 write_status_(WriteOperation::OperationPollingStatus::READY),
95 MODE(MODE),
96 write_op_(write_status_),
97 read_(read_port),
98 write_(write_port),
103 {
104 }
Queue< LibXR::String< MAX_LINE_SIZE > > history_
历史命令 History of commands
Definition terminal.hpp:122
WriteOperation write_op_
终端写操作 Terminal write operation
Definition terminal.hpp:110
RamFS & ramfs_
关联的文件系统 Associated file system
Definition terminal.hpp:113
ReadPort * read_
读取端口 Read port
Definition terminal.hpp:111
WritePort * write_
写入端口 Write port
Definition terminal.hpp:112
RamFS::Dir * current_dir_
当前目录 Current directory
Definition terminal.hpp:116
Stack< char > input_line_
输入行缓冲区 Input line buffer
Definition terminal.hpp:119
const Mode MODE
终端换行模式 Terminal line feed mode
Definition terminal.hpp:109
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Member Function Documentation

◆ AddCharToInputLine()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::AddCharToInputLine ( char  data)
inline

向输入行中添加字符,支持在光标位置插入 Adds a character to the input line, supports insertion at the cursor position

Parameters
data要添加的字符 The character to add

Definition at line 178 of file terminal.hpp.

179 {
180 if (offset_ == 0)
181 {
182 input_line_.Push(data);
183 }
184 else
185 {
187 }
188 input_line_[input_line_.Size()] = '\0';
189 }
ErrorCode Insert(const Data &data, uint32_t index)
在指定位置插入数据 / Inserts data at a specified position
Definition stack.hpp:160
ErrorCode Push(const Data &data)
向栈中推入数据 / Pushes data onto the stack
Definition stack.hpp:72
uint32_t Size() const
获取栈中当前元素数量 / Returns the number of elements currently in the stack
Definition stack.hpp:58
int offset_
光标偏移 Cursor offset
Definition terminal.hpp:118

◆ AddHistory()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::AddHistory ( )
inline

将当前输入行添加到历史记录 Adds the current input line to the history

Definition at line 350 of file terminal.hpp.

351 {
352 input_line_.Push('\0');
353
354 if (history_.EmptySize() == 0)
355 {
356 history_.Pop();
357 }
358 history_.Push(*reinterpret_cast<String<MAX_LINE_SIZE> *>(&input_line_[0]));
359 }

◆ AutoComplete()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::AutoComplete ( )
inline

实现命令自动补全,匹配目录或文件名 Implements command auto-completion by matching directories or file names

Definition at line 627 of file terminal.hpp.

628 {
629 /* skip space */
630 char *path = &input_line_[0];
631 while (*path == ' ')
632 {
633 path++;
634 }
635
636 /* find last '/' in first argument */
637 char *tmp = path, *path_end = path;
638
639 while (*tmp != ' ' && *tmp != '\0')
640 {
641 if (*tmp == '/')
642 {
643 path_end = tmp;
644 }
645 tmp++;
646 }
647
648 /* return if not need complete */
649 if (tmp - &input_line_[0] != static_cast<int>(input_line_.Size() + offset_))
650 {
651 return;
652 }
653
654 /* get start of prefix */
655 char *prefix_start = nullptr;
656 RamFS::Dir *dir = nullptr;
657
658 if (path_end == path)
659 {
662 }
663 else
664 {
666 }
667
668 /* find dir*/
669 if (dir == nullptr)
670 {
671 *path_end = '\0';
672 dir = Path2Dir(path);
673 *path_end = '/';
674 if (dir == nullptr)
675 {
676 return;
677 }
678 }
679
680 /* prepre for match */
681 RBTree<const char *>::Node<RamFS::FsNode> *ans_node = nullptr;
682 uint32_t number = 0;
683 size_t same_char_number = 0;
684
685 if (*prefix_start == '/')
686 {
687 prefix_start++;
688 }
689
690 int prefix_len = static_cast<int>(tmp - prefix_start);
691
692 auto foreach_fun_find = [&](RBTree<const char *>::Node<RamFS::FsNode> &node)
693 {
694 if (strncmp(node->name, prefix_start, prefix_len) == 0)
695 {
696 ans_node = &node;
697 number++;
698 }
699
700 return ErrorCode::OK;
701 };
702
703 /* start match */
704 (*dir)->rbt.Foreach<RamFS::FsNode>(foreach_fun_find);
705
706 if (number == 0)
707 {
708 return;
709 }
710 else if (number == 1)
711 {
712 auto name_len = strlen(ans_node->data_.name);
713 for (size_t i = 0; i < name_len - prefix_len; i++)
714 {
715 DisplayChar(ans_node->data_.name[i + prefix_len]);
716 }
717 }
718 else
719 {
720 ans_node = nullptr;
721 LineFeed();
722
723 auto foreach_fun_show = [&](RBTree<const char *>::Node<RamFS::FsNode> &node)
724 {
725 if (strncmp(node->name, prefix_start, prefix_len) == 0)
726 {
727 auto name_len = strlen(node->name);
728 (*this->write_)(ConstRawData(node->name, name_len), this->write_op_);
729 this->LineFeed();
730 if (ans_node == nullptr)
731 {
732 ans_node = &node;
734 return ErrorCode::OK;
735 }
736
737 for (size_t i = 0; i < name_len; i++)
738 {
739 if (node->name[i] != ans_node->data_.name[i])
740 {
742 break;
743 }
744 }
745
747 {
749 }
750
751 ans_node = &node;
752 }
753
754 return ErrorCode::OK;
755 };
756
757 (*dir)->rbt.Foreach<RamFS::FsNode>(foreach_fun_show);
758
759 ShowHeader();
760 (*write_)(ConstRawData(&input_line_[0], input_line_.Size()), write_op_);
761
762 for (size_t i = 0; i < same_char_number - prefix_len; i++)
763 {
764 DisplayChar(ans_node->data_.name[i + prefix_len]);
765 }
766 }
767 }
RamFS::Dir * Path2Dir(char *path)
将路径字符串解析为目录对象 Converts a path string into a directory object
Definition terminal.hpp:391
void DisplayChar(char data)
在终端上显示字符,并根据历史记录模式进行相应操作 Displays a character on the terminal and updates accordingly if history mode...
Definition terminal.hpp:197
void LineFeed()
执行换行操作 Performs a line feed operation
Definition terminal.hpp:130
void ShowHeader()
显示终端提示符,包括当前目录信息 Displays the terminal prompt, including the current directory information
Definition terminal.hpp:281

◆ CanDeleteChar()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
bool LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::CanDeleteChar ( )
inline

检查是否可以删除字符 Checks if a character can be deleted

Returns
bool 是否可以删除字符 Whether the character can be deleted

Definition at line 171 of file terminal.hpp.

171{ return input_line_.Size() + offset_ > 0; }

◆ CanDisplayChar()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
bool LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::CanDisplayChar ( )
inline

检查是否可以显示字符 Checks if a character can be displayed

Returns
bool 是否可以显示字符 Whether the character can be displayed

Definition at line 164 of file terminal.hpp.

164{ return input_line_.EmptySize() > 1; }
uint32_t EmptySize() const
获取栈的剩余可用空间 / Returns the remaining available space in the stack
Definition stack.hpp:63

◆ Clear()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::Clear ( )
inline

清除整个终端屏幕 Clears the entire terminal screen

Definition at line 307 of file terminal.hpp.

307{ (*write_)(ConstRawData(CLEAR_ALL), write_op_); }
static constexpr char CLEAR_ALL[]
清屏命令 Clear screen command
Definition terminal.hpp:33

◆ ClearLine()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::ClearLine ( )
inline

清除当前行 Clears the current line

Definition at line 301 of file terminal.hpp.

301{ (*write_)(ConstRawData(CLEAR_LINE), write_op_); }
static constexpr char CLEAR_LINE[]
清除当前行命令 Clear current line command
Definition terminal.hpp:35

◆ CopyHistoryToInputLine()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::CopyHistoryToInputLine ( )
inline

将历史命令复制到输入行,并重置历史索引和光标偏移 Copies the history command to the input line and resets history index and cursor offset

Definition at line 335 of file terminal.hpp.

336 {
338 for (size_t i = 0; i < history_[-history_index_ - 1].Length(); i++)
339 {
341 }
342 history_index_ = -1;
343 offset_ = 0;
344 }
void Reset()
重置栈 / Resets the stack
Definition stack.hpp:219
int history_index_
当前历史索引 Current history index
Definition terminal.hpp:123

◆ DeleteChar()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::DeleteChar ( )
inline

处理删除字符操作,支持回退删除,并在历史模式下更新显示 Handles the delete character operation, supports backspace deletion, and updates display in history mode

Definition at line 248 of file terminal.hpp.

249 {
250 bool use_history = false;
251
252 if (history_index_ >= 0)
253 {
255 use_history = true;
256 }
257
258 if (CanDeleteChar())
259 {
261 if (use_history)
262 {
263 ShowHistory();
264 }
265 else
266 {
267 (*write_)(ConstRawData(DELETE_CHAR), write_op_);
268 }
269
270 if (offset_ != 0)
271 {
273 }
274 }
275 }
void UpdateDisplayPosition()
更新光标位置 Updates cursor position
Definition terminal.hpp:150
bool CanDeleteChar()
检查是否可以删除字符 Checks if a character can be deleted
Definition terminal.hpp:171
void CopyHistoryToInputLine()
将历史命令复制到输入行,并重置历史索引和光标偏移 Copies the history command to the input line and resets history index and cu...
Definition terminal.hpp:335
void ShowHistory()
显示历史记录中的输入行,更新终端显示 Displays the input line from history and updates the terminal display
Definition terminal.hpp:313
static constexpr char DELETE_CHAR[]
退格删除字符 Backspace delete character
Definition terminal.hpp:43
void RemoveCharFromInputLine()
从输入行中删除字符,支持在光标位置删除 Removes a character from the input line, supports deletion at the cursor position
Definition terminal.hpp:230

◆ DisplayChar()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::DisplayChar ( char  data)
inline

在终端上显示字符,并根据历史记录模式进行相应操作 Displays a character on the terminal and updates accordingly if history mode is active

Parameters
data要显示的字符 The character to display

Definition at line 197 of file terminal.hpp.

198 {
199 bool use_history = false;
200
201 if (history_index_ >= 0)
202 {
204 use_history = true;
205 }
206
207 if (CanDisplayChar())
208 {
209 AddCharToInputLine(data);
210 if (use_history)
211 {
212 ShowHistory();
213 }
214 else
215 {
216 (*write_)(ConstRawData(input_line_[input_line_.Size() - 1 + offset_]), write_op_);
217 }
218 if (offset_ != 0)
219 {
221 }
222 }
223 }
bool CanDisplayChar()
检查是否可以显示字符 Checks if a character can be displayed
Definition terminal.hpp:164
void AddCharToInputLine(char data)
向输入行中添加字符,支持在光标位置插入 Adds a character to the input line, supports insertion at the cursor position
Definition terminal.hpp:178

◆ ExecuteCommand()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::ExecuteCommand ( )
inline

解析并执行输入的命令 Parses and executes the entered command

Definition at line 467 of file terminal.hpp.

468 {
469 AddHistory();
470
471 GetArgs();
472
474 {
475 return;
476 }
477
478 if (strcmp(arg_tab_[0], "cd") == 0)
479 {
480 RamFS::Dir *dir = Path2Dir(arg_tab_[1]);
481 if (dir != nullptr)
482 {
484 }
485 LineFeed();
486 return;
487 }
488
489 if (strcmp(arg_tab_[0], "ls") == 0)
490 {
491 auto ls_fun = [&](RBTree<const char *>::Node<RamFS::FsNode> &item)
492 {
493 switch (item->type)
494 {
496 (*(this->write_))(ConstRawData("d "), this->write_op_);
497 break;
499 (*(this->write_))(ConstRawData("f "), this->write_op_);
500 break;
502 (*(this->write_))(ConstRawData("c "), this->write_op_);
503 break;
505 (*(this->write_))(ConstRawData("b "), this->write_op_);
506 break;
507 default:
508 (*(this->write_))(ConstRawData("? "), this->write_op_);
509 break;
510 }
511 (*(this->write_))(ConstRawData(item.data_.name), this->write_op_);
512 this->LineFeed();
513 return ErrorCode::OK;
514 };
515
516 current_dir_->data_.rbt.Foreach<RamFS::FsNode>(ls_fun);
517 return;
518 }
519
520 auto ans = Path2File(arg_tab_[0]);
521 if (ans == nullptr)
522 {
523 (*write_)(ConstRawData("Command not found."), write_op_);
524 LineFeed();
525 return;
526 }
527
528 if ((*ans)->type != RamFS::FileType::EXEC)
529 {
530 (*write_)(ConstRawData("Not an executable file."), write_op_);
531 LineFeed();
532 return;
533 }
534
535 (*ans)->Run(arg_number_, arg_tab_);
536 }
Data data_
存储的数据 (Stored data).
Definition rbt.hpp:99
@ STORAGE
存储 Storage
@ DIR
目录 Directory
@ EXEC
可执行 Executable
char * arg_tab_[MAX_ARG_NUMBER]
命令参数列表 Command argument list
Definition terminal.hpp:120
size_t arg_number_
参数数量 Number of arguments
Definition terminal.hpp:121
void AddHistory()
将当前输入行添加到历史记录 Adds the current input line to the history
Definition terminal.hpp:350
RamFS::File * Path2File(char *path)
将路径字符串解析为文件对象 Converts a path string into a file object
Definition terminal.hpp:436
void GetArgs()
解析输入行,将其拆分为参数数组 Parses the input line and splits it into argument array
Definition terminal.hpp:365

◆ GetArgs()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::GetArgs ( )
inline

解析输入行,将其拆分为参数数组 Parses the input line and splits it into argument array

Definition at line 365 of file terminal.hpp.

366 {
367 for (int i = 0; input_line_[i] != '\0'; i++)
368 {
369 if (input_line_[i] == ' ')
370 {
371 input_line_[i] = '\0';
372 }
373 else if (i == 0 || input_line_[i - 1] == '\0')
374 {
376 {
377 return;
378 }
380 }
381 }
382 }

◆ HandleAnsiCharacter()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::HandleAnsiCharacter ( char  data)
inline

解析输入数据流,将其转换为字符并处理 Parses the input data stream, converting it into characters and processing them

Parameters
raw_data输入的原始数据 Input raw data

Definition at line 559 of file terminal.hpp.

560 {
561 if (flag_ansi_ == 1)
562 {
563 if (isprint(data))
564 {
565 flag_ansi_++;
566 }
567 else
568 {
569 flag_ansi_ = 0;
570 }
571 }
572 else if (flag_ansi_ == 2)
573 {
574 switch (data)
575 {
576 case 'A':
577 if (history_index_ < int(history_.Size()) - 1)
578 {
580 ShowHistory();
581 }
582 break;
583 case 'B':
584 if (history_index_ >= 0)
585 {
587 ShowHistory();
588 }
589 break;
590 case 'C':
591 if (history_index_ >= 0)
592 {
594 ShowHistory();
595 }
596 if (offset_ < 0)
597 {
598 offset_++;
599 (*write_)(ConstRawData(KEY_RIGHT, sizeof(KEY_RIGHT) - 1), write_op_);
600 }
601
602 break;
603 case 'D':
604 if (history_index_ >= 0)
605 {
607 ShowHistory();
608 }
609 if (offset_ + input_line_.Size() > 0)
610 {
611 offset_--;
612 (*write_)(ConstRawData(KEY_LEFT, sizeof(KEY_LEFT) - 1), write_op_);
613 }
614 break;
615 default:
616 break;
617 }
618
619 flag_ansi_ = 0;
620 }
621 }
static constexpr char KEY_LEFT[]
左箭头键 Left arrow key
Definition terminal.hpp:40
uint8_t flag_ansi_
ANSI 控制字符状态 ANSI control character state.
Definition terminal.hpp:117
static constexpr char KEY_RIGHT[]
右箭头键 Right arrow key
Definition terminal.hpp:39

◆ HandleCharacter()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::HandleCharacter ( char  data)
inline

处理输入字符,根据类型调用相应的处理函数 Handles input characters, dispatching them to the appropriate handler

Parameters
data输入的字符 The input character

Definition at line 824 of file terminal.hpp.

825 {
826 if (flag_ansi_)
827 {
829 }
830 else if (isprint(data))
831 {
832 DisplayChar(data);
833 }
834 else
835 {
837 }
838 }
void HandleAnsiCharacter(char data)
解析输入数据流,将其转换为字符并处理 Parses the input data stream, converting it into characters and processing them
Definition terminal.hpp:559
void HandleControlCharacter(char data)
处理控制字符,包括换行、删除、制表符等 Handles control characters such as newline, delete, and tab
Definition terminal.hpp:774

◆ HandleControlCharacter()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::HandleControlCharacter ( char  data)
inline

处理控制字符,包括换行、删除、制表符等 Handles control characters such as newline, delete, and tab

Parameters
data输入的控制字符 The input control character

Definition at line 774 of file terminal.hpp.

775 {
776 if (data != '\r' && data != '\n')
777 {
778 linefeed_flag_ = false;
779 }
780
781 switch (data)
782 {
783 case '\n':
784 case '\r':
785 if (linefeed_flag_)
786 {
787 linefeed_flag_ = false;
788 return;
789 }
790 if (history_index_ >= 0)
791 {
793 }
794 LineFeed();
795 if (input_line_.Size() > 0)
796 {
798 arg_number_ = 0;
799 }
800 ShowHeader();
802 input_line_[0] = '\0';
803 offset_ = 0;
804 break;
805 case 0x7f:
806 DeleteChar();
807 break;
808 case '\t':
809 AutoComplete();
810 break;
811 case '\033':
812 flag_ansi_ = 1;
813 break;
814 default:
815 break;
816 }
817 }
void AutoComplete()
实现命令自动补全,匹配目录或文件名 Implements command auto-completion by matching directories or file names
Definition terminal.hpp:627
void ExecuteCommand()
解析并执行输入的命令 Parses and executes the entered command
Definition terminal.hpp:467
void DeleteChar()
处理删除字符操作,支持回退删除,并在历史模式下更新显示 Handles the delete character operation, supports backspace deletion,...
Definition terminal.hpp:248
bool linefeed_flag_
换行标志 Line feed flag
Definition terminal.hpp:124

◆ LineFeed()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::LineFeed ( )
inline

执行换行操作 Performs a line feed operation

Definition at line 130 of file terminal.hpp.

131 {
132 if (MODE == Mode::CRLF)
133 {
134 (*write_)(ConstRawData("\r\n"), write_op_);
135 }
136 else if (MODE == Mode::LF)
137 {
138 (*write_)(ConstRawData('\n'), write_op_);
139 }
140 else if (MODE == Mode::CR)
141 {
142 (*write_)(ConstRawData('\r'), write_op_);
143 }
144 }

◆ Parse()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::Parse ( RawData raw_data)
inline

解析输入数据流,将其转换为字符并处理 Parses the input data stream, converting it into characters and processing them

Parameters
raw_data输入的原始数据 Input raw data

Definition at line 544 of file terminal.hpp.

545 {
546 char *buff = static_cast<char *>(raw_data.addr_);
547 for (size_t i = 0; i < raw_data.size_; i++)
548 {
549 HandleCharacter(buff[i]);
550 }
551 }
void HandleCharacter(char data)
处理输入字符,根据类型调用相应的处理函数 Handles input characters, dispatching them to the appropriate handler
Definition terminal.hpp:824

◆ Path2Dir()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
RamFS::Dir * LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::Path2Dir ( char path)
inline

将路径字符串解析为目录对象 Converts a path string into a directory object

Parameters
path目录路径字符串 The directory path string
Returns
RamFS::Dir* 解析出的目录指针,若找不到则返回 nullptr Pointer to the resolved directory, or nullptr if not found

Definition at line 391 of file terminal.hpp.

392 {
393 size_t index = 0;
394 RamFS::Dir *dir = current_dir_;
395
396 if (*path == '/')
397 {
398 index++;
399 dir = &ramfs_.root_;
400 }
401
402 for (size_t i = 0; i < MAX_LINE_SIZE; i++)
403 {
404 auto tmp = strchr(path + index, '/');
405 if (tmp == nullptr)
406 {
407 return dir->FindDir(path + index);
408 }
409 else if (tmp == path + index)
410 {
411 return nullptr;
412 }
413 else
414 {
415 tmp[0] = '\0';
416 dir = dir->FindDir(path + index);
417 tmp[0] = '/';
418 index += tmp - path + 1;
419 if (path[index] == '\0' || dir == nullptr)
420 {
421 return dir;
422 }
423 }
424 }
425
426 return nullptr;
427 }
Dir root_
文件系统的根目录 Root directory of the file system
Definition ramfs.hpp:624

◆ Path2File()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
RamFS::File * LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::Path2File ( char path)
inline

将路径字符串解析为文件对象 Converts a path string into a file object

Parameters
path文件路径字符串 The file path string
Returns
RamFS::File* 解析出的文件指针,若找不到则返回 nullptr Pointer to the resolved file, or nullptr if not found

Definition at line 436 of file terminal.hpp.

437 {
438 auto name = StrchrRev(path, '/');
439
440 if (name == nullptr)
441 {
442 return current_dir_->FindFile(path);
443 }
444
445 if (name[1] == '\0')
446 {
447 return nullptr;
448 }
449
450 *name = '\0';
451 RamFS::Dir *dir = Path2Dir(path);
452 *name = '/';
453 if (dir != nullptr)
454 {
455 return dir->FindFile(name + 1);
456 }
457 else
458 {
459 return nullptr;
460 }
461 }
File * FindFile(const char *name)
查找当前目录中的文件 Finds a file in the current directory
Definition ramfs.hpp:290
char * StrchrRev(char *str, char c)
反向查找字符串中的特定字符 Finds a specific character in a string from the end
Definition terminal.hpp:54

◆ RemoveCharFromInputLine()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::RemoveCharFromInputLine ( )
inline

从输入行中删除字符,支持在光标位置删除 Removes a character from the input line, supports deletion at the cursor position

Definition at line 230 of file terminal.hpp.

231 {
232 if (offset_ == 0)
233 {
235 }
236 else
237 {
239 }
240 input_line_[input_line_.Size()] = '\0';
241 }
ErrorCode Delete(uint32_t index)
删除指定位置的数据 / Deletes data at a specified position
Definition stack.hpp:195
ErrorCode Pop(Data &data)
从栈中弹出数据 / Pops data from the stack
Definition stack.hpp:93

◆ ShowHeader()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::ShowHeader ( )
inline

显示终端提示符,包括当前目录信息 Displays the terminal prompt, including the current directory information

Definition at line 281 of file terminal.hpp.

282 {
283 (*write_)(ConstRawData(ramfs_.root_->name, strlen(ramfs_.root_->name)), write_op_);
284 if (current_dir_ == &ramfs_.root_)
285 {
286 (*write_)(ConstRawData(":/"), write_op_);
287 }
288 else
289 {
290 (*write_)(ConstRawData(":"), write_op_);
291 (*write_)(ConstRawData(current_dir_->data_.name), write_op_);
292 }
293
294 (*write_)(ConstRawData("$ "), write_op_);
295 }

◆ ShowHistory()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::ShowHistory ( )
inline

显示历史记录中的输入行,更新终端显示 Displays the input line from history and updates the terminal display

Definition at line 313 of file terminal.hpp.

314 {
315 ClearLine();
316 ShowHeader();
317 offset_ = 0;
318 if (history_index_ >= 0)
319 {
320 (*write_)(ConstRawData(history_[-history_index_ - 1].Raw(),
321 history_[-history_index_ - 1].Length()),
322 write_op_);
323 }
324 else
325 {
326 (*write_)(ConstRawData(&input_line_[0], input_line_.Size()), write_op_);
327 }
328 }
void ClearLine()
清除当前行 Clears the current line
Definition terminal.hpp:301

◆ StrchrRev()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
char * LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::StrchrRev ( char str,
char  c 
)
inlineprivate

反向查找字符串中的特定字符 Finds a specific character in a string from the end

Parameters
str输入字符串 Input string
c要查找的字符 Character to find
Returns
char* 指向找到的字符的指针,如果未找到返回 nullptr Pointer to the found character, nullptr if not found

Definition at line 54 of file terminal.hpp.

55 {
56 auto len = strlen(str);
57 for (int i = static_cast<int>(len - 1); i >= 0; i--)
58 {
59 if (str[i] == c)
60 {
61 return str + i;
62 }
63 }
64 return nullptr;
65 }

◆ TaskFun()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
static void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::TaskFun ( Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER > *  term)
inlinestatic

终端任务函数,以定时器任务方式驱动终端 Terminal task function, drives the terminal using a scheduled task

该函数用于以定时任务(或轮询方式)驱动终端,适用于资源受限的系统。 它不会持续运行,而是在定时器触发或系统任务调度时运行,执行一次数据读取和解析后返回。

This function drives the terminal using a scheduled task (or polling mode), making it suitable for resource-constrained systems. Unlike the thread-based approach, it only runs when scheduled (e.g., triggered by a timer) and processes available input data before returning.

Parameters
term指向 Terminal 实例的指针 Pointer to the Terminal instance

Definition at line 890 of file terminal.hpp.

891 {
892 RawData buff = term->read_buff_;
893 buff.size_ = LibXR::min(LibXR::max(1u, term->read_->Size()), READ_BUFF_SIZE);
894
895 ReadOperation op(term->read_status_);
896
897 while (true)
898 {
899 switch (term->read_status_)
900 {
901 case ReadOperation::OperationPollingStatus::READY:
902 buff.size_ = LibXR::min(LibXR::max(1u, term->read_->Size()), READ_BUFF_SIZE);
903 (*term->read_)(buff, op);
904 continue;
905 case ReadOperation::OperationPollingStatus::RUNNING:
906 return;
907 case ReadOperation::OperationPollingStatus::DONE:
908 buff.size_ = term->read_->read_size_;
909 if (buff.size_ > 0)
910 {
911 term->Parse(buff);
912 }
913 buff.size_ = LibXR::min(LibXR::max(1u, term->read_->Size()), READ_BUFF_SIZE);
914 (*term->read_)(buff, op);
915 return;
916 }
917 }
918 }
Operation< ErrorCode > ReadOperation
Read operation type.
Definition libxr_rw.hpp:267
constexpr auto max(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最大值

◆ ThreadFun()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
static void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::ThreadFun ( Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER > *  term)
inlinestatic

终端线程函数,以独立线程方式持续驱动终端 Terminal thread function, continuously drives the terminal as an independent thread

该函数用于以独立线程的方式驱动终端,持续从输入流读取数据并解析,适用于高实时性应用。 它会在循环中不断检查输入流的大小,并在数据可用时进行解析。

This function runs as a separate thread to continuously drive the terminal, reading and parsing input data in a loop. It is suitable for high real-time applications. It continuously checks the input stream size and processes data when available.

Parameters
term指向 Terminal 实例的指针 Pointer to the Terminal instance

Definition at line 856 of file terminal.hpp.

857 {
858 RawData buff = term->read_buff_;
859 buff.size_ = LibXR::min(LibXR::max(1u, term->read_->Size()), READ_BUFF_SIZE);
860
861 Semaphore sem;
862 ReadOperation op(sem);
863
864 while (true)
865 {
866 buff.size_ = LibXR::min(LibXR::max(1u, term->read_->Size()), READ_BUFF_SIZE);
867 if ((*term->read_)(buff, op) == ErrorCode::OK)
868 {
869 buff.size_ = term->read_->read_size_;
870 term->Parse(buff);
871 }
872 }
873 }

◆ UpdateDisplayPosition()

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
void LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::UpdateDisplayPosition ( )
inline

更新光标位置 Updates cursor position

Definition at line 150 of file terminal.hpp.

151 {
152 (*write_)(ConstRawData(KEY_SAVE), write_op_);
153 (*write_)(ConstRawData(CLEAR_BEHIND), write_op_);
154 (*write_)(ConstRawData(&input_line_[input_line_.Size() + offset_], -offset_),
155 write_op_);
156 (*write_)(ConstRawData(KEY_LOAD), write_op_);
157 }
static constexpr char KEY_LOAD[]
恢复光标位置 Restore cursor position
Definition terminal.hpp:42
static constexpr char CLEAR_BEHIND[]
清除光标后内容命令 Clear content after cursor command
Definition terminal.hpp:37
static constexpr char KEY_SAVE[]
保存光标位置 Save cursor position
Definition terminal.hpp:41

Field Documentation

◆ arg_number_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
size_t LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::arg_number_ = 0

参数数量 Number of arguments

Definition at line 121 of file terminal.hpp.

◆ arg_tab_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
char* LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::arg_tab_[MAX_ARG_NUMBER]

命令参数列表 Command argument list

Definition at line 120 of file terminal.hpp.

◆ CLEAR_ALL

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
constexpr char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::CLEAR_ALL[]
staticconstexprprivate
Initial value:
=
"\033[2J\033[1H"

清屏命令 Clear screen command

Definition at line 33 of file terminal.hpp.

◆ CLEAR_BEHIND

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
constexpr char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::CLEAR_BEHIND[]
staticconstexprprivate
Initial value:
=
"\033[K"

清除光标后内容命令 Clear content after cursor command

Definition at line 37 of file terminal.hpp.

◆ CLEAR_LINE

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
constexpr char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::CLEAR_LINE[]
staticconstexprprivate
Initial value:
=
"\033[2K\r"

清除当前行命令 Clear current line command

Definition at line 35 of file terminal.hpp.

◆ current_dir_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
RamFS::Dir* LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::current_dir_

当前目录 Current directory

Definition at line 116 of file terminal.hpp.

◆ DELETE_CHAR

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
constexpr char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::DELETE_CHAR[]
staticconstexprprivate
Initial value:
=
"\b \b"

退格删除字符 Backspace delete character

Definition at line 43 of file terminal.hpp.

◆ flag_ansi_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
uint8_t LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::flag_ansi_ = 0

ANSI 控制字符状态 ANSI control character state.

Definition at line 117 of file terminal.hpp.

◆ history_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
Queue<LibXR::String<MAX_LINE_SIZE> > LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::history_

历史命令 History of commands

Definition at line 122 of file terminal.hpp.

◆ history_index_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
int LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::history_index_ = -1

当前历史索引 Current history index

Definition at line 123 of file terminal.hpp.

◆ input_line_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
Stack<char> LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::input_line_

输入行缓冲区 Input line buffer

Definition at line 119 of file terminal.hpp.

◆ KEY_LEFT

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
constexpr char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::KEY_LEFT[] = "\033[D"
staticconstexprprivate

左箭头键 Left arrow key

Definition at line 40 of file terminal.hpp.

◆ KEY_LOAD

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
constexpr char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::KEY_LOAD[] = "\033[u"
staticconstexprprivate

恢复光标位置 Restore cursor position

Definition at line 42 of file terminal.hpp.

◆ KEY_RIGHT

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
constexpr char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::KEY_RIGHT[] = "\033[C"
staticconstexprprivate

右箭头键 Right arrow key

Definition at line 39 of file terminal.hpp.

◆ KEY_SAVE

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
constexpr char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::KEY_SAVE[] = "\033[s"
staticconstexprprivate

保存光标位置 Save cursor position

Definition at line 41 of file terminal.hpp.

◆ linefeed_flag_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
bool LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::linefeed_flag_ = false

换行标志 Line feed flag

Definition at line 124 of file terminal.hpp.

◆ MODE

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
const Mode LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::MODE

终端换行模式 Terminal line feed mode

Definition at line 109 of file terminal.hpp.

◆ offset_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
int LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::offset_ = 0

光标偏移 Cursor offset

Definition at line 118 of file terminal.hpp.

◆ ramfs_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
RamFS& LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::ramfs_

关联的文件系统 Associated file system

Definition at line 113 of file terminal.hpp.

◆ read_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
ReadPort* LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::read_

读取端口 Read port

Definition at line 111 of file terminal.hpp.

◆ read_buff_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
char LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::read_buff_[READ_BUFF_SIZE]

读取缓冲区 Read buffer

Definition at line 114 of file terminal.hpp.

◆ read_status_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
ReadOperation::OperationPollingStatus LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::read_status_

Definition at line 106 of file terminal.hpp.

◆ write_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
WritePort* LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::write_

写入端口 Write port

Definition at line 112 of file terminal.hpp.

◆ write_op_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
WriteOperation LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::write_op_

终端写操作 Terminal write operation

Definition at line 110 of file terminal.hpp.

◆ write_status_

template<size_t READ_BUFF_SIZE = 32, size_t MAX_LINE_SIZE = READ_BUFF_SIZE, size_t MAX_ARG_NUMBER = 5, size_t MAX_HISTORY_NUMBER = 5>
WriteOperation::OperationPollingStatus LibXR::Terminal< READ_BUFF_SIZE, MAX_LINE_SIZE, MAX_ARG_NUMBER, MAX_HISTORY_NUMBER >::write_status_

Definition at line 107 of file terminal.hpp.


The documentation for this class was generated from the following file: