@@ -4,6 +4,7 @@ import {FitAddon} from 'xterm-addon-fit';
44import { WebLinksAddon } from 'xterm-addon-web-links' ;
55import { SearchAddon , ISearchDecorationOptions } from 'xterm-addon-search' ;
66import { WebglAddon } from 'xterm-addon-webgl' ;
7+ import { CanvasAddon } from 'xterm-addon-canvas' ;
78import { LigaturesAddon } from 'xterm-addon-ligatures' ;
89import { Unicode11Addon } from 'xterm-addon-unicode11' ;
910import { clipboard , shell } from 'electron' ;
@@ -15,6 +16,7 @@ import {TermProps} from '../hyper';
1516import { ObjectTypedKeys } from '../utils/object' ;
1617import { decorate } from '../utils/plugins' ;
1718import 'xterm/css/xterm.css' ;
19+ import _ from 'lodash' ;
1820
1921const SearchBox = decorate ( _SearchBox , 'SearchBox' ) ;
2022
@@ -57,14 +59,14 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
5759 letterSpacing : props . letterSpacing ,
5860 allowTransparency : needTransparency ,
5961 macOptionClickForcesSelection : props . macOptionSelectionMode === 'force' ,
60- bellStyle : props . bell === 'SOUND' ? 'sound' : 'none' ,
62+ // bellStyle: props.bell === 'SOUND' ? 'sound' : 'none',
6163 windowsMode : isWindows ,
6264 theme : {
6365 foreground : props . foregroundColor ,
6466 background : backgroundColor ,
6567 cursor : props . cursorColor ,
6668 cursorAccent : props . cursorAccentColor ,
67- selection : props . selectionColor ,
69+ selectionBackground : props . selectionColor ,
6870 black : props . colors . black ,
6971 red : props . colors . red ,
7072 green : props . colors . green ,
@@ -83,7 +85,8 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
8385 brightWhite : props . colors . lightWhite
8486 } ,
8587 screenReaderMode : props . screenReaderMode ,
86- overviewRulerWidth : 20
88+ overviewRulerWidth : 20 ,
89+ allowProposedApi : true
8790 } ;
8891} ;
8992
@@ -158,7 +161,7 @@ export default class Term extends React.PureComponent<
158161
159162 this . termOptions = getTermOptions ( props ) ;
160163 this . term = props . term || new Terminal ( this . termOptions ) ;
161- this . termDefaultBellSound = this . term . getOption ( 'bellSound' ) ;
164+ // this.termDefaultBellSound = this.term.getOption('bellSound');
162165
163166 // The parent element for the terminal is attached and removed manually so
164167 // that we can preserve it across mounts and unmounts of the component
@@ -195,26 +198,28 @@ export default class Term extends React.PureComponent<
195198 this . term . attachCustomKeyEventHandler ( this . keyboardHandler ) ;
196199 this . term . loadAddon ( this . fitAddon ) ;
197200 this . term . loadAddon ( this . searchAddon ) ;
198- this . term . loadAddon (
199- new WebLinksAddon (
200- ( event : MouseEvent | undefined , uri : string ) => {
201- if ( shallActivateWebLink ( event ) ) void shell . openExternal ( uri ) ;
202- } ,
203- {
204- // prevent default electron link handling to allow selection, e.g. via double-click
205- willLinkActivate : ( event : MouseEvent | undefined ) => {
206- event ?. preventDefault ( ) ;
207- return shallActivateWebLink ( event ) ;
208- } ,
209- priority : Date . now ( )
210- }
211- )
212- ) ;
201+ // this.term.loadAddon(
202+ // new WebLinksAddon(
203+ // (event: MouseEvent | undefined, uri: string) => {
204+ // if (shallActivateWebLink(event)) void shell.openExternal(uri);
205+ // },
206+ // {
207+ // // prevent default electron link handling to allow selection, e.g. via double-click
208+ // willLinkActivate: (event: MouseEvent | undefined) => {
209+ // event?.preventDefault();
210+ // return shallActivateWebLink(event);
211+ // },
212+ // priority: Date.now()
213+ // }
214+ // )
215+ // );
213216 this . term . open ( this . termRef ) ;
214217 if ( useWebGL ) {
215218 this . term . loadAddon ( new WebglAddon ( ) ) ;
219+ } else {
220+ this . term . loadAddon ( new CanvasAddon ( ) ) ;
216221 }
217- if ( props . disableLigatures !== true && ! useWebGL ) {
222+ if ( props . disableLigatures !== true ) {
218223 this . term . loadAddon ( new LigaturesAddon ( ) ) ;
219224 }
220225 this . term . loadAddon ( new Unicode11Addon ( ) ) ;
@@ -402,37 +407,27 @@ export default class Term extends React.PureComponent<
402407
403408 // Use bellSound in nextProps if it exists
404409 // otherwise use the default sound found in xterm.
405- nextTermOptions . bellSound = this . props . bellSound || this . termDefaultBellSound ! ;
410+ // nextTermOptions.bellSound = this.props.bellSound || this.termDefaultBellSound!;
406411
407412 if ( prevProps . search && ! this . props . search ) {
408413 this . closeSearchBox ( ) ;
409414 }
410415
411416 // Update only options that have changed.
412- ObjectTypedKeys ( nextTermOptions )
413- . filter ( ( option ) => option !== 'theme' && nextTermOptions [ option ] !== this . termOptions [ option ] )
414- . forEach ( ( option ) => {
415- try {
416- this . term . setOption ( option , nextTermOptions [ option ] ) ;
417- } catch ( _e ) {
418- const e = _e as { message : string } ;
419- if ( / T h e w e b g l r e n d e r e r o n l y w o r k s w i t h t h e w e b g l c h a r a t l a s / i. test ( e . message ) ) {
420- // Ignore this because the char atlas will also be changed
421- } else {
422- throw e ;
423- }
424- }
425- } ) ;
417+ this . term . options = _ . pickBy (
418+ nextTermOptions ,
419+ ( value , key ) => this . termOptions [ key as keyof ITerminalOptions ] !== value && key !== 'theme'
420+ ) ;
426421
427422 // Do we need to update theme?
428423 const shouldUpdateTheme =
429424 ! this . termOptions . theme ||
430- nextTermOptions . rendererType !== this . termOptions . rendererType ||
425+ // nextTermOptions.rendererType !== this.termOptions.rendererType ||
431426 ObjectTypedKeys ( nextTermOptions . theme ! ) . some (
432427 ( option ) => nextTermOptions . theme ! [ option ] !== this . termOptions . theme ! [ option ]
433428 ) ;
434429 if ( shouldUpdateTheme ) {
435- this . term . setOption ( ' theme' , nextTermOptions . theme ) ;
430+ this . term . options . theme = nextTermOptions . theme ! ;
436431 }
437432
438433 this . termOptions = nextTermOptions ;
0 commit comments