import json
import math

FILE = "terminal.json"

rows = [
    "1234567890-",
    "qwertyuiop",
    "asdfghjkl",
    "zxcvbnm,.?"
]

COLS = 11

def make_actions():
    actions = []

    for row in rows:
        keys = list(row)

        # pad row with spaces
        while len(keys) < COLS:
            keys.append(" ")

        for k in keys:
            actions.append({
                "label": k,
                "width": 16
            })

    return actions


with open(FILE) as f:
    data = json.load(f)

data["actions"] = make_actions()

with open(FILE, "w") as f:
    json.dump(data, f, indent=4)

print("terminal.json updated")