From d087652857c4e77097fe834e9de4f3cc64092a96 Mon Sep 17 00:00:00 2001 From: Brando Date: Mon, 27 Jan 2025 16:20:36 -0800 Subject: [PATCH 01/11] Can create a new window --- src/interface.cpp | 39 ++++++++++++++++++++++++++++++++++++-- src/interface.hpp | 3 ++- src/typeinterfacestate.hpp | 1 + todo.md | 9 ++++++--- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index 1837d42..793cdc3 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -451,7 +451,7 @@ int Interface::windowCreateStateDraft(int inputWinWidth, int inputWinHeight) { box(this->_displayWin, 0, 0); // Add a box around the display window char title[COLS]; - snprintf(title, COLS, "%s - draft", this->_chatroom.get()->name()); + snprintf(title, COLS, "Username"); int y = (COLS - strlen(title)) / 2; mvwprintw(this->_headerWin, 0, y, title); @@ -499,6 +499,38 @@ int Interface::windowCreateModeHelp() { return 0; } +int Interface::windowCreateStatePromptUsername() { + // change to normal mode + BFLockLock(&this->_winlock); + + erase(); + DELETE_WINDOWS; + + // Create two windows + this->_headerWin = newwin(1, COLS, 0, 0); + this->_displayWin = newwin(LINES - 2, COLS, 1, 0); + this->_inputWin = newwin(1, COLS, LINES - 1, 0); + + box(this->_displayWin, 0, 0); // Add a box around the display window + + char title[COLS]; + snprintf(title, COLS, "username"); + int y = (COLS - strlen(title)) / 2; + mvwprintw(this->_headerWin, 0, y, title); + + refresh(); + wrefresh(this->_inputWin); + wrefresh(this->_displayWin); + wrefresh(this->_headerWin); + + keypad(this->_inputWin, true); // Enable special keys in input window + nodelay(this->_inputWin, false); // Set blocking input for input window + + BFLockUnlock(&this->_winlock); + + return 0; +} + int _InterfaceDrawUserInputDraft( BFLock * winlock, WINDOW * inputwin, @@ -580,6 +612,9 @@ int Interface::draw() { case kInterfaceStateHelp: this->windowCreateModeHelp(); break; + case kInterfaceStatePromptUsername: + this->windowCreateStatePromptUsername(); + break; default: break; } @@ -746,7 +781,7 @@ int Interface::windowLoop() { BFThreadAsyncID tid = BFThreadAsync(Interface::displayWindowUpdateThread, (void *) this); InputBuffer userInput; this->_prevstate = kInterfaceStateUnknown; - this->_state = kInterfaceStateLobby; + this->_state = kInterfaceStatePromptUsername; while (this->_state.get() != kInterfaceStateQuit) { // draw ui based on current state this->draw(); diff --git a/src/interface.hpp b/src/interface.hpp index 7ccee74..80c112a 100644 --- a/src/interface.hpp +++ b/src/interface.hpp @@ -75,7 +75,8 @@ class Interface : public BF::Object { int windowCreateModeHelp(); int windowCreateStateChatroom(); int windowCreateModeLobby(); - + int windowCreateStatePromptUsername(); + static void displayWindowUpdateThread(void * in); int processinputStateDraft(InputBuffer & userInput); diff --git a/src/typeinterfacestate.hpp b/src/typeinterfacestate.hpp index 513cc91..9b4f7be 100644 --- a/src/typeinterfacestate.hpp +++ b/src/typeinterfacestate.hpp @@ -14,6 +14,7 @@ typedef enum { kInterfaceStateChatroom = 3, kInterfaceStateHelp = 4, kInterfaceStateCreateChatroom = 5, + kInterfaceStatePromptUsername = 6, } InterfaceState; #endif // INTERFACE_STATE_HPP diff --git a/todo.md b/todo.md index 0d720c5..85df896 100644 --- a/todo.md +++ b/todo.md @@ -1,12 +1,15 @@ x.x -- [ ] user data window editor -- [ ] ability to change user name - [ ] window dynamic resizing -- [ ] get list of users in chatroom - [ ] add to homebrew package manager - [ ] docker? - [ ] ai bot chatroom +0.4 +- [ ] wrap entire communication in encryption +- [ ] user data window editor +- [ ] ability to change user name +- [ ] get list of users in chatroom + 0.3 - [x] improved controls (easier commands or guidance) - [x] use of ":" for long commands From f6833d01906ddf50ea61c6ce41de6ea111a1cc6d Mon Sep 17 00:00:00 2001 From: Brando Date: Fri, 31 Jan 2025 10:01:38 -0800 Subject: [PATCH 02/11] good little box --- src/interface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index 793cdc3..eab4655 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -499,6 +499,10 @@ int Interface::windowCreateModeHelp() { return 0; } +/** + * TODO: + * [] figure what the window size should be + */ int Interface::windowCreateStatePromptUsername() { // change to normal mode BFLockLock(&this->_winlock); @@ -506,9 +510,8 @@ int Interface::windowCreateStatePromptUsername() { erase(); DELETE_WINDOWS; - // Create two windows - this->_headerWin = newwin(1, COLS, 0, 0); - this->_displayWin = newwin(LINES - 2, COLS, 1, 0); + this->_headerWin = newwin(1, COLS, 24, 0); + this->_displayWin = newwin(LINES - 50, COLS - 200, 25, 100); this->_inputWin = newwin(1, COLS, LINES - 1, 0); box(this->_displayWin, 0, 0); // Add a box around the display window From 3b9c4413abc8ee7439b0395318e9361398291a1c Mon Sep 17 00:00:00 2001 From: Brando Date: Fri, 31 Jan 2025 14:35:55 -0800 Subject: [PATCH 03/11] attempting to write prompt --- src/interface.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index eab4655..6ae766e 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -515,11 +515,18 @@ int Interface::windowCreateStatePromptUsername() { this->_inputWin = newwin(1, COLS, LINES - 1, 0); box(this->_displayWin, 0, 0); // Add a box around the display window + + char buf[COLS]; - char title[COLS]; - snprintf(title, COLS, "username"); - int y = (COLS - strlen(title)) / 2; - mvwprintw(this->_headerWin, 0, y, title); + // header + snprintf(buf, COLS, "configuration"); + int y = (COLS - strlen(buf)) / 2; + mvwprintw(this->_headerWin, 0, y, buf); + + // prompt + snprintf(buf, COLS, "please enter a username"); + y = (COLS - strlen(buf)) / 2; + mvwprintw(this->_displayWin, 10, y, buf); refresh(); wrefresh(this->_inputWin); From 65fa18f7097f6ace8f682f8debdcf3b7b9d5fae0 Mon Sep 17 00:00:00 2001 From: Brando Date: Mon, 10 Feb 2025 20:04:38 -0800 Subject: [PATCH 04/11] creating an input function --- src/interface.cpp | 56 +++++++++++------------------------------------ src/interface.hpp | 2 +- 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index 6ae766e..4b36ce7 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -437,7 +437,7 @@ int Interface::windowCreateStateChatroom() { return 0; } -int Interface::windowCreateStateDraft(int inputWinWidth, int inputWinHeight) { +int Interface::windowCreateInput(int inputWinWidth, int inputWinHeight, const char * title) { BFLockLock(&this->_winlock); DELETE_WINDOWS; @@ -450,10 +450,10 @@ int Interface::windowCreateStateDraft(int inputWinWidth, int inputWinHeight) { box(this->_inputWin, 0, 0); // Add a box around the input window box(this->_displayWin, 0, 0); // Add a box around the display window - char title[COLS]; - snprintf(title, COLS, "Username"); - int y = (COLS - strlen(title)) / 2; - mvwprintw(this->_headerWin, 0, y, title); + char buf[COLS]; + snprintf(buf, COLS, title); + int y = (COLS - strlen(buf)) / 2; + mvwprintw(this->_headerWin, 0, y, buf); refresh(); wrefresh(this->_inputWin); @@ -473,7 +473,7 @@ int Interface::windowCreateStateDraft(int inputWinWidth, int inputWinHeight) { int Interface::windowCreateStateDraft() { int inputWinWidth = COLS; int inputWinHeight = 3; - return this->windowCreateStateDraft(inputWinWidth, inputWinHeight); + return this->windowCreateInput(inputWinWidth, inputWinHeight, "Draft"); } int Interface::windowCreateModeHelp() { @@ -504,41 +504,9 @@ int Interface::windowCreateModeHelp() { * [] figure what the window size should be */ int Interface::windowCreateStatePromptUsername() { - // change to normal mode - BFLockLock(&this->_winlock); - - erase(); - DELETE_WINDOWS; - - this->_headerWin = newwin(1, COLS, 24, 0); - this->_displayWin = newwin(LINES - 50, COLS - 200, 25, 100); - this->_inputWin = newwin(1, COLS, LINES - 1, 0); - - box(this->_displayWin, 0, 0); // Add a box around the display window - - char buf[COLS]; - - // header - snprintf(buf, COLS, "configuration"); - int y = (COLS - strlen(buf)) / 2; - mvwprintw(this->_headerWin, 0, y, buf); - - // prompt - snprintf(buf, COLS, "please enter a username"); - y = (COLS - strlen(buf)) / 2; - mvwprintw(this->_displayWin, 10, y, buf); - - refresh(); - wrefresh(this->_inputWin); - wrefresh(this->_displayWin); - wrefresh(this->_headerWin); - - keypad(this->_inputWin, true); // Enable special keys in input window - nodelay(this->_inputWin, false); // Set blocking input for input window - - BFLockUnlock(&this->_winlock); - - return 0; + int inputWinWidth = COLS; + int inputWinHeight = 3; + return this->windowCreateInput(inputWinWidth, inputWinHeight, "Username"); } int _InterfaceDrawUserInputDraft( @@ -591,7 +559,7 @@ int Interface::windowUpdateInputWindowText(InputBuffer & userInput) { // see if we need to expand the height for the input window if (lines > 1) { // change window to fit text const int off = 2; - this->windowCreateStateDraft(w, lines + off); + this->windowCreateInput(w, lines + off, "Draft"); } _InterfaceDrawUserInputDraft(&this->_winlock, this->_inputWin, userInput); @@ -791,7 +759,8 @@ int Interface::windowLoop() { BFThreadAsyncID tid = BFThreadAsync(Interface::displayWindowUpdateThread, (void *) this); InputBuffer userInput; this->_prevstate = kInterfaceStateUnknown; - this->_state = kInterfaceStatePromptUsername; + //this->_state = kInterfaceStatePromptUsername; + this->_state = kInterfaceStateLobby; while (this->_state.get() != kInterfaceStateQuit) { // draw ui based on current state this->draw(); @@ -870,6 +839,7 @@ int Interface::windowStop() { int Interface::run() { int error = this->gatherUserData(); + //int error = 0; this->windowStart(); diff --git a/src/interface.hpp b/src/interface.hpp index 80c112a..9b1e9c9 100644 --- a/src/interface.hpp +++ b/src/interface.hpp @@ -71,7 +71,7 @@ class Interface : public BF::Object { int windowUpdateInputWindowText(InputBuffer & userInput); int windowCreateStateDraft(); - int windowCreateStateDraft(int inputWinWidth, int inputWinHeight); + int windowCreateInput(int inputWinWidth, int inputWinHeight, const char * title); int windowCreateModeHelp(); int windowCreateStateChatroom(); int windowCreateModeLobby(); From d6515d91b2641d6546660440d89196559cd4fad6 Mon Sep 17 00:00:00 2001 From: Brando Date: Mon, 10 Feb 2025 20:18:22 -0800 Subject: [PATCH 05/11] Can see prompt --- src/interface.cpp | 35 +++++++++++++++++++++++++++-------- src/interface.hpp | 7 ++++++- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index 4b36ce7..47567c5 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -437,24 +437,41 @@ int Interface::windowCreateStateChatroom() { return 0; } -int Interface::windowCreateInput(int inputWinWidth, int inputWinHeight, const char * title) { +int Interface::windowCreateInput( + int inputWinWidth, + int inputWinHeight, + const char * title, + const char * prompt +) { BFLockLock(&this->_winlock); DELETE_WINDOWS; - + + int dispRowCount = LINES - inputWinHeight - 1; + // Create two windows this->_headerWin = newwin(1, COLS, 0, 0); - this->_displayWin = newwin(LINES - inputWinHeight - 1, COLS, 1, 0); + this->_displayWin = newwin(dispRowCount, COLS, 1, 0); this->_inputWin = newwin(inputWinHeight, inputWinWidth, LINES - inputWinHeight, 0); box(this->_inputWin, 0, 0); // Add a box around the input window box(this->_displayWin, 0, 0); // Add a box around the display window char buf[COLS]; + + // title snprintf(buf, COLS, title); int y = (COLS - strlen(buf)) / 2; mvwprintw(this->_headerWin, 0, y, buf); + // prompt, if provided + if (prompt) { + snprintf(buf, COLS, prompt); + y = (COLS - strlen(buf)) / 2; + int x = dispRowCount / 2; + mvwprintw(this->_displayWin, x, y, buf); + } + refresh(); wrefresh(this->_inputWin); wrefresh(this->_displayWin); @@ -506,7 +523,7 @@ int Interface::windowCreateModeHelp() { int Interface::windowCreateStatePromptUsername() { int inputWinWidth = COLS; int inputWinHeight = 3; - return this->windowCreateInput(inputWinWidth, inputWinHeight, "Username"); + return this->windowCreateInput(inputWinWidth, inputWinHeight, "Username", "Please provide a username"); } int _InterfaceDrawUserInputDraft( @@ -759,8 +776,10 @@ int Interface::windowLoop() { BFThreadAsyncID tid = BFThreadAsync(Interface::displayWindowUpdateThread, (void *) this); InputBuffer userInput; this->_prevstate = kInterfaceStateUnknown; - //this->_state = kInterfaceStatePromptUsername; - this->_state = kInterfaceStateLobby; + + this->_state = kInterfaceStatePromptUsername; + //this->_state = kInterfaceStateLobby; + while (this->_state.get() != kInterfaceStateQuit) { // draw ui based on current state this->draw(); @@ -838,8 +857,8 @@ int Interface::windowStop() { } int Interface::run() { - int error = this->gatherUserData(); - //int error = 0; + //int error = this->gatherUserData(); + int error = 0; this->windowStart(); diff --git a/src/interface.hpp b/src/interface.hpp index 9b1e9c9..a48c213 100644 --- a/src/interface.hpp +++ b/src/interface.hpp @@ -71,11 +71,16 @@ class Interface : public BF::Object { int windowUpdateInputWindowText(InputBuffer & userInput); int windowCreateStateDraft(); - int windowCreateInput(int inputWinWidth, int inputWinHeight, const char * title); int windowCreateModeHelp(); int windowCreateStateChatroom(); int windowCreateModeLobby(); int windowCreateStatePromptUsername(); + int windowCreateInput( + int inputWinWidth, + int inputWinHeight, + const char * title, + const char * prompt = NULL + ); static void displayWindowUpdateThread(void * in); From eb99e9cf9efdfc61c3673a852bc3f6e654f65e35 Mon Sep 17 00:00:00 2001 From: Brando Date: Mon, 10 Feb 2025 20:25:56 -0800 Subject: [PATCH 06/11] can update input window --- src/interface.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index 47567c5..141df0a 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -544,8 +544,20 @@ int _InterfaceDrawUserInputDraft( return 0; } +const char * _InterfaceGetInputTitle(InterfaceState state) { + switch (state) { + case kInterfaceStateDraft: + return "Draft"; + case kInterfaceStatePromptUsername: + return "Username"; + default: + return NULL; + } +} + int Interface::windowUpdateInputWindowText(InputBuffer & userInput) { - switch (this->_state.get()) { + InterfaceState state = this->_state.get(); + switch (state) { case kInterfaceStateChatroom: case kInterfaceStateLobby: { @@ -567,6 +579,7 @@ int Interface::windowUpdateInputWindowText(InputBuffer & userInput) { break; } case kInterfaceStateDraft: + case kInterfaceStatePromptUsername: { int w, h; getmaxyx(this->_inputWin, h, w); @@ -576,7 +589,7 @@ int Interface::windowUpdateInputWindowText(InputBuffer & userInput) { // see if we need to expand the height for the input window if (lines > 1) { // change window to fit text const int off = 2; - this->windowCreateInput(w, lines + off, "Draft"); + this->windowCreateInput(w, lines + off, _InterfaceGetInputTitle(state)); } _InterfaceDrawUserInputDraft(&this->_winlock, this->_inputWin, userInput); From f13d93693e5275b044d716b7d0807989a42e6fa9 Mon Sep 17 00:00:00 2001 From: Brando Date: Mon, 10 Feb 2025 20:28:54 -0800 Subject: [PATCH 07/11] utility function to get title --- src/interface.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index 141df0a..f4e8f13 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -487,10 +487,21 @@ int Interface::windowCreateInput( return 0; } +const char * _InterfaceGetInputTitle(InterfaceState state) { + switch (state) { + case kInterfaceStateDraft: + return "Draft"; + case kInterfaceStatePromptUsername: + return "Username"; + default: + return NULL; + } +} + int Interface::windowCreateStateDraft() { int inputWinWidth = COLS; int inputWinHeight = 3; - return this->windowCreateInput(inputWinWidth, inputWinHeight, "Draft"); + return this->windowCreateInput(inputWinWidth, inputWinHeight, _InterfaceGetInputTitle(this->_state.get())); } int Interface::windowCreateModeHelp() { @@ -523,7 +534,12 @@ int Interface::windowCreateModeHelp() { int Interface::windowCreateStatePromptUsername() { int inputWinWidth = COLS; int inputWinHeight = 3; - return this->windowCreateInput(inputWinWidth, inputWinHeight, "Username", "Please provide a username"); + return this->windowCreateInput( + inputWinWidth, + inputWinHeight, + _InterfaceGetInputTitle(this->_state.get()), + "Please provide a username" + ); } int _InterfaceDrawUserInputDraft( @@ -544,17 +560,6 @@ int _InterfaceDrawUserInputDraft( return 0; } -const char * _InterfaceGetInputTitle(InterfaceState state) { - switch (state) { - case kInterfaceStateDraft: - return "Draft"; - case kInterfaceStatePromptUsername: - return "Username"; - default: - return NULL; - } -} - int Interface::windowUpdateInputWindowText(InputBuffer & userInput) { InterfaceState state = this->_state.get(); switch (state) { From 67babf98978ff94279d8b66cd53a60bd71f119b7 Mon Sep 17 00:00:00 2001 From: Brando Date: Mon, 10 Feb 2025 20:47:52 -0800 Subject: [PATCH 08/11] can get username --- src/interface.cpp | 24 ++++++++++++++++++++++++ src/interface.hpp | 1 + src/utils.cpp | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index f4e8f13..839cd4a 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -750,6 +750,27 @@ int Interface::processinputStateDraft(InputBuffer & userInput) { return 0; } +int Interface::processinputStatePromptUsername(InputBuffer & userInput) { + if (Utils::inputReady(userInput, this->_state)) { // send buf + // set up user + char username[USER_NAME_SIZE]; + strncpy(username, userInput.cString(), USER_NAME_SIZE); + + if (username[strlen(username) - 1] == '\n') { + username[strlen(username)- 1] = '\0'; + } + + this->_user = User::create(username); + BFRelease(this->_user.get()); + + this->_state = kInterfaceStateLobby; + + userInput.reset(); + } + + return 0; +} + int Interface::processinput(InputBuffer & userInput) { switch (this->_state.get()) { case kInterfaceStateLobby: @@ -761,6 +782,9 @@ int Interface::processinput(InputBuffer & userInput) { case kInterfaceStateDraft: this->processinputStateDraft(userInput); break; + case kInterfaceStatePromptUsername: + this->processinputStatePromptUsername(userInput); + break; case kInterfaceStateHelp: this->_state = this->_returnfromhelpstate; userInput.reset(); diff --git a/src/interface.hpp b/src/interface.hpp index a48c213..8cbc512 100644 --- a/src/interface.hpp +++ b/src/interface.hpp @@ -87,6 +87,7 @@ class Interface : public BF::Object { int processinputStateDraft(InputBuffer & userInput); int processinputStateChatroom(InputBuffer & userInput); int processinputStateLobby(InputBuffer & userInput); + int processinputStatePromptUsername(InputBuffer & userInput); /** * draws lobby ui diff --git a/src/utils.cpp b/src/utils.cpp index 9e715f4..7b71530 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -11,9 +11,9 @@ bool Utils::inputReady(InputBuffer & buf, InterfaceState state) { return buf.starts_with(":") && (buf.length() > 1) && buf.enterPressed() || - !buf.starts_with(":") && (buf.length() == 1) && (state != kInterfaceStateDraft) + !buf.starts_with(":") && (buf.length() == 1) && (state != kInterfaceStateDraft) && (state != kInterfaceStatePromptUsername) || - (state == kInterfaceStateDraft) && buf.enterPressed(); + ((state == kInterfaceStateDraft) || (state == kInterfaceStatePromptUsername)) && buf.enterPressed(); ; } From 07be912ed907b8278727eec4bfd840a892134e2d Mon Sep 17 00:00:00 2001 From: Brando Date: Mon, 10 Feb 2025 20:57:18 -0800 Subject: [PATCH 09/11] update todo --- todo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/todo.md b/todo.md index 85df896..48bef24 100644 --- a/todo.md +++ b/todo.md @@ -18,7 +18,7 @@ x.x - [x] drafting messages crashes - [x] add text at the bottom that says "press '?' or type ":help" to show help" - [ ] improve help -- [ ] chat configuration implemented in ncurses +- [x] chat username configuration implemented in ncurses - [ ] user typing - [x] update build and test process - [x] move package logic to libs From b14a4bda9c7eae88c0c5b0b46d877810570f43f6 Mon Sep 17 00:00:00 2001 From: Brando Date: Tue, 11 Feb 2025 09:41:06 -0800 Subject: [PATCH 10/11] adding more test points --- testbench/utils_tests.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/testbench/utils_tests.hpp b/testbench/utils_tests.hpp index 157b992..5e89035 100644 --- a/testbench/utils_tests.hpp +++ b/testbench/utils_tests.hpp @@ -21,13 +21,17 @@ using namespace BF; BFTEST_UNIT_FUNC(test_utilsIsReady, 2<<10, { InputBuffer b0("i"); - BF_ASSERT(Utils::inputReady(b0, kInterfaceStateDraft)); + BF_ASSERT(!Utils::inputReady(b0, kInterfaceStateDraft)); + BF_ASSERT(!Utils::inputReady(b0, kInterfaceStatePromptUsername)); + BF_ASSERT(Utils::inputReady(b0, kInterfaceStateCreateChatroom)); InputBuffer b1("asdf"); BF_ASSERT(!Utils::inputReady(b1, kInterfaceStateDraft)); - InputBuffer b2("asdf"); + b1.addChar('\n'); + BF_ASSERT(Utils::inputReady(b1, kInterfaceStateDraft)); + InputBuffer b2(":asdf"); + BF_ASSERT(!Utils::inputReady(b1, kInterfaceStateLobby)); b2.addChar('\n'); - BF_ASSERT(Utils::inputReady(b2, kInterfaceStateDraft)); - + BF_ASSERT(Utils::inputReady(b2, kInterfaceStateLobby)); }) BFTEST_COVERAGE_FUNC(utils_tests, { From 9df76921b4f7369d1430448206047ccab9e26570 Mon Sep 17 00:00:00 2001 From: Brando Date: Tue, 11 Feb 2025 12:13:21 -0800 Subject: [PATCH 11/11] cleaning up interface --- src/interface.cpp | 22 +--------------------- src/interface.hpp | 2 -- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/interface.cpp b/src/interface.cpp index 839cd4a..38bd206 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -867,22 +867,6 @@ User * Interface::getuser() { return this->_user.get(); } -int Interface::gatherUserData() { - // set up user - char username[USER_NAME_SIZE]; - printf("username: "); - fgets(username, sizeof(username), stdin); - - if (username[strlen(username) - 1] == '\n') { - username[strlen(username)- 1] = '\0'; - } - - this->_user = User::create(username); - BFRelease(this->_user.get()); - - return 0; -} - int Interface::windowStart() { initscr(); // Initialize the library cbreak(); // Line buffering disabled, pass on everything to me @@ -899,13 +883,9 @@ int Interface::windowStop() { } int Interface::run() { - //int error = this->gatherUserData(); - int error = 0; - this->windowStart(); - if (!error) - error = this->windowLoop(); + int error = this->windowLoop(); this->windowStop(); diff --git a/src/interface.hpp b/src/interface.hpp index 8cbc512..a394be2 100644 --- a/src/interface.hpp +++ b/src/interface.hpp @@ -66,8 +66,6 @@ class Interface : public BF::Object { int windowLoop(); int windowStop(); - int gatherUserData(); - int windowUpdateInputWindowText(InputBuffer & userInput); int windowCreateStateDraft();