Skip to content

Commit b3221fc

Browse files
committed
Decoupled CompletionList and MethodCallTip from Scintilla.
- This includes removing the controls from the MainForm, so they can be used in floating panels, dialogs, etc. - Removed Backspace from being a shortcut, it didn't make any sense. - Several UX improvements. - ScintillaControl a bit more similar to newest (old) ScintillaNet control.
1 parent 291625d commit b3221fc

File tree

17 files changed

+2929
-1345
lines changed

17 files changed

+2929
-1345
lines changed

External/Plugins/ASCompletion/Completion/ASComplete.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static public bool OnShortcut(Keys keys, ScintillaControl Sci)
241241
// dot complete
242242
if (keys == (Keys.Control | Keys.Space))
243243
{
244-
if (ASContext.HasContext && ASContext.Context.IsFileValid)
244+
if (ASContext.HasContext && ASContext.Context.IsFileValid && Sci.ContainsFocus)
245245
{
246246
// try to get completion as if we had just typed the previous char
247247
if (OnChar(Sci, Sci.CharAt(Sci.PositionBefore(Sci.CurrentPos)), false))
@@ -257,7 +257,7 @@ static public bool OnShortcut(Keys keys, ScintillaControl Sci)
257257
}
258258
else if (keys == Keys.Back)
259259
{
260-
HandleAddClosingBraces(Sci, Sci.CurrentChar, false);
260+
if (Sci.ContainsFocus) HandleAddClosingBraces(Sci, Sci.CurrentChar, false);
261261
return false;
262262
}
263263
// show calltip
@@ -275,7 +275,8 @@ static public bool OnShortcut(Keys keys, ScintillaControl Sci)
275275
// project types completion
276276
else if (keys == (Keys.Control | Keys.Alt | Keys.Space))
277277
{
278-
if (ASContext.HasContext && ASContext.Context.IsFileValid && !ASContext.Context.Settings.LazyClasspathExploration)
278+
if (ASContext.HasContext && ASContext.Context.IsFileValid &&
279+
!ASContext.Context.Settings.LazyClasspathExploration && Sci.ContainsFocus)
279280
{
280281
int position = Sci.CurrentPos-1;
281282
string tail = GetWordLeft(Sci, ref position);
@@ -1344,7 +1345,7 @@ static private void ShowCalltip(ScintillaControl Sci, int paramIndex, bool force
13441345
prevParam = paramName;
13451346
calltipDetails = UITools.Manager.ShowDetails;
13461347
string text = calltipDef + ASDocumentation.GetTipDetails(calltipMember, paramName);
1347-
UITools.CallTip.CallTipShow(Sci, calltipPos - calltipOffset, text, forceRedraw);
1348+
UITools.CallTip.CallTipShow(calltipPos - calltipOffset, text, forceRedraw);
13481349
}
13491350

13501351
// highlight

External/Plugins/ASCompletion/PluginMain.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,6 @@ private void AddEventHandlers()
747747
PluginBase.MainForm.IgnoredKeys.Add(Keys.Control | Keys.Enter);
748748
PluginBase.MainForm.IgnoredKeys.Add(Keys.Space | Keys.Control | Keys.Alt); // complete project types
749749
PluginBase.MainForm.RegisterShortcutItem("Completion.ShowHelp", Keys.F1);
750-
PluginBase.MainForm.RegisterShortcutItem("Completion.Delete", Keys.Back);
751750

752751
// application events
753752
EventManager.AddEventHandler(this, eventMask);
@@ -913,22 +912,21 @@ private void OnTextChanged(ScintillaControl sender, int position, int length, in
913912
ASContext.OnTextChanged(sender, position, length, linesAdded);
914913
}
915914

916-
private void OnUpdateCallTip(ScintillaControl sci, int position)
915+
private void OnUpdateCallTip(Control control, int position)
917916
{
918-
if (ASComplete.HasCalltip())
919-
{
920-
int pos = sci.CurrentPos - 1;
921-
char c = (char)sci.CharAt(pos);
922-
if ((c == ',' || c == '(') && sci.BaseStyleAt(pos) == 0)
923-
sci.Colourise(0, -1);
924-
ASComplete.HandleFunctionCompletion(sci, false, true);
925-
}
917+
var sci = (ScintillaControl) control;
918+
int pos = sci.CurrentPos - 1;
919+
char c = (char)sci.CharAt(pos);
920+
if ((c == ',' || c == '(') && sci.BaseStyleAt(pos) == 0)
921+
sci.Colourise(0, -1);
922+
if (!ASComplete.HandleFunctionCompletion(sci, false, true))
923+
UITools.CallTip.Hide();
926924
}
927925

928-
private void OnUpdateSimpleTip(ScintillaControl sci, Point mousePosition)
926+
private void OnUpdateSimpleTip(Control sci, Point mousePosition)
929927
{
930928
if (UITools.Tip.Visible)
931-
OnMouseHover(sci, lastHoverPosition);
929+
OnMouseHover((ScintillaNet.ScintillaControl)sci, lastHoverPosition);
932930
}
933931

934932
void timerPosition_Elapsed(object sender, ElapsedEventArgs e)

External/Plugins/BasicCompletion/PluginMain.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
132132
Keys keys = (e as KeyEvent).Value;
133133
if (this.isSupported && keys == (Keys.Control | Keys.Space))
134134
{
135-
String lang = document.SciControl.ConfigurationLanguage;
135+
var sci = document.SciControl;
136+
if (!sci.ContainsFocus) return;
137+
String lang = sci.ConfigurationLanguage;
136138
List<ICompletionListItem> items = this.GetCompletionListItems(lang, document.FileName);
137139
if (items != null && items.Count > 0)
138140
{
139141
items.Sort();
140-
Int32 curPos = document.SciControl.CurrentPos - 1;
141-
String curWord = document.SciControl.GetWordLeft(curPos, false);
142+
Int32 curPos = sci.CurrentPos - 1;
143+
String curWord = sci.GetWordLeft(curPos, false);
142144
if (curWord == null) curWord = String.Empty;
143145
CompletionList.Show(items, false, curWord);
144146
e.Handled = true;

External/Plugins/CssCompletion/PluginMain.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,12 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
126126
case EventType.Keys:
127127
{
128128
Keys keys = (e as KeyEvent).Value;
129-
if (this.IsSupported(document) && keys == (Keys.Control | Keys.Space))
129+
if (this.IsSupported(document) && keys == (Keys.Control | Keys.Space) && completion != null)
130130
{
131-
if (completion != null)
131+
var sci = document.SciControl;
132+
if (sci.ContainsFocus)
132133
{
133-
completion.OnComplete(document.SciControl, document.SciControl.CurrentPos);
134+
completion.OnComplete(sci, sci.CurrentPos);
134135
e.Handled = true;
135136
}
136137
}

External/Plugins/XMLCompletion/XMLComplete.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ public static Boolean OnShortCut(Keys keys)
650650
ITabbedDocument document = PluginBase.MainForm.CurrentDocument;
651651
if (!document.IsEditable) return false;
652652
ScintillaControl sci = document.SciControl;
653+
if (!sci.ContainsFocus) return false;
653654
XMLContextTag ctag = GetXMLContextTag(sci, sci.CurrentPos);
654655
// Starting tag
655656
if (ctag.Tag == null)

FlashDevelop/Docking/TabbedDocument.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ public void AddEditorControls(String file, String text, Int32 codepage)
312312
this.editor.MarkerDeleteAll(2);
313313
this.IsModified = false;
314314
};
315-
this.editor.FocusChanged += new FocusHandler(this.EditorFocusChanged);
316-
this.editor2.FocusChanged += new FocusHandler(this.EditorFocusChanged);
315+
this.editor.GotFocus += EditorFocusChanged;
316+
this.editor2.GotFocus += EditorFocusChanged;
317317
this.editor.UpdateSync += new UpdateSyncHandler(this.EditorUpdateSync);
318318
this.editor2.UpdateSync += new UpdateSyncHandler(this.EditorUpdateSync);
319319
this.Controls.Add(this.splitContainer);
@@ -342,14 +342,11 @@ private void EditorUpdateSync(ScintillaControl sender)
342342
/// <summary>
343343
/// When the user changes to sci, block events from inactive sci
344344
/// </summary>
345-
private void EditorFocusChanged(ScintillaControl sender)
345+
private void EditorFocusChanged(object sender, EventArgs e)
346346
{
347-
if (sender.IsFocus)
348-
{
349-
this.lastEditor = sender;
350-
this.editor.DisableAllSciEvents = (sender == editor2);
351-
this.editor2.DisableAllSciEvents = (sender == editor);
352-
}
347+
this.lastEditor = (ScintillaControl)sender;
348+
this.editor.DisableAllSciEvents = (sender == editor2);
349+
this.editor2.DisableAllSciEvents = (sender == editor);
353350
}
354351

355352
/// <summary>

FlashDevelop/MainForm.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,13 +1522,15 @@ public Boolean PreFilterMessage(ref Message m)
15221522
ITabbedDocument doc = Globals.CurrentDocument;
15231523
if (Control.FromHandle(hWnd) != null)
15241524
{
1525-
Win32.SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
1526-
return true;
1527-
}
1528-
else if (doc != null && doc.IsEditable && (hWnd == doc.SplitSci1.HandleSci || hWnd == doc.SplitSci2.HandleSci))
1529-
{
1530-
Win32.SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
1531-
return true;
1525+
if (hWnd == doc.SplitSci1.Handle || hWnd == doc.SplitSci2.Handle)
1526+
{
1527+
if (doc != null && doc.IsEditable)
1528+
{
1529+
Win32.SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
1530+
return true;
1531+
}
1532+
}
1533+
else return Win32.SendMessage(hWnd, m.Msg, m.WParam, m.LParam) != IntPtr.Zero;
15321534
}
15331535
}
15341536
}

PluginCore/PluginCore.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@
309309
<Compile Include="PluginCore\Controls\Common.cs">
310310
<SubType>Component</SubType>
311311
</Compile>
312+
<Compile Include="PluginCore\Controls\CompletionListControl.cs" />
313+
<Compile Include="PluginCore\Controls\ICompletionListHost.cs" />
314+
<Compile Include="PluginCore\Controls\InactiveForm.cs">
315+
<SubType>Form</SubType>
316+
</Compile>
312317
<Compile Include="PluginCore\Controls\MessageBoxManager.cs" />
313318
<Compile Include="PluginCore\Controls\ScrollBarEx.cs">
314319
<SubType>Component</SubType>

0 commit comments

Comments
 (0)