144d93782SGreg Clayton //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
244d93782SGreg Clayton //
344d93782SGreg Clayton //                     The LLVM Compiler Infrastructure
444d93782SGreg Clayton //
544d93782SGreg Clayton // This file is distributed under the University of Illinois Open Source
644d93782SGreg Clayton // License. See LICENSE.TXT for details.
744d93782SGreg Clayton //
844d93782SGreg Clayton //===----------------------------------------------------------------------===//
944d93782SGreg Clayton 
1044d93782SGreg Clayton #include "lldb/lldb-python.h"
1144d93782SGreg Clayton 
1244d93782SGreg Clayton #include "CommandObjectGUI.h"
1344d93782SGreg Clayton 
1444d93782SGreg Clayton // C Includes
1544d93782SGreg Clayton // C++ Includes
1644d93782SGreg Clayton // Other libraries and framework includes
1744d93782SGreg Clayton // Project includes
1844d93782SGreg Clayton #include "lldb/lldb-private.h"
1944d93782SGreg Clayton #include "lldb/Interpreter/CommandInterpreter.h"
2044d93782SGreg Clayton #include "lldb/Interpreter/CommandReturnObject.h"
2144d93782SGreg Clayton 
2244d93782SGreg Clayton using namespace lldb;
2344d93782SGreg Clayton using namespace lldb_private;
2444d93782SGreg Clayton 
2544d93782SGreg Clayton //-------------------------------------------------------------------------
2644d93782SGreg Clayton // CommandObjectGUI
2744d93782SGreg Clayton //-------------------------------------------------------------------------
2844d93782SGreg Clayton 
2944d93782SGreg Clayton CommandObjectGUI::CommandObjectGUI (CommandInterpreter &interpreter) :
3044d93782SGreg Clayton     CommandObjectParsed (interpreter, "gui", "Switch into the curses based GUI mode.", "gui")
3144d93782SGreg Clayton {
3244d93782SGreg Clayton }
3344d93782SGreg Clayton 
3444d93782SGreg Clayton CommandObjectGUI::~CommandObjectGUI ()
3544d93782SGreg Clayton {
3644d93782SGreg Clayton }
3744d93782SGreg Clayton 
3844d93782SGreg Clayton bool
3944d93782SGreg Clayton CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
4044d93782SGreg Clayton {
41914b8d98SDeepak Panickal #ifndef LLDB_DISABLE_CURSES
4244d93782SGreg Clayton     if (args.GetArgumentCount() == 0)
4344d93782SGreg Clayton     {
4444d93782SGreg Clayton         Debugger &debugger = m_interpreter.GetDebugger();
45*456f2712SGreg Clayton 
46*456f2712SGreg Clayton         lldb::StreamFileSP input_sp = debugger.GetInputFile();
47*456f2712SGreg Clayton         if (input_sp &&
48*456f2712SGreg Clayton             input_sp->GetFile().GetIsRealTerminal() &&
49*456f2712SGreg Clayton             input_sp->GetFile().GetIsInteractive())
50*456f2712SGreg Clayton         {
5144d93782SGreg Clayton             IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger));
5244d93782SGreg Clayton             if (io_handler_sp)
5344d93782SGreg Clayton                 debugger.PushIOHandler(io_handler_sp);
5444d93782SGreg Clayton             result.SetStatus (eReturnStatusSuccessFinishResult);
5544d93782SGreg Clayton         }
5644d93782SGreg Clayton         else
5744d93782SGreg Clayton         {
58*456f2712SGreg Clayton             result.AppendError("the gui command requires an interactive terminal.");
59*456f2712SGreg Clayton             result.SetStatus (eReturnStatusFailed);
60*456f2712SGreg Clayton         }
61*456f2712SGreg Clayton     }
62*456f2712SGreg Clayton     else
63*456f2712SGreg Clayton     {
6444d93782SGreg Clayton         result.AppendError("the gui command takes no arguments.");
6544d93782SGreg Clayton         result.SetStatus (eReturnStatusFailed);
6644d93782SGreg Clayton     }
6744d93782SGreg Clayton     return true;
68914b8d98SDeepak Panickal #else
69914b8d98SDeepak Panickal     result.AppendError("lldb was not build with gui support");
70914b8d98SDeepak Panickal     return false;
71914b8d98SDeepak Panickal #endif
7244d93782SGreg Clayton }
7344d93782SGreg Clayton 
74