annotate src/tools/frontends/composition.py @ 699:e819630c6737

plugin text syntaxes: fixed bad parameter order for getParamA
author Goffi <goffi@goffi.org>
date Wed, 13 Nov 2013 14:00:07 +0100
parents 481e0f8ae47c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
691
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
1 #!/usr/bin/python
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
3
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
4 """
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
5 Libervia: a Salut à Toi frontend
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
6 Copyright (C) 2013 Adrien Cossa <souliane@mailoo.org>
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
7
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
9 it under the terms of the GNU Affero General Public License as published by
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
11 (at your option) any later version.
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
12
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
16 GNU Affero General Public License for more details.
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
17
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
18 You should have received a copy of the GNU Affero General Public License
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
20 """
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
21
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
22 # Map the messages recipient types to their properties.
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
23 RECIPIENT_TYPES = {"To": {"desc": "Direct recipients", "optional": False},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
24 "Cc": {"desc": "Carbon copies", "optional": True},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
25 "Bcc": {"desc": "Blind carbon copies", "optional": True}}
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
26
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
27 # Rich text buttons icons and descriptions
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
28 RICH_BUTTONS = {
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
29 "bold": {"tip": "Bold", "icon": "media/icons/dokuwiki/toolbar/16/bold.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
30 "italic": {"tip": "Italic", "icon": "media/icons/dokuwiki/toolbar/16/italic.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
31 "underline": {"tip": "Underline", "icon": "media/icons/dokuwiki/toolbar/16/underline.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
32 "code": {"tip": "Code", "icon": "media/icons/dokuwiki/toolbar/16/mono.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
33 "strikethrough": {"tip": "Strikethrough", "icon": "media/icons/dokuwiki/toolbar/16/strike.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
34 "heading": {"tip": "Heading", "icon": "media/icons/dokuwiki/toolbar/16/hequal.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
35 "numberedlist": {"tip": "Numbered List", "icon": "media/icons/dokuwiki/toolbar/16/ol.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
36 "list": {"tip": "List", "icon": "media/icons/dokuwiki/toolbar/16/ul.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
37 "link": {"tip": "Link", "icon": "media/icons/dokuwiki/toolbar/16/linkextern.png"},
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
38 "horizontalrule": {"tip": "Horizontal rule", "icon": "media/icons/dokuwiki/toolbar/16/hr.png"}
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
39 }
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
40
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
41 # Define here your rich text formats, the key must match the ones used in button.
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
42 # Tupples values must have 3 elements : prefix to the selection or cursor
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
43 # position, sample text to write if the marker is not applied on a selection,
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
44 # suffix to the selection or cursor position.
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
45 # FIXME: must not be hard-coded like this
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
46 RICH_FORMATS = {"markdown": {"bold": ("**", "bold", "**"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
47 "italic": ("*", "italic", "*"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
48 "code": ("`", "code", "`"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
49 "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
50 "list": ("\n* ", "item", "\n + subitem\n"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
51 "link": ("[desc](", "link", ")"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
52 "horizontalrule": ("\n***\n", "", "")
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
53 },
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
54 "bbcode": {"bold": ("[b]", "bold", "[/b]"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
55 "italic": ("[i]", "italic", "[/i]"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
56 "underline": ("[u]", "underline", "[/u]"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
57 "strikethrough": ("[s]", "strikethrough", "[/s]"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
58 "code": ("[code]", "code", "[/code]"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
59 "link": ("[url=", "link", "]desc[/url]"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
60 "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n")
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
61 },
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
62 "dokuwiki": {"bold": ("**", "bold", "**"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
63 "italic": ("//", "italic", "//"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
64 "underline": ("__", "underline", "__"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
65 "strikethrough": ("<del>", "strikethrough", "</del>"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
66 "code": ("<code>", "code", "</code>"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
67 "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
68 "link": ("[[", "link", "|desc]]"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
69 "list": ("\n * ", "item\n", "\n * subitem\n"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
70 "horizontalrule": ("\n----\n", "", "")
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
71 },
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
72 "XHTML": {"bold": ("<b>", "bold", "</b>"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
73 "italic": ("<i>", "italic", "</i>"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
74 "underline": ("<u>", "underline", "</u>"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
75 "strikethrough": ("<s>", "strikethrough", "</s>"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
76 "code": ("<pre>", "code", "</pre>"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
77 "heading": ("\n<h3>", "Heading 1", "</h3>\n<h4>Heading 2</h4>\n"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
78 "link": ("<a href=\"", "link", "\">desc</a>"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
79 "list": ("\n<ul><li>", "item 1", "</li><li>item 2</li></ul>\n"),
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
80 "horizontalrule": ("\n<hr/>\n", "", "")
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
81 }
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
82
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
83 }
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
84
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
85 # These values should be equal to the ones in plugin_misc_text_syntaxes
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
86 # FIXME: should the plugin import them from here to avoid duplicity? Importing
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
87 # the plugin's values from here is not possible because Libervia would fail.
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
88 PARAM_KEY_COMPOSITION = "Composition"
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
89 PARAM_NAME_SYNTAX = "Syntax"
481e0f8ae47c tools frontend: moved here from Libervia some definitions for message composition
souliane <souliane@mailoo.org>
parents:
diff changeset
90