Exemplo n.º 1
0
        private static void CopySelectionOrLine()
        {
            var scintilla = new ScintillaGateway(PluginBase.GetCurrentScintilla());

            if (scintilla.GetSelectionLength() != 0)
            {
                scintilla.Copy();
            }
            else
            {
                scintilla.CopyAllowLine();
            }
        }
Exemplo n.º 2
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            String settingsFilePath = Path.Combine(iniFilePath, PluginName + ".ini");

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETNPPDIRECTORY, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            String languageFilePath = Path.Combine(iniFilePath, @"plugins\" + PluginName + @"\" + PluginName + "_Lang.ini");

            pluginSettings = new Settings(settingsFilePath);
            pluginSettings.load();
            pluginLanguage = new ClassLanguage(languageFilePath);

            cADdyPoints    = new ClassCADdyPunkte(ref pluginLanguage);
            cADdyMessdaten = new ClassCADdyMessdaten(ref pluginLanguage);


            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord, pluginLanguage.getLanguageText("Menue_Coord"), dummy);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_FormCADdy, pluginLanguage.getLanguageText("Menue_Coord_FormCADdy"), formatCADdyKoord, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_FormExcel, pluginLanguage.getLanguageText("Menue_Coord_FormExcel"), formatExcelKoord, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_Sort, pluginLanguage.getLanguageText("Menue_Coord_Sort"), dummy);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_SortCol1, pluginLanguage.getLanguageText("Menue_Coord_SortCol1"), sortByNumber, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_SortCol2, pluginLanguage.getLanguageText("Menue_Coord_SortCol2"), sortByEast, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_SortCol3, pluginLanguage.getLanguageText("Menue_Coord_SortCol3"), sortByNorth, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_SortCol4, pluginLanguage.getLanguageText("Menue_Coord_SortCol4"), sortByElev, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_SortCol5, pluginLanguage.getLanguageText("Menue_Coord_SortCol5"), sortByCode, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_Rotation, pluginLanguage.getLanguageText("Menue_Coord_Rotation"), rotateCoordDialog, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_Translation, pluginLanguage.getLanguageText("Menue_Coord_Translation"), translateCoordDialog, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_Transformation, pluginLanguage.getLanguageText("Menue_Coord_Transformation"), transformationCoordDialog, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_Polar, pluginLanguage.getLanguageText("Menue_Coord_Polar"), polarCoordDialog, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Coord_Compare, pluginLanguage.getLanguageText("Menue_Coord_Compare"), compareCoordDialog, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Dummy_1, "----", null);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Measure, pluginLanguage.getLanguageText("Menue_Measure"), dummy);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Measure_FormCADdy, pluginLanguage.getLanguageText("Menue_Measure_FormCADdy"), formatCADdyMessaten, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Measure_FormExcel, pluginLanguage.getLanguageText("Menue_Measure_FormExcel"), formatExcelMessaten, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Measure_FormCAPLAN, pluginLanguage.getLanguageText("Menue_Measure_FormCAPLAN"), formatCAPLANMessaten, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Measure_SetID, pluginLanguage.getLanguageText("Menue_Measure_SetID"), changeIDDialog);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Dummy_2, "----", null);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_MeasCode, pluginLanguage.getLanguageText("Menue_MeasCode"), dummy);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_ChangeCode, pluginLanguage.getLanguageText("Menue_ChangeCode"), changeCodeDialog);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Dummy_3, "----", null);
            PluginBase.SetCommand((int)CADdyToolsMenuId.Menue_Settings, pluginLanguage.getLanguageText("Menue_Settings"), settingsDialog);
            PluginBase.SetCommand((int)CADdyToolsMenuId.About, "About ...", aboutDialog);
        }
