Skip to content

Commit 4f6b8b7

Browse files
committed
UI: fix label display issue
1 parent 764aeda commit 4f6b8b7

File tree

5 files changed

+32
-26
lines changed

5 files changed

+32
-26
lines changed

src/ui/ansiwidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ void AnsiWidget::drawActiveButton() {
575575
if (_focus != NULL && !_activeButton->hasHover()) {
576576
MAHandle currentHandle = maSetDrawTarget(HANDLE_SCREEN);
577577
_focus->drawShape(_activeButton);
578+
_focus->drawLabel();
578579
maUpdateScreen();
579580
maSetDrawTarget(currentHandle);
580581
}

src/ui/screen.cpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ void Screen::clear() {
101101
_label.empty();
102102
}
103103

104+
void Screen::drawLabel() {
105+
if (_label.length()) {
106+
MAExtent screenSize = maGetScrSize();
107+
int screenW = EXTENT_X(screenSize);
108+
int screenH = EXTENT_Y(screenSize);
109+
int w = _charWidth * (_label.length() + 2);
110+
int h = _charHeight + 2;
111+
int top = screenH - h;
112+
int left = (screenW - w) / 2;
113+
int textY = top + ((h - _charHeight) / 2);
114+
115+
maSetColor(0xbfbfbf);
116+
maFillRect(left, top, w, h);
117+
maSetColor(0xe5e5e5);
118+
maLine(left, top, left + w, top);
119+
maSetColor(0x737373);
120+
maLine(left, top + h - 1, left + w, top + h - 1);
121+
maLine(left + w, top + 1, left + w, top + h - 1);
122+
maSetColor(0x403c44);
123+
maDrawText(left + _charWidth, textY, _label.c_str(), _label.length());
124+
}
125+
}
126+
104127
void Screen::drawShape(Shape *rect) {
105128
if (rect != NULL &&
106129
rect->_y >= _scrollY &&
@@ -164,27 +187,7 @@ void Screen::drawOverlay(bool vscroll) {
164187
}
165188
}
166189

167-
// display the label
168-
if (_label.length()) {
169-
MAExtent screenSize = maGetScrSize();
170-
int screenW = EXTENT_X(screenSize);
171-
int screenH = EXTENT_Y(screenSize);
172-
int w = _charWidth * (_label.length() + 2);
173-
int h = _charHeight + 2;
174-
int top = screenH - h;
175-
int left = (screenW - w) / 2;
176-
int textY = top + ((h - _charHeight) / 2);
177-
178-
maSetColor(0xbfbfbf);
179-
maFillRect(left, top, w, h);
180-
maSetColor(0xe5e5e5);
181-
maLine(left, top, left + w, top);
182-
maSetColor(0x737373);
183-
maLine(left, top + h - 1, left + w, top + h - 1);
184-
maLine(left + w, top + 1, left + w, top + h - 1);
185-
maSetColor(0x403c44);
186-
maDrawText(left + _charWidth, textY, _label.c_str(), _label.length());
187-
}
190+
drawLabel();
188191
}
189192

190193
void Screen::drawInto(bool background) {

src/ui/screen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct Screen : public Shape {
5050
void add(Shape *button);
5151
void addImage(ImageDisplay &image);
5252
int ansiToMosync(long c);
53+
void drawLabel();
5354
void drawShape(Shape *button);
5455
void drawOverlay(bool vscroll);
5556
FormInput *getMenu(FormInput *prev, int px, int py);

src/ui/system.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ void System::editSource(strlib::String &loadPath) {
138138

139139
while (_state == kEditState) {
140140
MAEvent event = getNextEvent();
141-
if (event.type == EVENT_TYPE_KEY_PRESSED &&
142-
_userScreenId == -1) {
141+
if (event.type == EVENT_TYPE_KEY_PRESSED && _userScreenId == -1) {
143142
dev_clrkb();
144143
int sw = _output->getScreenWidth();
145144
bool redraw = true;
@@ -1105,7 +1104,7 @@ void System::scratchPad() {
11051104
path = "/sdcard/";
11061105
#endif
11071106
char file[OS_PATHNAME_SIZE];
1108-
sprintf(file, "%suntitled.bas", path);
1107+
sprintf(file, "%sscratch.bas", path);
11091108
bool ready = access(file, R_OK) == 0;
11101109
if (!ready) {
11111110
FILE *fp = fopen(file, "w");

src/ui/textedit.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,9 @@ char *TextEditInput::copy(bool cut) {
555555
}
556556

557557
void TextEditInput::paste(const char *text) {
558-
stb_textedit_paste(&_buf, &_state, text, strlen(text));
558+
if (text != NULL) {
559+
stb_textedit_paste(&_buf, &_state, text, strlen(text));
560+
}
559561
}
560562

561563
void TextEditInput::layout(StbTexteditRow *row, int start) const {
@@ -699,7 +701,7 @@ void TextEditInput::editTab() {
699701
// get the current lines indent
700702
char *buf = lineText(start);
701703
int curIndent = 0;
702-
while (buf && buf[curIndent] == ' ') {
704+
while (buf && (buf[curIndent] == ' ' || buf[curIndent] == '\t')) {
703705
curIndent++;
704706
}
705707

0 commit comments

Comments
 (0)