sources/interface.h

branch
protocol5
changeset 195
be953e1621d9
parent 141
d9073c13dc98
parent 192
94c67ae846fc
equal deleted inserted replaced
176:060a13878ca0 195:be953e1621d9
1 /* 1 /*
2 Copyright 2014 - 2016 Teemu Piippo 2 Copyright 2014 - 2021 Teemu Piippo
3 All rights reserved. 3 All rights reserved.
4 4
5 Redistribution and use in source and binary forms, with or without 5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions 6 modification, are permitted provided that the following conditions
7 are met: 7 are met:
47 INPUTSTATE_PASSWORD, 47 INPUTSTATE_PASSWORD,
48 INPUTSTATE_CONFIRM_DISCONNECTION, 48 INPUTSTATE_CONFIRM_DISCONNECTION,
49 }; 49 };
50 50
51 Interface(); 51 Interface();
52 void connect(String address, String password); 52 virtual ~Interface();
53 void connect(std::string address, std::string password);
53 void disconnected(); 54 void disconnected();
54 RCONSession* getSession() { return &m_session; } 55 RCONSession* getSession() { return &m_session; }
55 void handleCommand(const String& input); 56 void handleCommand(const std::string& input, bool *shouldquit);
56 void handleInput(); 57 void handleInput(bool *shouldquit);
57 void needRefresh(); 58 void needRefresh();
58 void __cdecl print(const char* fmtstr, ...); 59 void __cdecl print(const char* fmtstr, ...) GNUATTRIBUTE((format(printf, 2, 3)));
59 void __cdecl printWarning(const char* fmtstr, ...); 60 void __cdecl printWarning(const char* fmtstr, ...) GNUATTRIBUTE((format(printf, 2, 3)));
60 void __cdecl printError(const char* fmtstr, ...); 61 void __cdecl printError(const char* fmtstr, ...) GNUATTRIBUTE((format(printf, 2, 3)));
61 void __cdecl printText(const char* fmtstr, ...); 62 void __cdecl printText(const char* fmtstr, ...) GNUATTRIBUTE((format(printf, 2, 3)));
62 void render(); 63 void render();
63 void renderFull(); 64 void renderFull();
64 void setPlayerNames(const StringList& names); 65 void setPlayerNames(const std::vector<std::string>& names);
65 void setTitle(const String& message); 66 void setTitle(const std::string& message);
66 void tabComplete(const String& part, String complete); 67 void tabComplete(const std::string& part, std::string complete);
67 void updateStatusBar(); 68 void updateStatusBar();
68 void vprint(const char* fmtstr, va_list args); 69 void vprint(const char* fmtstr, va_list args);
69 70
70 private: 71 private:
71 StringList m_inputHistory; 72 std::vector<std::string> m_inputHistory;
72 int m_inputCursor; 73 int m_inputCursor;
73 int m_cursorPosition; 74 int m_cursorPosition;
74 int m_inputPanning; 75 int m_inputPanning;
75 bool m_needRefresh; 76 bool m_needRefresh;
76 bool m_needStatusBarRender; 77 bool m_needStatusBarRender;
77 bool m_needInputRender; 78 bool m_needInputRender;
78 bool m_needOutputRender; 79 bool m_needOutputRender;
79 bool m_needNicklistRender; 80 bool m_needNicklistRender;
80 struct { char ch; int x; } m_cursorCharacter; 81 struct { char ch; int x; } m_cursorCharacter;
81 Vector<ColoredLine> m_outputLines; 82 std::vector<ColoredLine> m_outputLines;
82 int m_outputScroll; 83 int m_outputScroll;
83 String m_title; 84 std::string m_title;
84 InputState m_inputState; 85 InputState m_inputState;
85 std::function<void(bool)> m_disconnectCallback; 86 std::function<void(bool)> m_disconnectCallback;
86 IPAddress m_remoteAddress; 87 net::ip_address m_remoteAddress;
87 String m_statusBarText; 88 std::string m_statusBarText;
88 List<ColoredLine> m_playerNames; 89 std::vector<ColoredLine> m_playerNames;
89 String m_pasteBuffer; 90 std::string m_pasteBuffer;
90 RCONSession m_session; 91 RCONSession m_session;
91 92
92 void detachInput(); 93 void detachInput();
93 int findNextWord(); 94 int findNextWord();
94 int findPreviousWord(); 95 int findPreviousWord();
95 void flushInput(); 96 void flushInput();
96 chtype getColorPair(Color fg, Color bg); 97 chtype getColorPair(Color fg, Color bg);
97 const String& getCurrentInput(); 98 const std::string& getCurrentInput();
98 String& getEditableInput(); 99 std::string& getEditableInput();
99 String getPromptString(); 100 std::string getPromptString();
100 void moveInputCursor(int delta); 101 void moveInputCursor(int delta);
101 int nicklistWidth(); 102 int nicklistWidth();
102 void positionCursor(); 103 void positionCursor();
103 void printToConsole(String message); 104 void printToConsole(std::string message);
104 int renderColorline(int y, int x0, int width, const ColoredLine& line, bool allowWrap); 105 int renderColorline(int y, int x0, int width, const ColoredLine& line, bool allowWrap);
105 void renderInput(); 106 void renderInput();
106 void renderNicklist(); 107 void renderNicklist();
107 void renderOutput(); 108 void renderOutput();
108 void renderStatusBar(); 109 void renderStatusBar();
109 void renderTitlebar(); 110 void renderTitlebar();
110 void resetTitle(); 111 void resetTitle();
111 void safeDisconnect(std::function<void(bool)> afterwards); 112 void safeDisconnect(std::function<void(bool)> afterwards);
112 void setInputState(InputState newstate); 113 void setInputState(InputState newstate);
113 void yank(int a, int b); 114 void yank(int a, int b);
115 bool tryResolveAddress(const std::string& address_string, net::ip_address *target);
114 }; 116 };
115 117
116 END_ZFC_NAMESPACE 118 END_ZFC_NAMESPACE

mercurial