예제 #1
0
        /// <summary>
        /// Handles the clicks on the link displayed in the tooltip
        /// </summary>
        /// <param name="htmlLinkClickedEventArgs"></param>
        private static void ClickHandler(HtmlLinkClickedEventArgs htmlLinkClickedEventArgs)
        {
            var  split      = htmlLinkClickedEventArgs.Link.Split('#');
            var  actionType = split[0];
            bool handled    = true;

            switch (actionType)
            {
            case "gotoownerfile":
                if (split.Length > 1)
                {
                    Npp.Goto(split[1]);
                    Close();
                }
                break;

            case "trigger":
                if (split.Length > 1)
                {
                    var fullPath = ProEnvironment.Current.FindFirstFileInEnv(split[1]);
                    Npp.Goto(string.IsNullOrEmpty(fullPath) ? split[1] : fullPath);
                    Close();
                }
                break;

            case "proto":
                if (split.Length > 3)
                {
                    Npp.Goto(split[1], int.Parse(split[2]), int.Parse(split[3]));
                    Close();
                }
                break;

            case "gotodefinition":
                ProMisc.GoToDefinition();
                break;

            case "nexttooltip":
                IndexToShow++;
                TryToShowIndex();
                break;

            default:
                handled = false;
                break;
            }
            htmlLinkClickedEventArgs.Handled = handled;
        }
예제 #2
0
        public static bool MouseMessageHandler(WinApi.Messages message, Win32Api.MOUSEHOOKSTRUCT mouseStruct)
        {
            switch (message)
            {
            // middle click : go to definition
            case WinApi.Messages.WM_MBUTTONDOWN:
                if (Npp.CurrentFileInfo.IsProgress)
                {
                    if (KeyboardMonitor.GetModifiers.IsCtrl)
                    {
                        Npp.GoBackFromDefinition();
                    }
                    else
                    {
                        ProMisc.GoToDefinition(true);
                    }
                }
                return(true);

            //break;
            // (CTRL + ) Right click : show main menu
            case WinApi.Messages.WM_RBUTTONUP:
                if (KeyboardMonitor.GetModifiers.IsCtrl)
                {
                    // we need the cursor to be in scintilla but not on the application or the autocompletion!
                    if ((!Appli.IsVisible || !Appli.IsMouseIn()) &&
                        (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) &&
                        (!AutoCompletion.IsVisible || !AutoCompletion.IsMouseIn()))
                    {
                        AppliMenu.ShowMainMenu(true);
                        return(true);
                    }
                }
                break;
            }

            return(false);
        }
