public static void EditorSetCaret(CWFile File, int[] position, bool isOffset) { AssertOpenProject("EditorSetCaret"); AssertOpenFile(File, "EditorSetCaret"); UCEditor editor = GetEditor(GetFile(File)); if (!isOffset) { // Try to cast the line/column thing into an offset try { int pos = editor.txtEditor.Document.PositionToOffset(new ActiproSoftware.SyntaxEditor.Position(position[0], position[1])); editor.txtEditor.SelectedView.Selection.StartOffset = pos; editor.txtEditor.SelectedView.Selection.EndOffset = pos; } catch { throw new PluginException("Unable to cast the specified line/column combination into an offset.", "EditorSetCaret"); } } else { editor.txtEditor.SelectedView.Selection.StartOffset = position[0]; editor.txtEditor.SelectedView.Selection.EndOffset = position[0]; } }
private static void AssertValidFile(CWFile file, string caller) { if (GetFile(file) == null) { throw new PluginException("Invalid file handle.", caller); } }
public static bool IsFileOpen(CWFile File) { AssertOpenProject("IsFileOpen"); AssertValidFile(File, "IsFileOpen"); return(GetEditor(GetFile(File)) != null); }
public static void AddIndicatorSpan(CWFile File, string IndicatorName, int startoffset, int endoffset, Image marginIcon, Color lineForeColor, Color lineBackColor, bool Bold, bool Italic, bool Underline) { if (g.Project == null) { throw new PluginException("Attempting to add indicator with no project open.", "AddIndicatorSpan"); } CProject.File file = GetFile(File); if (file == null) { throw new PluginException("Invalid CWFile instance -- file is not in project.", "AddIndicatorSpan"); } // Check to see if the file is open UCEditor editor = GetEditor(file); if (editor == null) { throw new PluginException("File specified is not open", "AddIndicatorSpan"); } // Finally, add the indicator editor.txtEditor.Document.Indicators.Add( new CIndicators.CustomIndicator(IndicatorName, marginIcon, lineForeColor, lineBackColor, Bold, Italic, Underline), startoffset, (endoffset - startoffset)); }
public static void RemoveFile(CWFile FileInfo) { AssertOpenProject("RemoveFile"); AssertValidFile(FileInfo, "RemoveFile"); g.Main.DeleteFile(GetFile(FileInfo), false); }
public static string EditorGetText(CWFile File) { AssertOpenProject("EditorGetText"); AssertOpenFile(File, "EditorGetText"); return(GetEditor(GetFile(File)).txtEditor.Document.Text); }
public static void SetFile(CWFile File) { AssertOpenProject("SetFile"); AssertValidFile(File, "SetFile"); CProject.File actfile = GetFile(File); actfile.FileIcon = File.file_icon; actfile.isDirty = File.is_dirty; actfile.isForcedReload = File.is_forced_reload; actfile.isForeign = File.is_foreign; actfile.isPendingReload = File.is_pending_reload; actfile.RelativePath = File.relative_path; actfile.SimpleName = File.simple_name; if (File.parent_dir != null) { AssertValidDirectory(File.parent_dir, "SetFile__SetDirectoryOnFile"); actfile.ParentDir = GetDir(File.parent_dir); } else { actfile.ParentDir = null; } }
public static void DebugDelBreakpoint(CWFile File, int line) { AssertOpenProject("DebugDelBreakpoint"); AssertValidFile(File, "DebugDelBreakpoint"); CProject.File file = GetFile(File); // Find the breakpoint foreach (CProject.Breakpoint bp in g.Project.ProjectBreaks) { if (bp.file == file && bp.LineNumber == line) { g.Project.ProjectBreaks.Remove(bp); break; } } // Update the breakpoints if the file is open UCEditor editor = GetEditor(file); if (editor != null) { editor.BreakpointRender(); } }
public static void CloseFile(CWFile FileInfo, bool PromptForSaveIfDirty, bool ForceSaveIfDirty) { AssertOpenProject("CloseFile"); AssertOpenFile(FileInfo, "CloseFile"); g.Main.CloseFile(GetFile(FileInfo), PromptForSaveIfDirty, ForceSaveIfDirty); }
public static int[] DebugGetBreakpoints(CWFile File) { AssertOpenProject("DebugGetBreakpoints"); AssertValidFile(File, "DebugGetBreakpoints"); CProject.File file = GetFile(File); // Go through the breakpoints ArrayList breakpoints = new ArrayList(); foreach (CProject.Breakpoint bp in g.Project.ProjectBreaks) { if (bp.file == file) { breakpoints.Add(bp.LineNumber); } } // Turn it into an array int[] output = new int[breakpoints.Count]; for (int i = 0; i < breakpoints.Count; i++) { output[i] = (int)breakpoints[i]; } return(output); }
public static void OpenFile(CWFile FileInfo, int JumpToOffset) { AssertOpenProject("OpenFile"); AssertValidFile(FileInfo, "OpenFile"); g.Main.OpenFile(GetFile(FileInfo), JumpToOffset, true); }
public static void AddIndicatorIcon(CWFile File, string IndicatorName, int line, Image marginIcon) { if (g.Project == null) { throw new PluginException("Attempting to add indicator with no project open.", "AddIndicatorSpan"); } CProject.File file = GetFile(File); if (file == null) { throw new PluginException("Invalid CWFile instance -- file is not in project.", "AddIndicatorSpan"); } // Check to see if the file is open UCEditor editor = GetEditor(file); if (editor == null) { throw new PluginException("File specified is not open", "AddIndicatorSpan"); } // Add the indicator editor.txtEditor.Document.Indicators.Add( new CIndicators.CustomIconIndicator(IndicatorName, marginIcon), line); }
public static string EditorGetSelected(CWFile File) { AssertOpenProject("EditorInsertText"); AssertOpenFile(File, "EditorInsertText"); return(GetEditor(GetFile(File)).txtEditor.SelectedView.SelectedText); }
public static void EditorSetText(CWFile File, string text) { AssertOpenProject("EditorSetText"); AssertOpenFile(File, "EditorSetText"); GetEditor(GetFile(File)).txtEditor.Document.Text = text; }
public static void EditorInsertText(CWFile File, int offset, string text) { AssertOpenProject("EditorInsertText"); AssertOpenFile(File, "EditorInsertText"); EditorSetCaret(File, new int[] { offset }, true); GetEditor(GetFile(File)).txtEditor.SelectedView.InsertText(text); }
public static CWObjects IntellicodeObjectsInFile(CWFile File) { AssertOpenProject("IntellicodeObjectsInProject"); AssertValidFile(File, "IntellicodeObjectsInProject"); CProject.File file = GetFile(File); CWObjects objout = new CWObjects(File, new ArrayList()); foreach (CProject.TokenKey tok in file.TokenList.Values) { objout.objects.Add(new CWObjects.CWObject( CWObjectType.DefinedFunction, "", tok.FuncName, String.Join(", ", tok.FuncParams), tok.FuncDescr, tok.LineNumber)); } foreach (CProject.TokenObject tokobj in g.Project.TokenObjList.Values) { if (tokobj.ObjectFileDecl != file) { continue; } objout.objects.Add(new CWObjects.CWObject( CWObjectType.DefinedClass, tokobj.ObjectType, tokobj.ObjectName, "", "", tokobj.ObjectDeclOffset)); foreach (CProject.TokenObject.ObjectDescr objdescr in tokobj.ObjectFunctions) { if (objdescr.FuncFile != file) { continue; } objout.objects.Add(new CWObjects.CWObject( CWObjectType.DefinedClassFunction, tokobj.ObjectName, objdescr.FuncName, String.Join(", ", objdescr.FuncParams), objdescr.FuncDescr, objdescr.FuncOffset)); } } return(objout); }
private static CProject.File GetFile(CWFile file) { foreach (CProject.File fileX in g.Project.FileList) { if (fileX.GetHashCode() == file.id) { return(fileX); } } return(null); }
private static void AssertOpenFile(CWFile file, string caller) { CProject.File actfile = GetFile(file); if (actfile == null) { throw new PluginException("Invalid file handle.", caller); } if (GetEditor(actfile) == null) { throw new PluginException("File not open", caller); } }
public static void RemoveIndicator(CWFile File, string IndicatorName, int line) { if (g.Project == null) { throw new PluginException("Attempting to add indicator with no project open.", "AddIndicatorSpan"); } CProject.File file = GetFile(File); if (file == null) { throw new PluginException("Invalid CWFile instance -- file is not in project.", "AddIndicatorSpan"); } // Check to see if the file is open UCEditor editor = GetEditor(file); if (editor == null) { throw new PluginException("File specified is not open", "AddIndicatorSpan"); } // Remove the indicator ArrayList toremove = new ArrayList(); foreach (ActiproSoftware.SyntaxEditor.Indicator ind in editor.txtEditor.Document.Indicators) { if (ind is CIndicators.CustomIconIndicator) { if (line == -1) { toremove.Add(ind); } else if ((ind as CIndicators.CustomIconIndicator).LineIndex == line) { toremove.Add(ind); } } else if (ind is CIndicators.CustomIndicator) { toremove.Add(ind); } } foreach (ActiproSoftware.SyntaxEditor.Indicator ind in toremove) { editor.txtEditor.Document.Indicators.Remove(ind); } }
public static int[] EditorGetCaret(CWFile File, bool TranslateToOffset) { AssertOpenProject("EditorGetCaret"); AssertOpenFile(File, "EditorGetCaret"); UCEditor editor = GetEditor(GetFile(File)); if (TranslateToOffset) { return(new int[] { editor.txtEditor.SelectedView.Selection.StartOffset }); } else { ActiproSoftware.SyntaxEditor.Position pos = editor.txtEditor.Document.OffsetToPosition(editor.txtEditor.SelectedView.Selection.StartOffset); return(new int[] { pos.Line, pos.Character }); } }
public static void DebugAddBreakpoint(CWFile File, int line, int pass_count, bool clear_after_hit, string conditional) { AssertOpenProject("DebugAddBreakpoint"); AssertValidFile(File, "DebugAddBreakpoint"); CProject.File file = GetFile(File); // Create a new instance of the breakpoint CProject.Breakpoint bp = new CProject.Breakpoint(file, line, pass_count, ((conditional == "") ? "true" : conditional)); if (clear_after_hit == true) { throw new PluginException("NotImplemented: clear_after_hit cannot equal true. The enhanced telnetdebugger does not support this attribute yet.", "DebugAddBreakpoint"); } // Add the breakpoint g.Project.ProjectBreaks.Add(bp); }
public static CWErrors IntellicodeScanFile(CWFile File) { AssertOpenProject("IntellicodeScanFile"); AssertValidFile(File, "IntellicodeScanFile"); netMercs.TorqueDev.Lexer.ErrorCollection errcoll = null; CWErrors errout = new CWErrors(File, new ArrayList()); errcoll = g.Main.ScanFile(GetFile(File)); // Translate the errors foreach (netMercs.TorqueDev.Lexer.Error err in errcoll) { errout.file_errors.Add(new CWErrors.CWError( err.Text, err.Line, err.Column)); } return(errout); }
public void CWEditorTriggerFire(CWFile FileDetails, string TriggerName) { }
public void CWFileAfterSave(CWFile FileDetails) { }
public void CWFileAfterClose(CWFile FileDetails) { }
public void CWFileAfterLoad(CWFile FileDetails) { }
public static void SaveFile(CWFile File) { AssertOpenFile(File, "SaveFile"); GetEditor(GetFile(File)).CommitSave(GetFile(File)); }