コード例 #1
0
 /// <summary>
 /// Goes to the match and ensures that correct fold is opened
 /// </summary>
 private void SetSelAndFocus(ScintillaControl sci, Int32 line, Int32 startPosition, Int32 endPosition)
 {
     sci.SetSel(startPosition, endPosition);
     sci.EnsureVisible(line);
 }
コード例 #2
0
ファイル: FRInDocDialog.cs プロジェクト: zvoronz/flashdevelop
        /// <summary>
        /// Replaces all results specified by user input
        /// </summary>
        private void ReplaceAllButtonClick(Object sender, System.EventArgs e)
        {
            if (Globals.SciControl == null)
            {
                return;
            }
            ScintillaControl   sci           = Globals.SciControl;
            List <SearchMatch> matches       = this.GetResults(sci);
            Boolean            selectionOnly = this.lookComboBox.SelectedIndex == 1 && sci.SelText.Length > 0;

            if (matches != null && selectionOnly)
            {
                Int32 end   = sci.MBSafeCharPosition(sci.SelectionEnd);
                Int32 start = sci.MBSafeCharPosition(sci.SelectionStart);
                matches = FRDialogGenerics.FilterMatches(matches, start, end);
            }
            if (matches != null)
            {
                sci.BeginUndoAction();
                try
                {
                    var firstVisibleLine = sci.FirstVisibleLine;
                    var pos = sci.CurrentPos;
                    for (int i = 0, count = matches.Count; i < count; i++)
                    {
                        var match             = matches[i];
                        var replacement       = GetReplaceText(match);
                        var replacementLenght = sci.MBSafeTextLength(replacement);
                        if (sci.MBSafePosition(match.Index) < pos)
                        {
                            pos += replacementLenght - sci.MBSafeTextLength(match.Value);
                        }
                        if (selectionOnly)
                        {
                            FRDialogGenerics.SelectMatchInTarget(sci, match);
                        }
                        else
                        {
                            FRDialogGenerics.SelectMatch(sci, match);
                        }
                        FRSearch.PadIndexes(matches, i, match.Value, replacement);
                        sci.EnsureVisible(sci.CurrentLine);
                        if (selectionOnly)
                        {
                            sci.ReplaceTarget(replacementLenght, replacement);
                        }
                        else
                        {
                            sci.ReplaceSel(replacement);
                        }
                    }
                    sci.FirstVisibleLine = firstVisibleLine;
                    sci.SetSel(pos, pos);
                }
                finally
                {
                    sci.EndUndoAction();
                }
                FRDialogGenerics.UpdateComboBoxItems(this.findComboBox);
                FRDialogGenerics.UpdateComboBoxItems(this.replaceComboBox);
                String message   = TextHelper.GetString("Info.ReplacedMatches");
                String formatted = String.Format(message, matches.Count);
                this.ShowMessage(formatted, 0);
                this.lookupIsDirty = false;
            }
        }