diff options
Diffstat (limited to 'scintilla/src')
-rw-r--r-- | scintilla/src/CharClassify.cxx | 16 | ||||
-rw-r--r-- | scintilla/src/CharClassify.h | 1 | ||||
-rw-r--r-- | scintilla/src/Document.cxx | 6 | ||||
-rw-r--r-- | scintilla/src/Document.h | 1 | ||||
-rw-r--r-- | scintilla/src/Editor.cxx | 16 |
5 files changed, 39 insertions, 1 deletions
diff --git a/scintilla/src/CharClassify.cxx b/scintilla/src/CharClassify.cxx index 89e690d..abe39f8 100644 --- a/scintilla/src/CharClassify.cxx +++ b/scintilla/src/CharClassify.cxx @@ -46,3 +46,19 @@ void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) { }
}
}
+
+int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) {
+ // Get characters belonging to the given char class; return the number
+ // of characters (if the buffer is NULL, don't write to it).
+ int count = 0;
+ for (int ch = maxChar - 1; ch >= 0; --ch) {
+ if (charClass[ch] == characterClass) {
+ ++count;
+ if (buffer) {
+ *buffer = static_cast<unsigned char>(ch);
+ buffer++;
+ }
+ }
+ }
+ return count;
+}
diff --git a/scintilla/src/CharClassify.h b/scintilla/src/CharClassify.h index f4b5aef..4b322a6 100644 --- a/scintilla/src/CharClassify.h +++ b/scintilla/src/CharClassify.h @@ -19,6 +19,7 @@ public: enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation };
void SetDefaultCharClasses(bool includeWordClass);
void SetCharClasses(const unsigned char *chars, cc newCharClass);
+ int GetCharsOfClass(cc charClass, unsigned char *buffer);
cc GetClass(unsigned char ch) const { return static_cast<cc>(charClass[ch]);}
bool IsWord(unsigned char ch) const { return static_cast<cc>(charClass[ch]) == ccWord;}
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index f5ac169..a491aa8 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -751,7 +751,7 @@ void Document::CheckReadOnly() { // SetStyleAt does not change the persistent state of a document
bool Document::DeleteChars(int pos, int len) {
- if (len == 0)
+ if (len <= 0)
return false;
if ((pos + len) > Length())
return false;
@@ -1615,6 +1615,10 @@ void Document::SetCharClasses(const unsigned char *chars, CharClassify::cc newCh charClass.SetCharClasses(chars, newCharClass);
}
+int Document::GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer) {
+ return charClass.GetCharsOfClass(characterClass, buffer);
+}
+
void Document::SetStylingBits(int bits) {
stylingBits = bits;
stylingBitsMask = (1 << stylingBits) - 1;
diff --git a/scintilla/src/Document.h b/scintilla/src/Document.h index dcdafd4..926fb48 100644 --- a/scintilla/src/Document.h +++ b/scintilla/src/Document.h @@ -364,6 +364,7 @@ public: void SetDefaultCharClasses(bool includeWordClass);
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
+ int GetCharsOfClass(CharClassify::cc charClass, unsigned char *buffer);
void SetStylingBits(int bits);
void SCI_METHOD StartStyling(int position, char mask);
bool SCI_METHOD SetStyleFor(int length, char style);
diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 4d3a7ff..24306a4 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -7527,6 +7527,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { caret.period = wParam;
break;
+ case SCI_GETWORDCHARS:
+ return pdoc->GetCharsOfClass(CharClassify::ccWord, reinterpret_cast<unsigned char *>(lParam));
+
case SCI_SETWORDCHARS: {
pdoc->SetDefaultCharClasses(false);
if (lParam == 0)
@@ -7535,6 +7538,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { }
break;
+ case SCI_GETWHITESPACECHARS:
+ return pdoc->GetCharsOfClass(CharClassify::ccSpace, reinterpret_cast<unsigned char *>(lParam));
+
case SCI_SETWHITESPACECHARS: {
if (lParam == 0)
return 0;
@@ -7542,6 +7548,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { }
break;
+ case SCI_GETPUNCTUATIONCHARS:
+ return pdoc->GetCharsOfClass(CharClassify::ccPunctuation, reinterpret_cast<unsigned char *>(lParam));
+
+ case SCI_SETPUNCTUATIONCHARS: {
+ if (lParam == 0)
+ return 0;
+ pdoc->SetCharClasses(reinterpret_cast<unsigned char *>(lParam), CharClassify::ccPunctuation);
+ }
+ break;
+
case SCI_SETCHARSDEFAULT:
pdoc->SetDefaultCharClasses(true);
break;
|