Skip to content

Commit 51327e6

Browse files
committed
UI: experimental keypad to replace android keypad
- fixed some intellij issues
1 parent 751a15b commit 51327e6

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

src/platform/android/jni/editor.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void Runtime::editSource(strlib::String loadPath, bool restoreOnExit) {
8787

8888
while (_state == kEditState) {
8989
MAEvent event = getNextEvent();
90+
bool exitHelp = false;
9091
switch (event.type) {
9192
case EVENT_TYPE_POINTER_PRESSED:
9293
if (!showStatus && widget == editWidget && event.point.x < editWidget->getMarginWidth()) {
@@ -135,14 +136,11 @@ void Runtime::editSource(strlib::String loadPath, bool restoreOnExit) {
135136
break;
136137
case SB_KEY_F(1):
137138
if (widget == helpWidget) {
138-
// end help mode
139-
widget = editWidget;
140-
helpWidget->hide();
141-
helpWidget->cancelMode();
139+
exitHelp = true;
142140
} else {
143141
widget = helpWidget;
144-
helpWidget->createKeywordIndex();
145142
helpWidget->showPopup(-4, -2);
143+
helpWidget->createKeywordIndex();
146144
helpWidget->setFocus(true);
147145
}
148146
break;
@@ -155,10 +153,7 @@ void Runtime::editSource(strlib::String loadPath, bool restoreOnExit) {
155153
break;
156154
case SB_KEY_CTRL('f'):
157155
if (widget == helpWidget) {
158-
// end help mode
159-
widget = editWidget;
160-
helpWidget->hide();
161-
helpWidget->cancelMode();
156+
exitHelp = true;
162157
} else {
163158
widget = helpWidget;
164159
helpWidget->createSearch(false);
@@ -203,7 +198,7 @@ void Runtime::editSource(strlib::String loadPath, bool restoreOnExit) {
203198
}
204199
}
205200

206-
if (isBack() && widget == helpWidget) {
201+
if ((exitHelp || isBack()) && widget == helpWidget) {
207202
widget = editWidget;
208203
helpWidget->hide();
209204
editWidget->setFocus(true);

src/ui/audio.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#define MINIAUDIO_IMPLEMENTATION
1010

1111
#include "config.h"
12-
#include <stdio.h>
13-
#include <stdint.h>
12+
#include <cstdio>
13+
#include <cstdint>
1414
#include <unistd.h>
1515
#include "include/osd.h"
1616
#include "ui/strlib.h"
@@ -153,7 +153,7 @@ bool audio_open() {
153153
ma_backend_dsound,
154154
#endif
155155
};
156-
if (ma_context_init(backends, sizeof(backends)/sizeof(backends[0]), NULL, &context) != MA_SUCCESS) {
156+
if (ma_context_init(backends, sizeof(backends)/sizeof(backends[0]), nullptr, &context) != MA_SUCCESS) {
157157
result = false;
158158
} else {
159159
queuePos = 0;
@@ -170,7 +170,7 @@ void audio_close() {
170170
}
171171

172172
void osd_audio(const char *path) {
173-
Sound *sound = new Sound();
173+
auto *sound = new Sound();
174174
ma_result result = sound->construct(path);
175175
if (result != MA_SUCCESS) {
176176
delete sound;
@@ -197,7 +197,7 @@ void osd_clear_sound_queue() {
197197
// remove any cached sounds from the queue
198198
List_each(Sound *, it, queue) {
199199
Sound *next = *it;
200-
if (next != NULL && next->_decoder != nullptr) {
200+
if (next != nullptr && next->_decoder != nullptr) {
201201
queue.remove(it);
202202
it--;
203203
}

src/ui/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ char *System::readSource(const char *fileName) {
753753
}
754754
if (buffer != nullptr) {
755755
delete [] _programSrc;
756-
int len = strlen(buffer) + 1;
756+
size_t len = strlen(buffer) + 1;
757757
_programSrc = new char[len];
758758
memcpy(_programSrc, buffer, len);
759759
_programSrc[len - 1] = '\0';

src/ui/textedit.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,9 @@ void TextEditHelpWidget::buildKeywordIndex() {
24112411
_buf.clear();
24122412
_buf.append("SmallBASIC language reference\n\n");
24132413
_buf.append("+ Select a category\n|\n");
2414+
int rows = 4;
24142415

2415-
keywordIterator([=](int index, int packageIndex, bool nextPackage) {
2416+
keywordIterator([&](int index, int packageIndex, bool nextPackage) {
24162417
if (nextPackage) {
24172418
const char *package = keyword_help[index].package;
24182419
if (packageIndex < _packageIndex) {
@@ -2430,9 +2431,11 @@ void TextEditHelpWidget::buildKeywordIndex() {
24302431
}
24312432
_buf.append(package);
24322433
_buf.append("\n", 1);
2434+
++rows;
24332435

24342436
if (_packageOpen && _packageIndex == packageIndex) {
24352437
_buf.append(" |\n", 5);
2438+
++rows;
24362439
}
24372440
}
24382441

@@ -2441,6 +2444,7 @@ void TextEditHelpWidget::buildKeywordIndex() {
24412444
_buf.append(LEVEL2_OPEN, LEVEL2_LEN);
24422445
_buf.append(keyword_help[index].keyword);
24432446
_buf.append("\n", 1);
2447+
++rows;
24442448
}
24452449

24462450
return true;
@@ -2456,10 +2460,15 @@ void TextEditHelpWidget::buildKeywordIndex() {
24562460
_buf.append("\n\n", 2);
24572461
_buf.append(keyword_help[_keywordIndex].help);
24582462
_buf.append("\n\n", 2);
2463+
rows += 7;
2464+
int scroll = ((_charHeight * rows) - (_height - _y)) / _charHeight;
2465+
if (scroll > 0) {
2466+
_scroll = scroll;
2467+
}
2468+
} else {
2469+
_scroll = 0;
24592470
}
2460-
24612471
_cursorRow = getCursorRow();
2462-
_scroll = 0;
24632472
}
24642473

24652474
void TextEditHelpWidget::showPopup(int cols, int rows) {

0 commit comments

Comments
 (0)