Exemplo n.º 3
0
        private void GotoSelectedSection()
        {
            Editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());
            SourceNavigationItem selectedItem = (SourceNavigationItem)SNListBox.SelectedItem;
            int    line          = selectedItem.LineNumber;
            int    linesOnScreen = Editor.LinesOnScreen();
            string sectionName   = selectedItem.Name.Trim().Split(' ')[0];
            string lineText      = Editor.GetLine(line).ToUpper();

            Editor.GotoLine(line);
            Editor.SetFirstVisibleLine(line - linesOnScreen / 2 + 1 < 0 ? 0 : line - linesOnScreen / 2 + 1);
            Editor.SetSelection(Editor.PositionFromLine(line).Value + lineText.IndexOf(sectionName) + sectionName.Length, Editor.PositionFromLine(line).Value + lineText.IndexOf(sectionName));
            Editor.GrabFocus();
        }
Exemplo n.º 4
0
        private static void GotoSectionOrPerform()
        {
            if (SNDialogStruct.Form == null)
            {
                SourceNavigationDialog();
            }
            var editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());

            CheckAndSwitchOnCobolWords();
            editor.SetSelection(editor.WordEndPosition(editor.GetCurrentPos(), true), editor.WordStartPosition(editor.GetCurrentPos(), true));

            if (editor.GetSelectionLength() == 0)
            {
                return;
            }
            // If new search
            if (sectionName != editor.GetSelText().ToUpper())
            {
                sectionName = editor.GetSelText().ToUpper();
                int sectionImplementationLine = GetSectionImplementationLine(sectionName);
                if (sectionImplementationLine >= 0)
                {
                    if (editor.GetCurrentLineNumber() == sectionImplementationLine)
                    {
                        if (!SearchNextSectionOrPerform(sectionName, editor.GetCurrentPos().Value))
                        {
                            SearchNextSectionOrPerform(sectionName, 0);
                        }
                    }
                    else
                    {
                        ScrollToLine(sectionImplementationLine);
                        CurrentSearchOffset = sectionImplementationLine;
                    }
                }
                else
                {
                    sectionName = "";
                }
            }
            //If continuing search
            else
            {
                if (!SearchNextSectionOrPerform(sectionName, CurrentSearchOffset))
                {
                    SearchNextSectionOrPerform(sectionName, 0);
                }
            }
        }
Exemplo n.º 5
0
        private void FrmSNDlg_SNListBox_Context_Click(object sender, EventArgs e)
        {
            Editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());
            int    line          = int.Parse(((ToolStripItem)sender).Text.Split(':')[0]) - 1;
            int    linesOnScreen = Editor.LinesOnScreen();
            string lineText      = Editor.GetLine(line);

            Editor.GotoLine(line);
            Editor.SetFirstVisibleLine(line - linesOnScreen / 2 + 1 < 0 ? 0 : line - linesOnScreen / 2 + 1);
            string sectionName = lineText.Trim().Split(' ')[1];

            Editor.SetSelection(Editor.WordEndPosition(new Position(Editor.PositionFromLine(line).Value + lineText.IndexOf(sectionName)), true), Editor.PositionFromLine(line).Value + lineText.IndexOf(sectionName));
            Editor.GrabFocus();
            ((ToolStripItem)sender).Owner.Dispose();
        }
Exemplo n.º 6
0
        internal static void myMenuFunction()
        {
            IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
            ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);
            // Get selected text.
            string selectedText = scintillaGateway.GetSelText();


            var lines = selectedText.Split('\n');
            //var html = "<table style='box-sizing: inherit; font-family: arial, sans-serif; border-collapse: collapse; color: rgb(0, 0, 0); font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;'>";

            var myHtml = generator.GenerateMarkdown(lines);

            ClipboardHelper.CopyToClipboard(selectedText, myHtml);
        }
Exemplo n.º 7
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");
            someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0);

            PluginBase.SetCommand(0, "Format Text", FormatText, new ShortcutKey(true, true, false, Keys.P));
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        internal static void CommandMenuInit()
        {
            BootStrapper.RegisterComponents();
            BootStrapper.RegisterCommandHandlers();

            var container = ContainerDelivery.GetContainer();

            pluginFormProvider = container.Resolve <IPluginFormProvider>();
            commandBus         = container.Resolve <ICommandBus>();
            documentController = container.Resolve <IDocumentsController>();

            PluginBase.SetCommand(0, "Object explorer", ToggleObjectExplorer);
            PluginBase.SetCommand(1, "Output", ToggleOutput);
            PluginBase.SetCommand(2, "Execute", Execute);
        }
