Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoupled CompletionList and MethodCallTip from Scintilla. #1026

Open
wants to merge 7 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions External/Plugins/ASCompletion/Completion/ASComplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ static public bool OnShortcut(Keys keys, ScintillaControl Sci)
// dot complete
if (keys == (Keys.Control | Keys.Space))
{
if (ASContext.HasContext && ASContext.Context.IsFileValid)
if (ASContext.HasContext && ASContext.Context.IsFileValid && Sci.ContainsFocus)
{
// try to get completion as if we had just typed the previous char
if (OnChar(Sci, Sci.CharAt(Sci.PositionBefore(Sci.CurrentPos)), false))
Expand All @@ -258,7 +258,7 @@ static public bool OnShortcut(Keys keys, ScintillaControl Sci)
}
else if (keys == Keys.Back)
{
HandleAddClosingBraces(Sci, Sci.CurrentChar, false);
if (Sci.ContainsFocus) HandleAddClosingBraces(Sci, Sci.CurrentChar, false);
return false;
}
// show calltip
Expand All @@ -276,7 +276,8 @@ static public bool OnShortcut(Keys keys, ScintillaControl Sci)
// project types completion
else if (keys == (Keys.Control | Keys.Alt | Keys.Space))
{
if (ASContext.HasContext && ASContext.Context.IsFileValid && !ASContext.Context.Settings.LazyClasspathExploration)
if (ASContext.HasContext && ASContext.Context.IsFileValid &&
!ASContext.Context.Settings.LazyClasspathExploration && Sci.ContainsFocus)
{
int position = Sci.CurrentPos-1;
string tail = GetWordLeft(Sci, ref position);
Expand Down Expand Up @@ -1332,7 +1333,7 @@ static private void ShowCalltip(ScintillaControl Sci, int paramIndex, bool force
prevParam = paramName;
calltipDetails = UITools.Manager.ShowDetails;
string text = calltipDef + ASDocumentation.GetTipDetails(calltipMember, paramName);
UITools.CallTip.CallTipShow(Sci, calltipPos - calltipOffset, text, forceRedraw);
UITools.CallTip.CallTipShow(calltipPos - calltipOffset, text, forceRedraw);
}

// highlight
Expand Down Expand Up @@ -4610,4 +4611,4 @@ public sealed class ResolvedContext
public ClassModel TokenType;
}
#endregion
}
}
21 changes: 10 additions & 11 deletions External/Plugins/ASCompletion/PluginMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -921,22 +921,21 @@ private void OnTextChanged(ScintillaControl sender, int position, int length, in
ASContext.OnTextChanged(sender, position, length, linesAdded);
}

private void OnUpdateCallTip(ScintillaControl sci, int position)
private void OnUpdateCallTip(Control control, int position)
{
if (ASComplete.HasCalltip())
{
int pos = sci.CurrentPos - 1;
char c = (char)sci.CharAt(pos);
if ((c == ',' || c == '(') && sci.BaseStyleAt(pos) == 0)
sci.Colourise(0, -1);
ASComplete.HandleFunctionCompletion(sci, false, true);
}
var sci = (ScintillaControl) control;
int pos = sci.CurrentPos - 1;
char c = (char)sci.CharAt(pos);
if ((c == ',' || c == '(') && sci.BaseStyleAt(pos) == 0)
sci.Colourise(0, -1);
if (!ASComplete.HandleFunctionCompletion(sci, false, true))
UITools.CallTip.Hide();
}

private void OnUpdateSimpleTip(ScintillaControl sci, Point mousePosition)
private void OnUpdateSimpleTip(Control sci, Point mousePosition)
{
if (UITools.Tip.Visible)
OnMouseHover(sci, lastHoverPosition);
OnMouseHover((ScintillaNet.ScintillaControl)sci, lastHoverPosition);
}

