Skip to content

Commit

Permalink
Changed again the symbol regexp, added other money symbols, modified …
Browse files Browse the repository at this point in the history
…behavior of manual activation according to normal profile
  • Loading branch information
ABuffEr committed Aug 14, 2024
1 parent d61fc0a commit ccfa1f0
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions addon/globalPlugins/numberProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class Status(Enum):
DISABLED = 0
AUTO_ENABLED = 1
MANUAL_ENABLED = 2
MANUAL_NORMAL_ENABLED = 3


def debugLog(message):
if DEBUG:
Expand All @@ -72,7 +74,7 @@ def loadConfig():
loadConfig()

def filter_numberProcessing(speechSequence):
if not isEnabled():
if not isProcessingEnabled():
return speechSequence
debugLog("Initial speech sequence: %s"%speechSequence)
newSpeechSequence = []
Expand All @@ -92,9 +94,24 @@ def filter_numberProcessing(speechSequence):
debugLog("New speech sequence: %s"%newSpeechSequence)
return newSpeechSequence

def isEnabled():
status = profileStatus.get(curProfile, Status.DISABLED)
return bool(status.value)
def isProcessingEnabled():
normalStatus = profileStatus.get(None, Status.DISABLED)
curStatus = profileStatus.get(curProfile, Status.DISABLED)
return bool(normalStatus.value) or bool(curStatus.value)

def enableProcessing():
if curProfile is None:
newStatus = Status.MANUAL_NORMAL_ENABLED
else:
newStatus = Status.MANUAL_ENABLED
profileStatus[curProfile] = newStatus

def disableProcessing():
newStatus = Status.DISABLED
profileStatus[curProfile] = newStatus
if curProfile and Status.MANUAL_NORMAL_ENABLED in profileStatus.values():
profileStatus[None] = newStatus


def replaceFunc(match):
# group(0) returns digits captured by match
Expand Down Expand Up @@ -189,11 +206,11 @@ def script_toggleDigitManager(self, gesture, repeating=False):
self.script_toggleDigitManager(None, repeating=True)
return
loadConfig()
if not isEnabled():
profileStatus[curProfile] = Status.MANUAL_ENABLED
if not isProcessingEnabled():
enableProcessing()
message = _("Digit processing on")
else:
profileStatus[curProfile] = Status.DISABLED
disableProcessing()
message = _("Digit processing off")
if not repeating:
ui.message(message)
Expand Down

0 comments on commit ccfa1f0

Please sign in to comment.