Exemplo n.º 9
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");
            someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0);

            PluginBase.SetCommand(0, "MyMenuCommand", myMenuFunction, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand(1, "MyDockableDialog", myDockableDialog); idMyDlg = 1;
        }
Exemplo n.º 10
0
        internal static void printDebugLine()
        {
            IntPtr           hCurrScintilla = PluginBase.GetCurrentScintilla();
            ScintillaGateway sci            = new ScintillaGateway(hCurrScintilla);
            var lineNumber       = sci.GetCurrentLineNumber() + 1;
            NotepadPPGateway npp = new NotepadPPGateway();
            var fileName         = Path.GetFileNameWithoutExtension(npp.GetCurrentFilePath());
            var stream           = new FileStream(@"plugins/Config/GoToDefinition/debug_table.txt", FileMode.Open, FileAccess.Read);

            using (var streamReader = new StreamReader(stream, Encoding.UTF8))
            {
                var text = streamReader.ReadToEnd();
                text = text + $"'{fileName}', {lineNumber}, )";
                sci.AddText(text.Length, text);
            }
        }
Exemplo n.º 11
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");
            someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0);

            PluginBase.SetCommand(0, "Encode", base64Encode);
            PluginBase.SetCommand(1, "Decode", base64Decode);
            idMyDlg = 1;
        }
Exemplo n.º 12
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");
            someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0);

            // Here we build the menu of our plugin
            PluginBase.SetCommand(menuId_Format, "Format", FormatMessages, new ShortcutKey(true, false, false, Keys.F12));
            PluginBase.SetCommand(menuId_MenuSeparator, "-", null);
            PluginBase.SetCommand(menuId_ShowAboutWindow, "About", ShowAboutWindow);
        }
Exemplo n.º 13
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);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Find and capitalize all Markdown Titles in the document.
        /// </summary>
        internal static void CapitalizeMDTitles()
        {
            // Get scintilla gateway.
            IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
            ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);

            string line;

            // Get the number of lines in the document.
            int numLines = scintillaGateway.GetLineCount();

            // Traverse through each line.
            for (int i = 0; i < numLines; i++)
            {
                // Set line to the current line.
                line = scintillaGateway.GetLine(i);

                // Check each character in the line to see if it begins
                // with a '#'.
                for (int j = 0; j < line.Length; j++)
                {
                    if (line[j] == '#')
                    {
                        // If it begins with '#', select the line and call
                        // the CapitalizeTitle method with these parameters.
                        scintillaGateway.GotoLine(i);
                        scintillaGateway.SetSel(scintillaGateway.PositionFromLine(i), scintillaGateway.GetLineEndPosition(i));
                        CapitalizeTitle();
                        break;
                    }
                    // Support for Setext headers.
                    else if ((line[j] == '-' || line[j] == '=') && !IsAlphaNumeric(line))
                    {
                        // If it begins with '-' or '=', select the previous line and call
                        // the CapitalizeTitle method with these parameters.
                        scintillaGateway.GotoLine(i - 1);
                        scintillaGateway.SetSel(scintillaGateway.PositionFromLine(i - 1), scintillaGateway.GetLineEndPosition(i - 1));
                        CapitalizeTitle();
                        break;
                    }
                }
            }
        }
Exemplo n.º 15
0
        private static void FormatRtf()
        {
            IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
            ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);

            string allText = scintillaGateway.GetAllText();

            if (!IsTextRtf(allText))
            {
                return;
            }

            string newText = rtfFormatter.GetFormattedText(allText);

            if (allText != newText)
            {
                scintillaGateway.SetText(newText);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Returns a string containing the last word typed.
        /// </summary>
        /// <returns>string</returns>
        internal static string getLastWord()
        {
            IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
            ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);

            var selectionStart = scintillaGateway.GetCurrentPos();
            var selectionEnd   = scintillaGateway.GetCurrentPos();
            var endOfVariable  = scintillaGateway.GetCurrentPos();

            scintillaGateway.WordLeft();
            selectionStart = scintillaGateway.GetCurrentPos();
            scintillaGateway.WordRight();
            selectionEnd  = scintillaGateway.GetCurrentPos();
            endOfVariable = selectionEnd;

            scintillaGateway.SetSel(selectionStart, selectionEnd);

            return(scintillaGateway.GetSelText());
        }
