export slides as PNG files
This commit is contained in:
@@ -218,6 +218,10 @@ Keyboard shortcuts:
|
|||||||
help="Execute commands in `! or `> tags at show time with Enter key. WARNING: Potentially very dangerous to run others' slides with this switch!")
|
help="Execute commands in `! or `> tags at show time with Enter key. WARNING: Potentially very dangerous to run others' slides with this switch!")
|
||||||
parser.add_argument("-E",action="store_true",dest="execute_read",default=False,
|
parser.add_argument("-E",action="store_true",dest="execute_read",default=False,
|
||||||
help="Execute commands in $> tags at file read time. WARNING: Potentially very dangerous to run others' slides with this switch!")
|
help="Execute commands in $> tags at file read time. WARNING: Potentially very dangerous to run others' slides with this switch!")
|
||||||
|
parser.add_argument("--exit",action="store_true",dest="exit_last",default=False,
|
||||||
|
help="Exit after last slide.")
|
||||||
|
parser.add_argument("--export",action="store",dest="screenshots",default=False,
|
||||||
|
type=str, help="Take screenshots of the slideshow in the given folder.")
|
||||||
parser.add_argument("-m",action="store_true",dest="autocolor",default=False,
|
parser.add_argument("-m",action="store_true",dest="autocolor",default=False,
|
||||||
help="Color by markdown structure.")
|
help="Color by markdown structure.")
|
||||||
parser.add_argument("--no-color","-n",action="store_false",dest="color",default=True,
|
parser.add_argument("--no-color","-n",action="store_false",dest="color",default=True,
|
||||||
@@ -240,6 +244,10 @@ Keyboard shortcuts:
|
|||||||
help="File to show")
|
help="File to show")
|
||||||
opts=parser.parse_args()
|
opts=parser.parse_args()
|
||||||
opts.slideShow=not not opts.slideTimer
|
opts.slideShow=not not opts.slideTimer
|
||||||
|
if opts.screenshots:
|
||||||
|
opts.slideShow=True
|
||||||
|
opts.slideTimer=1
|
||||||
|
opts.exit_last=True
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
def page_print(reader,opts,offset):
|
def page_print(reader,opts,offset):
|
||||||
@@ -279,6 +287,7 @@ def page_print(reader,opts,offset):
|
|||||||
break
|
break
|
||||||
r+=row_lines+1
|
r+=row_lines+1
|
||||||
sys.stdout.write("\n")
|
sys.stdout.write("\n")
|
||||||
|
sys.stdout.flush()
|
||||||
return
|
return
|
||||||
|
|
||||||
def menu_print(reader,opts):
|
def menu_print(reader,opts):
|
||||||
@@ -338,6 +347,9 @@ def browser(opts,filename):
|
|||||||
if opts.menu:
|
if opts.menu:
|
||||||
menu_print(reader,opts)
|
menu_print(reader,opts)
|
||||||
sys.stdout.write(bc.pos(opts.size[0], opts.size[1]))
|
sys.stdout.write(bc.pos(opts.size[0], opts.size[1]))
|
||||||
|
sys.stdout.flush()
|
||||||
|
if opts.screenshots:
|
||||||
|
take_screenshot(reader,opts)
|
||||||
while 1:
|
while 1:
|
||||||
if opts.slideTimer and opts.slideShow:
|
if opts.slideTimer and opts.slideShow:
|
||||||
signal.signal(signal.SIGALRM, timeouthandler)
|
signal.signal(signal.SIGALRM, timeouthandler)
|
||||||
@@ -345,6 +357,9 @@ def browser(opts,filename):
|
|||||||
inkey=getkeypress()
|
inkey=getkeypress()
|
||||||
signal.alarm(0)
|
signal.alarm(0)
|
||||||
if not inkey and opts.slideShow:
|
if not inkey and opts.slideShow:
|
||||||
|
if opts.exit_last:
|
||||||
|
if reader.page+1==reader.pages:
|
||||||
|
return
|
||||||
reader.inc_page_no(1,True)
|
reader.inc_page_no(1,True)
|
||||||
offset=(0,0)
|
offset=(0,0)
|
||||||
break
|
break
|
||||||
@@ -353,6 +368,9 @@ def browser(opts,filename):
|
|||||||
#print('Exited in: ')
|
#print('Exited in: ')
|
||||||
return
|
return
|
||||||
if inkey in [67,54,32]: # PGDN or space
|
if inkey in [67,54,32]: # PGDN or space
|
||||||
|
if opts.exit_last:
|
||||||
|
if reader.page+1==reader.pages:
|
||||||
|
return
|
||||||
reader.inc_page_no(1)
|
reader.inc_page_no(1)
|
||||||
offset=(0, 0)
|
offset=(0, 0)
|
||||||
if inkey in [68,53,127]:
|
if inkey in [68,53,127]:
|
||||||
@@ -385,6 +403,7 @@ def browser(opts,filename):
|
|||||||
launch(reader,opts,offset)
|
launch(reader,opts,offset)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@@ -472,6 +491,14 @@ def launch(reader,opts,offset):
|
|||||||
shell=True)
|
shell=True)
|
||||||
return
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def take_screenshot(reader,opts):
|
||||||
|
out_file=os.path.join(opts.screenshots,"slide%03d.png"%(reader.page+1))
|
||||||
|
if not os.path.exists(opts.screenshots):
|
||||||
|
os.mkdir(opts.screenshots)
|
||||||
|
subprocess.call("sleep 0.5; import -window $WINDOWID '%s'"%(out_file,),
|
||||||
|
stdout=subprocess.PIPE,stderr=subprocess.PIPE,
|
||||||
|
shell=True)
|
||||||
bc=ansi.code()
|
bc=ansi.code()
|
||||||
getch=getch()
|
getch=getch()
|
||||||
opts=setup_options()
|
opts=setup_options()
|
||||||
|
|||||||
Reference in New Issue
Block a user