diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\help.c tde51v\help.c
--- tde51u\help.c	Fri Sep 15 11:11:26 2006
+++ tde51v\help.c	Tue May 01 14:39:44 2007
Prereq: 5.1u
@@ -17,10 +17,10 @@
 #include "letters.h"
 #define NULL 0
 
-#define VERSION  "   Version 5.1u   "   /* This width must not change! */
-#define DATE     "September 15, 2006"   /* This width must not change! */
-#define PVERSION "5.1u"
-#define PDATE    "September 15, 2006"
+#define VERSION  "   Version 5.1v   "   /* This width must not change! */
+#define DATE     "   May 1, 2007    "   /* This width must not change! */
+#define PVERSION "5.1v"
+#define PDATE    "May 1, 2007"
 
 
 const char * const tde_help =
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\common.h tde51v\common.h
--- tde51u\common.h	Sat Jul 23 00:21:00 2005
+++ tde51v\common.h	Sat Jul 23 00:21:00 2005
@@ -415,6 +415,7 @@
 extern const char win9[];
 extern const char win9b[];              /* added by jmh 031116 */
 extern const char win9a[];              /* added by jmh */
+extern const char win18[];              /* added by jmh 070501 */
 extern const char win19[];
 extern const char win20[];              /* added by jmh 990502 */
 extern const char win21a[];             /* ditto */
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\config\tde.cfg tde51v\config\tde.cfg
--- tde51u\config\tde.cfg	Fri Sep 15 12:27:36 2006
+++ tde51v\config\tde.cfg	Tue May 01 20:29:18 2007
@@ -1,12 +1,12 @@
 ;                        TDE, the Thomson-Davis Editor
-;                                 Version 5.1u
-;                              September 15, 2006
+;                                 Version 5.1v
+;                                 May 1, 2007
 ;                           Frank Davis / Jason Hood
 ;
 ;
 ;
 ; These are the default function key, mode, and color assignments in
-;   the distribution version of tde, version 5.1u.  Please feel free to
+;   the distribution version of tde, version 5.1v.  Please feel free to
 ;   change/modify these function assignments to suit your tastes.
 ;
 ;
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\config\tdecfg tde51v\config\tdecfg
--- tde51u\config\tdecfg	Fri Sep 15 12:27:48 2006
+++ tde51v\config\tdecfg	Tue May 01 20:29:34 2007
@@ -1,6 +1,6 @@
 ;                        TDE, the Thomson-Davis Editor
-;                                 Version 5.1u
-;                              September 15, 2006
+;                                 Version 5.1v
+;                                 May 1, 2007
 ;                           Frank Davis / Jason Hood
 ;
 ;
@@ -10,7 +10,7 @@
 ;
 ;
 ; These are the default function key, mode, and color assignments in
-;   the distribution version of tde, version 5.1u.  Please feel free to
+;   the distribution version of tde, version 5.1v.  Please feel free to
 ;   change/modify these function assignments to suit your tastes.
 ;
 ;
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\file.c tde51v\file.c
--- tde51u\file.c	Fri Sep 15 17:46:30 2006
+++ tde51v\file.c	Tue May 01 17:54:48 2007
@@ -97,7 +97,6 @@
 /*
  * Name:    write_file
  * Purpose: To write text to a file
- *           way.
  * Date:    June 5, 1991
  * Passed:  name:  name of disk file or device
  *          open_mode:  fopen flags to be used in open
@@ -554,6 +553,8 @@  * Name:    backup_file
  * Purpose: To make a back-up copy of current file.
  * Date:    June 5, 1991
  * Passed:  window:  current window pointer
+ *
+ * jmh 070430: always succeed, otherwise nothing else is possible.
  */
 int  backup_file( TDE_WIN *window )
 {
@@ -562,10 +563,8 @@  * Name:    backup_file
 int  old_line_buff_len;
 int  old_tabout_buff_len;
 int  old_copied;
-int  rc;
 file_infos *file;
 
-   rc = OK;
    file = window->file_info;
    if (file->backed_up == FALSE  &&  file->modified == TRUE) {
       old_line_buff = malloc( MAX_LINE_LENGTH );
@@ -576,25 +575,22 @@  * Name:    backup_file
          old_copied = g_status.copied;
          memcpy( old_line_buff, g_status.line_buff, MAX_LINE_LENGTH );
          memcpy( old_tabout_buff, g_status.tabout_buff, MAX_LINE_LENGTH );
-         if ((rc = save_backup( window )) != ERROR) {
-            file->backed_up = TRUE;
+         if (save_backup( window ) != ERROR)
             set_ftime( file->backup_fname, &file->ftime );
-         }
          memcpy( g_status.line_buff, old_line_buff, MAX_LINE_LENGTH );
          memcpy( g_status.tabout_buff, old_tabout_buff, MAX_LINE_LENGTH );
          g_status.line_buff_len = old_line_buff_len;
          g_status.tabout_buff_len = old_tabout_buff_len;
          g_status.copied = old_copied;
-      } else {
+      } else
          error( WARNING, window->bottom_line, main4 );
-         rc = ERROR;
-      }
       if (old_line_buff != NULL)
          free( old_line_buff );
       if (old_tabout_buff != NULL)
          free( old_tabout_buff );
