Skip to content

Commit ebeaef8

Browse files
committed
COMMON: cannot run unit
1 parent 792984a commit ebeaef8

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

src/common/brun.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ int brun_create_task(const char *filename, byte *preloaded_bc, int libf) {
11781178
find_unit(filename, fname);
11791179
}
11801180
if (access(fname, R_OK)) {
1181-
panic("File '%s' not found", filename);
1181+
panic("File '%s' not found", fname);
11821182
}
11831183
// look if it is already loaded
11841184
if (search_task(fname) != -1) {
@@ -1765,6 +1765,10 @@ int sbasic_exec(const char *file) {
17651765
if (opt_syntaxcheck) { // this is a command-line flag to
17661766
// syntax-check only
17671767
exec_rq = 0;
1768+
} else if (ctask->bc_type == 2) {
1769+
// cannot run a unit
1770+
exec_rq = 0;
1771+
gsb_last_error = 1;
17681772
} else if (opt_decomp && success) {
17691773
sbasic_exec_prepare(file); // load everything
17701774
sbasic_dump_taskinfo(stdout);

src/common/scan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4529,6 +4529,7 @@ int comp_compile(const char *sb_file_name) {
45294529
comp_close();
45304530
close_task(tid);
45314531
activate_task(prev_tid);
4532+
ctask->bc_type = is_unit ? 2 : 1;
45324533

45334534
if (opt_nosave && !is_unit) {
45344535
ctask->bytecode = bc.code;

src/ui/inputs.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ FormList *activeList = NULL;
2222
FormInput *focusInput = NULL;
2323
FormEditInput *focusEdit = NULL;
2424

25+
#define LINE_Y (_height - 2)
26+
#define LINE_W (_width - 2)
27+
2528
FormEditInput *get_focus_edit() {
2629
return focusEdit;
2730
}
@@ -117,7 +120,9 @@ FormInput::~FormInput() {
117120

118121
void FormInput::construct(var_p_t form, var_p_t field, int id) {
119122
_exit = (map_get_bool(field, FORM_INPUT_IS_EXIT));
120-
_noFocus = (map_get_bool(field, FORM_INPUT_NO_FOCUS));
123+
if (!_noFocus) {
124+
_noFocus = (map_get_bool(field, FORM_INPUT_NO_FOCUS));
125+
}
121126
_id = id;
122127

123128
var_p_t v_id = map_get(field, FORM_INPUT_ID);
@@ -219,8 +224,8 @@ void FormInput::drawButton(const char *caption, int dx, int dy,
219224
void FormInput::drawHover(int dx, int dy, bool selected) {
220225
MAHandle currentHandle = maSetDrawTarget(HANDLE_SCREEN);
221226
maSetColor(selected ? _fg : _bg);
222-
int y = _y + dy + _height - 2;
223-
maLine(dx + _x + 2, y, dx + _x + _width - 2, y);
227+
int y = _y + dy + LINE_Y;
228+
maLine(dx + _x + 2, y, dx + _x + LINE_W, y);
224229
maUpdateScreen();
225230
maSetDrawTarget(currentHandle);
226231
}
@@ -414,25 +419,28 @@ FormLink::FormLink(const char *link, int x, int y, int w, int h) :
414419
_link(link) {
415420
}
416421

422+
void FormLink::draw(int x, int y, int w, int h, int chw) {
423+
drawLink(_link.c_str(), x, y, w, chw);
424+
if (_pressed) {
425+
maSetColor(_pressed ? _fg : _bg);
426+
maLine(x, y + LINE_Y, x + LINE_W, y + LINE_Y);
427+
}
428+
}
429+
417430
//
418431
// FormTab
419432
//
420433
FormTab::FormTab(const char *link, int x, int y, int w, int h) :
421434
FormLink(link, x, y, w, h) {
435+
_noFocus = true;
422436
}
423437

424438
void FormTab::draw(int x, int y, int w, int h, int chw) {
425439
int x_begin = chw;
426440
int x_end = x + MIN(w, _width);
427441

428-
maSetColor(_fg);
429-
drawText(_link, x + x_begin, y, w, chw);
430-
setTextColor();
442+
drawLink(_link.c_str(), x + x_begin, y, w, chw);
431443
maLine(x_end, y + 4, x_end, y + _height - 4);
432-
433-
x_end -= x_begin;
434-
maSetColor(_pressed ? _fg : _bg);
435-
maLine(x + x_begin, y + _height - 2, x_end, y + _height - 2);
436444
}
437445

438446
int FormTab::padding(bool vert) const {
@@ -1188,9 +1196,9 @@ void MenuButton::draw(int x, int y, int w, int h, int chw) {
11881196
maDrawText(x + 4, textY, _label.c_str(), len);
11891197
if (!_pressed && _index > 0 && _index % 2 == 0) {
11901198
maSetColor(0x3b3a36);
1191-
maLine(x + 2, y, x + _width - 2, y);
1199+
maLine(x + 2, y, x + LINE_W, y);
11921200
maSetColor(0x46453f);
1193-
maLine(x + 2, y - 1, x + _width - 2, y - 1);
1201+
maLine(x + 2, y - 1, x + LINE_W, y - 1);
11941202
}
11951203
}
11961204
}

src/ui/inputs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ struct FormLink : public FormInput {
186186
const char *getText() const { return _link.c_str(); }
187187
bool hasHover() { return true; }
188188

189-
void draw(int x, int y, int w, int h, int chw) {
190-
drawLink(_link.c_str(), x, y, w, chw);
191-
}
189+
void draw(int x, int y, int w, int h, int chw);
192190
int padding(bool vert) const { return vert ? LN_H : 0; }
193191

194192
protected:

0 commit comments

Comments
 (0)