import Tabs_ from './tabs'; import Term_ from './term'; import RPC from './rpc'; import Mousetrap from 'mousetrap'; import classes from 'classnames'; import shallowCompare from 'react-addons-shallow-compare'; import React, { Component } from 'react'; import decorate from './plugins'; // make subcomponents reload siwth plugin changes const Tabs = decorate(Tabs_); const Term = decorate(Term_); export default class HyperTerm extends Component { constructor (props) { super(); this.state = { cols: null, rows: null, hpadding: 12, vpadding: 12, sessions: [], titles: {}, urls: {}, active: null, activeMarkers: [], mac: /Mac/.test(navigator.userAgent), resizeIndicatorShowing: false, fontSizeIndicatorShowing: false, dismissedUpdate: false, updateVersion: null, fontSize: props.config.fontSize }; // we set this to true when the first tab // has been initialized and ack'd by the // node server for the *first time* this.init = false; // we keep track of activity in tabs to avoid // placing an activity marker right after // opening this.tabWasActive = {}; this.onResize = this.onResize.bind(this); this.onChange = this.onChange.bind(this); this.openExternal = this.openExternal.bind(this); this.quitAndInstall = this.quitAndInstall.bind(this); this.focusActive = this.focusActive.bind(this); this.closeBrowser = this.closeBrowser.bind(this); this.onHeaderMouseDown = this.onHeaderMouseDown.bind(this); this.closeTab = this.closeTab.bind(this); this.moveLeft = this.moveLeft.bind(this); this.moveRight = this.moveRight.bind(this); this.resetFontSize = this.resetFontSize.bind(this); this.increaseFontSize = this.increaseFontSize.bind(this); this.decreaseFontSize = this.decreaseFontSize.bind(this); this.dismissUpdate = this.dismissUpdate.bind(this); this.onUpdateAvailable = this.onUpdateAvailable.bind(this); document.body.style.backgroundColor = props.config.backgroundColor; } componentWillReceiveProps (props) { if (props.config.fontSize !== this.props.config.fontSize) { this.changeFontSize(props.config.fontSize); } if (props.config.backgroundColor !== this.props.config.backgroundColor) { document.body.style.backgroundColor = props.config.backgroundColor; } } render () { const { backgroundColor, borderColor, css } = this.props.config; return
{ const title = this.state.titles[uid]; return null != title ? title : 'Shell'; })} onChange={this.onChange} onClose={this.closeTab} />
{ this.state.sessions.map((uid, i) => { const active = i === this.state.active; const { config } = this.props; return
; }) }
{this.state.fontSizeIndicatorShowing &&
{ this.state.fontSize }px
}
{ this.state.cols }x{ this.state.rows }
Version { this.state.updateVersion } ready. {this.state.updateNote ? ` ${this.state.updateNote}. ` : ' '} Restart to apply [x]