void timerPosition_Elapsed(object sender, ElapsedEventArgs e)
Expand Down
8 changes: 5 additions & 3 deletions External/Plugins/BasicCompletion/PluginMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
Keys keys = (e as KeyEvent).Value;
if (this.isSupported && keys == (Keys.Control | Keys.Space))
{
String lang = document.SciControl.ConfigurationLanguage;
var sci = document.SciControl;
if (!sci.ContainsFocus) return;
String lang = sci.ConfigurationLanguage;
List<ICompletionListItem> items = this.GetCompletionListItems(lang, document.FileName);
if (items != null && items.Count > 0)
{
items.Sort();
Int32 curPos = document.SciControl.CurrentPos - 1;
String curWord = document.SciControl.GetWordLeft(curPos, false);
Int32 curPos = sci.CurrentPos - 1;
String curWord = sci.GetWordLeft(curPos, false);
if (curWord == null) curWord = String.Empty;
CompletionList.Show(items, false, curWord);
e.Handled = true;
Expand Down
7 changes: 4 additions & 3 deletions External/Plugins/CssCompletion/PluginMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
case EventType.Keys:
{
Keys keys = (e as KeyEvent).Value;
if (this.IsSupported(document) && keys == (Keys.Control | Keys.Space))
if (this.IsSupported(document) && keys == (Keys.Control | Keys.Space) && completion != null)
{
if (completion != null)
var sci = document.SciControl;
if (sci.ContainsFocus)
{
completion.OnComplete(document.SciControl, document.SciControl.CurrentPos);
completion.OnComplete(sci, sci.CurrentPos);
e.Handled = true;
}
}
Expand Down
1 change: 1 addition & 0 deletions External/Plugins/XMLCompletion/XMLComplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ public static Boolean OnShortCut(Keys keys)
ITabbedDocument document = PluginBase.MainForm.CurrentDocument;
if (!document.IsEditable) return false;
ScintillaControl sci = document.SciControl;
if (!sci.ContainsFocus) return false;
XMLContextTag ctag = GetXMLContextTag(sci, sci.CurrentPos);
// Starting tag
if (ctag.Tag == null)
Expand Down
15 changes: 6 additions & 9 deletions FlashDevelop/Docking/TabbedDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ public void AddEditorControls(String file, String text, Int32 codepage)
this.editor.MarkerDeleteAll(2);
this.IsModified = false;
};
this.editor.FocusChanged += new FocusHandler(this.EditorFocusChanged);
this.editor2.FocusChanged += new FocusHandler(this.EditorFocusChanged);
this.editor.GotFocus += EditorFocusChanged;
this.editor2.GotFocus += EditorFocusChanged;
this.editor.UpdateSync += new UpdateSyncHandler(this.EditorUpdateSync);
this.editor2.UpdateSync += new UpdateSyncHandler(this.EditorUpdateSync);
this.Controls.Add(this.splitContainer);
Expand Down Expand Up @@ -342,14 +342,11 @@ private void EditorUpdateSync(ScintillaControl sender)
/// <summary>
/// When the user changes to sci, block events from inactive sci
/// </summary>
private void EditorFocusChanged(ScintillaControl sender)
private void EditorFocusChanged(object sender, EventArgs e)
{
if (sender.IsFocus)
{
this.lastEditor = sender;
this.editor.DisableAllSciEvents = (sender == editor2);
this.editor2.DisableAllSciEvents = (sender == editor);
}
this.lastEditor = (ScintillaControl)sender;
this.editor.DisableAllSciEvents = (sender == editor2);
this.editor2.DisableAllSciEvents = (sender == editor);
}

/// <summary>
Expand Down
20 changes: 13 additions & 7 deletions FlashDevelop/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,13 +1580,19 @@ public Boolean PreFilterMessage(ref Message m)
ITabbedDocument doc = Globals.CurrentDocument;
if (Control.FromHandle(hWnd) != null)
{
Win32.SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
return true;
}
else if (doc != null && doc.IsEditable && (hWnd == doc.SplitSci1.HandleSci || hWnd == doc.SplitSci2.HandleSci))
{
Win32.SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
return true;
if (hWnd == doc.SplitSci1.Handle || hWnd == doc.SplitSci2.Handle)
{
if (doc != null && doc.IsEditable)
{
Win32.SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
return true;
}
}
else
{
Win32.SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
return true;
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions PluginCore/PluginCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@
<Compile Include="PluginCore\Controls\Common.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="PluginCore\Controls\CompletionListControl.cs" />
<Compile Include="PluginCore\Controls\ICompletionListHost.cs" />
<Compile Include="PluginCore\Controls\InactiveForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PluginCore\Controls\MessageBoxManager.cs" />
<Compile Include="PluginCore\Controls\ScrollBarEx.cs">
<SubType>Component</SubType>
Expand Down
Loading