Skip to content

Commit 1c31c17

Browse files
committed
SDL: alt-num key to restore previous edit file
1 parent 1028996 commit 1c31c17

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/platform/sdl/editor.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ void setupStatus(String &dirtyFile, String &cleanFile, String &loadPath) {
5151
cleanFile.append(help);
5252
}
5353

54+
void showRecentFiles(TextEditHelpWidget *helpWidget) {
55+
helpWidget->createMessage();
56+
helpWidget->show();
57+
helpWidget->reload(NULL);
58+
String fileList;
59+
getRecentFileList(fileList);
60+
helpWidget->setText(fileList);
61+
}
62+
5463
void System::editSource(String &loadPath) {
5564
logEntered();
5665

@@ -224,6 +233,11 @@ void System::editSource(String &loadPath) {
224233
_output->selectScreen(SOURCE_SCREEN);
225234
_state = kEditState;
226235
break;
236+
case SB_KEY_ALT('0'):
237+
_output->setStatus("Recent files. Esc=Close");
238+
widget = helpWidget;
239+
showRecentFiles(helpWidget);
240+
break;
227241
case SB_KEY_ALT('1'):
228242
case SB_KEY_ALT('2'):
229243
case SB_KEY_ALT('3'):

src/platform/sdl/settings.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "common/smbas.h"
1919
#include "platform/sdl/settings.h"
2020

21+
using namespace strlib;
22+
2123
static const char *ENV_VARS[] = {
2224
"APPDATA", "HOME", "TMP", "TEMP", "TMPDIR"
2325
};
@@ -37,7 +39,7 @@ static const char *ENV_VARS[] = {
3739
#define makedir(f) mkdir(f, 0700)
3840
#endif
3941

40-
strlib::String recentPath[NUM_RECENT_ITEMS];
42+
String recentPath[NUM_RECENT_ITEMS];
4143
int recentPosition[NUM_RECENT_ITEMS];
4244

4345
FILE *openConfig(const char *flags, bool debug) {
@@ -216,7 +218,7 @@ void saveSettings(SDL_Window *window, int fontScale, bool debug) {
216218
}
217219
}
218220

219-
bool getRecentFile(strlib::String &path, unsigned position) {
221+
bool getRecentFile(String &path, unsigned position) {
220222
bool result = false;
221223
if (position < NUM_RECENT_ITEMS && recentPath[position].length() > 0 &&
222224
!recentPath[position].equals(path)) {
@@ -227,6 +229,15 @@ bool getRecentFile(strlib::String &path, unsigned position) {
227229
return result;
228230
}
229231

232+
void getRecentFileList(String &fileList) {
233+
for (int i = 0; i < NUM_RECENT_ITEMS; i++) {
234+
if (recentPath[i].length() > 0) {
235+
fileList.append(i + 1).append(" ");
236+
fileList.append(recentPath[i]).append("\n\n");
237+
}
238+
}
239+
}
240+
230241
void setRecentFile(const char *filename) {
231242
bool found = false;
232243
for (int i = 0; i < NUM_RECENT_ITEMS && !found; i++) {

src/platform/sdl/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void restoreSettings(SDL_Rect &rect, int &fontScale, bool debug, bool restoreDir
1515
void saveSettings(SDL_Window *window, int fontScale, bool debug);
1616
void setRecentFile(const char *path);
1717
bool getRecentFile(strlib::String &path, unsigned position);
18+
void getRecentFileList(strlib::String &fileList);
1819

1920
#endif
2021

0 commit comments

Comments
 (0)