Exemplo n.º 17
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");
            someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0);

            PluginBase.SetCommand(0, "Generate Table", myMenuFunction, new ShortcutKey(true, false, true, Keys.C));
            PluginBase.SetCommand(0, "Generate Diagram to Clipoard", generateDiagram);
            PluginBase.SetCommand(1, "Save DrawIO as File", saveAsDrawIO);
            PluginBase.SetCommand(2, "Copy as Image", copyAsImage, new ShortcutKey(true, true, false, Keys.C));
            idMyDlg = 0;
        }
Exemplo n.º 18
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");
            someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0);

            PluginBase.SetCommand(0, "Capitalize Selected Title", CapitalizeTitle, new ShortcutKey(true, true, false, Keys.U));
            PluginBase.SetCommand(1, "Capitalize All Markdown Titles", CapitalizeMDTitles);
            PluginBase.SetCommand(2, "Capitalize First Word of All Sentences", CapSentence);
            PluginBase.SetCommand(3, "CamelCase Last Word Typed", CamelCaseLastWord, new ShortcutKey(false, true, true, Keys.U));
            PluginBase.SetCommand(4, "Plugin Info", FirstUpperInfo);
        }
Exemplo n.º 19
0
        internal static void myDockableDialog()
        {
            if (frmMyDlg == null)
            {
                frmMyDlg = new frmMyDlg();

                using (Bitmap newBmp = new Bitmap(16, 16))
                {
                    Graphics   g        = Graphics.FromImage(newBmp);
                    ColorMap[] colorMap = new ColorMap[1];
                    colorMap[0]          = new ColorMap();
                    colorMap[0].OldColor = Color.Fuchsia;
                    colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace);
                    ImageAttributes attr = new ImageAttributes();
                    attr.SetRemapTable(colorMap);
                    g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr);
                    tbIcon = Icon.FromHandle(newBmp.GetHicon());
                }

                NppTbData _nppTbData = new NppTbData();
                _nppTbData.hClient       = frmMyDlg.Handle;
                _nppTbData.pszName       = "My dockable dialog";
                _nppTbData.dlgID         = idMyDlg;
                _nppTbData.uMask         = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR;
                _nppTbData.hIconTab      = (uint)tbIcon.Handle;
                _nppTbData.pszModuleName = PluginName;
                IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData));
                Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false);

                Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData);
            }
            else
            {
                Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle);
                Win32.SendMessage(PluginBase.GetCurrentScintilla(),
                                  SciMsg.SCI_SETSELFORE, 1, 0xFFFFFF);
                Win32.SendMessage(PluginBase.GetCurrentScintilla(),
                                  SciMsg.SCI_SETSELBACK, 1, 0xFFFFFF);
                Win32.SendMessage(PluginBase.GetCurrentScintilla(),
                                  SciMsg.SCI_SETVIEWWS, 1, SCWS_VISIBLEALWAYS);
            }
        }
