Merge lp:~gatesphere/leo-editor/printing into lp:leo-editor
- printing
- Merge into trunk3
Proposed by
Jake Peck
Status: | Merged |
---|---|
Merged at revision: | 5779 |
Proposed branch: | lp:~gatesphere/leo-editor/printing |
Merge into: | lp:leo-editor |
Diff against target: |
514 lines (+351/-18) 4 files modified
leo/config/leoSettings.leo (+22/-9) leo/core/LeoPyRef.leo (+7/-7) leo/plugins/leoPluginsRef.leo (+5/-2) leo/plugins/printing.py (+317/-0) |
To merge this branch: | bzr merge lp:~gatesphere/leo-editor/printing |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
The Leo editor team | Pending | ||
Review via email: mp+163725@code.launchpad.net |
Commit message
Description of the change
Adds a printing plugin that allows printing and print-previewing from the Qt GUI. Offers several printing modes, including single node, marked nodes, and expanded node (filling in all @others, <<sections>>, etc.). All of these are available in two modes - body only, or with headlines.
All unit tests pass.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'leo/config/leoSettings.leo' | |||
2 | --- leo/config/leoSettings.leo 2013-05-13 05:40:49 +0000 | |||
3 | +++ leo/config/leoSettings.leo 2013-05-14 14:51:04 +0000 | |||
4 | @@ -93,9 +93,9 @@ | |||
5 | 93 | <v t="ekr.20041119035704.3"><vh>\@type type-name: base-type = [list of valid values]</vh></v> | 93 | <v t="ekr.20041119035704.3"><vh>\@type type-name: base-type = [list of valid values]</vh></v> |
6 | 94 | <v t="ekr.20041120155431.2"><vh>\@type type-name: script: script-name</vh></v> | 94 | <v t="ekr.20041120155431.2"><vh>\@type type-name: script: script-name</vh></v> |
7 | 95 | </v> | 95 | </v> |
9 | 96 | <v t="ekr.20061011082224"><vh>Candidates for settings in myLeoSettings.leo</vh> | 96 | <v t="ekr.20061011082224" a="E"><vh>Candidates for settings in myLeoSettings.leo</vh> |
10 | 97 | <v t="ekr.20070224073109.1"><vh>@enabled-plugins</vh></v> | 97 | <v t="ekr.20070224073109.1"><vh>@enabled-plugins</vh></v> |
12 | 98 | <v t="ekr.20110611092035.16470"><vh>Appearance</vh> | 98 | <v t="ekr.20110611092035.16470" a="E"><vh>Appearance</vh> |
13 | 99 | <v t="ekr.20111024091133.16701"><vh>@@@int qt-tab-width = 40</vh></v> | 99 | <v t="ekr.20111024091133.16701"><vh>@@@int qt-tab-width = 40</vh></v> |
14 | 100 | <v t="ekr.20081018053140.12"><vh>@data qt-gui-plugin-style-sheet</vh></v> | 100 | <v t="ekr.20081018053140.12"><vh>@data qt-gui-plugin-style-sheet</vh></v> |
15 | 101 | <v t="ekr.20081023060109.13"><vh>@int qt-rich-text-zoom-in = 10</vh></v> | 101 | <v t="ekr.20081023060109.13"><vh>@int qt-rich-text-zoom-in = 10</vh></v> |
16 | @@ -103,7 +103,7 @@ | |||
17 | 103 | <v t="ekr.20070604075218"><vh>@bool use_chapter_tabs = True</vh></v> | 103 | <v t="ekr.20070604075218"><vh>@bool use_chapter_tabs = True</vh></v> |
18 | 104 | <v t="ekr.20070318065601"><vh>@bool use_chapters = True</vh></v> | 104 | <v t="ekr.20070318065601"><vh>@bool use_chapters = True</vh></v> |
19 | 105 | </v> | 105 | </v> |
21 | 106 | <v t="ekr.20110611092035.16471"><vh>Colorizer & colors</vh> | 106 | <v t="ekr.20110611092035.16471" a="E"><vh>Colorizer & colors</vh> |
22 | 107 | <v t="ekr.20060201111002"><vh>@bool use_syntax_coloring = True</vh></v> | 107 | <v t="ekr.20060201111002"><vh>@bool use_syntax_coloring = True</vh></v> |
23 | 108 | <v t="ekr.20041119034357.67"><vh>@color split_bar_color = LightSteelBlue2</vh></v> | 108 | <v t="ekr.20041119034357.67"><vh>@color split_bar_color = LightSteelBlue2</vh></v> |
24 | 109 | <v t="ekr.20081018053140.12"></v> | 109 | <v t="ekr.20081018053140.12"></v> |
25 | @@ -515,7 +515,7 @@ | |||
26 | 515 | </v> | 515 | </v> |
27 | 516 | </v> | 516 | </v> |
28 | 517 | <v t="ekr.20070224073109.1"></v> | 517 | <v t="ekr.20070224073109.1"></v> |
30 | 518 | <v t="ekr.20041119034357.1"><vh>@settings</vh> | 518 | <v t="ekr.20041119034357.1" a="E"><vh>@settings</vh> |
31 | 519 | <v t="ekr.20100904134301.11000"><vh>Abbreviations</vh> | 519 | <v t="ekr.20100904134301.11000"><vh>Abbreviations</vh> |
32 | 520 | <v t="ekr.20100904134301.11006"><vh>@bool enable-abbreviations = False</vh></v> | 520 | <v t="ekr.20100904134301.11006"><vh>@bool enable-abbreviations = False</vh></v> |
33 | 521 | <v t="ekr.20100904134301.11002"><vh>@data global-abbreviations</vh></v> | 521 | <v t="ekr.20100904134301.11002"><vh>@data global-abbreviations</vh></v> |
34 | @@ -527,7 +527,7 @@ | |||
35 | 527 | <v t="tbrown.20120821183537.18663"><vh>@string abbreviations-place-start = <|</vh></v> | 527 | <v t="tbrown.20120821183537.18663"><vh>@string abbreviations-place-start = <|</vh></v> |
36 | 528 | <v t="tbrown.20120821183537.18662"><vh>@string abbreviations-place-end = |></vh></v> | 528 | <v t="tbrown.20120821183537.18662"><vh>@string abbreviations-place-end = |></vh></v> |
37 | 529 | </v> | 529 | </v> |
39 | 530 | <v t="ekr.20110611092035.16470"></v> | 530 | <v t="ekr.20110611092035.16470" a="E"></v> |
40 | 531 | <v t="ekr.20110510071925.14588"><vh>Autocompleter</vh> | 531 | <v t="ekr.20110510071925.14588"><vh>Autocompleter</vh> |
41 | 532 | <v t="ekr.20110512085854.14461"><vh>@bool auto_tab_complete = False</vh></v> | 532 | <v t="ekr.20110512085854.14461"><vh>@bool auto_tab_complete = False</vh></v> |
42 | 533 | <v t="ekr.20051027175030"><vh>@bool autocomplete-brackets = False</vh></v> | 533 | <v t="ekr.20051027175030"><vh>@bool autocomplete-brackets = False</vh></v> |
43 | @@ -536,7 +536,7 @@ | |||
44 | 536 | <v t="ekr.20110510071925.14590"><vh>@@@bool use_codewise = False</vh></v> | 536 | <v t="ekr.20110510071925.14590"><vh>@@@bool use_codewise = False</vh></v> |
45 | 537 | <v t="ekr.20110510071925.14589"><vh>@bool use_qcompleter = True</vh></v> | 537 | <v t="ekr.20110510071925.14589"><vh>@bool use_qcompleter = True</vh></v> |
46 | 538 | </v> | 538 | </v> |
48 | 539 | <v t="ekr.20110611092035.16471"></v> | 539 | <v t="ekr.20110611092035.16471" a="E"></v> |
49 | 540 | <v t="ekr.20041119034357.10"><vh>Command options</vh> | 540 | <v t="ekr.20041119034357.10"><vh>Command options</vh> |
50 | 541 | <v t="ekr.20111115083813.12518"><vh>@bool indent_added_comments = True</vh></v> | 541 | <v t="ekr.20111115083813.12518"><vh>@bool indent_added_comments = True</vh></v> |
51 | 542 | <v t="ekr.20041119041019.1"><vh>@string remove_sentinels_extension = .txt</vh></v> | 542 | <v t="ekr.20041119041019.1"><vh>@string remove_sentinels_extension = .txt</vh></v> |
52 | @@ -1389,7 +1389,7 @@ | |||
53 | 1389 | <v t="ekr.20110611092035.16492"><vh>Mouse</vh> | 1389 | <v t="ekr.20110611092035.16492"><vh>Mouse</vh> |
54 | 1390 | <v t="ekr.20080324105006.6"><vh>@bool allow_middle_button_paste = False</vh></v> | 1390 | <v t="ekr.20080324105006.6"><vh>@bool allow_middle_button_paste = False</vh></v> |
55 | 1391 | </v> | 1391 | </v> |
57 | 1392 | <v t="ekr.20051123100536"><vh>Plugins</vh> | 1392 | <v t="ekr.20051123100536" a="E"><vh>Plugins</vh> |
58 | 1393 | <v t="ekr.20041119034357.13"><vh>@bool use_plugins = True</vh></v> | 1393 | <v t="ekr.20041119034357.13"><vh>@bool use_plugins = True</vh></v> |
59 | 1394 | <v t="ekr.20071113084330"><vh>@bool warn_when_plugins_fail_to_load = True</vh></v> | 1394 | <v t="ekr.20071113084330"><vh>@bool warn_when_plugins_fail_to_load = True</vh></v> |
60 | 1395 | <v t="ekr.20070224073109.1"></v> | 1395 | <v t="ekr.20070224073109.1"></v> |
61 | @@ -1453,6 +1453,10 @@ | |||
62 | 1453 | <v t="ekr.20060922110220"><vh>@bool opml_write_uAs = True</vh></v> | 1453 | <v t="ekr.20060922110220"><vh>@bool opml_write_uAs = True</vh></v> |
63 | 1454 | <v t="ekr.20060919171527.2"><vh>@string opml_namespace = leo:com:leo-opml-version-1</vh></v> | 1454 | <v t="ekr.20060919171527.2"><vh>@string opml_namespace = leo:com:leo-opml-version-1</vh></v> |
64 | 1455 | </v> | 1455 | </v> |
65 | 1456 | <v t="peckj.20130514082859.5599" a="E"><vh>printing plugin</vh> | ||
66 | 1457 | <v t="peckj.20130514082859.5600"><vh>@string printing-font-size = 12</vh></v> | ||
67 | 1458 | <v t="peckj.20130514082859.5601"><vh>@string printing-font-family = DejaVu Sans Mono</vh></v> | ||
68 | 1459 | </v> | ||
69 | 1456 | <v t="ekr.20081018053140.11"><vh>qtGui plugin</vh> | 1460 | <v t="ekr.20081018053140.11"><vh>qtGui plugin</vh> |
70 | 1457 | <v t="ekr.20110611092035.16472"><vh>Don't change these unless you know what you are doing</vh> | 1461 | <v t="ekr.20110611092035.16472"><vh>Don't change these unless you know what you are doing</vh> |
71 | 1458 | <v t="ekr.20081023060109.14"><vh>@bool qt-use-scintilla = False</vh></v> | 1462 | <v t="ekr.20081023060109.14"><vh>@bool qt-use-scintilla = False</vh></v> |
72 | @@ -1462,7 +1466,7 @@ | |||
73 | 1462 | </v> | 1466 | </v> |
74 | 1463 | </v> | 1467 | </v> |
75 | 1464 | <v t="ekr.20071213060239"><vh>rst3 plugin</vh> | 1468 | <v t="ekr.20071213060239"><vh>rst3 plugin</vh> |
77 | 1465 | <v t="ekr.20071213060239.1"><vh>rst3 http options</vh> | 1469 | <v t="ekr.20071213060239.1" a="E"><vh>rst3 http options</vh> |
78 | 1466 | <v t="ekr.20071213061454"><vh>@bool rst3_clear_http_attributes = False</vh></v> | 1470 | <v t="ekr.20071213061454"><vh>@bool rst3_clear_http_attributes = False</vh></v> |
79 | 1467 | <v t="ekr.20071213061454.1"><vh>@bool rst3_http_server_support = False</vh></v> | 1471 | <v t="ekr.20071213061454.1"><vh>@bool rst3_http_server_support = False</vh></v> |
80 | 1468 | <v t="ekr.20071213061454.2"><vh>@string rst3_http_attributename = rst_http_attribute</vh></v> | 1472 | <v t="ekr.20071213061454.2"><vh>@string rst3_http_attributename = rst_http_attribute</vh></v> |
81 | @@ -1487,7 +1491,7 @@ | |||
82 | 1487 | <v t="ekr.20071213061923.2"><vh>@bool rst3_generate_rst = True</vh></v> | 1491 | <v t="ekr.20071213061923.2"><vh>@bool rst3_generate_rst = True</vh></v> |
83 | 1488 | <v t="ekr.20090430075506.7"><vh>@bool rst3_generate_rst_header_comment = True</vh></v> | 1492 | <v t="ekr.20090430075506.7"><vh>@bool rst3_generate_rst_header_comment = True</vh></v> |
84 | 1489 | </v> | 1493 | </v> |
86 | 1490 | <v t="ekr.20071213060514.2"><vh>rst3 formatting options</vh> | 1494 | <v t="ekr.20071213060514.2" a="E"><vh>rst3 formatting options</vh> |
87 | 1491 | <v t="ekr.20071213061930.1"><vh>@bool rst3_show_headlines = True</vh></v> | 1495 | <v t="ekr.20071213061930.1"><vh>@bool rst3_show_headlines = True</vh></v> |
88 | 1492 | <v t="ekr.20071213061930.2"><vh>@bool rst3_show_organizer_nodes = True</vh></v> | 1496 | <v t="ekr.20071213061930.2"><vh>@bool rst3_show_organizer_nodes = True</vh></v> |
89 | 1493 | <v t="ekr.20071213061930.3"><vh>@bool rst3_show_options_nodes = False</vh></v> | 1497 | <v t="ekr.20071213061930.3"><vh>@bool rst3_show_options_nodes = False</vh></v> |
90 | @@ -4461,6 +4465,7 @@ | |||
91 | 4461 | stickynotes.py | 4465 | stickynotes.py |
92 | 4462 | todo.py | 4466 | todo.py |
93 | 4463 | viewrendered.py | 4467 | viewrendered.py |
94 | 4468 | printing.py | ||
95 | 4464 | 4469 | ||
96 | 4465 | # Alphabetical list of all Leo plugins. | 4470 | # Alphabetical list of all Leo plugins. |
97 | 4466 | 4471 | ||
98 | @@ -9733,6 +9738,14 @@ | |||
99 | 9733 | action will be used instead.</t> | 9738 | action will be used instead.</t> |
100 | 9734 | <t tx="leohag.20081204085551.13"></t> | 9739 | <t tx="leohag.20081204085551.13"></t> |
101 | 9735 | <t tx="nh910.20110621123823.3423"></t> | 9740 | <t tx="nh910.20110621123823.3423"></t> |
102 | 9741 | <t tx="peckj.20130514082859.5599"></t> | ||
103 | 9742 | <t tx="peckj.20130514082859.5600">This defines the font size for body text in print outs. | ||
104 | 9743 | |||
105 | 9744 | Size is in px. Default 12.</t> | ||
106 | 9745 | <t tx="peckj.20130514082859.5601">This determines the font family for print outs. It's highly recommended | ||
107 | 9746 | to choose a monospaced font. | ||
108 | 9747 | |||
109 | 9748 | Default: DejaVu Sans Mono</t> | ||
110 | 9736 | <t tx="tbrown.20081003103821.1">True: if the same file (basename) occurs more than once in the recent files | 9749 | <t tx="tbrown.20081003103821.1">True: if the same file (basename) occurs more than once in the recent files |
111 | 9737 | list, i.e. on two different paths it will appear as a submenu with the basename | 9750 | list, i.e. on two different paths it will appear as a submenu with the basename |
112 | 9738 | as its heading, and the two (or more) paths as its entries. This is easier to | 9751 | as its heading, and the two (or more) paths as its entries. This is easier to |
113 | 9739 | 9752 | ||
114 | === modified file 'leo/core/LeoPyRef.leo' | |||
115 | --- leo/core/LeoPyRef.leo 2013-05-01 16:19:39 +0000 | |||
116 | +++ leo/core/LeoPyRef.leo 2013-05-14 14:51:04 +0000 | |||
117 | @@ -27,8 +27,7 @@ | |||
118 | 27 | expanded="ekr.20120329072206.9701,"><vh>@file ../doc/leoProjects.txt</vh></v> | 27 | expanded="ekr.20120329072206.9701,"><vh>@file ../doc/leoProjects.txt</vh></v> |
119 | 28 | </v> | 28 | </v> |
120 | 29 | <v t="EKR.20040519090151.2"><vh>To do</vh> | 29 | <v t="EKR.20040519090151.2"><vh>To do</vh> |
123 | 30 | <v t="ekr.20100119205347.6015" | 30 | <v t="ekr.20100119205347.6015"><vh>@file ../doc/leoToDo.txt</vh></v> |
122 | 31 | marks="ekr.20111116103733.9818,"><vh>@file ../doc/leoToDo.txt</vh></v> | ||
124 | 32 | </v> | 31 | </v> |
125 | 33 | <v t="ekr.20031218072017.2406" a="E"><vh>Code</vh> | 32 | <v t="ekr.20031218072017.2406" a="E"><vh>Code</vh> |
126 | 34 | <v t="ekr.20090802181029.5988"><vh>Version</vh> | 33 | <v t="ekr.20090802181029.5988"><vh>Version</vh> |
127 | @@ -42,7 +41,7 @@ | |||
128 | 42 | <v t="ekr.20120519121124.9919"><vh>@file ../external/leosax.py</vh></v> | 41 | <v t="ekr.20120519121124.9919"><vh>@file ../external/leosax.py</vh></v> |
129 | 43 | <v t="ekr.20031218072017.2605"><vh>@file runLeo.py </vh></v> | 42 | <v t="ekr.20031218072017.2605"><vh>@file runLeo.py </vh></v> |
130 | 44 | </v> | 43 | </v> |
132 | 45 | <v t="ekr.20031218072017.2604" a="E"><vh>Core classes</vh> | 44 | <v t="ekr.20031218072017.2604"><vh>Core classes</vh> |
133 | 46 | <v t="ekr.20031218072017.2608"><vh>@file leoApp.py</vh></v> | 45 | <v t="ekr.20031218072017.2608"><vh>@file leoApp.py</vh></v> |
134 | 47 | <v t="ekr.20041005105605.1"><vh>@file leoAtFile.py</vh></v> | 46 | <v t="ekr.20041005105605.1"><vh>@file leoAtFile.py</vh></v> |
135 | 48 | <v t="ekr.20070227091955.1"><vh>@file leoBridge.py</vh></v> | 47 | <v t="ekr.20070227091955.1"><vh>@file leoBridge.py</vh></v> |
136 | @@ -51,7 +50,7 @@ | |||
137 | 51 | <v t="ekr.20031218072017.2794"><vh>@file leoColor.py</vh></v> | 50 | <v t="ekr.20031218072017.2794"><vh>@file leoColor.py</vh></v> |
138 | 52 | <v t="ekr.20031218072017.2810"><vh>@file leoCommands.py</vh></v> | 51 | <v t="ekr.20031218072017.2810"><vh>@file leoCommands.py</vh></v> |
139 | 53 | <v t="ekr.20041117062700"><vh>@file leoConfig.py</vh></v> | 52 | <v t="ekr.20041117062700"><vh>@file leoConfig.py</vh></v> |
141 | 54 | <v t="ekr.20050710142719" a="E" | 53 | <v t="ekr.20050710142719" |
142 | 55 | expanded="ekr.20050920084036.13,ekr.20100901080826.6002,ekr.20100901080826.6155,ekr.20050920084036.53,ekr.20071114081313,ekr.20080108092811,"><vh>@file leoEditCommands.py</vh></v> | 54 | expanded="ekr.20050920084036.13,ekr.20100901080826.6002,ekr.20100901080826.6155,ekr.20050920084036.53,ekr.20071114081313,ekr.20080108092811,"><vh>@file leoEditCommands.py</vh></v> |
143 | 56 | <v t="ekr.20031218072017.3018"><vh>@file leoFileCommands.py</vh></v> | 55 | <v t="ekr.20031218072017.3018"><vh>@file leoFileCommands.py</vh></v> |
144 | 57 | <v t="ekr.20031218072017.3093" descendentVnodeUnknownAttributes="7d71005506302e31352e3071017d71025808000000616e6e6f7461746571037d710473732e"><vh>@file leoGlobals.py</vh></v> | 56 | <v t="ekr.20031218072017.3093" descendentVnodeUnknownAttributes="7d71005506302e31352e3071017d71025808000000616e6e6f7461746571037d710473732e"><vh>@file leoGlobals.py</vh></v> |
145 | @@ -78,12 +77,13 @@ | |||
146 | 78 | </v> | 77 | </v> |
147 | 79 | <v t="ekr.20110605121601.17862" a="E"><vh>Qt gui</vh> | 78 | <v t="ekr.20110605121601.17862" a="E"><vh>Qt gui</vh> |
148 | 80 | <v t="ekr.20110605121601.17863"><vh>@file ../plugins/baseNativeTree.py</vh></v> | 79 | <v t="ekr.20110605121601.17863"><vh>@file ../plugins/baseNativeTree.py</vh></v> |
150 | 81 | <v t="ekr.20120419093256.10048" a="E" | 80 | <v t="ekr.20120419093256.10048" |
151 | 82 | expanded="ekr.20110318080425.14389,"><vh>@file ../plugins/free_layout.py</vh></v> | 81 | expanded="ekr.20110318080425.14389,"><vh>@file ../plugins/free_layout.py</vh></v> |
153 | 83 | <v t="ekr.20110605121601.17954" a="E" | 82 | <v t="ekr.20110605121601.17954" |
154 | 84 | expanded="tbrown.20120418121002.25711,ekr.20110605121601.17961,ekr.20110605121601.17966,ekr.20110605121601.17969,"><vh>@file ../plugins/nested_splitter.py</vh></v> | 83 | expanded="tbrown.20120418121002.25711,ekr.20110605121601.17961,ekr.20110605121601.17966,ekr.20110605121601.17969,"><vh>@file ../plugins/nested_splitter.py</vh></v> |
155 | 85 | <v t="ekr.20110605121601.17996"><vh>@file ../plugins/qtframecommands.py</vh></v> | 84 | <v t="ekr.20110605121601.17996"><vh>@file ../plugins/qtframecommands.py</vh></v> |
157 | 86 | <v t="ekr.20110605121601.18002" a="E"><vh>@file ../plugins/qtGui.py</vh></v> | 85 | <v t="ekr.20110605121601.18002" a="E" |
158 | 86 | expanded="ekr.20110605121601.18136,ekr.20110605121601.18340,ekr.20110605121601.18342,ekr.20110605121601.18343,ekr.20110605121601.18354,ekr.20110605121601.18361,"><vh>@file ../plugins/qtGui.py</vh></v> | ||
159 | 87 | <v t="ekr.20110605121601.18695"><vh>QDesigner files</vh> | 87 | <v t="ekr.20110605121601.18695"><vh>QDesigner files</vh> |
160 | 88 | <v t="ekr.20110605121601.18696"><vh>@auto ../test/qtui_generate.py</vh></v> | 88 | <v t="ekr.20110605121601.18696"><vh>@auto ../test/qtui_generate.py</vh></v> |
161 | 89 | <v t="ekr.20110605121601.18698"><vh>@auto ../plugins/qt_main.py</vh></v> | 89 | <v t="ekr.20110605121601.18698"><vh>@auto ../plugins/qt_main.py</vh></v> |
162 | 90 | 90 | ||
163 | === modified file 'leo/plugins/leoPluginsRef.leo' | |||
164 | --- leo/plugins/leoPluginsRef.leo 2013-04-20 15:05:19 +0000 | |||
165 | +++ leo/plugins/leoPluginsRef.leo 2013-05-14 14:51:04 +0000 | |||
166 | @@ -58,7 +58,7 @@ | |||
167 | 58 | </v> | 58 | </v> |
168 | 59 | </v> | 59 | </v> |
169 | 60 | </v> | 60 | </v> |
171 | 61 | <v t="ekr.20101110150056.9453"><vh> Qt only plugins</vh> | 61 | <v t="ekr.20101110150056.9453" a="E"><vh> Qt only plugins</vh> |
172 | 62 | <v t="tbrown.20091029123555.5319" descendentVnodeUnknownAttributes="7d71005503302e3571017d710258040000007465737471037d710458050000005f6564697471057d7106580400000074686973710758120000006f6b20686f77206120626f757420746869737108737373732e"><vh>@file attrib_edit.py</vh></v> | 62 | <v t="tbrown.20091029123555.5319" descendentVnodeUnknownAttributes="7d71005503302e3571017d710258040000007465737471037d710458050000005f6564697471057d7106580400000074686973710758120000006f6b20686f77206120626f757420746869737108737373732e"><vh>@file attrib_edit.py</vh></v> |
173 | 63 | <v t="ville.20090310191936.10"><vh>@file colorize_headlines.py</vh></v> | 63 | <v t="ville.20090310191936.10"><vh>@file colorize_headlines.py</vh></v> |
174 | 64 | <v t="ekr.20090701111504.5294"><vh>@file contextmenu.py</vh></v> | 64 | <v t="ekr.20090701111504.5294"><vh>@file contextmenu.py</vh></v> |
175 | @@ -72,7 +72,9 @@ | |||
176 | 72 | <v t="tbrown.20100318101414.5990"><vh>@file viewrendered.py</vh></v> | 72 | <v t="tbrown.20100318101414.5990"><vh>@file viewrendered.py</vh></v> |
177 | 73 | <v t="tbrown.20090206153748.1"><vh>@file graphcanvas.py</vh></v> | 73 | <v t="tbrown.20090206153748.1"><vh>@file graphcanvas.py</vh></v> |
178 | 74 | <v t="ville.20110403115003.10348"><vh>@file valuespace.py</vh></v> | 74 | <v t="ville.20110403115003.10348"><vh>@file valuespace.py</vh></v> |
180 | 75 | <v t="ville.20130127035134.3685"><vh>@file internal_ipkernel.py</vh></v> | 75 | <v t="ville.20130127035134.3685" a="O"><vh>@file internal_ipkernel.py</vh></v> |
181 | 76 | <v t="peckj.20130514093558.4062" a="E" | ||
182 | 77 | expanded="peckj.20130513115943.16249,"><vh>@file printing.py</vh></v> | ||
183 | 76 | <v t="tbrown.20130420091241.44181"><vh>@file screen_capture.py</vh></v> | 78 | <v t="tbrown.20130420091241.44181"><vh>@file screen_capture.py</vh></v> |
184 | 77 | </v> | 79 | </v> |
185 | 78 | <v t="ekr.20100103093121.5365"><vh>Auto completion</vh> | 80 | <v t="ekr.20100103093121.5365"><vh>Auto completion</vh> |
186 | @@ -541,5 +543,6 @@ | |||
187 | 541 | <t tx="ekr.20121126102050.10134"></t> | 543 | <t tx="ekr.20121126102050.10134"></t> |
188 | 542 | <t tx="rogererens.20041130095659">@ It is possible to link to nodes within the same file. However clones might be better. | 544 | <t tx="rogererens.20041130095659">@ It is possible to link to nodes within the same file. However clones might be better. |
189 | 543 | </t> | 545 | </t> |
190 | 546 | <t tx="ville.20130127035134.3685"></t> | ||
191 | 544 | </tnodes> | 547 | </tnodes> |
192 | 545 | </leo_file> | 548 | </leo_file> |
193 | 546 | 549 | ||
194 | === added file 'leo/plugins/printing.py' | |||
195 | --- leo/plugins/printing.py 1970-01-01 00:00:00 +0000 | |||
196 | +++ leo/plugins/printing.py 2013-05-14 14:51:04 +0000 | |||
197 | @@ -0,0 +1,317 @@ | |||
198 | 1 | #@+leo-ver=5-thin | ||
199 | 2 | #@+node:peckj.20130513115943.16246: * @file printing.py | ||
200 | 3 | #@@language python | ||
201 | 4 | #@@tabwidth -4 | ||
202 | 5 | |||
203 | 6 | #@+<< docstring >> | ||
204 | 7 | #@+node:peckj.20130513115943.16252: ** << docstring >> | ||
205 | 8 | '''Supports printing from the Qt GUI. | ||
206 | 9 | |||
207 | 10 | Jacob M. Peck, 2013 | ||
208 | 11 | |||
209 | 12 | Commands | ||
210 | 13 | ======== | ||
211 | 14 | |||
212 | 15 | This plugin supports the following twelve commands: | ||
213 | 16 | |||
214 | 17 | print-selected-node | ||
215 | 18 | ------------------- | ||
216 | 19 | |||
217 | 20 | Opens up the print dialog to print the selected headline and node. | ||
218 | 21 | |||
219 | 22 | print-preview-selected-node | ||
220 | 23 | --------------------------- | ||
221 | 24 | |||
222 | 25 | Opens up the print preview dialog to preview the selected headline | ||
223 | 26 | and node. | ||
224 | 27 | |||
225 | 28 | print-selected-node-body | ||
226 | 29 | ------------------------ | ||
227 | 30 | |||
228 | 31 | Opens up the print dialog to print the selected node body. | ||
229 | 32 | |||
230 | 33 | print-preview-selected-node-body | ||
231 | 34 | -------------------------------- | ||
232 | 35 | |||
233 | 36 | Opens up the print preview dialog to preview the selected node body. | ||
234 | 37 | |||
235 | 38 | print-expanded-node | ||
236 | 39 | ------------------- | ||
237 | 40 | |||
238 | 41 | Opens up the print dialog to print the expanded contents of the | ||
239 | 42 | selected node, with top-level headline. | ||
240 | 43 | |||
241 | 44 | print-preview-expanded-node | ||
242 | 45 | --------------------------- | ||
243 | 46 | |||
244 | 47 | Opens up the print preview dialog to preview the expanded contents | ||
245 | 48 | of theselected node, with top-level headline. | ||
246 | 49 | |||
247 | 50 | print-expanded-node-body | ||
248 | 51 | ------------------------ | ||
249 | 52 | |||
250 | 53 | Opens up the print dialog to print the expanded node body. | ||
251 | 54 | |||
252 | 55 | print-preview-expanded-node-body | ||
253 | 56 | -------------------------------- | ||
254 | 57 | |||
255 | 58 | Opens up the print preview dialog to preview the expanded node | ||
256 | 59 | body. | ||
257 | 60 | |||
258 | 61 | print-marked-nodes | ||
259 | 62 | ------------------ | ||
260 | 63 | |||
261 | 64 | Opens up the print dialog to print all marked nodes in the current | ||
262 | 65 | outline, with headlines. | ||
263 | 66 | |||
264 | 67 | print-preview-marked-nodes | ||
265 | 68 | -------------------------- | ||
266 | 69 | |||
267 | 70 | Opens up the print preview dialog to preview all marked nodes in \ | ||
268 | 71 | the current outline, with headlines. | ||
269 | 72 | |||
270 | 73 | print-marked-node-bodies | ||
271 | 74 | ------------------------ | ||
272 | 75 | |||
273 | 76 | Opens up the print dialog to print the bodies of all marked nodes | ||
274 | 77 | in the current outline. | ||
275 | 78 | |||
276 | 79 | print-preview-marked-node-bodies | ||
277 | 80 | -------------------------------- | ||
278 | 81 | |||
279 | 82 | Opens up the print preview dialog to preview the bodies of all | ||
280 | 83 | marked nodes in the current outline. | ||
281 | 84 | |||
282 | 85 | Settings | ||
283 | 86 | ======== | ||
284 | 87 | |||
285 | 88 | - ``@string printing-font-family = DejaVu Sans Mono`` | ||
286 | 89 | The font family for printing. A monospaced font is recommended. | ||
287 | 90 | |||
288 | 91 | - ``@string printing-font-size = 12`` | ||
289 | 92 | The font size for printing bodies, in px. Due to limitations | ||
290 | 93 | of PyQt, the size of headlines cannot be changed. | ||
291 | 94 | |||
292 | 95 | ''' | ||
293 | 96 | #@-<< docstring >> | ||
294 | 97 | #@+<< version history >> | ||
295 | 98 | #@+node:peckj.20130513115943.16254: ** << version history >> | ||
296 | 99 | #@+at | ||
297 | 100 | # | ||
298 | 101 | # version 0.1 (2013-05-14) - initial release | ||
299 | 102 | # | ||
300 | 103 | #@@c | ||
301 | 104 | #@-<< version history >> | ||
302 | 105 | #@+<< imports >> | ||
303 | 106 | #@+node:peckj.20130513115943.16253: ** << imports >> | ||
304 | 107 | import leo.core.leoGlobals as g | ||
305 | 108 | import leo.plugins.qtGui as qtGui | ||
306 | 109 | from PyQt4 import QtGui | ||
307 | 110 | from PyQt4 import QtCore | ||
308 | 111 | #@-<< imports >> | ||
309 | 112 | |||
310 | 113 | __version__ = '0.1' | ||
311 | 114 | |||
312 | 115 | #@+others | ||
313 | 116 | #@+node:peckj.20130513115943.16247: ** init | ||
314 | 117 | def init (): | ||
315 | 118 | |||
316 | 119 | if g.app.gui is None: | ||
317 | 120 | g.app.createQtGui(__file__) | ||
318 | 121 | |||
319 | 122 | ok = g.app.gui.guiName().startswith('qt') | ||
320 | 123 | |||
321 | 124 | if ok: | ||
322 | 125 | g.registerHandler(('new','open2'),onCreate) | ||
323 | 126 | g.plugin_signon(__name__) | ||
324 | 127 | |||
325 | 128 | return ok | ||
326 | 129 | #@+node:peckj.20130513115943.16248: ** onCreate | ||
327 | 130 | def onCreate (tag, keys): | ||
328 | 131 | |||
329 | 132 | '''Handle the onCreate event in the printing plugin.''' | ||
330 | 133 | |||
331 | 134 | c = keys.get('c') | ||
332 | 135 | |||
333 | 136 | if c: | ||
334 | 137 | pc = printingController(c) | ||
335 | 138 | c.thePrintingController = pc | ||
336 | 139 | |||
337 | 140 | #@+node:peckj.20130513115943.16249: ** class printingController | ||
338 | 141 | class printingController: | ||
339 | 142 | |||
340 | 143 | #@+others | ||
341 | 144 | #@+node:peckj.20130513115943.16250: *3* __init__ | ||
342 | 145 | def __init__ (self,c): | ||
343 | 146 | self.c = c | ||
344 | 147 | |||
345 | 148 | # gather settings | ||
346 | 149 | self.font_size = c.config.getString('printing-font-size') or '12' | ||
347 | 150 | self.font_family = c.config.getString('printing-font-family') or 'DejaVu Sans Mono' | ||
348 | 151 | |||
349 | 152 | # initialize | ||
350 | 153 | self.stylesheet = self.construct_stylesheet() | ||
351 | 154 | |||
352 | 155 | # register commands | ||
353 | 156 | ## selected node | ||
354 | 157 | c.k.registerCommand('print-selected-node-body',shortcut=None,func=self.print_selected_node_body) | ||
355 | 158 | c.k.registerCommand('print-preview-selected-node-body', | ||
356 | 159 | shortcut=None,func=self.print_preview_selected_node_body) | ||
357 | 160 | c.k.registerCommand('print-selected-node',shortcut=None,func=self.print_selected_node) | ||
358 | 161 | c.k.registerCommand('print-preview-selected-node', | ||
359 | 162 | shortcut=None,func=self.print_preview_selected_node) | ||
360 | 163 | ## expanded node | ||
361 | 164 | c.k.registerCommand('print-expanded-node-body',shortcut=None,func=self.print_expanded_node_body) | ||
362 | 165 | c.k.registerCommand('print-preview-expanded-node-body', | ||
363 | 166 | shortcut=None,func=self.print_preview_expanded_node_body) | ||
364 | 167 | c.k.registerCommand('print-expanded-node',shortcut=None,func=self.print_expanded_node) | ||
365 | 168 | c.k.registerCommand('print-preview-expanded-node', | ||
366 | 169 | shortcut=None,func=self.print_preview_expanded_node) | ||
367 | 170 | ## marked nodes | ||
368 | 171 | c.k.registerCommand('print-marked-node-bodies',shortcut=None,func=self.print_marked_node_bodies) | ||
369 | 172 | c.k.registerCommand('print-preview-marked-node-bodies', | ||
370 | 173 | shortcut=None,func=self.print_preview_marked_node_bodies) | ||
371 | 174 | c.k.registerCommand('print-marked-nodes',shortcut=None,func=self.print_marked_nodes) | ||
372 | 175 | c.k.registerCommand('print-preview-marked-nodes', | ||
373 | 176 | shortcut=None,func=self.print_preview_marked_nodes) | ||
374 | 177 | |||
375 | 178 | #@+node:peckj.20130513115943.22457: *3* helpers | ||
376 | 179 | #@+node:peckj.20130513115943.22458: *4* construct stylesheet | ||
377 | 180 | def construct_stylesheet(self): | ||
378 | 181 | s = 'h1 {font-family: %s}\n' % self.font_family | ||
379 | 182 | s += 'pre {font-family: %s; font-size: %spx}' % (self.font_family, self.font_size) | ||
380 | 183 | return s | ||
381 | 184 | #@+node:peckj.20130513115943.22459: *4* construct document | ||
382 | 185 | def construct_document(self, text, head=None): | ||
383 | 186 | doc = QtGui.QTextDocument() | ||
384 | 187 | doc.setDefaultStyleSheet(self.stylesheet) | ||
385 | 188 | text = self.sanitize_html(text) | ||
386 | 189 | if head: | ||
387 | 190 | head = self.sanitize_html(head) | ||
388 | 191 | contents = "<h1>%s</h1>\n<pre>%s</pre>" % (head, text) | ||
389 | 192 | else: | ||
390 | 193 | contents = "<pre>%s<pre>" % text | ||
391 | 194 | doc.setHtml(contents) | ||
392 | 195 | return doc | ||
393 | 196 | #@+node:peckj.20130514082859.5603: *4* construct complex document | ||
394 | 197 | def construct_complex_document(self, nodes, heads=False): | ||
395 | 198 | doc = QtGui.QTextDocument() | ||
396 | 199 | doc.setDefaultStyleSheet(self.stylesheet) | ||
397 | 200 | contents = '' | ||
398 | 201 | for n in nodes: | ||
399 | 202 | if heads: | ||
400 | 203 | contents += '<h1>%s</h1>\n' % (self.sanitize_html(n.h)) | ||
401 | 204 | contents += '<pre>%s</pre>\n' % (self.sanitize_html(n.b)) | ||
402 | 205 | doc.setHtml(contents) | ||
403 | 206 | return doc | ||
404 | 207 | #@+node:peckj.20130513115943.22661: *4* print dialog | ||
405 | 208 | def print_doc(self, doc): | ||
406 | 209 | dialog = QtGui.QPrintDialog() | ||
407 | 210 | if dialog.exec_() == QtGui.QDialog.Accepted: | ||
408 | 211 | doc.print_(dialog.printer()) | ||
409 | 212 | #@+node:peckj.20130513115943.22662: *4* print preview dialog | ||
410 | 213 | def print_preview_doc(self, doc): | ||
411 | 214 | dialog = QtGui.QPrintPreviewDialog() | ||
412 | 215 | dialog.paintRequested.connect(doc.print_) | ||
413 | 216 | dialog.exec_() | ||
414 | 217 | #@+node:peckj.20130514082859.5604: *4* sanitize html | ||
415 | 218 | def sanitize_html(self, html): | ||
416 | 219 | ''' quick and dirty way to make sure html is escaped properly for printing ''' | ||
417 | 220 | return html.replace('&', '&').replace('<', '<').replace('>', '>') | ||
418 | 221 | #@+node:peckj.20130514082859.5610: *4* untangle | ||
419 | 222 | def untangle(self,p): | ||
420 | 223 | return g.getScript(self.c,p, | ||
421 | 224 | useSelectedText=False, | ||
422 | 225 | useSentinels=False) | ||
423 | 226 | #@+node:peckj.20130513115943.22666: *3* selected node | ||
424 | 227 | #@+node:peckj.20130513193024.6336: *4* print_selected_node_body | ||
425 | 228 | def print_selected_node_body (self,event=None): | ||
426 | 229 | ''' prints the selected node body''' | ||
427 | 230 | |||
428 | 231 | doc = self.construct_document(self.c.p.b) | ||
429 | 232 | self.print_doc(doc) | ||
430 | 233 | #@+node:peckj.20130513193024.6337: *4* print_preview_selected_node_body | ||
431 | 234 | def print_preview_selected_node_body (self,event=None): | ||
432 | 235 | ''' print previews the selected node body''' | ||
433 | 236 | |||
434 | 237 | doc = self.construct_document(self.c.p.b) | ||
435 | 238 | self.print_preview_doc(doc) | ||
436 | 239 | #@+node:peckj.20130513115943.16251: *4* print_selected_node | ||
437 | 240 | def print_selected_node (self,event=None): | ||
438 | 241 | ''' prints the selected node ''' | ||
439 | 242 | |||
440 | 243 | doc = self.construct_document(self.c.p.b, head=self.c.p.h) | ||
441 | 244 | self.print_doc(doc) | ||
442 | 245 | #@+node:peckj.20130513115943.22456: *4* print_preview_selected_node | ||
443 | 246 | def print_preview_selected_node (self,event=None): | ||
444 | 247 | ''' prints the selected node ''' | ||
445 | 248 | |||
446 | 249 | doc = self.construct_document(self.c.p.b, head=self.c.p.h) | ||
447 | 250 | self.print_preview_doc(doc) | ||
448 | 251 | #@+node:peckj.20130514082859.5616: *3* expanded selected node | ||
449 | 252 | #@+node:peckj.20130514082859.5617: *4* print_expanded_node_body | ||
450 | 253 | def print_expanded_node_body (self,event=None): | ||
451 | 254 | ''' prints the expanded selected node body ''' | ||
452 | 255 | |||
453 | 256 | doc = self.construct_document(self.untangle(self.c.p)) | ||
454 | 257 | self.print_doc(doc) | ||
455 | 258 | #@+node:peckj.20130514082859.5618: *4* print_preview_expanded_node_body | ||
456 | 259 | def print_preview_expanded_node_body (self,event=None): | ||
457 | 260 | ''' print previews the expanded selected node body''' | ||
458 | 261 | |||
459 | 262 | doc = self.construct_document(self.untangle(self.c.p)) | ||
460 | 263 | self.print_preview_doc(doc) | ||
461 | 264 | #@+node:peckj.20130514082859.5619: *4* print_expanded_node | ||
462 | 265 | def print_expanded_node (self,event=None): | ||
463 | 266 | ''' prints the expanded selected node ''' | ||
464 | 267 | |||
465 | 268 | p = self.c.p | ||
466 | 269 | doc = self.construct_document(self.untangle(p), head=p.h) | ||
467 | 270 | self.print_doc(doc) | ||
468 | 271 | #@+node:peckj.20130514082859.5620: *4* print_preview_expanded_node | ||
469 | 272 | def print_preview_expanded_node (self,event=None): | ||
470 | 273 | ''' prints the expanced selected node ''' | ||
471 | 274 | |||
472 | 275 | p = self.c.p | ||
473 | 276 | doc = self.construct_document(self.untangle(p), head=p.h) | ||
474 | 277 | self.print_preview_doc(doc) | ||
475 | 278 | #@+node:peckj.20130514082859.5605: *3* marked nodes | ||
476 | 279 | #@+node:peckj.20130514082859.5606: *4* print_marked_node_bodies | ||
477 | 280 | def print_marked_node_bodies (self,event=None): | ||
478 | 281 | ''' prints the marked node bodies''' | ||
479 | 282 | nodes = [] | ||
480 | 283 | for n in self.c.all_positions(): | ||
481 | 284 | if n.isMarked(): | ||
482 | 285 | nodes.append(n.v) | ||
483 | 286 | doc = self.construct_complex_document(nodes) | ||
484 | 287 | self.print_doc(doc) | ||
485 | 288 | #@+node:peckj.20130514082859.5607: *4* print_preview_marked_node_bodies | ||
486 | 289 | def print_preview_marked_node_bodies (self,event=None): | ||
487 | 290 | ''' print previews the marked node bodies''' | ||
488 | 291 | nodes = [] | ||
489 | 292 | for n in self.c.all_positions(): | ||
490 | 293 | if n.isMarked(): | ||
491 | 294 | nodes.append(n.v) | ||
492 | 295 | doc = self.construct_complex_document(nodes) | ||
493 | 296 | self.print_preview_doc(doc) | ||
494 | 297 | #@+node:peckj.20130514082859.5608: *4* print_marked_nodes | ||
495 | 298 | def print_marked_nodes (self,event=None): | ||
496 | 299 | ''' prints the marked nodes''' | ||
497 | 300 | nodes = [] | ||
498 | 301 | for n in self.c.all_positions(): | ||
499 | 302 | if n.isMarked(): | ||
500 | 303 | nodes.append(n.v) | ||
501 | 304 | doc = self.construct_complex_document(nodes, heads=True) | ||
502 | 305 | self.print_doc(doc) | ||
503 | 306 | #@+node:peckj.20130514082859.5609: *4* print_preview_marked_nodes | ||
504 | 307 | def print_preview_marked_nodes (self,event=None): | ||
505 | 308 | ''' print previews the marked nodes''' | ||
506 | 309 | nodes = [] | ||
507 | 310 | for n in self.c.all_positions(): | ||
508 | 311 | if n.isMarked(): | ||
509 | 312 | nodes.append(n.v) | ||
510 | 313 | doc = self.construct_complex_document(nodes, heads=True) | ||
511 | 314 | self.print_preview_doc(doc) | ||
512 | 315 | #@-others | ||
513 | 316 | #@-others | ||
514 | 317 | #@-leo |