mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 07:06:47 +00:00
bugfix: textui换行后删除字符,无法回退到上一行的问题
This commit is contained in:
parent
8d39334e39
commit
4a6924d7dd
@ -227,25 +227,27 @@ int textui_putchar_window(struct textui_window_t *window, uint16_t character, ui
|
||||
}
|
||||
else if (character == '\b') // 退格
|
||||
{
|
||||
|
||||
--window->vlines.chromatic[window->vline_operating].index;
|
||||
char bufff[128] = {0};
|
||||
--(window->vlines.chromatic[window->vline_operating].index);
|
||||
{
|
||||
uint16_t tmp = window->vlines.chromatic[window->vline_operating].index;
|
||||
window->vlines.chromatic[window->vline_operating].chars[tmp].c = ' ';
|
||||
textui_refresh_characters(window, window->vline_operating, tmp, 1);
|
||||
if (tmp >= 0)
|
||||
{
|
||||
window->vlines.chromatic[window->vline_operating].chars[tmp].c = ' ';
|
||||
textui_refresh_characters(window, window->vline_operating, tmp, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 需要向上缩一行
|
||||
if (window->vlines.chromatic[window->vline_operating].index < 0)
|
||||
if (window->vlines.chromatic[window->vline_operating].index <= 0)
|
||||
{
|
||||
window->vlines.chromatic[window->vline_operating].index = 0;
|
||||
memset(window->vlines.chromatic[window->vline_operating].chars, 0, sizeof(struct textui_char_chromatic_t) * window->chars_per_line);
|
||||
--window->vline_operating;
|
||||
--(window->vline_operating);
|
||||
if (unlikely(window->vline_operating < 0))
|
||||
window->vline_operating = window->vlines_num - 1;
|
||||
|
||||
// 考虑是否向上滚动
|
||||
if (likely(window->vlines_used >= __private_info.actual_line))
|
||||
if (likely(window->vlines_used > __private_info.actual_line))
|
||||
{
|
||||
--window->top_vline;
|
||||
if (unlikely(window->top_vline < 0))
|
||||
@ -256,7 +258,11 @@ int textui_putchar_window(struct textui_window_t *window, uint16_t character, ui
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (window->vlines.chromatic[window->vline_operating].index == window->chars_per_line)
|
||||
__textui_new_line(window, window->vline_operating);
|
||||
__textui_putchar_window(window, character, FRcolor, BKcolor);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&window->lock, rflags);
|
||||
return 0;
|
||||
|
@ -56,7 +56,7 @@ struct textui_vline_normal_t
|
||||
struct textui_vline_chromatic_t
|
||||
{
|
||||
struct textui_char_chromatic_t *chars;
|
||||
uint16_t index; // 当前操作的位置
|
||||
int16_t index; // 当前操作的位置
|
||||
};
|
||||
|
||||
/**
|
||||
@ -68,8 +68,8 @@ struct textui_window_t
|
||||
struct List list;
|
||||
|
||||
uint32_t id; // 窗口id
|
||||
uint16_t vlines_num; // 虚拟行总数
|
||||
uint16_t vlines_used; // 当前已经使用了的虚拟行总数
|
||||
int16_t vlines_num; // 虚拟行总数
|
||||
int16_t vlines_used; // 当前已经使用了的虚拟行总数
|
||||
|
||||
// 指向虚拟行的数组的指针(二选一)
|
||||
union
|
||||
@ -78,16 +78,16 @@ struct textui_window_t
|
||||
struct textui_vline_chromatic_t *chromatic;
|
||||
} vlines;
|
||||
|
||||
uint16_t top_vline; // 位于最顶上的那一个虚拟行的行号
|
||||
uint16_t vline_operating; // 正在操作的vline
|
||||
uint16_t chars_per_line; // 每行最大容纳的字符数
|
||||
int16_t top_vline; // 位于最顶上的那一个虚拟行的行号
|
||||
int16_t vline_operating; // 正在操作的vline
|
||||
int16_t chars_per_line; // 每行最大容纳的字符数
|
||||
uint8_t flags; // 窗口flag
|
||||
spinlock_t lock; // 窗口操作锁
|
||||
};
|
||||
|
||||
struct textui_private_info_t
|
||||
{
|
||||
uint16_t actual_line; // 真实行的数量
|
||||
int16_t actual_line; // 真实行的数量
|
||||
struct textui_window_t *current_window; // 当前的主窗口
|
||||
struct textui_window_t *default_window; // 默认print到的窗口
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user