FLUID: Fixes regression #777

Wrote wrong path in #inlude statement under certain
conditions. Also removed 'snap' tag if not needed.
This commit is contained in:
Matthias Melcher 2023-09-26 00:29:14 +02:00
parent b8fa522ca4
commit 0a2f05a2fe
23 changed files with 28 additions and 105 deletions

View File

@ -714,6 +714,14 @@ void Fd_Layout_List::read(Fl_Preferences &prefs, int storage) {
Write Suite and Layout selection and project layout data to an .fl project file.
*/
void Fd_Layout_List::write(Fd_Project_Writer *out) {
// Don't write the Snap field if no custom layout was used
if ((current_suite()==0) && (current_preset()==0)) {
int nSuite = 0;
for (int i=0; i<list_size_; i++) {
if (list_[i].storage_ == FD_STORE_PROJECT) nSuite++;
}
if (nSuite == 0) return;
}
out->write_string("\nsnap {\n ver 1\n");
out->write_string(" current_suite "); out->write_word(list_[current_suite()].name_); out->write_string("\n");
out->write_string(" current_preset %d\n", current_preset());

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
comment {//
// About dialog for the Fast Light Tool Kit (FLTK).
//

View File

@ -5,7 +5,7 @@ code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
current_preset 0
suite {
name {FLUID (based on FLTK)}
preset { 1

View File

@ -771,7 +771,7 @@ int Fd_Code_Writer::write_code(const char *s, const char *t, bool to_sourceview)
} else if (g_project.header_file_name[0] == '.' && strchr(g_project.header_file_name.c_str(), '/') == NULL) {
write_c("#include \"%s\"\n", fl_filename_name(t));
} else {
write_c("#include \"%s\"\n", t);
write_c("#include \"%s\"\n", g_project.header_file_name.c_str());
}
}
Fl_String loc_include, loc_conditional;

View File

@ -311,6 +311,10 @@ void Fluid_Project::reset() {
code_file_set = 0;
header_file_name = ".h";
code_file_name = ".cxx";
g_layout_list.remove_all(FD_STORE_PROJECT);
g_layout_list.current_suite(0);
g_layout_list.current_preset(0);
}
void Fluid_Project::update_settings_dialog() {
@ -1127,29 +1131,31 @@ int write_code_files()
// -- write the code and header files
if (!batch_mode) enter_project_dir();
int x = f.write_code(code_filename.c_str(), header_filename.c_str());
Fl_String code_filename_rel = fl_filename_relative(code_filename);
Fl_String header_filename_rel = fl_filename_relative(header_filename);
if (!batch_mode) leave_project_dir();
// -- print error message in batch mode or pop up an error or confirmation dialog box
if (batch_mode) {
if (!x) {
fprintf(stderr, "%s and %s: %s\n",
code_filename.c_str(),
header_filename.c_str(),
code_filename_rel.c_str(),
header_filename_rel.c_str(),
strerror(errno));
exit(1);
}
} else {
if (!x) {
fl_message("Can't write %s and %s: %s",
code_filename.c_str(),
header_filename.c_str(),
fl_message("Can't write %s or %s: %s",
code_filename_rel.c_str(),
header_filename_rel.c_str(),
strerror(errno));
} else {
set_modflag(-1, 0);
if (completion_button->value()) {
fl_message("Wrote %s and %s",
g_project.codefile_name().c_str(),
g_project.headerfile_name().c_str());
code_filename_rel.c_str(),
header_filename_rel.c_str());
}
}
}
@ -2080,7 +2086,7 @@ int main(int argc,char **argv) {
exit(0);
}
// don't lock up if silly command line arguments were given
// don't lock up if inconsistent command line arguments were given
if (batch_mode)
exit(0);

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
comment {//
// Code dialogs for the Fast Light Tool Kit (FLTK).
//

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
comment {//
// FLUID print panel for the Fast Light Tool Kit (FLTK).
//

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
comment {//
// Code dialogs for the Fast Light Tool Kit (FLTK).
//
@ -31,7 +26,7 @@ decl {\#include "fluid.h"} {private local
decl {\#include "file.h"} {private local
}
decl {\#include "../src/flstring.h"} {selected private local
decl {\#include "../src/flstring.h"} {private local
}
decl {\#include <FL/Fl_Tabs.H>} {private local
@ -136,8 +131,6 @@ and load those into the Code Viewer widgets.} open return_type void
sv_strings->buffer()->loadfile(fn);
sv_strings->scroll(top, 0);
} else if (sv_source->visible_r() || sv_header->visible_r()) {
g_project.basename = fl_filename_name(sv_source_filename);
g_project.basename = fl_filename_setext(g_project.basename, "");
Fl_String code_file_name_bak = g_project.code_file_name;
g_project.code_file_name = sv_source_filename;
Fl_String header_file_name_bak = g_project.header_file_name;
@ -162,7 +155,8 @@ and load those into the Code Viewer widgets.} open return_type void
g_project.code_file_name = code_file_name_bak;
g_project.header_file_name = header_file_name_bak;
}} {}
}} {selected
}
}
Function {update_sourceview_timer(void*)} {

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
comment {//
// FLUID template support for the Fast Light Tool Kit (FLTK).
//

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
comment {//
// Widget panel for the Fast Light Tool Kit (FLTK).
//

View File

@ -98,7 +98,7 @@ window->hide();} open
} {}
Fl_Button newButton {
callback {newdir();}
image {new.xbm} xywh {455 10 25 25} labelsize 8
image {new.xbm} compress_image 0 xywh {455 10 25 25} labelsize 8
code0 {\#include <FL/Fl_Preferences.H>}
code1 {o->tooltip(new_directory_tooltip);}
}

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
class CubeViewUI {open
} {
Function {CubeViewUI()} {open

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 0
}
comment {//
// Checkers images for the Fast Light Tool Kit (FLTK).
//

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
Function {} {open
} {
Fl_Window {} {open selected

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
Function {} {open
} {
Fl_Window {} {open

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
Function {make_window()} {open
} {
Fl_Window my_window {open

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 0
}
decl {\#include "mandelbrot.h"} {public local
}

View File

@ -7,11 +7,6 @@ i18n_gnu_function gettext
i18n_gnu_static_function gettext_noop
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 0
}
comment {About test/preferences:
The preferences app shows two features of FLTK and FLUID.

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
Function {button_cb(Fl_Button *b, void *)} {
comment {Buttons test callback} open private return_type void
} {

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
Function {} {open
} {
Fl_Window {} {open selected

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 0
}
Function {} {open
} {
Fl_Window foo_window {

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
decl {\#include <stdio.h>} {public global
}

View File

@ -2,11 +2,6 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 0
}
decl {\#include <FL/Fl_Simple_Terminal.H>} {public global
}