[code] [textadept] History for TA

From: Qwerky <mr.qwerky.att.gmail.com>
Date: Sat, 27 Jul 2019 18:15:01 -0600

Hello TA users,

Most editors include a 'Recent Files' facility, providing the ability to
quickly open a file which the editor had previously seen, and restoring
that file's state (caret position, current window position, etc.). 
TextAdept also provides such a capability, but it is limited in these
ways:  First, the number of files remembered is limited to ten (this
number may be adjusted).  Second, the list of remembered files is
session-based, meaning that one session's list is not available in
another session.  For some purposes (or in the view of some users) this
may be regarded as a feature, rather than a limitation.  Finally, the
file's state is not remembered for the recent files (though of course it
is for session files).

'History' for TA provides a system-wide list of remembered files, not
limited to a single session, including each file's state, and with a
large upper limit to the number of files remembered.  This history of
files does not interfere with TA's native facility, and both may be used
at the same time.  'History' provides both a dialog in the same manner
as TA, as well as a menu list, in the manner of many other editors. 
Like other editors, any file in the menu (which is, of necessity,
limited in number) may be quickly selected by an accelerator key.  Like
TA itself, the dialog (which shows the entire history) may be used to
quickly filter files by typing a few letters.

'History' installs a sub-menu called 'Recent', at position four in TA's
main 'File' menu (following TA's own 'Open Recent...' entry). Both the
name and position of the sub-menu may be altered by the user; I chose
that name because it is standard, and I am used to the 'Alt-F, R' key
sequence to quickly access it.  The 'Recent' menu is divided into two
sections:  'pinned' and 'unpinned'.  The unpinned section, as expected,
is in most-recently-used order; when a file is opened which TA has not
previously seen, it is added to the top of the unpinned section, pushing
other entries down; and when a previously seen file is opened from the
history list, it is moved to the top of the unpinned section.  The
pinned section, as the name implies, is more static:  files are added
to, or removed from, that section only by direct user action, allowing
the user to keep frequently accessed files at the top of the list,
without them being pushed off the list as new files are added.  This
pinned section is limited to ten files, using accelerator keys '1'
through '0'.  The unpinned section is limited to twenty-six files, using
accelerator keys 'A' through 'Z'.  The dialog, on the other hand, shows
the entire history, and is limited only by the set maximum size, which
the user may adjust.

To install 'History', simply copy history.lua to your
_USERHOME/modules/common directory (assuming a common directory in which
all modules are automatically 'required').  'History' stores its history
in a file called 'history' in your _USERHOME directory (the same
location as TA's session file).  If 'History' cannot find its history
file, it generates one, containing ten empty entries for the 'pinned'
files.  The history file contains, for each remembered file, the full
path and file name, the caret position and selection anchor, and any
bookmarks for the file.  This is the same information that TA's session
remembers, but in a slightly different file format.  This is no
coincidence, as 'History' is heavily based on TA's session.lua by
Mitchell.  Of course the user may, by editing the code, adjust many
parameters, such as the history filename and location, the menu name and
position, and so on.

Feedback is welcome, not only with regard to program operation, but also
with regard to the content of the code itself, as this is my first
attempt at Lua programming for TA, and I am not yet entirely familiar
with all of the conventions therein.


You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sat 27 Jul 2019 - 20:15:01 EDT

This archive was generated by hypermail 2.2.0 : Sun 28 Jul 2019 - 06:31:49 EDT