diff options
| author | Greg Ercolano <erco@seriss.com> | 2020-08-08 19:10:57 -0700 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2020-08-08 19:10:57 -0700 |
| commit | 0da41da713ff5674207334a7c205c958364c18aa (patch) | |
| tree | ac7f3febe59c200c4349e28f55ef4019dad2abe3 /test/native-filechooser.cxx | |
| parent | b105dd726fc43405bf4388cce018097fb11febfd (diff) | |
Allow unix style paths for windows native filechooser
Allows and preserves unix style paths if user specifies them,
otherwise uses Windows style. This allows end users to use either
style path and get behavior they expect in cross-platform environments.
Addresses problems raised by issue #122
Diffstat (limited to 'test/native-filechooser.cxx')
| -rw-r--r-- | test/native-filechooser.cxx | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/native-filechooser.cxx b/test/native-filechooser.cxx index dd0c4812d..df2433021 100644 --- a/test/native-filechooser.cxx +++ b/test/native-filechooser.cxx @@ -93,10 +93,15 @@ int main(int argc, char **argv) { int argn = 1; #ifdef __APPLE__ // OS X may add the process number as the first argument - ignore - if (argc>argn && strncmp(argv[1], "-psn_", 5)==0) - argn++; + if (argc>argn && strncmp(argv[argn], "-psn_", 5)==0) ++argn; #endif + // Parse preset filename (if any) + char *filename = 0; + if ( argc>argn && argv[argn][0] != '-' ) { + filename = argv[argn++]; + } + Fl_Window *win = new Fl_Window(640, 400+TERMINAL_HEIGHT, "Native File Chooser Test"); win->size_range(win->w(), win->h(), 0, 0); win->begin(); @@ -105,7 +110,7 @@ int main(int argc, char **argv) { int x = 80, y = 10; G_filename = new Fl_Input(x, y, win->w()-80-10, 25, "Filename"); - G_filename->value(argc <= argn ? "." : argv[argn]); + G_filename->value(filename ? filename : "."); G_filename->tooltip("Default filename"); y += G_filename->h() + 10; @@ -148,6 +153,11 @@ int main(int argc, char **argv) { win->resizable(G_filter); } win->end(); - win->show(argc, argv); + // Pass show() remaining args we haven't already parsed.. + { + char **args = argv+(argn-1); + int nargs = argc-(argn-1); + win->show(nargs, args); + } return(Fl::run()); } |
