Fix wrong quotes
This commit is contained in:
parent
81f4f7ccf0
commit
ab75b2bca3
@ -3,9 +3,10 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
# we're not in a dev environment, so we don't need to worry about typing
|
# we're not in a dev environment, so we don't need to worry about typing
|
||||||
pass
|
pass
|
||||||
|
from micropython import const
|
||||||
|
|
||||||
from kmk.keys import KC, Key
|
from kmk.keys import KC, Key
|
||||||
from kmk.modules import Module
|
from kmk.modules import Module
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
@ -21,7 +22,7 @@ class DictionaryEntry:
|
|||||||
|
|
||||||
|
|
||||||
class Character:
|
class Character:
|
||||||
"""Helper class for making a left-shifted key identical to a right-shifted key"""
|
'''Helper class for making a left-shifted key identical to a right-shifted key'''
|
||||||
|
|
||||||
is_shifted: bool = False
|
is_shifted: bool = False
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ class Character:
|
|||||||
|
|
||||||
|
|
||||||
class Phrase:
|
class Phrase:
|
||||||
"""Manages a collection of characters and keeps an index of them so that potential matches can be tracked"""
|
'''Manages a collection of characters and keeps an index of them so that potential matches can be tracked'''
|
||||||
|
|
||||||
def __init__(self, string: str) -> None:
|
def __init__(self, string: str) -> None:
|
||||||
self._characters: list[Character] = []
|
self._characters: list[Character] = []
|
||||||
@ -48,36 +49,36 @@ class Phrase:
|
|||||||
self._characters.append(Character(key_code, shifted))
|
self._characters.append(Character(key_code, shifted))
|
||||||
|
|
||||||
def next_character(self) -> None:
|
def next_character(self) -> None:
|
||||||
"""Increment the current index for this phrase"""
|
'''Increment the current index for this phrase'''
|
||||||
if not self.index_at_end():
|
if not self.index_at_end():
|
||||||
self._index += 1
|
self._index += 1
|
||||||
|
|
||||||
def get_character_at_current_index(self) -> Character:
|
def get_character_at_current_index(self) -> Character:
|
||||||
"""Returns the character at the current index for this phrase"""
|
'''Returns the character at the current index for this phrase'''
|
||||||
return self._characters[self._index]
|
return self._characters[self._index]
|
||||||
|
|
||||||
def reset_index(self) -> None:
|
def reset_index(self) -> None:
|
||||||
"""Reset the index to the start of the phrase"""
|
'''Reset the index to the start of the phrase'''
|
||||||
self._index = 0
|
self._index = 0
|
||||||
|
|
||||||
def index_at_end(self) -> bool:
|
def index_at_end(self) -> bool:
|
||||||
"""Returns True if the index is at the end of the phrase"""
|
'''Returns True if the index is at the end of the phrase'''
|
||||||
return self._index == len(self._characters)
|
return self._index == len(self._characters)
|
||||||
|
|
||||||
def character_is_next(self, character) -> bool:
|
def character_is_next(self, character) -> bool:
|
||||||
"""Returns True if the given character is the next character in the phrase"""
|
'''Returns True if the given character is the next character in the phrase'''
|
||||||
return self.get_character_at_current_index() == character
|
return self.get_character_at_current_index() == character
|
||||||
|
|
||||||
|
|
||||||
class Rule:
|
class Rule:
|
||||||
"""Represents the relationship between a phrase to be substituted and its substitution"""
|
'''Represents the relationship between a phrase to be substituted and its substitution'''
|
||||||
|
|
||||||
def __init__(self, to_substitute: Phrase, substitution: Phrase) -> None:
|
def __init__(self, to_substitute: Phrase, substitution: Phrase) -> None:
|
||||||
self.to_substitute: Phrase = to_substitute
|
self.to_substitute: Phrase = to_substitute
|
||||||
self.substitution: Phrase = substitution
|
self.substitution: Phrase = substitution
|
||||||
|
|
||||||
def restart(self) -> None:
|
def restart(self) -> None:
|
||||||
"""Resets this rule's to_substitute and substitution phrases"""
|
'''Resets this rule's to_substitute and substitution phrases'''
|
||||||
self.to_substitute.reset_index()
|
self.to_substitute.reset_index()
|
||||||
self.substitution.reset_index()
|
self.substitution.reset_index()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user