llvm/lldb/source/Core/IOHandlerCursesGUI.cpp

//===-- IOHandlerCursesGUI.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "lldb/Core/IOHandlerCursesGUI.h"
#include "lldb/Host/Config.h"

#if LLDB_ENABLE_CURSES
#if CURSES_HAVE_NCURSES_CURSES_H
#include <ncurses/curses.h>
#include <ncurses/panel.h>
#else
#include <curses.h>
#include <panel.h>
#endif
#endif

#if defined(__APPLE__)
#include <deque>
#endif
#include <string>

#include "lldb/Core/Debugger.h"
#include "lldb/Core/ValueObjectUpdater.h"
#include "lldb/Host/File.h"
#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StringList.h"
#include "lldb/lldb-forward.h"

#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"

#if LLDB_ENABLE_CURSES
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/State.h"
#endif

#include "llvm/ADT/StringRef.h"

#ifdef _WIN32
#include "lldb/Host/windows/windows.h"
#endif

#include <memory>
#include <mutex>

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <functional>
#include <optional>
#include <type_traits>

usingnamespacelldb;
usingnamespacelldb_private;
StringRef;

// we may want curses to be disabled for some builds for instance, windows
#if LLDB_ENABLE_CURSES

#define KEY_CTRL_A
#define KEY_CTRL_E
#define KEY_CTRL_K
#define KEY_RETURN
#define KEY_ESCAPE
#define KEY_DELETE

#define KEY_SHIFT_TAB
#define KEY_ALT_ENTER

namespace curses {
class Menu;
class MenuDelegate;
class Window;
class WindowDelegate;
MenuSP;
MenuDelegateSP;
WindowSP;
WindowDelegateSP;
Menus;
Windows;
WindowDelegates;

#if 0
type summary add -s "x=${var.x}, y=${var.y}" curses::Point
type summary add -s "w=${var.width}, h=${var.height}" curses::Size
type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
#endif

struct Point {};

bool operator==(const Point &lhs, const Point &rhs) {}

bool operator!=(const Point &lhs, const Point &rhs) {}

struct Size {};

bool operator==(const Size &lhs, const Size &rhs) {}

bool operator!=(const Size &lhs, const Size &rhs) {}

struct Rect {};

bool operator==(const Rect &lhs, const Rect &rhs) {}

bool operator!=(const Rect &lhs, const Rect &rhs) {}

enum HandleCharResult {};

enum class MenuActionResult {};

struct KeyHelp {};

// COLOR_PAIR index names
enum {};

class WindowDelegate {};

class HelpDialogDelegate : public WindowDelegate {};

// A surface is an abstraction for something than can be drawn on. The surface
// have a width, a height, a cursor position, and a multitude of drawing
// operations. This type should be sub-classed to get an actually useful ncurses
// object, such as a Window or a Pad.
class Surface {};

class Pad : public Surface {};

class Window : public Surface {};

/////////
// Forms
/////////

// A scroll context defines a vertical region that needs to be visible in a
// scrolling area. The region is defined by the index of the start and end lines
// of the region. The start and end lines may be equal, in which case, the
// region is a single line.
struct ScrollContext {};

class FieldDelegate {};

FieldDelegateUP;

class TextFieldDelegate : public FieldDelegate {};

class IntegerFieldDelegate : public TextFieldDelegate {};

class FileFieldDelegate : public TextFieldDelegate {};

class DirectoryFieldDelegate : public TextFieldDelegate {};

class ArchFieldDelegate : public TextFieldDelegate {};

class BooleanFieldDelegate : public FieldDelegate {};

class ChoicesFieldDelegate : public FieldDelegate {};

class PlatformPluginFieldDelegate : public ChoicesFieldDelegate {};

class ProcessPluginFieldDelegate : public ChoicesFieldDelegate {};

class LazyBooleanFieldDelegate : public ChoicesFieldDelegate {};

template <class T> class ListFieldDelegate : public FieldDelegate {};

class ArgumentsFieldDelegate : public ListFieldDelegate<TextFieldDelegate> {};

template <class KeyFieldDelegateType, class ValueFieldDelegateType>
class MappingFieldDelegate : public FieldDelegate {};

class EnvironmentVariableNameFieldDelegate : public TextFieldDelegate {};

class EnvironmentVariableFieldDelegate
    : public MappingFieldDelegate<EnvironmentVariableNameFieldDelegate,
                                  TextFieldDelegate> {};

class EnvironmentVariableListFieldDelegate
    : public ListFieldDelegate<EnvironmentVariableFieldDelegate> {};

class FormAction {};

class FormDelegate {};

FormDelegateSP;

class FormWindowDelegate : public WindowDelegate {};

///////////////////////////
// Form Delegate Instances
///////////////////////////

class DetachOrKillProcessFormDelegate : public FormDelegate {};

class ProcessAttachFormDelegate : public FormDelegate {};

class TargetCreateFormDelegate : public FormDelegate {};

class ProcessLaunchFormDelegate : public FormDelegate {};

////////////
// Searchers
////////////

class SearcherDelegate {};

SearcherDelegateSP;

class SearcherWindowDelegate : public WindowDelegate {};

//////////////////////////////
// Searcher Delegate Instances
//////////////////////////////

// This is a searcher delegate wrapper around CommandCompletions common
// callbacks. The callbacks are only given the match string. The completion_mask
// can be a combination of lldb::CompletionType.
class CommonCompletionSearcherDelegate : public SearcherDelegate {};

////////
// Menus
////////

class MenuDelegate {};

class Menu : public WindowDelegate {};

// Menubar or separator constructor
Menu::Menu(Type type)
    :{}

// Menuitem constructor
Menu::Menu(const char *name, const char *key_name, int key_value,
           uint64_t identifier)
    :{}

void Menu::RecalculateNameLengths() {}

void Menu::AddSubmenu(const MenuSP &menu_sp) {}

void Menu::DrawMenuTitle(Window &window, bool highlight) {}

bool Menu::WindowDelegateDraw(Window &window, bool force) {}

HandleCharResult Menu::WindowDelegateHandleChar(Window &window, int key) {}

class Application {};

} // namespace curses

