KDevelop API Documentation

python_colorizer.cpp

Go to the documentation of this file.
00001 /* $Id: python_colorizer.cpp,v 1.12 2002/12/19 22:02:39 raggi Exp $
00002  *
00003  *  This file is part of Klint
00004  *  Copyright (C) 2001 Roberto Raggi (roberto@kdevelop.org)
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; see the file COPYING.  If not, write to
00018  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  *  Boston, MA 02111-1307, USA.
00020  *
00021  */
00022 
00023 
00024 #include "python_colorizer.h"
00025 #include "qeditor.h"
00026 #include "paragdata.h"
00027 
00028 #include <qfont.h>
00029 #include <qapplication.h>
00030 #include <qsettings.h>
00031 #include <private/qrichtext_p.h>
00032 
00033 static const char *python_keywords[] = {
00034   // Python keywords
00035   "and",
00036   "assert",
00037   "break",
00038   "class",
00039   "continue",
00040   "def",
00041   "del",
00042   "elif",
00043   "else",
00044   "except",
00045   "exec",
00046   "finally",
00047   "for",
00048   "from",
00049   "global",
00050   "if",
00051   "import",
00052   "in",
00053   "is",
00054   "lambda",
00055   "not",
00056   "or",
00057   "pass",
00058   "print",
00059   "raise",
00060   "return",
00061   "try",
00062   "while",
00063   0
00064 };
00065 
00066 PythonColorizer::PythonColorizer( QEditor* editor )
00067     : QSourceColorizer( editor )
00068 {
00069     HLItemCollection* context0 = new HLItemCollection( 0 );
00070     context0->appendChild( new StartsWithHLItem( "#", Comment, 0 ) );
00071     context0->appendChild( new WhiteSpacesHLItem( Normal, 0 ) );
00072     context0->appendChild( new StringHLItem( "'''", String, 3 ) );
00073     context0->appendChild( new StringHLItem( "\"\"\"", String, 4 ) );
00074     context0->appendChild( new StringHLItem( "\"", String, 1 ) );
00075     context0->appendChild( new StringHLItem( "'", String, 2 ) );
00076     context0->appendChild( new KeywordsHLItem( python_keywords, Keyword, Normal, 0 ) );
00077     context0->appendChild( new NumberHLItem( Constant, 0 ) );
00078 
00079     HLItemCollection* context1 = new HLItemCollection( String );
00080     context1->appendChild( new StringHLItem( "\\\\", String, 1 ) );
00081     context1->appendChild( new StringHLItem( "\\\"", String, 1 ) );
00082     context1->appendChild( new StringHLItem( "\"", String, 0 ) );
00083 
00084     HLItemCollection* context2 = new HLItemCollection( String );
00085     context2->appendChild( new StringHLItem( "\\'", String, 2 ) );
00086     context2->appendChild( new StringHLItem( "\\\\", String, 2 ) );
00087     context2->appendChild( new StringHLItem( "'", String, 0 ) );
00088 
00089     HLItemCollection* context3 = new HLItemCollection( String );
00090     context3->appendChild( new StringHLItem( "'''", String, 0 ) );
00091 
00092     HLItemCollection* context4 = new HLItemCollection( String );
00093     context4->appendChild( new StringHLItem( "\"\"\"", String, 0 ) );
00094 
00095 
00096     m_items.append( context0 );
00097     m_items.append( context1 );
00098     m_items.append( context2 );
00099     m_items.append( context3 );
00100     m_items.append( context4 );
00101 }
00102 
00103 PythonColorizer::~PythonColorizer()
00104 {
00105 }
00106 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:24 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003