Only in nedit5.5-orig: .cvsignore
diff -crB nedit5.5-orig/menu.c nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/menu.c
*** nedit5.5-orig/menu.c	2004-09-16 08:50:56.000000000 +1000
--- nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/menu.c	2013-07-27 11:15:23.382790000 +1000
***************
*** 96,101 ****
--- 96,104 ----
  
  typedef void (*menuCallbackProc)();
  
+ #ifdef SWITCH_DOCUMENTS_PATCH
+ void initialiseSwitchDocumentsListWrapper();
+ #endif
  static void doActionCB(Widget w, XtPointer clientData, XtPointer callData);
  static void doTabActionCB(Widget w, XtPointer clientData, XtPointer callData);
  static void pasteColCB(Widget w, XtPointer clientData, XtPointer callData); 
***************
*** 219,224 ****
--- 222,228 ----
  	Cardinal *nArgs);
  static void closeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs); 
  static void saveAP(Widget w, XEvent *event, String *args, Cardinal *nArgs); 
+ static void saveAllAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
  static void saveAsDialogAP(Widget w, XEvent *event, String *args,
  	Cardinal *nArgs); 
  static void saveAsAP(Widget w, XEvent *event, String *args, Cardinal *nArgs); 
***************
*** 310,315 ****
--- 314,329 ----
  	Cardinal *nArgs);
  static void lastDocumentAP(Widget w, XEvent *event, String *args,
  	Cardinal *nArgs);
+ #ifdef SWITCH_DOCUMENTS_PATCH	
+ static void switchDocumentsAP(Widget w, XEvent *event, String *args,
+ 	Cardinal *nArgs);
+ static void switchDocumentsReverseAP(Widget w, XEvent *event, String *args,
+ 	Cardinal *nArgs);
+ static void switchDocumentsEndAP(Widget w, XEvent *event, String *args,
+ 	Cardinal *nArgs);
+ static void switchDocumentsNullAP(Widget w, XEvent *event, String *args,
+ 	Cardinal *nArgs);			
+ #endif		
  static void closePaneAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
  static void capitalizeAP(Widget w, XEvent *event, String *args,
  	Cardinal *nArgs);
***************
*** 433,438 ****
--- 447,454 ----
      {"open_selected", openSelectedAP},
      {"close", closeAP},
      {"save", saveAP},
+     {"save-all", saveAllAP },
+     {"save-all", saveAllAP },
      {"save-as", saveAsAP},
      {"save_as", saveAsAP},
      {"save-as-dialog", saveAsDialogAP},
***************
*** 523,528 ****
--- 539,550 ----
      {"next_document", nextDocumentAP},
      {"previous_document", prevDocumentAP},
      {"last_document", lastDocumentAP},
+ #ifdef SWITCH_DOCUMENTS_PATCH    
+     {"switch_documents", switchDocumentsAP},
+     {"switch_documents_reverse", switchDocumentsReverseAP},
+     {"switch_documents_end", switchDocumentsEndAP},
+     {"switch_documents_null", switchDocumentsNullAP},        
+ #endif    
      {"uppercase", capitalizeAP},
      {"lowercase", lowercaseAP},
      {"fill-paragraph", fillAP},
***************
*** 587,592 ****
--- 609,621 ----
  static WindowInfo *ShortMenuWindow;
  #endif
  
