All Projects → migueldeicaza → Swiftterm

migueldeicaza / Swiftterm

Licence: mit
VT100/Xterm Terminal emulator in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftterm

Wtrequestcenter
WTKit is my Code accumulation
Stars: ✭ 293 (-16.29%)
Mutual labels:  uikit
Reactionbutton
Since Facebook introduced reactions in 2016, it became a standard in several applications as a way for users to interact with content. ReactionButton is a control that allows developers to add this functionality to their apps in an easy way.
Stars: ✭ 305 (-12.86%)
Mutual labels:  uikit
Swift Composable Architecture
A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
Stars: ✭ 5,199 (+1385.43%)
Mutual labels:  uikit
Deskapp
DeskApp Admin is a free to use Bootstrap 4 admin template.
Stars: ✭ 296 (-15.43%)
Mutual labels:  uikit
Metaballs
Blob effect implementation with UIKIt
Stars: ✭ 300 (-14.29%)
Mutual labels:  uikit
Uix Kit
A free UI toolkit based on some common libraries for building beautiful responsive website, compatible with Bootstrap v4.
Stars: ✭ 318 (-9.14%)
Mutual labels:  uikit
Framework Codeidea
System file classification
Stars: ✭ 289 (-17.43%)
Mutual labels:  uikit
Ios Nbukit
UIKit and NSFoundation convenience categories and subclasses.
Stars: ✭ 344 (-1.71%)
Mutual labels:  uikit
Wlemptystate
WLEmptyState is an iOS based component that lets you customize the view when the dataset of a UITableView or a UICollectionView is empty. We created a sample project with the WLEmptyState component to show how you can use it.
Stars: ✭ 305 (-12.86%)
Mutual labels:  uikit
Onboardkit
Customisable user onboarding for your iOS app
Stars: ✭ 334 (-4.57%)
Mutual labels:  uikit
Swiftui Cheat Sheet
SwiftUI 2.0 Cheat Sheet
Stars: ✭ 3,417 (+876.29%)
Mutual labels:  uikit
Chakra Ui
⚡️Simple, Modular & Accessible UI Components for your React Applications
Stars: ✭ 295 (-15.71%)
Mutual labels:  uikit
Alchemy
An experimental GUI framework for Rust, backed by per-platform native widgets. React, AppKit/UIKit inspired. EXPERIMENTAL, runs on Cocoa right now. ;P
Stars: ✭ 321 (-8.29%)
Mutual labels:  uikit
Uikitplus
🏰 Declarative UIKit with LivePreview for iOS9+ (best alternative to SwiftUI)
Stars: ✭ 294 (-16%)
Mutual labels:  uikit
Swiftreorder
Easy UITableView drag-and-drop cell reordering
Stars: ✭ 340 (-2.86%)
Mutual labels:  uikit
Contraflutterkit
A Flutter UI kit with 50 plus screens for beginners to learn.
Stars: ✭ 288 (-17.71%)
Mutual labels:  uikit
Compositional Layouts Kit
📏 A set of advanced compositional layouts for UICollectionView with examples [Swift 5.3, iOS 13].
Stars: ✭ 317 (-9.43%)
Mutual labels:  uikit
Coderyi.github.io
Don't fork! coderyi's blog,about iOS ,CS and my code life.
Stars: ✭ 349 (-0.29%)
Mutual labels:  uikit
Valuestepper
A Stepper object that displays its value.
Stars: ✭ 343 (-2%)
Mutual labels:  uikit
Chatkit
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon
Stars: ✭ 3,496 (+898.86%)
Mutual labels:  uikit

Swift

SwiftTerm

SwiftTerm is a VT100/Xterm terminal emulator for Swift applications that can be embedded into macOS or iOS applications.

This repository contains both a terminal emulator engine that is UI agnostic, as well as front-ends for this engine for iOS using UIKit, and macOS using AppKit. Additionally there are a couple of minimal sample apps for Mac and iOS showing how to use the library.

The companion module SwiftTermApp builds an actual iOS app that uses this library and is more complete than the testing apps in this module.

Check the API Documentation

The macOS AppKit NSView implementation TerminalView is a reusable NSView control that can be connected to any source by implementing the TerminalViewDelegate.
I anticipate that a common scenario will be to host a local Unix command, so I have included LocalProcessTerminalView which is an implementation that connects the TerminalView to a Unix pseudo-terminal and runs a command there.

There is an equivalent UIKit UIVIew implementation for TerminalView which like its NSView companion is an embeddable and reusable view that can be connected to your application by implementing the same TerminalViewDelegate. Unlike the NSView case running on a Mac, where a common scenario will be to run local commands, given that iOS does not offer access to processes, the most common scenario will be to wire up this terminal to a remote host. And the safest way of connecting to a remote system is with SSH.

The core library currently does not provide a convenient way to connect to SSH, purely to avoid the additional dependency. But this git module references a module that pulls a precompiled SSH client (Frugghi's SwiftSH), along with a UIKitSsshTerminalView in the iOS sample that that connects the TerminalView for iOS to an SSH connection.

The iOS and UIKit code share a lot of the code, that code lives under the Apple directory.

Both of these rely on the terminal engine (implemented in class Terminal). The engine itself does not have a user interface, nor does it take input, nor does it know how to connect to an actual process, those are provided by higher levels.

In the longer term, I want to also add a tvOS UIView, a SwiftGtk front-end for Linux, as well as an implementation for my Swift console toolkit TermKit.

This is a port of my original XtermSharp, which was itself based on xterm.js. At this point, I consider SwiftTerm to be a more advanced terminal emulator than both of those (modulo Selection/Accessibility) as it handles UTF, Unicode and grapheme clusters better than those and has a more complete coverage of terminal emulation. XtermSharp is generally attempting to keep up.

SwiftTerm library

The SwiftTerm library itself contains the source code for both the engine and the front-ends. The front-ends are conditionally compiled based on the target platform.

The engine is in this directory, while code for macOS lives under Mac, and code for iOS, lives under iOS. Given that those two share a lot of common traits, the shared code is under Apple.

Features

  • Pretty decent terminal emulation, on or better than XtermSharp and xterm.js (and more comprehensive in many ways)
  • Unicode rendering (including Emoji, and combining characters and emoji)
  • Reusable and pluggable engine allows multiple user interfaces to be built on top of it.
  • Selection engine (with macOS support in the view)
  • Supports colors (ANSI, 256, TrueColor)
  • Supports mouse events
  • Supports terminal resizing operations (controlled by remote host, or locally)
  • Hyperlinks in terminal output
  • AppKit, UIKit front-ends
  • Local process and SSH connection support (some assembly required for the last one)
  • Proper CoreText rendering can munch through the hardened Unicode test suites.
  • Seems pretty fast to me

Using SwiftTerm

SwiftTerm uses the Swift Package Manager for its build, and you can add the library to your project by using the url for this project or a fork of it.

Working on SwiftTerm

If you are using Xcode, there are two toplevel projects, one for Mac and one for iOS in the TerminalApp directory, one called "iOSTerminal.xcodeproj" and one called "MacTerminal.xcodeproj".

This is needed because Xcode does not provide code completion for iOS if you have a Mac project in the project. So I had to split them up. Both projects reference the same SwiftTerm package.

When working with these projects, if you choose the terminal application it will run this one. To run the test suite, select the 'SwiftTerm' target instead, and you can use 'SwiftTermFuzz' to run the fuzzer.

You can use swift build to build the package, and swift test to run the test suite - but be warned that the test suite expects the directory esctest to be checked out to run. You can see how I run these on GitHub actions in the file .github/workflows/swift.yml if you want to do this locally.

If using Xcode, you can select the "SwiftTerm" project, and then use Command-U to run the test suite.

Pending Work

GitHub issues has a list of desired features and enhancements

Resources

Additional and useful documents:

Test suites:

  • VTTest - old, but still good
  • EscTest - fantastic: George Nachman, the author of iTerm, created this test suite, and it became a FreeDesktop standard. Since then, Thomas E. Dickey, the xterm maintainer and maintainer of many text apps has contributed to this effort.

Screenshots

24 Bit Color

24 bit color

Midnight Commander

Screen Shot 2020-04-12 at 12 17 49 AM

Solid UTF-8 support, excellent rendering: Screen Shot 2020-04-22 at 11 25 30 PM

Screen Shot 2020-04-22 at 11 25 24 PM

Supports hyperlinks emitted by modern apps:

image

iOS support:

image

Screenshots

Authors

  • Thanks go to the xterm.js developers that originally wrote a terminal emulator that was licensed under a license that allowed for maximum reuse.
  • Marcin Krzyzanowski who masterfully improved and curated the rendering engine on AppKit/CoreText to be the glorious renderer that it is today - and for his contributions to the rendering engine
  • Greg Munn that did a lot of work in XtermSharp to support the needs of Visual Studio for Mac
  • Miguel de Icaza -me- who have been looking for an excuse to write some Swift code.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].