aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AutoComplete.cxx8
-rw-r--r--src/AutoComplete.h2
-rw-r--r--src/Editor.cxx7
-rw-r--r--src/Editor.h1
-rw-r--r--src/ScintillaBase.cxx25
-rw-r--r--src/ScintillaBase.h1
6 files changed, 26 insertions, 18 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index d45ab27a6..f9dbd4d67 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -11,7 +11,6 @@
#include "AutoComplete.h"
AutoComplete::AutoComplete() {
- lb = 0;
active = false;
posStart = 0;
strcpy(stopChars, "");
@@ -54,8 +53,7 @@ char AutoComplete::GetSeparator() {
return separator;
}
-int AutoComplete::SetList(const char *list) {
- int maxStrLen = 12;
+void AutoComplete::SetList(const char *list) {
lb.Clear();
char *words = new char[strlen(list) + 1];
if (words) {
@@ -66,18 +64,15 @@ int AutoComplete::SetList(const char *list) {
if (words[i] == separator) {
words[i] = '\0';
lb.Append(startword);
- maxStrLen = Platform::Maximum(maxStrLen, strlen(startword));
startword = words + i + 1;
}
}
if (startword) {
lb.Append(startword);
- maxStrLen = Platform::Maximum(maxStrLen, strlen(startword));
}
delete []words;
}
lb.Sort();
- return maxStrLen;
}
void AutoComplete::Show() {
@@ -88,7 +83,6 @@ void AutoComplete::Show() {
void AutoComplete::Cancel() {
if (lb.Created()) {
lb.Destroy();
- lb = 0;
active = false;
}
}
diff --git a/src/AutoComplete.h b/src/AutoComplete.h
index 96d061f50..37795fce6 100644
--- a/src/AutoComplete.h
+++ b/src/AutoComplete.h
@@ -35,7 +35,7 @@ public:
char GetSeparator();
// The list string contains a sequence of words separated by the separator character
- int SetList(const char *list);
+ void SetList(const char *list);
void Show();
void Cancel();
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 29037474e..487a4c4f7 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -116,6 +116,7 @@ Editor::~Editor() {
}
void Editor::Finalise() {
+ CancelModes();
}
void Editor::DropGraphics() {
@@ -1950,6 +1951,10 @@ void Editor::LineTranspose() {
}
}
+void Editor::CancelModes() {
+ SetEmptySelection(currentPos);
+}
+
int Editor::KeyCommand(UINT iMessage) {
Point pt = LocationFromPosition(currentPos);
@@ -2069,7 +2074,7 @@ int Editor::KeyCommand(UINT iMessage) {
break;
case SCI_CANCEL: // Cancel any modes - handled in subclass
// Also unselect text
- SetEmptySelection(currentPos);
+ CancelModes();
break;
case SCI_DELETEBACK:
DelCharBack();
diff --git a/src/Editor.h b/src/Editor.h
index c39157747..4f42c80a0 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -246,6 +246,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void PageMove(int direction, bool extend=false);
void ChangeCaseOfSelection(bool makeUpperCase);
void LineTranspose();
+ virtual void CancelModes();
virtual int KeyCommand(UINT iMessage);
virtual int KeyDefault(int /* key */, int /*modifiers*/);
int KeyDown(int key, bool shift, bool ctrl, bool alt);
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index bf1b28394..d381b6739 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -49,6 +49,7 @@ ScintillaBase::~ScintillaBase() {
}
void ScintillaBase::Finalise() {
+ Editor::Finalise();
popup.Destroy();
}
@@ -162,7 +163,7 @@ int ScintillaBase::KeyCommand(UINT iMessage) {
}
void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
- //Platform::DebugPrintf("AutoCOmplete %s\n", list);
+ //Platform::DebugPrintf("AutoComplete %s\n", list);
ct.CallTipCancel();
ac.Start(wDraw, idAutoComplete, currentPos, lenEntered);
@@ -170,7 +171,6 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
PRectangle rcClient = GetClientRectangle();
Point pt = LocationFromPosition(currentPos-lenEntered);
- //Platform::DebugPrintf("Auto complete %x\n", lbAutoComplete);
int heightLB = 100;
int widthLB = 100;
if (pt.x >= rcClient.right - widthLB) {
@@ -193,16 +193,18 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
rcac.right = rcac.left + widthLB;
rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcClient.bottom);
ac.lb.SetPositionRelative(rcac, wMain);
- ac.lb.SetFont(vs.styles[0].font);
+ ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font);
+ ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth);
- int maxStrLen = ac.SetList(list);
+ ac.SetList(list);
// Fiddle the position of the list so it is right next to the target and wide enough for all its strings
- PRectangle rcList = ac.lb.GetPosition();
+ PRectangle rcList = ac.lb.GetDesiredRect();
int heightAlloced = rcList.bottom - rcList.top;
+ widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left);
// Make an allowance for large strings in list
rcList.left = pt.x - 5;
- rcList.right = rcList.left + Platform::Maximum(widthLB, maxStrLen * 8 + 16);
+ rcList.right = rcList.left + widthLB;
if (pt.y >= rcClient.bottom - heightLB && // Wont fit below.
pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above.
rcList.top = pt.y - heightAlloced;
@@ -249,7 +251,7 @@ void ScintillaBase::AutoCompleteChanged(char ch) {
void ScintillaBase::AutoCompleteCompleted() {
int item = ac.lb.GetSelection();
- char selected[200];
+ char selected[1000];
if (item != -1) {
ac.lb.GetValue(item, selected, sizeof(selected));
}
@@ -278,9 +280,14 @@ void ScintillaBase::ContextMenu(Point pt) {
popup.Show(pt, wMain);
}
-void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
+void ScintillaBase::CancelModes() {
AutoCompleteCancel();
ct.CallTipCancel();
+ Editor::CancelModes();
+}
+
+void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
+ CancelModes();
Editor::ButtonDown(pt, curTime, shift, ctrl, alt);
}
@@ -364,7 +371,7 @@ LRESULT ScintillaBase::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (!ct.wCallTip.Created()) {
PRectangle rc = ct.CallTipStart(currentPos, LocationFromPosition(wParam),
reinterpret_cast<char *>(lParam),
- vs.styles[0].fontName, vs.styles[0].size);
+ vs.styles[STYLE_DEFAULT].fontName, vs.styles[STYLE_DEFAULT].size);
// If the call-tip window would be out of the client
// space, adjust so it displays above the text.
PRectangle rcClient = GetClientRectangle();
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index a7aefd8bc..2e7402a1c 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -47,6 +47,7 @@ protected:
virtual void AddCharUTF(char *s, unsigned int len);
void Command(int cmdId);
+ virtual void CancelModes();
virtual int KeyCommand(UINT iMessage);
void AutoCompleteStart(int lenEntered, const char *list);