aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface3
-rw-r--r--src/Document.cxx48
-rw-r--r--src/Editor.cxx4
4 files changed, 10 insertions, 46 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 44a608d9f..30e50c608 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -568,6 +568,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_WORDRIGHTEND 2441
#define SCI_WORDRIGHTENDEXTEND 2442
#define SCI_SETWHITESPACECHARS 2443
+#define SCI_SETCHARSDEFAULT 2444
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCI_SETLEXER 4001
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 93173d07e..6f1d52a9d 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1541,6 +1541,9 @@ fun void WordRightEndExtend=2442(,)
# Set the set of characters making up whitespace for when moving or selecting by word.
set void SetWhitespaceChars=2443(, string characters)
+# Reset the set of characters for whitespace and word characters to the defaults.
+fun void SetCharsDefault=2444(,)
+
# Start notifying the container of all key presses and commands.
fun void StartRecord=3001(,)
diff --git a/src/Document.cxx b/src/Document.cxx
index 53d01d2b8..0320fcb7f 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1119,11 +1119,9 @@ void Document::ChangeCase(Range r, bool makeUpperCase) {
}
}
-
void Document::SetDefaultCharClasses() {
- int ch;
// Initialize all char classes to default values
- for (ch = 0; ch < 256; ch++) {
+ for (int ch = 0; ch < 256; ch++) {
if (ch == '\r' || ch == '\n')
charClass[ch] = ccNewLine;
else if (ch < 0x20 || ch == ' ')
@@ -1136,57 +1134,15 @@ void Document::SetDefaultCharClasses() {
}
void Document::SetCharClasses(unsigned char *chars, charClassification newCharClass) {
- int ch;
- // The old code always reset all chars to their default charClass and then applied the new charClass
- // to a specific set of chars, so the most reasonable way to honour the old promise is to reset all chars
- // that currently are of class newCharClass, and then apply the newCharClass to any specified chars. Remember,
- // the point is to allow the caller to explicitly define all chars which are to be of class newCharClass.
- // The only other tricky thing is that the old promise was that if the user passes in NULL for the chars
- // parameter, we are supposed to reset all chars that default to newCharClass, which is not the
- // same as resetting the char class of any chars that are currently of newCharClass (user might have altered
- // some char classes from their default class).
-
- // If all of that seems a little complex, well, it is. If we could break the old promise and make some
- // simplifying assumptions, this would all be waaaaay simpler. This way though, Scintilla will do the right
- // thing if lots of changes of charClass are applied during the lifetime of the Document object (not very likely,
- // but as long as I'm doing this, might as well get it right).
-
- // So, first reset the char class of any chars that are currently of the class newCharClass
- for (ch = 0; ch < 256; ch++) {
- if (charClass[ch] == newCharClass) {
- if (ch == '\r' || ch == '\n')
- charClass[ch] = ccNewLine;
- else if (ch < 0x20 || ch == ' ')
- charClass[ch] = ccSpace;
- else if (ch >= 0x80 || isalnum(ch) || ch == '_')
- charClass[ch] = ccWord;
- else
- charClass[ch] = ccPunctuation;
- }
- }
-
- // Next, apply the newCharClass to the specifed chars
+ // Apply the newCharClass to the specifed chars
if (chars) {
while (*chars) {
charClass[*chars] = newCharClass;
chars++;
}
- } else {
- // If user passed NULL for chars, reinitialize only the specified class of chars
- for (ch = 0; ch < 256; ch++) {
- if ((ch == '\r' || ch == '\n') && newCharClass == ccNewLine)
- charClass[ch] = ccNewLine;
- else if ((ch < 0x20 || ch == ' ') && newCharClass == ccSpace)
- charClass[ch] = ccSpace;
- else if ((ch >= 0x80 || isalnum(ch) || ch == '_') && newCharClass == ccWord)
- charClass[ch] = ccWord;
- else if (newCharClass == ccPunctuation)
- charClass[ch] = ccPunctuation;
- }
}
}
-
void Document::SetStylingBits(int bits) {
stylingBits = bits;
stylingBitsMask = 0;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index c4e6860e9..897680833 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5744,6 +5744,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
+ case SCI_SETCHARSDEFAULT:
+ pdoc->SetDefaultCharClasses();
+ break;
+
case SCI_GETLENGTH:
return pdoc->Length();