Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xterm-addon-ligatures

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xterm-addon-ligatures - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0-beta.1

lib/xterm-addon-ligatures.js

5

bin/download-fonts.js

@@ -0,1 +1,6 @@

/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
const fs = require('fs');

@@ -2,0 +7,0 @@ const path = require('path');

60

package.json
{
"name": "xterm-addon-ligatures",
"version": "0.2.1",
"version": "0.3.0-beta.1",
"description": "Add support for programming ligatures to xterm.js",
"homepage": "https://github.com/xtermjs/xterm-addon-ligatures#readme",
"repository": {
"type": "git",
"url": "https://github.com/xtermjs/xterm-addon-ligatures.git"
"author": {
"name": "The xterm.js authors",
"url": "https://xtermjs.org/"
},
"bugs": {
"url": "https://github.com/xtermjs/xterm-addon-ligatures/issues"
},
"main": "lib/xterm-addon-ligatures.js",
"types": "typings/xterm-addon-ligatures.d.ts",
"repository": "https://github.com/xtermjs/xterm.js",
"engines": {
"node": ">8.0.0"
},
"main": "lib/LigaturesAddon.js",
"types": "typings/xterm-addon-ligatures.d.ts",
"scripts": {
"prepare": "node bin/download-fonts.js",
"lint": "tslint --project tsconfig.json --fix",
"prebuild": "npm run lint",
"build": "tsc",
"watch": "tsc -w",
"build": "tsc -p src",
"watch": "tsc -w -p src",
"prepackage": "npm run build",
"package": "webpack",
"pretest": "npm run build",
"test": "nyc mocha lib/**/*.test.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"prepublish": "npm run build"
"test": "nyc mocha out/**/*.test.js",
"prepublish": "npm run package"
},

@@ -42,17 +38,6 @@ "keywords": [

"devDependencies": {
"@types/chai": "^4.1.3",
"@types/mocha": "^5.2.0",
"@types/node": "^8.10.10",
"@types/sinon": "^5.0.1",
"axios": "^0.18.0",
"chai": "^4.1.2",
"coveralls": "^3.0.2",
"mkdirp": "^0.5.1",
"mocha": "^5.2.0",
"nyc": "^12.0.2",
"sinon": "^6.1.3",
"tslint": "^5.9.1",
"tslint-consistent-codestyle": "^1.13.0",
"typescript": "^2.8.3",
"xterm": "^3.6.0",
"yauzl": "^2.10.0"

@@ -62,20 +47,3 @@ },

"xterm": "^4.0.0"
},
"nyc": {
"sourceMap": true,
"reporter": [
"text",
"html",
"json"
],
"include": [
"lib/**/*.js"
],
"exclude": [
"lib/**/*.test.*",
"lib/**/*.integration.*",
"lib/**/*.d.ts",
"lib/**/*.map*"
]
}
}
}

@@ -1,89 +0,44 @@