usingnamespacecurses;

struct Row {};

struct DisplayOptions {};

class TreeItem;

class TreeDelegate {};

TreeDelegateSP;

struct TreeItemData {};

class TreeItem : public TreeItemData {};

class TreeWindowDelegate : public WindowDelegate {};

// A tree delegate that just draws the text member of the tree item, it doesn't
// have any children or actions.
class TextTreeDelegate : public TreeDelegate {};

class FrameTreeDelegate : public TreeDelegate {};

class ThreadTreeDelegate : public TreeDelegate {};

class ThreadsTreeDelegate : public TreeDelegate {};

class BreakpointLocationTreeDelegate : public TreeDelegate {};

class BreakpointTreeDelegate : public TreeDelegate {};

class BreakpointsTreeDelegate : public TreeDelegate {};

class ValueObjectListDelegate : public WindowDelegate {};

class FrameVariablesWindowDelegate : public ValueObjectListDelegate {};

class RegistersWindowDelegate : public ValueObjectListDelegate {};

static const char *CursesKeyToCString(int ch) {}

HelpDialogDelegate::HelpDialogDelegate(const char *text,
                                       KeyHelp *key_help_array)
    :{}

HelpDialogDelegate::~HelpDialogDelegate() = default;

bool HelpDialogDelegate::WindowDelegateDraw(Window &window, bool force) {}

HandleCharResult HelpDialogDelegate::WindowDelegateHandleChar(Window &window,
                                                              int key) {}

class ApplicationDelegate : public WindowDelegate, public MenuDelegate {};

class StatusBarWindowDelegate : public WindowDelegate {};

class SourceFileWindowDelegate : public WindowDelegate {};

DisplayOptions ValueObjectListDelegate::g_options =;

IOHandlerCursesGUI::IOHandlerCursesGUI(Debugger &debugger)
    :{}

void IOHandlerCursesGUI::Activate() {}

void IOHandlerCursesGUI::Deactivate() {}

void IOHandlerCursesGUI::Run() {}

IOHandlerCursesGUI::~IOHandlerCursesGUI() = default;

void IOHandlerCursesGUI::Cancel() {}

bool IOHandlerCursesGUI::Interrupt() {}

void IOHandlerCursesGUI::GotEOF() {}

void IOHandlerCursesGUI::TerminalSizeChanged() {}

#endif // LLDB_ENABLE_CURSES