예제 #1
0
파일: Screen.cs 프로젝트: cobergmd/cdbg
        public void DisplayFile(string path, int highlight)
        {
            bool exists = false;

            for (int i = 0; i < _Buffers.Count; i++)
            {
                OutputBuffer buffer = _Buffers[i];
                if (buffer.Name.Equals(path))
                {
                    exists            = true;
                    _CurrentBufferIdx = i;
                    _CurrentView      = buffer;
                    break;
                }
            }

            if (!exists)
            {
                _CurrentView = new SourceViewer(path);
                string line;
                using (var reader = File.OpenText(path))
                {
                    while ((line = reader.ReadLine()) != null)
                    {
                        _CurrentView.Append(line);
                    }
                }

                _Buffers.Add(_CurrentView);
                _CurrentBufferIdx = _Buffers.Count - 1;
            }
            if (_CurrentView != null)
            {
                if (_CurrentView is SourceViewer)
                {
                    SourceViewer sviewer = _CurrentView as SourceViewer;
                    sviewer.HighLight = highlight;

                    MDbgBreakpointCollection breakpoints = _Shell.Debugger.Processes.Active.Breakpoints;
                    foreach (MDbgBreakpoint b in breakpoints)
                    {
                        if (b.Location is IBreakpointBySourceLine)
                        {
                            IBreakpointBySourceLine bp = b.Location as IBreakpointBySourceLine;
                            if (path.Equals(bp.FileName))
                            {
                                sviewer.AddBreakpoint(bp.LineNumber);
                            }
                        }
                    }
                }

                _CurrentView.Draw(0, Console.WindowHeight - 3);
            }
        }
예제 #2
0
파일: Screen.cs 프로젝트: cobergmd/cdbg
 public void WriteOutput(string outputType, string message, int highlightStart, int highlightLen)
 {
     _CommandView.Append(message);
     _CurrentView = _CommandView;
     _CurrentView.Draw(0, Console.WindowHeight - 3);
 }
예제 #3
0
파일: Screen.cs 프로젝트: cobergmd/cdbg
 public void WriteOutput(string outputType, string output)
 {
     _CommandView.Append(output);
     _CurrentView = _CommandView;
     _CurrentView.Draw(0, Console.WindowHeight - 3);
 }
예제 #4
0
파일: Screen.cs 프로젝트: cobergmd/cdbg
        public void Draw()
        {
            int winHeight = Console.WindowHeight;

            DrawMenu(winHeight - 1);
            _Prompt.Draw(winHeight - 2);

            bool           refreshViewer = false;
            bool           refreshList   = false;
            ConsoleKeyInfo cki           = Console.ReadKey(true);

            if (cki != null)
            {
                if (cki.Key == ConsoleKey.Enter) // evaluate
                {
                    if (_FileList.IsVisible)
                    {
                        if (_SelectedCmd != null)
                        {
                            _Prompt.Load(_SelectedCmd);
                            _SelectedCmd = null;
                        }
                        _FileList.Close();
                    }
                    ProcessCommandLine();
                }
                else if (cki.Key == ConsoleKey.Tab && (cki.Modifiers & ConsoleModifiers.Control) != 0)
                {
                    if (_CurrentBufferIdx == _Buffers.Count - 1)
                    {
                        _CurrentBufferIdx = 0;
                    }
                    else
                    {
                        _CurrentBufferIdx += 1;
                    }

                    _CurrentView  = _Buffers[_CurrentBufferIdx];
                    refreshViewer = true;
                }
                else if (cki.Key == ConsoleKey.Tab)
                {
                    if (_FileList.IsVisible && _SelectedCmd != null)
                    {
                        _Prompt.Load(_SelectedCmd);
                        _FileList.Close();
                        _SelectedCmd  = null;
                        refreshViewer = true;
                    }
                }
                else if (cki.Key == ConsoleKey.F2)
                {
                    DrawVariableViewer();
                }
                else if (cki.Key == ConsoleKey.F4)
                {
                    Stop();
                }
                else if (cki.Key == ConsoleKey.F10)
                {
                    string       cmdArgs = null;
                    IMDbgCommand dbgcmd  = null;
                    _Shell.Commands.ParseCommand("n", out dbgcmd, out cmdArgs);
                    dbgcmd.Execute(cmdArgs);
                }
                else if (cki.Key == ConsoleKey.F12)
                {
                    if (_CurrentMenu == _AltMenu)
                    {
                        _CurrentMenu = _MainMenu;
                    }
                    else
                    {
                        _CurrentMenu = _AltMenu;
                    }
                }
                else if (cki.Key == ConsoleKey.Home)
                {
                    _Prompt.MoveToHome();
                }
                else if (cki.Key == ConsoleKey.End)
                {
                    _Prompt.MoveToEnd();
                }
                else if (cki.Key == ConsoleKey.Backspace)
                {
                    _Prompt.Backspace();
                    refreshList = true;
                }
                else if (cki.Key == ConsoleKey.Delete)
                {
                    _Prompt.Delete();
                    refreshList = true;
                }
                else if (cki.Key == ConsoleKey.RightArrow)
                {
                    _Prompt.MoveRight();
                }
                else if (cki.Key == ConsoleKey.LeftArrow)
                {
                    _Prompt.MoveLeft();
                }
                else if (cki.Key == ConsoleKey.Escape)
                {
                    _FileList.Close();
                    refreshViewer = true;
                }
                else if (cki.Key == ConsoleKey.UpArrow)
                {
                    if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
                    {
                        if (_CurrentView != null)
                        {
                            _CurrentView.DecreaseLine(1);
                            refreshViewer = true;
                        }
                    }
                    else
                    {
                        if (_FileList.IsVisible)
                        {
                            _SelectedCmd = _FileList.MoveSelection(FileList.ArrowMovement.Up);
                            refreshList  = true;
                        }
                        else
                        {
                            // update prompt with command history
                            _Prompt.Load(GetNextCommand());
                        }
                    }
                }
                else if (cki.Key == ConsoleKey.DownArrow)
                {
                    if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
                    {
                        if (_CurrentView != null)
                        {
                            _CurrentView.IncreaseLine(1);
                            refreshViewer = true;
                        }
                    }
                    else
                    {
                        if (_FileList.IsVisible)
                        {
                            _SelectedCmd = _FileList.MoveSelection(FileList.ArrowMovement.Down);
                            refreshList  = true;
                        }
                        else
                        {
                            // update prompt with command history
                            _Prompt.Load(GetPreviousCommand());
                        }
                    }
                }
                else if (cki.Key == ConsoleKey.PageDown)
                {
                    if (_CurrentView != null)
                    {
                        _CurrentView.IncreasePage();
                        refreshViewer = true;
                    }
                }
                else if (cki.Key == ConsoleKey.PageUp)
                {
                    if (_CurrentView != null)
                    {
                        _CurrentView.DecreasePage();
                        refreshViewer = true;
                    }
                }
                else // add to buffer
                {
                    _Prompt.AddCharacter(cki.KeyChar);
                    refreshList = true;
                }
            }
            if (refreshList)
            {
                _FileList.Draw(_Prompt.ToString());
            }
            if (_CurrentView != null && refreshViewer)
            {
                _CurrentView.Draw(0, Console.WindowHeight - 3);
            }
        }
