Cleanup, comments, and making extra test aps.

This commit is contained in:
2023-03-26 03:55:57 -07:00
parent 732283b699
commit b6d097f84f
4 changed files with 205 additions and 42 deletions

View File

@@ -22,29 +22,8 @@ using namespace std;
| ╬ | WACS_D_PLUS | WACS_DDDD |
*/
int main(int argc, char* argv[]) {
setlocale(LC_ALL, "");
wchar_t buffer[255] = {0};
// Load ncurses and initialize stdscr
initscr();
// Enable raw mode to give us direct access to extra keys.
raw();
// Disable echoing characters as they are typed.
noecho();
// Enable keypad characters (function keys, arrow keys, and numpad keys.)
keypad(stdscr, true);
// Create a window with width: 17, height: 15, startX: 10, startY: 2
// These dimensions include the window bounds so the window actually starts at column 11 and row 3
// The size of the window is actually 17 wide by 15 tall, but after drawing the border the usable
// area is only 15x13 instead of 17x15.
// WINDOW* newwin(nlines, ncols, begin_y, begin_x)
// WINDOW* pWindow = newwin(15, 17, 2, 10);
refresh();
// Draw a box around the window with default chars
wborder_set(stdscr,
int set_double_border(WINDOW* screen) {
return wborder_set(screen,
WACS_D_VLINE/*left side*/,
WACS_D_VLINE/*right side*/,
WACS_D_HLINE/*top side*/,
@@ -53,26 +32,47 @@ int main(int argc, char* argv[]) {
WACS_D_URCORNER/*top right corner*/,
WACS_D_LLCORNER/*bottom left corner*/,
WACS_D_LRCORNER/*bottom right corner*/);
int width;
int height;
getmaxyx(stdscr, height, width);
swprintf(buffer, sizeof(buffer), L"width: %i, height: %i", width, height);
mvaddwstr(1, 2, buffer);
//mvaddwstr(5,5, L"x\u2562╢x");
//mvadd_wch(3,2, WACS_D_PLUS);
refresh();
// wrefresh(pWindow);
}
int main(int argc, char* argv[]) {
setlocale(LC_ALL, "");
wchar_t buffer[255] = {0};
WINDOW* pWindow = nullptr;
// Load ncurses and initialize stdscr.
initscr();
pWindow = stdscr;
// Enable raw mode to give us direct access to extra keys.
raw();
// Disable echoing characters as they are typed.
noecho();
// Enable keypad characters. (function keys, arrow keys, and numpad keys.)
keypad(pWindow, true);
// Remove the delay when pressing esc.
set_escdelay(0);
bool done = false;
while(!done) {
int key = getch();
swprintf(buffer, sizeof(buffer), L"0x%04o pressed", key);
mvaddwstr(2, 2, buffer);
if (key == KEY_ESCAPE) {
done = true;
int key = KEY_RESIZE;
while(key != KEY_ESCAPE) {
if (key == KEY_RESIZE) {
// Clear the screen.
werase(pWindow);
// Draw a box around the window with default chars.
set_double_border(pWindow);
// Display the event
mvwaddwstr(pWindow, 2, 2, L"Resized");
// Get the window width and height.
int width;
int height;
getmaxyx(pWindow, height, width);
// Display the width and height.
swprintf(buffer, sizeof(buffer), L"width: %i, height: %i", width, height);
mvwaddwstr(pWindow, 1, 2, buffer);
} else {
// Display the keycode of the key that was pressed in hex and octal.
swprintf(buffer, sizeof(buffer), L"0x%04X %04o pressed", key, key);
mvwaddwstr(pWindow,2, 2, buffer);
}
wrefresh(pWindow);
key = wgetch(pWindow);
}
endwin();