Skip to content

Commit ab0c8fe

Browse files
GitSquaredStanzilla
authored andcommitted
Add support for font ligatures via xterm-addon-ligatures - Clos… (#3853)
* Add support for font ligatures via xterm-addon-ligatures * Add disableLigatures config option, defaults to false * Fix lint issue
1 parent ff479fd commit ab0c8fe

File tree

8 files changed

+74
-2
lines changed

8 files changed

+74
-2
lines changed

app/config/config-default.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ module.exports = {
154154
// rendering (slower, but supports transparent backgrounds)
155155
webGLRenderer: true,
156156

157+
// if `true` (without backticks and without quotes), Hyper will ignore ligatures provided by some fonts
158+
disableLigatures: false,
159+
157160
// for advanced config flags please refer to https://hyper.is/#cfg
158161
},
159162

lib/components/term-group.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class TermGroup_ extends React.PureComponent {
9797
quickEdit: this.props.quickEdit,
9898
webGLRenderer: this.props.webGLRenderer,
9999
macOptionSelectionMode: this.props.macOptionSelectionMode,
100+
disableLigatures: this.props.disableLigatures,
100101
uid
101102
});
102103

lib/components/term.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {FitAddon} from 'xterm-addon-fit';
44
import {WebLinksAddon} from 'xterm-addon-web-links';
55
import {SearchAddon} from 'xterm-addon-search';
66
import {WebglAddon} from 'xterm-addon-webgl';
7+
import {LigaturesAddon} from 'xterm-addon-ligatures';
78
import {clipboard} from 'electron';
89
import * as Color from 'color';
910
import terms from '../terms';
@@ -137,6 +138,7 @@ export default class Term extends React.PureComponent {
137138
console.warn('WebGL2 is not supported on your machine. Falling back to canvas-based rendering.');
138139
} else {
139140
// Experimental WebGL renderer needs some more glue-code to make it work on Hyper.
141+
// If you're working on enabling back WebGL, you will also need to look into `xterm-addon-ligatures` support for that renderer.
140142
// useWebGL = true;
141143
}
142144
}
@@ -150,6 +152,9 @@ export default class Term extends React.PureComponent {
150152
if (useWebGL) {
151153
this.term.loadAddon(new WebglAddon());
152154
}
155+
if (props.disableLigatures !== true) {
156+
this.term.loadAddon(new LigaturesAddon());
157+
}
153158
} else {
154159
// get the cached plugins
155160
this.fitAddon = props.fitAddon;

lib/components/terms.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export default class Terms extends React.Component {
129129
quickEdit: this.props.quickEdit,
130130
webGLRenderer: this.props.webGLRenderer,
131131
macOptionSelectionMode: this.props.macOptionSelectionMode,
132+
disableLigatures: this.props.disableLigatures,
132133
parentProps: this.props
133134
});
134135