Exemplo n.º 20
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");
            someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0);

            PluginBase.SetCommand(0, "MyMenuCommand", myMenuFunction, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand(1, "MyDockableDialog", myDockableDialog); idMyDlg = 1;
            PluginBase.SetCommand(2, "GoToDefinition", goToDefinition, new ShortcutKey(true, false, false, Keys.F12));
            PluginBase.SetCommand(3, "PrintDebugLine", printDebugLine, new ShortcutKey(false, true, false, Keys.F12));
            PluginBase.SetCommand(4, "Idk", idk, new ShortcutKey(true, true, true, Keys.F12));
            PluginBase.SetCommand(4, "CloseOpenForms", closeOpenForms, new ShortcutKey(false, false, false, Keys.Escape));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Replace the tag at the caret with an expansion defined in the [Tags]
        /// ini-file section.
        /// </summary>
        internal static void ReplaceTag()
        {
            IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
            ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);
            int position = scintillaGateway.GetSelectionEnd();

            string selectedText = scintillaGateway.GetSelText();

            if (string.IsNullOrEmpty(selectedText))
            {
                // TODO: remove this hardcoded 10 crap. Remove selection manipulation:
                // user will not be happy to see any such side-effects.
                scintillaGateway.SetSelection(position > 10 ? (position - 10) : (position - position), position);
                selectedText = scintillaGateway.GetSelText();
                var reges = Regex.Matches(scintillaGateway.GetSelText(), @"(\w+)");
                if (reges.Count > 0)
                {
                    selectedText = reges.Cast <Match>().Select(m => m.Value).LastOrDefault();
                    scintillaGateway.SetSelection(position - selectedText.Length, position);
                    selectedText = scintillaGateway.GetSelText();
                }
            }
            try {
                if (string.IsNullOrEmpty(selectedText))
                {
                    throw new Exception("No tag here.");
                }
                byte[] buffer = new byte[1048];
                var    ini    = new IniFile(iniFilePath);
                string value  = ini.Get("Tags", selectedText, 1048);
                if (string.IsNullOrEmpty(value.Trim('\0')))
                {
                    throw new Exception("No tag here.");
                }
                value = TransformTags(value);
                scintillaGateway.ReplaceSel(value.Replace("|", null));
                scintillaGateway.SetSelectionEnd(position + value.Substring(0, value.IndexOf('|')).Length - selectedText.Length);
            } catch (Exception ex) {
                scintillaGateway.CallTipShow(position, ex.Message);
            }
        }
Exemplo n.º 22
0
        internal static void goToDefinition()
        {
            IntPtr           hCurrScintilla = PluginBase.GetCurrentScintilla();
            NotepadPPGateway npp            = new NotepadPPGateway();
            ScintillaGateway sci            = new ScintillaGateway(hCurrScintilla);
            var selectedText = sci.GetSelText();

            if (string.IsNullOrEmpty(selectedText))
            {
                return;
            }
            Dictionary <string, string> filePaths = new Dictionary <string, string>();
            var stream = new FileStream(@"plugins/Config/GoToDefinition/sql_repos.txt", FileMode.Open, FileAccess.Read);

            using (var streamReader = new StreamReader(stream, Encoding.UTF8))
            {
                var text         = streamReader.ReadToEnd();
                var allFilePaths = text.Split(';');
                foreach (var filePath in allFilePaths)
                {
                    var kvp = filePath.Split('=');
                    if (kvp.Length > 1)
                    {
                        filePaths.Add(kvp[0], kvp[1]);
                    }
                }
            }
            StringBuilder sb = new StringBuilder();

            var matchingFileNames = new List <string>();

            foreach (var kvp in filePaths)
            {
                var matchingFiles = Directory.GetFiles(kvp.Value, $"{selectedText}*", SearchOption.TopDirectoryOnly);
                matchingFileNames.AddRange(matchingFiles);
            }

            FilesDialog fd = new FilesDialog(matchingFileNames.ToArray());

            fd.Show();
        }
Exemplo n.º 23
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");
            someSetting = (Win32.GetPrivateProfileInt("SomeSection", "SomeKey", 0, iniFilePath) != 0);

            PluginBase.SetCommand(0, "Commit Code", pmlCommit, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand(1, "Available Versions", availableVersions);
            PluginBase.SetCommand(2, "Revert to This", revertToOldVersion);

            //PluginBase.SetCommand(3, "Select Language", languageSetup); //Implement later
            idMyDlg = 1;
            //PluginBase.SetCommand(2, "Test", availableVersions); idMyDlg = 1;
        }
