Codebase list tpp / debian/1.2-2
Imported Debian patch 1.2-2 Nico Golde authored 19 years ago Axel Beckert committed 10 years ago
23 changed file(s) with 2572 addition(s) and 790 deletion(s). Raw diff Collapse all Expand all
0 1.2:
1 - heavily refactored tpp code
2 - added line wrapping
3 - added possibility of a footer and a header
4 - added LinuxDoc SGML output mode
5 - added reload feature
6 - added support for transparent terminals
7
08 1.1.1:
19 - added version number command line option
10 - added support for transparent terminals
211
312 1.1:
413 - fixed two spelling mistakes (one reported by Michael Prokop)
0 tpp design decisions:
1
2 1. visualizer
3
4 The visualization of a slide is done by a visualizer. Visualization in the context of tpp
5 means outputting it to an output device, e.g. a terminal via ncurses, a LaTeX source file,
6 a Docbook source file, you name it. The generic TppVisualizer is the base for all visualizers.
7 Look at the source which methods you need to implement if you want to write your own
8 visualizer.
9
10 2. controller
11
12 the controller handles the correct output, utilizing the parser and a visualizer. The generic
13 TppVisualizer is the base for all visualizers. All controllers must implement a constructor,
14 and the two methods run and close.
99
1010 install :
1111 mkdir -p $(DOCPATH)
12 install -m644 CHANGES COPYING README THANKS $(DOCPATH)
12 install -m644 DESIGN CHANGES COPYING README THANKS $(DOCPATH)
1313 install -m644 doc/tpp.1 $(MANPATH)
1414 install tpp.rb $(INSPATH)$(BIN)
1515 mkdir -p $(DOCPATH)/contrib
4040 b, cursor-up, cursor-left .............. display previous page
4141 q, Q ................................... quit tpp
4242 j, J ................................... jump directly to page
43 l, L ................................... reload current file
4344 s, S ................................... jump to the start page
4445 e, E ................................... jump to the last page
4546 c, C ................................... start command line
47 ?, h ................................... show help screen
4648
4749 On the lower left side of your terminal you will notice the current slide
4850 number and the total number of slides. Left of that, a '*' will appear when
49 pressing space bar the next time would show the next slide. If no '*' appears,
51 the end of the current slide has been reached. If no '*' appears,
5052 pressing space bar the next time will show the next entry on the page
5153 (separated by '---'). You are also able to go to the next/previous page at
5254 this point.
55
56 When you press 'l' (lower-case L) or 'L', the file you have currently loaded
57 into tpp will be reloaded from disk. This is very useful when you write
58 presentations with tpp, and constantly need a preview.
5359
5460 Writing tpp presentations
5561 -------------------------
6268 the "--newpage". Before the first "--newpage" is encountered, all
6369 non-command text is used as the presentation's abstract. Here, the
6470 title, the author and the date can be set, too. You can also optionally
65 specify a name for a page, which append it to the "--newpage" command,
71 specify a name for a page: append it to the "--newpage" command,
6672 separated by a single blank. If no name is set, a name will be
6773 automatically generated.
6874
8288
8389 --fgcolor <color>: the foreground color is set to <color>.
8490
85 Valid colors are white, yellow, red, green, blue, cyan, magenta, black.
91 Valid colors are white, yellow, red, green, blue, cyan, magenta, black and default for transparency.
8692
8793 Within a page, so-called "page-local" commands can be used. The
8894 following page-local commands are available:
9197 in bold (if supported by the terminal).
9298
9399 --horline: draws a horizontal line in the current line
100
101 --header: adds text to the first line on the screen
102
103 --footer: adds text to the last line on the screen
94104
95105 --color <color>: draw the text with specified color until a new color is set
96106
0 Sven Guckes, Florian Cramer initial idea of tpp
01 Patricia Jung <trish@trish.de> for supporting tpp and making the vim syntax file
12 Gerfried Fuchs for making another vim syntax file
3 Christian Dietrich <stettberger@gmx.de> for emacs file
0 ;; tpp-mode.el - An Major mode for Emacs to editing TextPraesentionProgramm (tpp) - Files
1
2 ;; Filename: tpp-mode.el
3 ;; Author: Christian Dietrich <stettberger@gmx.de>
4 ;; Version: 0.1
5 ;; License: GNU General Public License
6
7 ;; Installation:
8 ;;
9 ;; 1) Optionally, byte-compile this file
10 ;; 2) Put this file in a directory Emacs can find
11 ;; 3) Tell Emacs when to load this file
12 ;; 4) Customize some variables for your system
13 ;;
14 ;; ad 1)
15 ;; Byte-compilation speeds up the load time for this mode
16 ;; and is therefore recommended. Just load this file into
17 ;; Emacs and select "Byte-compile This File" from the
18 ;; "Emacs-Lisp" main menu. This will create the compiled
19 ;; file with the extension "elc".
20 ;;
21 ;; ad 2)
22 ;; The directories that Emacs searches are given by the
23 ;; load-path variable, which you can query within Emacs with
24 ;; ESC-x describe-variable RET load-path Ret
25 ;; To add a directory (eg. ~/.emacs) to load-path, add
26 ;; the following code to your $HOME/.emacs file:
27 ;; (add-to-list 'load-path "~/elisp")
28 ;;
29 ;; ad 3)
30 ;; Add the following lines to your $HOME/.emacs file:
31 ;; (autoload 'tpp-mode "tpp-mode" "TPP mode." t)
32 ;; (add-to-list 'auto-mode-alist '("\\.tpp$" . tpp-mode))
33 ;; The first line tells Emacs to load tpp-mode.elc or
34 ;; tpp-mode.el when the command 'tpp-mode' is called.
35 ;; The second line tells emacs to invoke the command 'tpp-mode'
36 ;; when a file with a name ending on ".tpp" is opened.
37 ;;
38 ;; ad 4)
39 ;; Some variables might need adjustment to your local system
40 ;; environment. You can do it in your $HOME/.emacs file with
41 ;; commands like
42 ;; (setq tpp-command "xterm -e tpp")
43 ;; (setq tpp-helpcommand "cat /usr/local/share/doc/tpp/README | xless")
44 ;; You can also set these variables interactively from the
45 ;; entry "Options" in the "TPP" main menu that is created
46 ;; when tpp-mode is entered.
47 ;;
48 ;; History:
49 ;; 28.02.2005 Initial Release for Emacs
50 ;; Thanks to:
51 ;;
52 ;; Christoph Dalitz:
53 ;; He wrte the mgp-mode-cd.el, on which this script is based, Thanks
54
55
56 (defcustom tpp-mode-hook '()
57 "*Hook for customising `tpp-mode'."
58 :type 'hook
59 :group 'Tpp)
60
61 ;; custom variables
62 (defcustom tpp-command "xterm -e tpp"
63 "tpp command line.
64 Must be adjusted according to the compilation options,
65 eg."
66 :group 'Tpp)
67 (defcustom tpp-helpcommand "cat /usr/local/share/doc/tpp/README | xless"
68 "Command for display of TPP syntax documentation."
69 :group 'Tpp)
70
71 ;; shortcut key bindings
72 (defvar tpp-mode-map
73 (let ((map (make-sparse-keymap)))
74 (define-key map (kbd "C-c C-b") 'tpp-preview-file)
75 (define-key map (kbd "C-c C-c") 'tpp-comment-region)
76 (define-key map (kbd "C-c C-u") 'tpp-uncomment-region)
77 map)
78 "Mode map used for `tpp-mode'.")
79
80 ;; main menu entry
81 (easy-menu-define
82 tpp-mode-menu tpp-mode-map
83 "Menu for `tpp-mode'."
84 '("TPP"
85 ["Preview Buffer" tpp-preview-file ]
86 ["Comment Region" tpp-comment-region ]
87 ["Uncomment Region" tpp-uncomment-region ]
88 ["Syntax Help" (shell-command tpp-helpcommand) ]
89 ["Options" (customize-group "Tpp") ]
90 ))
91
92 ;; Syntax Higlighting
93 (defvar tpp-mode-font-lock-keywords nil
94 "Tpp keywords used by font-lock.")
95 (if tpp-mode-font-lock-keywords ()
96 (let ()
97 (setq tpp-mode-font-lock-keywords
98 (list
99 ;; comments
100 (cons "^--##.*" 'font-lock-comment-face)
101 ;;Abstract - Options
102 (cons "^--author.*" 'font-lock-keyword-face)
103 (cons "^--title.*" 'font-lock-keyword-face)
104 (cons "^--date.*" 'font-lock-keyword-face)
105 ;; Local - Option
106 (cons "^--heading.*" 'font-lock-constant-face)
107 (cons "^--center.*" 'font-lock-constant-face)
108 (cons "^--right.*" 'font-lock-constant-face)
109 (cons "^--sleep.*" 'font-lock-constant-face)
110 (cons "^--exec.*" 'font-lock-constant-face)
111 (cons "^--huge.*" 'font-lock-constant-face)
112 (cons "^--newpage.*" 'font-lock-constant-face)
113 (cons "^--huge.*" 'font-lock-constant-face)
114 ;; other format parameters
115 (cons "^--.*" 'font-lock-builtin-face)
116 ))
117 ))
118
119
120
121 ;; Functions
122 (defun tpp-preview-file ()
123 "Previews current file with tpp"
124 (interactive)
125 (save-buffer)
126 (shell-command
127 (format "%s %s" tpp-command (shell-quote-argument buffer-file-name))))
128
129 (defun tpp-comment-region (start end)
130 "Comments out the current region with '--## '."
131 (interactive "r")
132 (goto-char end) (beginning-of-line) (setq end (point))
133 (goto-char start) (beginning-of-line) (setq start (point))
134 (let ()
135 (save-excursion
136 (save-restriction
137 (narrow-to-region start end)
138 (while (not (eobp))
139 (insert "--## ")
140 (forward-line 1)))))
141 )
142
143 (defun tpp-uncomment-region (start end)
144 "Remove '--## ' comments from current region."
145 (interactive "r")
146 (goto-char end) (beginning-of-line) (setq end (point))
147 (goto-char start) (beginning-of-line) (setq start (point))
148 (let ((prefix-len '5))
149 (save-excursion
150 (save-restriction
151 (narrow-to-region start end)
152 (while (not (eobp))
153 (if (string= "--## "
154 (buffer-substring
155 (point) (+ (point) prefix-len)))
156 (delete-char prefix-len))
157 (forward-line 1)))))
158 )
159
160 ;; The Modi Function
161 (defun tpp-mode ()
162 "Major mode for editing tpp source.
163 Comments etc. are highlighted with font-lock. There are also a
164 number of commands that make editing and working with TPP files
165 more convenient. These commands are available from the main menu
166 `TPP' or via the following shortcuts:
167
168 \\[tpp-preview-file] - Run tpp on the current file.
169 \\[tpp-comment-region] - Comments out the current region.
170 \\[tpp-uncomment-region] - Uncomments the current region.
171 "
172 (interactive)
173 (kill-all-local-variables)
174 (setq major-mode 'tpp-mode)
175 (setq mode-name "tpp")
176 (use-local-map tpp-mode-map)
177 (make-local-variable 'font-lock-defaults)
178 (easy-menu-add tpp-mode-menu tpp-mode-map)
179 (if (string-match "XEmacs\\|Lucid" emacs-version)
180 (progn (make-face 'font-lock-builtin-face)
181 (copy-face 'font-lock-preprocessor-face 'font-lock-builtin-face)))
182
183 (setq font-lock-defaults '(tpp-mode-font-lock-keywords
184 t t ((?_ . "w") (?. . "w"))))
185 ;; let ispell skip '--'-directives
186 (make-local-variable 'ispell-skip-region-alists)
187 (add-to-list 'ispell-skip-region-alist (list "^--.*$"))
188 ;; Hook ablaufen lassen
189 (run-hooks 'tpp-mode-hook)
190 )
191 ;; End of tpp-mode.el
11 " Language: tpp - Text Presentation Program
22 " Maintainer: Gerfried Fuchs <alfie@ist.org>
33 " Filenames: *.tpp
4 " Last Change: 30 September 2004
4 " Last Change: 24. February 2005
55 " URL: http://alfie.ist.org/projects/vim/syntax/tpp.vim
66 " License: BSD
77 "
1717 finish
1818 endif
1919
20 if !exists("main_syntax")
21 let main_syntax = 'tpp'
22 endif
23
24
2025 "" list of the legal switches/options
21 syn match tppAbstractOptionKey contained "^--\%(author\|title\|date\) *" nextgroup=tppValue
22 syn match tppPageLocalOptionKey contained "^--\%(heading\|center\|right\|sleep\|huge\|exec\|newpage\) *" nextgroup=tppValue
26 syn match tppAbstractOptionKey contained "^--\%(author\|title\|date\|footer\) *" nextgroup=tppString
27 syn match tppPageLocalOptionKey contained "^--\%(heading\|center\|right\|huge\|sethugefont\|exec\) *" nextgroup=tppString
2328 syn match tppPageLocalSwitchKey contained "^--\%(horline\|-\|\%(begin\|end\)\%(\%(shell\)\?output\|slide\%(left\|right\|top\|bottom\)\)\|\%(bold\|rev\|ul\)\%(on\|off\)\|withborder\)"
29 syn match tppNewPageOptionKey contained "^--newpage *" nextgroup=tppString
2430 syn match tppColorOptionKey contained "^--\%(\%(bg\|fg\)\?color\) *"
2531 syn match tppTimeOptionKey contained "^--sleep *"
2632
27 syn match tppValue contained ".*"
28 syn match tppColor contained "\%(white\|yellow\|red\|green\|blue\|cyan\|magenta\|black\)"
33 syn match tppString contained ".*"
34 syn match tppColor contained "\%(white\|yellow\|red\|green\|blue\|cyan\|magenta\|black\|default\)"
2935 syn match tppTime contained "\d\+"
3036
3137 syn region tppPageLocalSwitch start="^--" end="$" contains=tppPageLocalSwitchKey oneline
32 syn region tppPageLocalOption start="^--\%(heading\|center\|right\|sleep\|huge\|exec\|newpage\)" end="$" contains=tppPageLocalOptionKey oneline
3338 syn region tppColorOption start="^--\%(\%(bg\|fg\)\?color\)" end="$" contains=tppColorOptionKey,tppColor oneline
3439 syn region tppTimeOption start="^--sleep" end="$" contains=tppTimeOptionKey,tppTime oneline
35 syn region tppAbstractOption start="^--\%(author\|title\|date\)" end="$" contains=tppAbstractOptionKey oneline
40 syn region tppNewPageOption start="^--newpage" end="$" contains=tppNewPageOptionKey oneline
41 syn region tppPageLocalOption start="^--\%(heading\|center\|right\|huge\|sethugefont\|exec\)" end="$" contains=tppPageLocalOptionKey oneline
42 syn region tppAbstractOption start="^--\%(author\|title\|date\|footer\)" end="$" contains=tppAbstractOptionKey oneline
43
44 if main_syntax != 'sh'
45 " shell command
46 if version < 600
47 syn include @tppShExec <sfile>:p:h/sh.vim
48 else
49 syn include @tppShExec syntax/sh.vim
50 endif
51 unlet b:current_syntax
52
53 syn region shExec matchgroup=tppPageLocalOptionKey start='^--exec *' keepend end='$' contains=@tppShExec
54
55 endif
56
57 syn match tppComment "^--##.*$"
3658
3759 " Define the default highlighting.
3860 " For version 5.7 and earlier: only when not done already
4567 command -nargs=+ HiLink hi def link <args>
4668 endif
4769
48 HiLink tppAbstractOptionKey Keyword
70 HiLink tppAbstractOptionKey Special
4971 HiLink tppPageLocalOptionKey Keyword
5072 HiLink tppPageLocalSwitchKey Keyword
5173 HiLink tppColorOptionKey Keyword
52 HiLink tppTimeOptionKey Keyword
53 HiLink tppValue String
74 HiLink tppTimeOptionKey Comment
75 HiLink tppNewPageOptionKey PreProc
76 HiLink tppString String
5477 HiLink tppColor String
55 HiLink tppTime String
78 HiLink tppTime Number
79 HiLink tppComment Comment
5680 HiLink tppAbstractOption Error
5781 HiLink tppPageLocalOption Error
5882 HiLink tppPageLocalSwitch Error
5983 HiLink tppColorOption Error
84 HiLink tppNewPageOption Error
6085 HiLink tppTimeOption Error
6186
6287 delcommand HiLink
0 tpp (1.1.1-2) unstable; urgency=low
0 tpp (1.2-2) unstable; urgency=low
11
2 * changed suggests field because of typo
3 * removed watch file
2 * fixed typo in Suggests field.
43
5 -- Nico Golde <nico@ngolde.de> Fri, 22 Oct 2004 03:12:27 +0200
4 -- Nico Golde <nico@ngolde.de> Sun, 6 Mar 2005 10:52:23 +0100
5
6 tpp (1.2-1) unstable; urgency=low
7
8 * new upstream release.
9 * changed arch, deleted watch file.
10
11 -- Nico Golde <nico@ngolde.de> Thu, 3 Mar 2005 17:05:14 +0100
612
713 tpp (1.1.1-1) unstable; urgency=low
814
55 Standards-Version: 3.6.1
66
77 Package: tpp
8 Architecture: any
8 Architecture: all
99 Depends: ruby (>=1.8.0-1), libncurses-ruby1.8
1010 Suggests: figlet, texpower
1111 Description: text presentation program
00 This package was debianized by Nico Golde <nico@ngolde.de> on
1 Sun, 15 Aug 2004 16:09:20 +0200
1 Thu, 3 Mar 2005 17:05:14 +0100
22
33 It was downloaded from http://www.ngolde.de/tpp
44
0 makefile
1 man
0 make
1 manual
0 #! /bin/sh /usr/share/dpatch/dpatch-run
1 ## make.dpatch by Nico Golde <nico@ngolde.de>
2 ##
3 ## All lines beginning with `## DP:' are a description of the patch.
4 ## DP: No description.
5
6 @DPATCH@
7 diff -urNad tpp-1.2/Makefile /tmp/dpep.wWKaal/tpp-1.2/Makefile
8 --- tpp-1.2/Makefile 2005-03-03 17:10:55.000000000 +0100
9 +++ /tmp/dpep.wWKaal/tpp-1.2/Makefile 2005-03-03 17:14:19.922440232 +0100
10 @@ -6,11 +6,11 @@
11 prefix=/usr/local
12 INSPATH= $(prefix)/bin/
13 DOCPATH = $(prefix)/share/doc/tpp
14 -MANPATH = $(prefix)/man/man1
15 +MANPATH = $(prefix)/share/man/man1
16
17 install :
18 mkdir -p $(DOCPATH)
19 - install -m644 DESIGN CHANGES COPYING README THANKS $(DOCPATH)
20 + install -m644 DESIGN README THANKS $(DOCPATH)
21 install -m644 doc/tpp.1 $(MANPATH)
22 install tpp.rb $(INSPATH)$(BIN)
23 mkdir -p $(DOCPATH)/contrib
+0
-24
debian/patches/makefile.dpatch less more
0 #! /bin/sh /usr/share/dpatch/dpatch-run
1 ## makefile.dpatch by Nico Golde <nico@ngolde.de>
2 ##
3 ## All lines beginning with `## DP:' are a description of the patch.
4 ## DP: No description.
5
6 @DPATCH@
7 diff -urNad tpp-1.1.1/Makefile /tmp/dpep.ViLC9s/tpp-1.1.1/Makefile
8 --- tpp-1.1.1/Makefile 2004-10-13 13:29:17.000000000 +0200
9 +++ /tmp/dpep.ViLC9s/tpp-1.1.1/Makefile 2004-10-13 13:30:08.000000000 +0200
10 @@ -6,11 +6,11 @@
11 prefix=/usr/local
12 INSPATH= $(prefix)/bin/
13 DOCPATH = $(prefix)/share/doc/tpp
14 -MANPATH = $(prefix)/man/man1
15 +MANPATH = $(prefix)/share/man/man1
16
17 install :
18 mkdir -p $(DOCPATH)
19 - install -m644 CHANGES COPYING README THANKS $(DOCPATH)
20 + install -m644 README THANKS $(DOCPATH)
21 install -m644 doc/tpp.1 $(MANPATH)
22 install tpp.rb $(INSPATH)$(BIN)
23 mkdir -p $(DOCPATH)/contrib
+0
-30
debian/patches/man.dpatch less more
0 #! /bin/sh /usr/share/dpatch/dpatch-run
1 ## man.dpatch by Nico Golde <nico@ngolde.de>
2 ##
3 ## All lines beginning with `## DP:' are a description of the patch.
4 ## DP: No description.
5
6 @DPATCH@
7 diff -urNad tpp-1.1.1/doc/tpp.1 /tmp/dpep.ePYKBH/tpp-1.1.1/doc/tpp.1
8 --- tpp-1.1.1/doc/tpp.1 2004-10-10 22:16:27.000000000 +0200
9 +++ /tmp/dpep.ePYKBH/tpp-1.1.1/doc/tpp.1 2004-10-13 13:23:23.000000000 +0200
10 @@ -1,4 +1,4 @@
11 -.TH TPP "1" "August 2004" "tpp 1.0" "User Commands"
12 +.TH TPP "1" "October 2004" "tpp 1.1.1" "User Commands"
13 .SH NAME
14 TPP - Text Presentation Program
15 .SH SYNOPSIS
16 @@ -53,11 +53,11 @@
17 commands. Special commands are contained in lines that begin with "--"
18 and the command name.
19
20 -See /usr/share/doc/tpp/README for complete list of command names.
21 +See /usr/share/doc/tpp/README.gz for complete list of command names.
22
23 .SH VIM SYNTAX FILE
24 In /usr/share/doc/tpp/contrib you'll find a syntax file for the vim editor.
25 -See /usr/share/doc/tpp/README for installation instructions.
26 +See /usr/share/doc/tpp/README.gz for installation instructions.
27
28 .SH AUTHOR CONTACT
29 Tpp was written by Nico Golde <nico@ngolde.de> and Andreas Krennmair <ak@synflood.at>
0 #! /bin/sh /usr/share/dpatch/dpatch-run
1 ## manual.dpatch by Nico Golde <nico@ngolde.de>
2 ##
3 ## All lines beginning with `## DP:' are a description of the patch.
4 ## DP: No description.
5
6 @DPATCH@
7 diff -urNad tpp-1.2/doc/tpp.1 /tmp/dpep.ltoYdm/tpp-1.2/doc/tpp.1
8 --- tpp-1.2/doc/tpp.1 2005-03-03 17:10:54.000000000 +0100
9 +++ /tmp/dpep.ltoYdm/tpp-1.2/doc/tpp.1 2005-03-03 17:15:07.379225704 +0100
10 @@ -53,11 +53,11 @@
11 commands. Special commands are contained in lines that begin with "--"
12 and the command name.
13
14 -See /usr/share/doc/tpp/README for complete list of command names.
15 +See /usr/share/doc/tpp/README.gz for complete list of command names.
16
17 .SH VIM SYNTAX FILE
18 In /usr/share/doc/tpp/contrib you'll find a syntax file for the vim editor.
19 -See /usr/share/doc/tpp/README for installation instructions.
20 +See /usr/share/doc/tpp/README.gz for installation instructions.
21
22 .SH AUTHOR CONTACT
23 Tpp was written by Nico Golde <nico@ngolde.de> and Andreas Krennmair <ak@synflood.at>
0 .TH TPP "1" "August 2004" "tpp 1.0" "User Commands"
0 .TH TPP "1" "October 2004" "tpp 1.1.1" "User Commands"
11 .SH NAME
22 TPP - Text Presentation Program
33 .SH SYNOPSIS
0 --author Nico Golde
1 --title Testing Orientation
2 --footer and this is the footer line
3 --header and this is the header line
4 This is oriented left.
5 ---
6 --center This is centered.
7 ---
8 --right This is oriented right.
9 ---
10 --beginoutput
11 It works even here
12 --center as you can see
13 --right in these three lines.
14 --endoutput
+0
-13
examples/center-et-al.tpp less more
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
0 --boldon
1 --center Debian GNU/Linux
2 --center Paketerstellung
3 --center am Beispiel von binclock
4
5 --author Nico Golde <nico@ngolde.de>
6 --boldoff
7
8
9
10 --center Berlinux
11 --center 22.+23. Okt 2004
12
13
14 --center http://www.ngolde.de
15 --fgcolor white
16 --bgcolor black
17 --boldoff
18
19
20 --newpage Inhalt
21 --boldon
22 --huge Inhalt
23 --ulon
24 --horline
25 --boldoff
26 --uloff
27 --boldon
28
29
30
31
32 - Gründe für die Erstellung von Paketen
33
34 - Benötigte Software
35
36 - Vorbereitung
37
38 - Debian-Pakete
39
40 - Erstellung benötigter Dateien
41
42 - Konfiguration
43
44 - Build-Prozess
45
46 - Testen des Pakets
47
48 - Veröffentlichung:
49 Wie mache ich das Paket verfügbar?
50
51 - Weitere Informationen
52
53
54 --newpage warum
55 --boldon
56 --huge Warum?
57 --ulon
58 --horline
59 --boldoff
60 --uloff
61 --boldon
62
63
64
65
66 - Eingliederung von Software in das Debian-Paketsystem
67
68 - Ziel: Offizieller Maintainer
69
70 - "NEU!" Das Programm war bisher nicht als Debian-Paket verfügbar
71
72 - Erweiterung vorhandener Pakete, zB durch patches
73 oder zusätzliche Konfigurationsdateien
74
75 - Cluster/Pool: Leichte De- und Installation
76 von Programmen auf mehreren Rechnern
77
78 - Auflösen von Abhängigkeiten und Konflikten
79 dem Paketsystem überlassen können
80
81 - Eingliederung in das Menüsystem
82
83 --newpage software
84 --boldon
85 --huge Software
86 --ulon
87 --horline
88 --boldoff
89 --uloff
90 --boldon
91
92
93
94
95 - Compiler, Bibliotheken (Paket: build-essential)
96
97 - dpkg-dev (Hilfe beim Entpacken und Erstellen)
98
99 - debhelper
100
101 - lintian (Paket-Checker)
102
103 - patch, dpatch, automake, autoconf
104
105
106 --newpage Vorbereitung
107 --boldon
108 --huge Vorbereitung
109 --ulon
110 --horline
111 --boldoff
112 --uloff
113 --boldon
114
115
116
117 - Existieren schon Pakete?
118 -> packages.debian.org
119
120 - Kontakt zum Autor herstellen!
121 Interesse an einem Paket?
122
123 - Lizenzen überprüfen:
124 Ist das Programm auch frei?
125 aka "Klären der Fakten"
126 -> Debian Free Software Guidelines (DFSG)
127
128 - Abhängigkeiten zu anderen Programmen prüfen
129
130 - Kenntnis des Programms erforderlich!
131
132 - Format des Dateinamens:
133 paketname-version.tar.gz
134
135
136 --newpage paket
137 --boldon
138 --huge Pakete
139 --ulon
140 --horline
141 --boldoff
142 --uloff
143 --boldon
144
145
146 Inhalt:
147 --## --exec display paket.png
148
149 --beginoutput
150 Debian Paket:
151 (1) Quellpaket (Source Package)
152 - paket.orig.tar.gz ("source archive")
153 - paket.dsc ("description")
154 - paket.diff.gz ("differences")
155
156 (2) Binärpaket (.deb) (Binary Package)
157 --endoutput
158
159 - zu installierende Programme und Pfade
160
161 --newpage dateierstellung
162 --boldon
163 --huge Dateien - 1
164 --ulon
165 --horline
166 --boldoff
167 --uloff
168 --boldon
169
170
171
172 1. Entpacken der Quellen
173 ---
174 --beginshelloutput
175 $ tar xvfz binclock-1.5.tar.gz
176 binclock-1.5/
177 binclock-1.5/CHANGELOG
178 binclock-1.5/COPYING
179 binclock-1.5/doc/
180 binclock-1.5/doc/binclock.1
181 binclock-1.5/src/
182 binclock-1.5/src/binclock.c
183 binclock-1.5/Makefile
184 binclock-1.5/README
185 binclock-1.5/INSTALL
186 binclock-1.5/binclockrc
187 --endshelloutput
188
189 2. Umbgebungsvariablen
190 ---
191
192 --beginshelloutput
193 $ export DEBEMAIL="nico@ngolde.de"
194 --endshelloutput
195 --beginshelloutput
196 $ export DEBFULLNAME="Nico Golde"
197 --endshelloutput
198
199 --newpage dateien2
200 --boldon
201 --huge Dateien - 2
202 --ulon
203 --horline
204 --boldoff
205 --uloff
206 --boldon
207
208
209
210 ---
211 --beginshelloutput
212 $ dh_make
213 Type of package: single binary, multiple \
214 binary, library, or kernel module? [s/m/l/k]
215
216 ---
217 Maintainer name : Nico Golde
218 Email-Address : nico@ngolde.de
219 Date : Sat, 16 Oct 2004 01:00:14 +0200
220 Package Name : binclock
221 Version : 1.5
222 Type of Package : Single
223 Hit <enter> to confirm:
224 ---
225 Done. Please edit the files in the debian/ subdirectory now.
226 You should also check that the binclock Makefiles
227 install into $DESTDIR and not in / .
228 --endshelloutput
229
230
231 --beginslideleft
232 --color red
233 ==> debian-Dateien (im Ordner debian/)
234 --endslideleft
235 --color white
236
237 --newpage Config-1
238 --boldon
239 --huge Config - 1
240 --ulon
241 --horline
242 --boldoff
243 --uloff
244 --boldon
245
246
247
248
249 --ulon
250 Die wichtigen Dateien:
251 --uloff
252
253 changelog:
254 (später /usr/share/doc/binclock/changelog.Debian.gz)
255 ---
256
257 --beginoutput
258 binclock (1.5-1) unstable; urgency=low
259 * Initial Release.
260 Nico Golde <nico@ngolde.de> Fri, 15 Oct 2004 18:45:13 +0200
261 --endoutput
262
263 - Paketname, Version, Distribution, Priorität
264
265 - Änderungen am Paket, _nicht_ am Quellcode
266
267 - Name des Maintainers, Emailaddresse, Datum
268 --## "date -R" erstmal nicht so wichtig
269
270 - neuer changelog-Eintrag mit "dch -i"
271
272 --newpage Config-2a
273 --boldon
274 --huge Config - 2a
275 --ulon
276 --horline
277 --boldoff
278 --uloff
279 --boldon
280
281
282
283
284 Datei "control" (vor dem Editieren):
285 ---
286
287 --beginoutput
288 Source: binclock
289 Section: unknown
290 Priority: optional
291 Maintainer: Nico Golde <nico@ngolde.de>
292 Build-Depends: debhelper (>= 4.1.0)
293 Standards-Version: 3.6.1
294
295 Package: binclock
296 Architecture: any
297 Depends: ${shlibs:Depends}, ${misc:Depends}
298 Description: <insert up to 60 chars description>
299 <insert long description, indented with spaces>
300 --endoutput
301
302 --newpage Config-2b
303 --boldon
304 --huge Config - 2b
305 --ulon
306 --horline
307 --boldoff
308 --uloff
309 --boldon
310
311
312
313
314 Datei "control" (nach dem Editieren):
315
316 ---
317 --beginoutput
318 Source: binclock
319 --color green
320 Section: utils
321 --color white
322 Priority: optional
323 Maintainer: Nico Golde <nico@ngolde.de>
324 --color green
325 Build-Depends: debhelper (>= 4.1.0)
326 --color white
327 Standards-Version: 3.6.1
328
329 Package: binclock
330 --color green
331 Architecture: any
332 --color white
333 Depends: ${shlibs:Depends}, ${misc:Depends}
334 --color green
335 Description: binary clock for console with color support * (60 Zeichen)
336 BinClock - Displays system time in binary format.
337 It supports showing the time with eight different colors, and it can
338 run a loop that prints the time every second.
339 The default colors and characters for printing can be changed with a
340 config file.
341 --color white
342
343 --endoutput
344 - Kontrollinformationen, Name des Quellpakets, Subsection, Maintainer,
345 Abhängigkeiten zum Bauen, Policy-Version
346
347 - Paketname, Architektur
348
349 - Abhängigkeiten (mögliche weitere Felder: Suggests, Conflicts, Replaces, ...)
350
351 - kurze und lange Beschreibung, kurze Beschreibung darf nicht mit
352 Programmnamen anfangen
353
354 --newpage Config-3a
355 --boldon
356 --huge Config - 3a
357 --ulon
358 --horline
359 --boldoff
360 --uloff
361 --boldon
362
363
364
365
366 copyright (vor dem Editieren):
367
368 --beginoutput
369 This package was debianized by Nico Golde <nico@ngolde.de> on
370 Tue, 19 Feb 2004 16:43:41 +0200.
371
372 It was downloaded from <fill in ftp site>
373
374 Copyright:
375
376 Upstream Author(s): <put author(s) name and email here>
377
378 License:
379
380 <Must follow here>
381 --endoutput
382
383 --newpage Config-3a
384 --boldon
385 --huge Config - 3b
386 --ulon
387 --horline
388 --boldoff
389 --uloff
390 --boldon
391
392
393
394 --beginoutput
395
396 This package was debianized by Nico Golde <nico@ngolde.de> on
397 Wed, 19 Feb 2004 16:43:41 +0100.
398 It was downloaded from http://www.ngolde.de/binclock/
399
400 Upstream Author: Nico Golde <binclock@ngolde.de>
401
402
403 This software is copyrighted (c) 2003-2004 by Nico Golde.
404
405 You are free to distribute this software under
406 the terms of the GNU General Public License.
407 On Debian systems, the complete text of the
408 GNU General Public License can be found
409 in the file `/usr/share/common-licenses/GPL'.
410 --endoutput
411
412 - Download Ort
413
414 - Autor des Programmes
415
416 - Copyright (sollte DFSG kompatibel sein)
417
418 --newpage Config-4
419 --boldon
420 --huge Config - 4
421 --ulon
422 --horline
423 --boldoff
424 --uloff
425 --boldon
426
427
428
429
430 dirs:
431
432 - Verzeichnisse, die nicht vom Makefile angelegt werden
433
434 - ohne / am Anfang, Bsp.: usr/man
435
436 conffiles.ex:
437
438 - Konfigurationsdateienm, für manuelle Auswahl, in dem Fall /etc/binclockrc
439
440 - WICHTIG: datei.ex immer in datei umbenennen, wenn sie verwendet wird
441
442
443 docs:
444
445 - zu installierende Dokumentationsdatein, in dem Fall nur README
446
447
448 README.Debian:
449
450 - nennenswerte Unterschied zum Original
451
452
453 --newpage Configis
454 --boldon
455 --huge Config - 5
456 --ulon
457 --horline
458 --boldoff
459 --uloff
460 --boldon
461
462
463
464
465 menu.ex:
466
467 - Fenstermanager-Menu
468
469 vor dem Editieren:
470
471 --beginoutput
472 ?package(binclock):needs="X11|text|vc|wm" section="Apps/see-menu-manual"\
473 title="binclock" command="/usr/bin/binclock"
474 --endoutput
475
476 --beginoutput
477 ?package(binclock): needs="text|X11" section="Apps/Tools" \
478 title="BinClock" command="/usr/bin/binclock"
479 --endoutput
480
481 - Bestimmung von Oberfläche, Abteilung, Titel und das auszuführende Kommando
482
483 --newpage Config-5
484 --boldon
485 --huge Config - 6
486 --ulon
487 --horline
488 --boldoff
489 --uloff
490 --boldon
491
492
493
494 rules:
495 ---
496 --## this doesn't works here, because there is no rules file
497 --##--exec vim rules
498 --exec echo "eigentlich wäre hier die rules datei, sie ist in diesem beispiel leider nicht enthalten" | vim -
499
500 --newpage Config-6
501 --boldon
502 --huge Config - 7
503 --ulon
504 --horline
505 --boldoff
506 --uloff
507 --boldon
508
509
510
511 Anpassung des Makefiles:
512
513 vor dem Editieren:
514
515 --beginoutput
516 INSPATH = /usr/local/bin/
517 MANPATH = /usr/man/man1/
518 CONF = /etc/
519 all : $(MAINSRC)
520 gcc -02 --pedantic -Wall -o binclock ./src/binclock.c
521 strip binclock
522 install :
523 cp -pf CHANGELOG README COPYING
524 cp -pf ./doc/binclock.1 $(MANPATH)
525 cp -pf binclockrc $(CONF)binclockrc
526 install -c -s -m 0755 binclock $(INSPATH)
527 clean :
528 rm -f binclock
529 uninstall :
530 rm -f $(INSPATH)binclock
531 rm -f $(CONF)$(BIN)rc
532 rm -f $(MANPATH)/binclock.1
533 --endoutput
534 --newpage Config-a
535 --boldon
536 --huge Config - 8
537 --ulon
538 --horline
539 --boldoff
540 --uloff
541 --boldon
542
543
544
545
546 Nach dem Editieren:
547
548 --beginoutput
549 --color green
550 INSPATH = $(DESTDIR)/usr/bin/
551 MANPATH = $(DESTDIR)/usr/share/man/man1/
552 CONF = $(DESTDIR)/etc/
553 all : $(MAINSRC)
554 --color white
555 gcc --pedantic -Wall -o binclock ./src/binclock.c
556 strip binclock
557 install :
558 cp -pf ./doc/binclock.1 $(MANPATH)
559 cp -pf binclockrc $(CONF)binclockrc
560 install -c -s -m 0755 $(BIN) $(INSPATH)
561 clean :
562 rm -f $(SOURCEPATH)$(BIN)
563 --endoutput
564
565 - Anpassung der Variablen mit $(DESTDIR)
566
567 - Entfernen von Regeln, die von debhelper übernommen werden
568
569 - bei Programmen mit configure Scripten normalerweise nicht nötig,
570 sondern in rules statt $(DESTDIR) prefix einsetzen
571
572
573 --newpage Config-7
574 --boldon
575 --huge Config-9
576 --ulon
577 --horline
578 --boldoff
579 --uloff
580 --boldon
581
582
583
584
585 Letzte Schritte:
586
587 .ex-Dateien:
588
589 - Spezialfälle, je nach Bedarf editieren und umbennen
590
591 - anschliessend übrige .ex Dateien löschen
592
593 - eventuell Manual schreiben (so wie in der Policy beschrieben)
594
595 - falls benötigt die Maintainer-Scripte editieren: postinst.ex, preinst.ex,
596 postrm.ex, prerm.ex
597 -> werden ausgeführt bei Installation, Löschen oder Aktualisierung eines Paketes
598
599 - umbenennen von binclock-1.5.tar.gz in binclock_1.5.orig.tar.gz
600
601 --newpage build
602 --boldon
603 --huge Build Prozess
604 --ulon
605 --horline
606 --boldoff
607 --uloff
608 --boldon
609
610
611
612
613 Schritt 1:
614
615 - Zurückkehren in das Stammverzeichnis des Programms, i.d. Fall binclock-1.5/
616
617 Schritt 2:
618
619 - Bauen des Paketes mittels dpkg-buildpackage -rfakeroot
620
621 ---
622 --color red
623 --beginslideleft
624 ==> Debian-Paket in binclock-1.5/../
625 --endslideleft
626 --color white
627 --newpage build2
628 --boldon
629 --huge Nach dem Build
630 --ulon
631 --horline
632 --boldoff
633 --uloff
634 --boldon
635
636
637
638
639 Neue Dateien in binclock-1.5/../ :
640
641 ---
642 --beginshelloutput
643 $ ls
644 --color blue
645 binclock-1.5
646 --color white
647 binclock_1.5-1.diff.gz
648 binclock_1.5-1.dsc
649 binclock_1.5-1_i386.changes
650 binclock_1.5-1_i386.deb
651 binclock_1.5.orig.tar.gz
652 --endshelloutput
653
654 - Alle Änderungen am Originalquelltext (.diff.gz)
655
656 - Paketname, Version, Maintainer, Architektur, Build-Depends,
657 Policy Version, Dateien mit md5 Summen (.dsc)
658
659 - Paketdatum, Version, Distribution, Maintainer,
660 _Veränderungen_, Paketbeschreibung,
661 Dateien mit md5 Summen (.changes)
662
663 - Alle zur installierenden Dateien mit Ordnern gezippt (.deb)
664
665 - Originalquellen (.orig.tar.gz)
666
667 --newpage test
668 --boldon
669 --huge Tests
670 --ulon
671 --horline
672 --boldoff
673 --uloff
674 --boldon
675
676 1. Testen auf Policy mit lintian (Paket-Checker):
677
678 ---
679 --beginshelloutput
680 $ lintian binclock_1.5-1_i386.changes
681 E: binclock: binary-without-manpage binclock
682 --endshelloutput
683
684 - Fehler und Warnungen beseitigen (lintian -i für weiter Eklärungen)
685
686 2. Testen des Paketinhalts:
687 ---
688
689 --beginshelloutput
690 $ dpkg -c binclock_1.5-1_i386.deb
691 drwxr-xr-x root/root 0 2004-10-17 16:38:42 ./
692 drwxr-xr-x root/root 0 2004-10-17 16:38:42 ./usr/
693 drwxr-xr-x root/root 0 2004-10-17 16:38:42 ./usr/bin/
694 -rwxr-xr-x root/root 7500 2004-10-17 16:38:42 ./usr/bin/binclock
695 drwxr-xr-x root/root 0 2004-10-17 16:38:41 ./usr/share/
696 drwxr-xr-x root/root 0 2004-10-17 16:38:41 ./usr/share/man/
697 drwxr-xr-x root/root 0 2004-10-17 16:38:43 ./usr/share/man/man1/
698 -rw-r--r-- root/root 882 2004-10-17 16:38:41 ./usr/share/man/man1/binclock.1.gz
699 drwxr-xr-x root/root 0 2004-10-17 16:38:41 ./usr/share/doc/
700 drwxr-xr-x root/root 0 2004-10-17 16:38:43 ./usr/share/doc/binclock/
701 -rw-r--r-- root/root 1698 2004-07-24 13:42:04 ./usr/share/doc/binclock/README
702 -rw-r--r-- root/root 484 2004-07-24 15:10:45 ./usr/share/doc/binclock/copyright
703 -rw-r--r-- root/root 319 2004-07-24 15:10:45 ./usr/share/doc/binclock/changelog.Debian.gz
704 drwxr-xr-x root/root 0 2004-10-17 16:38:42 ./usr/lib/
705 drwxr-xr-x root/root 0 2004-10-17 16:38:42 ./usr/lib/menu/
706 -rw-r--r-- root/root 99 2004-07-24 19:54:23 ./usr/lib/menu/binclock
707 drwxr-xr-x root/root 0 2004-10-17 16:38:41 ./etc/
708 --endshelloutput
709
710 - Installieren des Pakets mittels dpkg -i binclock-1.5-1_i386.deb (wahlweise in chroot)
711
712 --newpage Veröffentlichung
713 --boldon
714 --huge Veröffentlichung
715 --ulon
716 --horline
717 --boldoff
718 --uloff
719 --boldon
720
721
722
723
724 1. Kopieren des Quellpakets und Binärpakets in
725 gewünschten Ordner (z.B. auf einen http-Server)
726
727 ---
728 --beginshelloutput
729 $ ls
730 binclock_1.5-1.diff.gz binclock_1.5-1.dsc
731 binclock_1.5-1_i386.deb binclock_1.5.orig.tar.gz
732 --endshelloutput
733
734 2. Erstellen von Sources.gz (Namen, Version, Build-Depends)
735 und Packages.gz (Beschreibung, Name, Abhängigkeiten)
736
737 ---
738 --beginshelloutput
739 $ dpkg-scanpackages ./ /dev/null | gzip -9c > Packages.gz
740 ** Packages in archive but missing from override file: **
741 binclock
742
743 Wrote 1 entries to output Packages file.
744 --endshelloutput
745 ---
746
747 --beginshelloutput
748 $ dpkg-scansources ./ /dev/null | gzip -9c > ./Sources.gz
749 --endshelloutput
750
751 --beginshelloutput
752 $ echo thats all :)
753 --endshelloutput
754
755 --newpage Ende
756 --boldon
757 --huge Danke! Fragen?
758 --ulon
759 --horline
760 --boldoff
761 --uloff
762 --boldon
763
764
765
766 Feedback:
767
768 --center Nico Golde <nico@ngolde.de>
769 --center http://www.ngolde.de
770
771 --newpage Links
772 --boldon
773 --huge Links
774 --ulon
775 --horline
776 --boldoff
777 --uloff
778 --boldon
779
780
781
782
783 http://www.debian.org
784
785 http://www.debian.org/devel/
786
787 debian-reference, maint-guide, debian-policy
788
789 http://www.openoffice.de/linux/buch/debianpakete.html
790
791 http://mentors.debian.net/
792
793 debian-mentors@lists.debian.org
794
795 debian-devel@lists.debian.org
796
797 http://www.ngolde.de/papers.html
798
799 Vortragsunterlagen: http://www.ngolde.de/papers.html
800
801 Präsentationsprogramm: TPP <http://www.ngolde.de/tpp>
00 --author Andreas Krennmair
1 --title exec test
1 --title exec fbi /home/nion/privat/bilder/linux/bart.gif
22 --newpage
33 --heading heading
44
55 bla. bla. bla.
66 ---
7 --exec echo foobar
7 --exec echo "foobar - this is the exec output"
88 more bla.
0 --bgcolor white
1 --fgcolor black
2 --title TPP Feature Show
3 --author Andreas Krennmair
4 --date today
5 --newpage intro
6 --heading What is TPP?
7
8 * A text console application
9 ---
10
11 * "Powerpoint for Sven G^W^Wtext tool users"
12 ---
13
14 * Simple file format, only text editor required
15 ---
16
17 * First version: 4-hour hack in Ruby + ruby-ncurses
18 ---
19
20 * Extension until source code was f*cked up,
21 then complete rewrite w/ generic design
22 --newpage slide
23 --heading Basic TPP Features
24
25 Simple text that is in one line
26 ---
27
28 What TPP also does is that it also takes very long lines, but doesn't simply output them, but break those long lines into a series of shorter ones, which are then printed to screen. Like this one. :-)
29 ---
30
31 --center You can also center text (long lines will be wrapped, too)
32 ---
33
34 --right And everything on the right side
35 ---
36
37 --beginslideleft
38 * You can slide it in from the left
39 * or from the right:
40 --endslideleft
41
42 --beginslideright
43 * Like this line, for example
44 --endslideright
45 ---
46 --beginslidetop
47 O R L O O K A T T H I S ! ! !
48 --endslidetop
49 ---
50 --beginslidebottom
51 O R T H I S ! ! !
52 --endslidetop
53 --newpage attrib
54 --heading Attributes
55
56 This should be normal
57 ---
58 --ulon
59 This should be underlined
60 ---
61 --revon
62 This should be underlined and reverse
63 ---
64 --boldon
65 This should be underlined, reverse and bold
66 --center This should be underlined, reverse, bold and centered
67 ---
68 --uloff
69 This should be reverse and bold
70 ---
71 --revoff
72 This should be bold
73 ---
74 --boldoff
75 This should be normal again
76 --newpage keys
77 --heading Keys to Control TPP
78
79 --beginoutput
80 space bar ............................... display next entry within page
81 space bar, cursor-down, cursor-right .... display next page
82 b, cursor-up, cursor-left ............... display previous page
83 q, Q .................................... quit tpp
84 j, J .................................... jump directly to page
85 s, S .................................... jump to the first page
86 e, E .................................... jump to the last page
87 c, C .................................... start command line
88 ?, h .................................... help screen
89 --endoutput
90 --newpage source
91 --heading Source Code Example
92
93 --beginoutput
94 --##comment in the beginning
95 --author Nico Golde <nico@ngolde.de>
96 --title Test for TPP
97 --date today
98 --withborder
99 The next line in the source file is a comment and will not be displayed.
100 --##This is the abstract, which is pretty cool.
101 It consists of several lines.
102 --newpage
103 --withborder
104 This is the next page, which also consists of
105 several lines
106 blubber. bla.
107 --## comment somewhere else
108 --newpage
109 --withborder
110 asdf jklö asdf jklö asdf jklö asdf jklö
111 --endoutput
112 --newpage other
113 --heading Other Things
114
115 This is supposed to be shell output:
116 --beginshelloutput
117 $ ls ~/bin
118 c89 cat if.pl seq ssh-agent ssh-agent.sh
119 $ cd ~/bin
120 $ ls -l
121 total 36
122 -rwxr-xr-x 1 ak staff 27 Jul 11 2003 c89
123 -rwxr-xr-x 1 ak staff 14732 Aug 26 2002 cat
124 -rwxr-xr-x 1 ak staff 236 Apr 27 2003 if.pl
125 -rwxr-xr-x 1 ak staff 73 Feb 19 2004 seq
126 -rwxr-xr-x 1 ak staff 126 Dec 21 20:45 ssh-agent
127 -rwxr-xr-x 1 ak staff 94 Jul 24 15:01 ssh-agent.sh
128 $
129 --endshelloutput
130 --newpage figlet
131 --heading FIGlet support!
132
133 --huge This is FIGlet
134 ---
135 --sethugefont mini
136 --huge This is the mini font
137 --newpage future
138 --heading Future Goals
139
140 * Release refactored version
141
142 ---
143 * More features (i.e. effects that make PowerPoint look lousy)
144
145 ---
146 * Stable support for export formats
147 --newpage thx
148 --heading Thanks To...
149
150 * Nico Golde, the TPP co-author, who came up with lots of nice features, and brought TPP into Debian
151
152 * Sven Guckes, who had the initial idea and established contact with Nico Golde, the TPP co-author
153
154 * Alfie, for writing a VIM syntax file
155
156 * arved, for bringing TPP into FreeBSD
157
158 * Patricia "trish" Jung, for writing a very good article about TPP
159 - "Linux User" and
160 - "Linux Magasinet" (Norway)
0 --author Andreas Krennmair
1 --title Wrapping long lines
2 --date today %a %b %e %H:%M:%S %Z %Y
3 This is oriented left. This is also quite long, also there to test how the line wrapping works. You will see examples for centered wrapping and right aligned wrapping later.
4 ---
5 --center This is centered. And an extremely long line, so long that it is going to be wrapped at some point, wherever that is.
6 ---
7 --right This is oriented right. Probably this line is even longer than the other, but this doesn't matter because this test must be as real as only possible. And I will make it even longer than planned, just to test how reliable it is, and whether it really aligns to the right.
8 ---
9 --beginoutput
10 This is oriented left. This is also quite long, also there to test how the line wrapping works. You will see examples for centered wrapping and right aligned wrapping later.
11 ---
12 --center This is centered. And an extremely long line, so long that it is going to be wrapped at some point, wherever that is.
13 ---
14 --right This is oriented right. Probably this line is even longer than the other, but this doesn't matter because this test must be as real as only possible. And I will make it even longer than planned, just to test how reliable it is, and whether it really aligns to the right.
15 --endoutput
16 --newpage
17 --heading This is probably an overlong heading, but it's supposed to be the way it is, for testing purposes. One more sentence, and we have our test object.
18
19 This is normal text after the heading.
+1241
-697
tpp.rb less more
00 #!/usr/bin/env ruby
11
2 begin
2 begin
33 require "ncurses"
44 include Ncurses
5
65 rescue LoadError
76 $stderr.print <<EOF
87 There is no Ncurses-Ruby package installed which is needed by TPP.
109 EOF
1110 Kernel.exit(1)
1211 end
12
1313 class ColorMap
1414
1515 def ColorMap.get_color(color)
2020 "blue" => COLOR_BLUE,
2121 "cyan" => COLOR_CYAN,
2222 "magenta" => COLOR_MAGENTA,
23 "black" => COLOR_BLACK }
23 "black" => COLOR_BLACK,
24 "default" => -1 }
2425 colors[color]
2526 end
2627
3233 "blue" => 5,
3334 "cyan" => 6,
3435 "magenta" => 7,
35 "black" => 8 }
36 "black" => 8,
37 "default" =>-1}
3638 colors[color]
3739 end
3840
3941 end
4042
41 class Page
42
43 def initialize(name)
44 @lines = []
45 @name = name
46 end
47
48 def name
49 @name
50 end
51
52 def set_name(n)
53 @name = n
54 end
55
56 def lines=(l)
57 @lines = l
58 end
59
60 def add_line(l)
61 @lines << l
62 end
63
64 def set_lines(l)
65 @lines = l
66 end
67
68 def lines
69 @lines
70 end
71
72 def print
73 @lines.each do |l|
74 puts l
75 end
76 end
77
78 end
79
80
81
82 class LatexGenerator
83
84 def initialize(pages,title,author,date)
85 @pages = pages
86 @title = title
87 @author = author
88 @date = date
89
90 @cur_item = ""
91 @itemize_open = false
92 @output = false
93 end
94
95 def generate_output(fn)
96 @fh = File.new(fn,"w+") or begin
97 $stderr.puts "error: couldn't open #{fn} for writing!\n"
98 Kernel.exit(1)
99 end
100
101 print_frontpage
102 @pages.each_index do |i|
103 print_page(i)
104 end
105 print_footer
106 end
107
108 def print_frontpage
109 @fh.puts "\\documentclass[slifonts,a4,landscape]{powersem}
110
111 \\usepackage[display,slifonts]{texpower}
112
113 \\usepackage[T1]{fontenc}
114 \\usepackage{umlaut}
115 \\usepackage[german]{babel}
116 \\usepackage{pslatex}
117 \\usepackage{fixseminar}
118 \\title{#{@title}}
119 \\author{#{@author}}
120 \\date{#{@date}}
121
122 \\begin{document}
123
124 \\thispagestyle{plain}
125 \\maketitle
126 "
127
128 end
129
130 def print_footer
131 @fh.puts '\end{document}'
132 end
133
134 def print_line(l)
135 if not @output then # only do substitutions when not in verbatim mode
136 l.gsub!(/_/,'\_') # needs to be escaped
137 l.gsub!(/#/,'\#') # needs to be escaped, too
138 l.gsub!(/->/,'$\rightarrow$') # a real arrow looks better than '->'
139 l.gsub!(/"/,'\'\'') # replace " so that "A really prints ''A and not Ä
140 l.gsub!(/%/,'\%') # % are LaTeX comments and must be escaped
141 end
142 case l
143 when /^--heading /
144 heading = l.sub(/^--heading /,"")
145 @fh.puts "\\section*{#{heading}}"
146 when /^--center /
147 text = l.sub(/^--center /,"")
148 @fh.puts "\\begin{center}#{text}\\end{center}"
149 when /^--right /
150 text = l.sub(/^--right /,"")
151 @fh.puts "\\begin{right}#{text}\\end{right}"
152 when /^---/,/^--sleep/,/--beginslide/,/--endslide/,/^--color/
153 # do nothing
154 when /^--beginoutput/,/^--beginshelloutput/
155 @fh.puts '\begin{verbatim}'
156 @output = true
157 when /^--endoutput/,/--endshelloutput/
158 @fh.puts '\end{verbatim}'
159 @output = false
160 when /^--boldon/
161 @fh.puts '{\bf '
162 when /^--horline/
163 @fh.puts '\hline '
164 when /^--revon/,/^--ulon/
165 @fh.puts '{\it '
166 when /^--boldoff/,/^--revoff/,/^--uloff/
167 @fh.puts '}'
168 when /^--huge /
169 text = l.sub(/^--huge /,"")
170 @fh.puts "{\\huge #{text}}"
171 else
172 # TODO: add better itemize handling, including multi-line items and nested items
173 if l =~ /^ *\*/ then
174 if @itemize_open then
175 @fh.puts("\\item #{@cur_item}")
176 else
177 @fh.puts('\begin{itemize}')
178 @itemize_open = true
179 end
180 @cur_item = l.sub(/^ *\*/,"")
181 elsif l =~ /^ +/ then
182 if @itemize_open then
183 if @cur_item =~ /-$/ then # hack to keep with - separated words and phrases together
184 @cur_item += l.strip
185 else
186 @cur_item += " " + l.strip
187 end
188 else
189 @fh.puts("#{l}")
190 end
191 else
192 if @itemize_open then
193 @itemize_open = false
194 @fh.puts("\\item #{@cur_item}")
195 @fh.puts('\end{itemize}')
196 end
197 @fh.puts("#{l}")
198 end
199 end
200 end
201
202 def print_page(i)
203 if i == 0 then
204 @fh.puts '\begin{abstract}'
205 @pages[i].lines.each do |l|
206 print_line(l)
207 end
208 @fh.puts '\end{abstract}'
209 else
210 @pages[i].lines.each do |l|
211 print_line(l)
212 end
213 end
214 if @itemize_open then
215 @fh.puts("\\item #{@cur_item}")
216 @fh.puts('\end{itemize}')
217 @itemize_open = false
218 end
219 @fh.puts '\newpage'
220 end
221 end
222
223
43 # FileParser
44 # opens a tpp source file, and splits it into the different pages
45 # methods:
46 # * initialize(filename): constructor
47 # * get_pages: returns the parsed pages
22448 class FileParser
22549
22650 def initialize(filename)
22751 @filename = filename
228 @pages = [ nil ]
229 @bgcolor = "black"
230 @fgcolor = "white"
231 end
232
233 def do_work(output_latex)
234 f = File.open(@filename)
235
236 if not f then
237 $stderr.puts "Couldn't open #{@filename}."
52 @pages = []
53 end
54
55 def get_pages
56 begin
57 f = File.open(@filename)
58 rescue
59 $stderr.puts "Error: couldn't open file: #{$!}"
23860 Kernel.exit(1)
23961 end
24062
241 cur_page = nil
242
243 @title = ""
244 @author = ""
245 @date = ""
246 abstract = []
247
24863 number_pages = 0
64
65 cur_page = Page.new("slide " + (number_pages + 1).to_s)
24966
25067 f.each_line do |line|
25168 line.chomp!
25269 case line
253 #comment
254 when /--##/
255 when /^--title / # store title
256 @title = line.sub(/^--title /,"")
257 when /^--author / # store author
258 @author = line.sub(/^--author /,"")
259 when /^--date / # store date
260 @date = line.sub(/^--date /,"")
261 if @date == "today" then
262 @date = Time.now.strftime("%b %d %Y")
263 elsif @date =~ /^today / then
264 @date = Time.now.strftime(@date.sub(/^today /,""))
265 end
266 when /^--bgcolor /
267 tmp_bgcolor = line.sub(/^--bgcolor /,"")
268 @bgcolor = tmp_bgcolor.strip
269 when /^--fgcolor /
270 tmp_fgcolor = line.sub(/^--fgcolor /,"")
271 @fgcolor = tmp_fgcolor.strip
70 when /--##/ # ignore comments
27271 when /^--newpage/
273 if cur_page then
274 @pages << cur_page
275 end
72 @pages << cur_page
27673 number_pages += 1
27774 name = line.sub(/^--newpage/,"")
27875 if name == "" then
279 name = "slide " + (number_pages+1).to_s
76 name = "slide " + (number_pages+1).to_s
28077 else
28178 name.strip!
28279 end
28380 cur_page = Page.new(name)
28481 else
285 if number_pages == 0 then
286 abstract << line # lines before the first page are the abstract
287 else
288 cur_page.add_line(line)
289 end
290 end
291 end
292
293 if cur_page and cur_page.lines.size > 0 then
294 @pages << cur_page
295 end
296
297 front_page = Page.new("#{@title}")
298 if output_latex then
299 fp_lines = [] # "--title #{@title}",
300 #"--author #{@author}",
301 #"--date #{@date}"
302 #]
82 cur_page.add_line(line)
83 end # case
84 end # each
85 @pages << cur_page
86 end
87 end # class FileParser
88
89
90 # class Page
91 # represents a page in tpp. A page contains of one or more lines and a title.
92 # methods:
93 # * initialize(title): constructor
94 # * add_line(line): appends a line to the current page
95 # * next_line: returns the next line. If there are not more lines, it returns nil, and eop is set to true
96 # * eop?: returns whether we reached the end of the page
97 # * reset_eop: reesets the end of page flag and sets the current line to the first line.
98 # * lines: returns all lines as array
99 # * name: returns the title of the page
100 class Page
101
102 def initialize(title)
103 @lines = []
104 @title = title
105 @cur_line = 0
106 @eop = false
107 end
108
109 def add_line(line)
110 @lines << line if line
111 end
112
113 def next_line
114 line = @lines[@cur_line]
115 @cur_line += 1
116 if @cur_line >= @lines.size then
117 @eop = true
118 end
119 return line
120 end
121
122 def eop?
123 @eop
124 end
125
126 def reset_eop
127 @cur_line = 0
128 @eop = false
129 end
130
131 def lines
132 @lines
133 end
134
135 def name
136 @title
137 end
138 end
139
140
141
142 # class TppVisualizer
143 # generic class from which all visualizers need to be derived
144 # all the methods are only implemented because there are no pure virtual functions in ruby
145 class TppVisualizer
146
147 def initialize
148 # nothing
149 end
150
151 def do_footer(footer_text)
152 $stderr.puts "Error: TppVisualizer#do_footer has been called directly."
153 Kernel.exit(1)
154 end
155
156 def do_header(header_text)
157 $stderr.puts "Error: TppVisualizer#do_header has been called directly."
158 Kernel.exit(1)
159 end
160
161
162 def do_refresh
163 $stderr.puts "Error: TppVisualizer#do_refresh has been called directly."
164 Kernel.exit(1)
165 end
166
167 def new_page
168 $stderr.puts "Error: TppVisualizer#new_page has been called directly."
169 Kernel.exit(1)
170 end
171
172 def do_heading(text)
173 $stderr.puts "Error: TppVisualizer#do_heading has been called directly."
174 Kernel.exit(1)
175 end
176
177 def do_withborder
178 $stderr.puts "Error: TppVisualizer#do_withborder has been called directly."
179 Kernel.exit(1)
180 end
181
182 def do_horline
183 $stderr.puts "Error: TppVisualizer#do_horline has been called directly."
184 Kernel.exit(1)
185 end
186
187 def do_color(text)
188 $stderr.puts "Error: TppVisualizer#do_color has been called directly."
189 Kernel.exit(1)
190 end
191
192 def do_center(text)
193 $stderr.puts "Error: TppVisualizer#do_center has been called directly."
194 Kernel.exit(1)
195 end
196
197 def do_right(text)
198 $stderr.puts "Error: TppVisualizer#do_right has been called directly."
199 Kernel.exit(1)
200 end
201
202 def do_exec(cmdline)
203 $stderr.puts "Error: TppVisualizer#do_exec has been called directly."
204 Kernel.exit(1)
205 end
206
207 def do_wait
208 $stderr.puts "Error: TppVisualizer#do_wait has been called directly."
209 Kernel.exit(1)
210 end
211
212 def do_beginoutput
213 $stderr.puts "Error: TppVisualizer#do_beginoutput has been called directly."
214 Kernel.exit(1)
215 end
216
217 def do_beginshelloutput
218 $stderr.puts "Error: TppVisualizer#do_beginshelloutput has been called directly."
219 Kernel.exit(1)
220 end
221
222 def do_endoutput
223 $stderr.puts "Error: TppVisualizer#do_endoutput has been called directly."
224 Kernel.exit(1)
225 end
226
227 def do_endshelloutput
228 $stderr.puts "Error: TppVisualizer#do_endshelloutput has been called directly."
229 Kernel.exit(1)
230 end
231
232 def do_sleep(time2sleep)
233 $stderr.puts "Error: TppVisualizer#do_sleep has been called directly."
234 Kernel.exit(1)
235 end
236
237 def do_boldon
238 $stderr.puts "Error: TppVisualizer#do_boldon has been called directly."
239 Kernel.exit(1)
240 end
241
242 def do_boldoff
243 $stderr.puts "Error: TppVisualizer#do_boldoff has been called directly."
244 Kernel.exit(1)
245 end
246
247 def do_revon
248 $stderr.puts "Error: TppVisualizer#do_revon has been called directly."
249 Kernel.exit(1)
250 end
251
252 def do_revoff
253 $stderr.puts "Error: TppVisualizer#do_revoff has been called directly."
254 Kernel.exit(1)
255 end
256
257 def do_ulon
258 $stderr.puts "Error: TppVisualizer#do_ulon has been called directly."
259 Kernel.exit(1)
260 end
261
262 def do_uloff
263 $stderr.puts "Error: TppVisualizer#do_uloff has been called directly."
264 Kernel.exit(1)
265 end
266
267 def do_beginslideleft
268 $stderr.puts "Error: TppVisualizer#do_beginslideleft has been called directly."
269 Kernel.exit(1)
270 end
271
272 def do_endslide
273 $stderr.puts "Error: TppVisualizer#do_endslide has been called directly."
274 Kernel.exit(1)
275 end
276
277 def do_command_prompt
278 $stderr.puts "Error: TppVisualizer#do_command_prompt has been called directly."
279 Kernel.exit(1)
280 end
281
282 def do_beginslideright
283 $stderr.puts "Error: TppVisualizer#do_beginslideright has been called directly."
284 Kernel.exit(1)
285 end
286
287 def do_beginslidetop
288 $stderr.puts "Error: TppVisualizer#do_beginslidetop has been called directly."
289 Kernel.exit(1)
290 end
291
292 def do_beginslidebottom
293 $stderr.puts "Error: TppVisualizer#do_beginslidebottom has been called directly."
294 Kernel.exit(1)
295 end
296
297 def do_sethugefont
298 $stderr.puts "Error: TppVisualizer#do_sethugefont has been called directly."
299 Kernel.exit(1)
300 end
301
302 def do_huge(text)
303 $stderr.puts "Error: TppVisualizer#do_huge has been called directly."
304 Kernel.exit(1)
305 end
306
307 def print_line(line)
308 $stderr.puts "Error: TppVisualizer#print_line has been called directly."
309 Kernel.exit(1)
310 end
311
312 def do_title(title)
313 $stderr.puts "Error: TppVisualizer#do_title has been called directly."
314 Kernel.exit(1)
315 end
316
317 def do_author(author)
318 $stderr.puts "Error: TppVisualizer#do_author has been called directly."
319 Kernel.exit(1)
320 end
321
322 def do_date(date)
323 $stderr.puts "Error: TppVisualizer#do_date has been called directly."
324 Kernel.exit(1)
325 end
326
327 def do_bgcolor(color)
328 $stderr.puts "Error: TppVisualizer#do_bgcolor has been called directly."
329 Kernel.exit(1)
330 end
331
332 def do_fgcolor(color)
333 $stderr.puts "Error: TppVisualizer#do_fgcolor has been called directly."
334 Kernel.exit(1)
335 end
336
337 def do_color(color)
338 $stderr.puts "Error: TppVisualizer#do_color has been called directly."
339 Kernel.exit(1)
340 end
341
342 # visualize receives a line, parses it if necessary, and dispatches it
343 # to the correct method when then does the correct processing
344 # returns whether the controller shall wait for input
345 def visualize(line,eop)
346 case line
347 when /^--heading /
348 text = line.sub(/^--heading /,"")
349 do_heading(text)
350 when /^--withborder/
351 do_withborder
352 when /^--horline/
353 do_horline
354 when /^--color /
355 text = line.sub(/^--color /,"")
356 text.strip!
357 do_color(text)
358 when /^--center /
359 text = line.sub(/^--center /,"")
360 do_center(text)
361 when /^--right /
362 text = line.sub(/^--right /,"")
363 do_right(text)
364 when /^--exec /
365 cmdline = line.sub(/^--exec /,"")
366 do_exec(cmdline)
367 when /^---/
368 do_wait
369 return true
370 when /^--beginoutput/
371 do_beginoutput
372 when /^--beginshelloutput/
373 do_beginshelloutput
374 when /^--endoutput/
375 do_endoutput
376 when /^--endshelloutput/
377 do_endshelloutput
378 when /^--sleep /
379 time2sleep = line.sub(/^--sleep /,"")
380 do_sleep(time2sleep)
381 when /^--boldon/
382 do_boldon
383 when /^--boldoff/
384 do_boldoff
385 when /^--revon/
386 do_revon
387 when /^--revoff/
388 do_revoff
389 when /^--ulon/
390 do_ulon
391 when /^--uloff/
392 do_uloff
393 when /^--beginslideleft/
394 do_beginslideleft
395 when /^--endslideleft/, /^--endslideright/, /^--endslidetop/, /^--endslidebottom/
396 do_endslide
397 when /^--beginslideright/
398 do_beginslideright
399 when /^--beginslidetop/
400 do_beginslidetop
401 when /^--beginslidebottom/
402 do_beginslidebottom
403 when /^--sethugefont /
404 params = line.sub(/^--sethugefont /,"")
405 do_sethugefont(params.strip)
406 when /^--huge /
407 figlet_text = line.sub(/^--huge /,"")
408 do_huge(figlet_text)
409 when /^--footer /
410 @footer_txt = line.sub(/^--footer /,"")
411 do_footer(@footer_txt)
412 when /^--header /
413 @header_txt = line.sub(/^--header /,"")
414 do_header(@header_txt)
415 when /^--title /
416 title = line.sub(/^--title /,"")
417 do_title(title)
418 when /^--author /
419 author = line.sub(/^--author /,"")
420 do_author(author)
421 when /^--date /
422 date = line.sub(/^--date /,"")
423 if date == "today" then
424 date = Time.now.strftime("%b %d %Y")
425 elsif date =~ /^today / then
426 date = Time.now.strftime(date.sub(/^today /,""))
427 end
428 do_date(date)
429 when /^--bgcolor /
430 color = line.sub(/^--bgcolor /,"").strip
431 do_bgcolor(color)
432 when /^--fgcolor /
433 color = line.sub(/^--fgcolor /,"").strip
434 do_fgcolor(color)
435 when /^--color /
436 color = line.sub(/^--color /,"").strip
437 do_color(color)
303438 else
304 fp_lines = ["--color #{@fgcolor}",
305 "--heading #{@title}",
306 "",
307 "--center #{@author}",
308 "--center #{@date}",
309 "" ]
310 end
311 abstract.each { |al| fp_lines << al }
312 front_page.set_lines(fp_lines)
313 @pages[0] = front_page
314 end
315
316 def get_title
317 @title
318 end
319
320 def get_author
321 @author
322 end
323
324 def get_date
325 @date
326 end
327
328 def get_bgcolor
329 if @bgcolor then
330 @bgcolor
331 else
332 "black"
333 end
334 end
335
336 def get_pages
337 @pages
439 print_line(line)
440 end
441
442 return false
443 end
444
445 def close
446 # nothing
338447 end
339448
340449 end
341450
342
343 class Pager
344
345 def initialize(pages,bgcolor)
346 @pages = pages
347 @figletfont ="standard"
451 # class NcursesVisualizer
452 # a TppVisualizer for ncurses output
453 # methods:
454 # * initialize: initializes ncurses and sets several default values
455 # * split_lines: split a line on word boundaries, takes a maximum line length,
456 # returns an array of strings guaranteed shorter to be shorter
457 # or as long as the maximum length
458 class NcursesVisualizer < TppVisualizer
459
460 def initialize
461 @figletfont = "standard"
348462 Ncurses.initscr
349463 Ncurses.curs_set(0)
350464 Ncurses.cbreak # unbuffered input
351465 Ncurses.noecho # turn off input echoing
352466 Ncurses.stdscr.intrflush(false)
353467 Ncurses.stdscr.keypad(true)
468 @screen = Ncurses.stdscr
469 setsizes
354470 Ncurses.start_color()
355 @bgcolor = ColorMap.get_color(bgcolor) or COLOR_BLACK
356 Ncurses.init_pair(1, COLOR_WHITE, @bgcolor)
357 Ncurses.init_pair(2, COLOR_YELLOW, @bgcolor)
358 Ncurses.init_pair(3, COLOR_RED, @bgcolor)
359 Ncurses.init_pair(4, COLOR_GREEN, @bgcolor)
360 Ncurses.init_pair(5, COLOR_BLUE, @bgcolor)
361 Ncurses.init_pair(6, COLOR_CYAN, @bgcolor)
362 Ncurses.init_pair(7, COLOR_MAGENTA, @bgcolor)
363 Ncurses.init_pair(8, COLOR_BLACK, @bgcolor)
364 Ncurses.bkgd(Ncurses.COLOR_PAIR(1));
365 @current_page = 0
366 @current_color_pair = 1
367 @number_pages = @pages.size
368 @indent = 5
369 @voffset = 3
370 @screen = Ncurses.stdscr
371 set_sizes
372 end
373
374 def close
375 Ncurses.nocbreak
376 Ncurses.endwin
377 end
378
379 def set_sizes(sig = nil)
471 Ncurses.use_default_colors()
472 do_bgcolor("black")
473 #do_fgcolor("white")
474 @fgcolor = ColorMap.get_color_pair("white")
475 @voffset = 5
476 @indent = 3
477 @cur_line = @voffset
478 @output = @shelloutput = false
479 end
480
481 def clear
482 @screen.clear
483 @screen.refresh
484 end
485
486 def split_lines(text,width)
487 lines = []
488 if text then
489 begin
490 i = width
491 if text.length <= i then # text length is OK -> add it to array and stop splitting
492 lines << text
493 text = ""
494 else
495 # search for word boundary (space actually)
496 while i > 0 and text[i] != ' '[0] do
497 i -= 1
498 end
499 # if we can't find any space character, simply cut it off at the maximum width
500 if i == 0 then
501 i = width
502 end
503 # extract line
504 x = text[0..i-1]
505 # remove extracted line
506 text = text[i+1..-1]
507 # added line to array
508 lines << x
509 end
510 end while text.length > 0
511 end
512 return lines
513 end
514
515 def setsizes
380516 @termwidth = Ncurses.getmaxx(@screen)
381517 @termheight = Ncurses.getmaxy(@screen)
382518 end
383519
384 def read_newpage()
385 page = []
386 @screen.clear()
387 col = 0
388 line = 2
389 @pages.each_index do |i|
390 @screen.move(line,col*15 + 2)
391 if @current_page == i then
392 @screen.printw("%2d %s <=",i+1,@pages[i].name[0..10])
393 else
394 @screen.printw("%2d %s",i+1,@pages[i].name[0..10])
395 end
396 line += 1
397 if line >= @termheight - 3 then
398 line = 2
399 col += 1
400 end
401 end
402 prompt = "jump to slide: "
403 prompt_indent = 12
404 @screen.move(@termheight - 2, @indent + prompt_indent)
405 @screen.addstr(prompt)
406 # @screen.refresh();
407 Ncurses.echo
408 @screen.scanw("%d",page)
409 Ncurses.noecho
410 @screen.move(@termheight - 2, @indent + prompt_indent)
411 (prompt.length + page[0].to_s.length).times { @screen.addstr(" ") }
412 if page[0] then
413 return page[0] - 1
414 end
415 return -1 # invalid page
520 def do_refresh
521 @screen.refresh
522 end
523
524 def do_withborder
525 @withborder = true
526 draw_border
416527 end
417528
418 def draw_slidenum
419 @screen.move(@termheight - 2, @indent)
420 #@screen.attroff(Ncurses.COLOR_PAIR(@current_color_pair))
421 @screen.attroff(Ncurses::A_BOLD) # this is bad
422 @screen.addstr("[slide #{@current_page+1}/#{@number_pages}]")
423 end
424
425 def draw_eop_marker
426 @screen.move(@termheight - 2, @indent - 1)
427 @screen.attron(A_BOLD)
428 @screen.addstr("*")
429 @screen.attroff(A_BOLD)
430 end
431
432 def draw_border
433 @screen.move(0,0)
434 @screen.addstr(".")
435 (@termwidth-2).times { @screen.addstr("-") }; @screen.addstr(".")
436 @screen.move(@termheight-2,0)
437 @screen.addstr("`")
438 (@termwidth-2).times { @screen.addstr("-") }; @screen.addstr("'")
439 1.upto(@termheight-3) do |y|
440 @screen.move(y,0)
441 @screen.addstr("|")
442 end
443 1.upto(@termheight-3) do |y|
444 @screen.move(y,@termwidth-1)
445 @screen.addstr("|")
446 end
447 end
448
449 def type_line(l)
450 l.each_byte do |x|
451 @screen.addstr(x.chr)
452 @screen.refresh()
453 r = rand(20)
454 time_to_sleep = (5 + r).to_f / 250;
455 # puts "#{time_to_sleep} #{r}"
456 Kernel.sleep(time_to_sleep)
457 end
458 end
459 def command_prompt()
529 def do_command_prompt()
460530 message = "Press any key to continue :)"
461531 cursor_pos = 0
462532 max_len = 50
474544 loop do
475545 window.mvaddstr(@termheight/4,1+prompt.length,string) # add the code
476546 window.move(@termheight/4,1+prompt.length+cursor_pos) # move cursor to the end of code
477
478547 ch = window.getch
479548 case ch
480 when Ncurses::KEY_LEFT
481 cursor_pos = [0, cursor_pos-1].max # jump one character to the left
482 when Ncurses::KEY_RIGHT
483 cursor_pos = [0, cursor_pos+1].max # jump one character to the right
484549 when Ncurses::KEY_ENTER, ?\n, ?\r
485550 Ncurses.curs_set(0)
486551 Ncurses.noecho
491556 end
492557 if rc then
493558 @screen.mvaddstr(@termheight-2,@termwidth/2-message.length/2,message)
559 ch = Ncurses.getch()
560 @screen.refresh
494561 end
495 ch = Ncurses.getch()
496562 return
563 when Ncurses::KEY_LEFT
564 cursor_pos = [0, cursor_pos-1].max # jump one character to the left
565 when Ncurses::KEY_RIGHT
566 cursor_pos = [0, cursor_pos+1].max # jump one character to the right
497567 when Ncurses::KEY_BACKSPACE
498568 string = string[0...([0, cursor_pos-1].max)] + string[cursor_pos..-1]
499569 cursor_pos = [0, cursor_pos-1].max
511581 end
512582 end
513583
584 def draw_border
585 @screen.move(0,0)
586 @screen.addstr(".")
587 (@termwidth-2).times { @screen.addstr("-") }; @screen.addstr(".")
588 @screen.move(@termheight-2,0)
589 @screen.addstr("`")
590 (@termwidth-2).times { @screen.addstr("-") }; @screen.addstr("'")
591 1.upto(@termheight-3) do |y|
592 @screen.move(y,0)
593 @screen.addstr("|")
594 end
595 1.upto(@termheight-3) do |y|
596 @screen.move(y,@termwidth-1)
597 @screen.addstr("|")
598 end
599 end
600
601 def new_page
602 @cur_line = @voffset
603 @output = @shelloutput = false
604 setsizes
605 @screen.clear
606 end
607
608 def do_heading(line)
609 @screen.attron(Ncurses::A_BOLD)
610 print_heading(line)
611 @screen.attroff(Ncurses::A_BOLD)
612 end
613
614 def do_horline
615 @screen.attron(Ncurses::A_BOLD)
616 @termwidth.times do |x|
617 @screen.move(@cur_line,x)
618 @screen.addstr("-")
619 end
620 @screen.attroff(Ncurses::A_BOLD)
621 end
622
623 def print_heading(text)
624 width = @termwidth - 2*@indent
625 lines = split_lines(text,width)
626 lines.each do |l|
627 @screen.move(@cur_line,@indent)
628 x = (@termwidth - l.length)/2
629 @screen.move(@cur_line,x)
630 @screen.addstr(l)
631 @cur_line += 1
632 end
633 end
634
635 def do_center(text)
636 width = @termwidth - 2*@indent
637 if @output or @shelloutput then
638 width -= 2
639 end
640 lines = split_lines(text,width)
641 lines.each do |l|
642 @screen.move(@cur_line,@indent)
643 if @output or @shelloutput then
644 @screen.addstr("| ")
645 end
646 x = (@termwidth - l.length)/2
647 @screen.move(@cur_line,x)
648 @screen.addstr(l)
649 @cur_line += 1
650 end
651 end
652
653 def do_right(text)
654 width = @termwidth - 2*@indent
655 if @output or @shelloutput then
656 width -= 2
657 end
658 lines = split_lines(text,width)
659 lines.each do |l|
660 @screen.move(@cur_line,@indent)
661 if @output or @shelloutput then
662 @screen.addstr("| ")
663 end
664 x = (@termwidth - l.length - 2)
665 @screen.move(@cur_line,x)
666 @screen.addstr(l)
667 @cur_line += 1
668 end
669 end
670
671 def show_help_page
672 help_text = [ "tpp help",
673 "",
674 "space bar ............................... display next entry within page",
675 "space bar, cursor-down, cursor-right .... display next page",
676 "b, cursor-up, cursor-left ............... display previous page",
677 "q, Q .................................... quit tpp",
678 "j, J .................................... jump directly to page",
679 "l, L .................................... reload current file",
680 "s, S .................................... jump to the first page",
681 "e, E .................................... jump to the last page",
682 "c, C .................................... start command line",
683 "?, h .................................... this help screen" ]
684 @screen.clear
685 y = @voffset
686 help_text.each do |line|
687 @screen.move(y,@indent)
688 @screen.addstr(line)
689 y += 1
690 end
691 @screen.move(@termheight - 2, @indent)
692 @screen.addstr("Press any key to return to slide")
693 @screen.refresh
694 end
695
696 def do_exec(cmdline)
697 rc = Kernel.system(cmdline)
698 if not rc then
699 # @todo: add error message
700 end
701 end
702
703 def do_wait
704 # nothing
705 end
706
707 def do_beginoutput
708 @screen.move(@cur_line,@indent)
709 @screen.addstr(".")
710 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
711 @output = true
712 @cur_line += 1
713 end
714
715 def do_beginshelloutput
716 @screen.move(@cur_line,@indent)
717 @screen.addstr(".")
718 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
719 @shelloutput = true
720 @cur_line += 1
721 end
722
723 def do_endoutput
724 if @output then
725 @screen.move(@cur_line,@indent)
726 @screen.addstr("`")
727 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
728 @output = false
729 @cur_line += 1
730 end
731 end
732
733 def do_title(title)
734 do_boldon
735 do_center(title)
736 do_boldoff
737 do_center("")
738 end
739
740 def do_footer(footer_txt)
741 @screen.move(@termheight - 3, (@termwidth - footer_txt.length)/2)
742 @screen.addstr(footer_txt)
743 end
744
745 def do_header(header_txt)
746 @screen.move(@termheight - @termheight+1, (@termwidth - header_txt.length)/2)
747 @screen.addstr(header_txt)
748 end
749
750 def do_author(author)
751 do_center(author)
752 do_center("")
753 end
754
755 def do_date(date)
756 do_center(date)
757 do_center("")
758 end
759
760 def do_endshelloutput
761 if @shelloutput then
762 @screen.move(@cur_line,@indent)
763 @screen.addstr("`")
764 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
765 @shelloutput = false
766 @cur_line += 1
767 end
768 end
769
770 def do_sleep(time2sleep)
771 Kernel.sleep(time2sleep.to_i)
772 end
773
774 def do_boldon
775 @screen.attron(Ncurses::A_BOLD)
776 end
777
778 def do_boldoff
779 @screen.attroff(Ncurses::A_BOLD)
780 end
781
782 def do_revon
783 @screen.attron(Ncurses::A_REVERSE)
784 end
785
786 def do_revoff
787 @screen.attroff(Ncurses::A_REVERSE)
788 end
789
790 def do_ulon
791 @screen.attron(Ncurses::A_UNDERLINE)
792 end
793
794 def do_uloff
795 @screen.attroff(Ncurses::A_UNDERLINE)
796 end
797
798 def do_beginslideleft
799 @slideoutput = true
800 @slidedir = "left"
801 end
802
803 def do_endslide
804 @slideoutput = false
805 end
806
807 def do_beginslideright
808 @slideoutput = true
809 @slidedir = "right"
810 end
811
812 def do_beginslidetop
813 @slideoutput = true
814 @slidedir = "top"
815 end
816
817 def do_beginslidebottom
818 @slideoutput = true
819 @slidedir = "bottom"
820 end
821
822 def do_sethugefont(params)
823 @figletfont = params
824 end
825
826 def do_huge(figlet_text)
827 output_width = @termwidth - @indent
828 output_width -= 2 if @output or @shelloutput
829 op = IO.popen("figlet -f #{@figletfont} -w #{output_width} -k \"#{figlet_text}\"","r")
830 op.readlines.each do |line|
831 print_line(line)
832 end
833 op.close
834 end
835
836 def do_bgcolor(color)
837 bgcolor = ColorMap.get_color(color) or COLOR_BLACK
838 Ncurses.init_pair(1, COLOR_WHITE, bgcolor)
839 Ncurses.init_pair(2, COLOR_YELLOW, bgcolor)
840 Ncurses.init_pair(3, COLOR_RED, bgcolor)
841 Ncurses.init_pair(4, COLOR_GREEN, bgcolor)
842 Ncurses.init_pair(5, COLOR_BLUE, bgcolor)
843 Ncurses.init_pair(6, COLOR_CYAN, bgcolor)
844 Ncurses.init_pair(7, COLOR_MAGENTA, bgcolor)
845 Ncurses.init_pair(8, COLOR_BLACK, bgcolor)
846 if @fgcolor then
847 Ncurses.bkgd(Ncurses.COLOR_PAIR(@fgcolor))
848 else
849 Ncurses.bkgd(Ncurses.COLOR_PAIR(1))
850 end
851 end
852
853 def do_fgcolor(color)
854 @fgcolor = ColorMap.get_color_pair(color)
855 Ncurses.attron(Ncurses.COLOR_PAIR(@fgcolor))
856 end
857
858 def do_color(color)
859 num = ColorMap.get_color_pair(color)
860 Ncurses.attron(Ncurses.COLOR_PAIR(num))
861 end
862
863 def type_line(l)
864 l.each_byte do |x|
865 @screen.addstr(x.chr)
866 @screen.refresh()
867 r = rand(20)
868 time_to_sleep = (5 + r).to_f / 250;
869 # puts "#{time_to_sleep} #{r}"
870 Kernel.sleep(time_to_sleep)
871 end
872 end
514873
515874 def slide_text(l)
516875 return if l == ""
517 if @slidedir == "left" then
876 case @slidedir
877 when "left"
518878 xcount = l.length-1
519879 while xcount >= 0
520880 @screen.move(@cur_line,@indent)
524884 Kernel.sleep(time_to_sleep)
525885 xcount -= 1
526886 end
527 elsif @slidedir == "right" then
887 when "right"
528888 (@termwidth - @indent).times do |pos|
529889 @screen.move(@cur_line,@termwidth - pos - 1)
530890 @screen.clrtoeol()
534894 time_to_sleep = 1.to_f / 20
535895 Kernel.sleep(time_to_sleep)
536896 end # do
537 elsif @slidedir == "top" then
897 when "top"
538898 # ycount = @cur_line
539899 new_scr = @screen.dupwin
540900 1.upto(@cur_line) do |i|
544904 @screen.refresh()
545905 Kernel.sleep(1.to_f / 10)
546906 end
547 elsif @slidedir == "bottom" then
907 when "bottom"
548908 new_scr = @screen.dupwin
549909 (@termheight-1).downto(@cur_line) do |i|
550910 Ncurses.overwrite(new_scr,@screen)
556916 end
557917 end
558918
559 def draw_page(page)
560 @output = false
561 @shelloutput = false
562 @slideoutput = false
563 @with_border = false
564 @cur_line = @voffset
919 def print_line(line)
920 width = @termwidth - 2*@indent
921 if @output or @shelloutput then
922 width -= 2
923 end
924 lines = split_lines(line,width)
925 lines.each do |l|
926 @screen.move(@cur_line,@indent)
927 if @output or @shelloutput then
928 @screen.addstr("| ")
929 end
930 if @shelloutput and (l =~ /^\$/ or l=~ /^%/ or l =~ /^#/) then # allow sh and csh style prompts
931 type_line(l)
932 elsif @slideoutput then
933 slide_text(l)
934 else
935 @screen.addstr(l)
936 end
937 @cur_line += 1
938 end
939 end
940
941 def close
942 Ncurses.nocbreak
943 Ncurses.endwin
944 end
945
946 def read_newpage(pages,current_page)
947 page = []
565948 @screen.clear()
566 draw_slidenum
567 page.lines.each do |l|
568 case l
569 when /^--heading /
570 @screen.move(@cur_line,@indent)
571 text = l.sub(/^--heading /,"")
572 x = (@termwidth - text.length)/2
573 @screen.move(@cur_line,x)
574 @screen.attron(Ncurses::A_BOLD)
575 @screen.addstr(text)
576 @screen.attroff(Ncurses::A_BOLD) # this is bad
577 @cur_line += 1
578 when /^--withborder/
579 draw_border()
580 @with_border = true
581 when /^--horline/
582 @screen.attron(Ncurses::A_BOLD)
583 (@termwidth).times do |x|
584 @screen.move(@cur_line,x)
585 @screen.addstr("-")
949 col = 0
950 line = 2
951 pages.each_index do |i|
952 @screen.move(line,col*15 + 2)
953 if current_page == i then
954 @screen.printw("%2d %s <=",i+1,pages[i].name[0..80])
955 else
956 @screen.printw("%2d %s",i+1,pages[i].name[0..80])
957 end
958 line += 1
959 if line >= @termheight - 3 then
960 line = 2
961 col += 1
962 end
963 end
964 prompt = "jump to slide: "
965 prompt_indent = 12
966 @screen.move(@termheight - 2, @indent + prompt_indent)
967 @screen.addstr(prompt)
968 # @screen.refresh();
969 Ncurses.echo
970 @screen.scanw("%d",page)
971 Ncurses.noecho
972 @screen.move(@termheight - 2, @indent + prompt_indent)
973 (prompt.length + page[0].to_s.length).times { @screen.addstr(" ") }
974 if page[0] then
975 return page[0] - 1
976 end
977 return -1 # invalid page
978 end
979
980 def store_screen
981 @screen.dupwin
982 end
983
984 def restore_screen(s)
985 Ncurses.overwrite(s,@screen)
986 end
987
988 def draw_slidenum(cur_page,max_pages,eop)
989 @screen.move(@termheight - 2, @indent)
990 @screen.attroff(Ncurses::A_BOLD) # this is bad
991 @screen.addstr("[slide #{cur_page}/#{max_pages}]")
992 if @footer_txt.to_s.length > 0 then
993 do_footer(@footer_txt)
994 end
995 if @header_txt.to_s.length > 0 then
996 do_header(@header_txt)
997 end
998
999 if eop then
1000 draw_eop_marker
1001 end
1002 end
1003
1004 def draw_eop_marker
1005 @screen.move(@termheight - 2, @indent - 1)
1006 @screen.attron(A_BOLD)
1007 @screen.addstr("*")
1008 @screen.attroff(A_BOLD)
1009 end
1010
1011 end
1012
1013
1014 # class LinuxdocVisualizer
1015 # converts tpp source to LinuxDoc SGML
1016 class LinuxdocVisualizer < TppVisualizer
1017
1018 def initialize(outputfile)
1019 @filename = outputfile
1020 begin
1021 @f = File.open(@filename,"w+")
1022 rescue
1023 $stderr.print "Error: couldn't open file: #{$!}"
1024 Kernel.exit(1)
1025 end
1026 @f.puts "<!doctype linuxdoc system>\n<article>"
1027 @need_p = true
1028 @verb = false
1029 @had_sect = false
1030 @itemize_open = false
1031 end
1032
1033 def do_footer(footer_text)
1034 end
1035
1036 def do_header(header_text)
1037 end
1038
1039 def do_refresh
1040 end
1041
1042 def new_page
1043 end
1044
1045 def do_heading(text)
1046 if not @need_p then
1047 if @had_sect then
1048 #@f.puts "</p>"
1049 else
1050 @f.puts "</abstract>"
1051 end
1052 @need_p = true
1053 end
1054 @f.puts "<sect>#{text}"
1055 @had_sect = true
1056 end
1057
1058 def do_withborder
1059 end
1060
1061 def do_horline
1062 end
1063
1064 def do_color(text)
1065 end
1066
1067 def do_center(text)
1068 end
1069
1070 def do_right(text)
1071 end
1072
1073 def do_exec(cmdline)
1074 end
1075
1076 def do_wait
1077 end
1078
1079 def do_beginoutput
1080 @f.puts "<p><tscreen><verb>"
1081 @verb_mode = true
1082 end
1083
1084 def do_beginshelloutput
1085 @f.puts "<p><tscreen><verb>"
1086 @verb_mode = true
1087 end
1088
1089 def do_endoutput
1090 @f.puts "</verb></tscreen>"
1091 @verb_mode = false
1092 end
1093
1094 def do_endshelloutput
1095 @f.puts "</verb></tscreen>"
1096 @verb_mode = false
1097 end
1098
1099 def do_sleep(time2sleep)
1100 end
1101
1102 def do_boldon
1103 @f.puts "<bf>"
1104 end
1105
1106 def do_boldoff
1107 @f.puts "</bf>"
1108 end
1109
1110 def do_revon
1111 end
1112
1113 def do_command_prompt
1114 end
1115 def do_revoff
1116 end
1117
1118 def do_ulon
1119 end
1120
1121 def do_uloff
1122 end
1123
1124 def do_beginslideleft
1125 end
1126
1127 def do_endslide
1128 end
1129
1130 def do_beginslideright
1131 end
1132
1133 def do_beginslidetop
1134 end
1135
1136 def do_beginslidebottom
1137 end
1138
1139 def do_sethugefont(text)
1140 end
1141
1142 def do_huge(text)
1143 end
1144
1145 def print_line(line)
1146 if not @verb_mode then
1147 if @need_p then
1148 if line.strip != "" then
1149 if @had_sect then
1150 @f.print "<p>"
1151 else
1152 @f.print "<abstract>"
5861153 end
587 @screen.attroff(Ncurses::A_BOLD)
588 @cur_line += 1
589 when /^--color /
590 text = l.sub(/^--color /,"")
591 text.strip!
592 num = ColorMap.get_color_pair(text)
593 Ncurses.attron(Ncurses.COLOR_PAIR(num))
594 @current_color_pair = num
595 when /^--center /
596 @screen.move(@cur_line,@indent)
597 if @output or @shelloutput then
598 @screen.addstr("| ")
599 end
600 text = l.sub(/^--center /,"")
601 x = (@termwidth - text.length)/2
602 @screen.move(@cur_line,x)
603 @screen.addstr(text)
604 @cur_line += 1
605 when /^--right /
606 @screen.move(@cur_line,@indent)
607 if @output or @shelloutput then
608 @screen.addstr("| ")
609 end
610 text = l.sub(/^--right /,"")
611 x = (@termwidth - text.length - 2)
612 @screen.move(@cur_line,x)
613 @screen.addstr(text)
614 @cur_line += 1
615 when /^--exec /
616 cmdline = l.sub(/^--exec /,"")
617 rc = Kernel.system(cmdline)
618 if not rc then
619 print_line("Error: exec \"#{cmdline}\" failed with error code #{$?}")
620 end
621 when /^---/
622 while true do
623 x = @screen.getch()
624 case x
625 when ' '[0]
626 break
627 when 'q'[0], 'Q'[0], 'j'[0], 'J'[0], 's'[0], 'S'[0], 'e'[0], 'E'[0], 'c'[0], 'C'[0], Ncurses::KEY_LEFT, Ncurses::KEY_RIGHT, Ncurses::KEY_UP, Ncurses::KEY_DOWN
628 if [ Ncurses::KEY_DOWN, Ncurses::KEY_RIGHT ].include?(x) then
629 return x if not on_last_page?
630 elsif [ Ncurses::KEY_UP, Ncurses::KEY_LEFT].include?(x) then
631 return x if not on_first_page?
632 else
633 return x
634 end
635 end # case
636 end # while
637 # @screen.refresh()
638 when /^--beginoutput/
639 @screen.move(@cur_line,@indent)
640 @screen.addstr(".")
641 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
642 @output = true
643 @cur_line += 1
644 when /^--beginshelloutput/
645 @screen.move(@cur_line,@indent)
646 @screen.addstr(".")
647 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
648 @shelloutput = true
649 @cur_line += 1
650 when /^--endoutput/
651 if @output then
652 @screen.move(@cur_line,@indent)
653 @screen.addstr("`")
654 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
655 @output = false
656 @cur_line += 1
657 end
658 when /^--endshelloutput/
659 if @shelloutput then
660 @screen.move(@cur_line,@indent)
661 @screen.addstr("`")
662 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
663 @shelloutput = false
664 @cur_line += 1
665 end
666 when /^--sleep /
667 time2sleep = l.sub(/^--sleep /,"")
668 Kernel.sleep(time2sleep.to_i)
669 when /^--boldon/
670 @screen.attron(Ncurses::A_BOLD)
671 when /^--boldoff/
672 @screen.attroff(Ncurses::A_BOLD)
673 when /^--revon/
674 @screen.attron(Ncurses::A_REVERSE)
675 when /^--revoff/
676 @screen.attroff(Ncurses::A_REVERSE)
677 when /^--ulon/
678 @screen.attron(Ncurses::A_UNDERLINE)
679 when /^--uloff/
680 @screen.attroff(Ncurses::A_UNDERLINE)
681 when /^--beginslideleft/
682 @slideoutput = true
683 @slidedir = "left"
684 when /^--endslideleft/, /^--endslideright/, /^--endslidetop/, /^--endslidebottom/
685 @slideoutput = false
686 when /^--beginslideright/
687 @slideoutput = true
688 @slidedir = "right"
689 when /^--beginslidetop/
690 @slideoutput = true
691 @slidedir = "top"
692 when /^--beginslidebottom/
693 @slideoutput = true
694 @slidedir = "bottom"
695 when /^--sethugefont /
696 params = l.sub(/^--sethugefont /,"")
697 @figletfont = params.strip
698 when /^--huge /
699 figlet_text = l.sub(/^--huge /,"")
700 output_width = @termwidth - @indent
701 output_width -= 2 if @output or @shelloutput
702 op = IO.popen("figlet -f #{@figletfont} -w #{output_width} -k \"#{figlet_text}\"","r")
703 op.readlines.each do |line|
704 print_line(line)
705 end
706 op.close
1154 @need_p = false
1155 end
1156 end
1157 end
1158 if line =~ /^ *\*/ then
1159 line.sub!(/^ *\*/,"")
1160 if @itemize_open then
1161 @f.puts "<item> #{line}"
7071162 else
708 print_line(l)
709 end
710 end
711
712 if @output or @shelloutput then # forgot --endoutput or --endshelloutput
713 @screen.move(@cur_line,@indent)
714 @screen.addstr("`")
715 ((@termwidth - @indent)/2).times { @screen.addstr("-") }
716 end
717 end
718
719 def print_line(line)
720 @screen.move(@cur_line,@indent)
721 if @output or @shelloutput then
722 @screen.addstr("| ")
723 end
724 if @shelloutput and (line =~ /^\$/ or line=~ /^%/) then # allow sh and csh style prompts
725 type_line(line)
726 elsif @slideoutput then
727 slide_text(line)
1163 @f.puts "<itemize> <item> #{line}"
1164 @itemize_open = true
1165 end
7281166 else
729 @screen.addstr(line)
730 end
731 @cur_line += 1
732 end
733
734 def show_helpscreen
735 help_text = [ "tpp help",
736 "",
737 "space bar ............................... display next entry within page",
738 "space bar, cursor-down, cursor-right .... display next page",
739 "b, cursor-up, cursor-left ............... display previous page",
740 "q, Q .................................... quit tpp",
741 "j, J .................................... jump directly to page",
742 "s, S .................................... jump to the first page",
743 "e, E .................................... jump to the last page",
744 "c, C .................................... start command line",
745 "? ....................................... this help screen" ]
746 @screen.clear
747 y = @voffset
748 help_text.each do |line|
749 @screen.move(y,@indent)
750 @screen.addstr(line)
751 y += 1
752 end
753 @screen.move(@termheight - 2, @indent)
754 @screen.addstr("Press any key to return to slide")
755 @screen.refresh()
756 @screen.getch()
1167 if @itemize_open then
1168 @itemize_open = false
1169 @f.puts "</itemize>"
1170 end
1171 @f.puts "#{line}"
1172 end
1173 if not @verb_mode then
1174 if line.strip == "" and not @need_p then
1175 if @had_sect then
1176 #@f.puts "</p>"
1177 else
1178 @f.puts "</abstract>"
1179 end
1180 @need_p = true
1181 end
1182 end
1183 end
1184
1185 def do_title(title)
1186 @f.puts "<title>#{title}"
1187 end
1188
1189 def do_author(author)
1190 @f.puts "<author>#{author}"
1191 end
1192
1193 def do_date(date)
1194 @f.puts "<date>#{date}"
1195 end
1196
1197 def do_bgcolor(color)
1198 end
1199
1200 def do_fgcolor(color)
1201 end
1202
1203 def do_color(color)
1204 end
1205
1206 def close
1207 @f.puts "</article>"
1208 @f.close
1209 end
1210
1211 end
1212
1213
1214 # class TppController
1215 # generic controller that does nothing
1216 class TppController
1217
1218 def initialize
1219 $stderr.puts "Error: TppController.initialize has been called directly!"
1220 Kernel.exit(1)
1221 end
1222
1223 def close
1224 $stderr.puts "Error: TppController.close has been called directly!"
1225 Kernel.exit(1)
7571226 end
7581227
7591228 def run
760 changed_page = true
761 jumped_out = false
762 x = ""
763 while true do
764 if changed_page then
765 x = draw_page(@pages[@current_page])
766 jump_out_chars = [ 'q'[0],'j'[0],'Q'[0],'J'[0],'e'[0],'E'[0],'s'[0],'S'[0],'c'[0],'C'[0],'?'[0], Ncurses::KEY_LEFT, Ncurses::KEY_RIGHT, Ncurses::KEY_UP, Ncurses::KEY_DOWN ]
767 jumped_out = true if jump_out_chars.include?(x)
768 # jumped_out = true if x == 'q'[0] or x == 'j'[0] or x == 'Q'[0] or x == 'J'[0] or x == 'e'[0] or x == 'E'[0] or x == 's'[0] or x == 'S'[0] or x == 'c' or x == 'C'[0]
769 draw_slidenum # draw slidenum to bring cursor down
770 @screen.refresh()
771 end
772 if not jumped_out then
773 draw_eop_marker
774 draw_slidenum
775 @screen.refresh()
776 x = @screen.getch()
777 end
778 changed_page = false
779 jumped_out = false
780 case x
781 when 'q'[0], 'Q'[0] # 'Q'uit
782 return
783 when 'r'[0], 'R'[0] # 'R'edraw slide
784 changed_page = true
785 when 'j'[0], 'J'[0] # 'J'ump to slide
786 p = read_newpage
787 if p >=0 and p < @number_pages then
788 @current_page = p
789 end
790 changed_page = true
791 draw_slidenum
792 when '?'[0] # show a help screen explaining all important commands
793 new_scr = @screen.dupwin
794 show_helpscreen
795 Ncurses.overwrite(new_scr,@screen)
796 @screen.refresh()
797 draw_slidenum
798 when 'e'[0], 'E'[0] # jump to end
799 @current_page=@number_pages-1
800 changed_page = true
801 when 's'[0], 'S'[0] # jump to start
802 @current_page = 0
803 changed_page = true
804 when Ncurses::KEY_RIGHT, Ncurses::KEY_DOWN, ' '[0] # next slide
805 if @current_page + 1 < @number_pages then
806 @current_page += 1
807 changed_page = true
808 end
809 when 'b'[0], 'B'[0], Ncurses::KEY_LEFT, Ncurses::KEY_UP # previous slide
810 if @current_page > 0 then
811 @current_page -= 1
812 changed_page = true
813 end
814 when 'c'[0], 'C'[0] # commandprompt
815 command_prompt()
816 changed_page = true
817 when Ncurses::KEY_RESIZE # WINCH signal (ugly!)
818 set_sizes
819 end # case
820 @screen.refresh()
821 end # while
822 end
823
824 def on_first_page?
825 @current_page == 0
826 end
827
828 def on_last_page?
829 @current_page == (@number_pages - 1)
1229 $stderr.puts "Error: TppController.run has been called directly!"
1230 Kernel.exit(1)
8301231 end
8311232
8321233 end
8331234
834 filename = nil
835 output_latex = false
836 latex_filename = nil
1235 # class NcursesController
1236 # controls both the keyboard input and what needs to be printed
1237 class NcursesController < TppController
1238
1239 def initialize(filename)
1240 @filename = filename
1241 @vis = NcursesVisualizer.new
1242 @cur_page = 0
1243 end
1244
1245 def close
1246 @vis.close
1247 end
1248
1249 def run
1250 begin
1251 @reload_file = false
1252 parser = FileParser.new(@filename)
1253 @pages = parser.get_pages
1254 if @cur_page >= @pages.size then
1255 @cur_page = @pages.size - 1
1256 end
1257 @vis.clear
1258 @vis.new_page
1259 do_run
1260 end while @reload_file
1261 end
1262
1263 def do_run
1264 window = Ncurses.stdscr
1265 loop do
1266 wait = false
1267 @vis.draw_slidenum(@cur_page + 1, @pages.size, false)
1268 # read and visualize lines until the visualizer says "stop" or we reached end of page
1269 begin
1270 line = @pages[@cur_page].next_line
1271 eop = @pages[@cur_page].eop?
1272 wait = @vis.visualize(line,eop)
1273 end while not wait and not eop
1274 # draw slide number on the bottom left and redraw:
1275 @vis.draw_slidenum(@cur_page + 1, @pages.size, eop)
1276 @vis.do_refresh
1277
1278 # read a character from the keyboard
1279 # a "break" in the when means that it breaks the loop, i.e. goes on with visualizing lines
1280 loop do
1281 ch = window.getch
1282 case ch
1283 when 'q'[0], 'Q'[0] # 'Q'uit
1284 return
1285 when 'r'[0], 'R'[0] # 'R'edraw slide
1286 changed_page = true # @todo: actually implement redraw
1287 when 'e'[0], 'E'[0]
1288 @cur_page = @pages.size - 1
1289 break
1290 when 's'[0], 'S'[0]
1291 @cur_page = 0
1292 break
1293 when 'j'[0], 'J'[0] # 'J'ump to slide
1294 screen = @vis.store_screen
1295 p = @vis.read_newpage(@pages,@cur_page)
1296 if p >= 0 and p < @pages.size
1297 @cur_page = p
1298 @pages[@cur_page].reset_eop
1299 @vis.new_page
1300 else
1301 @vis.restore_screen(screen)
1302 end
1303 break
1304 when 'l'[0], 'L'[0] # re'l'oad current file
1305 @reload_file = true
1306 return
1307 when 'c'[0], 'C'[0] # command prompt
1308 screen = @vis.store_screen
1309 @vis.do_command_prompt
1310 #ch = window.getch
1311 @vis.clear
1312 @vis.restore_screen(screen)
1313 when '?'[0], 'h'[0]
1314 screen = @vis.store_screen
1315 @vis.show_help_page
1316 ch = window.getch
1317 @vis.clear
1318 @vis.restore_screen(screen)
1319 when Ncurses::KEY_RIGHT, Ncurses::KEY_DOWN, ' '[0]
1320 if @cur_page + 1 < @pages.size and eop then
1321 @cur_page += 1
1322 @pages[@cur_page].reset_eop
1323 @vis.new_page
1324 end
1325 break
1326 when 'b'[0], 'B'[0], Ncurses::KEY_LEFT, Ncurses::KEY_UP
1327 if @cur_page > 0 then
1328 @cur_page -= 1
1329 @pages[@cur_page].reset_eop
1330 @vis.new_page
1331 end
1332 break
1333 when Ncurses::KEY_RESIZE
1334 @vis.setsizes
1335 end
1336 end
1337 end # loop
1338 end
1339
1340 end
1341
1342
1343 class LinuxdocController
1344
1345 def initialize(input,output)
1346 parser = FileParser.new(input)
1347 @pages = parser.get_pages
1348 @vis = LinuxdocVisualizer.new(output)
1349 end
1350
1351 def run
1352 @pages.each do |p|
1353 begin
1354 line = p.next_line
1355 eop = p.eop?
1356 @vis.visualize(line,eop)
1357 end while not eop
1358 end
1359 end
1360
1361 def close
1362 @vis.close
1363 end
1364
1365 end
1366
1367
1368 def usage
1369 $stderr.puts "usage: #{$0} [-t <type> -o <file>] <file>\n"
1370 $stderr.puts "\t -t <type>\t\tset filetype <type> as output format"
1371 $stderr.puts "\t -o <file>\t\twrite output to file <file>"
1372 $stderr.puts "\t --version\t\tprint the version"
1373 $stderr.puts "\t --help\t\t\tprint this help"
1374 $stderr.puts "\n\t currently available types: ncurses (default), linuxdoc"
1375 Kernel.exit(1)
1376 end
1377
1378 input = nil
1379 output = nil
1380 type = "ncurses"
1381
8371382 skip_next = false
838 version_number = "1.1.1"
1383
8391384 ARGV.each_index do |i|
8401385 if skip_next then
8411386 skip_next = false
8421387 else
843 if ARGV[i] == "-l" or ARGV[i] == "--latex" then
844 output_latex = true
845 latex_filename = ARGV[i+1]
1388 if ARGV[i] == '-v' or ARGV[i] == '--version' then
1389 printf "tpp - text presentation program %s\n", version_number
1390 elsif ARGV[i] == '-h' or ARGV[i] == '--help' then
1391 usage
1392 elsif ARGV[i] == '-t' then
1393 type = ARGV[i+1]
8461394 skip_next = true
847 elsif ARGV[i] == "-h" or ARGV[i] == "--help" then
848 printf "tpp - text presentation program %s\n", version_number
849 elsif ARGV[i] == "-v" or ARGV[i] == "--version" then
850 printf "tpp - text presentation program %s\n", version_number
851 Kernel.exit(1)
852 elsif filename == nil then
853 filename = ARGV[i]
854 end
1395 elsif ARGV[i] == '-o' then
1396 output = ARGV[i+1]
1397 skip_next = true
1398 elsif input == nil then
1399 input = ARGV[i]
1400 end
1401 if output==input then
1402 $stderr.puts "Don't use the input file name as the output filename to prevent overwrinting it. \n"
1403 Kernel.exit(1)
1404 end
8551405 end
8561406 end
8571407
858
859 if filename == nil then
860 $stderr.puts "usage: #{$0} [options] <file>"
861 $stderr.puts "\nOptions: -l <outputfile> <file> convert presentation to latex"
862 $stderr.puts "\t --version\t\tprints this help"
863 $stderr.puts "\t --help\t\t\tprints this help"
864 Kernel.exit(1)
1408 if input == nil then
1409 usage
8651410 end
8661411
867 parser = FileParser.new(filename)
868 parser.do_work(output_latex)
869
870 pages = parser.get_pages
871 bgcolor = parser.get_bgcolor
872
873 if output_latex then
874 if latex_filename == nil then
875 $stderr.puts "error: no filename supplied to -l"
876 Kernel.exit(1)
877 end
878 gen = LatexGenerator.new(pages,parser.get_title,parser.get_author,parser.get_date)
879 gen.generate_output(latex_filename)
1412 ctrl = nil
1413
1414 case type
1415 when "linuxdoc"
1416 if output == nil then
1417 usage
1418 else
1419 ctrl = LinuxdocController.new(input,output)
1420 end
1421 when "ncurses"
1422 ctrl = NcursesController.new(input)
8801423 else
881 pager = Pager.new(pages,bgcolor)
882 pager.run
883 pager.close
884 end
1424 usage
1425 end # case
1426
1427 ctrl.run
1428 ctrl.close