Esempio n. 1
0
        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];
            }
        }
Esempio n. 2
0
 private static void AssertValidFile(CWFile file, string caller)
 {
     if (GetFile(file) == null)
     {
         throw new PluginException("Invalid file handle.", caller);
     }
 }
Esempio n. 3
0
        public static bool IsFileOpen(CWFile File)
        {
            AssertOpenProject("IsFileOpen");
            AssertValidFile(File, "IsFileOpen");

            return(GetEditor(GetFile(File)) != null);
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        public static void RemoveFile(CWFile FileInfo)
        {
            AssertOpenProject("RemoveFile");
            AssertValidFile(FileInfo, "RemoveFile");

            g.Main.DeleteFile(GetFile(FileInfo), false);
        }
Esempio n. 6
0
        public static string EditorGetText(CWFile File)
        {
            AssertOpenProject("EditorGetText");
            AssertOpenFile(File, "EditorGetText");

            return(GetEditor(GetFile(File)).txtEditor.Document.Text);
        }
Esempio n. 7
0
        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;
            }
        }
Esempio n. 8
0
        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();
            }
        }
Esempio n. 9
0
        public static void CloseFile(CWFile FileInfo, bool PromptForSaveIfDirty, bool ForceSaveIfDirty)
        {
            AssertOpenProject("CloseFile");
            AssertOpenFile(FileInfo, "CloseFile");

            g.Main.CloseFile(GetFile(FileInfo), PromptForSaveIfDirty, ForceSaveIfDirty);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        public static void OpenFile(CWFile FileInfo, int JumpToOffset)
        {
            AssertOpenProject("OpenFile");
            AssertValidFile(FileInfo, "OpenFile");

            g.Main.OpenFile(GetFile(FileInfo), JumpToOffset, true);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        public static string EditorGetSelected(CWFile File)
        {
            AssertOpenProject("EditorInsertText");
            AssertOpenFile(File, "EditorInsertText");

            return(GetEditor(GetFile(File)).txtEditor.SelectedView.SelectedText);
        }
Esempio n. 14
0
        public static void EditorSetText(CWFile File, string text)
        {
            AssertOpenProject("EditorSetText");
            AssertOpenFile(File, "EditorSetText");

            GetEditor(GetFile(File)).txtEditor.Document.Text = text;
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        private static CProject.File GetFile(CWFile file)
        {
            foreach (CProject.File fileX in g.Project.FileList)
            {
                if (fileX.GetHashCode() == file.id)
                {
                    return(fileX);
                }
            }

            return(null);
        }
Esempio n. 18
0
        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);
            }
        }
Esempio n. 19
0
        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);
            }
        }
Esempio n. 20
0
        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 });
            }
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
 public void CWEditorTriggerFire(CWFile FileDetails, string TriggerName)
 {
 }
Esempio n. 24
0
 public void CWFileAfterSave(CWFile FileDetails)
 {
 }
Esempio n. 25
0
 public void CWFileAfterClose(CWFile FileDetails)
 {
 }
Esempio n. 26
0
 public void CWFileAfterLoad(CWFile FileDetails)
 {
 }
Esempio n. 27
0
        public static void SaveFile(CWFile File)
        {
            AssertOpenFile(File, "SaveFile");

            GetEditor(GetFile(File)).CommitSave(GetFile(File));
        }