# xterm-addon-ligatures
## xterm-addon-ligatures
[![Build Status](https://dev.azure.com/xtermjs/xterm-addon-ligatures/_apis/build/status/xtermjs.xterm-addon-ligatures)](https://dev.azure.com/xtermjs/xterm-addon-ligatures/_build/latest?definitionId=4)
[![Coverage Status](https://coveralls.io/repos/github/xtermjs/xterm-addon-ligatures/badge.svg?branch=refs%2Fheads%2Fmaster)](https://coveralls.io/github/xtermjs/xterm-addon-ligatures?branch=refs%2Fheads%2Fmaster)
Add support for programming ligatures to [xterm.js] when running in environments with access to [Node.js] APIs (such as [Electron]).
Add support for programming ligatures to [xterm.js][] when running in
environments with access to [Node.js][] APIs (such as [Electron][]).
### Requirements
## Requirements
* [Node.js] 8.x or higher (present in [Electron] 1.8.3 or higher)
* [xterm.js] 4.0.0 or higher using the default canvas renderer
* [Node.js][] 8.x or higher (present in [Electron][] 1.8.3 or higher)
* [xterm.js][] 4.0.0 or higher using the default canvas renderer
### Install
## Usage
Install in your project by running:
```bash
npm install --save xterm-addon-ligatures
```
npm install xterm-addon-ligatures
```
Then, modify the location where you initialize the terminal to enable ligature
support after opening. If you enable ligatures prior to opening the terminal,
they will not function properly.
### Usage
Your code should look something like this:
```js
import { Terminal } from 'xterm';
import * as ligatures from 'xterm-addon-ligatures';
Terminal.applyAddon(ligatures);
const terminal = new Terminal();
terminal.open(document.getElementById('terminal-mount'));
terminal.enableLigatures();
```
### Importing in TypeScript
If you use TypeScript, you will need to cast the terminal variable as `any` when
you enable ligatures because TypeScript does not know that the addon is
available on the terminal object. It will look like this:
```ts
(terminal as any).enableLigatures()
```
Alternatively, you can import the addon directly as a function and pass the
terminal as an argument:
```js
import { Terminal } from 'xterm';
import { enableLigatures } from 'xterm-addon-ligatures';
import { LigaturesAddon } from 'xterm-addon-ligatures';
const terminal = new Terminal();
terminal.open(document.getElementById('terminal-mount'));
enableLigatures(terminal);
const ligaturesAddon = new LigaturesAddon();
terminal.open(containerElement);
terminal.loadAddon(ligaturesAddon);
```
## How It Works
### How It Works
In a browser environment, font ligature information is read directly by the web
browser and used to render text correctly without any intervention from the
developer. As of version 3, xterm.js uses the canvas to render characters
individually, resulting in a significant performance boost. However, this means
that it can no longer lean on the browser to determine when to draw font
ligatures.
In a browser environment, font ligature information is read directly by the web browser and used to render text correctly without any intervention from the developer. As of version 3, xterm.js uses the canvas to render characters individually, resulting in a significant performance boost. However, this means that it can no longer lean on the browser to determine when to draw font ligatures.
This package locates the font file on disk for the font currently in use by the
terminal and parses the ligature information out of it (via the
[font-ligatures][] package). As text is rendered in xterm.js, this package
annotates it with the locations of ligatures, allowing xterm.js to render it
correctly.
This package locates the font file on disk for the font currently in use by the terminal and parses the ligature information out of it (via the [font-ligatures] package). As text is rendered in xterm.js, this package annotates it with the locations of ligatures, allowing xterm.js to render it correctly.
Since this package depends on being able to find and resolve a system font from
disk, it has to have system access that isn't available in the web browser. As a
result, this package is mainly useful in environments that combine browser and
Node.js runtimes (such as [Electron][]).
Since this package depends on being able to find and resolve a system font from disk, it has to have system access that isn't available in the web browser. As a result, this package is mainly useful in environments that combine browser and Node.js runtimes (such as [Electron]).
## Fonts
### Fonts
This package makes use of the following fonts for testing:
* [Fira Code][] - [Licensed under the OFL][Fira Code License] by Nikita
* [Fira Code][Fira Code] - [Licensed under the OFL][Fira Code License] by Nikita
Prokopov, Mozilla Foundation with reserved names Fira Code, Fira Mono, and
Fira Sans
* [Iosevka][] - [Licensed under the OFL][Iosevka License] by Belleve Invis with
* [Iosevka] - [Licensed under the OFL][Iosevka License] by Belleve Invis with
reserved name Iosevka

@@ -90,0 +45,0 @@

@@ -0,1 +1,6 @@

/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import * as fontFinder from 'font-finder';

@@ -2,0 +7,0 @@ import * as fontLigatures from 'font-ligatures';

@@ -0,1 +1,6 @@

/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { Terminal } from 'xterm';

@@ -73,3 +78,4 @@ import { Font } from 'font-ligatures';

);
} else if (loadingState === LoadingState.FAILED) {
}
if (loadingState === LoadingState.FAILED) {
throw loadError || new Error('Failure while loading font');

@@ -81,14 +87,1 @@ }

}
/**
* Add capabilities to the provided terminal class for enabling ligature
* support. After calling this function, an `enableLigatures()` method is
* available on the terminal class, which will enable ligature support when
* called.
* @param terminalConstructor Terminal class from xterm.js
*/
export function apply(terminalConstructor: typeof Terminal): void {
(<any>terminalConstructor.prototype).enableLigatures = function (): void {
enableLigatures(this);
};
}

@@ -0,1 +1,6 @@

/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
interface IParseContext {

@@ -153,3 +158,4 @@ input: string;

return unicodeToString(str);
} else if (str.length >= 6 || !/[0-9a-fA-F]/.test(char)) {
}
if (str.length >= 6 || !/[0-9a-fA-F]/.test(char)) {
// If the next character is not a valid hex digit or we have reached the

@@ -156,0 +162,0 @@ // maximum of 6 digits in the escape, terminate the escape.

/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT

@@ -10,3 +11,3 @@ *

import { Terminal, ILinkMatcherOptions, ITerminalAddon } from 'xterm';
import { Terminal, ITerminalAddon } from 'xterm';

@@ -13,0 +14,0 @@ declare module 'xterm-addon-ligatures' {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc