hyper/lib/index.js
Martin Ek a7595c1a45 Split Panes (#693)
* npm: add .npmrc with save-exact=true

* split panes: create initial implementation

This allows users to split their Hyperterm terms into
multiple nested splits, both vertical and horizontal.

Fixes #56

* split panes: suport closing tabs and individual panes

* split panes: ensure new splits are placed at the correct index

New split panes should be placed after the currently active
pane, not at the end like they were previously.

* split panes: add explicit dependency to uuid

* split panes: implement split pane cycling

This adds menu buttons for moving back and forward between
open split panes in the currect terminal tab.
Doesn't add a hotkey yet, needs some bikeshedding.

* split panes: move activeSessionUid to its own object

It made little sense to have so many objects with `activeSessionUid`
set to `null` when it only mattered on the top level.
Now it's an object mapping term-group `uid` to `sessionUid` instead.

* split panes: make sure closing the last split pane exits the app

* split panes: fix a crash after closing specific panes

Sometimes the terminal would crash when a specific
split pane was closed, because the `activeSessions`
mapping wasn't updated correctly.

* split panes: fix a bug that caused initial session sizing to be wrong

* fix all our focus / blur issues in one fell swoop :O (famous last words)

* get rid of react warning

* hterm: make sure not to lose focus when VT listens on clicks

* term: restore onactive callback

* add missing `return` to override (just in case)

* split pane: new split pane implementation

* goodbye react-split-pane

* added term group resizing action and reducer

* terms: supply border color so that we can use it for splits

* term-group: add resizing hook

* term-groups: add resizing constant

* remove split pane css side-effect

* split panes: pass existing hterm instances to Term

* split panes: add keybindings for split pane cycling

* split panes: remove unused action

* split panes: remove unused styling

* split-pane: remove `console.log`

* split-pane: remove `console.log`

* split panes: rebalance sizes on insert/removal

* split panes: pass existing hterm instances to Term

* split panes: add keybindings for split pane cycling

* split panes: remove unused action

* split panes: remove unused styling

* split panes: rebalance sizes on insert/removal

* split panes: set a minimum size for resizing

* split-pane: fix vertical splits

* css :|

* package: bump electron

* split panes: attach onFocus listener to webviews

* 1.4.1 and 1.4.2 are broken. they have the following regression:
- open google.com on the main window
- open a new tab
- come back to previous tab. webview is gone :|

* split panes: handle PTY exits

* split panes: add linux friendly keybindings
2016-10-03 19:00:50 -07:00

136 lines
3.5 KiB
JavaScript

import forceUpdate from 'react-deep-force-update';
import {Provider} from 'react-redux';
import React from 'react';
import {render} from 'react-dom';
import {webFrame} from 'electron';
import rpc from './rpc';
import {init} from './actions/index';
import * as config from './utils/config';
import * as plugins from './utils/plugins';
import * as uiActions from './actions/ui';
import * as updaterActions from './actions/updater';
import * as sessionActions from './actions/sessions';
import * as termGroupActions from './actions/term-groups';
import HyperTermContainer from './containers/hyperterm';
import {loadConfig, reloadConfig} from './actions/config';
import configureStore from './store/configure-store';
// Disable pinch zoom
webFrame.setZoomLevelLimits(1, 1);
const store_ = configureStore();
window.__defineGetter__('store', () => store_);
window.__defineGetter__('rpc', () => rpc);
window.__defineGetter__('config', () => config);
window.__defineGetter__('plugins', () => plugins);
// initialize config
store_.dispatch(loadConfig(config.getConfig()));
config.subscribe(() => {
store_.dispatch(reloadConfig(config.getConfig()));
});
// initialize communication with main electron process
// and subscribe to all user intents for example from menus
rpc.on('ready', () => {
store_.dispatch(init());
store_.dispatch(uiActions.setFontSmoothing());
});
rpc.on('session add', data => {
store_.dispatch(sessionActions.addSession(data));
});
rpc.on('session data', ({uid, data}) => {
store_.dispatch(sessionActions.addSessionData(uid, data));
});
rpc.on('session data send', ({uid, data}) => {
store_.dispatch(sessionActions.sendSessionData(uid, data));
});
rpc.on('session title', ({uid, title}) => {
store_.dispatch(sessionActions.setSessionProcessTitle(uid, title));
});
rpc.on('session exit', ({uid}) => {
store_.dispatch(termGroupActions.ptyExitTermGroup(uid));
});
rpc.on('termgroup close req', () => {
store_.dispatch(termGroupActions.exitActiveTermGroup());
});
rpc.on('session clear req', () => {
store_.dispatch(sessionActions.clearActiveSession());
});
rpc.on('termgroup add req', () => {
store_.dispatch(termGroupActions.requestTermGroup());
});
rpc.on('split request horizontal', () => {
store_.dispatch(termGroupActions.requestHorizontalSplit());
});
rpc.on('split request vertical', () => {
store_.dispatch(termGroupActions.requestVerticalSplit());
});
rpc.on('reset fontSize req', () => {
store_.dispatch(uiActions.resetFontSize());
});
rpc.on('increase fontSize req', () => {
store_.dispatch(uiActions.increaseFontSize());
});
rpc.on('decrease fontSize req', () => {
store_.dispatch(uiActions.decreaseFontSize());
});
rpc.on('move left req', () => {
store_.dispatch(uiActions.moveLeft());
});
rpc.on('move right req', () => {
store_.dispatch(uiActions.moveRight());
});
rpc.on('next pane req', () => {
store_.dispatch(uiActions.moveToNextPane());
});
rpc.on('prev pane req', () => {
store_.dispatch(uiActions.moveToPreviousPane());
});
rpc.on('preferences', () => {
store_.dispatch(uiActions.showPreferences());
});
rpc.on('open file', ({path}) => {
store_.dispatch(uiActions.openFile(path));
});
rpc.on('update available', ({releaseName, releaseNotes}) => {
store_.dispatch(updaterActions.updateAvailable(releaseName, releaseNotes));
});
rpc.on('move', () => {
store_.dispatch(uiActions.windowMove());
});
const app = render(
<Provider store={store_}>
<HyperTermContainer/>
</Provider>,
document.getElementById('mount')
);
rpc.on('reload', () => {
plugins.reload();
forceUpdate(app);
});