+      file->backed_up = TRUE;
    }
-   return( rc );
+   return( OK );
 }
 
 
@@ -1783,6 +1779,8 @@  * Name:    search_and_seize
          if (g_status.sas_dta == NULL) {
             name = g_status.sas_argv[g_status.sas_arg];
             if (is_glob( name )) {
+               if (strstr( name, "..." ))
+                  set_prompt( win18, bottom_line );
                g_status.sas_dta = find_files( name );
                if (g_status.sas_dta != NULL) {
                   rc = OK;
@@ -2258,6 +2256,9 @@  * Name:     edit_next_file
                   name = namebuf;
                   rc = list_and_pick( name, win );
                } else if (is_glob( name )) {
+                  if (strstr( name, "..." ))
+                     set_prompt( win18, win == NULL ? g_display.end_line
+                                                    : win->bottom_line );
                   g_status.dta = find_files( name );
                   if (g_status.dta != NULL) {
                      name = g_status.dta->name;
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\findrep.c tde51v\findrep.c
--- tde51u\findrep.c	Mon Jan 02 11:29:08 2006
+++ tde51v\findrep.c	Tue May 01 14:39:12 2007
@@ -272,7 +272,7 @@  * Name:     ask_wrap_replace
       /*
        * search has wrapped. continue or quit? - default continue
        */
-      rc = get_response( find3, window->bottom_line, R_ALL,
+      rc = get_response( find3, window->bottom_line, R_NOMACRO,
                          2, L_CONTINUE, OK, L_QUIT, ERROR );
    }
    if (rc == ERROR)
@@ -2674,6 +2674,9 @@  * Name:    add_search_line
  * Returns: TRUE if line added, FALSE if not (search should stop)
  * Notes:   if results_window is NULL a new window is created, otherwise the
  *           line is appended to the current.
+ *
+ * 070501:  pad line numbers according to current file length and column
+ *           numbers to two digits.
  */
 int  add_search_line( line_list_ptr ll, long rline, int rcol )
 {
@@ -2714,11 +2717,13 @@  * Name:    add_search_line
 
    w.file_info = search_file;
    flen = strlen( relative_path( (char *)buf, &w, FALSE ) );
-   len  = 4 + numlen( rline ) + numlen( rcol );
+   len  = 4 + numlen( search_file->length )
+          + (numlen( rcol ) > 2 ? numlen( rcol ) : 2);
    llen = ll->len;
    if (llen + flen + len > MAX_LINE_LENGTH)
       llen -= flen + len;
-   len = flen + sprintf( (char *)buf + flen, ":%ld:%d: ", rline, rcol );
+   len = flen + sprintf( (char *)buf + flen, ":%*ld:%2d: ",
+                         numlen( search_file->length ), rline, rcol );
    memcpy( buf + len, ll->line, llen );
    temp_ll = new_line_text( buf, len + llen, 0, &rc );
    if (rc == OK) {
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\movement.c tde51v\movement.c
--- tde51u\movement.c	Thu Aug 18 17:13:28 2005
+++ tde51v\movement.c	Tue May 01 14:49:56 2007
@@ -1513,8 +1513,10 @@  * Name:    browser_parse
  *           without line numbers).
  *          Set rcol to -1 if no column was found.
  *
- * jmh 040714: parse a results window separately (to recognise spaces in names
- *              and pipes [returns name = ""]).
+ * 040714:  parse a results window separately (to recognise spaces in names
+ *           and pipes [returns name = ""]).
+ * 070501:  recognise "[]()" as delimiters (for "filename(linenum)" and
+ *           "filename [linenum]" formats).
  */
 static int  browser_parse( char *name, long *rline, int *rcol )
 {
@@ -1544,11 +1546,8 @@  * Name:    browser_parse
       if (j < len) {
          token[tokens] = line + j;
          t_len[tokens] = 0;
-         while (j < len  &&  line[j] != ':'  &&  (results  ||
-                            (line[j] != ' '
-                         &&  line[j] != '\t'
-                         &&  line[j] != ';'
-                         &&  line[j] != ','))) {
+         while (j < len  &&  line[j] != ':'  &&
+                (results  ||  (strchr( " \t;,[]()", line[j] ) == NULL))) {
             ++t_len[tokens];
             ++j;
          }
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\prompts.c tde51v\prompts.c
--- tde51u\prompts.c	Thu Sep 14 11:35:58 2006
+++ tde51v\prompts.c	Tue May 01 17:51:00 2007
@@ -530,6 +530,7 @@ const char * const days[2][7] = {
 const char win9b[] = "Pattern not found";       /* added by jmh 031116 */
 const char win9a[] = "Use the <Grep> key for more files";      /* jmh */
 
+const char win18[]  = "Gathering file names..."; /* jmh 070501 */
 const char win19[]  = "Searching:  ";
 
 const char win20[] = "Goto window: ";           /* added by jmh 990502 */
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\readme_s.txt tde51v\readme_s.txt
--- tde51u\readme_s.txt	Fri Sep 15 12:51:02 2006
+++ tde51v\readme_s.txt	Tue May 01 20:26:46 2007
@@ -1,7 +1,7 @@
 
                          TDE, the Thomson-Davis Editor
-                                  Version 5.1u
-                               September 15, 2006
+                                  Version 5.1v
+                                  May 1, 2007
                             Frank Davis / Jason Hood
 
 
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\tde.rc tde51v\tde.rc
--- tde51u\tde.rc	Mon Aug 28 12:02:14 2006
+++ tde51v\tde.rc	Tue May 01 20:27:56 2007
@@ -12,8 +12,8 @@
 1 ICON tde.ico
 
 VS_VERSION_INFO VERSIONINFO
-  FILEVERSION    5,1,21,0
-  PRODUCTVERSION 5,1,21,0
+  FILEVERSION    5,1,22,0
+  PRODUCTVERSION 5,1,22,0
   FILEOS   VOS__WINDOWS32
   FILETYPE VFT_APP
 BEGIN
@@ -23,12 +23,12 @@
     BEGIN
       VALUE "CompanyName",      "Jason Hood"
       VALUE "FileDescription",  "TDE, the Thomson-Davis Editor"
-      VALUE "FileVersion",      "5.1u"
+      VALUE "FileVersion",      "5.1v"
       VALUE "InternalName",     "tde"
       VALUE "LegalCopyright",   "Public Domain"
       VALUE "OriginalFilename", "tdew.exe"
       VALUE "ProductName",      "TDE"
-      VALUE "ProductVersion",   "5.1u"
+      VALUE "ProductVersion",   "5.1v"
       VALUE "Comments",         "http://tde.adoxa.cjb.net/"
     END
   END
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\todo.txt tde51v\todo.txt
--- tde51u\todo.txt	Fri Sep 15 11:44:24 2006
+++ tde51v\todo.txt	Tue May 01 20:21:42 2007
@@ -9,6 +9,10 @@
   Copying block doesn't check for long line (see Frank's defect 4/9 msg).
     Above three will be fixed with the Line changes.
 
+Should grep test if a file is already loaded?  Ignore loaded files?
+
+Toggle to remove current and dirty line colors?
+
 Make ruler part of the file, add tabs (smart = physical, fixed = logical).
 Incorporate cursor cross into ruler?  (Display optimisation.)
 
@@ -20,6 +24,9 @@
      Wild/regx keywords? Just expand sets (mov[bwl] -> movb movw movl)?
      Tags setting (HTML: "Tags < >" "Tags </ >" "Tags a b font table").
      Allow custom color keywords ("Prepro green" "Prepro isspace").
+     Display mismatched brackets in the bad colour?
+
+Startup/shutdown/"write-hook" macros?
 
 Undo!
 
@@ -35,7 +42,7 @@
 others can still have tabs (no, maybe not).
 
 Non-US keyboards sometimes revert to using US keys (need more info).
-
+DR-DOS keyboard troubles?
 Linux: have another look at xterm keyboard, update help and config.
 
 Win32: use API to provide localisation defaults?
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\unix\console.c tde51v\unix\console.c
--- tde51u\unix\console.c	Sat Dec 06 10:47:02 2003
+++ tde51v\unix\console.c	Sun Apr 01 11:20:16 2007
@@ -373,7 +373,7 @@  * Name:    getkey
 long new_key;
 int  shift_state;
 int  alt_esc;
-char escape[8];
+char escape[12];
 int  esclen;
 int  j, k;
 
@@ -384,6 +384,16 @@  * Name:    getkey
 
    while ((ch = getch( )) == ERR) ;
 
+#if 0 /* intended for testing Unix escape sequences */
+   if (ch == 13)  /* ^M / enter */
+     return( _FUNCTION|Rturn );
+   if (ch == 17)  /* ^Q */
+     return( _FUNCTION|Quit );
+   if (ch == 28)  /* ^\ */
+     return( _FUNCTION|PullDown );
+   return( ch );
+#endif
+
    if (g_status.control_break)
       return( _CONTROL_BREAK );
 
@@ -392,7 +402,7 @@  * Name:    getkey
 
    if (ch == 27) {
       while ((ch = getch()) != ERR) {
-         if (esclen == 5) {
+         if (esclen == sizeof(escape) - 1) {
             while (getch() != ERR) ;
             goto go_again;
          }
@@ -404,26 +414,22 @@  * Name:    getkey
          alt_esc = TRUE;
          ch = escape[0];
       } else {
-         if (escape[0] == 27 && escape[1] == '[') {
+         if (escape[0] == 27) {
             alt_esc = TRUE;
-            key = 2;
-            esclen -= 2;
-         } else if (escape[0] == '[') {
             key = 1;
             --esclen;
-         } else
-            goto go_again;
-         if (esclen > 3)
+         }
+         if (esclen > 6)
             goto go_again;
-         k = esc_idx[esclen - 1].last;
-         for (j = esc_idx[esclen - 1].first; j <= k; ++j) {
-            if (memcmp( esc_seq[j].seq, escape + key, esclen ) == 0) {
-               key = esc_seq[j].key;
+         k = esc_idx[esclen];
+         for (j = esc_idx[esclen - 1]; j < k; ++j) {
+            if (memcmp( esc_seq[j].key, escape + key, esclen ) == 0) {
+               key = esc_seq[j].key_index;
                ch  = 0;
                break;
             }
          }
-         if (j > k)
+         if (j >= k)
             goto go_again;
       }
    }
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\unix\keys.h tde51v\unix\keys.h
--- tde51u\unix\keys.h	Tue Nov 25 21:27:02 2003
+++ tde51v\unix\keys.h	Sun Apr 01 14:28:08 2007
@@ -143,63 +143,85 @@ static const int char_to_scan[128] = {
 
 
 /*
- * Translate escape sequences to TDE keys.  "\e[" is implied.
+ * Translate escape sequences to TDE keys.  "\e" is implied.
+ * 070401: modified to handle SuSE/KDE sequences.
  */
-static const struct {
-   char seq[4];
-   long key;
-} esc_seq[] = {
-   { "A",     _UP            }, /*  0 */
-   { "B",     _DOWN          }, /*  1 */
-   { "C",     _RIGHT         }, /*  2 */
-   { "D",     _LEFT          }, /*  3 */
-   { "G",     _CENTER        }, /*  4 */
-   { "P",     _CONTROL_BREAK }, /*  5 */
-   { "H",     _HOME          }, /*  6 */
-   { "F",     _END           }, /*  7 */
-
-   { "1~",    _HOME          }, /*  8 */
-   { "2~",    _INS           }, /*  9 */
-   { "3~",    _DEL           }, /* 10 */
-   { "4~",    _END           }, /* 11 */
-   { "5~",    _PGUP          }, /* 12 */
-   { "6~",    _PGDN          }, /* 13 */
-   { "[A",    _F1            }, /* 14 */
-   { "[B",    _F2            }, /* 15 */
-   { "[C",    _F3            }, /* 16 */
-   { "[D",    _F4            }, /* 17 */
-   { "[E",    _F5            }, /* 18 */
-
-   { "11~",   _F1            }, /* 19 */
-   { "12~",   _F2            }, /* 20 */
-   { "13~",   _F3            }, /* 21 */
-   { "14~",   _F4            }, /* 22 */
-   { "15~",   _F5            }, /* 23 */
-   { "17~",   _F6            }, /* 24 */
-   { "18~",   _F7            }, /* 25 */
-   { "19~",   _F8            }, /* 26 */
-   { "20~",   _F9            }, /* 27 */
-   { "21~",   _F10           }, /* 28 */
-   { "23~",   _F11           }, /* 29 */
-   { "24~",   _F12           }, /* 30 */
-   { "25~",   _SHIFT+_F1     }, /* 31 */
-   { "26~",   _SHIFT+_F2     }, /* 32 */
-   { "28~",   _SHIFT+_F3     }, /* 33 */
-   { "29~",   _SHIFT+_F4     }, /* 34 */
-   { "31~",   _SHIFT+_F5     }, /* 35 */
-   { "32~",   _SHIFT+_F6     }, /* 36 */
-   { "33~",   _SHIFT+_F7     }, /* 37 */
-   { "34~",   _SHIFT+_F8     }, /* 38 */
+static const CONFIG_DEFS esc_seq[] = {
+   { "OM",     _SHIFT+_ENTER  },  /*  0 */
+   { "OP",     _F1            },  /*  1 */
+   { "OQ",     _F2            },  /*  2 */
+   { "OR",     _F3            },  /*  3 */
+   { "OS",     _F4            },  /*  4 */
+   { "[A",     _UP            },  /*  5 */
+   { "[B",     _DOWN          },  /*  6 */
+   { "[C",     _RIGHT         },  /*  7 */
+   { "[D",     _LEFT          },  /*  8 */
+   { "[F",     _END           },  /*  9 */
+   { "[G",     _CENTER        },  /* 10 */
+   { "[H",     _HOME          },  /* 11 */
+   { "[P",     _CONTROL_BREAK },  /* 12 */
+   { "[Z",     _SHIFT+_TAB    },  /* 13 */
+   { "[a",     _SHIFT+_UP     },  /* 14 */
+   { "[b",     _SHIFT+_DOWN   },  /* 15 */
+   { "[c",     _SHIFT+_RIGHT  },  /* 16 */
+   { "[d",     _SHIFT+_LEFT   },  /* 17 */
+
+   { "O2P",    _SHIFT+_F1     },  /* 18 */
+   { "O2Q",    _SHIFT+_F2     },  /* 19 */
+   { "O2R",    _SHIFT+_F3     },  /* 20 */
+   { "O2S",    _SHIFT+_F4     },  /* 21 */
+   { "[1~",    _HOME          },  /* 22 */
+   { "[2F",    _SHIFT+_END    },  /* 23 */
+   { "[2H",    _SHIFT+_HOME   },  /* 24 */
+   { "[2~",    _INS           },  /* 25 */
+   { "[3~",    _DEL           },  /* 26 */
+   { "[4~",    _END           },  /* 27 */
+   { "[5~",    _PGUP          },  /* 28 */
+   { "[6~",    _PGDN          },  /* 29 */
+   { "[[A",    _F1            },  /* 30 */
+   { "[[B",    _F2            },  /* 31 */
+   { "[[C",    _F3            },  /* 32 */
+   { "[[D",    _F4            },  /* 33 */
+   { "[[E",    _F5            },  /* 34 */
+
+   { "[11~",   _F1            },  /* 35 */
+   { "[12~",   _F2            },  /* 36 */
+   { "[13~",   _F3            },  /* 37 */
+   { "[14~",   _F4            },  /* 38 */
+   { "[15~",   _F5            },  /* 39 */
+   { "[17~",   _F6            },  /* 40 */
+   { "[18~",   _F7            },  /* 41 */
+   { "[19~",   _F8            },  /* 42 */
+   { "[20~",   _F9            },  /* 43 */
+   { "[21~",   _F10           },  /* 44 */
+   { "[23~",   _F11           },  /* 45 */
+   { "[24~",   _F12           },  /* 46 */
+   { "[25~",   _SHIFT+_F1     },  /* 47 */
+   { "[26~",   _SHIFT+_F2     },  /* 48 */
+   { "[28~",   _SHIFT+_F3     },  /* 49 */
+   { "[29~",   _SHIFT+_F4     },  /* 50 */
+   { "[31~",   _SHIFT+_F5     },  /* 51 */
+   { "[32~",   _SHIFT+_F6     },  /* 52 */
+   { "[33~",   _SHIFT+_F7     },  /* 53 */
+   { "[34~",   _SHIFT+_F8     },  /* 54 */
+   { "[5;2",   _SHIFT+_PGUP   },  /* 55 */
+   { "[6;2",   _SHIFT+_PGDN   },  /* 56 */
+
+   { "[2;2~",  _SHIFT+_INS    },  /* 57 */
+   { "[3;2~",  _SHIFT+_DEL    },  /* 58 */
+
+   { "[15;2~", _SHIFT+_F5     },  /* 59 */
+   { "[17;2~", _SHIFT+_F6     },  /* 60 */
+   { "[18;2~", _SHIFT+_F7     },  /* 61 */
+   { "[19;2~", _SHIFT+_F8     },  /* 62 */
+   { "[20;2~", _SHIFT+_F9     },  /* 63 */
+   { "[21;2~", _SHIFT+_F10    },  /* 64 */
+   { "[23;2~", _SHIFT+_F11    },  /* 65 */
+   { "[24;2~", _SHIFT+_F12    },  /* 66 */
 };
 
 
 /*
  * Index positions for the length of each sequence.
  */
-static const struct {
-   int first, last;
-} esc_idx[] = {
-   {  0,  7 },
-   {  8, 18 },
-   { 19, 38 },
-};
+static const int esc_idx[] = { 0, 0, 18, 35, 57, 59, 67 };
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\update.txt tde51v\update.txt
--- tde51u\update.txt	Fri Sep 15 10:51:06 2006
+++ tde51v\update.txt	Tue May 01 20:22:12 2007
@@ -846,3 +846,19 @@
 September 15, 2006: added InflateTabs, PTabSize & LTabSize settings to syntax.
 
 Uploaded 5.1u.
+
+September 19, 2006: fixed potential problem closing hidden windows (VC-compiled
+                     version crashes).
+September 20, 2006: fixed macros that ask to wrap.
+April 1, 2007: fixed SuSE/KDE keyboard problems (more escape sequences).
+April 22, 2007: Win32: fixed Ctrl+C on Win9X.
+April 30, 2007: always say the backup succeeded, to avoid a deadlock.
+May 1, 2007: pad search results line numbers to current file length and column
+              numbers to two digits;
+             browser can handle "filename(line)" and "filename [line]";
+             corrected scratch numbering (due to closing out of order);
+             fixed potential problem when closing a split browser window;
+             adjust (visible) window letters after closing;
+             display a message when globbing "...".
+
+Uploaded 5.1v.
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\win32\console.c tde51v\win32\console.c
--- tde51u\win32\console.c	Fri Sep 15 18:03:22 2006
+++ tde51v\win32\console.c	Sun Apr 22 17:32:00 2007
@@ -98,6 +98,8 @@  * Name:    console_init
 void console_init( struct vcfg *cfg )
 {
 SECURITY_ATTRIBUTES sa = { sizeof(sa), NULL, TRUE };
+OSVERSIONINFO osvi;
+DWORD mode;
 
    conout = CreateConsoleScreenBuffer( GENERIC_READ | GENERIC_WRITE,
                                        FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -112,8 +114,15 @@  * Name:    console_init
                                  &sa, OPEN_EXISTING, 0, 0 );
 
    GetConsoleMode( conin, &conmode );
-   SetConsoleMode( conin, ENABLE_EXTENDED_FLAGS | ENABLE_MOUSE_INPUT
-                          | (conmode & ENABLE_QUICK_EDIT) );
+   /*
+    * 070422: Win9X doesn't like the extended flag (using Ctrl+C will
+    *         SIGSEGV), so test the version and adjust the flags accordingly.
+    */
+   osvi.dwOSVersionInfoSize = sizeof(osvi);
+   GetVersionEx( &osvi );
+   mode = osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
+          ? ENABLE_EXTENDED_FLAGS | (conmode & ENABLE_QUICK_EDIT) : 0;
+   SetConsoleMode( conin, mode | ENABLE_MOUSE_INPUT );
 
    page( 1 );
    video_config( cfg );
diff -u -F ^Begin( -F = {$ -F ^ \* Name: -r tde51u\window.c tde51v\window.c
--- tde51u\window.c	Wed Sep 13 17:16:48 2006
+++ tde51v\window.c	Tue May 01 16:04:58 2007
@@ -1631,9 +1631,9 @@  * Name:    finish
  */
 int  finish( TDE_WIN *window )
 {
-register TDE_WIN *wp;   /* for scanning other windows */
-register TDE_WIN *win;  /* register pointer for window */
-file_infos *file, *fp;  /* for scanning other files */
+register TDE_WIN *wp, *wn;      /* for scanning other windows */
+register TDE_WIN *win;          /* register pointer for window */
+file_infos *file, *fp;          /* for scanning other files */
 int  poof;
 int  top;
 int  bottom;
@@ -1660,18 +1660,19 @@  * Name:    finish
       /*
        * remove all hidden windows that point to same file
        */
-      for (wp = g_status.window_list; wp != NULL; wp = wp->next) {
+      for (wp = g_status.window_list; wp != NULL; wp = wn) {
+         wn = wp->next;
          if (wp->file_info == file) {
             if (!wp->visible) {
                if (wp->prev == NULL) {
-                  if (wp->next == NULL)
+                  if (wn == NULL)
                      g_status.stop = TRUE;
                   else
-                     g_status.window_list = wp->next;
+                     g_status.window_list = wn;
                } else
-                  wp->prev->next = wp->next;
-               if (wp->next)
-                  wp->next->prev = wp->prev;
+                  wp->prev->next = wn;
+               if (wn)
+                  wn->prev = wp->prev;
                my_free( wp->title );
                free( wp );
                --file->ref_count;
@@ -1868,8 +1869,16 @@  * Name:    finish
          }
          file_change = file->file_no;
 
-         if (file->scratch  &&  file->scratch == g_status.scratch_count)
-            --g_status.scratch_count;
+         if (file->scratch  &&  file->scratch == g_status.scratch_count) {
+            /*
+             * find the new highest scratch number
+             */
+            file->scratch = g_status.scratch_count = 0;
+            for (fp = g_status.file_list; fp != NULL; fp = fp->next) {
+               if (fp->scratch > g_status.scratch_count)
+                  g_status.scratch_count = fp->scratch;
+            }
+         }
 
          /*
           * no window now refers to this file, so remove file from the list
@@ -1940,6 +1949,22 @@  * Name:    finish
       if (diff.defined  &&  (diff.w1 == win  ||  diff.w2 == win))
          diff.defined = FALSE;
 
+      if (!file_change  &&  win->letter != LAST_WINDOWLETTER) {
+         int let = (int)(strchr( windowletters, win->letter )
+                         - (char *)windowletters);
+         for (wp = g_status.window_list; wp != NULL; wp = wp->next) {
+            if (wp->file_info == file  &&  wp->letter != LAST_WINDOWLETTER) {
+               letter_index = (int)(strchr( windowletters, wp->letter )
+                                    - (char *)windowletters);
+               if (letter_index > let) {
+                  wp->letter = windowletters[letter_index - 1];
+                  if (wp->visible)
+                     show_window_number_letter( wp );
+               }
+            }
+         }
+      }
+
       /*
        * free the memory taken by the window structure
        */
@@ -1980,7 +2005,7 @@  * Name:    finish
       if (win == results_window)
          results_window = find_file_window( results_file );
       if (win == browser_window)
-         browser_window = find_file_window( browser_window->file_info );
+         browser_window = find_file_window( file );
 
    } else {
       if (g_status.sas_defined) {
