Esempio n. 1
0
        private void HandleCodeCompletionSelection_Ex()
        {
            try
            {
                ActiveTextArea.BeginUpdate();
                string userSelection = String.Empty;
                if (_codeCompWindowEx.Selector.HasMultipleSelection)
                {
                    userSelection = _codeCompWindowEx.SelectedItemsAsCommaSeparatedString;
                }
                else
                {
                    userSelection = _codeCompWindowEx.SelectedItem;
                }


                if (_codeCompWindowEx.Selector.HasMultipleSelection)
                {
                    ActiveTextArea.InsertString(userSelection);
                }
                else
                {
                    DeleteWordBeforeCaret();
                    ActiveTextArea.InsertString(userSelection);
                }
                FireAfterCodeCompletionShowed(CodeCompletionType.UserDefinedList, userSelection, true);
            }
            finally
            {
                ActiveTextArea.EndUpdate();
            }
            _codeCompWindowEx.DismissSelector();
            _textEditor.Focus();
        }
Esempio n. 2
0
        private void lv_DoubleClick(object sender, EventArgs e)
        {
            if (lv.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem selItem = lv.SelectedItems[0];
            string       selText = selItem.SubItems[2].Text;

            if (String.IsNullOrEmpty(selText))
            {
                return;
            }

            int lineNo = Convert.ToInt32(selText);

            if (lineNo > ActiveTextArea.Document.TotalNumberOfLines)
            {
                return;
            }

            ActiveTextArea.Caret.Column = 0;
            ActiveTextArea.Caret.Line   = lineNo - 1;
            ActiveTextArea.Select();
            Point startPoint = ActiveTextArea.Caret.Position;
            Point endPoint   = ActiveTextArea.Caret.Position;

            endPoint.X = endPoint.X + ActiveTextArea.Document.GetLineSegment(lineNo - 1).Length;
            ActiveTextArea.SelectionManager.SetSelection(startPoint, endPoint);
        }
Esempio n. 3
0
        private int MatchNext(string matchText)
        {
            if (String.IsNullOrEmpty(matchText))
            {
                return(-1);
            }

            int indexOf = -1;

            try
            {
                ActiveTextArea.BeginUpdate();
                int    lineNo          = ActiveTextArea.Caret.Line;
                int    colNo           = ActiveTextArea.Caret.Column;
                int    totalNumOfLines = ActiveDocument.TotalNumberOfLines;
                string LineText        = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo);
                LineText = ActiveDocument.GetText(ActiveTextArea.Caret.Offset, LineText.Length - colNo);

                indexOf = LineText.IndexOf(matchText, StringComparison.InvariantCultureIgnoreCase);
                int offset = colNo;

                if (indexOf < 0)
                {
                    offset = 0;
                    do
                    {
                        int tmpLineNo = ActiveDocument.GetNextVisibleLineAbove(lineNo, 1);
                        if (tmpLineNo == lineNo)
                        {
                            break;
                        }
                        lineNo   = tmpLineNo;
                        LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo);
                        indexOf  = LineText.IndexOf(matchText, StringComparison.InvariantCultureIgnoreCase);
                    }while (indexOf < 0 && lineNo < totalNumOfLines);
                }

                if (indexOf >= 0)
                {
                    ActiveTextArea.Caret.Column = 0;
                    ActiveTextArea.Caret.Line   = lineNo;

                    Point startPoint = ActiveTextArea.Caret.Position;
                    startPoint.X = indexOf + offset;
                    Point endPoint = startPoint;
                    endPoint.X = endPoint.X + matchText.Length;
                    ActiveTextArea.SelectionManager.SetSelection(startPoint, endPoint);
                    ActiveTextArea.Caret.Column = endPoint.X;
                }
                else if (lineNo == totalNumOfLines - 1)
                {
                    MessageBox.Show("Reached end of document", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
                ActiveTextArea.EndUpdate();
            }
            return(indexOf);
        }
Esempio n. 4
0
        private int MatchPrev(string matchText)
        {
            if (String.IsNullOrEmpty(matchText))
            {
                return(-1);
            }

            int indexOf = -1;

            try
            {
                ActiveTextArea.BeginUpdate();
                int lineNo = ActiveTextArea.Caret.Line;
                int colNo  = ActiveTextArea.Caret.Column;

                string LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo);
                LineText = LineText.Substring(0, ActiveTextArea.Caret.Column);

                indexOf = LineText.LastIndexOf(matchText, StringComparison.InvariantCultureIgnoreCase);
                if (indexOf < 0)
                {
                    do
                    {
                        int tmpLineNo = ActiveDocument.GetNextVisibleLineBelow(lineNo, 1);
                        if (tmpLineNo == lineNo)
                        {
                            break;
                        }
                        lineNo   = tmpLineNo;
                        LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo);

                        indexOf = LineText.LastIndexOf(matchText, StringComparison.InvariantCultureIgnoreCase);
                    }while (indexOf < 0 && lineNo >= 0);
                }

                if (indexOf > 0)
                {
                    ActiveTextArea.Caret.Column = 0;
                    ActiveTextArea.Caret.Line   = lineNo;

                    Point startPoint = ActiveTextArea.Caret.Position;
                    startPoint.X = indexOf;
                    Point endPoint = startPoint;
                    endPoint.X = endPoint.X + matchText.Length;
                    ActiveTextArea.SelectionManager.SetSelection(startPoint, endPoint);
                    ActiveTextArea.Caret.Column = startPoint.X;
                }
                else if (lineNo == 0)
                {
                    MessageBox.Show("Reached start of document", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
                ActiveTextArea.EndUpdate();
            }
            return(indexOf);
        }
Esempio n. 5
0
    public void ClearResults()
    {
      _bs.DataSource = null;
      _dataTbl.Clear();

      ActiveDocument.TextContent = String.Empty;
      ActiveTextArea.Invalidate();
      ActiveTextArea.Update();
    }
Esempio n. 6
0
        public void ConvertTokensTo(TokenConversionType conversionType)
        {
            try
            {
                ActiveTextArea.BeginUpdate();

                StringBuilder       sb    = null;
                HighlightRuleSet    rules = ActiveDocument.HighlightingStrategy.GetRuleSet(null);
                IList <LineSegment> lines = ActiveDocument.LineSegmentCollection;
                for (int k = 0; k < lines.Count; k++)
                {
                    LineSegment segment = lines[k];
                    for (int i = 0; i < segment.Words.Count; i++)
                    {
                        TextWord word = segment.Words[i];
                        if (word.Type != TextWordType.Word)
                        {
                            continue;
                        }

                        if (rules.KeyWords[ActiveDocument, segment, word.Offset, word.Length] != null)
                        {
                            string newVal = word.Word;
                            switch (conversionType)
                            {
                            case TokenConversionType.Lower:
                                newVal = word.Word.ToLowerInvariant();
                                break;

                            case TokenConversionType.Upper:
                                newVal = word.Word.ToUpperInvariant();
                                break;

                            case TokenConversionType.Capitalize:
                                newVal = word.Word;
                                char[] chars = newVal.ToCharArray();
                                chars[0] = Char.ToUpperInvariant(newVal[0]);
                                sb       = new StringBuilder();
                                sb.Append(chars);
                                newVal = sb.ToString();
                                break;

                            default:
                                break;
                            }
                            ActiveDocument.Replace(segment.Offset + word.Offset, word.Length, newVal);
                        }
                    }
                }
            }
            finally
            {
                ActiveTextArea.EndUpdate();
            }
        }
Esempio n. 7
0
 public void AppendContent(string content)
 {
     try
     {
         ActiveTextArea.BeginUpdate();
         ActiveTextArea.Text += content;
     }
     finally
     {
         ActiveTextArea.EndUpdate();
         ActiveTextArea.Invalidate();
     }
 }
Esempio n. 8
0
        private void OnGoToLine(object sender, int lineNo)
        {
            if (lineNo <= 0 || lineNo > ActiveDocument.TotalNumberOfLines)
            {
                MessageBox.Show("Can not locate line in script!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ActiveTextArea.Caret.Line   = lineNo - 1;
            ActiveTextArea.Caret.Column = 0;
            ActiveTextArea.Focus();
            _frmGoToLine.Hide();
        }
Esempio n. 9
0
 private void HandleCodeCompletionSelection()
 {
     if (_codeCompWindow.Selector.HasMultipleSelection)
     {
         ActiveTextArea.InsertString(_codeCompWindow.SelectedItemsAsCommaSeparatedString);
     }
     else
     {
         DeleteWordBeforeCaret();
         ActiveTextArea.InsertString(_codeCompWindow.SelectedItem);
     }
     _codeCompWindow.DismissSelector();
 }
Esempio n. 10
0
        public void RemoveContent(CaretPosition startPos, CaretPosition endPos)
        {
            try
            {
                ActiveTextArea.BeginUpdate();

                ActiveTextArea.SelectionManager.SetSelection(startPos.ToPoint(), endPos.ToPoint());
                ActiveTextArea.SelectionManager.RemoveSelectedText();
            }
            finally
            {
                ActiveTextArea.EndUpdate();
                ActiveTextArea.Invalidate();
            }
        }
Esempio n. 11
0
 private void OnAction_ToggleFoldings_Execute(object sender, EventArgs e)
 {
     try
     {
         ActiveTextArea.BeginUpdate();
         foreach (FoldMarker marker in ActiveDocument.FoldingManager.FoldMarker)
         {
             marker.IsFolded = !marker.IsFolded;
         }
     }
     finally
     {
         ActiveTextArea.EndUpdate();
         ActiveTextArea.Invalidate();
     }
 }
Esempio n. 12
0
    private void _bs_CurrentChanged(object sender, EventArgs e)
    {
      DataRowView row = _bs.Current as DataRowView;

      if (row == null)
      {
        ActiveDocument.TextContent = String.Empty;
        ActiveTextArea.Invalidate();
        ActiveTextArea.Update();
        return;
      }
     
      ActiveDocument.TextContent = row["ObjectScript"] as string;
      kryptonHeader1.Text = String.Format("Script of '{0}'",row["ObjectName"]);
      ActiveTextArea.Invalidate();
      ActiveTextArea.Update();
      _textEditor.BringToFront();
    }
Esempio n. 13
0
        public string GetContent(CaretPosition startPos, CaretPosition endPos)
        {
            string result = String.Empty;

            try
            {
                ActiveTextArea.BeginUpdate();

                ActiveTextArea.SelectionManager.SetSelection(startPos.ToPoint(), endPos.ToPoint());
                result = ActiveTextArea.SelectionManager.SelectedText;
                ActiveTextArea.SelectionManager.ClearSelection();
                return(result);
            }
            finally
            {
                ActiveTextArea.EndUpdate();
                ActiveTextArea.Invalidate();
            }
        }
Esempio n. 14
0
        private void HandleCodeCompletionKeyPress_Ex(char c)
        {
            switch (c)
            {
            case (char)27: //ESC
                _codeCompWindowEx.DismissSelector();
                _textEditor.Focus();
                return;

            default:
                if (Char.IsControl(c))
                {
                    return;
                }
                ActiveTextArea.InsertChar(c);
                _codeCompWindowEx.JumpTo(GetPreviousNonWSLineParts);
                break;
            }
        }
Esempio n. 15
0
        private void HandleCodeCompletionKeyPress_Ex(char c)
        {
            switch (c)
            {
            case (char)27: //ESC
                _codeCompWindowEx.DismissSelector();
                _textEditor.Focus();
                FireAfterCodeCompletionShowed(CodeCompletionType.UserDefinedList, String.Empty, false);
                return;

            default:
                if (Char.IsControl(c))
                {
                    return;
                }
                ActiveTextArea.InsertChar(c);
                _codeCompWindowEx.JumpTo(GetPreviousNonWSLineParts);
                break;
            }
        }
Esempio n. 16
0
        public void ChangeScriptCase(TokenConversionType conversionType)
        {
            try
            {
                ActiveTextArea.BeginUpdate();
                HighlightRuleSet    rules = ActiveDocument.HighlightingStrategy.GetRuleSet(null);
                IList <LineSegment> lines = ActiveDocument.LineSegmentCollection;
                for (int k = 0; k < lines.Count; k++)
                {
                    LineSegment segment = lines[k];
                    for (int i = 0; i < segment.Words.Count; i++)
                    {
                        TextWord word = segment.Words[i];
                        if (word.Type != TextWordType.Word)
                        {
                            continue;
                        }

                        string newVal = word.Word;
                        switch (conversionType)
                        {
                        case TokenConversionType.Lower:
                            newVal = word.Word.ToLowerInvariant();
                            break;

                        case TokenConversionType.Upper:
                            newVal = word.Word.ToUpperInvariant();
                            break;

                        default:
                            break;
                        }
                        ActiveDocument.Replace(segment.Offset + word.Offset, word.Length, newVal);
                    }
                }
            }
            finally
            {
                ActiveTextArea.EndUpdate();
            }
        }
Esempio n. 17
0
        private void HandleCodeCompletionKeyPress(char c)
        {
            switch (c)
            {
            case (char)27: //ESC
                _codeCompWindow.DismissSelector();
                return;

            /*
             * case '\b':
             * return;
             * case '\n':
             * return;
             */
            default:
                if (Char.IsControl(c))
                {
                    return;
                }
                ActiveTextArea.InsertChar(c);
                _codeCompWindow.JumpTo(PreviousNonWSLineParts);
                break;
            }
        }
Esempio n. 18
0
 public void InsertContent(CaretPosition startPos, string content)
 {
     PositionCaretTo(startPos);
     ActiveTextArea.InsertString(content);
 }
Esempio n. 19
0
 public void InsertContent(string content)
 {
     ActiveTextArea.InsertString(content);
 }