示例#1
0
        public static void      PreviewStackFrame(RowsDrawer rowsDrawer, Rect r, Frame frame)
        {
            if (frame.fileExist == true &&
                RowUtility.previewFrame != frame)
            {
                try
                {
                    RowUtility.previewLines = ConsoleUtility.files.GetFile(frame.fileName);
                    RowUtility.rowsDrawer   = rowsDrawer;
                    RowUtility.previewFrame = frame;
                    RowUtility.previewRect  = r;

                    FilesWatcher.Watch(frame.fileName);

                    RowUtility.previewEditorWindow      = RowUtility.drawingWindow;
                    RowUtility.rowsDrawer.AfterAllRows -= RowUtility.DrawPreview;
                    RowUtility.rowsDrawer.AfterAllRows += RowUtility.DrawPreview;
                }
                catch (Exception ex)
                {
                    InternalNGDebug.LogException(ex);
                    RowUtility.ClearPreview();
                }
            }
        }
示例#2
0
        private object  HandleKeyboard(object data)
        {
            RowsDrawer rowsDrawer = data as RowsDrawer;

            if (Event.current.type == EventType.KeyDown)
            {
                InputsManager inputsManager = HQ.Settings.Get <ConsoleSettings>().inputsManager;

                if (inputsManager.Check("Navigation", ConsoleConstants.CloseLogCommand) == true)
                {
                    if (rowsDrawer.rowsData.ContainsKey(this) == true)
                    {
                        rowsDrawer.rowsData.Remove(this);
                        rowsDrawer.InvalidateViewHeight();
                        RowUtility.drawingWindow.Repaint();
                        RowUtility.ClearPreview();
                    }
                }
                else if (inputsManager.Check("Navigation", ConsoleConstants.OpenLogCommand) == true)
                {
                    if (rowsDrawer.rowsData.ContainsKey(this) == false)
                    {
                        rowsDrawer.rowsData.Add(this, true);
                        rowsDrawer.InvalidateViewHeight();
                        RowUtility.drawingWindow.Repaint();
                        RowUtility.ClearPreview();
                    }
                }
                else if (inputsManager.Check("Navigation", ConsoleConstants.GoToLineCommand) == true &&
                         rowsDrawer.currentVars.CountSelection == 1 &&
                         this.Frames.Length > 0)
                {
                    string fileName = this.Frames[0].fileName;
                    int    line     = this.Frames[0].line;
                    bool   focus    = (Event.current.modifiers & HQ.Settings.Get <LogSettings>().forceFocusOnModifier) != 0;

                    RowUtility.GoToFileLine(fileName, line, focus);
                    RowUtility.drawingWindow.Repaint();
                    Event.current.Use();
                }
            }

            return(null);
        }
示例#3
0
        private static void     DrawPreview(Rect bodyRect)
        {
            Rect r = RowUtility.previewRect;

            r.x += bodyRect.x;
            r.y += bodyRect.y;

            // Out of window.
            if (EditorWindow.mouseOverWindow != RowUtility.previewEditorWindow)
            {
                RowUtility.ClearPreview();
                return;
            }
            // Out of stacktrace.
            //else if (Event.current.type == EventType.MouseMove)
            if (Event.current.type == EventType.MouseMove && r.Contains(Event.current.mousePosition) == false)
            {
                RowUtility.ClearPreview();
                return;
            }

            if (RowUtility.previewFrame.line <= RowUtility.previewLines.Length)
            {
                StackTraceSettings stackTrace = HQ.Settings.Get <StackTraceSettings>();
                float maxWidth = float.MinValue;

                r.x      = Event.current.mousePosition.x + stackTrace.previewOffset.x;
                r.y      = Event.current.mousePosition.y + stackTrace.previewOffset.y;
                r.width  = RowUtility.previewRect.width;
                r.height = stackTrace.previewHeight;

                for (int i = RowUtility.previewFrame.line - stackTrace.previewLinesBeforeStackFrame - 1,
                     max = Mathf.Min(RowUtility.previewFrame.line + stackTrace.previewLinesAfterStackFrame, RowUtility.previewLines.Length);
                     i < max; i++)
                {
                    Utility.content.text = RowUtility.previewLines[i];
                    Vector2 size = stackTrace.PreviewSourceCodeStyle.CalcSize(Utility.content);
                    if (size.x > maxWidth)
                    {
                        maxWidth = size.x;
                    }
                }

                r.width = maxWidth;
                for (int i = RowUtility.previewFrame.line - stackTrace.previewLinesBeforeStackFrame - 1,
                     max = Mathf.Min(RowUtility.previewFrame.line + stackTrace.previewLinesAfterStackFrame, RowUtility.previewLines.Length);
                     i < max; i++)
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        if (i + 1 != RowUtility.previewFrame.line)
                        {
                            EditorGUI.DrawRect(r, stackTrace.previewSourceCodeBackgroundColor);
                        }
                        else
                        {
                            EditorGUI.DrawRect(r, stackTrace.previewSourceCodeMainLineBackgroundColor);
                        }
                    }

                    GUI.Label(r, RowUtility.previewLines[i], stackTrace.PreviewSourceCodeStyle);
                    r.y += r.height;
                }

                RowUtility.drawingWindow.Repaint();
            }
        }