diff --git a/app/commands.js b/app/commands.js index 19632cd4..4791b8bf 100644 --- a/app/commands.js +++ b/app/commands.js @@ -101,6 +101,12 @@ const commands = { 'editor:break': focusedWindow => { focusedWindow && focusedWindow.rpc.emit('session break req'); }, + 'editor:search': focusedWindow => { + focusedWindow && focusedWindow.rpc.emit('session search'); + }, + 'editor:search-close': focusedWindow => { + focusedWindow && focusedWindow.rpc.emit('session search close'); + }, 'cli:install': () => { installCLI(true); }, diff --git a/app/keymaps/darwin.json b/app/keymaps/darwin.json index 908e71ab..30f0f276 100644 --- a/app/keymaps/darwin.json +++ b/app/keymaps/darwin.json @@ -39,6 +39,8 @@ "editor:copy": "command+c", "editor:paste": "command+v", "editor:selectAll": "command+a", + "editor:search": "command+f", + "editor:search-close": "esc", "editor:movePreviousWord": "alt+left", "editor:moveNextWord": "alt+right", "editor:moveBeginningLine": "command+left", diff --git a/app/keymaps/linux.json b/app/keymaps/linux.json index 1c9ff68d..ab07a2fd 100644 --- a/app/keymaps/linux.json +++ b/app/keymaps/linux.json @@ -36,6 +36,8 @@ "editor:copy": "ctrl+shift+c", "editor:paste": "ctrl+shift+v", "editor:selectAll": "ctrl+shift+a", + "editor:search": "ctrl+shift+f", + "editor:search-close": "esc", "editor:movePreviousWord": "ctrl+left", "editor:moveNextWord": "ctrl+right", "editor:moveBeginningLine": "home", diff --git a/app/keymaps/win32.json b/app/keymaps/win32.json index ce80196f..9d8fe435 100644 --- a/app/keymaps/win32.json +++ b/app/keymaps/win32.json @@ -40,6 +40,8 @@ "editor:copy": "ctrl+shift+c", "editor:paste": "ctrl+shift+v", "editor:selectAll": "ctrl+shift+a", + "editor:search": "ctrl+shift+f", + "editor:search-close": "esc", "editor:movePreviousWord": "ctrl+left", "editor:moveNextWord": "ctrl+right", "editor:moveBeginningLine": "Home", diff --git a/app/menus/menus/edit.js b/app/menus/menus/edit.js index bac65a3d..0c017447 100644 --- a/app/menus/menus/edit.js +++ b/app/menus/menus/edit.js @@ -113,6 +113,13 @@ module.exports = (commandKeys, execCommand) => { click(item, focusedWindow) { execCommand('editor:clearBuffer', focusedWindow); } + }, + { + label: 'Search', + accelerator: commandKeys['editor:search'], + click(item, focusedWindow) { + execCommand('editor:search', focusedWindow); + } } ]; diff --git a/lib/actions/sessions.js b/lib/actions/sessions.js index 42f96732..4d1bd95a 100644 --- a/lib/actions/sessions.js +++ b/lib/actions/sessions.js @@ -12,7 +12,9 @@ import { SESSION_SET_ACTIVE, SESSION_CLEAR_ACTIVE, SESSION_USER_DATA, - SESSION_SET_XTERM_TITLE + SESSION_SET_XTERM_TITLE, + SESSION_SEARCH, + SESSION_SEARCH_CLOSE } from '../constants/sessions'; export function addSession({uid, shell, pid, cols, rows, splitDirection}) { @@ -131,6 +133,26 @@ export function resizeSession(uid, cols, rows) { }; } +export function onSearch(uid) { + return (dispatch, getState) => { + const targetUid = uid || getState().sessions.activeUid; + dispatch({ + type: SESSION_SEARCH, + uid: targetUid + }); + }; +} + +export function closeSearch(uid) { + return (dispatch, getState) => { + const targetUid = uid || getState().sessions.activeUid; + dispatch({ + type: SESSION_SEARCH_CLOSE, + uid: targetUid + }); + }; +} + export function sendSessionData(uid, data, escaped) { return (dispatch, getState) => { dispatch({ diff --git a/lib/components/searchBox.js b/lib/components/searchBox.js new file mode 100644 index 00000000..08eee3ff --- /dev/null +++ b/lib/components/searchBox.js @@ -0,0 +1,78 @@ +import React from 'react'; + +const searchBoxStyling = { + float: 'right', + height: '28px', + backgroundColor: 'white', + position: 'absolute', + right: '10px', + top: '25px', + width: '224px', + zIndex: '9999' +}; + +const enterKey = 13; + +export default class SearchBox extends React.PureComponent { + constructor(props) { + super(props); + this.handleChange = this.handleChange.bind(this); + this.searchTerm = ''; + } + + handleChange(event) { + this.searchTerm = event.target.value; + if (event.keyCode === enterKey) { + this.props.search(event.target.value); + } + } + + render() { + return ( +