public static void EnsureIntellisenseIntegration() { //Debug.Assert(false); //Merge Configs CSScriptIntellisense.Config.Location = Plugin.ConfigDir; CSScriptNpp.Config.InitData(); //will also exchange required data between configs CSScriptIntellisense.Plugin.SuppressCodeTolltips = () => Debugger.IsInBreak; CSScriptIntellisense.Plugin.DisplayInOutputPanel = message => { Plugin.EnsureOutputPanelVisible(); OutputPanel.DisplayInGenericOutputPanel(message); }; CSScriptIntellisense.Plugin.ResolveCurrentFile = () => { if (string.IsNullOrEmpty(ProjectPanel.currentScript)) { return(Npp.GetCurrentFile()); } else { return(ProjectPanel.currentScript); } }; }
static public void InitOutputPanel() { if (Plugin.outputPanel == null) { Plugin.outputPanel = ShowDockablePanel <OutputPanel>("Output", outputPanelId, NppTbMsg.DWS_DF_CONT_BOTTOM | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR); Application.DoEvents(); } }
static internal void CleanUp() { Config.Instance.ShowProjectPanel = (dockedManagedPanels.ContainsKey(projectPanelId) && dockedManagedPanels[projectPanelId].Visible); Config.Instance.ShowOutputPanel = (dockedManagedPanels.ContainsKey(outputPanelId) && dockedManagedPanels[outputPanelId].Visible); Config.Instance.ShowDebugPanel = (dockedManagedPanels.ContainsKey(debugPanelId) && dockedManagedPanels[debugPanelId].Visible); Config.Instance.Save(); OutputPanel.Clean(); CloseAutomationChannel(); }
public void Build() { lock (this) { if (currentScript == null) { loadBtn.PerformClick(); } if (currentScript == null) { MessageBox.Show("Please load some script file first.", "CS-Script"); } else { OutputPanel outputPanel = Plugin.ShowOutputPanel(); outputPanel.ShowBuildOutput(); outputPanel.BuildOutput.Clear(); outputPanel.BuildOutput.WriteLine("------ Build started: Script: " + Path.GetFileNameWithoutExtension(currentScript) + " ------"); try { if (!CurrentDocumentBelongsToProject()) { EditItem(currentScript); } npp.SaveDocuments(GetProjectDocuments()); CSScriptHelper.Build(currentScript, line => outputPanel.BuildOutput.WriteLine(line)); outputPanel.BuildOutput.WriteLine(null) .WriteLine("========== Build: succeeded ==========") .SetCaretAtStart(); } catch (Exception ex) { outputPanel.ShowBuildOutput() .WriteLine(null) .WriteLine(ex.Message) .WriteLine("========== Build: Failed ==========") .SetCaretAtStart(); } } } }
static IEnumerable <Keys> BindInternalShortcuts() { var uniqueKeys = new Dictionary <Keys, int>(); AddInternalShortcuts("Build:F7", "Build (validate)", Build, uniqueKeys); AddInternalShortcuts("LoadCurrentDocument:Ctrl+F7", "Load Current Document", () => { InitProjectPanel(); ShowProjectPanel(); ProjectPanel.LoadCurrentDoc(); }, uniqueKeys); AddInternalShortcuts("Stop:Shift+F5", "Stop running script", Stop, uniqueKeys); AddInternalShortcuts("_Run:F5", "Run", Run, uniqueKeys); AddInternalShortcuts("ShowNextFileLocationFromOutput:F4", "Next File Location in Output", () => { OutputPanel.TryNavigateToFileReference(toNext: true); }, uniqueKeys); AddInternalShortcuts("ShowPrevFileLocationFromOutput:Shift+F4", "Previous File Location in Output", () => { OutputPanel.TryNavigateToFileReference(toNext: false); }, uniqueKeys); return(uniqueKeys.Keys); }
public OutputPanel() { instance = this; InitializeComponent(); var cb = new CheckBox(); cb.Text = "Intercept StdOut"; cb.Checked = Config.Instance.InterceptConsole; cb.CheckStateChanged += (s, ex) => Config.Instance.InterceptConsole = cb.Checked; toolStrip1.Items.Insert(3, new ToolStripControlHost(cb) { ToolTipText = "Check to redirect the console output to the output panel" }); AddOutputType(BuildOutputName); AddOutputType(ConsoleOutputName); AddOutputType(GeneralOutputName); #if DEBUG AddOutputType(PluginLogOutputName); #endif }
void Run(bool asExternal) { if (currentScript == null || (Config.Instance.ReloadActiveScriptOnRun && currentScript != Npp.Editor.GetCurrentFilePath())) { loadBtn.PerformClick(); } if (currentScript == null) { MessageBox.Show("Please load some script file first.", "CS-Script"); } else { try { if (!CurrentDocumentBelongsToProject()) { EditItem(currentScript); } npp.SaveDocuments(GetProjectDocuments()); if (asExternal) { try { CSScriptHelper.ExecuteAsynch(currentScript); } catch (Exception e) { Plugin.ShowOutputPanel() .ShowBuildOutput() .WriteLine(e.Message) .SetCaretAtStart(); } } else { OutputPanel outputPanel = Plugin.ShowOutputPanel(); if (Config.Instance.StartDebugMonitorOnScriptExecution) { outputPanel.AttachDebgMonitor(); } outputPanel.ClearAllDefaultOutputs(); Task.Factory.StartNew(() => { try { if (Config.Instance.InterceptConsole) { CSScriptHelper.ExecuteScript(currentScript, OnRunStart, OnConsoleObjectOut); } else { CSScriptHelper.ExecuteScript(currentScript, OnRunStart); } } catch (Exception e) { this.InUiThread(() => { outputPanel.ShowBuildOutput() .WriteLine(e.Message) .SetCaretAtStart(); }); } finally { this.InUiThread(() => { Plugin.RunningScript = null; RefreshControls(); Npp.GetCurrentDocument().GrabFocus(); }); } }); } } catch (Exception ex) { Plugin.ShowOutputPanel() .ShowBuildOutput() .WriteLine(ex.Message) .SetCaretAtStart(); } } }
static IEnumerable <Keys> BindInteranalShortcuts() { var uniqueKeys = new Dictionary <Keys, int>(); AddInternalShortcuts("Build:F7", "Build (validate)", Build, uniqueKeys); AddInternalShortcuts("LoadCurrentDocument:Ctrl+F7", "Load Current Document", () => { InitProjectPanel(); ShowProjectPanel(); ProjectPanel.LoadCurrentDoc(); }, uniqueKeys); AddInternalShortcuts("Stop:Shift+F5", "Stop running script", Stop, uniqueKeys); AddInternalShortcuts("_Run:F5", "Run", Run, uniqueKeys); AddInternalShortcuts("_Debug:Alt+F5", "Debug", () => { if (!Debugger.IsRunning && Npp.Editor.IsCurrentDocScriptFile()) { DebugScript(); } }, uniqueKeys); AddInternalShortcuts("ToggleBreakpoint:F9", "Toggle Breakpoint", () => Debugger.ToggleBreakpoint(), uniqueKeys); AddInternalShortcuts("QuickWatch:Shift+F9", "Show QuickWatch...", QuickWatchPanel.PopupDialog, uniqueKeys); AddInternalShortcuts("StepInto:F11", "Step Into", Debugger.StepIn, uniqueKeys); AddInternalShortcuts("StepOut:Shift+F11", "Step Out", Debugger.StepOut, uniqueKeys); AddInternalShortcuts("StepOver:F10", "Step Over", StepOver, uniqueKeys); AddInternalShortcuts("SetNextIP:Ctrl+Shift+F10", "Set Next Statement", Debugger.SetInstructionPointer, uniqueKeys); AddInternalShortcuts("RunToCursor:Ctrl+F10", "Run To Cursor", Debugger.RunToCursor, uniqueKeys); AddInternalShortcuts("RunAsExternal:Ctrl+F5", "Run As External Process", () => { if (Npp.Editor.IsCurrentDocScriptFile()) { RunAsExternal(); } }, uniqueKeys); AddInternalShortcuts("ShowNextFileLocationFromOutput:F4", "Next File Location in Output", () => { OutputPanel.TryNavigateToFileReference(toNext: true); }, uniqueKeys); AddInternalShortcuts("ShowPrevFileLocationFromOutput:Shift+F4", "Previous File Location in Output", () => { OutputPanel.TryNavigateToFileReference(toNext: false); }, uniqueKeys); return(uniqueKeys.Keys); }