mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Allow plugins to set the parent/predecessor of a new session (#3723)
This commit is contained in:
parent
6deb733d63
commit
71953e0fdf
6 changed files with 22 additions and 19 deletions
|
|
@ -10,16 +10,16 @@ const commands = {
|
|||
},
|
||||
'tab:new': focusedWindow => {
|
||||
if (focusedWindow) {
|
||||
focusedWindow.rpc.emit('termgroup add req');
|
||||
focusedWindow.rpc.emit('termgroup add req', {});
|
||||
} else {
|
||||
setTimeout(app.createWindow, 0);
|
||||
}
|
||||
},
|
||||
'pane:splitRight': focusedWindow => {
|
||||
focusedWindow && focusedWindow.rpc.emit('split request vertical');
|
||||
focusedWindow && focusedWindow.rpc.emit('split request vertical', {});
|
||||
},
|
||||
'pane:splitDown': focusedWindow => {
|
||||
focusedWindow && focusedWindow.rpc.emit('split request horizontal');
|
||||
focusedWindow && focusedWindow.rpc.emit('split request horizontal', {});
|
||||
},
|
||||
'pane:close': focusedWindow => {
|
||||
focusedWindow && focusedWindow.rpc.emit('termgroup close req');
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ module.exports = class Window {
|
|||
// If no callback is passed to createWindow,
|
||||
// a new session will be created by default.
|
||||
if (!fn) {
|
||||
fn = win => win.rpc.emit('termgroup add req');
|
||||
fn = win => win.rpc.emit('termgroup add req', {});
|
||||
}
|
||||
|
||||
// app.windowCallback is the createWindow callback
|
||||
|
|
@ -166,7 +166,8 @@ module.exports = class Window {
|
|||
uid: options.uid,
|
||||
splitDirection: options.splitDirection,
|
||||
shell: session.shell,
|
||||
pid: session.pty.pid
|
||||
pid: session.pty ? session.pty.pid : null,
|
||||
activeUid: options.activeUid
|
||||
});
|
||||
|
||||
// If this is the initial session, flush any events that might have
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import {
|
|||
SESSION_SEARCH_CLOSE
|
||||
} from '../constants/sessions';
|
||||
|
||||
export function addSession({uid, shell, pid, cols, rows, splitDirection}) {
|
||||
export function addSession({uid, shell, pid, cols, rows, splitDirection, activeUid}) {
|
||||
return (dispatch, getState) => {
|
||||
const {sessions} = getState();
|
||||
const now = Date.now();
|
||||
|
|
@ -29,7 +29,7 @@ export function addSession({uid, shell, pid, cols, rows, splitDirection}) {
|
|||
cols,
|
||||
rows,
|
||||
splitDirection,
|
||||
activeUid: sessions.activeUid,
|
||||
activeUid: activeUid ? activeUid : sessions.activeUid,
|
||||
now
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,14 +12,15 @@ import getRootGroups from '../selectors';
|
|||
import {setActiveSession, ptyExitSession, userExitSession} from './sessions';
|
||||
|
||||
function requestSplit(direction) {
|
||||
return () => (dispatch, getState) => {
|
||||
return activeUid => (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: SESSION_REQUEST,
|
||||
effect: () => {
|
||||
const {ui} = getState();
|
||||
const {ui, sessions} = getState();
|
||||
rpc.emit('new', {
|
||||
splitDirection: direction,
|
||||
cwd: ui.cwd
|
||||
cwd: ui.cwd,
|
||||
activeUid: activeUid ? activeUid : sessions.activeUid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -37,7 +38,7 @@ export function resizeTermGroup(uid, sizes) {
|
|||
};
|
||||
}
|
||||
|
||||
export function requestTermGroup() {
|
||||
export function requestTermGroup(activeUid) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: TERM_GROUP_REQUEST,
|
||||
|
|
@ -46,7 +47,8 @@ export function requestTermGroup() {
|
|||
const {cwd} = ui;
|
||||
rpc.emit('new', {
|
||||
isNewGroup: true,
|
||||
cwd
|
||||
cwd,
|
||||
activeUid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
12
lib/index.js
12
lib/index.js
|
|
@ -142,16 +142,16 @@ rpc.on('session search close', () => {
|
|||
store_.dispatch(sessionActions.closeSearch());
|
||||
});
|
||||
|
||||
rpc.on('termgroup add req', () => {
|
||||
store_.dispatch(termGroupActions.requestTermGroup());
|
||||
rpc.on('termgroup add req', ({activeUid}) => {
|
||||
store_.dispatch(termGroupActions.requestTermGroup(activeUid));
|
||||
});
|
||||
|
||||
rpc.on('split request horizontal', () => {
|
||||
store_.dispatch(termGroupActions.requestHorizontalSplit());
|
||||
rpc.on('split request horizontal', ({activeUid}) => {
|
||||
store_.dispatch(termGroupActions.requestHorizontalSplit(activeUid));
|
||||
});
|
||||
|
||||
rpc.on('split request vertical', () => {
|
||||
store_.dispatch(termGroupActions.requestVerticalSplit());
|
||||
rpc.on('split request vertical', ({activeUid}) => {
|
||||
store_.dispatch(termGroupActions.requestVerticalSplit(activeUid));
|
||||
});
|
||||
|
||||
rpc.on('reset fontSize req', () => {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ const reducer = (state = initialState, action) => {
|
|||
cols: action.cols,
|
||||
rows: action.rows,
|
||||
uid: action.uid,
|
||||
shell: action.shell.split('/').pop(),
|
||||
shell: action.shell ? action.shell.split('/').pop() : null,
|
||||
pid: action.pid
|
||||
})
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue