Skip to content

Commit 021c75b

Browse files
committed
SDL: display current in recent file list
1 parent 723d796 commit 021c75b

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/platform/sdl/editor.cpp

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

54-
void showRecentFiles(TextEditHelpWidget *helpWidget) {
54+
void showRecentFiles(TextEditHelpWidget *helpWidget, String &loadPath) {
5555
helpWidget->createMessage();
5656
helpWidget->show();
5757
helpWidget->reload(NULL);
5858
String fileList;
59-
getRecentFileList(fileList);
59+
getRecentFileList(fileList, loadPath);
6060
helpWidget->setText(fileList);
6161
}
6262

@@ -236,7 +236,7 @@ void System::editSource(String &loadPath) {
236236
case SB_KEY_ALT('0'):
237237
_output->setStatus("Recent files. Esc=Close");
238238
widget = helpWidget;
239-
showRecentFiles(helpWidget);
239+
showRecentFiles(helpWidget, loadPath);
240240
break;
241241
case SB_KEY_ALT('1'):
242242
case SB_KEY_ALT('2'):
@@ -256,6 +256,9 @@ void System::editSource(String &loadPath) {
256256
dirty = !editWidget->isDirty();
257257
setupStatus(dirtyFile, cleanFile, loadPath);
258258
_modifiedTime = getModifiedTime();
259+
if (helpWidget->messageMode() && helpWidget->isVisible()) {
260+
showRecentFiles(helpWidget, loadPath);
261+
}
259262
}
260263
break;
261264
default:

src/platform/sdl/settings.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,12 @@ bool getRecentFile(String &path, unsigned position) {
229229
return result;
230230
}
231231

232-
void getRecentFileList(String &fileList) {
232+
void getRecentFileList(String &fileList, String &current) {
233233
for (int i = 0; i < NUM_RECENT_ITEMS; i++) {
234234
if (recentPath[i].length() > 0) {
235+
if (recentPath[i].equals(current)) {
236+
fileList.append(">> ");
237+
}
235238
fileList.append(i + 1).append(" ");
236239
fileList.append(recentPath[i]).append("\n\n");
237240
}

src/platform/sdl/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +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);
18+
void getRecentFileList(strlib::String &fileList, strlib::String &current);
1919

2020
#endif
2121

src/ui/textedit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ struct TextEditHelpWidget : public TextEditInput {
198198
void resize(int w, int h) { _x = w - _width; _height = h; }
199199
void reset(HelpMode mode);
200200
bool closeOnEnter() const;
201+
bool messageMode() const { return _mode == kMessage; }
201202
bool replaceMode() const { return _mode == kReplace; }
202203
bool replaceDoneMode() const { return _mode == kReplaceDone; }
203204
bool selected(MAPoint2d pt, int scrollX, int scrollY, bool &redraw);

0 commit comments

Comments
 (0)