Last active
September 19, 2019 16:43
-
-
Save okay-type/85e6f60fc35092d5a6249ee26b2bdd4c to your computer and use it in GitHub Desktop.
Go to the next line of Input Text in Robofont's Space Center
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Go to the next line of Input Text in Robofont's Space Center | |
from mojo.UI import CurrentSpaceCenter | |
from difflib import get_close_matches | |
class SpacecenterNext(object): | |
def __init__(self): | |
sp = CurrentSpaceCenter() | |
tgli = sp.top.glyphLineInput | |
items = tgli.getItems() | |
current = tgli.getRaw() | |
if current in items: | |
count = len(items) | |
index = items.index(current) | |
nextitem = index+1 | |
if nextitem >= count: | |
nextitem = 0 | |
nextline = items[nextitem] | |
sp.setRaw(nextline) | |
else: | |
x = get_close_matches(current, items) | |
try: | |
index = items.index(x[0]) | |
sp.setRaw(items[index]) | |
except: | |
tempcurrent = [item[:5] for item in items] | |
x = get_close_matches(current, tempcurrent) | |
try: | |
index = tempcurrent.index(x[0]) | |
sp.setRaw(items[index]) | |
except: | |
restart = 0 | |
sp.setRaw(items[restart]) | |
SpacecenterNext() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment