import React from 'react'; import Component from '../component'; import {decorate, getTermGroupProps} from '../utils/plugins'; import TermGroup_ from './term-group'; const TermGroup = decorate(TermGroup_, 'TermGroup'); export default class Terms extends Component { constructor(props, context) { super(props, context); this.terms = {}; this.bound = new WeakMap(); this.onRef = this.onRef.bind(this); props.ref_(this); } componentWillReceiveProps(next) { const {write} = next; if (write && this.props.write !== write) { this.getTermByUid(write.uid).write(write.data); } } shouldComponentUpdate(nextProps) { for (const i in nextProps) { if (i === 'write') { continue; } if (this.props[i] !== nextProps[i]) { return true; } } for (const i in this.props) { if (i === 'write') { continue; } if (this.props[i] !== nextProps[i]) { return true; } } return false; } onRef(uid, term) { if (term) { this.terms[uid] = term; } else if (!this.props.sessions[uid]) { delete this.terms[uid]; } } getTermByUid(uid) { return this.terms[uid]; } getActiveTerm() { return this.getTermByUid(this.props.activeSession); } getLastTermIndex() { return this.props.sessions.length - 1; } onTerminal(uid, term) { this.terms[uid] = term; } componentWillUnmount() { this.props.ref_(null); } template(css) { return (