diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Browser.cxx | 52 | ||||
| -rw-r--r-- | src/Fl_File_Chooser2.cxx | 98 | ||||
| -rw-r--r-- | src/Fl_Help_View.cxx | 10 | ||||
| -rw-r--r-- | src/Fl_Menu.cxx | 8 | ||||
| -rw-r--r-- | src/Fl_Text_Editor.cxx | 24 |
5 files changed, 111 insertions, 81 deletions
diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx index 9dd964990..0556f0fc6 100644 --- a/src/Fl_Browser.cxx +++ b/src/Fl_Browser.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Browser.cxx,v 1.9.2.12.2.11 2004/05/16 02:18:13 easysw Exp $" +// "$Id: Fl_Browser.cxx,v 1.9.2.12.2.12 2004/07/26 20:52:50 easysw Exp $" // // Browser widget for the Fast Light Tool Kit (FLTK). // @@ -497,6 +497,54 @@ int Fl_Browser::value() const { return lineno(selection()); } +// SWAP TWO LINES +void Fl_Browser::swap(FL_BLINE *a, FL_BLINE *b) { + + if ( a == b || !a || !b) return; // nothing to do + FL_BLINE *aprev = a->prev; + FL_BLINE *anext = a->next; + FL_BLINE *bprev = b->prev; + FL_BLINE *bnext = b->next; + if ( b->prev == a ) { // A ADJACENT TO B + if ( aprev ) aprev->next = b; else first = b; + b->next = a; + a->next = bnext; + b->prev = aprev; + a->prev = b; + if ( bnext ) bnext->prev = a; else last = a; + } else if ( a->prev == b ) { // B ADJACENT TO A + if ( bprev ) bprev->next = a; else first = a; + a->next = b; + b->next = anext; + a->prev = bprev; + b->prev = a; + if ( anext ) anext->prev = b; else last = b; + } else { // A AND B NOT ADJACENT + // handle prev's + b->prev = aprev; + if ( anext ) anext->prev = b; else last = b; + a->prev = bprev; + if ( bnext ) bnext->prev = a; else last = a; + // handle next's + if ( aprev ) aprev->next = b; else first = b; + b->next = anext; + if ( bprev ) bprev->next = a; else first = a; + a->next = bnext; + } + // Disable cache -- we played around with positions + cacheline = 0; + // Redraw modified lines + redraw_line(a); + redraw_line(b); +} + +void Fl_Browser::swap(int ai, int bi) { + if (ai < 1 || ai > lines || bi < 1 || bi > lines) return; + FL_BLINE* a = find_line(ai); + FL_BLINE* b = find_line(bi); + swap(a,b); +} + // -// End of "$Id: Fl_Browser.cxx,v 1.9.2.12.2.11 2004/05/16 02:18:13 easysw Exp $". +// End of "$Id: Fl_Browser.cxx,v 1.9.2.12.2.12 2004/07/26 20:52:50 easysw Exp $". // 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 $". // diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx index 36ae551f3..b8a0da47f 100644 --- a/src/Fl_Help_View.cxx +++ b/src/Fl_Help_View.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Help_View.cxx,v 1.1.2.51 2004/07/23 21:12:24 easysw Exp $" +// "$Id: Fl_Help_View.cxx,v 1.1.2.52 2004/07/26 20:52:51 easysw Exp $" // // Fl_Help_View widget routines. // @@ -1125,6 +1125,10 @@ Fl_Help_View::format() format_table(&table_width, columns, start); if ((xx + table_width) > hsize_) { +#ifdef DEBUG + printf("xx=%d, table_width=%d, hsize_=%d\n", xx, table_width, + hsize_); +#endif // DEBUG hsize_ = xx + table_width; done = 0; break; @@ -1953,7 +1957,7 @@ Fl_Help_View::format_table(int *table_width, // O - Total table width int scale_width = *table_width; if (scale_width == 0) { - if (width > hsize_) scale_width = hsize_; + if (width > (hsize_ - 24)) scale_width = hsize_ - 24; else scale_width = width; } @@ -2806,5 +2810,5 @@ hscrollbar_callback(Fl_Widget *s, void *) // -// End of "$Id: Fl_Help_View.cxx,v 1.1.2.51 2004/07/23 21:12:24 easysw Exp $". +// End of "$Id: Fl_Help_View.cxx,v 1.1.2.52 2004/07/26 20:52:51 easysw Exp $". // diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index e901e7817..7a62f0a2d 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu.cxx,v 1.18.2.12.2.32 2004/06/08 14:11:59 easysw Exp $" +// "$Id: Fl_Menu.cxx,v 1.18.2.12.2.33 2004/07/26 20:52:51 easysw Exp $" // // Menu code for the Fast Light Tool Kit (FLTK). // @@ -240,7 +240,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp, set_modal(); clear_border(); menu = m; - m = m->first(); // find the first item that needs to be rendered + if (m) m = m->first(); // find the first item that needs to be rendered drawn_selected = -1; if (button) { box(button->box()); @@ -405,7 +405,7 @@ int menuwindow::find_selected(int mx, int my) { if (my < 0 || my >= h()) return -1; if (!itemheight) { // menubar int xx = 3; int n = 0; - const Fl_Menu_Item* m = menu->first(); + const Fl_Menu_Item* m = menu ? menu->first() : 0; for (; ; m = m->next(), n++) { if (!m->text) return -1; xx += m->measure(0, button) + 16; @@ -791,5 +791,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const { } // -// End of "$Id: Fl_Menu.cxx,v 1.18.2.12.2.32 2004/06/08 14:11:59 easysw Exp $". +// End of "$Id: Fl_Menu.cxx,v 1.18.2.12.2.33 2004/07/26 20:52:51 easysw Exp $". // diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx index 6454bfc8a..be96e2a66 100644 --- a/src/Fl_Text_Editor.cxx +++ b/src/Fl_Text_Editor.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Text_Editor.cxx,v 1.9.2.19 2004/05/26 02:42:10 easysw Exp $" +// "$Id: Fl_Text_Editor.cxx,v 1.9.2.20 2004/07/26 20:52:52 easysw Exp $" // // Copyright 2001-2004 by Bill Spitzak and others. // Original code Copyright Mark Edel. Permission to distribute under @@ -47,8 +47,6 @@ Fl_Text_Editor::Fl_Text_Editor(int X, int Y, int W, int H, const char* l) Fl_Text_Editor::Key_Binding* Fl_Text_Editor::global_key_bindings = 0; -static int ctrl_a(int, Fl_Text_Editor* e); - // These are the default key bindings every widget should start with static struct { int key; @@ -102,7 +100,7 @@ static struct { { FL_Insert, FL_CTRL, Fl_Text_Editor::kf_copy }, { 'v', FL_CTRL, Fl_Text_Editor::kf_paste }, { FL_Insert, FL_SHIFT, Fl_Text_Editor::kf_paste }, - { 'a', FL_CTRL, ctrl_a }, + { 'a', FL_CTRL, Fl_Text_Editor::kf_select_all }, #ifdef __APPLE__ // Define CMD+key accelerators... @@ -110,7 +108,7 @@ static struct { { 'x', FL_COMMAND, Fl_Text_Editor::kf_cut }, { 'c', FL_COMMAND, Fl_Text_Editor::kf_copy }, { 'v', FL_COMMAND, Fl_Text_Editor::kf_paste }, - { 'a', FL_COMMAND, ctrl_a }, + { 'a', FL_COMMAND, Fl_Text_Editor::kf_select_all }, #endif // __APPLE__ { 0, 0, 0 } @@ -301,20 +299,6 @@ int Fl_Text_Editor::kf_c_s_move(int c, Fl_Text_Editor* e) { return 1; } -static int ctrl_a(int, Fl_Text_Editor* e) { - // make 2+ ^A's in a row toggle select-all: - int i = e->buffer()->line_start(e->insert_position()); - if (i != e->insert_position()) - return Fl_Text_Editor::kf_move(FL_Home, e); - else { - if (e->buffer()->selected()) - e->buffer()->unselect(); - else - Fl_Text_Editor::kf_select_all(0, e); - } - return 1; -} - int Fl_Text_Editor::kf_home(int, Fl_Text_Editor* e) { return kf_move(FL_Home, e); } @@ -488,5 +472,5 @@ int Fl_Text_Editor::handle(int event) { } // -// End of "$Id: Fl_Text_Editor.cxx,v 1.9.2.19 2004/05/26 02:42:10 easysw Exp $". +// End of "$Id: Fl_Text_Editor.cxx,v 1.9.2.20 2004/07/26 20:52:52 easysw Exp $". // |
