mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
* 3.0.0 * 3.0.2 * Save * Save * Upgrade yarn lock packages * update node-gyp and node-pty * update travis and appveyor to node 12 * appveyor is outdated as always * update travis to xenial * update node-pty@0.9.0-beta26 * update yarn.lock * update electron to 6.0.8 * move node-pty to the correct package.json * Fix linting failure * Update yarn lockfile to try to fix appveyor build * Remove unnecessary changes from package.json * Try to fix appveyor by using a newer image * Fix linting after my last change * update electron to 6.0.9 * install windows-build-tools on appveyor * fix syntax * switch back to 2017 image * remove old resolutions field * revert accidental version change * update electron to 6.0.11 and electron-rebuild to 1.8.6 * downgrade yarn to 1.18 until this issue is resolved https://github.com/yarnpkg/yarn/issues/7584 * update node-gyp to 6.0.0 and generate a fresh yarn lockfile * update react and a few other dependencies * fix lint * this should actually be electron-builder, I think! * update a few dependencies * change to electron-store electron-config was renamed to electron-store a while ago * update xterm to v4.1.0 and ora to 4.0.2 * move pify to app/package.json * TODO: Revert maybe. Throw a fit on every change to maybe fix the resizing issues * a * fix react ref problem * fix split view focus problem * remove the unnecessary fit * remove the init col and row * fix the problem that cannot show about hyper * update electron to 6.0.12 * fix lint * add more todos for componentWillReceiveProps deprecation * update babel and plugins Co-authored-by: Juan Campa <juancampa@gmail.com> Co-authored-by: Benjamin Staneck <staneck@gmail.com> Co-authored-by: ivan <ivanwonder@outlook.com>
145 lines
4.5 KiB
JavaScript
145 lines
4.5 KiB
JavaScript
import React from 'react';
|
|
import {connect} from 'react-redux';
|
|
import {decorate, getTermProps, getTermGroupProps} from '../utils/plugins';
|
|
import {resizeTermGroup} from '../actions/term-groups';
|
|
import Term_ from './term';
|
|
import SplitPane_ from './split-pane';
|
|
|
|
const Term = decorate(Term_, 'Term');
|
|
const SplitPane = decorate(SplitPane_, 'SplitPane');
|
|
|
|
class TermGroup_ extends React.PureComponent {
|
|
constructor(props, context) {
|
|
super(props, context);
|
|
this.bound = new WeakMap();
|
|
this.termRefs = {};
|
|
this.onTermRef = this.onTermRef.bind(this);
|
|
}
|
|
|
|
bind(fn, thisObj, uid) {
|
|
if (!this.bound.has(fn)) {
|
|
this.bound.set(fn, {});
|
|
}
|
|
const map = this.bound.get(fn);
|
|
if (!map[uid]) {
|
|
map[uid] = fn.bind(thisObj, uid);
|
|
}
|
|
return map[uid];
|
|
}
|
|
|
|
renderSplit(groups) {
|
|
const [first, ...rest] = groups;
|
|
if (rest.length === 0) {
|
|
return first;
|
|
}
|
|
|
|
const direction = this.props.termGroup.direction.toLowerCase();
|
|
return (
|
|
<SplitPane
|
|
direction={direction}
|
|
sizes={this.props.termGroup.sizes}
|
|
onResize={this.props.onTermGroupResize}
|
|
borderColor={this.props.borderColor}
|
|
>
|
|
{groups}
|
|
</SplitPane>
|
|
);
|
|
}
|
|
|
|
onTermRef(uid, term) {
|
|
this.term = term;
|
|
this.props.ref_(uid, term);
|
|
}
|
|
|
|
renderTerm(uid) {
|
|
const session = this.props.sessions[uid];
|
|
const termRef = this.props.terms[uid];
|
|
const props = getTermProps(uid, this.props, {
|
|
isTermActive: uid === this.props.activeSession,
|
|
term: termRef ? termRef.term : null,
|
|
fitAddon: termRef ? termRef.fitAddon : null,
|
|
searchAddon: termRef ? termRef.searchAddon : null,
|
|
scrollback: this.props.scrollback,
|
|
backgroundColor: this.props.backgroundColor,
|
|
foregroundColor: this.props.foregroundColor,
|
|
colors: this.props.colors,
|
|
cursorBlink: this.props.cursorBlink,
|
|
cursorShape: this.props.cursorShape,
|
|
cursorColor: this.props.cursorColor,
|
|
cursorAccentColor: this.props.cursorAccentColor,
|
|
fontSize: this.props.fontSize,
|
|
fontFamily: this.props.fontFamily,
|
|
uiFontFamily: this.props.uiFontFamily,
|
|
fontSmoothing: this.props.fontSmoothing,
|
|
fontWeight: this.props.fontWeight,
|
|
fontWeightBold: this.props.fontWeightBold,
|
|
lineHeight: this.props.lineHeight,
|
|
letterSpacing: this.props.letterSpacing,
|
|
modifierKeys: this.props.modifierKeys,
|
|
padding: this.props.padding,
|
|
url: session.url,
|
|
cleared: session.cleared,
|
|
search: session.search,
|
|
cols: session.cols,
|
|
rows: session.rows,
|
|
copyOnSelect: this.props.copyOnSelect,
|
|
bell: this.props.bell,
|
|
bellSoundURL: this.props.bellSoundURL,
|
|
bellSound: this.props.bellSound,
|
|
onActive: this.bind(this.props.onActive, null, uid),
|
|
onResize: this.bind(this.props.onResize, null, uid),
|
|
onTitle: this.bind(this.props.onTitle, null, uid),
|
|
onData: this.bind(this.props.onData, null, uid),
|
|
toggleSearch: this.bind(this.props.toggleSearch, null, uid),
|
|
onContextMenu: this.bind(this.props.onContextMenu, null, uid),
|
|
borderColor: this.props.borderColor,
|
|
selectionColor: this.props.selectionColor,
|
|
quickEdit: this.props.quickEdit,
|
|
webGLRenderer: this.props.webGLRenderer,
|
|
macOptionSelectionMode: this.props.macOptionSelectionMode,
|
|
disableLigatures: this.props.disableLigatures,
|
|
uid
|
|
});
|
|
|
|
// This will create a new ref_ function for every render,
|
|
// which is inefficient. Should maybe do something similar
|
|
// to this.bind.
|
|
return <Term ref_={this.onTermRef} key={uid} {...props} />;
|
|
}
|
|
|
|
render() {
|
|
const {childGroups, termGroup} = this.props;
|
|
if (termGroup.sessionUid) {
|
|
return this.renderTerm(termGroup.sessionUid);
|
|
}
|
|
|
|
const groups = childGroups.map(child => {
|
|
const props = getTermGroupProps(
|
|
child.uid,
|
|
this.props.parentProps,
|
|
Object.assign({}, this.props, {termGroup: child})
|
|
);
|
|
|
|
return <DecoratedTermGroup key={child.uid} {...props} />;
|
|
});
|
|
|
|
return this.renderSplit(groups);
|
|
}
|
|
}
|
|
|
|
const TermGroup = connect(
|
|
(state, ownProps) => ({
|
|
childGroups: ownProps.termGroup.children.map(uid => state.termGroups.termGroups[uid])
|
|
}),
|
|
(dispatch, ownProps) => ({
|
|
onTermGroupResize(splitSizes) {
|
|
dispatch(resizeTermGroup(ownProps.termGroup.uid, splitSizes));
|
|
}
|
|
}),
|
|
null,
|
|
{forwardRef: true}
|
|
)(TermGroup_);
|
|
|
|
const DecoratedTermGroup = decorate(TermGroup, 'TermGroup');
|
|
|
|
export default TermGroup;
|