Skip to content

Commit

Permalink
👓 Rename KeyCombinationHistory to KeyHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
greena13 committed Jul 9, 2019
1 parent c6aa828 commit 7dfe0ea
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import KeyCombinationRecord from './KeyCombinationRecord';
* List of key combinations seen by hot key components
* @class
*/
class KeyCombinationHistory {
class KeyHistory {
/**
* Creates a new KeyCombinationHistory instance
* Creates a new KeyHistory instance
* @param {Number} maxLength Maximum length of the list.
* @param {KeyCombinationRecord} startingPoint Initial state of first combination
* @returns {KeyCombinationHistory}
* @returns {KeyHistory}
*/
constructor({ maxLength }, startingPoint = null) {
this._records = [];
Expand Down Expand Up @@ -137,4 +137,4 @@ class KeyCombinationHistory {
}
}

export default KeyCombinationHistory;
export default KeyHistory;
26 changes: 13 additions & 13 deletions src/lib/matching/ActionResolver.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import KeyCombinationHistoryMatcher from './KeyCombinationHistoryMatcher';
import KeyHistoryMatcher from './KeyHistoryMatcher';

/**
* Resolves the correct actions to trigger for a list of hotkeys components and a
Expand All @@ -15,7 +15,7 @@ class ActionResolver {
/**
* List of mappings from key sequences to handlers that is constructed on-the-fly
* as key events propagate up the render tree
* @type {KeyCombinationHistoryMatcher[]}
* @type {KeyHistoryMatcher[]}
*/
this._keyMapMatchers = [];

Expand Down Expand Up @@ -45,21 +45,21 @@ class ActionResolver {
while(iterator.next()) {
const { handlers } = iterator.getComponent();
this._unmatchedHandlerStatus.push( [ Object.keys(handlers).length, {} ]);
this._keyMapMatchers.push(new KeyCombinationHistoryMatcher());
this._keyMapMatchers.push(new KeyHistoryMatcher());
}

this._componentList = componentList;
this._componentListIterator = componentList.getNewIterator();
}

/**
* The KeyCombinationHistoryMatcher for the component in a particular position
* The KeyHistoryMatcher for the component in a particular position
* @param {number} componentPosition Position of component to find the
* KeyCombinationHistoryMatcher for
* @returns {KeyCombinationHistoryMatcher} Key combination matcher that corresponds
* KeyHistoryMatcher for
* @returns {KeyHistoryMatcher} Key combination matcher that corresponds
* to the component
*/
getKeyCombinationHistoryMatcher(componentPosition) {
getKeyHistoryMatcher(componentPosition) {
if (this._componentHasUnmatchedHandlers(componentPosition)) {
/**
* We build the mapping between actions and their closest handlers the
Expand All @@ -75,7 +75,7 @@ class ActionResolver {
}
}

return this._getKeyCombinationHistoryMatcher(componentPosition);
return this._getKeyHistoryMatcher(componentPosition);
}

/**
Expand All @@ -85,13 +85,13 @@ class ActionResolver {
* @returns {boolean} true if the component has an action bound to the event type
*/
componentHasActionsBoundToEventType(componentPosition, keyEventType) {
return this.getKeyCombinationHistoryMatcher(componentPosition).hasMatchesForEventType(keyEventType);
return this.getKeyHistoryMatcher(componentPosition).hasMatchesForEventType(keyEventType);
}

/**
* Finds matcher for sequence and current key event for a component at a position
* @param {number} componentPosition Position of the component
* @param {KeyCombinationHistory} keyHistory History of key combinations to match
* @param {KeyHistory} keyHistory History of key combinations to match
* against actions defined in component
* @param {ReactKeyName} keyName Name of the key the current event relates to
* @param {KeyEventType} keyEventType Type of key event
Expand All @@ -102,7 +102,7 @@ class ActionResolver {
return null;
}

return this.getKeyCombinationHistoryMatcher(componentPosition).findMatch(
return this.getKeyHistoryMatcher(componentPosition).findMatch(
keyHistory,
keyName,
keyEventType
Expand All @@ -113,7 +113,7 @@ class ActionResolver {
* Private methods
*********************************************************************************/

_getKeyCombinationHistoryMatcher(index) {
_getKeyHistoryMatcher(index) {
return this._keyMapMatchers[index];
}

Expand Down Expand Up @@ -141,7 +141,7 @@ class ActionResolver {
* Get key map that corresponds with the component that defines the handler
* closest to the event target
*/
const keyMapMatcher = this._getKeyCombinationHistoryMatcher(handlerComponentIndex);
const keyMapMatcher = this._getKeyHistoryMatcher(handlerComponentIndex);

/**
* At least one child HotKeys component (or the component itself) has
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import KeyCombinationRecordMatcher from './KeyCombinationRecordMatcher';
import KeyEventRecordState from '../../const/KeyEventRecordState';

/**
* Matches a KeyCombinationHistory to a list of pre-registered ActionConfiguration and
* Matches a KeyHistory to a list of pre-registered ActionConfiguration and
* their corresponding handler functions
* @class
*/
class KeyCombinationHistoryMatcher {
class KeyHistoryMatcher {
/**
* Returns a new instance of KeyMapMatcher
* @returns {KeyCombinationHistoryMatcher}
* @returns {KeyHistoryMatcher}
*/
constructor() {
this._combinationMatchers = {};
Expand Down Expand Up @@ -52,19 +52,19 @@ class KeyCombinationHistoryMatcher {
/**
* Attempts to find a match from the list of possible matches previously registered
* for a given key event and key combination history
* @param {KeyCombinationHistory} keyCombinationHistory History to attempt to
* @param {KeyHistory} keyHistory History to attempt to
* find a match for
* @param {ReactKeyName} key Name of the key to find a match for
* @param {KeyEventType} keyEventType Type of event to find a match
* @returns {MatchingActionConfig|null} First MatchingActionOptions that matches
*/
findMatch(keyCombinationHistory, key, keyEventType) {
const combinationMatcher = this._findCombinationMatcher(keyCombinationHistory);
findMatch(keyHistory, key, keyEventType) {
const combinationMatcher = this._findCombinationMatcher(keyHistory);

if (combinationMatcher) {
return combinationMatcher.findMatch(
keyCombinationHistory.getCurrentCombination(),
keyCombinationHistory.getCurrentCombination().getNormalizedKeyName(key),
keyHistory.getCurrentCombination(),
keyHistory.getCurrentCombination().getNormalizedKeyName(key),
keyEventType
)
}
Expand Down Expand Up @@ -122,9 +122,9 @@ class KeyCombinationHistoryMatcher {
return this._combinationMatchers[prefix];
}

_findCombinationMatcher(keyCombinationHistory) {
_findCombinationMatcher(keyHistory) {
const sequenceHistory =
keyCombinationHistory.getMostRecentCombinations(this.getLongestSequence());
keyHistory.getMostRecentCombinations(this.getLongestSequence());

if (sequenceHistory.length === 0) {
return this._combinationMatchers[''];
Expand Down Expand Up @@ -171,4 +171,4 @@ class KeyCombinationHistoryMatcher {
}
}

export default KeyCombinationHistoryMatcher;
export default KeyHistoryMatcher;
12 changes: 6 additions & 6 deletions src/lib/strategies/AbstractKeyEventStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ModifierFlagsDictionary from '../../const/ModifierFlagsDictionary';
import Logger from '../logging/Logger';
import KeyCombinationSerializer from '../shared/KeyCombinationSerializer';
import Configuration from '../config/Configuration';
import KeyCombinationHistory from '../listening/KeyCombinationHistory';
import KeyHistory from '../listening/KeyHistory';
import KeyCombinationRecord from '../listening/KeyCombinationRecord';
import ComponentTree from '../definitions/ComponentTree';
import ComponentOptionsList from '../definitions/ComponentOptionsList';
Expand Down Expand Up @@ -94,7 +94,7 @@ class AbstractKeyEventStrategy {
}

_newKeyHistory() {
return new KeyCombinationHistory({
return new KeyHistory({
maxLength: this.componentList.getLongestSequence()
});
}
Expand Down Expand Up @@ -130,7 +130,7 @@ class AbstractKeyEventStrategy {
this.keyupEventsToSimulate = [];

if (this.getKeyHistory().any() && !options.force) {
this._keyHistory = new KeyCombinationHistory(
this._keyHistory = new KeyHistory(
{ maxLength: this.componentList.getLongestSequence() },
new KeyCombinationRecord(this.getCurrentCombination().keysStillPressedDict())
);
Expand Down Expand Up @@ -383,13 +383,13 @@ class AbstractKeyEventStrategy {
}

while (componentSearchIndex <= componentPosition) {
const keyCombinationHistoryMatcher =
this._actionResolver.getKeyCombinationHistoryMatcher(componentSearchIndex);
const keyHistoryMatcher =
this._actionResolver.getKeyHistoryMatcher(componentSearchIndex);

this.logger.verbose(
this._logPrefix(componentSearchIndex),
'Internal key mapping:\n',
`${printComponent(keyCombinationHistoryMatcher.toJSON())}`
`${printComponent(keyHistoryMatcher.toJSON())}`
);

const sequenceMatch =
Expand Down

0 comments on commit 7dfe0ea

Please sign in to comment.