Exemplo n.º 24
0
        internal static void CommandMenuInit()
        {
            StringBuilder sbIniFilePath = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, sbIniFilePath);
            iniFilePath = sbIniFilePath.ToString();
            if (!Directory.Exists(iniFilePath))
            {
                Directory.CreateDirectory(iniFilePath);
            }
            IniPath     = iniFilePath;
            iniFilePath = Path.Combine(iniFilePath, PluginName + ".ini");

            Settings.OutputPanel.SetDefaultBGColor(Win32.GetPrivateProfileInt("OutputPanel", "BackgroundColor", Color.LightGray.ToArgb(), iniFilePath));
            Settings.OutputPanel.SetDefaultTextColor(Win32.GetPrivateProfileInt("OutputPanel", "DefaultTextColor", Color.Black.ToArgb(), iniFilePath));
            Settings.OutputPanel.Bold     = (Win32.GetPrivateProfileInt("OutputPanel", "BoldStyle", 0, iniFilePath) != 0);
            Settings.OutputPanel.Italic   = (Win32.GetPrivateProfileInt("OutputPanel", "ItalicStyle", 0, iniFilePath) != 0);
            Settings.OutputPanel.FontSize = (Win32.GetPrivateProfileInt("OutputPanel", "FontSize", 12, iniFilePath));
            StringBuilder fontNameBuilder = new StringBuilder(32767);

            Win32.GetPrivateProfileString("OutputPanel", "FontName", "Consolas", fontNameBuilder, 32767, iniFilePath);
            Settings.OutputPanel.FontName = fontNameBuilder.ToString();
            StringBuilder colorOverrides       = new StringBuilder(32767);
            string        coloroverridedefault = "Black,LightGray;Blue,Blue;Cyan,Cyan;DarkBlue,DarkBlue;DarkCyan,DarkCyan;DarkGray,DarkGray;DarkGreen,DarkGreen;" +
                                                 "DarkMagenta,DarkMagenta;DarkRed,DarkRed;DarkYellow,YellowGreen;Green,Green;Magenta,Magenta;Red,Red;White,White;Yellow,Yellow;";

            Win32.GetPrivateProfileString("OutputPanel", "ColorOverrides", coloroverridedefault, colorOverrides, 32767, iniFilePath);
            Settings.OutputPanel.ColorOverrides = colorOverrides.ToString();
            StringBuilder llStrBuilder = new StringBuilder(32767);

            Win32.GetPrivateProfileString("OutputPanel", "LogLevel", "warn", llStrBuilder, 32767, iniFilePath);
            Settings.OutputPanel.LogLevel = llStrBuilder.ToString();


            PluginBase.SetCommand(0, "Run/Stop Script", RunStopTS, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand(1, "Output Panel", OutputDockableDialog); outputDialogId = 1;
            PluginBase.SetCommand(2, "---", null); funcTipsDialogId = 2;//function tips not implemented yet
            PluginBase.SetCommand(3, "---", null);
            PluginBase.SetCommand(4, "Settings", SettingsDialog); settingsDialogId = 4;
        }