+ #ifdef SWITCH_DOCUMENTS_PATCH
+ void initialiseSwitchDocumentsListWrapper()
+ {
+     initialiseSwitchDocumentsList();
+ }
+ #endif
+ 
  void HidePointerOnKeyedEvent(Widget w, XEvent *event)
  {
      if (event && (event->type == KeyPress || event->type == KeyRelease)) {
***************
*** 672,677 ****
--- 701,707 ----
      window->closeItem = createMenuItem(menuPane, "close", "Close", 'C',
      	    doActionCB, "close", SHORT);
      createMenuItem(menuPane, "save", "Save", 'S', doActionCB, "save", SHORT);
+     createMenuItem(menuPane, "saveAll", "Save All", 'l', doActionCB, "save-all", SHORT);
      createMenuItem(menuPane, "saveAs", "Save As...", 'A', doActionCB,
      	    "save_as_dialog", SHORT);
      createMenuItem(menuPane, "revertToSaved", "Revert to Saved", 'R',
***************
*** 699,705 ****
      createMenuItem(menuPane, "print", "Print...", 'P', doActionCB, "print",
      	    SHORT);
      window->printSelItem = createMenuItem(menuPane, "printSelection",
!     	    "Print Selection...", 'l', doActionCB, "print_selection",
      	    SHORT);
      XtSetSensitive(window->printSelItem, window->wasSelected);
      createMenuSeparator(menuPane, "sep4", SHORT);
--- 729,735 ----
      createMenuItem(menuPane, "print", "Print...", 'P', doActionCB, "print",
      	    SHORT);
      window->printSelItem = createMenuItem(menuPane, "printSelection",
!     	    "Print Selection...", 't', doActionCB, "print_selection",
      	    SHORT);
      XtSetSensitive(window->printSelItem, window->wasSelected);
      createMenuSeparator(menuPane, "sep4", SHORT);
***************
*** 2817,2822 ****
--- 2847,2863 ----
      SaveWindow(window);
  }
  
+ static void saveAllAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
+ {
+     WindowInfo *window;
+ 
+     for (window = WindowList; window != NULL; window = window->next) {
+         if (CheckReadOnly(window))
+             continue;
+         SaveWindow(window);
+     }
+ }
+ 
  static void saveAsDialogAP(Widget w, XEvent *event, String *args,
  	Cardinal *nArgs) 
  {
***************
*** 3502,3507 ****
--- 3543,3574 ----
      LastDocument(WidgetToWindow(w));    
  }
  
+ #ifdef SWITCH_DOCUMENTS_PATCH
+ static void switchDocumentsAP(Widget w, XEvent *event, String *args,
+ 	Cardinal *nArgs)
+ {    
+     switchDocuments(WidgetToWindow(w), SWITCH_DOCUMENTS_PATCH_DIRECTION_NORMAL);    
+ }
+ 
+ static void switchDocumentsReverseAP(Widget w, XEvent *event, String *args,
+ 	Cardinal *nArgs)
+ {    
+     switchDocuments(WidgetToWindow(w), SWITCH_DOCUMENTS_PATCH_DIRECTION_REVERSE);    
+ }
+ 
+ static void switchDocumentsEndAP(Widget w, XEvent *event, String *args,
+ 	Cardinal *nArgs)
+ {    
+     switchDocumentsEnd(WidgetToWindow(w));    
+ }
+ 
+ static void switchDocumentsNullAP(Widget w, XEvent *event, String *args,
+ 	Cardinal *nArgs)
+ {    
+     //printf("switchDocumentsNull\n");
+ }
+ #endif
+ 
  static void capitalizeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
  {
      WindowInfo *window = WidgetToWindow(w);
diff -crB nedit5.5-orig/nedit.c nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/nedit.c
*** nedit5.5-orig/nedit.c	2013-07-01 12:31:20.282999000 +1000
--- nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/nedit.c	2013-07-01 12:32:25.125723000 +1000
***************
*** 392,397 ****
--- 392,401 ----
      /* Save the command which was used to invoke nedit for restart command */
      ArgV0 = argv[0];
  
+     #ifdef SWITCH_DOCUMENTS_PATCH
+     initialiseSwitchDocumentsListWrapper();
+     #endif
+ 
      /* Set locale for C library, X, and Motif input functions. 
         Reverts to "C" if requested locale not available. */
      XtSetLanguageProc(NULL, neditLanguageProc, NULL);
diff -crB nedit5.5-orig/nedit.h nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/nedit.h
*** nedit5.5-orig/nedit.h	2013-07-01 12:03:34.281055000 +1000
--- nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/nedit.h	2013-07-01 18:08:06.929718000 +1000
***************
*** 41,46 ****
--- 41,48 ----
  #endif
  #endif /*VMS*/
  
+ #define SWITCH_DOCUMENTS_PATCH
+ 
  /* Some default colors */
  #define NEDIT_DEFAULT_FG        "black"
  #define NEDIT_DEFAULT_TEXT_BG   "rgb:e5/e5/e5"
diff -crB nedit5.5-orig/window.c nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/window.c
*** nedit5.5-orig/window.c	2013-07-01 09:13:23.664029000 +1000
--- nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/window.c	2013-07-27 11:18:26.146010000 +1000
***************
*** 193,198 ****
--- 193,368 ----
  
  static WindowInfo *inFocusDocument = NULL;  	/* where we are now */
  static WindowInfo *lastFocusDocument = NULL;	    	/* where we came from */
+ 
+ #ifdef SWITCH_DOCUMENTS_PATCH
+ 
+ typedef struct SwitchDocumentsListNode
+ {
+     int windowIDdebug;
+     WindowInfo * focusDocument;
+     struct SwitchDocumentsListNode* next;
+     struct SwitchDocumentsListNode* previous;
+ } SwitchDocumentsList;
+ 
+ static SwitchDocumentsList* firstNodeInSwitchDocumentsList;
+ static SwitchDocumentsList* activeNodeInSwitchDocumentsList;
+ int switchDocumentsListTraverseDisableMarkActiveDocument;
+ struct timeval switchDocumentsClockLastSave;
+ int switchingDocumentsAtPresent;
+ 
+ struct timeval getTimeNow()
+ {
+     struct timeval timenow;
+     gettimeofday(&timenow, NULL);
+     /*
+     OLD:
+     time_t timenow;
+     time(&timenow);
+     */
+     return timenow;
+ }
+ 
+ void printWindowList()
+ {
+     printf("*****printWindowList:******\n");
+     printf("firstNodeInSwitchDocumentsList = %d\n", firstNodeInSwitchDocumentsList->windowIDdebug);
+     printf("activeNodeInSwitchDocumentsList = %d\n", activeNodeInSwitchDocumentsList->windowIDdebug);
+     SwitchDocumentsList* currentNode = firstNodeInSwitchDocumentsList;
+     WindowInfo *win;   
+      
+     while(currentNode->next != NULL)
+     {
+     	printf("\tcurrentNode = %d, currentNode pointer = %d\n", currentNode->windowIDdebug, currentNode->focusDocument);
+     	currentNode = currentNode->next;
+     }
+     /*
+     for(win = WindowList; win; win=win->next)
+     {
+     	printf("\twindowList pointer = %d\n", win);
+     } 
+     */
+ }
+ 
+ void initialiseSwitchDocumentsList()
+ {
+     //printf("initialiseSwitchDocumentsList\n");
+     switchDocumentsClockLastSave = getTimeNow();
+     firstNodeInSwitchDocumentsList = malloc(sizeof(SwitchDocumentsList));
+     firstNodeInSwitchDocumentsList->windowIDdebug = 0;
+     firstNodeInSwitchDocumentsList->focusDocument = NULL;
+     firstNodeInSwitchDocumentsList->next = NULL;
+     firstNodeInSwitchDocumentsList->previous = NULL;
+     activeNodeInSwitchDocumentsList = firstNodeInSwitchDocumentsList;
+     switchDocumentsListTraverseDisableMarkActiveDocument = 0;
+     switchingDocumentsAtPresent = 0;
+     //printWindowList();	//debug
+     //printf("finish initialiseSwitchDocumentsList\n");
+     
+ }
+ 
+ SwitchDocumentsList* switchDocumentsGetLastNodeInList()
+ {
+     SwitchDocumentsList* currentNode = firstNodeInSwitchDocumentsList;
+     SwitchDocumentsList* lastNodeInList = currentNode;
+     while(currentNode->next != NULL)
+     {
+     	lastNodeInList = currentNode;
+     	currentNode = currentNode->next;
+     }
+     return lastNodeInList;
+ }
+ 		    
+ SwitchDocumentsList* switchDocumentsListRemoveNode(SwitchDocumentsList* nodeToRemove)
+ {
+     //printf("switchDocumentsListRemoveNode\n");    
+     if(nodeToRemove->next != NULL)
+     {
+ 	if(nodeToRemove->previous == NULL)
+ 	{//nodeToRemove is first node in list
+ 
+     	    nodeToRemove->next->previous = NULL;
+ 	    firstNodeInSwitchDocumentsList = nodeToRemove->next;
+ 
+ 	}
+ 	else
+ 	{//nodeToRemove is not first node in list
+ 	    nodeToRemove->previous->next = nodeToRemove->next;
+ 	    nodeToRemove->next->previous = nodeToRemove->previous;
+ 	}
+ 	free(nodeToRemove);
+     }
+     else
+     {
+ 	printf("switchDocumentsListRemoveNode() error: removing dummy node is impossible: (nodeToRemove->next == NULL)\n");
+ 	exit(0);
+     }   
+ 
+     SwitchDocumentsList* lastNodeInList = switchDocumentsGetLastNodeInList();
+ 
+     //printWindowList();	//debug
+     //printf("finish switchDocumentsListRemoveNode\n");   
+         
+     return lastNodeInList;     //update activeNodeInSwitchDocumentsList (restore to last document in list) 
+ }
+ 
+ SwitchDocumentsList* switchDocumentsListRemove(WindowInfo * focusDocument)
+ {
+     SwitchDocumentsList* currentNode = firstNodeInSwitchDocumentsList;
+     SwitchDocumentsList* nodeToRemove = NULL;
+     int foundNodeToRemove = 0;
+     while(currentNode->next != NULL)
+     {
+     	//printf("currentNode = %d\n", currentNode->windowIDdebug);    
+     	if(currentNode->focusDocument == focusDocument)
+ 	{
+ 	    //printf("found node to remove");
+ 	    nodeToRemove = currentNode;
+ 	    foundNodeToRemove = 1;
+ 	}
+     	currentNode = currentNode->next;
+     }
+     SwitchDocumentsList* lastNodeInList = currentNode;
+     if(foundNodeToRemove)
+     {
+     	 lastNodeInList = switchDocumentsListRemoveNode(nodeToRemove);
+     }
+     else
+     {	
+     	 //printf("error: !foundNodeToRemove\n");
+     }
+     return lastNodeInList;
+ }
+ 
+ 
+ SwitchDocumentsList* switchDocumentsListAdd(WindowInfo * focusDocument)
+ {
+     //printf("switchDocumentsListAdd\n");
+     //printf("removing document %d\n", focusDocument);
+     switchDocumentsListRemove(focusDocument);	//remove previous instance if existent
+       
+     SwitchDocumentsList* currentNode = firstNodeInSwitchDocumentsList;
+     int lastNewWindowIDdebug = 0;
+     while(currentNode->next != NULL)
+     {
+ 	lastNewWindowIDdebug = currentNode->windowIDdebug;
+     	currentNode = currentNode->next;
+     }
+     currentNode->windowIDdebug = lastNewWindowIDdebug+1;
+     //printf("adding node = %d\n", currentNode->windowIDdebug);    
+     currentNode->focusDocument = focusDocument;
+     SwitchDocumentsList* newNode = malloc(sizeof(SwitchDocumentsList));
+     newNode->focusDocument = NULL;
+     newNode->next = NULL;
+     newNode->previous = currentNode;
+     currentNode->next = newNode;
+     //printWindowList();	//debug
+     //printf("finish switchDocumentsListAdd\n");  
+       
+     return currentNode;
+ }
+ 
+ #endif
+ 
  static int DoneWithMoveDocumentDialog;
  
  /*
***************
*** 772,777 ****
--- 942,955 ----
  	}
      }
      
+     #ifdef SWITCH_DOCUMENTS_PATCH
+     //printf("CreateWindow\n");    
+     //printf("window = %d\n", window);  
+     activeNodeInSwitchDocumentsList = switchDocumentsListAdd(window);
+     //printWindowList();	//debug
+     //printf("CreateWindow\n");      
+     #endif
+         
      return window;
  }
  
***************
*** 3683,3689 ****
      
      if (window)
      	lastFocusDocument = window;
! 	
      return prev;
  }
  
--- 3861,3867 ----
      
      if (window)
      	lastFocusDocument = window;
!     	
      return prev;
  }
  
***************
*** 3697,3702 ****
--- 3875,3895 ----
      if (window)
      	inFocusDocument = window;
  
+     #ifdef SWITCH_DOCUMENTS_PATCH
+     //printf("MarkActiveDocument\n");    
+     //printf("inFocusDocument = %d\n", inFocusDocument);  
+     if(switchDocumentsListTraverseDisableMarkActiveDocument == 0)
+     {
+ 	if(switchingDocumentsAtPresent == 1)
+ 	{//in strange case user is switching documents while creating a new window for example?
+     	    activeNodeInSwitchDocumentsList = switchDocumentsListAdd(activeNodeInSwitchDocumentsList->focusDocument);	
+ 	    switchingDocumentsAtPresent = 0; 
+ 	} 
+     	activeNodeInSwitchDocumentsList = switchDocumentsListAdd(inFocusDocument);
+     }  
+     //printf("finish MarkLastDocument\n");      
+     #endif
+ 
      return prev;
  }
  
***************
*** 3761,3766 ****
--- 3954,4026 ----
  	
  }
  
+ #ifdef SWITCH_DOCUMENTS_PATCH
+ 
+ void switchDocumentsEnd(WindowInfo *window)
+ {
+ 	//printf("switchDocumentsEnd\n");  
+ 	if(switchingDocumentsAtPresent == 1)
+ 	{
+     		activeNodeInSwitchDocumentsList = switchDocumentsListAdd(activeNodeInSwitchDocumentsList->focusDocument);
+ 		switchingDocumentsAtPresent = 0;
+ 	}
+ }
+ /*
+ ** Switch through last active windows
+ */
+ void switchDocuments(WindowInfo *window, int direction)
+ {
+     //printf("switchDocuments\n");  
+     WindowInfo *win;
+ 
+     if((activeNodeInSwitchDocumentsList->previous != NULL) || (activeNodeInSwitchDocumentsList->next->next != NULL))
+     {
+ 	if(direction == SWITCH_DOCUMENTS_PATCH_DIRECTION_NORMAL)
+ 	{
+ 	    if(activeNodeInSwitchDocumentsList->previous != NULL)
+ 	    {
+ 		activeNodeInSwitchDocumentsList = activeNodeInSwitchDocumentsList->previous;
+ 	    }
+ 	    else
+ 	    {//go around in circles...
+ 		activeNodeInSwitchDocumentsList = switchDocumentsGetLastNodeInList();
+ 	    }
+ 	}
+ 	else if(direction != SWITCH_DOCUMENTS_PATCH_DIRECTION_NORMAL)
+ 	{
+ 	    if(activeNodeInSwitchDocumentsList->next->next != NULL)
+ 	    {
+ 		activeNodeInSwitchDocumentsList = activeNodeInSwitchDocumentsList->next;
+ 	    }
+ 	    else
+ 	    {//go around in circles...
+ 		activeNodeInSwitchDocumentsList = firstNodeInSwitchDocumentsList;
+ 	    }	
+ 	}
+     }
+     //printf("activeNodeInSwitchDocumentsList = ", activeNodeInSwitchDocumentsList);
+     switchingDocumentsAtPresent = 1;
+         
+     for(win = WindowList; win; win=win->next)
+     	if (activeNodeInSwitchDocumentsList->focusDocument == win)
+ 	    break;
+     
+     if (!win)
+     	return;
+ 
+     switchDocumentsListTraverseDisableMarkActiveDocument = 1;
+ 
+     if (window->shell == win->shell)
+ 	RaiseDocument(win);
+     else
+     	RaiseDocumentWindow(win);
+ 
+     switchDocumentsListTraverseDisableMarkActiveDocument = 0;	
+     //printf("finish switchDocuments\n");  
+ }
+ #endif
+ 
+  
  /*
  ** make sure window is alive is kicking
  */
***************
*** 3934,3939 ****
--- 4194,4203 ----
      if (!window)
      	return;
      
+     #ifdef SWITCH_DOCUMENTS_PATCH
+     switchDocumentsListRemove(window);   
+     #endif
+ 
      XtDestroyWidget(window->splitPane);
  }
  
diff -crB nedit5.5-orig/window.h nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/window.h
*** nedit5.5-orig/window.h	2013-07-01 12:57:20.103988000 +1000
--- nedit5.5-withSaveAllAndIncreaseFindDialogboxCharlengAndCtrlTabSwitchBetweenMultipleDocuments/window.h	2013-07-27 09:42:59.370790000 +1000
***************
*** 89,94 ****
--- 89,100 ----
  void NextDocument(WindowInfo *window);
  void PreviousDocument(WindowInfo *window);
  void LastDocument(WindowInfo *window);
+ #ifdef SWITCH_DOCUMENTS_PATCH
+ #define SWITCH_DOCUMENTS_PATCH_DIRECTION_NORMAL (1)
+ #define SWITCH_DOCUMENTS_PATCH_DIRECTION_REVERSE (2)
+ void switchDocuments(WindowInfo *window, int direction);
+ void switchDocumentsEnd(WindowInfo *window);
+ #endif
  int NDocuments(WindowInfo *window);
  WindowInfo *MoveDocument(WindowInfo *toWindow, WindowInfo *window);
  WindowInfo *DetachDocument(WindowInfo *window);
