コード例 #1
0
        static public void Show(ArrayList itemList, bool autoHide)
        {
            // check controls
            ScintillaControl sci = UITools.MainForm.CurSciControl;
            ListBox          cl  = completionList;

            try
            {
                if ((itemList == null) || (itemList.Count == 0))
                {
                    if (isActive)
                    {
                        Hide();
                    }
                    return;
                }
                if (sci == null)
                {
                    if (isActive)
                    {
                        Hide();
                    }
                    return;
                }
                if (InfoTip.CallTipActive)
                {
                    InfoTip.Hide();
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowError("Completion list Control exception.", ex);
            }
            // state
            allItems     = itemList;
            autoHideList = autoHide;
            word         = "";
            if (currentWord != null)
            {
                word        = currentWord;
                currentWord = null;
            }
            fullList         = (word.Length == 0) || !autoHide || !autoFilterList;
            lastIndex        = 0;
            exactMatchInList = false;
            startPos         = sci.CurrentPos - word.Length;
            currentPos       = sci.CurrentPos;
            // lock keys
            isActive = true;
            UITools.LockControl(sci);
            // populate list
            tempo.Enabled = autoHide && (displayDelay > 0);
            if (tempo.Enabled)
            {
                tempo.Interval = displayDelay;
            }
            FindWordStartingWith(word);
        }
コード例 #2
0
		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();
		}
コード例 #3
0
 static public void ReplaceText(ScintillaControl sci, string tail)
 {
     if (InfoTip.CallTipActive)
     {
         InfoTip.Hide();
         return;
     }
     if (completionList.SelectedIndex >= 0)
     {
         ICompletionListItem item = (ICompletionListItem)completionList.Items[completionList.SelectedIndex];
         sci.SetSel(startPos, sci.CurrentPos);
         string replace = item.Value;
         if (replace != null)
         {
             sci.ReplaceSel(replace + tail);
         }
     }
     Hide();
 }
コード例 #4
0
 static public void Hide()
 {
     if ((completionList != null) && isActive)
     {
         // list
         tempo.Enabled          = false;
         isActive               = false;
         fullList               = false;
         completionList.Visible = false;
         if (completionList.Items.Count > 0)
         {
             completionList.Items.Clear();
         }
         currentItem = null;
         allItems    = null;
         InfoTip.Hide();                 // InfoTip
         UITools.UnlockControl();        // unlock keys
     }
 }
コード例 #5
0
        static public bool HandleKeys(ScintillaControl sci, Keys key)
        {
            switch (key)
            {
            case Keys.Multiply:
            case Keys.Subtract:
            case Keys.Divide:
            case Keys.Decimal:
            case Keys.Add:
                return(false);

            case Keys.Right:
                sci.CharRight();
                currentPos = sci.CurrentPos;
                if (sci.LineFromPosition(sci.CurrentPos) != currentLine)
                {
                    Hide();
                }
                else if (OnUpdateCallTip != null)
                {
                    OnUpdateCallTip(sci, currentPos);
                }
                return(true);

            case Keys.Left:
                sci.CharLeft();
                currentPos = sci.CurrentPos;
                if (currentPos < startPos)
                {
                    Hide();
                }
                else
                {
                    if (sci.LineFromPosition(sci.CurrentPos) != currentLine)
                    {
                        Hide();
                    }
                    else if (OnUpdateCallTip != null)
                    {
                        OnUpdateCallTip(sci, currentPos);
                    }
                }
                return(true);

            case Keys.Back:
                sci.DeleteBack();
                currentPos = sci.CurrentPos;
                if (currentPos < startPos)
                {
                    Hide();
                }
                else if (OnUpdateCallTip != null)
                {
                    OnUpdateCallTip(sci, currentPos);
                }
                return(true);

            case Keys.Tab:
            case Keys.Space:
                return(false);

            default:
                InfoTip.Hide();
                return(false);
            }
        }
コード例 #6
0
		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);
		}