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

List:       kwrite-devel
Subject:    [Bug 113033] S&S style indenting sometimes behaves incorrectly with
From:       Tim Hutt <tdh29 () cam ! ac ! uk>
Date:       2006-08-18 14:48:25
Message-ID: 20060818144825.30475.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=113033         




------- Additional Comments From tdh29 cam ac uk  2006-08-18 16:48 -------
Well there are the following class cases:

   class QWidget : QObject

   label_class:

   label_class :

   classy_label:

So after thinking I will change it so that if the first whitespace delimited 'word' \
is 'class', then it returns false. Which makes all of the above cases work (I think).

Haven't compiled/tested this yet:

bool KateCSAndSIndent::startsWithLabel( int line ) 
{ 
   // Get the current line. 
   KateTextLine::Ptr indentLine = doc->plainKateTextLine(line); 
   const int indentFirst = indentLine->firstChar(); 
 
   // Not entirely sure what this check does. 
   int attrib = indentLine->attribute(indentFirst); 
   if (attrib != 0 && attrib != keywordAttrib && attrib != normalAttrib && attrib != \
extensionAttrib)   return false; 
 
   // Get the line text. 
   const QString lineContents = indentLine->string();
   const int indentLast = indentLine->lastChar();
   bool whitespaceFound = false;
   for ( int n = indentFirst; n <= indentLast; ++n ) 
   { 
     // Get the character as latin1. Can't use QChar::isLetterOrNumber() as that \
includes non 0-9 numbers.   char c = lineContents[n].toLatin1(); 
     if ( c == ':' ) 
     { 
       // See if the next character is ':' - if so, skip to the character after it. 
       if ( n < lineContents.length() - 1 ) 
       { 
         if ( lineContents[n+1].toLatin1() == ':' ) 
         { 
           n += 2; 
           continue; 
         }
       }
       // Right this is the relevent ':'. 
       if ( n == indentFirst)
       { 
         // Just a line with a : on it.
         return false;
       } 
       // It is a label of some kind! 
       return true;
     }
     if (isspace(c))
     {
       if (!whitespaceFound)
       {
         if (lineContents.mid(indentFirst, n - indentFirst) == "class")
           return false;
         whitespaceFound = true;
       }
     }
     // All other characters don't indent. 
     else if ( !isalnum(c) && c != '_' )
     { 
       return false; 
     } 
   } 
   return false; 
}
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


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

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