[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdevelop/parts/qeditor
From:       Harald Fernengel <harry () kdevelop ! org>
Date:       2003-04-23 1:07:52
[Download RAW message or body]

CVS commit by harald: 

SQL is totally case insensitive, so add a new flag for case insensitive
highlighting


  M +19 -9     qsourcecolorizer.h   1.17
  M +1 -1      sql_colorizer.cpp   1.2


--- kdevelop/parts/qeditor/qsourcecolorizer.h  #1.16:1.17
@@ -101,14 +101,18 @@ public:
 class KeywordsHLItem: public HLItem{
 public:
-    KeywordsHLItem( const char** keywords, int state, int ide_state, int context, \
                bool finalize = true )
-        : HLItem( state, context ), m_ok(false), m_state(state), \
m_ide_state(ide_state), m_finalize(finalize) { +    KeywordsHLItem( const char** \
keywords, int state, int ide_state, int context, bool finalize = true, bool \
ignoreCase = false ) +        : HLItem( state, context ), m_ok(false), \
m_state(state), m_ide_state(ide_state), m_finalize(finalize), \
m_ignoreCase(ignoreCase) {  int i = 1;
-            while( *keywords ){
+            if ( ignoreCase ) {
+                while( *keywords )
+                    m_keywords.insert( QString(*keywords++).lower(), i++ );
+            } else {
+                while( *keywords )
                 m_keywords.insert( QString(*keywords++), i++ );
             }
     }
         
-    KeywordsHLItem( const QMap<QString, int> keywords, int state, int ide_state, int \
                context, bool finalize = true )
-        : HLItem( state, context ), m_ok(false), m_state(state), \
m_ide_state(ide_state), m_finalize(finalize) { +    KeywordsHLItem( const \
QMap<QString, int> keywords, int state, int ide_state, int context, bool finalize = \
true, bool ignoreCase = false ) +        : HLItem( state, context ), m_ok(false), \
m_state(state), m_ide_state(ide_state), m_finalize(finalize), \
m_ignoreCase(ignoreCase) {  m_keywords = keywords;
     }
@@ -124,6 +128,11 @@ public:
             ++pos;
         
-        if( start_pos != pos )
+        if( start_pos != pos ) {
+            if ( m_ignoreCase ) {
+                m_ok = m_keywords.contains( QString(buffer+start_pos, \
pos-start_pos).lower() ); +            } else {
             m_ok = m_keywords.contains( QString(buffer+start_pos, pos-start_pos) );
+            }
+        }
         
         return ( m_ok || m_finalize ) ? pos : start_pos;
@@ -136,4 +145,5 @@ private:
     int m_ide_state;
     bool m_finalize; //!< setting finalize to false allows to have another \
KeywordsHLItem in HLItemCollection after this one +    bool m_ignoreCase;
 };
 

--- kdevelop/parts/qeditor/sql_colorizer.cpp  #1.1:1.2
@@ -56,5 +56,5 @@ SqlColorizer::SqlColorizer( QEditor* edi
     // default context
     HLItemCollection* context0 = new HLItemCollection( 0 );
-    context0->appendChild( new KeywordsHLItem( sql_keywords, Keyword, Normal, 0 ) );
+    context0->appendChild( new KeywordsHLItem( sql_keywords, Keyword, Normal, 0, \
true, true ) );  context0->appendChild( new StartsWithHLItem( "--", Comment, 0 ) );
     context0->appendChild( new StringHLItem( "'", String, 1 ) );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic