Manual contents

Plugins (Expert)

A plugin brings Lua commands, themes, text clips or file templates, in one piece that TriPad installs, updates, turns off and removes for you. Tools > Plugins has the commands of the plugins you have, and Manage Plugins... lists those and the plugins in TriPad's catalogue:

  • Install downloads a plugin from the catalogue, says what it has and what it can do, and asks first.
  • Update appears when the catalogue has a newer version of a plugin you installed from it.
  • Turn Off keeps a plugin but stops it: its commands, themes, clips and templates go until you turn it on again.
  • Remove deletes its folder.
  • Install from Folder... installs a plugin from a folder on your computer, such as one you are writing or one someone sent you. It is marked Folder, not reviewed, and never updated from the catalogue.

What a plugin can do. A plugin's Lua runs with your rights, as a script does: it can read and change any file you can, run programs and use the internet. So before it installs a plugin that has Lua, TriPad says so, and says whether it was reviewed for TriPad's catalogue; Show its files lists every file in it. A plugin with only themes, clips or templates runs no code. Every plugin in the catalogue is read line by line before it goes in. The catalogue, plugins.json, is signed with TriPad's own key, as update.json is, and TriPad installs only a download that is exactly the file it names, by size and SHA-256.

When TriPad looks. It fetches https://xn3tech.com/tripad/plugins.json when you open Manage Plugins, and with the daily update check when you have a plugin from the catalogue. When an update is waiting, the status bar says so; nothing is installed until you choose Update. An update that brings Lua to a plugin that had none asks again. The Microsoft Store's copy looks only when you open Manage Plugins.

Where plugins are. Each one is a folder, named by its id, in the plugins folder of the settings folder (Help > Open Settings Folder): %APPDATA%\TriPad\plugins, the plugins folder beside a portable TriPad.exe, or the Microsoft Store copy's own folder, which Windows removes with it. The plugins that are off are in TriPad.ini, under [Plugins].

If a plugin stops TriPad from starting, start it with TriPad -noplugins: no plugin runs until TriPad starts again, and Manage Plugins can turn that one off or remove it.

Writing a plugin#

A plugin is a folder with a plugin.json:

{
  "id": "identifier-case",
  "name": "Identifier Case",
  "version": "1.0",
  "author": "Your name",
  "description": "What it does, in a sentence or two.",
  "tripad": "1.4"
}
  • id is 2 to 40 lowercase letters, digits and hyphens, starting with a letter. It is the name of the plugin's folder once it is installed.
  • version is two to four numbers, such as 1.0 or 1.2.3, and a higher one is an update.
  • tripad is the oldest TriPad the plugin works with. An optional tripadMax is the newest, on as many numbers as it has: "1" is any 1.x, "1.4" any 1.4.x. TriPad doesn't install or run a plugin made for another version, and Manage Plugins says why.
  • author and description are optional.

And any of these:

  • main.lua, which runs when the first Expert window opens, before startup.lua, and the .lua files it loads with require: require("lib.util") is lib\util.lua, or lib\util\init.lua, in the plugin's folder.
  • themes\*.ini, themes as the Style Configurator saves them, which are in View > Theme in every mode.
  • clips\*.clips, clip libraries, as in the clips folder (below).
  • templates\*, for File > New from Template.
  • README.md, other .md or .txt files, and LICENSE.

Nothing else: no programs, DLLs or compiled Lua, only text in UTF-8, at most 200 files and 1 MB together, and no more than three folders deep. Files and folders whose names start with ., such as .git, are left out when TriPad installs from a folder.

A plugin's Lua has the editor and tripad that scripts have (above), and three things of its own:

  • Its globals are its own. What it sets isn't seen by scripts or other plugins, and what it reads and hasn't set comes from the shared globals, editor and tripad among them.
  • tripad.register(name, function) adds the command to Tools > Plugins, as Plugin name: command.
  • plugin says what and where it is: plugin.id, plugin.name, plugin.version and plugin.dir, its folder.

To try a plugin, use Install from Folder..., and again after each change. A Lua error in it is shown in the Lua console, with the plugin's id and the line.