Codebase list tpp / 718b1e6
Import upstream version 1.3.1+git20160320.a12c15c, md5 00451daa8af14f63303dc1c75bdf1ef6 Debian Janitor 4 years ago
5 changed file(s) with 68 addition(s) and 52 deletion(s). Raw diff Collapse all Expand all
00 Sven Guckes, Florian Cramer initial idea of tpp
11 Patricia Jung <trish@trish.de> for supporting tpp and making the vim syntax file
2 Gerfried Fuchs for making another vim syntax file
2 Rhonda D'Vine for making another vim syntax file
33 Christian Dietrich <stettberger@gmx.de> for emacs file
44 Thomas Winde Frank, Frank Hofmann for the German translation of README
00 " Vim syntax file
11 " Language: tpp - Text Presentation Program
2 " Maintainer: Gerfried Fuchs <alfie@ist.org>
2 " Maintainer: Rhonda D'Vine <rhonda@deb.at>
33 " Filenames: *.tpp
44 " Last Change: 24. February 2005
5 " URL: http://alfie.ist.org/projects/vim/syntax/tpp.vim
6 " License: BSD
5 " URL: http://rhonda.deb.at/projects/vim/syntax/tpp.vim
6 " License: WTFPLv2
77 "
88 " Comments are very welcome - but please make sure that you are commenting on
99 " the latest version of this file.
10 " SPAM is _NOT_ welcome - be ready to be reported!
1110
1211 " For version 5.x: Clear all syntax items
1312 " For version 6.x: Quit when a syntax file was already loaded
0 --author Andreas Krennmair
1 --title Testing Orientation
2 This is oriented left.
3 ---
4 --center This is centered.
5 ---
6 --right This is oriented right.
7 ---
8 --beginoutput
9 It works even here
10 --center as you can see
11 --right in these three lines.
12 --endoutput
151151
152152 * Sven Guckes, who had the initial idea and established contact with Nico Golde, the TPP co-author
153153
154 * Alfie, for writing a VIM syntax file
154 * Rhonda, for writing a VIM syntax file
155155
156156 * arved, for bringing TPP into FreeBSD
157157
4343 "blue" => 5,
4444 "cyan" => 6,
4545 "magenta" => 7,
46 "black" => 8,
46 "black" => 8,
4747 "default" =>-1}
4848 colors[color]
4949 end
9494 end # class FileParser
9595
9696
97 # Represents a page (aka `slide') in TPP. A page consists of a title and one or
97 # Represents a page (aka `slide') in TPP. A page consists of a title and one or
9898 # more lines.
9999 class Page
100100
144144
145145
146146
147 # Implements a generic visualizer from which all other visualizers need to be
148 # derived. If Ruby supported abstract methods, all the do_* methods would be
147 # Implements a generic visualizer from which all other visualizers need to be
148 # derived. If Ruby supported abstract methods, all the do_* methods would be
149149 # abstract.
150150 class TppVisualizer
151151
153153 # nothing
154154 end
155155
156 # Splits a line into several lines, where each of the result lines is at most
157 # _width_ characters long, caring about word boundaries, and returns an array
156 # Splits a line into several lines, where each of the result lines is at most
157 # _width_ characters long, caring about word boundaries, and returns an array
158158 # of strings.
159159 def split_lines(text,width)
160160 lines = []
189189 $stderr.puts "Error: TppVisualizer#do_footer has been called directly."
190190 Kernel.exit(1)
191191 end
192
192
193193 def do_header(header_text)
194194 $stderr.puts "Error: TppVisualizer#do_header has been called directly."
195195 Kernel.exit(1)
196196 end
197197
198
198
199199 def do_refresh
200200 $stderr.puts "Error: TppVisualizer#do_refresh has been called directly."
201201 Kernel.exit(1)
315315 $stderr.puts "Error: TppVisualizer#do_command_prompt has been called directly."
316316 Kernel.exit(1)
317317 end
318
318
319319 def do_beginslideright
320320 $stderr.puts "Error: TppVisualizer#do_beginslideright has been called directly."
321321 Kernel.exit(1)
376376 Kernel.exit(1)
377377 end
378378
379 # Receives a _line_, parses it if necessary, and dispatches it
379 # Receives a _line_, parses it if necessary, and dispatches it
380380 # to the correct method which then does the correct processing.
381381 # It returns whether the controller shall wait for input.
382382 def visualize(line,eop)
445445 do_huge(figlet_text)
446446 when /^--footer /
447447 @footer_txt = line.sub(/^--footer /,"")
448 do_footer(@footer_txt)
448 do_footer(@footer_txt)
449449 when /^--header /
450450 @header_txt = line.sub(/^--header /,"")
451 do_header(@header_txt)
451 do_header(@header_txt)
452452 when /^--title /
453453 title = line.sub(/^--title /,"")
454454 do_title(title)
546546 @withborder = true
547547 draw_border
548548 end
549
549
550550 def do_command_prompt()
551551 message = "Press any key to continue :)"
552552 cursor_pos = 0
567567 window.move(@termheight/4,1+prompt.length+cursor_pos) # move cursor to the end of code
568568 ch = window.getch
569569 case ch
570 when Ncurses::KEY_ENTER, ?\n, ?\r
570 when Ncurses::KEY_ENTER, "\n"[0].ord, "\r"[0].ord
571571 Ncurses.curs_set(0)
572572 Ncurses.noecho
573 window.move(@termheight/4 + 1,1) # move cursor to the next line
574 window.refresh
573575 rc = Kernel.system(string)
574576 if not rc then
575577 @screen.mvaddstr(@termheight/4+1,1,"Error: exec \"#{string}\" failed with error code #{$?}")
576578 @screen.mvaddstr(@termheight-2,@termwidth/2-message.length/2,message)
579 ch = Ncurses.getch()
580 @screen.refresh
577581 end
578582 if rc then
579583 @screen.mvaddstr(@termheight-2,@termwidth/2-message.length/2,message)
581585 @screen.refresh
582586 end
583587 return
584 when Ncurses::KEY_LEFT
588 when Ncurses::KEY_LEFT
585589 cursor_pos = [0, cursor_pos-1].max # jump one character to the left
586590 when Ncurses::KEY_RIGHT
587591 cursor_pos = [0, cursor_pos+1].max # jump one character to the right
588 when Ncurses::KEY_BACKSPACE
592 when Ncurses::KEY_BACKSPACE, "\b"[0].ord, 127
589593 string = string[0...([0, cursor_pos-1].max)] + string[cursor_pos..-1]
590594 cursor_pos = [0, cursor_pos-1].max
591 window.mvaddstr(@termheight/4, 1+prompt.length+string.length, " ")
592 when " "[0]..255
595 window.mvaddstr(@termheight/4, 1+prompt.length+string.length, " ")
596 when " "[0].ord..255
593597 if (cursor_pos < max_len)
594598 string[cursor_pos,0] = ch.chr
595599 cursor_pos += 1
613617 (@termwidth-2).times { @screen.addstr("-") }; @screen.addstr("'")
614618 1.upto(@termheight-3) do |y|
615619 @screen.move(y,0)
616 @screen.addstr("|")
620 @screen.addstr("|")
617621 end
618622 1.upto(@termheight-3) do |y|
619623 @screen.move(y,@termwidth-1)
620 @screen.addstr("|")
624 @screen.addstr("|")
621625 end
622626 end
623627
699703 end
700704
701705 def show_help_page
702 help_text = [ "tpp help",
706 help_text = [ "tpp help",
703707 "",
704708 "space bar ............................... display next entry within page",
705709 "space bar, cursor-down, cursor-right .... display next page",
774778 @screen.move(@termheight - 3, (@termwidth - footer_txt.length)/2)
775779 @screen.addstr(footer_txt)
776780 end
777
781
778782 def do_header(header_txt)
779783 @screen.move(@termheight - @termheight+1, (@termwidth - header_txt.length)/2)
780784 @screen.addstr(header_txt)
860864 def do_huge(figlet_text)
861865 output_width = @termwidth - @indent
862866 output_width -= 2 if @output or @shelloutput
863 op = IO.popen("figlet -f #{@figletfont} -w #{output_width} -k \"#{figlet_text}\"","r")
867 op = IO.popen(["figlet", "-f", @figletfont, "-w", output_width.to_s, "-k", figlet_text], "r")
864868 op.readlines.each do |line|
865869 print_line(line)
866870 end
917921 time_to_sleep = 1.to_f / 20
918922 Kernel.sleep(time_to_sleep)
919923 xcount -= 1
920 end
924 end
921925 when "right"
922926 (@termwidth - @indent).times do |pos|
923927 @screen.move(@cur_line,@termwidth - pos - 1)
990994 @screen.move(line,col*15 + 2)
991995 if current_page == i then
992996 @screen.printw("%2d %s <=",i+1,pages[i].title[0..80])
993 else
997 else
994998 @screen.printw("%2d %s",i+1,pages[i].title[0..80])
995999 end
9961000 line += 1
10911095
10921096 def do_footer(footer_text)
10931097 end
1094
1098
10951099 def do_header(header_text)
10961100 end
10971101
11651169
11661170 def do_revon
11671171 end
1168
1172
11691173 def do_command_prompt
11701174 end
11711175 def do_revoff
11821186
11831187 def do_endslide
11841188 end
1185
1189
11861190 def do_beginslideright
11871191 end
11881192
13481352
13491353 end
13501354
1351 # Implements an interactive controller which feeds the visualizer until it is
1355 # Implements an interactive controller which feeds the visualizer until it is
13521356 # told to stop, and then reads a key press and executes the appropiate action.
13531357 class InteractiveController < TppController
13541358
13951399 loop do
13961400 ch = @vis.get_key
13971401 case ch
1398 when 'q'[0], 'Q'[0] # 'Q'uit
1402 when ?q.ord, ?Q.ord # 'Q'uit
13991403 return
1400 when 'r'[0], 'R'[0] # 'R'edraw slide
1404 when ?r.ord, ?R.ord # 'R'edraw slide
14011405 changed_page = true # @todo: actually implement redraw
1402 when 'e'[0], 'E'[0]
1406 when ?e.ord, ?E.ord
14031407 @cur_page = @pages.size - 1
14041408 break
1405 when 's'[0], 'S'[0]
1409 when ?s.ord, ?S.ord
14061410 @cur_page = 0
14071411 break
1408 when 'j'[0], 'J'[0] # 'J'ump to slide
1412 when ?j.ord, ?J.ord # 'J'ump to slide
14091413 screen = @vis.store_screen
14101414 p = @vis.read_newpage(@pages,@cur_page)
14111415 if p >= 0 and p < @pages.size
14161420 @vis.restore_screen(screen)
14171421 end
14181422 break
1419 when 'l'[0], 'L'[0] # re'l'oad current file
1423 when ?l.ord, ?L.ord # re'l'oad current file
14201424 @reload_file = true
14211425 return
1422 when 'c'[0], 'C'[0] # command prompt
1426 when ?c.ord, ?C.ord # command prompt
14231427 screen = @vis.store_screen
14241428 @vis.do_command_prompt
14251429 @vis.clear
14261430 @vis.restore_screen(screen)
1427 when '?'[0], 'h'[0]
1431 when ??.ord, ?h.ord
14281432 screen = @vis.store_screen
14291433 @vis.show_help_page
14301434 ch = @vis.get_key
14311435 @vis.clear
14321436 @vis.restore_screen(screen)
1433 when :keyright, :keydown, ' '[0]
1437 when :keyright, :keydown, ' '.ord
14341438 if @cur_page + 1 < @pages.size and eop then
14351439 @cur_page += 1
14361440 @pages[@cur_page].reset_eop
14371441 @vis.new_page
14381442 end
14391443 break
1440 when 'b'[0], 'B'[0], :keyleft, :keyup
1444 when ?b.ord, ?B.ord, :keyleft, :keyup
14411445 if @cur_page > 0 then
14421446 @cur_page -= 1
14431447 @pages[@cur_page].reset_eop
14541458 end
14551459
14561460
1457 # Implements a visualizer which converts TPP source to a nicely formatted text
1461 # Implements a visualizer which converts TPP source to a nicely formatted text
14581462 # file which can e.g. be used as handout.
14591463 class TextVisualizer < TppVisualizer
14601464
14741478
14751479 def do_footer(footer_text)
14761480 end
1477
1481
14781482 def do_header(header_text)
14791483 end
14801484
15381542
15391543 def do_revon
15401544 end
1541
1545
15421546 def do_command_prompt
15431547 end
15441548 def do_revoff
15551559
15561560 def do_endslide
15571561 end
1558
1562
15591563 def do_beginslideright
15601564 end
15611565
15721576 def do_huge(text)
15731577 output_width = @width
15741578 output_width -= 2 if @output_env
1575 op = IO.popen("figlet -f #{@figletfont} -w @output_width -k \"#{text}\"","r")
1579 op = IO.popen(["figlet", "-f", @figletfont, "-w", output_width.to_s, "-k", text], "r")
15761580 op.readlines.each do |line|
15771581 print_line(line)
15781582 end
16491653
16501654 end
16511655
1652 # Implements a non-interactive controller to control non-interactive
1653 # visualizers (i.e. those that are used for converting TPP source code into
1656 # Implements a non-interactive controller to control non-interactive
1657 # visualizers (i.e. those that are used for converting TPP source code into
16541658 # another format)
16551659 class ConversionController < TppController
16561660