void MembersList_MouseDoubleClick(object sender, MouseEventArgs e) { if (membersList.SelectedItem != null) { var info = (membersList.SelectedItem as MemberInfo); try { membersList.SelectedItem = null; if (info.Line != -1) { Npp.GrabFocus(); int currentLineNum = Npp.GetCaretLineNumber(); int prevLineEnd = Npp.GetLineStart(currentLineNum) - Environment.NewLine.Length; int topScrollOffset = currentLineNum - Npp.GetFirstVisibleLine(); Win32.SendMessage(Npp.CurrentScintilla, SciMsg.SCI_GOTOLINE, info.Line, 0); Npp.SetFirstVisibleLine(info.Line - topScrollOffset); } } catch { } //it is expected to fail if the line does not contain the file content position spec. This is also the reason for not validating any "IndexOf" results. } }
void Run(bool asExternal) { if (currentScript == null) { 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(); outputPanel.AttachDebuger(); outputPanel.ClearAllDefaultOutputs(); Task.Factory.StartNew(() => { try { outputPanel.ShowDebugOutput(); if (Config.Instance.InterceptConsole) { CSScriptHelper.Execute(currentScript, OnRunStart, OnConsoleOutChar); } else { CSScriptHelper.Execute(currentScript, OnRunStart); } } catch (Exception e) { outputPanel.ShowBuildOutput() .WriteLine(e.Message) .SetCaretAtStart(); } finally { this.InUiThread(() => { Plugin.RunningScript = null; RefreshControls(); Npp.GrabFocus(); }); } }); } } catch (Exception ex) { Plugin.ShowOutputPanel() .ShowBuildOutput() .WriteLine(ex.Message) .SetCaretAtStart(); } } }