예제 #5
0
파일: Screen.cs 프로젝트: cobergmd/cdbg
        public void DisplayFile(string path, int highlight)
        {
            bool exists = false;
            for (int i = 0; i < _Buffers.Count; i++)
            {
                OutputBuffer buffer = _Buffers[i];
                if (buffer.Name.Equals(path))
                {
                    exists = true;
                    _CurrentBufferIdx = i;
                    _CurrentView = buffer;
                    break;
                }
            }

            if (!exists)
            {
                _CurrentView = new SourceViewer(path);
                string line;
                using (var reader = File.OpenText(path))
                {
                    while ((line = reader.ReadLine()) != null)
                    {
                        _CurrentView.Append(line);
                    }
                }

                _Buffers.Add(_CurrentView);
                _CurrentBufferIdx = _Buffers.Count - 1;
            }
            if (_CurrentView != null)
            {
                if (_CurrentView is SourceViewer)
                {
                    SourceViewer sviewer = _CurrentView as SourceViewer;
                    sviewer.HighLight = highlight;

                    MDbgBreakpointCollection breakpoints = _Shell.Debugger.Processes.Active.Breakpoints;
                    foreach (MDbgBreakpoint b in breakpoints)
                    {
                        if (b.Location is IBreakpointBySourceLine)
                        {
                            IBreakpointBySourceLine bp = b.Location as IBreakpointBySourceLine;
                            if (path.Equals(bp.FileName))
                            {
                                sviewer.AddBreakpoint(bp.LineNumber);
                            }
                        }
                    }
                }

                _CurrentView.Draw(0, Console.WindowHeight - 3);
            }
        }
예제 #6
0
파일: Screen.cs 프로젝트: cobergmd/cdbg
 public void WriteOutput(string outputType, string message, int highlightStart, int highlightLen)
 {
     _CommandView.Append(message);
     _CurrentView = _CommandView;
     _CurrentView.Draw(0, Console.WindowHeight - 3);
 }
예제 #7
0
파일: Screen.cs 프로젝트: cobergmd/cdbg
 public void WriteOutput(string outputType, string output)
 {
     _CommandView.Append(output);
     _CurrentView = _CommandView;
     _CurrentView.Draw(0, Console.WindowHeight - 3);
 }
