mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-04 12:00:16 +00:00
macro improvements
This commit is contained in:
parent
845b7c2397
commit
c63796bcb7
@ -216,7 +216,7 @@ def _parse_recurse(macro, handler, macro_instance=None, depth=0):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if functions.get(call) is None:
|
if functions.get(call) is None:
|
||||||
logger.error('Unknown function %s', call)
|
raise Exception(f'Unknown function {call}')
|
||||||
|
|
||||||
# get all the stuff inbetween
|
# get all the stuff inbetween
|
||||||
brackets = 0
|
brackets = 0
|
||||||
@ -231,14 +231,13 @@ def _parse_recurse(macro, handler, macro_instance=None, depth=0):
|
|||||||
if char == ')':
|
if char == ')':
|
||||||
brackets -= 1
|
brackets -= 1
|
||||||
if brackets < 0:
|
if brackets < 0:
|
||||||
logger.error('There is one ")" too much at %s', position)
|
raise Exception(f'There is one ")" too much at {position}')
|
||||||
return
|
|
||||||
if brackets == 0:
|
if brackets == 0:
|
||||||
# the closing bracket of the call
|
# the closing bracket of the call
|
||||||
break
|
break
|
||||||
|
|
||||||
if brackets != 0:
|
if brackets != 0:
|
||||||
logger.error('There are %s closing brackets missing', brackets)
|
raise Exception(f'There are {brackets} closing brackets missing')
|
||||||
|
|
||||||
inner = macro[2:position - 1]
|
inner = macro[2:position - 1]
|
||||||
|
|
||||||
@ -251,7 +250,7 @@ def _parse_recurse(macro, handler, macro_instance=None, depth=0):
|
|||||||
for param in string_params
|
for param in string_params
|
||||||
]
|
]
|
||||||
|
|
||||||
logger.spam('%scalling %s with %s', space, call, params)
|
logger.spam('%sadd call to %s with %s', space, call, params)
|
||||||
functions[call](*params)
|
functions[call](*params)
|
||||||
|
|
||||||
# is after this another call? Chain it to the macro_instance
|
# is after this another call? Chain it to the macro_instance
|
||||||
@ -286,7 +285,7 @@ def parse(macro, handler):
|
|||||||
macro will write to this function once executed with `.run()`.
|
macro will write to this function once executed with `.run()`.
|
||||||
"""
|
"""
|
||||||
# whitespaces, tabs, newlines and such don't serve a purpose. make
|
# whitespaces, tabs, newlines and such don't serve a purpose. make
|
||||||
# the log output clearer.
|
# the log output clearer and the parsing easier.
|
||||||
macro = re.sub(r'\s', '', macro)
|
macro = re.sub(r'\s', '', macro)
|
||||||
logger.spam('preparing macro %s for later execution', macro)
|
logger.spam('preparing macro %s for later execution', macro)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user