Exemplo n.º 1
0
        public static bool HandleKeys(ScintillaControl sci, Keys key)
        {
            int index;
            switch (key)
            {
                case Keys.Back:
                    if (word.Length >= MinWordLength)
                    {
                        word = word.Substring(0, word.Length - 1);
                        currentPos = sci.CurrentPos - 1;
                        lastIndex = 0;
                        FindWordStartingWith(word);
                    }
                    else CompletionList.Hide((char)8);
                    return false;

                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;
        }
Exemplo n.º 2
0
 public static Int32 NextCharPosition(ScintillaControl sci, Int32 position, String c)
 {
     Int32 curPos = sci.CurrentPos;
     sci.GotoPos(position);
     char currentChar = (char)sci.CharAt(sci.CurrentPos);
     if (currentChar.ToString().Equals(c)) sci.CharRight();
     sci.SearchAnchor();
     Int32 next = sci.SearchNext(0, c);
     sci.GotoPos(curPos);
     return next;
 }
Exemplo n.º 3
0
        unsafe void SciControl_CharAdded(ScintillaControl sender, int ch)
        {
            if (ch == bracketOpen)
               {
               insert = arrBracketClose;

               }
               else if (ch == quote)
               {

               insert = arrQuote;
               }
               else if (ch == squareBracketOpen)
               {

               insert = arrSquareBracketClose;

               }
               else if (ch == bracketClose)
               {
               if (sender.CharAt(sender.CurrentPos) == bracketClose)
               {
                   // temporary disable
                   sender.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
                   sender.CharRight();
                   sender.DeleteBack();
                   sender.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
                   return;
               }
               return;
               }
               else if (ch == squareBracketClose)
               {
               if (sender.CharAt(sender.CurrentPos) == squareBracketClose)
               {
                   // temporary disable
                   sender.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
                   sender.CharRight();
                   sender.DeleteBack();
                   sender.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
                   return;
               }
               return;
               }
               else
               {
               return;
               }

               int pos = sender.CurrentPos;
               uint actPos = (uint)pos;

               char character;
               do
               {
               character =(char) sender.CharAt(pos);
               if (character == '\n') break;
               if (!Char.IsWhiteSpace(character)) break;
               pos++;

               } while (true);

             //  if (Char.IsLetterOrDigit(character) || character == ch || character == insert[0]) return;
               if (Char.IsLetterOrDigit(character) || character == ch ) return;

               int stylemask = (1 << sender.StyleBits) - 1;

               bool isTextStyle = ASComplete.IsTextStyle(sender.StyleAt(sender.CurrentPos) & stylemask);
               int style = sender.StyleAt(sender.CurrentPos - 1) & stylemask;

               if (ch == quote)
               {
               if (!isTextStyle)
               {

                   fixed (byte* b = System.Text.Encoding.GetEncoding(sender.CodePage).GetBytes(insert))
                   {
                       sender.SPerform(2003, actPos, (uint)b);
                   }

               }

               return;
               }

               if (!ASComplete.IsTextStyle(style) && !isTextStyle)
               {

               return;
               }

               fixed (byte* b = System.Text.Encoding.GetEncoding(sender.CodePage).GetBytes(insert))
               {
               sender.SPerform(2003, actPos, (uint)b);
               }
        }
Exemplo n.º 4
0
 public void RemoveBracket(ScintillaControl sci)
 {
     // temporary deactive
        sci.ModEventMask ^= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
        sci.CharRight();
        sci.DeleteBack();
        sci.ModEventMask |= (Int32)ScintillaNet.Enums.ModificationFlags.BeforeDelete;
 }
Exemplo n.º 5
0
        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.Up:
                    if (!CompletionList.Active) sci.LineUp();
                    return false;
                case Keys.Down:
                    if (!CompletionList.Active) sci.LineDown();
                    return false;
                case Keys.Up | Keys.Shift:
                    sci.LineUpExtend();
                    return false;
                case Keys.Down | Keys.Shift:
                    sci.LineDownExtend();
                    return false;
                case Keys.Left | Keys.Shift:
                    sci.CharLeftExtend();
                    return false;
                case Keys.Right | Keys.Shift:
                    sci.CharRightExtend();
                    return false;

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

                case Keys.Left:
                    if (!CompletionList.Active)
                    {
                        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 + deltaPos < startPos) Hide();
                    else if (OnUpdateCallTip != null) OnUpdateCallTip(sci, currentPos);
                    return true;

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

                default:
                    if (!CompletionList.Active) Hide();
                    return false;
            }
        }
Exemplo n.º 6
0
		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;
		}
Exemplo n.º 7
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;
			}			
		}