Example #1
0
 def quit(self):
     doc.unbind("keydown")
     doc.unbind("mousemove")
     self.display.game_canvas.style.cursor = "default"
     self.display.clear_all()
     if self.frame_id is not None:
         clear_timeout(self.frame_id)
Example #2
0
 def quit(self):
     doc.unbind("keydown")
     doc.unbind("mousemove")
     self.display.game_canvas.style.cursor = "default"
     self.display.clear_all()
     if self.frame_id is not None:
         clear_timeout(self.frame_id)
Example #3
0
def show(path,zone,page=0):
    src = open(path).read()
    title = ''
    page_num = False
    while src.startswith('@'):
        line_end = src.find('\n')
        key,value = src[:line_end].split(' ',1)
        if key=='@title':
            title = value
        elif key=='@pagenum':
            page_num = True
        src = src[line_end+1:]

    zone.html = ''
    pages = src.split('../..\n')
    if page<0:
        page = 0
    elif page >= len(pages):
        page = len(pages)-1
    doc.unbind('keydown')
    doc.bind('keydown',lambda ev:keydown(ev,path,zone,page))
    body = html.DIV()
    body.html = markdown.mark(pages[page])[0]

    footer = html.DIV(Id="footer")
    if title:
        footer <= html.DIV(title,style=dict(display='inline'))
    if page_num:
        footer <= html.SPAN(' (%s/%s)' %(page+1,len(pages)),
            style=dict(display='inline'))
    timeline = html.DIV(Id='timeline')
    tl_pos = html.DIV(Id='tl_pos')
    timeline <= tl_pos
    timeline.bind('click',lambda ev:move_to(ev,path,zone,len(pages)))
    tl_pos.bind('click',click_on_tl_pos)
    zone <= body+footer+timeline
    tl_pos.style.left = '%spx' %(timeline.width*page/len(pages))
Example #4
0
 def mouseUp(e):
     doc.unbind('mousemove')
Example #5
0
def show(path, zone, page_num=0):
    src = open(path).read()
    title = ''
    show_page_num = False

    # table of contents : matches matter with page number
    contents = []

    # directives for the document
    while src.startswith('@'):
        line_end = src.find('\n')
        key, value = src[:line_end].split(' ', 1)
        if key == '@title':
            title = value
        elif key == '@pagenum':
            show_page_num = True
        elif key == "@index":
            contents.append([value, 0])
        src = src[line_end + 1:]

    zone.html = ''
    pages = src.split('../..\n')

    # table of contents
    for num, _page in enumerate(pages):
        if num == 0:
            continue
        if _page.startswith('@index'):
            line_end = _page.find('\n')
            key, value = _page[:line_end].split(' ', 1)
            contents.append([value, num])
            pages[num] = _page[line_end + 1:]

    if page_num < 0:
        page_num = 0
    elif page_num >= len(pages):
        page_num = len(pages) - 1
    doc.unbind('keydown')
    doc.bind('keydown', lambda ev: keydown(ev, path, zone, page_num))

    # if table of contents is not empty, add it
    if contents:
        toc = html.SELECT(name="toc")
        toc.bind(
            'change', lambda ev: show(
                path, zone,
                int(ev.target.options[ev.target.selectedIndex].value)))
        for content in contents:
            toc <= html.OPTION(
                content[0], value=content[1], selected=page_num >= content[1])

    body = html.DIV()
    body.html = markdown.mark(pages[page_num])[0]

    if contents:
        body = html.DIV(toc + body)

    footer = html.DIV(Id="footer")
    if title:
        footer <= html.DIV(title, style=dict(display='inline'))
    if show_page_num:
        footer <= html.SPAN(' (%s/%s)' % (page_num + 1, len(pages)),
                            style=dict(display='inline'))
    timeline = html.DIV(Id='timeline')
    tl_pos = html.DIV(Id='tl_pos')
    timeline <= tl_pos
    timeline.bind('click', lambda ev: move_to(ev, path, zone, len(pages)))
    tl_pos.bind('click', click_on_tl_pos)
    zone <= body + footer + timeline
    tl_pos.style.left = '%spx' % (timeline.width * page_num / len(pages))
Example #6
0
def show(path, zone, page_num=0):
    src = open(path).read()
    title = ''
    show_page_num = False
    
    # table of contents : matches matter with page number
    contents = []
    
    # directives for the document
    while src.startswith('@'):
        line_end = src.find('\n')
        key,value = src[:line_end].split(' ',1)
        if key=='@title':
            title = value
        elif key=='@pagenum':
            show_page_num = True
        elif key=="@index":
            contents.append([value, 0])
        src = src[line_end+1:]

    zone.html = ''
    pages = src.split('../..\n')
    
    # table of contents
    for num, _page in enumerate(pages):
        if num==0:
            continue
        if _page.startswith('@index'):
            line_end = _page.find('\n')
            key,value = _page[:line_end].split(' ',1)
            contents.append([value, num])
            pages[num] = _page[line_end+1:]
    
    if page_num<0:
        page_num = 0
    elif page_num >= len(pages):
        page_num = len(pages)-1
    doc.unbind('keydown')
    doc.bind('keydown',lambda ev:keydown(ev, path, zone, page_num))
    
    # if table of contents is not empty, add it
    if contents:
        toc = html.SELECT(name="toc")
        toc.bind('change', lambda ev: show(path, zone, 
            int(ev.target.options[ev.target.selectedIndex].value)))
        for content in contents:
            toc <= html.OPTION(content[0], value=content[1],
                selected=page_num>=content[1])
            
    body = html.DIV()
    body.html = markdown.mark(pages[page_num])[0]

    if contents:
        body = html.DIV(toc+body)

    footer = html.DIV(Id="footer")
    if title:
        footer <= html.DIV(title,style=dict(display='inline'))
    if show_page_num:
        footer <= html.SPAN(' (%s/%s)' %(page_num+1, len(pages)),
            style=dict(display='inline'))
    timeline = html.DIV(Id='timeline')
    tl_pos = html.DIV(Id='tl_pos')
    timeline <= tl_pos
    timeline.bind('click', lambda ev:move_to(ev, path, zone, len(pages)))
    tl_pos.bind('click', click_on_tl_pos)
    zone <= body+footer+timeline
    tl_pos.style.left = '%spx' %(timeline.width*page_num/len(pages))
Example #7
0
 def mouseUp(e):
     doc.unbind('mousemove')