예제 #8
0
파일: Screen.cs 프로젝트: cobergmd/cdbg
        public void Draw()
        {
            int winHeight = Console.WindowHeight;
            DrawMenu(winHeight - 1);
            _Prompt.Draw(winHeight - 2);

            bool refreshViewer = false;
            bool refreshList = false;
            ConsoleKeyInfo cki = Console.ReadKey(true);
            if (cki != null)
            {
                if (cki.Key == ConsoleKey.Enter) // evaluate
                {
                    if (_FileList.IsVisible)
                    {
                        if (_SelectedCmd != null)
                        {
                            _Prompt.Load(_SelectedCmd);
                            _SelectedCmd = null;
                        }
                        _FileList.Close();
                    }
                    ProcessCommandLine();
                }
                else if (cki.Key == ConsoleKey.Tab && (cki.Modifiers & ConsoleModifiers.Control) != 0)
                {
                    if (_CurrentBufferIdx == _Buffers.Count-1)
                        _CurrentBufferIdx = 0;
                    else
                        _CurrentBufferIdx += 1;

                    _CurrentView = _Buffers[_CurrentBufferIdx];
                    refreshViewer = true;
                }
                else if (cki.Key == ConsoleKey.Tab)
                {
                    if (_FileList.IsVisible && _SelectedCmd != null)
                    {
                        _Prompt.Load(_SelectedCmd);
                        _FileList.Close();
                        _SelectedCmd = null;
                        refreshViewer = true;
                    }
                }
                else if (cki.Key == ConsoleKey.F2)
                {
                    DrawVariableViewer();
                }
                else if (cki.Key == ConsoleKey.F4)
                {
                    Stop();
                }
                else if (cki.Key == ConsoleKey.F10)
                {
                    string cmdArgs = null;
                    IMDbgCommand dbgcmd = null;
                    _Shell.Commands.ParseCommand("n", out dbgcmd, out cmdArgs);
                    dbgcmd.Execute(cmdArgs);
                }
                else if (cki.Key == ConsoleKey.F12)
                {
                    if (_CurrentMenu == _AltMenu)
                        _CurrentMenu = _MainMenu;
                    else
                        _CurrentMenu = _AltMenu;
                }
                else if (cki.Key == ConsoleKey.Home)
                {
                    _Prompt.MoveToHome();
                }
                else if (cki.Key == ConsoleKey.End)
                {
                    _Prompt.MoveToEnd();
                }
                else if (cki.Key == ConsoleKey.Backspace)
                {
                    _Prompt.Backspace();
                    refreshList = true;
                }
                else if (cki.Key == ConsoleKey.Delete)
                {
                    _Prompt.Delete();
                    refreshList = true;
                }
                else if (cki.Key == ConsoleKey.RightArrow)
                {
                    _Prompt.MoveRight();
                }
                else if (cki.Key == ConsoleKey.LeftArrow)
                {
                    _Prompt.MoveLeft();
                }
                else if (cki.Key == ConsoleKey.Escape)
                {
                    _FileList.Close();
                    refreshViewer = true;
                }
                else if (cki.Key == ConsoleKey.UpArrow)
                {
                    if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
                    {
                        if (_CurrentView != null)
                        {
                            _CurrentView.DecreaseLine(1);
                            refreshViewer = true;
                        }
                    }
                    else
                    {
                        if (_FileList.IsVisible)
                        {
                            _SelectedCmd = _FileList.MoveSelection(FileList.ArrowMovement.Up);
                            refreshList = true;
                        }
                        else
                        {
                            // update prompt with command history
                            _Prompt.Load(GetNextCommand());
                        }
                    }
                }
                else if (cki.Key == ConsoleKey.DownArrow)
                {
                    if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
                    {
                        if (_CurrentView != null)
                        {
                            _CurrentView.IncreaseLine(1);
                            refreshViewer = true;
                        }
                    }
                    else
                    {
                        if (_FileList.IsVisible)
                        {
                            _SelectedCmd = _FileList.MoveSelection(FileList.ArrowMovement.Down);
                            refreshList = true;
                        }
                        else
                        {
                            // update prompt with command history
                            _Prompt.Load(GetPreviousCommand());
                        }
                    }
                }
                else if (cki.Key == ConsoleKey.PageDown)
                {
                    if (_CurrentView != null)
                    {
                        _CurrentView.IncreasePage();
                        refreshViewer = true;
                    }
                }
                else if (cki.Key == ConsoleKey.PageUp)
                {
                    if (_CurrentView != null)
                    {
                        _CurrentView.DecreasePage();
                        refreshViewer = true;
                    }
                }
                else // add to buffer
                {
                    _Prompt.AddCharacter(cki.KeyChar);
                    refreshList = true;
                }
            }
            if (refreshList)
            {
                _FileList.Draw(_Prompt.ToString());
            }
            if (_CurrentView != null && refreshViewer)
            {
                _CurrentView.Draw(0, Console.WindowHeight - 3);
            }
        }