Skip to content

Commit 62cc14d

Browse files
committed
Merge pull request #35 from chrisws/0_11_20
0 12 2
2 parents 6d0a583 + 11f49fb commit 62cc14d

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
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: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ FILE *openConfig(const char *flags, bool debug) {
7676
int nextInteger(FILE *fp, int def) {
7777
int result = 0;
7878
for (int c = fgetc(fp); c != EOF && c != ',' && c != '\n'; c = fgetc(fp)) {
79-
result = (result * 10) + (c - '0');
79+
if (c != '\r') {
80+
result = (result * 10) + (c - '0');
81+
}
8082
}
8183
if (!result) {
8284
result = def;
@@ -90,8 +92,10 @@ int nextInteger(FILE *fp, int def) {
9092
int nextHex(FILE *fp, int def) {
9193
int result = 0;
9294
for (int c = fgetc(fp); c != EOF && c != ',' && c != '\n'; c = fgetc(fp)) {
93-
int val = (c >= 'a') ? (10 + (c - 'a')) : (c - '0');
94-
result = (result * 16) + val;
95+
if (c != '\r') {
96+
int val = (c >= 'a') ? (10 + (c - 'a')) : (c - '0');
97+
result = (result * 16) + val;
98+
}
9599
}
96100
if (!result) {
97101
result = def;
@@ -106,7 +110,7 @@ int nextString(FILE *fp) {
106110
int pos = ftell(fp);
107111
int len = 0;
108112
for (int c = fgetc(fp); c != EOF; c = fgetc(fp)) {
109-
if (c == '\n') {
113+
if (c == '\n' || c == '\r') {
110114
if (len > 0) {
111115
// string terminator
112116
break;
@@ -140,7 +144,7 @@ void restorePath(FILE *fp, bool restoreDir) {
140144
// restore window position
141145
//
142146
void restoreSettings(SDL_Rect &rect, int &fontScale, bool debug, bool restoreDir) {
143-
FILE *fp = openConfig("r", debug);
147+
FILE *fp = openConfig("rb", debug);
144148
if (fp) {
145149
rect.x = nextInteger(fp, SDL_WINDOWPOS_UNDEFINED);
146150
rect.y = nextInteger(fp, SDL_WINDOWPOS_UNDEFINED);
@@ -182,7 +186,7 @@ void restoreSettings(SDL_Rect &rect, int &fontScale, bool debug, bool restoreDir
182186
// save the window position
183187
//
184188
void saveSettings(SDL_Window *window, int fontScale, bool debug) {
185-
FILE *fp = openConfig("w", debug);
189+
FILE *fp = openConfig("wb", debug);
186190
if (fp) {
187191
int x, y, w, h;
188192
SDL_GetWindowPosition(window, &x, &y);
@@ -229,9 +233,12 @@ bool getRecentFile(String &path, unsigned position) {
229233
return result;
230234
}
231235

232-
void getRecentFileList(String &fileList) {
236+
void getRecentFileList(String &fileList, String &current) {
233237
for (int i = 0; i < NUM_RECENT_ITEMS; i++) {
234238
if (recentPath[i].length() > 0) {
239+
if (recentPath[i].equals(current)) {
240+
fileList.append(">> ");
241+
}
235242
fileList.append(i + 1).append(" ");
236243
fileList.append(recentPath[i]).append("\n\n");
237244
}

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.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#define strcasestr StrStrI
4141
#endif
4242

43-
int g_themeId = 0;
43+
unsigned g_themeId = 0;
4444
int g_lineMarker[MAX_MARKERS] = {
4545
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
4646
};
@@ -136,6 +136,9 @@ int compareIntegers(const void *p1, const void *p2) {
136136
// EditTheme
137137
//
138138
EditTheme::EditTheme() {
139+
if (g_themeId >= (sizeof(themes) / sizeof(themes[0]))) {
140+
g_themeId = 0;
141+
}
139142
selectTheme(themes[g_themeId]);
140143
}
141144

src/ui/textedit.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "common/smbas.h"
2424
#include "common/keymap.h"
2525

26-
extern int g_themeId;
26+
extern unsigned g_themeId;
2727
extern int g_user_theme[];
2828
#define THEME_COLOURS 17
2929

@@ -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)