aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2002-01-13 01:10:10 +0000
committernyamatongwe <devnull@localhost>2002-01-13 01:10:10 +0000
commit7b0c5a98abfcd122f2f88d55b3c1b09391a1af8a (patch)
tree7a1bd0b59cc23e517090aed5a2616b4f0a2126ed /src
parent3b8295dbe789457385284beafd3e8bd36359895a (diff)
downloadscintilla-mirror-7b0c5a98abfcd122f2f88d55b3c1b09391a1af8a.tar.gz
Added option to autocompletion AutoCSetDropRestOfWord which removes any
word characters following an insertion made by auto-completion. Bundled the changes made by an autocompletion into one undo action.
Diffstat (limited to 'src')
-rw-r--r--src/AutoComplete.cxx3
-rw-r--r--src/AutoComplete.h1
-rw-r--r--src/Document.cxx9
-rw-r--r--src/Document.h2
-rw-r--r--src/ScintillaBase.cxx24
5 files changed, 28 insertions, 11 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index 7f7412e43..f67d42b0b 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -22,7 +22,8 @@ AutoComplete::AutoComplete() :
posStart(0),
startLen(0),
cancelAtStartPos(true),
- autoHide(true) {
+ autoHide(true),
+ dropRestOfWord(false) {
stopChars[0] = '\0';
fillUpChars[0] = '\0';
}
diff --git a/src/AutoComplete.h b/src/AutoComplete.h
index 79d467529..80dc95dc0 100644
--- a/src/AutoComplete.h
+++ b/src/AutoComplete.h
@@ -25,6 +25,7 @@ public:
/// Should autocompletion be canceled if editor's currentPos <= startPos?
bool cancelAtStartPos;
bool autoHide;
+ bool dropRestOfWord;
AutoComplete();
~AutoComplete();
diff --git a/src/Document.cxx b/src/Document.cxx
index 8483d86f1..b7acc8610 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -722,13 +722,16 @@ Document::charClassification Document::WordCharClass(unsigned char ch) {
* Used by commmands that want to select whole words.
* Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0.
*/
-int Document::ExtendWordSelect(int pos, int delta) {
+int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) {
+ charClassification ccStart = ccWord;
if (delta < 0) {
- charClassification ccStart = WordCharClass(cb.CharAt(pos-1));
+ if (!onlyWordCharacters)
+ ccStart = WordCharClass(cb.CharAt(pos-1));
while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))
pos--;
} else {
- charClassification ccStart = WordCharClass(cb.CharAt(pos));
+ if (!onlyWordCharacters)
+ ccStart = WordCharClass(cb.CharAt(pos));
while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
pos++;
}
diff --git a/src/Document.h b/src/Document.h
index 09814fec8..51cfa9d53 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -177,7 +177,7 @@ public:
int GetFoldParent(int line);
void Indent(bool forwards);
- int ExtendWordSelect(int pos, int delta);
+ int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
int NextWordStart(int pos, int delta);
int Length() { return cb.Length(); }
long FindText(int minPos, int maxPos, const char *s,
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 2994f42db..4a9b87670 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -307,14 +307,18 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {
scn.lParam = 0;
scn.text = userListSelected.c_str();
NotifyParent(scn);
- return ;
+ return;
}
Position firstPos = ac.posStart - ac.startLen;
- if (currentPos < firstPos)
- return ;
- if (currentPos != firstPos) {
- pdoc->DeleteChars(firstPos, currentPos - firstPos);
+ Position endPos = currentPos;
+ if (ac.dropRestOfWord)
+ endPos = pdoc->ExtendWordSelect(endPos, 1, true);
+ if (endPos < firstPos)
+ return;
+ pdoc->BeginUndoAction();
+ if (endPos != firstPos) {
+ pdoc->DeleteChars(firstPos, endPos - firstPos);
}
SetEmptySelection(ac.posStart);
if (item != -1) {
@@ -324,6 +328,7 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {
pdoc->InsertString(firstPos, piece.c_str());
SetEmptySelection(firstPos + piece.length());
}
+ pdoc->EndUndoAction();
}
void ScintillaBase::ContextMenu(Point pt) {
@@ -404,7 +409,7 @@ void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0);
endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0);
Colourise(endStyled, endStyleNeeded);
- return ;
+ return;
}
#endif
Editor::NotifyStyleToNeeded(endStyleNeeded);
@@ -483,6 +488,13 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
case SCI_AUTOCGETAUTOHIDE:
return ac.autoHide;
+ case SCI_AUTOCSETDROPRESTOFWORD:
+ ac.dropRestOfWord = wParam != 0;
+ break;
+
+ case SCI_AUTOCGETDROPRESTOFWORD:
+ return ac.dropRestOfWord;
+
case SCI_CALLTIPSHOW: {
AutoCompleteCancel();
if (!ct.wCallTip.Created()) {