For developers (Mac version)
This page is about developing Tera Term Mac. For development of the original Tera Term (Windows), see For developers (Windows Tera Term).
- Source layout (this page)
- Build, test and release
- UI languages and help
Repository
The source is at https://github.com/teraterm-mac/teraterm-mac.
The repository is a fork of TeraTermProject/teraterm, and all of the Mac source lives in the macos/ folder.
Everything outside macos/ is a copy of the upstream source. Changes made there do not go upstream; if you want to fix upstream Tera Term, send the change to the TeraTerm Project.
Tera Term Mac is developed by a separate team from TeraTerm Project (which develops the Windows version). Please send bug reports, requests and pull requests to this repository's Issues / Discussions / Pull Requests, not to TeraTerm Project (see also CONTRIBUTING.md in the repository).
Swift package layout
macos/Package.swift is a Swift Package Manager package (swift-tools-version 5.5, macOS 11 or later). There is no Xcode project file. The targets are:
| Target | Location | Contents |
|---|---|---|
| TeraCore | Sources/TeraCore | Terminal emulator, character encodings, character widths, TTL macros, file transfer, reading and writing settings files. Does not depend on AppKit (this is what the tests cover) |
| TeraMac | Sources/TeraMac | The application (executable TeraMac): AppKit windows, menus, dialogs, connections, help and automatic updates |
| CTeraFile | Sources/CTeraFile | Compiles upstream teraterm/ttpfile C sources (XMODEM / YMODEM / ZMODEM / Kermit / B-Plus / Quick-VAN / raw) as they are. glue/ and compat/ stand in for the Windows APIs |
| COniguruma | Sources/COniguruma | The Oniguruma regular expression library (6.9.10), the same one Tera Term macros use |
| TeraUninstall | Sources/TeraUninstall | Uninstaller (removes the application, settings and connection list, and passwords saved in the keychain) |
| TeraCoreTests | Tests/TeraCoreTests | Tests for TeraCore (XCTest) |
The only external package is Sparkle for automatic updates. It is pinned to 2.9.x because Sparkle 2.10 requires macOS 12 or later.
Main files in TeraCore
| File | Contents |
|---|---|
| Terminal.swift | The terminal emulator (VT100 / xterm compatible escape sequences, screen and scrollback, attributes and colors) |
| TTL/ | The TTL macro interpreter, a Swift port of upstream teraterm/ttpmacro (ttmparse.cpp, ttmbuff.c, ttl.cpp, ttl_gui.cpp and others). TTLReserved.swift is the reserved word table generated from ttmparse.h / ttmparse.cpp |
| FileTransfer/ | File transfer. The protocols themselves are CTeraFile (upstream ttpfile); file name and folder rules follow upstream |
| TEK/ | TEK window (Tektronix 4010/4014) parser, ported from upstream ttptek |
| Encoding.swift | Character encodings (Kanji code). Single-byte code tables are in SBCSTables.swift |
| CharWidth.swift / CharWidthTables.swift | Display width of characters (combining, half width, full width, emoji). The tables are generated from upstream *.tbl files |
| SBCSTables.swift | Tables for ISO8859-x / CPxxx / KOI8-R and others, generated from upstream teraterm/teraterm/mapping/*.map |
| Lang.swift | UI languages (upstream language files plus Mac-only strings). See UI languages and help |
| IniFile.swift / IniBackup.swift | Reading and writing .ini files such as TERATERM.INI, and backups |
| TTCommandLine.swift | The Tera Term command line (also used for connect macro parameters) |
| TTKeyMap.swift | KEYBOARD.CNF key maps |
| ProxyCommandLine.swift / ProxyHandshake.swift | TTProxy command line and the handshake with HTTP / SOCKS4 / SOCKS5 / telnet proxies |
| TeraLog.swift | Log files |
| Others | IDN.swift (internationalized domain names), SerialLineMode.swift (serial data bits and parity), TitleFormat.swift (window title), TermLimits.swift (terminal size limits) and more |
Main files in TeraMac (the application)
| File | Contents |
|---|---|
| main.swift | Startup (command line, opening .ttl files, self tests) |
| SessionWindowController*.swift | One window = one connection. Menu actions, logging, file transfer, setup, switching to TEK |
| TerminalView.swift | Drawing the terminal, keyboard, mouse and input methods |
| Connection.swift | Connections. SSH runs macOS's /usr/bin/ssh; telnet and raw TCP use Network.framework; serial ports use termios; the local shell uses forkpty |
| SSHSetup.swift / ProxyRelay.swift | Translate TTSSH / TTProxy settings into ssh options. With a proxy, the application runs itself with --proxy-connect as ssh's ProxyCommand |
| Settings.swift | Terminal settings (stored in UserDefaults; the equivalent of TERATERM.INI). Defaults are read from the upstream TERATERM.INI bundled in the app |
| IniImport.swift | Importing and exporting Windows TERATERM.INI |
| MenuBar.swift / InWindowMenuBar.swift | The menu bar and the menu bar inside the window |
| SetupSheet.swift / Dialogs.swift | The Additional settings sheet and the base class for dialogs |
| TeraMenu.swift | Mac version of TeraTerm Menu (ttpmenu), a connection list in the menu bar |
| MacroRunner.swift | Runs TTL macros on a separate thread and connects them to the terminal window (replaces upstream ttpmacro and DDE) |
| HelpViewer.swift / HelpModernStyle.swift | The help viewer (classic and modern views) |
| Updater.swift | Automatic updates (Sparkle) |
| Others | TEKWindowController.swift, ThemeFile.swift (themes), ColorSchemes.swift, Broadcast.swift, FileDrop.swift, TransferDialogs.swift, Credits.swift (acknowledgements and licenses) and more |
Relation to upstream
Upstream Tera Term is written with the Win32 API, so it does not run on the Mac as is. Tera Term Mac is a rewrite in Swift / AppKit that follows upstream behavior.
- Upstream source used as is: the file transfer protocols (C sources of
teraterm/ttpfilecopied into CTeraFile) and Oniguruma - Upstream files used at build time:
installer/release/TERATERM.INI(default settings),installer/release/lang_utf8/*.lng(UI languages),installer/release/theme(sample themes),teraterm/common/helpid.h(help IDs).scripts/bundle.shcopies them into the app - Generated from upstream files: the character width tables and single-byte code tables (generators)
- Ported to Swift: TTL macros (ttpmacro), TEK, logging, command line, key maps, the TTProxy handshake and more. The comment at the top of each source file names the upstream file or function it is based on
- Rewritten for the Mac: windows, menus and dialogs; connections (SSH uses macOS's OpenSSH instead of TTSSH); settings storage (UserDefaults); password storage (keychain)
- Help: based on upstream
doc/jaanddoc/en, rewritten for the Mac, inmacos/Resources/help-mac
What the macro interpreter matches with upstream and what was changed for the Mac is listed in macos/docs/マクロ互換性.md (in Japanese) in the repository.
Where behavior differs between operating systems, Tera Term Mac follows the macOS way rather than the Windows way.
License
- The source in
macos/is under the MIT License (macos/LICENSE). Contributions are also published under the MIT License. - Parts derived from upstream (the application icon, the TTL macro interpreter, the CTeraFile file transfer code and the tables generated from upstream tables) are under Tera Term's BSD 3-Clause License.
- Oniguruma is under the BSD 2-Clause License, Sparkle under the MIT License.
The full texts are in macos/LICENSE, in the app's Acknowledgements and Licenses window, and in License and copyright.