# This is a keyjnote "InfoScript" that patches in a new feature. This script # allows you to jump to a page in a presentation by typing in the page number # and then hitting 'g'. # # If you make a mistake, hit '9' a few times and hit 'g'. The script will # silently fail to go to the non-existent page, and you can start again. # # This is how I call keyjnote: # # keyjnote -g 1024x768 -t none -I ~/bin/keyjnote_jumper.py # Where the last argument is the location of this file. # # Other key presses I use: # tab show icon view # f fullscreen toggle # b/w black/white screen toggle # If you draw a box with left mouse, clear with right mouse click. # # Iain Murray, May 2008 num_key_buff = '' def key_accum(ch): global num_key_buff num_key_buff += ch def go_key_press(): global num_key_buff if num_key_buff: try: page = int(num_key_buff) num_key_buff = '' LeaveZoomMode() if page < 1: page = PageCount + page TransitionTo(page) except: num_key_buff = '' def key0_press(): key_accum('0') def key1_press(): key_accum('1') def key2_press(): key_accum('2') def key3_press(): key_accum('3') def key4_press(): key_accum('4') def key5_press(): key_accum('5') def key6_press(): key_accum('6') def key7_press(): key_accum('7') def key8_press(): key_accum('8') def key9_press(): key_accum('9') def keyminus_press(): key_accum('-') PageProps = {} for pp in range(PageCount): # Note keyjnote documentation recommends against using lambda functions # in PageProps. PageProps[pp+1] = {'keys': { 'g': go_key_press, 'm': keyminus_press, # would have to hack keyjnote itself to catch '-'? '0': key0_press, '1': key1_press, '2': key2_press, '3': key3_press, '4': key4_press, '5': key5_press, '6': key6_press, '7': key7_press, '8': key8_press, '9': key9_press, }} # Including one lambda function causes keyjnote to do something desirable: not # trash this script's file when hitting 's'. So I'm deliberately poisoning the # PageProps dictionary here: PageProps[1]['keys']['0'] = lambda: key_accum('0')