예제 #3
0
        private AppliMenu()
        {
            // List of item that can be assigned to a shortcut
            ShortcutableItemList = new List <MenuItem> {
                // add the main menu here, so it can appear in the list of shortcut to set
                new MenuItem(null, "Open main menu", ImageResources.Logo20x20, item => ShowMainMenu(), "Show_main_menu_", "Alt+C")
                {
                    Generic = true
                }
            };

            #region Progress tools

            _progressTools = new List <MenuItem> {
                new MenuItem(this, "Progress desktop", ImageResources.ProDesktop, item => ProMisc.OpenProDesktop(), "Pro_desktop", "")
                {
                    Generic = true
                },
                new MenuItem(this, "Open in the AppBuilder", ImageResources.SendToAppbuilder, item => ProMisc.OpenCurrentInAppbuilder(), "Send_appbuilder", "Alt+O"),
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "PROLINT code", ImageResources.ProlintCode, item => ProMisc.StartProgressExec(ExecutionType.Prolint), "Prolint", "F12"),
                new MenuItem(this, "Deploy current file", ImageResources.Deploy, item => ProMisc.DeployCurrentFile(), "Deploy", "Ctrl+Alt+Prior")
                {
                    Generic = true
                },
                new MenuItem(this, "Generate DEBUG-LIST", ImageResources.ExtDbg, item => ProMisc.StartProgressExec(ExecutionType.GenerateDebugfile, compilation => compilation.CompileWithDebugList = true), "Generate_debug-list", null),
                new MenuItem(this, "Generate LISTING", ImageResources.ExtLis, item => ProMisc.StartProgressExec(ExecutionType.GenerateDebugfile, compilation => compilation.CompileWithListing      = true), "Generate_listing", null),
                new MenuItem(this, "Generate XREF", ImageResources.ExtXrf, item => ProMisc.StartProgressExec(ExecutionType.GenerateDebugfile, compilation => compilation.CompileWithXref            = true), "Generate_xref", null),
                new MenuItem(this, "Generate XREF-XML", ImageResources.ExtXml, item => ProMisc.StartProgressExec(ExecutionType.GenerateDebugfile, compilation => {
                    compilation.CompileWithXref = true;
                    compilation.UseXmlXref      = true;
                }), "Generate_xrefxml", null),
            };

            #endregion

            #region Generate code

            _generateCodeMenuList = new List <MenuItem> {
                new MenuItem(this, "Insert new internal procedure", ImageResources.Procedure, item => ProGenerateCode.Factory.InsertCode <ParsedProcedure>(), "Insert_new_procedure", "Alt+P"),
                new MenuItem(this, "Insert new function", ImageResources.Function, item => ProGenerateCode.Factory.InsertCode <ParsedImplementation>(), "Insert_new_function", "Alt+F"),
                new MenuItem(true), // --------------------------
                new MenuItem(this, "Delete existing internal procedure", ImageResources.DeleteProcedure, item => ProGenerateCode.Factory.DeleteCode <ParsedProcedure>(), "Delete_procedure", ""),
                new MenuItem(this, "Delete existing function", ImageResources.DeleteFunction, item => ProGenerateCode.Factory.DeleteCode <ParsedImplementation>(), "Delete_function", ""),
                new MenuItem(true), // --------------------------
                new MenuItem(this, "Synchronize function prototypes", ImageResources.Synchronize, item => ProGenerateCode.Factory.UpdateFunctionPrototypesIfNeeded(), "Synchronize_prototypes", "Alt+S")
            };

            #endregion

            #region Edit code

            _editCodeList = new List <MenuItem> {
                new MenuItem(this, "Display parser errors", ImageResources.DisplayParserResults, item => ProCodeFormat.DisplayParserErrors(), "Check_parser_errors", null),
                new MenuItem(this, "Toggle comment line", ImageResources.ToggleComment, item => ProMisc.ToggleComment(), "Toggle_Comment", "Ctrl+Q"),
                new MenuItem(this, "Correct indentation (selection or all)", ImageResources.IndentCode, item => ProCodeFormat.CorrectCodeIndentation(), "Reindent_document", "Ctrl+I")
                //new MenuItem(this, "Format document", ImageResources.FormatCode, CodeBeautifier.CorrectCodeIndentation, "Format_document", "Ctrl+I"),
            };

            #endregion

            #region Misc

            _modificationTagMenuList = new List <MenuItem> {
                new MenuItem(this, "Edit current file info", ImageResources.FileInfo, item => Appli.Appli.GoToPage(PageNames.FileInfo), "Edit_file_info", "Ctrl+Shift+M"),
                new MenuItem(this, "Insert title block", ImageResources.TitleBlock, item => ModificationTag.AddTitleBlockAtCaret(), "Insert_title_block", "Ctrl+Alt+M"),
                new MenuItem(this, "Surround with modification tags", ImageResources.ModificationTag, item => ModificationTag.SurroundSelectionWithTag(), "Modif_tags", "Ctrl+M")
                //new MenuItem(this, "Insert mark", ImageResources.InsertMark, null, "Insert_mark", "Ctrl+T"),
            };

            #endregion

            #region database tools

            _databaseTools = new List <MenuItem> {
                new MenuItem(this, "Open data administration", ImageResources.DataAdmin, item => ProMisc.OpenDbAdmin(), "Data_admin", "")
                {
                    Generic = true
                },
                new MenuItem(this, "Open progress dictionary", ImageResources.Dictionary, item => ProMisc.OpenDictionary(), "Data_dictionary", "")
                {
                    Generic = true
                },
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Explore and modify your data", ImageResources.DataDigger, item => ProMisc.OpenDataDigger(), "Data_digger", "")
                {
                    Generic = true
                },
                new MenuItem(this, "Explore (read-only) your data", ImageResources.DataReader, item => ProMisc.OpenDataReader(), "Data_reader", "")
                {
                    Generic = true
                }
            };

            #endregion

            #region Main menu

            var goToDefItem = new MenuItem(this, "Go to definition", ImageResources.GoToDefinition, item => ProMisc.GoToDefinition(false), "Go_To_Definition", "Ctrl+B")
            {
                Generic = true
            };
            goToDefItem.SubText = "Middle click  /  " + goToDefItem.SubText;
            var goToPreviousJump = new MenuItem(this, "Go to previous jump point", ImageResources.GoBackward, item => Npp.GoBackFromDefinition(), "Go_Backwards", "Ctrl+Shift+B")
            {
                Generic = true
            };
            goToPreviousJump.SubText = "Ctrl + Middle click  /  " + goToPreviousJump.SubText;

            MainMenuList = new List <MenuItem> {
                new MenuItem(this, "Show main window", ImageResources.MainWindow, item => Appli.Appli.ToggleView(), "Open_main_window", "Alt+Space")
                {
                    Generic = true
                },
                new MenuItem(this, "Show autocompletion at caret", ImageResources.Autocompletion, item => AutoCompletion.OnShowCompleteSuggestionList(), "Show_Suggestion_List", "Ctrl+Space")
                {
                    Generic = true
                },
                new MenuItem(this, "Toggle current file as progress", ImageResources.Progress, item => ProMisc.ReadCurrentFileAsProgress(), "Read_as_progress", null)
                {
                    Generic = true
                },
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Open 4GL help", ImageResources.ProgressHelp, item => ProMisc.Open4GlHelp(), "Open_4GL_help", "F1")
                {
                    Generic = true
                },
                new MenuItem(this, "Check syntax", ImageResources.CheckCode, item => ProMisc.StartProgressExec(ExecutionType.CheckSyntax), "Check_syntax", "Shift+F1"),
                new MenuItem(this, "Run program", ImageResources.RunCode, item => ProMisc.StartProgressExec(ExecutionType.Run), "Run_program", "Ctrl+F1"),
                new MenuItem(this, "Compile", ImageResources.CompileCode, item => ProMisc.StartProgressExec(ExecutionType.Compile), "Compile", "Alt+F1"),
                new MenuItem(this, "Compile options", ImageResources.CompileOptions, item => ProMisc.OpenCompilationOptions(), "Compile_options", null),
                new MenuItem(this, "Progress tools", ImageResources.ProgressTools, item => ShowProgressToolsMenu(), "Progress_tools", "Alt+T")
                {
                    Generic  = true,
                    Children = _progressTools.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Start searching files", ImageResources.Search, item => FileExplorer.FileExplorer.Instance.StartSearch(), "Search_file", "Alt+Q")
                {
                    Generic = true
                },
                goToDefItem,
                goToPreviousJump,
                //new MenuItem(this, "New 4GL file", ImageResources.GenerateCode, ShowNewFileAtCursor, "New_file", "Ctrl+Shift+N") {
                //    Children = GenerateCodeMenuList.Select(item => (YamuiMenuItem)item).ToList(),
                //},
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Switch environment", ImageResources.Env, item => ShowEnvMenu(), "Switch_env", "Ctrl+E")
                {
                    Generic = true
                },
                new MenuItem(this, "Database tools", ImageResources.DatabaseTools, item => ShowDatabaseToolsMenu(), "DatabaseTools", "Alt+D")
                {
                    Generic  = true,
                    Children = _databaseTools.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(this, "Generate and revise code", ImageResources.GenerateCode, item => ShowGenerateCodeMenu(), "Generate_code", "Alt+Insert")
                {
                    Generic  = true,
                    Children = _generateCodeMenuList.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(this, "Edit code", ImageResources.EditCode, item => ShowEditCodeMenu(), "Edit_code", "Alt+E")
                {
                    Generic  = true,
                    Children = _editCodeList.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(this, "Modification tag", ImageResources.ModificationTagMenu, item => ShowMiscMenu(), "Modification_tag", "Alt+M")
                {
                    Generic  = true,
                    Children = _modificationTagMenuList.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Options", ImageResources.ShowOptions, item => Appli.Appli.GoToPage(PageNames.OptionsGeneral), "Go_to_options", null)
                {
                    Generic = true
                }
            };

            #endregion

            #region special dev

            if (Config.IsDeveloper)
            {
                MainMenuList.Add(
                    new MenuItem(this, "Tests", ImageResources.Tests, null, null, null, new List <MenuItem> {
                    new MenuItem(this, "DebugTest1", ImageResources.TestTube, item => PlugDebug.DebugTest1(), "DebugTest1", "Ctrl+OemQuotes")
                    {
                        Generic = true
                    },
                    new MenuItem(this, "DebugTest2", ImageResources.TestTube, item => PlugDebug.DebugTest2(), "DebugTest2", "Alt+OemQuotes")
                    {
                        Generic = true
                    },
                    new MenuItem(this, "DebugTest3", ImageResources.TestTube, item => PlugDebug.DebugTest3(), "DebugTest3", "Shift+OemQuotes")
                    {
                        Generic = true
                    },
                    new MenuItem(this, "Parse current file", ImageResources.TestTube, item => PlugDebug.ParseCurrentFile(), "ParseCurrentFile", "")
                    {
                        Generic = false
                    },
                    new MenuItem(this, "GetCurrentFileParsedDebugfile", ImageResources.TestTube, item => PlugDebug.GetCurrentFileParsedDebugfile(), "GetCurrentFileParsedDebugfile", "")
                    {
                        Generic = false
                    },
                    new MenuItem(this, "Parse reference file", ImageResources.TestTube, item => PlugDebug.ParseReferenceFile(), "ParseReferenceFile", "")
                    {
                        Generic = true
                    },
                    new MenuItem(this, "Parse all files", ImageResources.TestTube, item => PlugDebug.ParseAllFiles(), "ParseAllFiles", "")
                    {
                        Generic = true
                    }
                })
                {
                    Generic = true
                });
            }

            #endregion
        }
예제 #4
0
        public static bool MouseMessageHandler(WinApi.Messages message, Win32Api.MOUSEHOOKSTRUCT mouseStruct)
        {
            switch (message)
            {
            // middle click : go to definition
            case WinApi.Messages.WM_MBUTTONDOWN:
                if (Npp.CurrentFileInfo.IsProgress)
                {
                    if (KeyboardMonitor.GetModifiers.IsCtrl)
                    {
                        Npp.GoBackFromDefinition();
                    }
                    else
                    {
                        ProMisc.GoToDefinition(true);
                    }
                }
                return(true);

            //break;
            // (CTRL + ) Right click : show main menu
            case WinApi.Messages.WM_RBUTTONUP:
                if (KeyboardMonitor.GetModifiers.IsCtrl)
                {
                    // we need the cursor to be in scintilla but not on the application or the autocompletion!
                    if ((!Appli.IsVisible || !Appli.IsMouseIn()) &&
                        (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) &&
                        (!AutoCompletion.IsVisible || !AutoCompletion.IsMouseIn()))
                    {
                        AppliMenu.ShowMainMenu(true);
                        return(true);
                    }
                }
                break;
            }

            // HACK: The following is to handle the MOVE/RESIZE event of npp's window.
            // It would be cleaner to use a WndProc bypass but it costs too much... this is a cheaper solution
            switch (message)
            {
            case WinApi.Messages.WM_NCLBUTTONDOWN:
                if (!WinApi.GetWindowRect(Npp.CurrentSci.Handle).Contains(Cursor.Position))
                {
                    MouseMonitor.Instance.Add(WinApi.Messages.WM_MOUSEMOVE);
                }
                break;

            case WinApi.Messages.WM_LBUTTONUP:
            case WinApi.Messages.WM_NCLBUTTONUP:
                if (MouseMonitor.Instance.Remove(WinApi.Messages.WM_MOUSEMOVE))
                {
                    if (OnNppWindowsMove != null)
                    {
                        OnNppWindowsMove();
                    }
                }
                break;

            case WinApi.Messages.WM_MOUSEMOVE:
                if (OnNppWindowsMove != null)
                {
                    OnNppWindowsMove();
                }
                break;
            }

            return(false);
        }