コード例 #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);
        }
コード例 #2
0
 private void OnRenderTimerElapsed(object source, EventArgs e)
 {
     renderTimer.Stop();
     try
     {
         markdownPreviewForm.RenderMarkdown(scintillaGateway.GetText(scintillaGateway.GetLength()), notepadPPGateway.GetCurrentFilePath());
     }
     catch (Exception ex)
     {
     }
 }
        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();
        }
コード例 #4
0
ファイル: Main.cs プロジェクト: jaredgray/Textie
        private static TupleList <string, string> GetTextFromEditorAsDictionary()
        {
            var requestLength = int.MaxValue;
            var currentText   = editor.GetText(requestLength);
            var textlist      = new TupleList <string, string>();

            using (StringReader sr = new StringReader(currentText))
            {
                string line = null;
                while (null != (line = sr.ReadLine()))
                {
                    textlist.Add(line.ToUpper(), line);
                }
            }
            return(textlist);
        }
コード例 #5
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);
                }
            }
        }
コード例 #6
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());
        }
コード例 #7
0
 private string GetCurrentEditorText()
 {
     return(scintillaGateway.GetText(scintillaGateway.GetLength() + 1));
 }
コード例 #8
0
        internal static void MT950()
        {
            try
            {
                // select all content in active page
                editor.SelectAll();
                int              length              = editor.GetLength();
                string           activePageText      = editor.GetText(length + 1);
                string           activeTextFlattened = Regex.Replace(activePageText, @"\r\n?|\n", "");
                string           modifiedResults     = null;
                HashSet <string> unqiueResults       = new HashSet <string>();

                // grab each message
                Regex mainSwiftContentPattern = new Regex(@"{.*?(-})+{.*?(:}})");
                //Regex swiftContentPatternWithoutFooter = new Regex(@"{.*?(-})");

                var swiftMessages = mainSwiftContentPattern.Matches(activeTextFlattened);
                foreach (Match swiftMessage in swiftMessages)
                {
                    // new match clear unique results tracker
                    unqiueResults.Clear();

                    //rename fields from :60: to opening_balance for example
                    foreach (var swiftField in swiftInfo.swiftMessageFields)
                    {
                        try
                        {
                            // using swiftMessageField.Value as regex, find match in string
                            string rawMessageField = utils.returnFirstStringMatch(swiftField.Value, swiftMessage.ToString());

                            // only work with unique results since dictionaries contain duplicate regexs
                            if (!unqiueResults.Contains(rawMessageField))
                            {
                                string modifiedMainMessageField = null;
                                try // replace field ID with human readable name
                                {
                                    string humanReadableFieldName = swiftInfo.swiftMessageNames[swiftField.Key];
                                    modifiedMainMessageField = rawMessageField.Replace(swiftField.Key, humanReadableFieldName);
                                }
                                catch //otherwise leave the field ID in tact
                                {
                                    modifiedMainMessageField = rawMessageField;
                                }

                                // only work with lines that actually contain anything
                                if (modifiedMainMessageField.Length > 0)
                                {
                                    unqiueResults.Add(rawMessageField);

                                    string subFieldDetails = utils.buildSwiftSubFieldOutput(rawMessageField, swiftField.Key);

                                    if (":5" == swiftField.Key)
                                    {
                                        modifiedResults = modifiedResults + "-}\n" + modifiedMainMessageField + "\n";
                                    }
                                    else
                                    {
                                        modifiedResults = modifiedResults + modifiedMainMessageField + subFieldDetails;
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("Message Field " + swiftField.Value + " not unique " + swiftField);
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Error converting " + swiftField.Key);
                        }
                    }
                }

                editor.SelectAll();
                editor.ReplaceSel(modifiedResults);
            }
            catch
            {
                MessageBox.Show("Error reading text on current page.\n Are you sure this is a MT950?", "Mismatch Error");
            }
        }
コード例 #9
0
 private static string GetCurrentText()
 {
     return(Editor.GetText(Editor.GetLength() + 1));
 }