[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kate
From: Joseph Wenninger <kde () jowenn ! at>
Date: 2005-04-20 12:34:09
Message-ID: 20050420123409.11AF05FA () office ! kde ! org
[Download RAW message or body]
CVS commit by jowenn:
add comment markers infront of the first non whitespace character in python
M +1 -1 data/python.xml 1.26
M +15 -3 part/katedocument.cpp 1.819
M +18 -10 part/katehighlight.cpp 1.221
M +14 -0 part/katehighlight.h 1.88
--- kdelibs/kate/data/python.xml #1.25:1.26
@@ -227,5 +227,5 @@
<folding indentationsensitive="1" />
<comments>
- <comment name="singleLine" start="#" />
+ <comment name="singleLine" start="#" position="afterwhitespace"/>
</comments>
<keywords casesensitive="1" />
--- kdelibs/kate/part/katedocument.cpp #1.818:1.819
@@ -3393,6 +3393,17 @@ bool KateDocument::removeStringFromEnd(i
void KateDocument::addStartLineCommentToSingleLine( int line, int attrib )
{
+ if (highlight()->getCommentSingleLinePosition(attrib)==KateHighlighting::CSLPosColumn0)
+ {
QString commentLineMark = highlight()->getCommentSingleLineStart( attrib ) + " ";
insertText (line, 0, commentLineMark);
+ }
+ else
+ {
+ QString commentLineMark=highlight()->getCommentSingleLineStart(attrib);
+ KateTextLine::Ptr l = m_buffer->line(line);
+ int pos=l->firstChar();
+ if (pos >=0)
+ insertText(line,pos,commentLineMark);
+ }
}
@@ -3526,5 +3537,6 @@ void KateDocument::addStartLineCommentTo
// For each line of the selection
for (int z = el; z >= sl; z--) {
- insertText (z, 0, commentLineMark);
+ //insertText (z, 0, commentLineMark);
+ addStartLineCommentToSingleLine(z, attrib );
}
--- kdelibs/kate/part/katehighlight.cpp #1.220:1.221
@@ -2117,4 +2117,10 @@ QString KateHighlighting::getCommentSing
}
+KateHighlighting::CSLPos KateHighlighting::getCommentSingleLinePosition( int attrib \
) const +{
+ return m_additionalData[ hlKeyForAttrib( attrib) ]->singleLineCommentPosition;
+}
+
+
/**
* Helper for makeContextList. It parses the xml file for
@@ -2126,5 +2132,6 @@ void KateHighlighting::readCommentConfig
KateSyntaxContextData \
*data=KateHlManager::self()->syntax->getGroupInfo("general","comment");
- QString cmlStart, cmlEnd, cmlRegion, cslStart ;
+ QString cmlStart="", cmlEnd="", cmlRegion="", cslStart="";
+ CSLPos cslPosition=CSLPosColumn0;
if (data)
@@ -2133,7 +2140,13 @@ void KateHighlighting::readCommentConfig
{
if (KateHlManager::self()->syntax->groupData(data,"name")=="singleLine")
+ {
cslStart=KateHlManager::self()->syntax->groupData(data,"start");
-
- if (KateHlManager::self()->syntax->groupData(data,"name")=="multiLine")
+ QString cslpos=KateHlManager::self()->syntax->groupData(data,"position");
+ if (cslpos=="afterwhitespace")
+ cslPosition=CSLPosAfterWhitespace;
+ else
+ cslPosition=CSLPosColumn0;
+ }
+ else if (KateHlManager::self()->syntax->groupData(data,"name")=="multiLine")
{
cmlStart=KateHlManager::self()->syntax->groupData(data,"start");
@@ -2145,12 +2158,7 @@ void KateHighlighting::readCommentConfig
KateHlManager::self()->syntax->freeGroupInfo(data);
}
- else
- {
- cslStart = "";
- cmlStart = "";
- cmlEnd = "";
- cmlRegion = "";
- }
+
m_additionalData[buildIdentifier]->singleLineCommentMarker = cslStart;
+ m_additionalData[buildIdentifier]->singleLineCommentPosition = cslPosition;
m_additionalData[buildIdentifier]->multiLineCommentStart = cmlStart;
m_additionalData[buildIdentifier]->multiLineCommentEnd = cmlEnd;
--- kdelibs/kate/part/katehighlight.h #1.87:1.88
@@ -185,4 +185,16 @@ class KateHighlighting
QString getCommentSingleLineStart( int attrib=0 ) const;
+
+ /**
+ * This enum is used for storing the information where a single line comment \
marker should be inserted + */
+ enum CSLPos { CSLPosColumn0=0,CSLPosAfterWhitespace=1};
+
+ /**
+ * @return the single comment marker position for the highlight corresponding
+ * to @p attrib.
+ */
+ CSLPos getCommentSingleLinePosition( int attrib=0 ) const;
+
/**
* @return the attribute for @p context.
@@ -297,4 +310,5 @@ class KateHighlighting
QString multiLineCommentEnd;
QString multiLineRegion;
+ CSLPos singleLineCommentPosition;
QString deliminator;
QString wordWrapDeliminator;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic