mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
* master: (62 commits) 1.4.3 Disable ia32 linux releases (#2164) Fixed writing composed characters (#2158) Doc: Add yarn install to contribute instructions (#2117) Change "Close Session" shortcut on Linux/Windows (#2160) Notice for plugins (#2114) Updated dependencies to the latest version (#2146) 1.4.2 Reverted class names to as they were before (#2139) 1.4.1 AppVeyor environment variables are now on the platform (#2137) Brought back the icon for closing tabs (#2136) Brought back keymap documentation to the website (#2133) 1.4.0 Don't build on master, except for releases (#2132) Ensured that `async-retry` is added to the bundle (#2131) Ensure correct update channel is displayed in About window (#2130) Retry loading it if config doesn't exist in auto updater (#2129) Write contents of default config to hyper.js (#2128) Use a string for setting the update channel (#2127) ...
136 lines
3 KiB
JavaScript
136 lines
3 KiB
JavaScript
/* eslint-disable react/no-danger */
|
|
|
|
import React from 'react';
|
|
|
|
import Component from '../component';
|
|
import {connect} from '../utils/plugins';
|
|
import * as uiActions from '../actions/ui';
|
|
|
|
import HeaderContainer from './header';
|
|
import TermsContainer from './terms';
|
|
import NotificationsContainer from './notifications';
|
|
|
|
const isMac = /Mac/.test(navigator.userAgent);
|
|
|
|
class Hyper extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.handleFocusActive = this.handleFocusActive.bind(this);
|
|
this.onTermsRef = this.onTermsRef.bind(this);
|
|
}
|
|
|
|
componentWillReceiveProps(next) {
|
|
if (this.props.backgroundColor !== next.backgroundColor) {
|
|
// this can be removed when `setBackgroundColor` in electron
|
|
// starts working again
|
|
document.body.style.backgroundColor = next.backgroundColor;
|
|
}
|
|
}
|
|
|
|
handleFocusActive() {
|
|
const term = this.terms.getActiveTerm();
|
|
if (term) {
|
|
term.focus();
|
|
}
|
|
}
|
|
|
|
attachKeyListeners() {
|
|
// eslint-disable-next-line no-console
|
|
console.error('removed key listeners')
|
|
}
|
|
|
|
onTermsRef(terms) {
|
|
this.terms = terms;
|
|
}
|
|
|
|
componentDidUpdate(prev) {
|
|
if (prev.activeSession !== this.props.activeSession) {
|
|
if (this.keys) {
|
|
this.keys.reset();
|
|
}
|
|
this.handleFocusActive();
|
|
this.attachKeyListeners();
|
|
}
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
if (this.keys) {
|
|
this.keys.reset();
|
|
}
|
|
document.body.style.backgroundColor = 'inherit';
|
|
}
|
|
|
|
template(css) {
|
|
const {isMac: isMac_, customCSS, uiFontFamily, borderColor, maximized} = this.props;
|
|
const borderWidth = isMac_ ? '' :
|
|
`${maximized ? '0' : '1'}px`;
|
|
|
|
return (
|
|
<div>
|
|
<div
|
|
style={{fontFamily: uiFontFamily, borderColor, borderWidth}}
|
|
className={css('main', isMac_ && 'mainRounded')}
|
|
>
|
|
<HeaderContainer/>
|
|
<TermsContainer ref_={this.onTermsRef}/>
|
|
{ this.props.customInnerChildren }
|
|
</div>
|
|
|
|
<NotificationsContainer/>
|
|
<style dangerouslySetInnerHTML={{__html: customCSS}}/>
|
|
{ this.props.customChildren }
|
|
</div>
|
|
);
|
|
}
|
|
|
|
styles() {
|
|
return {
|
|
main: {
|
|
position: 'fixed',
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
// can be overridden by inline style above
|
|
border: '1px solid #333'
|
|
},
|
|
|
|
mainRounded: {
|
|
borderRadius: '5px'
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
const HyperContainer = connect(
|
|
state => {
|
|
return {
|
|
isMac,
|
|
customCSS: state.ui.css,
|
|
uiFontFamily: state.ui.uiFontFamily,
|
|
borderColor: state.ui.borderColor,
|
|
activeSession: state.sessions.activeUid,
|
|
backgroundColor: state.ui.backgroundColor,
|
|
maximized: state.ui.maximized
|
|
};
|
|
},
|
|
dispatch => {
|
|
return {
|
|
moveTo: i => {
|
|
dispatch(uiActions.moveTo(i));
|
|
},
|
|
|
|
moveLeft: () => {
|
|
dispatch(uiActions.moveLeft());
|
|
},
|
|
|
|
moveRight: () => {
|
|
dispatch(uiActions.moveRight());
|
|
}
|
|
};
|
|
},
|
|
null,
|
|
{withRef: true}
|
|
)(Hyper, 'Hyper');
|
|
|
|
export default HyperContainer;
|