I'm trying to make a function who clean an area on the screen. Here is my function :
我正在尝试创建一个清理屏幕上某个区域的功能。这是我的功能:
void clearBuffer(CoordCR start, CoordCR end) const // Clear an area on screen
{
for (int i1 = 0; i1 < end.COLS; i1++)
{
for (int i2 = 0; i2 < end.ROWS; i2++)
{
setCursorPos(start.COLS + i1 - 1, start.ROWS + i2 - 1);
printf(" ");
}
}
}
setCursorPos is just a function who change the position of the cursor, to write ' ' character and so clear the screen. The first parameter of seCursorPos is the cols to go, the second is the row. My CoordCR struct is that :
setCursorPos只是一个改变光标位置,写''字符等清除屏幕的函数。 seCursorPos的第一个参数是cols,第二个是行。我的CoordCR结构是这样的:
struct CoordCR {
int COLS;
int ROWS;
};
I just give to this function the upper left point and the lower right point and she replace all character by space. This function works fine on windows but she is bugged on linux, I don't understand why. Thanks for help.
我只是给这个函数左上角点和右下角点,并用空格替换所有字符。这个功能在windows上运行正常,但她在linux上被窃听,我不明白为什么。感谢帮助。
2 个解决方案
#1
0
setCursorPos is a Win-API function. For the Linux counterpart you may find your answer under this thread: How to set mouse cursor position in C on linux?
setCursorPos是一个Win-API函数。对于Linux版本,你可以在这个帖子下找到你的答案:如何在Linux上设置C中的鼠标光标位置?
#2
0
Well... SetCursorPos (note the different capitalization) is a Win32 function. The suggested link how to set mouse cursor position in c on linux is mostly not relevant except for its brief mention of ncurses. For the simple example given, one would normally use the low-level termcap interface of ncurses, i.e., tgoto to position the cursor. That would let you use printf's for writing to the screen. The termcap with parameters question mentions that -- but read the whole termcap manual page (you have to initialize things first with tgetent).
嗯... SetCursorPos(注意不同的大小写)是一个Win32函数。建议的链接如何在Linux上的c中设置鼠标光标位置除了简要提及ncurses之外几乎无关紧要。对于给出的简单示例,通常使用ncurses的低级termcap接口,即tgoto来定位光标。那会让你使用printf来写入屏幕。带参数问题的termcap提到 - 但是读取整个termcap手册页(你必须先用tgetent初始化东西)。
#1
0
setCursorPos is a Win-API function. For the Linux counterpart you may find your answer under this thread: How to set mouse cursor position in C on linux?
setCursorPos是一个Win-API函数。对于Linux版本,你可以在这个帖子下找到你的答案:如何在Linux上设置C中的鼠标光标位置?
#2
0
Well... SetCursorPos (note the different capitalization) is a Win32 function. The suggested link how to set mouse cursor position in c on linux is mostly not relevant except for its brief mention of ncurses. For the simple example given, one would normally use the low-level termcap interface of ncurses, i.e., tgoto to position the cursor. That would let you use printf's for writing to the screen. The termcap with parameters question mentions that -- but read the whole termcap manual page (you have to initialize things first with tgetent).
嗯... SetCursorPos(注意不同的大小写)是一个Win32函数。建议的链接如何在Linux上的c中设置鼠标光标位置除了简要提及ncurses之外几乎无关紧要。对于给出的简单示例,通常使用ncurses的低级termcap接口,即tgoto来定位光标。那会让你使用printf来写入屏幕。带参数问题的termcap提到 - 但是读取整个termcap手册页(你必须先用tgetent初始化东西)。