lib/containers/terms.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ const TermsContainer = connect(
4343
modifierKeys: state.ui.modifierKeys,
4444
quickEdit: state.ui.quickEdit,
4545
webGLRenderer: state.ui.webGLRenderer,
46-
macOptionSelectionMode: state.ui.macOptionSelectionMode
46+
macOptionSelectionMode: state.ui.macOptionSelectionMode,
47+
disableLigatures: state.ui.disableLigatures
4748
};
4849
},
4950
dispatch => {

lib/reducers/ui.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ const initial = Immutable({
102102
showWindowControls: '',
103103
quickEdit: false,
104104
webGLRenderer: true,
105-
macOptionSelectionMode: 'vertical'
105+
macOptionSelectionMode: 'vertical',
106+
disableLigatures: false
106107
});
107108

108109
const currentWindow = remote.getCurrentWindow();
@@ -255,6 +256,10 @@ const reducer = (state = initial, action) => {
255256
ret.macOptionSelectionMode = config.macOptionSelectionMode;
256257
}
257258

259+
if (config.disableLigatures) {
260+
ret.disableLigatures = config.disableLigatures;
261+
}
262+
258263
ret._lastUpdate = now;
259264

260265
return ret;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@
263263
"webpack-cli": "3.3.7",
264264
"xterm": "~4.1.0",
265265
"xterm-addon-fit": "^0.2.1",
266+
"xterm-addon-ligatures": "^0.2.0",
266267
"xterm-addon-search": "^0.2.1",
267268
"xterm-addon-web-links": "^0.2.1",
268269
"xterm-addon-webgl": "^0.2.1"

yarn.lock

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,6 +3921,23 @@ fn-name@^2.0.0:
39213921
version "2.0.1"
39223922
resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7"
39233923

3924+
font-finder@^1.0.3, font-finder@^1.0.4:
3925+
version "1.0.4"
3926+
resolved "https://registry.yarnpkg.com/font-finder/-/font-finder-1.0.4.tgz#2ca944954dd8d0e1b5bdc4c596cc08607761d89b"
3927+
integrity sha512-naF16RpjWUTFLqzhmdivYpBCrqySN6PI+a4GPtoEsCdvOpbKYTGeTjO7mxh3Wwjz4xKU+Oqx9kwOcteLDeMFQA==
3928+
dependencies:
3929+
get-system-fonts "^2.0.0"
3930+
promise-stream-reader "^1.0.1"
3931+
3932+
font-ligatures@^1.3.2:
3933+
version "1.3.2"
3934+
resolved "https://registry.yarnpkg.com/font-ligatures/-/font-ligatures-1.3.2.tgz#227eb5fc38fef34b5373aa19b555320b82842a71"
3935+
integrity sha512-h9t+gvKVr/c2GnQs4GhXHY39/qyLlXNaIxupU1cxj7YOXEFT8+sJfcchIrZ9UETZUUT7dNcI7RDOXN7gFtuw2g==
3936+
dependencies:
3937+
font-finder "^1.0.3"
3938+
lru-cache "^4.1.3"
3939+
opentype.js "^0.8.0"
3940+
39243941
for-in@^1.0.1, for-in@^1.0.2:
39253942
version "1.0.2"
39263943
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
@@ -4149,6 +4166,11 @@ get-stream@^4.0.0:
41494166
dependencies:
41504167
pump "^3.0.0"
41514168

4169+
get-system-fonts@^2.0.0:
4170+
version "2.0.1"
4171+
resolved "https://registry.yarnpkg.com/get-system-fonts/-/get-system-fonts-2.0.1.tgz#0ec926d2d5fbc16a9f950a5737cd3b30819b0960"
4172+
integrity sha512-gcKzSGT5q5/eZGd6hNGEe2LZmMmdjAYcKHATw1KpUDFLNNeyyZVUZlv9TnbifxU4i0CgCFYrPYCaUcipym2Myw==
4173+
41524174
get-value@^2.0.3, get-value@^2.0.6:
41534175
version "2.0.6"
41544176
resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28"
@@ -5592,6 +5614,14 @@ lru-cache@^4.0.1:
55925614
pseudomap "^1.0.2"
55935615
yallist "^2.1.2"
55945616

5617+
lru-cache@^4.1.3:
5618+
version "4.1.5"
5619+
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
5620+
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
5621+
dependencies:
5622+
pseudomap "^1.0.2"
5623+
yallist "^2.1.2"
5624+
55955625
lru-cache@^5.1.1:
55965626
version "5.1.1"
55975627
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
@@ -6351,6 +6381,13 @@ onetime@^2.0.0:
63516381
dependencies:
63526382
mimic-fn "^1.0.0"
63536383

6384+
opentype.js@^0.8.0:
6385+
version "0.8.0"
6386+
resolved "https://registry.yarnpkg.com/opentype.js/-/opentype.js-0.8.0.tgz#acabcfa1642fbe894a3e4d759e43ba694e02bd35"
6387+
integrity sha1-rKvPoWQvvolKPk11nkO6aU4CvTU=
6388+
dependencies:
6389+
tiny-inflate "^1.0.2"
6390+
63546391
63556392
version "5.3.0"
63566393
resolved "https://registry.yarnpkg.com/opn/-/opn-5.3.0.tgz#64871565c863875f052cfdf53d3e3cb5adb53b1c"
@@ -7110,6 +7147,11 @@ promise-inflight@^1.0.1:
71107147
version "1.0.1"
71117148
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
71127149

7150+
promise-stream-reader@^1.0.1:
7151+
version "1.0.1"
7152+
resolved "https://registry.yarnpkg.com/promise-stream-reader/-/promise-stream-reader-1.0.1.tgz#4e793a79c9d49a73ccd947c6da9c127f12923649"
7153+
integrity sha512-Tnxit5trUjBAqqZCGWwjyxhmgMN4hGrtpW3Oc/tRI4bpm/O2+ej72BB08l6JBnGQgVDGCLvHFGjGgQS6vzhwXg==
7154+
71137155
promise@^7.1.1:
71147156
version "7.3.1"
71157157
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
@@ -8601,6 +8643,11 @@ timers-browserify@^2.0.4:
86018643
dependencies:
86028644
setimmediate "^1.0.4"
86038645

8646+
tiny-inflate@^1.0.2:
8647+
version "1.0.2"
8648+
resolved "https://registry.yarnpkg.com/tiny-inflate/-/tiny-inflate-1.0.2.tgz#93d9decffc8805bd57eae4310f0b745e9b6fb3a7"
8649+
integrity sha1-k9nez/yIBb1X6uQxDwt0Xptvs6c=
8650+
86048651
tmp@^0.0.33:
86058652
version "0.0.33"
86068653
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
@@ -9222,6 +9269,14 @@ xterm-addon-fit@^0.2.1:
92229269
resolved "https://registry.yarnpkg.com/xterm-addon-fit/-/xterm-addon-fit-0.2.1.tgz#353f43921eb78e3f9ad3f3afbb14e7ac183ca738"
92239270
integrity sha512-BlR57O3t1/bmVcnS81bn9ZnNf+GiGNbeXdNUKSBa9tKEwNUMcU3S+KFLIRv7rm1Ty0D5pMOu0vbz/RDorKRwKQ==
92249271

9272+
xterm-addon-ligatures@^0.2.0:
9273+
version "0.2.0"
9274+
resolved "https://registry.yarnpkg.com/xterm-addon-ligatures/-/xterm-addon-ligatures-0.2.0.tgz#8d65fea968ba5b4306b2ada6f53eed3e1984f69c"
9275+
integrity sha512-IcRgjq3QCcL6P8W5M86BCnXIGD1LcCVKk7w3S29Yn2+YksMM3c85JjW2OUgsL3VTW/Tb6uyxpSV2rJOsRElVrQ==
9276+
dependencies:
9277+
font-finder "^1.0.4"
9278+
font-ligatures "^1.3.2"
9279+
92259280
xterm-addon-search@^0.2.1:
92269281
version "0.2.1"
92279282
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.2.1.tgz#f2c02fa92198d5115bde5cc518bff9d7998f2b9c"

0 commit comments

Comments
 (0)