0

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 :

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.

Lucas S.
  • 312
  • 3
  • 15

2 Answers2

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?

Community
  • 1
  • 1
hamid attar
  • 388
  • 1
  • 8
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).

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105