Skip to content

Commit 764aeda

Browse files
committed
UI: add scratchpad menu item
1 parent 89ee072 commit 764aeda

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

src/ui/system.cpp

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
#define MENU_EDITMODE 11
3636
#define MENU_AUDIO 12
3737
#define MENU_SCREENSHOT 13
38-
#define MENU_SIZE 14
38+
#define MENU_SCRATCHPAD 14
39+
#define MENU_SIZE 15
3940

4041
#define FONT_SCALE_INTERVAL 10
4142
#define FONT_MIN 20
@@ -196,20 +197,16 @@ void System::editSource(strlib::String &loadPath) {
196197
}
197198
break;
198199
case SB_KEY_F(1):
200+
case SB_KEY_ALT('h'):
199201
_output->setStatus("Keyword Help. Esc=Close");
200202
widget = helpWidget;
201203
helpWidget->createKeywordIndex();
202204
helpWidget->show();
203205
break;
204206
case SB_KEY_CTRL('h'):
205-
if (widget == helpWidget) {
206-
_output->setStatus("Keyword Help. Esc=Close");
207-
helpWidget->createKeywordIndex();
208-
} else {
209-
_output->setStatus("Keystroke help. Esc=Close");
210-
widget = helpWidget;
211-
helpWidget->createHelp();
212-
}
207+
_output->setStatus("Keystroke help. Esc=Close");
208+
widget = helpWidget;
209+
helpWidget->createHelp();
213210
helpWidget->show();
214211
break;
215212
case SB_KEY_CTRL('l'):
@@ -506,6 +503,9 @@ void System::handleMenu(int menuId) {
506503
case MENU_SCREENSHOT:
507504
::screen_dump();
508505
break;
506+
case MENU_SCRATCHPAD:
507+
scratchPad();
508+
break;
509509
}
510510

511511
if (fontSize != _output->getFontSize()) {
@@ -932,10 +932,13 @@ void System::showMenu() {
932932
_systemMenu[index++] = MENU_KEYPAD;
933933
#endif
934934
if (_mainBas) {
935+
sprintf(buffer, "Scratchpad");
936+
items->add(new String(buffer));
935937
sprintf(buffer, "Font Size %d%%", _fontScale - FONT_SCALE_INTERVAL);
936938
items->add(new String(buffer));
937939
sprintf(buffer, "Font Size %d%%", _fontScale + FONT_SCALE_INTERVAL);
938940
items->add(new String(buffer));
941+
_systemMenu[index++] = MENU_SCRATCHPAD;
939942
_systemMenu[index++] = MENU_ZOOM_UP;
940943
_systemMenu[index++] = MENU_ZOOM_DN;
941944

@@ -1096,6 +1099,28 @@ void System::printSource() {
10961099
}
10971100
}
10981101

1102+
void System::scratchPad() {
1103+
const char *path = gsb_bas_dir;
1104+
#if defined(_ANDROID)
1105+
path = "/sdcard/";
1106+
#endif
1107+
char file[OS_PATHNAME_SIZE];
1108+
sprintf(file, "%suntitled.bas", path);
1109+
bool ready = access(file, R_OK) == 0;
1110+
if (!ready) {
1111+
FILE *fp = fopen(file, "w");
1112+
if (fp) {
1113+
fprintf(fp, "REM scratch buffer\n");
1114+
fclose(fp);
1115+
ready = true;
1116+
}
1117+
}
1118+
if (ready) {
1119+
setLoadPath(file);
1120+
setExit(false);
1121+
}
1122+
}
1123+
10991124
void System::setExit(bool quit) {
11001125
if (!isClosing()) {
11011126
bool running = isRunning();

src/ui/system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct System {
7474
void printErrorLine();
7575
void printSource();
7676
void printSourceLine(char *text, int line, bool last);
77+
void scratchPad();
7778
void setRestart();
7879
void showMenu();
7980
void showSystemScreen(bool showSrc);

src/ui/textedit.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ const char *helpText =
5757
"A-g goto line\n"
5858
"A-n trim line-endings\n"
5959
"SHIFT-<arrow> select\n"
60-
"F1, keyword help\n"
60+
"TAB indent line\n"
61+
"F1,A-h keyword help\n"
6162
"F9, C-r run\n";
6263

6364
//

0 commit comments

Comments
 (0)