static public void OnChar(ScintillaControl sci, int value) { string c = Convert.ToString((char)value); if (re_word.IsMatch(c)) { word += c; currentPos++; FindWordStartingWith(word); return; } else if (re_separator.IsMatch(c)) { if (!exactMatchInList) { CompletionList.Hide(); } else if (word.Length > 0 || c == "." || c == "(" || c == "[") { // TODO maybe add an option to add spaces around operators /*if (c == "=") ReplaceText(sci, " "+c+" "); * else*/ReplaceText(sci, c); } // handle this char UITools.SendChar(sci, value); } else { CompletionList.Hide(); } }
private void OnUIRefresh(ScintillaControl sci) { Form mainForm = PluginBase.MainForm as Form; if (mainForm.InvokeRequired) { mainForm.BeginInvoke((MethodInvoker) delegate { this.OnUIRefresh(sci); }); return; } if (sci != null && sci.IsFocus) { int position = sci.SelectionEnd; if (CompletionList.Active && CompletionList.CheckPosition(position)) { return; } if (callTip.CallTipActive && callTip.CheckPosition(position)) { return; } } callTip.Hide(); CompletionList.Hide(); simpleTip.Hide(); }
/// <summary> /// /// </summary> static public void OnChar(ScintillaControl sci, int value) { char c = (char)value; string characterClass = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage).characterclass.Characters; if (characterClass.IndexOf(c) >= 0) { word += c; currentPos++; FindWordStartingWith(word); return; } else { // check for fast typing long millis = (DateTime.Now.Ticks - showTime) / 10000; if (!exactMatchInList && (word.Length > 0 || millis < 400)) { CompletionList.Hide('\0'); } else if (word.Length > 0 || c == '.' || c == '(' || c == '[' || c == '<') { ReplaceText(sci, c.ToString(), c); } // handle this char UITools.Manager.SendChar(sci, value); } }
private UITools() { showDetails = PluginBase.Settings.ShowDetails; // // CONTROLS // try { CompletionList.CreateControl(PluginBase.MainForm); codeTip = new CodeTip(PluginBase.MainForm); simpleTip = new RichToolTip(PluginBase.MainForm); callTip = new MethodCallTip(PluginBase.MainForm); errorTip = new RichToolTip(PluginBase.MainForm); } catch (Exception ex) { ErrorManager.ShowError(/*"Error while creating editor controls.",*/ ex); } // // Events // PluginBase.MainForm.IgnoredKeys.Add(Keys.Space | Keys.Control); // complete member PluginBase.MainForm.IgnoredKeys.Add(Keys.Space | Keys.Control | Keys.Shift); // complete method PluginBase.MainForm.DockPanel.ActivePaneChanged += new EventHandler(DockPanel_ActivePaneChanged); EventManager.AddEventHandler(this, eventMask); }
public bool PreFilterMessage(ref Message m) { if (m.Msg == WM_MOUSEWHEEL) { // capture all MouseWheel events and transmit to completionList SendMessage(CompletionList.GetHandle(), m.Msg, (Int32)m.WParam, (Int32)m.LParam); return true; } return false; }
static public void OnUIRefresh(ScintillaControl sci) { if (sci != null && sci.IsActive) { int position = sci.CurrentPos; if (CompletionList.Active && CompletionList.CheckPosition(position)) return; if (InfoTip.CallTipActive && InfoTip.CheckPosition(position)) return; } CompletionList.Hide(); InfoTip.Hide(); }
static public void Init(IMainForm mainForm) { /** * CONTROLS */ instance = new UITools(); UITools.mainForm = mainForm; try { CompletionList.CreateControl(mainForm); InfoTip.CreateControl(mainForm); } catch(Exception ex) { ErrorHandler.ShowError("Error while creating editor controls.", ex); } /** * SETTINGS */ if (!MainForm.MainSettings.HasKey(SETTING_DELAY_HOVER)) { MainForm.MainSettings.AddValue(SETTING_DELAY_HOVER, "1000"); } if (!MainForm.MainSettings.HasKey(SETTING_FILTER)) { MainForm.MainSettings.AddValue(SETTING_FILTER, "true"); } if (!MainForm.MainSettings.HasKey(SETTING_DELAY)) { MainForm.MainSettings.AddValue(SETTING_DELAY, "100"); } if (!MainForm.MainSettings.HasKey(SETTING_HIDE)) { MainForm.MainSettings.AddValue(SETTING_HIDE, "false"); } if (!MainForm.MainSettings.HasKey(SETTING_DETAILS)) { MainForm.MainSettings.AddValue(SETTING_DETAILS, "false"); } if (!MainForm.MainSettings.HasKey(SETTING_WRAP)) { MainForm.MainSettings.AddValue(SETTING_WRAP, "false"); } if (!MainForm.MainSettings.HasKey(SETTING_INSERTIONKEYS)) { MainForm.MainSettings.AddValue(SETTING_INSERTIONKEYS, ".()[],;!+*/%=-><"); } ReadSettings(); // always ignore these keys MainForm.IgnoredKeys.Add(Keys.Space | Keys.Control); // complete member MainForm.IgnoredKeys.Add(Keys.Space | Keys.Control|Keys.Shift); // complete method }
public bool PreFilterMessage(ref Message m) { if (m.Msg == Win32.WM_MOUSEWHEEL) // capture all MouseWheel events { if (!callTip.CallTipActive || !callTip.Focused) { if (Win32.ShouldUseWin32()) { Win32.SendMessage(CompletionList.GetHandle(), m.Msg, (Int32)m.WParam, (Int32)m.LParam); return(true); } else { return(false); } } else { return(false); } } else if (m.Msg == Win32.WM_KEYDOWN) { if ((int)m.WParam == 17) // Ctrl { if (CompletionList.Active) { CompletionList.FadeOut(); } if (callTip.CallTipActive && !callTip.Focused) { callTip.FadeOut(); } } } else if (m.Msg == Win32.WM_KEYUP) { if ((int)m.WParam == 17 || (int)m.WParam == 18) // Ctrl / AltGr { if (CompletionList.Active) { CompletionList.FadeIn(); } if (callTip.CallTipActive) { callTip.FadeIn(); } } } return(false); }
private void OnUIRefresh(ScintillaControl sci) { if (sci != null && sci.IsFocus) { int position = sci.CurrentPos; if (CompletionList.Active && CompletionList.CheckPosition(position)) { return; } if (callTip.CallTipActive && callTip.CheckPosition(position)) { return; } } callTip.Hide(); CompletionList.Hide(); simpleTip.Hide(); }
private void OnChar(ScintillaControl sci, int value) { if (sci == null || DisableEvents) { return; } if (!CompletionList.Active && !callTip.CallTipActive) { SendChar(sci, value); return; } if (lockedSciControl != null && lockedSciControl.IsAlive) { sci = (ScintillaControl)lockedSciControl.Target; } else { codeTip.Hide(); callTip.Hide(); CompletionList.Hide(); SendChar(sci, value); return; } if (callTip.CallTipActive) { callTip.OnChar(sci, value); } if (CompletionList.Active) { CompletionList.OnChar(sci, value); } else { SendChar(sci, value); } return; }
static private void OnChar(ScintillaControl sci, int value) { if (sci == null) return; if (!CompletionList.Active && !InfoTip.CallTipActive) { if (OnCharAdded != null) OnCharAdded(sci, value); return; } if (lockedSciControl.IsAlive) sci = (ScintillaControl)lockedSciControl.Target; else { CompletionList.Hide(); if (OnCharAdded != null) OnCharAdded(sci, value); return; } if (InfoTip.CallTipActive) { InfoTip.OnChar(sci, value); return; } else CompletionList.OnChar(sci, value); return; }
static public bool HandleKeys(ScintillaControl sci, Keys key) { int index; switch (key) { case Keys.Back: sci.DeleteBack(); if (word.Length > 0) { word = word.Substring(0, word.Length - 1); currentPos = sci.CurrentPos; lastIndex = 0; FindWordStartingWith(word); } else { CompletionList.Hide(); } return(true); case Keys.Enter: case Keys.Tab: ReplaceText(sci); return(true); case Keys.Space: return(false); case Keys.Up: case Keys.Left: // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); if (key == Keys.Up) { sci.LineUp(); } else { sci.CharLeft(); } return(false); } // go up the list else if (completionList.SelectedIndex > 0) { index = completionList.SelectedIndex - 1; completionList.SelectedIndex = index; } // wrap else if (wrapList) { index = completionList.Items.Count - 1; completionList.SelectedIndex = index; } break; case Keys.Down: case Keys.Right: // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); if (key == Keys.Down) { sci.LineDown(); } else { sci.CharRight(); } return(false); } // go down the list else if (completionList.SelectedIndex < completionList.Items.Count - 1) { index = completionList.SelectedIndex + 1; completionList.SelectedIndex = index; } // wrap else if (wrapList) { index = 0; completionList.SelectedIndex = index; } break; case Keys.PageUp: // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); sci.PageUp(); return(false); } // go up the list else if (completionList.SelectedIndex > 0) { index = completionList.SelectedIndex - completionList.Height / completionList.ItemHeight; if (index < 0) { index = 0; } completionList.SelectedIndex = index; } break; case Keys.PageDown: // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); sci.PageDown(); return(false); } // go down the list else if (completionList.SelectedIndex < completionList.Items.Count - 1) { index = completionList.SelectedIndex + completionList.Height / completionList.ItemHeight; if (index > completionList.Items.Count - 1) { index = completionList.Items.Count - 1; } completionList.SelectedIndex = index; } break; case (Keys.Control | Keys.Space): break; default: CompletionList.Hide(); return(false); } return(true); }
/// <summary> /// /// </summary> static public bool HandleKeys(ScintillaControl sci, Keys key) { int index; switch (key) { case Keys.Back: if (!UITools.CallTip.CallTipActive) { sci.DeleteBack(); } if (word.Length > MinWordLength) { word = word.Substring(0, word.Length - 1); currentPos = sci.CurrentPos; lastIndex = 0; FindWordStartingWith(word); } else { CompletionList.Hide((char)8); } return(true); case Keys.Enter: if (noAutoInsert || !ReplaceText(sci, '\n')) { CompletionList.Hide(); return(false); } return(true); case Keys.Tab: if (!ReplaceText(sci, '\t')) { CompletionList.Hide(); return(false); } return(true); case Keys.Space: if (noAutoInsert) { CompletionList.Hide(); } return(false); case Keys.Up: noAutoInsert = false; // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); if (key == Keys.Up) { sci.LineUp(); } else { sci.CharLeft(); } return(false); } // go up the list if (completionList.SelectedIndex > 0) { RefreshTip(); index = completionList.SelectedIndex - 1; completionList.SelectedIndex = index; } // wrap else if (PluginBase.MainForm.Settings.WrapList) { RefreshTip(); index = completionList.Items.Count - 1; completionList.SelectedIndex = index; } break; case Keys.Down: noAutoInsert = false; // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); if (key == Keys.Down) { sci.LineDown(); } else { sci.CharRight(); } return(false); } // go down the list if (completionList.SelectedIndex < completionList.Items.Count - 1) { RefreshTip(); index = completionList.SelectedIndex + 1; completionList.SelectedIndex = index; } // wrap else if (PluginBase.MainForm.Settings.WrapList) { RefreshTip(); index = 0; completionList.SelectedIndex = index; } break; case Keys.PageUp: noAutoInsert = false; // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); sci.PageUp(); return(false); } // go up the list if (completionList.SelectedIndex > 0) { RefreshTip(); index = completionList.SelectedIndex - completionList.Height / completionList.ItemHeight; if (index < 0) { index = 0; } completionList.SelectedIndex = index; } break; case Keys.PageDown: noAutoInsert = false; // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); sci.PageDown(); return(false); } // go down the list if (completionList.SelectedIndex < completionList.Items.Count - 1) { RefreshTip(); index = completionList.SelectedIndex + completionList.Height / completionList.ItemHeight; if (index > completionList.Items.Count - 1) { index = completionList.Items.Count - 1; } completionList.SelectedIndex = index; } break; case (Keys.Control | Keys.Space): break; case Keys.Left: sci.CharLeft(); CompletionList.Hide(); break; case Keys.Right: sci.CharRight(); CompletionList.Hide(); break; default: CompletionList.Hide(); return(false); } return(true); }
private bool HandleKeys(Keys key) { // UITools is currently broadcasting a shortcut, ignore! if (ignoreKeys || DisableEvents) { return(false); } // list/tip shortcut dispatching if ((key == (Keys.Control | Keys.Space)) || (key == (Keys.Shift | Keys.Control | Keys.Space))) { /*if (CompletionList.Active || callTip.CallTipActive) * { * UnlockControl(); * CompletionList.Hide(); * callTip.Hide(); * }*/ // offer to handle the shortcut ignoreKeys = true; KeyEvent ke = new KeyEvent(EventType.Keys, key); EventManager.DispatchEvent(this, ke); ignoreKeys = false; // if not handled - show snippets if (!ke.Handled && PluginBase.MainForm.CurrentDocument.IsEditable && !PluginBase.MainForm.CurrentDocument.SciControl.IsSelectionRectangle) { PluginBase.MainForm.CallCommand("InsertSnippet", "null"); } return(true); } // toggle "long-description" for the hover tooltip if (key == Keys.F1 && Tip.Visible && !CompletionList.Active) { showDetails = !showDetails; simpleTip.UpdateTip(PluginBase.MainForm.CurrentDocument.SciControl); return(true); } // are we currently displaying something? if (!CompletionList.Active && !callTip.CallTipActive) { return(false); } // hide if pressing Esc or Ctrl+Key combination if (lockedSciControl == null || !lockedSciControl.IsAlive || key == Keys.Escape || ((Control.ModifierKeys & Keys.Control) != 0 && Control.ModifierKeys != (Keys.Control | Keys.Alt))) { if (key == (Keys.Control | Keys.C) || key == (Keys.Control | Keys.A)) { return(false); // let text copy in tip } UnlockControl(); CompletionList.Hide((char)27); callTip.Hide(); return(false); } ScintillaControl sci = (ScintillaControl)lockedSciControl.Target; // chars string ks = key.ToString(); if (ks.Length == 1 || (ks.EndsWithOrdinal(", Shift") && ks.IndexOf(',') == 1) || ks.StartsWithOrdinal("NumPad")) { return(false); } // toggle "long-description" if (key == Keys.F1) { showDetails = !showDetails; if (callTip.CallTipActive) { callTip.UpdateTip(sci); } else { CompletionList.UpdateTip(null, null); } return(true); } // switches else if ((key & Keys.ShiftKey) == Keys.ShiftKey || (key & Keys.ControlKey) == Keys.ControlKey || (key & Keys.Menu) == Keys.Menu) { return(false); } // handle special keys bool handled = false; if (callTip.CallTipActive) { handled |= callTip.HandleKeys(sci, key); } if (CompletionList.Active) { handled |= CompletionList.HandleKeys(sci, key); } return(handled); }
static public bool HandleKeys(Keys key) { // UITools is currently broadcasting a shortcut, ignore! if (ignoreKeys) return false; // list/tip shortcut dispatching if ((key == (Keys.Control | Keys.Space)) || (key == (Keys.Shift | Keys.Control | Keys.Space))) { if (CompletionList.Active || InfoTip.CallTipActive) { UnlockControl(); CompletionList.Hide(); InfoTip.Hide(); } // offer to handle the shortcut ignoreKeys = true; KeyEvent ke = new KeyEvent(EventType.Shortcut, key); MainForm.DispatchEvent(ke); ignoreKeys = false; // if not handled: if (!ke.Handled) MainForm.CallCommand("InsertSnippet", "null"); return true; } // are we currently displaying something? if (!CompletionList.Active && !InfoTip.CallTipActive) return false; // hide if pressing Esc or Ctrl+Key combination if (!lockedSciControl.IsAlive || (key == Keys.Escape) || ((Control.ModifierKeys & Keys.Control) != 0 && Control.ModifierKeys != (Keys.Control|Keys.Alt)) ) { UnlockControl(); CompletionList.Hide(); InfoTip.Hide(); return false; } ScintillaControl sci = (ScintillaControl)lockedSciControl.Target; // chars string ks = key.ToString(); if ((ks.Length == 1) || ks.EndsWith(", Shift") || ks.StartsWith("NumPad")) { return false; } // toggle "long-description" if (key == Keys.F1) { showDetails = !showDetails; if (InfoTip.CallTipActive) InfoTip.UpdateTip(sci); else CompletionList.UpdateTip(); return true; } // switches else if (((key & Keys.ShiftKey) == Keys.ShiftKey) || ((key & Keys.ControlKey) == Keys.ControlKey) || ((key & Keys.Menu) == Keys.Menu)) { return false; } // calltip keys handler if (InfoTip.CallTipActive) return InfoTip.HandleKeys(sci, key); // completion keys handler return CompletionList.HandleKeys(sci, key); }