Beispiel #1
0
        private void UpdateSNList()
        {
            Editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());
            List <SourceNavigationItem> SNList = new List <SourceNavigationItem>();

            SNList.Clear();
            SNList.Add(new SourceNavigationItem
            {
                Name       = "<TOP>",
                LineNumber = 0
            });
            if (Editor.GetTextLength() <= 999999)
            {
                string          text    = Editor.GetText(Editor.GetTextLength());
                string          search  = @"^[\s]*([\w|-]+)[\s]+(SECTION|DIVISION)[\s]*\.[\s]*$";
                MatchCollection matches = Regex.Matches(text, search, RegexOptions.Multiline | RegexOptions.IgnoreCase);
                if (matches.Count > 0)
                {
                    foreach (Match match in matches)
                    {
                        SNList.Add(new SourceNavigationItem
                        {
                            Name       = ((match.Groups[2].Value.StartsWith("SECTION", StringComparison.OrdinalIgnoreCase) ? " " : "") + match.Groups[1].Value + " " + match.Groups[2].Value).ToUpper(),
                            LineNumber = Editor.LineFromPosition(new Position(match.Index))
                        });
                    }
                }
            }
            PostDataToSNListBox(SNList);
        }
        public void Format()
        {
            scintilla.BeginUndoAction();
            int    textLength = scintilla.GetTextLength();
            string text       = scintilla.GetText(textLength);

            text = FormatText(text);
            scintilla.DeleteRange(new Position(0), textLength);
            scintilla.InsertText(new Position(0), text);
            scintilla.EndUndoAction();
        }
Beispiel #3
0
        private void SNListBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                Editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());
                ContextMenuStrip menuStrip = new ContextMenuStrip();
                int index = SNListBox.IndexFromPoint(e.X, e.Y);
                SNListBox.SetSelected(index, true);
                string          text    = Editor.GetText(Editor.GetTextLength());
                string          search  = @"^[ ]*PERFORM[\s]*" + ((SourceNavigationItem)SNListBox.Items[index]).Name.Trim().Split(' ')[0] + @"[\s]*[\.]{0,1}[\s]*$";
                MatchCollection matches = Regex.Matches(text, search, RegexOptions.Multiline | RegexOptions.IgnoreCase);
                if (matches.Count > 0)
                {
                    foreach (Match match in matches)
                    {
                        string itemName = "";
                        foreach (SourceNavigationItem item in GetStoredSectionsList())
                        {
                            int    line        = Editor.LineFromPosition(new Position(match.Index));
                            string currentText = "";
                            if (item.LineNumber > line)
                            {
                                break;
                            }
                            else
                            {
                                currentText = item.Name.Trim().Split(' ')[0];
                            }
                            if (currentText != "")
                            {
                                itemName = (line + 1) + ": " + currentText;
                            }
                            Editor.LineFromPosition(new Position(match.Index));
                        }

                        menuStrip.Items.Add(itemName).Click += FrmSNDlg_SNListBox_Context_Click;
                    }
                }
                if (menuStrip.Items.Count > 0)
                {
                    menuStrip.Show(SNListBox, e.X, e.Y);
                }
            }
        }
Beispiel #4
0
        internal static void FormatText()
        {
            var textLength = editor.GetTextLength();

            var documentText = editor.GetText(textLength);

            var splitText = documentText.Split('|');

            var sb = new StringBuilder();

            foreach (string text in splitText)
            {
                sb.AppendLine(text);
            }

            editor.ClearAll();

            editor.SetText(sb.ToString());
        }
Beispiel #5
0
        // private int _cleanCounter = 0;

        private void TryCleanCurrentFileHighlighting()
        {
            // if (++_cleanCounter % 5 != 0) return;
            _gateway.ClearIndicatorStyleForRange(HIGHLIGHT_INDICATOR_ID, 0, _gateway.GetTextLength());
        }