Skip to content

Instantly share code, notes, and snippets.

@okay-type
Last active September 19, 2019 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okay-type/85e6f60fc35092d5a6249ee26b2bdd4c to your computer and use it in GitHub Desktop.
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
# 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