mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-23 20:40:41 -07:00
feat(cli): customizable keyboard shortcuts (#21945)
This commit is contained in:
committed by
GitHub
parent
657f19c1f3
commit
daf3701194
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import type { KeyMatchers } from '../key/keyMatchers.js';
|
||||
import { defaultKeyMatchers } from '../key/keyMatchers.js';
|
||||
|
||||
/**
|
||||
* Hook to retrieve the currently active key matchers.
|
||||
* This prepares the codebase for dynamic or custom key bindings in the future.
|
||||
*/
|
||||
export function useKeyMatchers(): KeyMatchers {
|
||||
return useMemo(() => defaultKeyMatchers, []);
|
||||
}
|
||||
33
packages/cli/src/ui/hooks/useKeyMatchers.tsx
Normal file
33
packages/cli/src/ui/hooks/useKeyMatchers.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type React from 'react';
|
||||
import { createContext, useContext } from 'react';
|
||||
import type { KeyMatchers } from '../key/keyMatchers.js';
|
||||
import { defaultKeyMatchers } from '../key/keyMatchers.js';
|
||||
|
||||
export const KeyMatchersContext =
|
||||
createContext<KeyMatchers>(defaultKeyMatchers);
|
||||
|
||||
export const KeyMatchersProvider = ({
|
||||
children,
|
||||
value,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
value: KeyMatchers;
|
||||
}): React.JSX.Element => (
|
||||
<KeyMatchersContext.Provider value={value}>
|
||||
{children}
|
||||
</KeyMatchersContext.Provider>
|
||||
);
|
||||
|
||||
/**
|
||||
* Hook to retrieve the currently active key matchers.
|
||||
* Defaults to defaultKeyMatchers if no provider is present, allowing tests to run without explicit wrappers.
|
||||
*/
|
||||
export function useKeyMatchers(): KeyMatchers {
|
||||
return useContext(KeyMatchersContext);
|
||||
}
|
||||
Reference in New Issue
Block a user