Skip to content

Commit 11c9238

Browse files
use new windowsPty xterm option
1 parent 1daf594 commit 11c9238

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

lib/components/term-group.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class TermGroup_ extends React.PureComponent<TermGroupProps> {
106106
macOptionSelectionMode: this.props.macOptionSelectionMode,
107107
disableLigatures: this.props.disableLigatures,
108108
screenReaderMode: this.props.screenReaderMode,
109+
windowsPty: this.props.windowsPty,
109110
uid
110111
});
111112

lib/components/term.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import 'xterm/css/xterm.css';
1919

2020
const SearchBox = decorate(_SearchBox, 'SearchBox');
2121

22-
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform);
22+
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform) || process.platform === 'win32';
2323

2424
// map old hterm constants to xterm.js
2525
const CURSOR_STYLES = {
@@ -59,6 +59,7 @@ const getTermOptions = (props: TermProps): ITerminalOptions => {
5959
allowTransparency: needTransparency,
6060
macOptionClickForcesSelection: props.macOptionSelectionMode === 'force',
6161
windowsMode: isWindows,
62+
...(isWindows && props.windowsPty && {windowsPty: props.windowsPty}),
6263
theme: {
6364
foreground: props.foregroundColor,
6465
background: backgroundColor,

lib/components/terms.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export default class Terms extends React.Component<TermsProps> {
119119
macOptionSelectionMode: this.props.macOptionSelectionMode,
120120
disableLigatures: this.props.disableLigatures,
121121
screenReaderMode: this.props.screenReaderMode,
122+
windowsPty: this.props.windowsPty,
122123
parentProps: this.props
123124
});
124125

lib/containers/terms.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ const mapStateToProps = (state: HyperState) => {
5353
webLinksActivationKey: state.ui.webLinksActivationKey,
5454
macOptionSelectionMode: state.ui.macOptionSelectionMode,
5555
disableLigatures: state.ui.disableLigatures,
56-
screenReaderMode: state.ui.screenReaderMode
56+
screenReaderMode: state.ui.screenReaderMode,
57+
windowsPty: state.ui.windowsPty
5758
};
5859
};
5960

lib/hyper.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type ITermState = Immutable<{
3838
}>;
3939

4040
export type cursorShapes = 'BEAM' | 'UNDERLINE' | 'BLOCK';
41-
import {FontWeight, Terminal} from 'xterm';
41+
import {FontWeight, IWindowsPty, Terminal} from 'xterm';
4242
import {ColorMap} from './config';
4343

4444
export type uiState = Immutable<{
@@ -103,6 +103,7 @@ export type uiState = Immutable<{
103103
updateVersion: string | null;
104104
webGLRenderer: boolean;
105105
webLinksActivationKey: 'ctrl' | 'alt' | 'meta' | 'shift' | '';
106+
windowsPty?: IWindowsPty;
106107
}>;
107108

108109
export type session = {
@@ -308,6 +309,7 @@ export type TermGroupOwnProps = {
308309
| 'uiFontFamily'
309310
| 'webGLRenderer'
310311
| 'webLinksActivationKey'
312+
| 'windowsPty'
311313
>;
312314

313315
import {TermGroupConnectedProps} from './components/term-group';
@@ -382,6 +384,7 @@ export type TermProps = {
382384
url: string | null;
383385
webGLRenderer: boolean;
384386
webLinksActivationKey: 'ctrl' | 'alt' | 'meta' | 'shift' | '';
387+
windowsPty?: IWindowsPty;
385388
ref_: (uid: string, term: Term | null) => void;
386389
} & extensionProps;
387390

lib/reducers/ui.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import {
2222
} from '../constants/sessions';
2323
import {UPDATE_AVAILABLE} from '../constants/updater';
2424
import {uiState, Mutable, IUiReducer} from '../hyper';
25+
import {release} from 'os';
26+
27+
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(navigator.platform) || process.platform === 'win32';
2528

2629
const allowedCursorShapes = new Set(['BEAM', 'BLOCK', 'UNDERLINE']);
2730
const allowedCursorBlinkValues = new Set([true, false]);
@@ -269,6 +272,15 @@ const reducer: IUiReducer = (state = initial, action) => {
269272
ret.screenReaderMode = config.screenReaderMode;
270273
}
271274

275+
const buildNumber = parseInt(release().split('.').at(-1) || '0', 10);
276+
if (isWindows && !Number.isNaN(buildNumber) && buildNumber > 0) {
277+
const useConpty = typeof config.useConpty === 'boolean' ? config.useConpty : buildNumber >= 18309;
278+
ret.windowsPty = {
279+
backend: useConpty ? 'conpty' : 'winpty',
280+
buildNumber
281+
};
282+
}
283+
272284
ret._lastUpdate = now;
273285

274286
return ret;

0 commit comments

Comments
 (0)