https://bitbucket.org/hudson/magic-lantern
Raw File
Tip revision: 2edf3588768b8a4c86d45a6bec3255fe41418bad authored by nanomad on 10 September 2011, 00:10:53 UTC
We can now display a simple Hello World message on the screen
Tip revision: 2edf358
menuindex.py
import os,sys,string

f = open("menuindex.txt").readlines()

o = open("cam/menuidx.dat", "w")
menu = open("../src/menuindex.c", "w")

print >> menu, """
// Auto-generated; do not edit this file.
// Edit doc/menuindex.py instead.

#include "dryos.h"
#include "version.h"
#include "bmp.h"
#include "menu.h"
#include "menuhelp.h"

struct menu_entry help_menus[] = {
    {
        .name = "About Magic Lantern",
        .priv = "About Magic Lantern",
        .select = menu_help_go_to_label,
        .display = menu_print,
    },"""

print >> o, "001 About Magic Lantern"

sections = 0

#~ idx = {}
#~ idxp = {}
for l in f[1:]:
    l = l.strip("\n").split(" ")
    page, type, name = l[0], l[1], string.join(l[2:], " ")
    page = int(page)
    name = name.replace(r"$\leftrightarrow $", "<-->")
    name = name.replace(r"$\rightarrow $", "->")

    if type == "subsubsection": # each menu entry is a subsection
        item = name.split(":")[0]
        item = item.split(" and ")[0] # hacks, to be removed
        item = item.split(" / ")[0]
        item = item.split(" X sec")[0]
        item = item.strip()
        #~ idx[item] = page
        #~ idxp[page] = item
        print page, item
        print >> o, "%03d %s" % (page, item)

    if type == "section": # main sections in menu
        sections += 1
        item = name
        print page, item
        print >> o, "%03d %s" % (page, item)
        print >> menu, """    {
        .name = "%s",
        .priv = "%s",
        .select = menu_help_go_to_label,
        .display = menu_print,
    },""" % (item, item)

    if type == "end":
        lastpage = page - 1
        print >> o, "%03d end" % lastpage

print >> menu, """};

static void
help_menu_init( void* unused )
{
	menu_add(" (i)", help_menus, COUNT(help_menus));
}

INIT_FUNC( "help_menu", help_menu_init );

int help_pages = %d;
int help_menus_num = %d;

""" % (lastpage, sections+1);

#~ print idxp
o.close()
menu.close()
back to top