Skip to content

Commit 2a3bc1d

Browse files
committed
GUI: implement \t correctly in SourceView
1 parent deef25b commit 2a3bc1d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/gui/Src/Gui/SourceView.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,23 @@ void SourceView::parseLine(size_t index, LineData & line)
161161
QString lineText = QString::fromStdString((*mFileLines)[index]);
162162
line.addr = addrFromIndex(index);
163163
line.index = index;
164-
line.code.code = lineText.replace('\t', " "); //TODO: add syntax highlighting
164+
165+
line.code.code.clear();
166+
for(int i = 0; i < lineText.length(); i++)
167+
{
168+
QChar ch = lineText[i];
169+
if(ch == '\t')
170+
{
171+
int col = line.code.code.length();
172+
int spaces = mTabSize - col % mTabSize;
173+
line.code.code.append(QString(spaces, ' '));
174+
}
175+
else
176+
{
177+
line.code.code.append(ch);
178+
}
179+
}
180+
//TODO: add syntax highlighting?
165181
}
166182

167183
duint SourceView::addrFromIndex(size_t index)

src/gui/Src/Gui/SourceView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ private slots:
3333
MenuBuilder* mMenuBuilder = nullptr;
3434
QString mSourcePath;
3535
duint mModBase;
36+
int mTabSize = 4; //TODO: make customizable?
3637

3738
FileLines* mFileLines = nullptr;
3839

0 commit comments

Comments
 (0)