Skip to content

Commit

Permalink
feat: select current text with cmd+a (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev authored Nov 14, 2022
1 parent 27c3bb0 commit 061943c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/main/components/Cerebro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import React, {
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { clipboard, BrowserWindow } from 'electron'
import { clipboard } from 'electron'
import { focusableSelector } from '@cerebroapp/cerebro-ui'
import escapeStringRegexp from 'escape-string-regexp'

// import debounce from 'lodash/debounce'

import getWindowPosition from 'lib/getWindowPosition'
import {
WINDOW_WIDTH,
Expand All @@ -25,9 +23,7 @@ import ResultsList from '../ResultsList'
import StatusBar from '../StatusBar'
import styles from './styles.module.css'

const remote = process.type === 'browser'
? { getCurrentWindow: BrowserWindow.getFocusedWindow }
: require('@electron/remote')
const remote = require('@electron/remote')

/**
* Wrap click or mousedown event to custom `select-item` event,
Expand Down Expand Up @@ -206,8 +202,8 @@ function Cerebro({

// shortcuts for ctrl+...
if ((event.metaKey || event.ctrlKey) && !event.altKey) {
// Copy to clipboard on cmd+c
if (event.keyCode === 67) {
// Copy to clipboard on cmd+c
const text = highlightedResult()?.clipboard || term
if (text) {
clipboard.writeText(text)
Expand All @@ -220,6 +216,12 @@ function Cerebro({
return
}

// Select text on cmd+a
if (event.keyCode === 65) {
mainInput.current.select()
event.preventDefault()
}

// Select element by number
if (event.keyCode >= 49 && event.keyCode <= 57) {
const number = Math.abs(49 - event.keyCode)
Expand Down

0 comments on commit 061943c

Please sign in to comment.