Macro Programming Demos and Tests
This tool generates an HTML page that lets us bulk-test how well TSE fits list titles within a list.
Unfortunaly TSE 4.50 (26 Oct 2024) and older do not properly take the close button "[x]" into account.
As a result the "centered" list title is shown off-center, and the close button gets (initially partially!) overwritten if the list title gets too long.
Note:
The HTML format is a solution for the fact,
that TSE shows (list) borders using code page 437 for character encoding.
These characters cannot be shown in a Windows GUI TSE's text.
They can not reliably be shown in a Windows Console TSE's text
to non-American users, who typically not do use code page 437.
This tool lists key codes per key name, sorted on the 1st key code.
This tool's purpose is to provide and test the pick_file() procedure, which is intended to be a proc that is usable by other macros.
Syntax:
pick_file(string prompt, string file_specification)
The file specification can be empty, a file, or a directory, and may contain the wildcard characters "*" and "?".
pick_file() will browse directories until a file is selected, or the user pressed <Escape>.
pick_file() will return the fully qualified name of the selected file or an empty string.
pick_file() will not open or load the selected file.
pick_file() uses its own prompt and history. A separate history is maintained for each macro that pick_file() is used in.
This test tool makes an advanced-enough Linux terminal send keys to TSE whenever a mouse button is used, and shows live in a separate view window which keys TSE sees when.
It demonstrates that:
- A mouse event sends an F1 key plus 3 info characters.
- TSE sees the F1 key immediately.
- TSE does not see the 3 info characters until a new physical key is pressed, released or scrolled.
This test tool is a companion to the LinuxMouse extension.
This tool demonstrates a Linux terminal capability to TSE macro programmers.
An application running in a Linux terminal can call terminal functions by sending certain character strings to STDOUT. Some of those functions send result strings back to STDIN.
This tool demonstrates how to call such a function and how to process its result.
It uses "getting the terminal's cursor position" as a simple example.
The exciting part is, that advanced terminals can execute advanced functions.
This theoretically opens the way to new Linux TSE functionality.
The drawback is, that less advanced terminals will not be compatible with this.
This tool tests GetMarkedText() after MarkStream().
It shows no changes between TSE versions from v4 onwards.
It does show that GetMarkedText() ignores marked "characters" after the end of a line.
This tool tests TSE's copy commands when used after MarkStream():
- Copy()/Paste()
- CopyBlock()
- CopyToWinClip()/PasteFromWinClip()
This extension gives every edit buffer its own ViewFinds buffer.
Details:
-
TSE's "Search" menu has a "Redisplay View PickList" function.
- Without this extension it shows the results of the last search with the "v" option.
- With this extension it shows the results of the last search with the "v" option that was done in the current buffer.
- In other words, the extension provides a ViewFinds list per edit buffer.
- This new functionality has advantages and disadvantages that depend on user preferences. The extension is simple to install and deinstall, so trying it out is easy.
Credits:
This extension is based on the
idea and code
provided by Eliyahu Trigoub.
v1.0.1 Documented that the "a" search option is ignored if combined with the "v" search option.
This tool tests TSE's SearchPath() statement.
Its code is written so that its relevant part is includable in sanity1.
It automatically adapts to test SearchPath() with both values of SearchCurrentDirectory for TSE versions from v4.50rc20 upwards, and to working with older TSE versions.
It has a really cool debug option that shows off which files are searched in which order.
v1.0.1
Bug fixed: Was not compatible with Semware's Sanity1 tool as claimed.
Two commented meta-tests added to intentionally produce an error
in two different forms.
This tool is obsolete for TSE v4.50rc18 upwards, because the time difference has been fixed in TSE v4.50rc18.
This tool helps make DirList output comparable between Linux and Windows by diminishing all " h:mm:ss" and "hh:mm:ss" times it finds by 2 seconds.
The tool works on the whole file. It does not diminish the date if the old time is 0:00:00 or 00:00:00.
REASON
If you run DirList from Windows TSE and Linux TSE on the same directory
of a Linux system in WSL, then the times usually differ by 2 seconds, because
currently Windows TSE rounds up and Linux TSE rounds down to even seconds.
This makes it hard to compare results.
This tool lets us visually test whether Linux TSE supports RGB colors in a specific Linux terminal or command line.
In Windows GUI TSE the tool is always capable of showing the pretty RGB colors we hope to see in Linux.
v1.1
Made TSE 4.50 rc 17 the minimum requirement.
Made it independent of TSE settings.
Added resetting the terminal/command line screen afterwards.
Perfected its existing functionality.
This tool tests TSE's sort macro and TSE's internal and external sort.
v1.3.1 - 5 Jan 2024
Updated the documentation.
Updated the version requirement to needing at least TSE v4.50 rc 17.
This extension tests drawing around text.
It tests it by drawing blocks of pixels around all text.
CAVEAT: It only works for Windows GUI TSE with the Courier New font in a not-maximized screen.
The "make_dir_file_test.cmd" file creates a set of long and deep directories and file names. And a few directories and files with a non-TSE character in their name. They all have a root that starts with "D:\Long_" to be easily recognizable. You can change the drive letter.
This extension/tool demos how a not-yet-existing _BEFORE_FILE_OPEN_ hook could enable an extension to open remote files for protocols like HTTP and SSH, seemingly from TSE's own Edit(This)File prompts.
This extension continuously reports the color name of the character at the cursor.
It is intended for testing, because it is not always possible to visually distinguish colors.
This tool matches a set of 16 input colors to TSE's 16 standard color(name)s.
Suppose you found 16 colors you like and want to assign them to TSE's 16 standard color(name)s as documented in SetColorTableValue(). This tool will try to find the closest match of your new colors to TSE's named colors.
However, for the tool, which uses two main algorithms, the second algorithm does not work perfectly.
The first algorithm determines how well each input color matches with each standard color. For this the tool treats each RGB color as a 3-dimensional coordinate and calculates the visual similarity of two colors as the distance between their coordinates. Tests confirm that this works well.
The second algorithm tries to find the best match for a whole set of input colors with a whole set of standard colors. The current approach does not work perfectly. The algorithm simplistically matches closest colors first. This results in problems at the end, where because of the lack of remaining unmatched colors it has to make bad matches.
The problem has similarities to searching a route to a target destination, where simplisticly selecting each next road that most reduces the straight distance to the target can result in a longer route.
Preliminary exploratory tests suggest, that a better result can be achieved by searching for the set of input colors for which the sum of all its individual color distances to their matched standard colors is the smallest. This requires an algorithm that smartly searches a solution space of 21 trillion color set combinations.
Given that my technical interest was raised by the first algorithm, and given that nobody has expressed an unequivocal need for the complete tool, I am going to postpone its further development indefinitely.
This tool demonstrates, that while TSE's Color() function accepts 288 possible descriptions, they result in only 255 colors.
It could be used by other macros to browse directories and select one.
Its source is useful as an example of what a macro can achive with mouse clicks.
Linux TSE Beta v4.41.20 upwards
This tool is an TEST and EXAMPLE macro for the epoch_to_datetime() procedure, that given a time zone in hours can convert unix's epoch seconds (seconds since 1 Jan 1970 0:00:00) to a year, day, month, hours, minutes and seconds.
v1.0.1 Fixed: Apparently only February can have a leap day.
v1.0.2 Fixed: Apparently November 2019 has no 31st day for 1 second.
This tool implements and tests the included function GetLongPath(), which implements the opposite of TSE v4.41.35's GetShortPath() function.
v1.0.1 Fixed: GetLongPath() now returns the input file specification if it refers to a file that no longer exists.
This tool shows how many Hook()s are currently free, and, assuming the maximum available amount of Hook()s is 158, how many Hook()s TSE is currently using.
When running this tool in Windows GUI TSE 4.48 with all macros purged, it says that 158 Hook()s are free.
This tool asks for a file or files, and gets their last-written dates and times to the millisecond.
Context: As opposed to TSE and its macro language, which show and return file times rounded up to the next even second.
This tool demonstrates, that when you save a file and immediately spawn a second TSE instance to process it, the spawned process appears to have an earlier start time than the saved file's time.
This can be up to two seconds earlier.
This is caused by TSE's macro language returning the actual system time, but returning a file's time rounded up to the next even second.
This tool demonstrates downloading web pages and the downloadable files on them using two Semware download pages as an example:
Latest TSE macro sources from Semware
Old Semware page with user uploads
Note that downloading 112 + 378 files might take about 9 minutes.
This tool demonstrates how to write Unicode characters to TSE's screen, and explores and documents its capabilities and limitations.
v1.1 Documented additional things I learned. Speculated some more about possible usages.
v1.2 Documented that I learned that "Arial Unicode MS" is not a standard Windows font, so a tool cannot rely on its presence.
This is a tool for macro programmers, that checks the Hlp2txt tool's hidden raw Help file for link errors, warnings and notes.
Summarized answer for TSE 4.42:
It reports no errors or warnings.
It notes 337 subtopics that are never addressed, with the technical reason why. The latter is technically interesting, because of the Help's multiple implicit rules for addressing a subtopic.
For an extreme example; there are 3 subtopics for which there is a link to their address, but they are not addressed with their specific topic, and while their address does not overlap with a topic address, their address is the same as that of an earlier occurring subtopic.
The never-addressed subtopics are technically an error, but in practice they cause nothing to malfunction and only hamper Semware's maintenance of the Help, so they only get a note instead.
Here is a look at its report.
This is a tool for macro programmers, that helps to examine what extra topics TSE's Help contains, that are not shown from its its index.
Summarized answer: Menu-help topics, indirectly linked-to topics, obsolete topics, and InfoBoxes.
Here is a look at its report.
This test macro reveals the correct parameter formats for TSE Beta v4.41.42's new and incorrectly documented CompareLines() function.
Linux TSE Beta probably any version
This is an include-file for macro programmers, that provides the functions repeatable_lFind() and repeatable_lRepeatFind(), that unlike their TSE counterparts do not loop infinitely for a search with the "a" search option.
A demo/test macro is included too.
Linux TSE Beta probably any version
This tool lists what keys TSE can send to itself, when it is not interfered by an operating system or other software, and without the limitations of a keyboard.
It gives some insight into TSE's internal key capabilities and limitations, but otherwise has no practical use.
This is a quick&dirty adaptation of Semware's "match" macro dd 6 Apr 2020.
Like the Match macro, for the bracket under the cursor it jumps to its counterpart, but as requested by a user it ignores any in between commented brackets. So it "matches uncommented" brackets. [Is that even English?]
I do NOT recommend substituting Match by MatchUnCom. MatchUncom has known flaws:
- It blindly assumes that comment colours are always delimiter colours, which for some configurations might be false.
- It is badly tested. The user's example test case worked on the first try, and I didn't test any further.
This example macro asks for a regular expression, and calculates the minimum length it can match.
The usefulness of this macro lies primarily in that it contains a procedure which can be copied into your own macros.
Often regular expressions that can match an empty string are not useful. Worse, they can also be dangerous when used for searching inside a loop, which can then become infinite because the empty string always matches without advancing the cursor. This macro [procedure] returns zero for such regular expressions, and thus helps you and your macro recognize and avoid useless and dangerous searches.
Not maintained and experimental TSE macros, in various states
This tool was created for one specific user at their request. I generalized their request a bit, but I doubt this tool is useful to others.
From a file with search-recognizable keywords, generate keyword-named files, each containing the lines with their keywords.
This is neither a finished nor a well-working macro.
I do not see a way forward, so I am abandoning this one.
The intention was to show "best matches first" for a search string applied to the current file, BUT:
- Intentions turned out to be hard to catch in programming logic. I experimented with applying a weight to results, but this did not work satisfactory.
- Implementing intentions turned unavoidably into implementing my own biases, and worse, my current biases based on my current purposes. That made it impossible to make this a generic tool.
- For larger files it worked too slowly. I reduced the searched number of results, but that reduced the results. Sadness and pun intended.
Shows not only the current date/time of the current file on disk, but also the date/time the current file had on disk at the time it was loaded.
If TSE warns a user "Disk file has been changed by another program. Save Anyway?", then this macro lets a user verify that warning.
This macro lets you view long lines window-wrapped while still editing the original unwrapped lines.
Disclaimer: No it doesn't. This macro works imperfectly.
History:
v1.1 29 March 2009
A tilde indicator in the statusline shows if the file is in WinWrap mode. That only means that the file contains wrapped lines somewhere, not necessarily in the visible window.
v1.0.2 26 March 2009
Solved: Auto-wrapping wasn't delayed when the macro was autoloaded and TSE was started with a file.
v1.0.1 26 March 2009
Solved: The macro didn't compile for TSE Pro 4.0: the isAutoloaded() function doesn't exist yet in that version of TSE.
This macro changes the color of the cursor position: if the background color equals the one configured for TSE's cursorline, and: either only when the cursor is not on a visible character, or always.
The occasion for this macro was a user who uses a TSE color "intense ... ... on black" (which means a dark grey background): for this background color TSE doesn't show the cursor if the cursor position is a whitespace.
This macro remedies three potential Cobol issues:
- All TSE Pro versions are not capable of coloring columns, neither column 1 thru 6, nor column 73 to the end of line.
- Cobol versions up to and including Cobol-85 indicate comments by putting an asterisk or a slash on column 7. Since version 3.0 TSE Pro supports this with to-end-of-line syntax hiliting if a configurable character is present at a configurable column. TSE Pro 2.8 users need this macro to do the same.
- For old versions of TSE (but >= 2.8), which don't have a Cobol syntax hiliting file yet, you can install one.
I consider this macro OBSOLETE. It was written because TortoiseSVN versions prior to 1.8 needed minutes to open a folder with thousands of files in it. This macro could do it immediately.
In TortoiseSVN 1.8 this problem was solved, so I saw and see no reason to finish or maintain this macro.
For Subversion repositories I recommend TortoiseSVN instead of this macro.
The idea was to create a menu with both fillable fields and normal menu lines, but I cannot get it to work correctly. Usually I like the challenge of taking a tool past its intended use, but this has by now wasted way too much of my time, so I'm dropping it indefinitely.
It isn't even a real beta: it is just a half-built version 1.4.
You could also look upon it as a progress report.
v5.1 (beta) of the EolType macro. Compatibility: TSE Pro 2.5e upwards.
This OLD macro version is kept for OLD TSE versions.
I downgraded this macro to beta status, because the 5.0 to 5.1 changes were not tested yet. Please report any reproducible errors you might find.
Purpose:
Save files with a unix/microsoft end-of-file-type based on configurable substrings that do/don't occur in the files' full filenames.
Possibly handy when working with a Samba drive, Total Commander, WinSCP and other such tools.
Version 5.1:
Since the previously to SemWare's website released version was 1.0, the "new" features are:
- The substrings no longer have to start with a drive letter.
- Configuration file tse32\eoltype.dat became tse32\mac\eoltype.cfg.
- You can now configure what end-of-line-type warnings and questions you want when saving a file whose end-of-line-type is as configured being changed by the EolType macro.
This macro synchronizes (by ftp) directories from a pc to a server and/or back.
I use it after changing my offline website to update my identical online website. I have a syncdir.bat file that simply contains:
@call \tse32\g32.exe -eSyncDir
The macro needs macpar3.zip from SemWare's website to be installed first.
Like the version number indicates, the macro was and is a bit of a hack for my personal use, and is provided as is, with no garanty whatsoever.
Purpose: Search for a string which might span lines.
This is not a working macro! It is only half built. I am just sharing what I have been working on.
This macro's theory is, that you can search for a string which spans lines by putting a "slide" of lines under a "microscope", and moving the slide from the beginning to the end of the file in such a way, that the macro can use TSE's own Find command search each slide as if it was one line!
Well, the slide part is largely implemented, the search part not at all. When implementing the search part, it will have impact on the slide part, which probably needs a little extending then.
Given Tidy as an alternative, I won't proceed with building this macro.
This version is for historical purposes while the new version is being developed.
V0.5 (a buggy beta) of the WinWrap macro, formerly known as the ScrnWrap and LongLine macro. This is a windowwrapper, as opposed to a filewrapper. It wraps lines that are longer than the current window is wide, but it only wraps them on-screen, not in the editing buffer or the disk-file. It therefore does not interfere with most editor functions. However, it therefore does interfere with syntax hiliting, block marking, find marking, the "[End of File]" indicator, and the WhtSpc macro.
New in Version 0.5: Made the macro deactivate itself when there is blockmarking in the current window, and reactivate itself as soon as there isn't any more. If the WhtSpc macro is loaded, then it is deactivated during wrapping, and reactivated as soon as there is no more wrapping. Executing the macro now toggles it on and off. Alas, turning it on again is subject to a known bug.
I will not not develop this macro any further, because I have concluded that the current approch is not fully compatible with TSE's implementation. TSE has a (for this macro's purpose) nasty habit. "Normal" screen updates can immediately be corrected and overwritten by hooks, but screen updates as the result of scrolling can only be corrected with the _idle_ hook, which happens so much later that it causes the screen to flicker. Besides that there is a "no screen updating" bug. I have concluded that the current approach of creating a reformatted screen over the image of the original file will never work satisfactory. Another approach might be temporarily formatting the file itself, and (e.g. before saving) being able to reformat it back. A second alternative might be to show a formatted shadow-file to the user. That said, this macro's functionality is so low on my list of priorities, that its development is hereby stopped.