Skip to content

Commit 228bd7f

Browse files
authored
Merge pull request #79 from chrisws/0_12_15
0 12 15
2 parents 0e34f0d + 901f6ca commit 228bd7f

File tree

9 files changed

+50
-41
lines changed

9 files changed

+50
-41
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019-06-27 (0.12.15)
2+
FLTK: file file save as
3+
UI: fix reported crash in android printing null
4+
15
2019-06-22 (0.12.15)
26
FLTK: reactivated the FLTK port using FLTK v1.4
37

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ function buildSDL() {
205205
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} ${FONTCONFIG_CFLAGS}"
206206

207207
dnl backlinking support for modules
208-
PACKAGE_LIBS="${PACKAGE_LIBS} -ldl"
208+
PACKAGE_LIBS="${PACKAGE_LIBS} -ldl -no-pie"
209209
PACKAGE_LIBS="${PACKAGE_LIBS} ${FONTCONFIG_LIBS}"
210210
PACKAGE_LIBS="-static-libgcc ${PACKAGE_LIBS} `sdl2-config --static-libs` `freetype-config --libs`"
211211
esac
@@ -344,7 +344,7 @@ function buildFLTK() {
344344

345345
FLTK_CXXFLAGS="${PACKAGE_CFLAGS} `fltk-config --cxxflags`"
346346
FLTK_CXXFLAGS="${FLTK_CXXFLAGS} -fno-exceptions -fno-rtti -std=c++11 -Wno-unknown-pragmas"
347-
PACKAGE_LIBS="${PACKAGE_LIBS} `fltk-config --ldstaticflags --use-images`"
347+
PACKAGE_LIBS="${PACKAGE_LIBS} `fltk-config --ldstaticflags --use-images` -no-pie"
348348

349349
dnl do not depend on cygwin.dll under cygwin build
350350
case "${host_os}" in

src/platform/fltk/EditorWidget.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ bool EditorWidget::checkSave(bool discard) {
629629
} else {
630630
r = fl_choice(msg, "Save", "Cancel", NULL, NULL);
631631
}
632-
fprintf(stderr, "selected %d\n", r);
633632
if (r == 0) {
634633
// save selected
635634
save_file();
@@ -652,8 +651,8 @@ void EditorWidget::copyText() {
652651
/**
653652
* saves the editor buffer to the given file name
654653
*/
655-
void EditorWidget::doSaveFile(const char *newfile) {
656-
if (!_dirty && strcmp(newfile, _filename) == 0) {
654+
void EditorWidget::doSaveFile(const char *newfile, bool force) {
655+
if (!force && !_dirty && strcmp(newfile, _filename) == 0) {
657656
// neither buffer or filename have changed
658657
return;
659658
}

src/platform/fltk/EditorWidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct EditorWidget : public Fl_Group, StatusBar {
9797

9898
bool checkSave(bool discard);
9999
void copyText();
100-
void doSaveFile(const char *newfile);
100+
void doSaveFile(const char *newfile, bool force=false);
101101
void fileChanged(bool loadfile);
102102
bool focusWidget();
103103
const char *getFilename() { return _filename; }

src/platform/fltk/FileWidget.cxx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void FileWidget::fileOpen(EditorWidget *_saveEditorAs) {
266266
//
267267
void FileWidget::openPath(const char *newPath, StringList *recentPaths) {
268268
if (newPath && access(newPath, R_OK) == 0) {
269-
strcpy(_path, newPath);
269+
strlcpy(_path, newPath, PATH_MAX);
270270
} else {
271271
getcwd(_path, sizeof(_path));
272272
}
@@ -285,7 +285,7 @@ void FileWidget::openPath(const char *newPath, StringList *recentPaths) {
285285
void FileWidget::changeDir(const char *target) {
286286
char newPath[PATH_MAX + 1];
287287

288-
strcpy(newPath, _path);
288+
strlcpy(newPath, _path, PATH_MAX);
289289

290290
// file browser window
291291
if (strcmp(target, "..") == 0) {
@@ -299,9 +299,9 @@ void FileWidget::changeDir(const char *target) {
299299
} else {
300300
// go down a level
301301
if (newPath[strlen(newPath) - 1] != '/') {
302-
strcat(newPath, "/");
302+
strlcat(newPath, "/", PATH_MAX);
303303
}
304-
strcat(newPath, target);
304+
strlcat(newPath, target, PATH_MAX);
305305
}
306306
setDir(newPath);
307307
}
@@ -311,7 +311,7 @@ void FileWidget::changeDir(const char *target) {
311311
//
312312
void FileWidget::setDir(const char *target) {
313313
if (chdir(target) == 0) {
314-
strcpy(_path, target);
314+
strlcpy(_path, target, PATH_MAX);
315315
displayPath();
316316
} else {
317317
fl_message("Invalid path '%s'", target);
@@ -365,10 +365,10 @@ void FileWidget::displayPath() {
365365
if (_saveEditorAs) {
366366
const char *path = _saveEditorAs->getFilename();
367367
const char *slash = strrchr(path, '/');
368-
html.append("<b>Save ").append(slash ? slash + 1 : path).append(" as:<br>")
368+
html.append("<b>Save ").append(slash ? slash + 1 : path).append(" as:<font size=3><br>")
369369
.append("<input size=220 type=text value='").append(slash ? slash + 1 : path)
370370
.append("' name=saveas>&nbsp;<input type=button onclick='")
371-
.append(CMD_SAVE_AS).append("' value='Save As'><br><br>");
371+
.append(CMD_SAVE_AS).append("' value='Save As'><br><font size=1>");
372372
}
373373

374374
_recentPaths->sort(stringCompare);
@@ -433,7 +433,7 @@ void FileWidget::enterPath() {
433433
const char *newPath = fl_input("Enter path:", _path);
434434
if (newPath != 0) {
435435
if (chdir(newPath) == 0) {
436-
strcpy(_path, newPath);
436+
strlcpy(_path, newPath, PATH_MAX);
437437
displayPath();
438438
} else {
439439
fl_message("Invalid path '%s'", newPath);
@@ -497,23 +497,26 @@ void FileWidget::saveAs() {
497497
// substitute ~ for $HOME contents
498498
const char *home = dev_getenv("HOME");
499499
if (home) {
500-
strcpy(savepath, home);
500+
strlcpy(savepath, home, PATH_MAX);
501501
} else {
502502
savepath[0] = 0;
503503
}
504-
strcat(savepath, enteredPath + 1);
504+
strlcat(savepath, enteredPath + 1, PATH_MAX);
505505
} else if (enteredPath[0] == '/' || enteredPath[1] == ':') {
506506
// absolute path given
507-
strcpy(savepath, enteredPath);
507+
strlcpy(savepath, enteredPath, PATH_MAX);
508508
} else {
509-
strcpy(savepath, _path);
510-
strcat(savepath, "/");
511-
strcat(savepath, enteredPath);
509+
strlcpy(savepath, _path, PATH_MAX);
510+
strlcat(savepath, "/", PATH_MAX);
511+
strlcat(savepath, enteredPath, PATH_MAX);
512+
}
513+
if (strcasecmp(savepath + strlen(savepath) - 4, ".bas") != 0) {
514+
strlcat(savepath, ".bas", PATH_MAX);
512515
}
513516
const char *msg = "%s\n\nFile already exists.\nDo you want to replace it?";
514517
if (access(savepath, 0) != 0 || fl_choice(msg, "Yes", "No", 0, savepath) == 0) {
515-
_saveEditorAs->doSaveFile(savepath);
516-
}
518+
_saveEditorAs->doSaveFile(savepath, true);
519+
}
517520
}
518521
}
519522
}

src/platform/fltk/HelpView.cxx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ const char *aboutText =
3030
const char CMD_LEVEL1_OPEN = '+';
3131
const char CMD_LEVEL2_OPEN = '!';
3232
const char CMD_MORE = '^';
33-
const char LEVEL1_OPEN[] = "+ ";
34-
const char LEVEL2_OPEN[] = " + ";
35-
const char LEVEL1_CLOSE[] = " - ";
36-
const char LEVEL2_CLOSE[] = " - ";
3733

3834
HelpView *helpView;
3935

src/platform/fltk/HelpWidget.cxx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ struct BrNode : public BaseNode {
437437
struct AnchorNode : public BaseNode {
438438
AnchorNode(Attributes &p) :
439439
BaseNode(),
440+
x1(0),
441+
x2(0),
442+
y1(0),
443+
y2(0),
444+
lineHeight(0),
440445
wrapxy(0),
441446
pushed(0) {
442447
p.getName(name);
@@ -1446,7 +1451,7 @@ void createDropList(InputNode *node, strlib::List<String *> *options) {
14461451

14471452
void InputNode::update(strlib::List<NamedInput *> *names, Properties<String *> *env, Attributes *a) {
14481453
Fl_Valuator *valuator;
1449-
Fl_Input *input;
1454+
Fl_Input *input = NULL;
14501455
Fl_Color color;
14511456
strlib::String *name = a->getName();
14521457
strlib::String *value = a->getValue();
@@ -1490,7 +1495,6 @@ void InputNode::update(strlib::List<NamedInput *> *names, Properties<String *> *
14901495
}
14911496
break;
14921497
case ID_TEXTBOX:
1493-
button->box(FL_NO_BOX);
14941498
input = (Fl_Input *)button;
14951499
if (value && value->length()) {
14961500
input->value(value->c_str());
@@ -1523,17 +1527,11 @@ void InputNode::update(strlib::List<NamedInput *> *names, Properties<String *> *
15231527
// set colors
15241528
color = getColor(a->getBgColor(), 0);
15251529
if (color) {
1526-
button->color(color); // background
1527-
} else {
1528-
button->color(BUTTON_COLOR);
1530+
button->color(color);
15291531
}
15301532
color = getColor(a->getFgColor(), 0);
15311533
if (color) {
1532-
button->labelcolor(color); // foreground
1533-
button->color(color);
1534-
} else {
1535-
button->labelcolor(ANCHOR_COLOR);
1536-
button->color(ANCHOR_COLOR);
1534+
button->labelcolor(color);
15371535
}
15381536

15391537
// set alignment
@@ -1587,6 +1585,10 @@ void InputNode::display(Display *out) {
15871585
button->size(4 + (fl_width("$") * cols), button->h());
15881586
height = 4 + (fl_height() + fl_descent() * rows);
15891587
break;
1588+
case ID_TEXTBOX:
1589+
((Fl_Input *)button)->textfont(out->font);
1590+
((Fl_Input *)button)->textsize(out->fontSize);
1591+
break;
15901592
default:
15911593
break;
15921594
}
@@ -1598,7 +1600,7 @@ void InputNode::display(Display *out) {
15981600
button->labelfont(out->font);
15991601
button->labelsize(out->fontSize);
16001602
if (button->y() + button->h() < out->y2 && button->y() >= 0) {
1601-
button->clear_visible();
1603+
button->set_visible();
16021604
} else {
16031605
// draw a fake control in case partially visible
16041606
fl_color(button->color());
@@ -1862,6 +1864,11 @@ void HelpWidget::resize(int x, int y, int w, int h) {
18621864
}
18631865

18641866
void HelpWidget::draw() {
1867+
if (damage() == FL_DAMAGE_CHILD) {
1868+
Fl_Group::draw();
1869+
return;
1870+
}
1871+
18651872
int vscroll = -scrollbar->value();
18661873
Display out;
18671874
out.uline = false;
@@ -2008,7 +2015,7 @@ void HelpWidget::draw() {
20082015
for (int n = 0; n < numchildren; n++) {
20092016
Fl_Widget &w = *child(n);
20102017
if (&w != scrollbar) {
2011-
update_child(w);
2018+
draw_child(w);
20122019
}
20132020
}
20142021
fl_pop_clip();
@@ -2370,7 +2377,7 @@ void HelpWidget::compile() {
23702377
} else {
23712378
prop = p.get("size");
23722379
if (prop != NULL) {
2373-
fontSize = 7 + (prop->toInteger() * 2);
2380+
fontSize = (int)labelsize() + (prop->toInteger() - 1);
23742381
}
23752382
}
23762383
prop = p.get("face");

src/ui/ansiwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ int AnsiWidget::getScreenId(bool back) {
185185

186186
// prints the contents of the given string onto the backbuffer
187187
void AnsiWidget::print(const char *str) {
188-
int len = strlen(str);
188+
int len = (str == NULL ? 0 : strlen(str));
189189
if (len) {
190190
_back->drawInto();
191191

src/ui/strlib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ String::String(const char *s) {
2323
}
2424

2525
String::String(const String &s) {
26-
_buffer = strdup(s._buffer);
26+
_buffer = s._buffer == NULL ? NULL : strdup(s._buffer);
2727
}
2828

2929
String::String(const char *s, int len) : _buffer(NULL) {

0 commit comments

Comments
 (0)