Recent files >16

Ideas for new features

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
IanOfYork
Posts: 80
Joined: Sat Nov 04, 2017 11:54 am
Location: York, England

Recent files >16

Post by IanOfYork »

The recent files lists (at the end of the file menu and at the end of the File/Workspace menu) are limited to 16 entries.
Since I (currently) have 42 workspaces and a tall screen, a list of 50 would be fine in both cases.

Please just remove the limit (or at least make it larger).

Add an option to display the list sorted by name instead of by "recentness".
IanOfYork
Posts: 80
Joined: Sat Nov 04, 2017 11:54 am
Location: York, England

Re: Recent files >16

Post by IanOfYork »

48 TWS files now. Is there any real reason to stop the pulldown list at 50?
Maybe the left sidebar could have an option for a view of all known TWS files?
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Re: Recent files >16

Post by ben_josephs »

I also would like longer lists.

However, I always use workspaces and I don't have much need for the recently-used document file list.

As for workspaces (I have far more than 50 of them), I keep them all in a single directory, d:\t. I can list them at the command line by entering dir d:\t, or get Windows File Explorer to list them by running d:\t (start d:\t on the command line). Either way I can sort them however I like.

An advantage of keeping a workspace in a directory different from the ones that contain any of the files in the workspace is that in that case TextPad stores the whole file paths in the workspace. If all the workspaces are in the same directory I can, with a suitable script, search in them for files that I know I edited last week, but I can't remember which workspace I edited them in.
IanOfYork
Posts: 80
Joined: Sat Nov 04, 2017 11:54 am
Location: York, England

Re: Recent files >16

Post by IanOfYork »

Mostly, my TWS files are in the root directory of their "project".
However, it is an interesting thought about putting them all into the same directory.
I will ponder on such ...

I currently have a trivial "twsfiles" script that finds all of the TWS files.

I also have a "TWSdump" script that lists all of the referenced files.
The file format was a pain to understand and not documented anywhere as far as I know.

I am hoping that when I eventually do upgrade to TextPad version 9, I will find all of the TWS files have been converted to (simple to parse) XML. ;-)
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Re: Recent files >16

Post by ben_josephs »

Here's a Python script that outputs the names of the document files in a workspace file. It handles both very old-style (TextPad version < 7) ASCII workspace files and newer UTF-16 ones. (Note: workspace version numbers are not the same as TextPad version numbers.)

If you happen to have Python (3) installed:
To process all workspace files in the default directory (D:\t), enter:

Code: Select all

python \path\to\twsfiles.pl
To process all workspace files in directory wksp_dir, enter:

Code: Select all

python \path\to\twsfiles.pl wksp_dir
To process the workspace file wksp_file.tws, enter:

Code: Select all

python \path\to\twsfiles.pl wksp_file.tws
To process all workspace files matching *whatever*.tws, enter:

Code: Select all

python \path\to\twsfiles.pl *whatever*.tws
twsfiles.py

Code: Select all

import sys
import os
import glob
import re
from datetime import datetime

twsDir = 'D:\\t'

arg = sys.argv[ 1 ] if len ( sys.argv ) >= 2 else twsDir

if os.path.isdir ( arg ) :
  twsLst = glob.glob ( f'{arg}\\*.tws' )
else :
  if not re.search ( r'[/\\]', arg ) :
    arg = f'{twsDir}\\{arg}'
  twsLst = glob.glob ( arg )

if len ( twsLst ) == 0 :
  sys.exit ( "No workspaces found.\n" )

for twsPath in twsLst :

  mtime = os.path.getmtime ( twsPath )
  stamp = datetime.fromtimestamp ( mtime ).strftime ( '%Y-%m-%d %H:%M' )

  with open ( twsPath, 'rb' ) as twsFile :

    twsBody = twsFile.read ()
    ver     = twsBody[ 2 ]

    print ( f'\n{twsPath} ({ver}) {stamp}' )

    if ver >= 7 :  # new-style (UTF-16) workspace file

      docNames = re.findall ( rb'[EB]COD.{5,8}((?:..)+?)\x00\x00', twsBody )

      print ( len ( docNames ) )
      for docName in sorted ( docNames ) :
        print ( docName.decode ( 'utf-16' ) )

    else :         # old-style (ASCII) workspace file

      docNames = re.findall ( rb'[EB]COD..(.+?)\x00', twsBody )

      print ( len ( docNames ) )
      for docName in sorted ( docNames ) :
        print ( docName.decode ( 'ascii' ) )
I also have a Perl version of this.
IanOfYork
Posts: 80
Joined: Sat Nov 04, 2017 11:54 am
Location: York, England

Re: Recent files >16

Post by IanOfYork »

I have now have all of the TWS files in a single directory.
Since the files seem to contain relative file paths, they needed to be individually loaded and re-saved rather than just moved across.

This does seem to make life simpler.
I also have some batch files and desktop shortcuts that simplify switching to specific "popular" workspaces.

However, it would still be good if the recent file lists were both adjustable to (a lot) more than 16.
ben_josephs
Posts: 2456
Joined: Sun Mar 02, 2003 9:22 pm

Re: Recent files >16

Post by ben_josephs »

IanOfYork wrote: Tue Mar 19, 2024 10:44 am I have now have all of the TWS files in a single directory.
Since the files seem to contain relative file paths, they needed to be individually loaded and re-saved rather than just moved across.
You just need to save the workspace into the new location. For any file not in (or below?) the directory of the new workspace TextPad will save its name as a full path.

I'm glad it makes life simpler for you. It did for me.
IanOfYork
Posts: 80
Joined: Sat Nov 04, 2017 11:54 am
Location: York, England

Re: Recent files >16

Post by IanOfYork »

I am really looking forward to the XML format workspace file ... :-)
IanOfYork
Posts: 80
Joined: Sat Nov 04, 2017 11:54 am
Location: York, England

Re: Recent files >16

Post by IanOfYork »

Sadly, no XML format in version 9.
I have had the TWS files in one directory for a few weeks now and it does indeed improve matters.
Post Reply