|
1 | 1 | /* global Blob,URL,requestAnimationFrame,ResizeObserver */ |
2 | 2 | import React from 'react'; |
3 | 3 | import {Terminal} from 'xterm'; |
4 | | -import * as fit from 'xterm/lib/addons/fit/fit'; |
5 | | -import * as webLinks from 'xterm/lib/addons/webLinks/webLinks'; |
6 | | -import * as search from 'xterm/lib/addons/search'; |
7 | | -import * as winptyCompat from 'xterm/lib/addons/winptyCompat/winptyCompat'; |
| 4 | +import {FitAddon} from 'xterm-addon-fit'; |
| 5 | +import {WebLinksAddon} from 'xterm-addon-web-links'; |
| 6 | +import {SearchAddon} from 'xterm-addon-search'; |
| 7 | +import {WebglAddon} from 'xterm-addon-webgl'; |
8 | 8 | import {clipboard} from 'electron'; |
9 | 9 | import * as Color from 'color'; |
10 | 10 | import terms from '../terms'; |
11 | 11 | import processClipboard from '../utils/paste'; |
12 | 12 | import SearchBox from './searchBox'; |
13 | 13 |
|
14 | | -Terminal.applyAddon(fit); |
15 | | -Terminal.applyAddon(webLinks); |
16 | | -Terminal.applyAddon(winptyCompat); |
17 | | -Terminal.applyAddon(search); |
| 14 | +const fitAddon = new FitAddon(); |
| 15 | +const webLinksAddon = new WebLinksAddon(); |
| 16 | +const searchAddon = new SearchAddon(); |
| 17 | +const webglAddon = new WebglAddon(); |
18 | 18 |
|
19 | 19 | // map old hterm constants to xterm.js |
20 | 20 | const CURSOR_STYLES = { |
@@ -73,8 +73,8 @@ const getTermOptions = props => { |
73 | 73 | // HACK: Terminal.setOption breaks if we don't apply these in this order |
74 | 74 | // TODO: The above notice can be removed once this is addressed: |
75 | 75 | // https://github.com/xtermjs/xterm.js/pull/1790#issuecomment-450000121 |
76 | | - rendererType: useWebGL ? 'webgl' : 'canvas', |
77 | | - experimentalCharAtlas: useWebGL ? 'webgl' : 'dynamic', |
| 76 | + // rendererType: useWebGL ? 'webgl' : 'canvas', |
| 77 | + // experimentalCharAtlas: useWebGL ? 'webgl' : 'dynamic', |
78 | 78 | theme: { |
79 | 79 | foreground: props.foregroundColor, |
80 | 80 | background: backgroundColor, |
@@ -144,38 +144,42 @@ export default class Term extends React.PureComponent { |
144 | 144 |
|
145 | 145 | if (!props.term) { |
146 | 146 | this.term.attachCustomKeyEventHandler(this.keyboardHandler); |
| 147 | + this.term.loadAddon(fitAddon); |
| 148 | + this.term.loadAddon(webLinksAddon); |
| 149 | + this.term.loadAddon(searchAddon); |
147 | 150 | this.term.open(this.termRef); |
148 | | - this.term.webLinksInit(); |
149 | | - this.term.winptyCompatInit(); |
| 151 | + this.term.loadAddon(webglAddon); |
| 152 | + // this.term.webLinksInit(); |
| 153 | + // this.term.winptyCompatInit(); |
150 | 154 | } |
151 | 155 |
|
152 | 156 | if (this.props.isTermActive) { |
153 | 157 | this.term.focus(); |
154 | 158 | } |
155 | 159 |
|
156 | 160 | if (props.onTitle) { |
157 | | - this.disposableListeners.push(this.term.addDisposableListener('title', props.onTitle)); |
| 161 | + this.disposableListeners.push(this.term.onTitleChange(props.onTitle)); |
158 | 162 | } |
159 | 163 |
|
160 | | - if (props.onActive) { |
161 | | - this.disposableListeners.push(this.term.addDisposableListener('focus', props.onActive)); |
162 | | - } |
| 164 | + // if (props.onActive) { |
| 165 | + // this.disposableListeners.push(this.term.addDisposableListener('focus', props.onActive)); |
| 166 | + // } |
163 | 167 |
|
164 | 168 | if (props.onData) { |
165 | | - this.disposableListeners.push(this.term.addDisposableListener('data', props.onData)); |
| 169 | + this.disposableListeners.push(this.term.onData(props.onData)); |
166 | 170 | } |
167 | 171 |
|
168 | 172 | if (props.onResize) { |
169 | 173 | this.disposableListeners.push( |
170 | | - this.term.addDisposableListener('resize', ({cols, rows}) => { |
| 174 | + this.term.onResize(({cols, rows}) => { |
171 | 175 | props.onResize(cols, rows); |
172 | 176 | }) |
173 | 177 | ); |
174 | 178 | } |
175 | 179 |
|
176 | 180 | if (props.onCursorMove) { |
177 | 181 | this.disposableListeners.push( |
178 | | - this.term.addDisposableListener('cursormove', () => { |
| 182 | + this.term.onCursorMove(() => { |
179 | 183 | const cursorFrame = { |
180 | 184 | x: this.term._core.buffer.x * this.term._core.renderer.dimensions.actualCellWidth, |
181 | 185 | y: this.term._core.buffer.y * this.term._core.renderer.dimensions.actualCellHeight, |
@@ -278,7 +282,7 @@ export default class Term extends React.PureComponent { |
278 | 282 | if (!this.termWrapperRef) { |
279 | 283 | return; |
280 | 284 | } |
281 | | - this.term.fit(); |
| 285 | + fitAddon.fit(); |
282 | 286 | } |
283 | 287 |
|
284 | 288 | keyboardHandler(e) { |
|
0 commit comments