このコードを実行すると、作成した境界線の左側が右上のボックスで上書きされます。コードは同じように見えますが、問題はこの領域に限定されているようです。これが境界線を上書きしないようにするにはどうすればよいですか? g++ -lncurses でコンパイルし、Ubuntu ターミナルで実行しています
#include <ncurses.h>
#include <string.h>
#define WINDOWY 24
#define WINDOWX 80
#define ROW1 3
#define RROW1 1
#define COL1 2
#define COL2 23
#define COL3 33
#define COL4 38
#define MEMORYROW 9
#define MEMORYCOL 1
#define COMMANDROW 1
#define COMMANDCOL 41
int closeUp(void);
void printMockup(void);
void drawBorders(void);
WINDOW *create_newwin(int height, int width, int starty, int startx);
int main()
{
char input = ' ';
int row,col;
//initialize ncurses stuff
initscr();
cbreak();
curs_set(0);
//check window is right size
getmaxyx(stdscr,row,col);
if (row < WINDOWY || col < WINDOWX)
{
printw("You need to increase the terminal size to at least 24 x 70");
return closeUp();
}
//draw border
drawBorders();
//draw UI
printMockup();
getch();
endwin();
return 0;
}
int closeUp(void)
{
getch();
endwin();
return 0;
}
void printMockup(void)
{
mvprintw(1, 2, "6808 Emulator");
mvprintw(ROW1, COL1, "Accumulator:");
mvprintw(ROW1, COL2, "0x00");
mvprintw(ROW1+1, COL1, "Program Counter:");
mvprintw(ROW1+1, COL2, "0x0000");
mvprintw(ROW1+2, COL1, "Stack Pointer:");
mvprintw(ROW1+2, COL2, "0x0000");
mvprintw(ROW1+3, COL1, "Index Register Low:");
mvprintw(ROW1+3, COL2, "0x00");
mvprintw(ROW1+4, COL1, "Index Register High:");
mvprintw(ROW1+4, COL2, "0x00");
mvprintw(RROW1, COL3, "PC:");
mvprintw(RROW1, COL4, "0");
mvprintw(RROW1+1, COL3, "C:");
mvprintw(RROW1+1, COL4, "0");
mvprintw(RROW1+2, COL3, "Z:");
mvprintw(RROW1+2, COL4, "0");
mvprintw(RROW1+3, COL3, "N:");
mvprintw(RROW1+3, COL4, "0");
mvprintw(RROW1+4, COL3, "I:");
mvprintw(RROW1+4, COL4, "0");
mvprintw(RROW1+5, COL3, "H:");
mvprintw(RROW1+5, COL4, "0");
mvprintw(RROW1+6, COL3, "V:");
mvprintw(RROW1+6, COL4, "0");
mvprintw(COMMANDROW+1, COMMANDCOL+11, "r - Run");
mvprintw(COMMANDROW+2, COMMANDCOL+11, "s - Step");
mvprintw(COMMANDROW+3, COMMANDCOL+11, "a - Auto-step");
mvprintw(COMMANDROW+4, COMMANDCOL+11, "x - Reset");
mvprintw(COMMANDROW+5, COMMANDCOL+11, "m - Main menu");
mvprintw(MEMORYROW+1, MEMORYCOL+1, "PC:");
mvprintw(MEMORYROW+1, MEMORYCOL+1, "0");
}
WINDOW *create_newwin(int height, int width, int starty, int startx)
{
WINDOW *local_win;
local_win = newwin(height, width, starty, startx);
//wborder(local_win, '|', '|', '-', '-', '+', '+', '+', '+');
box(local_win, 0 , 0);
wrefresh(local_win);
return local_win;
}
void drawBorders(void)
{
refresh();
create_newwin(WINDOWY, WINDOWX, 0, 0);
create_newwin(WINDOWY-(WINDOWY-MEMORYROW-1)-2, WINDOWX-COMMANDCOL-1, COMMANDROW, COMMANDCOL);
create_newwin(WINDOWY-MEMORYROW-1, WINDOWX-MEMORYCOL-1, MEMORYROW, MEMORYCOL);
}