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).

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:

TargetLocationContents
TeraCoreSources/TeraCoreTerminal 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)
TeraMacSources/TeraMacThe application (executable TeraMac): AppKit windows, menus, dialogs, connections, help and automatic updates
CTeraFileSources/CTeraFileCompiles 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
COnigurumaSources/COnigurumaThe Oniguruma regular expression library (6.9.10), the same one Tera Term macros use
TeraUninstallSources/TeraUninstallUninstaller (removes the application, settings and connection list, and passwords saved in the keychain)
TeraCoreTestsTests/TeraCoreTestsTests 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

FileContents
Terminal.swiftThe 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.swiftCharacter encodings (Kanji code). Single-byte code tables are in SBCSTables.swift
CharWidth.swift / CharWidthTables.swiftDisplay width of characters (combining, half width, full width, emoji). The tables are generated from upstream *.tbl files
SBCSTables.swiftTables for ISO8859-x / CPxxx / KOI8-R and others, generated from upstream teraterm/teraterm/mapping/*.map
Lang.swiftUI languages (upstream language files plus Mac-only strings). See UI languages and help
IniFile.swift / IniBackup.swiftReading and writing .ini files such as TERATERM.INI, and backups
TTCommandLine.swiftThe Tera Term command line (also used for connect macro parameters)
TTKeyMap.swiftKEYBOARD.CNF key maps
ProxyCommandLine.swift / ProxyHandshake.swiftTTProxy command line and the handshake with HTTP / SOCKS4 / SOCKS5 / telnet proxies
TeraLog.swiftLog files
OthersIDN.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)

FileContents
main.swiftStartup (command line, opening .ttl files, self tests)
SessionWindowController*.swiftOne window = one connection. Menu actions, logging, file transfer, setup, switching to TEK
TerminalView.swiftDrawing the terminal, keyboard, mouse and input methods
Connection.swiftConnections. 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.swiftTranslate TTSSH / TTProxy settings into ssh options. With a proxy, the application runs itself with --proxy-connect as ssh's ProxyCommand
Settings.swiftTerminal settings (stored in UserDefaults; the equivalent of TERATERM.INI). Defaults are read from the upstream TERATERM.INI bundled in the app
IniImport.swiftImporting and exporting Windows TERATERM.INI
MenuBar.swift / InWindowMenuBar.swiftThe menu bar and the menu bar inside the window
SetupSheet.swift / Dialogs.swiftThe Additional settings sheet and the base class for dialogs
TeraMenu.swiftMac version of TeraTerm Menu (ttpmenu), a connection list in the menu bar
MacroRunner.swiftRuns TTL macros on a separate thread and connects them to the terminal window (replaces upstream ttpmacro and DDE)
HelpViewer.swift / HelpModernStyle.swiftThe help viewer (classic and modern views)
Updater.swiftAutomatic updates (Sparkle)
OthersTEKWindowController.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.

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 full texts are in macos/LICENSE, in the app's Acknowledgements and Licenses window, and in License and copyright.