diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2004-07-26 20:52:52 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2004-07-26 20:52:52 +0000 |
| commit | a529510e5b8f84b15aacd103936df89bb767bb29 (patch) | |
| tree | 48fed13b2239bc7de94c680ab1efa3b16c41c432 /src/Fl_File_Chooser2.cxx | |
| parent | dd193b3820f9b59233834d0f4bc020cd91168f58 (diff) | |
More documentation updates...
Fl_File_Chooser did not handle some cases for filename
completion (STR #376)
Fl_Help_View didn't properly compute the default maximum width
of the page properly, resulting in non-wrapped text in table
cells (STR #464)
Fl_Text_Editor no longer tries to emulate the Emacs CTRL-A
shortcut to move to the first column, since there is a key for
that and the widget does not emulate any other Emacs keys (STR
#421)
Fl_File_Chooser always disabled the OK button when the user
pressed DELETE or BACKSPACE (STR #397)
Added Fl_Browser::swap() methods (STR #459)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3698 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_File_Chooser2.cxx')
| -rw-r--r-- | src/Fl_File_Chooser2.cxx | 98 |
1 files changed, 46 insertions, 52 deletions
diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index 6bbbe6890..3fa961a6b 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.36 2004/04/11 04:38:57 easysw Exp $" +// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.37 2004/07/26 20:52:51 easysw Exp $" // // More Fl_File_Chooser routines. // @@ -475,12 +475,13 @@ Fl_File_Chooser::fileNameCB() #if (defined(WIN32) && !defined(__CYGWIN__)) || defined(__EMX__) if (directory_[0] != '\0' && filename[0] != '/' && filename[0] != '\\' && - !(isalpha(filename[0]) && (!filename[1] || filename[1] == ':'))) { + !(isalpha(filename[0] & 255) && (!filename[1] || filename[1] == ':'))) { #else if (directory_[0] != '\0' && filename[0] != '/') { #endif /* WIN32 || __EMX__ */ fl_filename_absolute(pathname, sizeof(pathname), filename); value(pathname); + fileName->mark(fileName->position()); // no selection after expansion } else if (filename != pathname) { // Finally, make sure that we have a writable copy... strlcpy(pathname, filename, sizeof(pathname)); @@ -489,11 +490,10 @@ Fl_File_Chooser::fileNameCB() filename = pathname; // Now process things according to the key pressed... - if (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter) - { + if (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter) { // Enter pressed - select or change directory... #if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__) - if ((strlen(pathname) == 2 && pathname[1] == ':') || + if ((isalpha(pathname[0] & 255) && pathname[1] == ':' && !pathname[2]) || fl_filename_isdir(pathname)) { #else if (fl_filename_isdir(pathname)) { @@ -513,75 +513,68 @@ Fl_File_Chooser::fileNameCB() // Hide the window to signal things are done... window->hide(); - } - else - { + } else { // File doesn't exist, so beep at and alert the user... fl_alert(existing_file_label); } } else if (Fl::event_key() != FL_Delete && - Fl::event_key() != FL_BackSpace) - { + Fl::event_key() != FL_BackSpace) { // Check to see if the user has entered a directory... if ((slash = strrchr(pathname, '/')) == NULL) slash = strrchr(pathname, '\\'); - if (slash != NULL) - { - // Yes, change directories if necessary... - *slash++ = '\0'; - filename = slash; + if (!slash) return; + + // Yes, change directories if necessary... + *slash++ = '\0'; + filename = slash; #if defined(WIN32) || defined(__EMX__) - if (strcasecmp(pathname, directory_) && - (pathname[0] || strcasecmp("/", directory_))) { + if (strcasecmp(pathname, directory_) && + (pathname[0] || strcasecmp("/", directory_))) { #else - if (strcmp(pathname, directory_) && - (pathname[0] || strcasecmp("/", directory_))) { + if (strcmp(pathname, directory_) && + (pathname[0] || strcasecmp("/", directory_))) { #endif // WIN32 || __EMX__ - int p = fileName->position(); - int m = fileName->mark(); - - directory(pathname); + int p = fileName->position(); + int m = fileName->mark(); - if (filename[0]) { - char tempname[1024]; + directory(pathname); - snprintf(tempname, sizeof(tempname), "%s/%s", directory_, filename); - fileName->value(tempname); - } + if (filename[0]) { + char tempname[1024]; - fileName->position(p, m); + snprintf(tempname, sizeof(tempname), "%s/%s", directory_, filename); + fileName->value(tempname); + strlcpy(pathname, tempname, sizeof(pathname)); } + + fileName->position(p, m); } // Other key pressed - do filename completion as possible... num_files = fileList->size(); min_match = strlen(filename); - max_match = 100000; + max_match = min_match + 1; first_line = 0; - for (i = 1; i <= num_files && max_match > min_match; i ++) - { + for (i = 1; i <= num_files && max_match > min_match; i ++) { file = fileList->text(i); #if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__) - if (strnicmp(filename, file, min_match) == 0) + if (strnicmp(filename, file, min_match) == 0) { #else - if (strncmp(filename, file, min_match) == 0) + if (strncmp(filename, file, min_match) == 0) { #endif // WIN32 || __EMX__ - { // OK, this one matches; check against the previous match - if (max_match == 100000) - { + if (!first_line) { // First match; copy stuff over... strlcpy(matchname, file, sizeof(matchname)); max_match = strlen(matchname); // Strip trailing /, if any... - if (matchname[max_match - 1] == '/') - { + if (matchname[max_match - 1] == '/') { max_match --; matchname[max_match] = '\0'; } @@ -589,9 +582,7 @@ Fl_File_Chooser::fileNameCB() // And then make sure that the item is visible fileList->topline(i); first_line = i; - } - else - { + } else { // Succeeding match; compare to find maximum string match... while (max_match > min_match) #if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__) @@ -616,9 +607,7 @@ Fl_File_Chooser::fileNameCB() fileList->deselect(0); fileList->select(first_line); fileList->redraw(); - } - else if (max_match > min_match && max_match != 100000) - { + } else if (max_match > min_match && first_line) { // Add the matching portion... fileName->replace(filename - pathname, filename - pathname + min_match, matchname); @@ -628,23 +617,28 @@ Fl_File_Chooser::fileNameCB() // (Tab and End also do this for both cases.) fileName->position(filename - pathname + max_match, filename - pathname + min_match); - } - else if (max_match == 0) { + } else if (max_match == 0) { fileList->deselect(0); fileList->redraw(); } // See if we need to enable the OK button... - if ((type_ & CREATE || access(fileName->value(), 0) == 0) && - (!fl_filename_isdir(fileName->value()) || type_ & DIRECTORY)) + if (((type_ & CREATE) || !access(fileName->value(), 0)) && + (!fl_filename_isdir(fileName->value()) || (type_ & DIRECTORY))) { okButton->activate(); - else + } else { okButton->deactivate(); + } } else { // FL_Delete or FL_BackSpace fileList->deselect(0); fileList->redraw(); - okButton->deactivate(); + if (((type_ & CREATE) || !access(fileName->value(), 0)) && + (!fl_filename_isdir(fileName->value()) || (type_ & DIRECTORY))) { + okButton->activate(); + } else { + okButton->deactivate(); + } } } @@ -1164,5 +1158,5 @@ unquote_pathname(char *dst, // O - Destination string // -// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.36 2004/04/11 04:38:57 easysw Exp $". +// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.37 2004/07/26 20:52:51 easysw Exp $". // |
