Skip to content

Commit 89ee072

Browse files
committed
SDL: fix file save in win32
1 parent 74c46f5 commit 89ee072

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/ui/system.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ void System::editSource(strlib::String &loadPath) {
177177
case SB_KEY_F(9):
178178
case SB_KEY_CTRL('r'):
179179
_state = kRunState;
180-
// fallthrough
180+
if (!editWidget->isDirty()) {
181+
break;
182+
}
183+
// otherwise fallthrough
181184
case SB_KEY_CTRL('s'):
182185
if (!editWidget->save(loadPath)) {
183186
alert("", "Failed to save file");

src/ui/textedit.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ void TextEditInput::draw(int x, int y, int w, int h, int chw) {
343343
maFillRect(cursorX + _marginWidth, cursorY, chw, _charHeight);
344344
if (_state.cursor < _buf._len) {
345345
maSetColor(_theme->_cursor_color);
346-
maDrawText(cursorX + _marginWidth, cursorY, _buf._buffer + _state.cursor, 1);
346+
if (_buf._buffer[_state.cursor] != '\r' &&
347+
_buf._buffer[_state.cursor] != '\n') {
348+
maDrawText(cursorX + _marginWidth, cursorY, _buf._buffer + _state.cursor, 1);
349+
}
347350
}
348351
if (_matchingBrace != -1) {
349352
maSetColor(_theme->_match_background);
@@ -463,7 +466,7 @@ void TextEditInput::reload(const char *text) {
463466

464467
bool TextEditInput::save(const char *filePath) {
465468
bool result = true;
466-
FILE *fp = fopen(filePath, "w");
469+
FILE *fp = fopen(filePath, "wb");
467470
if (fp) {
468471
fwrite(_buf._buffer, sizeof(char), _buf._len, fp);
469472
fclose(fp);

0 commit comments

Comments
 (0)