Example #1
0
        private void toggleBookmarkToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Line currentLine = ActiveDocument.Scintilla.Lines.Current;

            if (ActiveDocument.Scintilla.Markers.GetMarkerMask(currentLine) == 0)
            {
                currentLine.AddMarker(0);
            }
            else
            {
                currentLine.DeleteMarker(0);
            }
        }
Example #2
0
        private void cmdBookmark_Click(object sender, EventArgs e)
        {
            Line currentLine = this.Scintilla.Lines.Current;

            if (this.Scintilla.Markers.GetMarkerMask(currentLine) == 0)
            {
                currentLine.AddMarker(0);
            }
            else
            {
                currentLine.DeleteMarker(0);
            }
        }
Example #3
0
        private void toggleBookmarkToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (label1 == null)
            {
                return;
            }

            Line currentLine = label1.Lines.Current;

            if (label1.Markers.GetMarkerMask(currentLine) == 0)
            {
                currentLine.AddMarker(0);
            }
            else
            {
                currentLine.DeleteMarker(0);
            }
        }
Example #4
0
 private void ToggleBookmark()
 {
     try
     {
         Line currentLine = Lines.Current;
         if (Markers.GetMarkerMask(currentLine) == 0)
         {
             currentLine.AddMarker(0);
         }
         else
         {
             currentLine.DeleteMarker(0);
         }
     }
     catch (Exception err)
     {
         LogManager.Debug(err);
     }
 }
Example #5
0
        private void FindAllRegex(string searchText, string replaceText, bool isReplace)
        {
            ScintillaEditForm sci = GetActiveEditor();

            if (sci == null)
            {
                return;
            }

            // Clear all bookmarks
            sci.Editor.Markers.DeleteAll(Constants.BOOKMARK_MARKER);

            Regex           searchRegex = new Regex(searchText);
            MatchCollection matches     = searchRegex.Matches(sci.Editor.Text);

            int lineNumber = -1;
            int lineCount  = 0;

            foreach (Match match in matches)
            {
                Line line = sci.Editor.Lines.FromPosition(match.Index);
                if (line == null)
                {
                    continue;
                }

                // Only report each line once.
                if (lineNumber != line.Number)
                {
                    if (!isReplace)
                    {
                        line.AddMarker(Constants.BOOKMARK_MARKER);
                    }

                    lineNumber = line.Number;
                    lineCount++;
                }
            }

            if (isReplace)
            {
                /*
                 * Can't track the actual change locations using this method so
                 * we add a sentinel string to mark the lines on which the changes
                 * occur. Then we bookmark each line with a sentinel and remove it.
                 * This is a bit hacky and would break if the sentinel actually
                 * appears in the text but it's the only way to do multi-line
                 * replaces and still preserve the bookmarks in the right places.
                 */

                string sentinel = "{^¬%`^}";

                sci.Editor.UndoRedo.BeginUndoAction();

                sci.Editor.Text = searchRegex.Replace(
                    sci.Editor.Text, sentinel + replaceText);

                foreach (Line line in sci.Editor.Lines)
                {
                    if (line.Text.IndexOf(sentinel) != -1)
                    {
                        string s = line.Text.Replace(sentinel, String.Empty);

                        /*
                         * Line needs to be trimmed of any EOL characters to prevent
                         * extra blank lines being inserted.
                         */

                        line.Text = s.TrimEnd(new Char[] { '\n', '\r' });
                        line.AddMarker(Constants.BOOKMARK_MARKER);
                    }
                }

                sci.Editor.UndoRedo.EndUndoAction();
            }

            if (lineCount == 1)
            {
                _searchMessageLabel.Text = String.Format(isReplace ?
                                                         Resources.FindDialogMessageReplacedAllSingle :
                                                         Resources.FindDialogMessageFoundSingle, lineCount);
            }
            else
            {
                _searchMessageLabel.Text = String.Format(isReplace ?
                                                         Resources.FindDialogMessageReplacedAllMulti :
                                                         Resources.FindDialogMessageFoundMulti, lineCount);
            }
        }