Exemplo n.º 25
0
        internal static void myMenuFunction()
        {
            try
            {
                IntPtr hCurrScintilla = PluginBase.GetCurrentScintilla();
                int    textLen        = (int)Win32.SendMessage(hCurrScintilla, SciMsg.SCI_GETLENGTH, 0, 0);
                IntPtr ptrText        = Marshal.AllocHGlobal(textLen + 5);
                Win32.SendMessage(hCurrScintilla, SciMsg.SCI_GETTEXT, textLen + 1, ptrText);
                string s = Marshal.PtrToStringAnsi(ptrText);
                s = s.Trim();
                List <Error> errors = new List <Error>();
                string[]     lines  = s.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
                Error        error  = null;
                //Marshal.FreeHGlobal(ptrText);


                for (int i = 0; i < lines.Length; i++)
                {
                    try
                    {
                        error = Helper.CheckLine(lines[i], i);
                    }
                    catch (Exception)
                    {
                    }
                    if (error != null)
                    {
                        errors.Add(error);
                    }
                }

                myDockableDialog(errors);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemplo n.º 26
0
 private static void generateDiagram()
 {
     try
     {
         IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
         ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);
         // Get selected text.
         string        selectedText = scintillaGateway.GetSelText();
         var           lines        = selectedText.Split('\n');
         DrawIOBuilder builder      = new DrawIOBuilder();
         for (var i = 0; i < lines.Length; i++)
         {
             var line = lines[i];
             lines[i] = line.Trim(new char[] { ' ', '\r' });
         }
         DrawIOComponent[] drawIOComponent = builder.FlowchartBuilder(lines);
         builder.CopyToClipBoard(drawIOComponent);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 27
0
        internal static void CommandMenuInit()
        {
            InitPluginIniParameters();

            PluginBase.SetCommand(commandIndexCounter, "Show vertical lines", ShowMultipleVerticalLines, new ShortcutKey(false, false, false, Keys.None), ShowVerticalLines);
            ToggleVerticalLinesCommandId = commandIndexCounter++;
            PluginBase.SetCommand(commandIndexCounter, "Add vertical line...", AddVerticalLine, new ShortcutKey(false, false, false, Keys.None));
            AddVerticalLineCommandId = commandIndexCounter++;
            PluginBase.SetCommand(commandIndexCounter, "Clear all vertical lines", ClearAllVerticalLines, new ShortcutKey(false, false, false, Keys.None));
            ClearVerticalLinesCommandId = commandIndexCounter++;

            PluginBase.SetCommand(commandIndexCounter++, "---", null);
            PluginBase.SetCommand(commandIndexCounter, "Source Navigation Panel", SourceNavigationDialog);
            SNDialogStruct.FormCommandId = commandIndexCounter++;
            PluginBase.SetCommand(commandIndexCounter++, "Go to SECTION/PERFORM", GotoSectionOrPerform, new ShortcutKey(false, false, false, Keys.F9));

            PluginBase.SetCommand(commandIndexCounter++, "---", null);
            PluginBase.SetCommand(commandIndexCounter, "Toggle COBOL-like words", ToggleCobolLikeWords, new ShortcutKey(false, false, false, Keys.None));
            ToggleCobolWordsCommandId = commandIndexCounter++;

            PluginBase.SetCommand(commandIndexCounter++, "---", null);
            PopulateMenuSnippetsCommands();
        }
Exemplo n.º 28
0
        internal static void saveAsDrawIO()
        {
            try
            {
                frmMyDlg frmMyDlg = new frmMyDlg();
                var      filename = frmMyDlg.filename;

                IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
                ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);
                // Get selected text.
                string selectedText = scintillaGateway.GetSelText();
                var    lines        = selectedText.Split('\n'); for (var i = 0; i < lines.Length; i++)
                {
                    var line = lines[i];
                    lines[i] = line.Trim(new char[] { ' ', '\r' });
                }
                DrawIOBuilder     builder         = new DrawIOBuilder();
                DrawIOComponent[] drawIOComponent = builder.FlowchartBuilder(lines);
                builder.SaveToFile(filename, drawIOComponent);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 29
0
        private static bool SearchNextSectionOrPerform(string sectionName, int offset)
        {
            var editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());

            using (TextToFind textToFind = new TextToFind(offset, editor.GetTextLength() - 1, sectionName))
            {
                Position sectionPosition = editor.FindText(0, textToFind);
                if (sectionPosition.Value >= 0)
                {
                    if (editor.GetLine(editor.LineFromPosition(sectionPosition)).StartsWith("*"))
                    {
                        CurrentSearchOffset = sectionPosition.Value + sectionName.Length;
                        return(SearchNextSectionOrPerform(sectionName, CurrentSearchOffset));
                    }
                    ScrollToLine(editor.LineFromPosition(sectionPosition));
                    CurrentSearchOffset = sectionPosition.Value + sectionName.Length;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemplo n.º 30
0
 internal static void CommandMenuInit()
 {
     PluginBase.SetCommand(0, "Table Generator", myDockableDialog); idMyDlg = 0;
 }