Skip to content

Commit baf79fe

Browse files
authored
Merge pull request #181 from chrisws/12_26
12 26
2 parents 57e9549 + 781c74c commit baf79fe

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
2023-01-20 (12.26)
1+
2023-02-19 (12.26)
22
SDL: Fixed an issue with window resizing #144
3+
COMMON: Fixed "make dist" so it can produce a package with all internal dependencies
34

45
2023-01-20 (12.26)
56
COMMON: Fixed DIM lower bound

src/platform/android/app/src/main/assets/main.bas

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const colNav2 = theme.text6
1616
const menu_gap = -(char_w / 2)
1717
const is_android = instr(sbver, "Android") != 0
1818
const is_sdl = instr(sbver, "SDL") != 0
19+
const path_sep = iff(instr(sbver, "Win_") != 0, "\\", "/")
1920
const onlineUrl = "http://smallbasic.github.io/samples/index.bas"
2021
const idxEdit = 6
2122
const idxFiles = 7
@@ -321,7 +322,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
321322
local date_col = colNav
322323

323324
sub fix_path
324-
if (right(path, 1) != "/") then path += "/"
325+
if (right(path, 1) != path_sep) then path += path_sep
325326
end
326327

327328
fix_path
@@ -679,17 +680,19 @@ sub main
679680
sub go_back
680681
local backPath, index
681682
backPath = ""
682-
index = iff(isstring(path), rinstr(path, "/"), 0)
683+
index = iff(isstring(path), rinstr(path, path_sep), 0)
683684
if (index > 0 && index == len(path)) then
684-
index = rinstr(left(path, index - 1), "/")
685-
fi
685+
index = rinstr(left(path, index - 1), path_sep)
686+
endif
686687
if (index == 1) then
687688
index++
688-
fi
689+
endif
689690
if (index > 0)
690691
backPath = left(path, index - 1)
692+
else if (mid(path, 2, 1) == ":") then
693+
backPath = path
691694
else
692-
backPath = "/"
695+
backPath = path_sep
693696
endif
694697
path = backPath
695698
end

src/ui/textedit.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,22 @@ EditBuffer::EditBuffer(TextEditInput *in, const char *text) :
358358
_buffer = (char *)malloc(_size);
359359
memcpy(_buffer, text, _len);
360360
_buffer[_len] = '\0';
361+
convertTabs();
361362
}
362363
}
363364

364365
EditBuffer::~EditBuffer() {
365366
clear();
366367
}
367368

369+
void EditBuffer::convertTabs() {
370+
for (int i = 0; i < _len; i++) {
371+
if (_buffer[i] == '\t') {
372+
_buffer[i] = ' ';
373+
}
374+
}
375+
}
376+
368377
void EditBuffer::clear() {
369378
free(_buffer);
370379
_buffer = nullptr;
@@ -409,6 +418,9 @@ char EditBuffer::getChar(int pos) const {
409418
} else {
410419
result = '\0';
411420
}
421+
if (result == '\r') {
422+
result = '\n';
423+
}
412424
return result;
413425
}
414426

@@ -428,6 +440,7 @@ int EditBuffer::insertChars(int pos, const char *text, int num) {
428440
_len += num;
429441
_buffer[_len] = '\0';
430442
_in->setDirty(true);
443+
convertTabs();
431444
if (num > 1) {
432445
_lines += countNewlines(text, num);
433446
} else if (text[0] == '\n') {
@@ -729,8 +742,7 @@ void TextEditInput::dragPage(int y, bool &redraw) {
729742
}
730743
}
731744

732-
void TextEditInput::drawText(int x, int y, const char *str,
733-
int length, SyntaxState &state) {
745+
void TextEditInput::drawText(int x, int y, const char *str, int length, SyntaxState &state) {
734746
int i = 0;
735747
int offs = 0;
736748
SyntaxState nextState = state;
@@ -1603,10 +1615,10 @@ int TextEditInput::getIndent(char *spaces, int len, int pos) {
16031615

16041616
int TextEditInput::getLineChars(StbTexteditRow *row, int pos) const {
16051617
int numChars = row->num_chars;
1606-
if (numChars > 0 && _buf._buffer[pos + row->num_chars - 1] == '\r') {
1618+
if (numChars > 0 && _buf._buffer[pos + numChars - 1] == '\n') {
16071619
numChars--;
16081620
}
1609-
if (numChars > 0 && _buf._buffer[pos + row->num_chars - 1] == '\n') {
1621+
if (numChars > 0 && _buf._buffer[pos + numChars - 1] == '\r') {
16101622
numChars--;
16111623
}
16121624
return numChars;

src/ui/textedit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct EditBuffer {
5050
void append(const char *text, int len) { insertChars(_len, text, len); }
5151
void append(const char *text) { insertChars(_len, text, strlen(text)); }
5252
void clear();
53+
void convertTabs();
5354
int countNewlines(const char *text, int num);
5455
int deleteChars(int pos, int num);
5556
char getChar(int pos) const;

0 commit comments

Comments
 (0)