added shortcuts

This commit is contained in:
Santiago Lema 2025-05-08 02:08:36 -03:00
parent de3dc540c4
commit 392dc320b9
5 changed files with 19 additions and 11 deletions

View file

@ -31,10 +31,9 @@ void App::AboutRequested() {
BAboutWindow *about = new BAboutWindow(B_TRANSLATE_SYSTEM_NAME("DumBer"), BAboutWindow *about = new BAboutWindow(B_TRANSLATE_SYSTEM_NAME("DumBer"),
kApplicationSignature); kApplicationSignature);
about->AddDescription(B_TRANSLATE("about_body")); about->AddDescription(B_TRANSLATE("about_body"));
about->AddCopyright(2024, "Santiago Lema"); about->AddCopyright(2024-2025, "Santiago Lema");
about->AddText("e-mail me at haiku@lema.org"); about->AddText("e-mail me at haiku@lema.org");
about->AddText("or find me on the fediverse as"); about->AddText("or find me on the fediverse as\n@santi@go.lema.org");
about->AddText("@santi@go.lema.org");
about->Show(); about->Show();
} }

View file

@ -270,7 +270,9 @@ void Conversation::ask(const std::string &prompt) {
auto url = BUrl("https://api.openai.com/v1/chat/completions"); auto url = BUrl("https://api.openai.com/v1/chat/completions");
BHttpRequest request = BHttpRequest(url); BHttpRequest request = BHttpRequest(url);
request.SetMethod(BHttpMethod::Post); request.SetMethod(BHttpMethod::Post);
//Allow up to 2 minute before timeout, it can be long depending on load or complexity of prompt
request.SetTimeout(120*1000000);
BHttpFields fields = BHttpFields(); BHttpFields fields = BHttpFields();
fields.AddField("Authorization", buildBearerKey()); fields.AddField("Authorization", buildBearerKey());
// fields.AddField("Content-Type", "application/json"); //NO, this will // fields.AddField("Content-Type", "application/json"); //NO, this will

BIN
DumBer

Binary file not shown.

View file

@ -44,7 +44,7 @@ MainWindow::MainWindow()
BLayoutBuilder::Group<>(this, B_VERTICAL, 0).Add(menuBar).AddGlue().End(); BLayoutBuilder::Group<>(this, B_VERTICAL, 0).Add(menuBar).AddGlue().End();
_inputField = new BTextView("input_view", B_WILL_DRAW | B_FOLLOW_ALL); _inputField = new BTextView("input_view", B_WILL_DRAW | B_FOLLOW_ALL);
_inputField->SetText("What is the matrix... printer ?"); _inputField->SetText("What is the matrix... printer, Neo ?");
_inputField->MakeEditable(true); _inputField->MakeEditable(true);
_inputField->MakeSelectable(true); _inputField->MakeSelectable(true);
_inputField->SetWordWrap(true); _inputField->SetWordWrap(true);
@ -90,6 +90,7 @@ MainWindow::MainWindow()
_sendButton->MakeDefault(true); _sendButton->MakeDefault(true);
_answerView = new BTextView("answer", B_WILL_DRAW | B_FOLLOW_ALL); _answerView = new BTextView("answer", B_WILL_DRAW | B_FOLLOW_ALL);
_answerView->MakeEditable(false); // Disable editing _answerView->MakeEditable(false); // Disable editing
_answerView->MakeSelectable(true); // Enable text selection _answerView->MakeSelectable(true); // Enable text selection
@ -430,14 +431,23 @@ BMenuBar *MainWindow::_BuildMenu() {
//------------------------- //-------------------------
menu = new BMenu(B_TRANSLATE("History")); menu = new BMenu(B_TRANSLATE("Conversation"));
item = new BMenuItem(B_TRANSLATE("Send Prompt" B_UTF8_ELLIPSIS),
new BMessage(kSendPrompt));
item->SetShortcut('S', B_COMMAND_KEY);
item->SetTarget(this);
menu->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Clear History" B_UTF8_ELLIPSIS), item = new BMenuItem(B_TRANSLATE("Clear History" B_UTF8_ELLIPSIS),
new BMessage(kClearHistory)); new BMessage(kClearHistory));
item->SetTarget(this); item->SetTarget(this);
item->SetShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY);
menu->AddItem(item); menu->AddItem(item);
menuBar->AddItem(menu); menuBar->AddItem(menu);
return menuBar; return menuBar;
} }

View file

@ -38,15 +38,12 @@ public:
// Overriding FrameResized to receive notifications on resize // Overriding FrameResized to receive notifications on resize
void FrameResized(float newWidth, float newHeight) override { void FrameResized(float newWidth, float newHeight) override {
printf("Window resized to: Width = %f, Height = %f\n", newWidth, newHeight); printf("Window resized to: Width = %f, Height = %f\n", newWidth, newHeight);
// You can add additional handling code here if needed
// Resize the scroll view if necessary, otherwise we lose scroll ability // Resize the scroll view if necessary, otherwise we lose scroll ability
} }
Conversation *_conversation = new Conversation(this); Conversation *_conversation = new Conversation(this);
void checkValidKey(); void checkValidKey();