1 //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/lldb-python.h"
11 
12 #include "CommandObjectGUI.h"
13 
14 // C Includes
15 // C++ Includes
16 // Other libraries and framework includes
17 // Project includes
18 #include "lldb/lldb-private.h"
19 #include "lldb/Interpreter/CommandInterpreter.h"
20 #include "lldb/Interpreter/CommandReturnObject.h"
21 
22 using namespace lldb;
23 using namespace lldb_private;
24 
25 //-------------------------------------------------------------------------
26 // CommandObjectGUI
27 //-------------------------------------------------------------------------
28 
29 CommandObjectGUI::CommandObjectGUI (CommandInterpreter &interpreter) :
30     CommandObjectParsed (interpreter, "gui", "Switch into the curses based GUI mode.", "gui")
31 {
32 }
33 
34 CommandObjectGUI::~CommandObjectGUI ()
35 {
36 }
37 
38 bool
39 CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
40 {
41 #ifndef LLDB_DISABLE_CURSES
42     if (args.GetArgumentCount() == 0)
43     {
44         Debugger &debugger = m_interpreter.GetDebugger();
45 
46         lldb::StreamFileSP input_sp = debugger.GetInputFile();
47         if (input_sp &&
48             input_sp->GetFile().GetIsRealTerminal() &&
49             input_sp->GetFile().GetIsInteractive())
50         {
51             IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger));
52             if (io_handler_sp)
53                 debugger.PushIOHandler(io_handler_sp);
54             result.SetStatus (eReturnStatusSuccessFinishResult);
55         }
56         else
57         {
58             result.AppendError("the gui command requires an interactive terminal.");
59             result.SetStatus (eReturnStatusFailed);
60         }
61     }
62     else
63     {
64         result.AppendError("the gui command takes no arguments.");
65         result.SetStatus (eReturnStatusFailed);
66     }
67     return true;
68 #else
69     result.AppendError("lldb was not build with gui support");
70     return false;
71 #endif
72 }
73 
74