Update of /cvsroot/mahogany/M/src/modules/viewflt
In directory sc8-pr-cvs1:/tmp/cvs-serv12019/src/modules/viewflt
Modified Files:
TextMarkup.cpp
Log Message:
don't highlight *...* and _..._ inside the words
Index: TextMarkup.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/viewflt/TextMarkup.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -u -2 -r1.1 -r1.2
--- TextMarkup.cpp 5 Dec 2002 20:46:42 -0000 1.1
+++ TextMarkup.cpp 6 Dec 2002 16:51:23 -0000 1.2
@@ -63,4 +63,5 @@
"(c) 2002 Vadim Zeitlin <[EMAIL PROTECTED]>");
+// render all the words surrounded by asterisks/underscores in bold/italic font
void
TextMarkupFilter::DoProcess(String& text,
@@ -77,8 +78,14 @@
// the '*' or '_' last encountered
wxChar chLastSpecial = _T('\0'); // unneeded but silence compiler warning
+
+ // are we at the start of a new word?
+ bool atWordStart = true;
+
String textNormal,
textSpecial;
for ( const wxChar *pc = text.c_str(); ; pc++ )
{
+ bool isSpace = false;
+
switch ( *pc )
{
@@ -87,11 +94,23 @@
if ( state == Normal )
{
+ // is it at start of a word?
+ if ( atWordStart )
+ {
+ // yes: treat it as a markup character
+
// output the normal text we had so far
m_next->Process(textNormal, viewer, style);
textNormal.clear();
+ // change state
chLastSpecial = *pc;
state = chLastSpecial == _T('*') ? Bold : Italic;
}
+ else // no, it's in the middle of the word
+ {
+ // treat it as a normal character then;
+ textNormal += *pc;
+ }
+ }
else // ending markup tag?
{
@@ -127,7 +146,10 @@
case _T('\r'):
case _T('\n'):
+ isSpace = true;
+ // fall through
+
case _T('\0'):
- // as a space can't appear inside the marked up word, we decide
- // that the last special character wasn't mean to begin the markup
+ // as a space can't appear inside a marked up word, we decide
+ // that the last special character wasn't meant to begin the markup
// after all
if ( state != Normal )
@@ -152,4 +174,6 @@
break;
}
+
+ atWordStart = isSpace;
}
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates