~brian-sidebotham/wxwidgets-cmake/wxpython-2.9.4

« back to all changes in this revision

Viewing changes to wxPython/wx/tools/Editra/src/syntax/_latex.py

  • Committer: Brian Sidebotham
  • Date: 2013-08-03 14:30:08 UTC
  • Revision ID: brian.sidebotham@gmail.com-20130803143008-c7806tkych1tp6fc
Initial import into Bazaar

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###############################################################################
 
2
# Name: latex.py                                                              #
 
3
# Purpose: Define TeX/LateX syntax for highlighting and other features        #
 
4
# Author: Cody Precord <cprecord@editra.org>                                  #
 
5
# Copyright: (c) 2007 Cody Precord <staff@editra.org>                         #
 
6
# License: wxWindows License                                                  #
 
7
###############################################################################
 
8
 
 
9
"""
 
10
FILE: latex.py
 
11
AUTHOR: Cody Precord
 
12
@summary: Lexer configuration module for Tex/LaTex.
 
13
@todo: Fairly poor needs lots of work.
 
14
 
 
15
"""
 
16
 
 
17
__author__ = "Cody Precord <cprecord@editra.org>"
 
18
__svnid__ = "$Id: _latex.py 68798 2011-08-20 17:17:05Z CJP $"
 
19
__revision__ = "$Revision: 68798 $"
 
20
 
 
21
#-----------------------------------------------------------------------------#
 
22
# Imports
 
23
import wx.stc as stc
 
24
 
 
25
# Local Imports
 
26
import synglob
 
27
import syndata
 
28
 
 
29
#-----------------------------------------------------------------------------#
 
30
 
 
31
#---- Keyword Specifications ----#
 
32
 
 
33
# Tex Keywords
 
34
TEX_KW = (0, "Downarrow backslash lceil rceil Uparrow downarrow lfloor rfloor "
 
35
             "Updownarrow langle rangle Vert")
 
36
# ConTeXt Dutch
 
37
DUTCH = (1, "")
 
38
# ConTeXt English
 
39
ENG = (2, "")
 
40
# ConTeXt German
 
41
GERMAN = (3, "")
 
42
# ConTeXt Czech
 
43
CZECH = (4, "")
 
44
# ConTeXt Italian
 
45
ITALIAN = (5, "")
 
46
# ConTeXt Romanian
 
47
ROMAINIAN = (6, "")
 
48
 
 
49
# LaTeXt
 
50
# There are no keyword settings available for LaTeX
 
51
 
 
52
#---- Syntax Style Specs ----#
 
53
# TeX
 
54
SYNTAX_ITEMS1 = [(stc.STC_TEX_DEFAULT, 'default_style'),
 
55
                 (stc.STC_TEX_COMMAND, 'keyword_style'),
 
56
                 (stc.STC_TEX_GROUP, 'scalar_style'),
 
57
                 (stc.STC_TEX_SPECIAL, 'operator_style'),
 
58
                 (stc.STC_TEX_SYMBOL, 'number_style'),
 
59
                 (stc.STC_TEX_TEXT, 'default_style') ]
 
60
 
 
61
# LaTeX
 
62
SYNTAX_ITEMS2 = [(stc.STC_L_DEFAULT, 'default_style'),
 
63
                 (stc.STC_L_COMMAND, 'pre_style'),
 
64
                 (stc.STC_L_COMMENT, 'comment_style'),
 
65
                 (stc.STC_L_MATH, 'operator_style'),
 
66
                 (stc.STC_L_TAG, 'keyword_style')]
 
67
 
 
68
#-----------------------------------------------------------------------------#
 
69
 
 
70
class SyntaxData(syndata.SyntaxDataBase):
 
71
    """SyntaxData object for LaTeX/TeX""" 
 
72
    def __init__(self, langid):
 
73
        super(SyntaxData, self).__init__(langid)
 
74
 
 
75
        # Setup
 
76
        # TODO: change to LEX_TEX for TeX?
 
77
        if self.LangId == synglob.ID_LANG_LATEX:
 
78
            self.SetLexer(stc.STC_LEX_LATEX)
 
79
        else:
 
80
            self.SetLexer(stc.STC_LEX_TEX)
 
81
 
 
82
    def GetKeywords(self):
 
83
        """Returns Specified Keywords List """
 
84
        return [TEX_KW]
 
85
 
 
86
    def GetSyntaxSpec(self):
 
87
        """Syntax Specifications """
 
88
        if self.LangId == synglob.ID_LANG_TEX:
 
89
            return SYNTAX_ITEMS1
 
90
        else:
 
91
            return SYNTAX_ITEMS2
 
92
 
 
93
    def GetCommentPattern(self):
 
94
        """Returns a list of characters used to comment a block of code """
 
95
        return [u'%']