88#include " Common/StringUtils.h"
99
1010ImConsole::ImConsole () {
11- memset (InputBuf , 0 , sizeof (InputBuf ));
11+ memset (inputBuf_ , 0 , sizeof (inputBuf_ ));
1212
13- HistoryPos = -1 ;
13+ historyPos_ = -1 ;
1414
1515 // "CLASSIFY" is here to provide the test case where "C"+[tab] completes to "CL" and display multiple matches.
16- AutoScroll = true ;
17- ScrollToBottom = false ;
16+ autoScroll_ = true ;
17+ scrollToBottom_ = false ;
1818}
1919
2020ImConsole::~ImConsole () {
21- for (int i = 0 ; i < History .Size ; i++)
22- ImGui::MemFree (History [i]);
21+ for (int i = 0 ; i < history_ .Size ; i++)
22+ ImGui::MemFree (history_ [i]);
2323}
2424
2525// Portable helpers
@@ -52,7 +52,7 @@ void ImConsole::Draw(ImConfig &cfg) {
5252
5353 // Options menu
5454 if (ImGui::BeginPopup (" Options" )) {
55- ImGui::Checkbox (" Auto-scroll" , &AutoScroll );
55+ ImGui::Checkbox (" Auto-scroll" , &autoScroll_ );
5656 ImGui::EndPopup ();
5757 }
5858
@@ -61,7 +61,7 @@ void ImConsole::Draw(ImConfig &cfg) {
6161 if (ImGui::Button (" Options" ))
6262 ImGui::OpenPopup (" Options" );
6363 ImGui::SameLine ();
64- Filter .Draw (" Filter (\" incl,-excl\" ) (\" error\" )" , 180 );
64+ filter_ .Draw (" Filter (\" incl,-excl\" ) (\" error\" )" , 180 );
6565 ImGui::Separator ();
6666
6767 // Reserve enough left-over height for 1 separator + 1 input text
@@ -101,7 +101,7 @@ void ImConsole::Draw(ImConfig &cfg) {
101101 if (copy_to_clipboard)
102102 ImGui::LogToClipboard ();
103103 for (const auto &item : g_lua.GetLines ()) {
104- if (!Filter .PassFilter (item.line .c_str ()))
104+ if (!filter_ .PassFilter (item.line .c_str ()))
105105 continue ;
106106 ImVec4 color;
107107 bool has_color = true ;
@@ -138,9 +138,9 @@ void ImConsole::Draw(ImConfig &cfg) {
138138
139139 // Keep up at the bottom of the scroll region if we were already at the bottom at the beginning of the frame.
140140 // Using a scrollbar or mouse-wheel will take away from the bottom edge.
141- if (ScrollToBottom || (AutoScroll && ImGui::GetScrollY () >= ImGui::GetScrollMaxY ()))
141+ if (scrollToBottom_ || (autoScroll_ && ImGui::GetScrollY () >= ImGui::GetScrollMaxY ()))
142142 ImGui::SetScrollHereY (1 .0f );
143- ScrollToBottom = false ;
143+ scrollToBottom_ = false ;
144144
145145 ImGui::PopStyleVar ();
146146 }
@@ -156,8 +156,8 @@ void ImConsole::Draw(ImConfig &cfg) {
156156 // Command-line
157157 bool reclaim_focus = false ;
158158 ImGuiInputTextFlags input_text_flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_EscapeClearsAll | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory;
159- if (ImGui::InputText (" Input" , InputBuf , IM_ARRAYSIZE (InputBuf ), input_text_flags, &TextEditCallbackStub, (void *)this )) {
160- char * s = InputBuf ;
159+ if (ImGui::InputText (" Input" , inputBuf_ , IM_ARRAYSIZE (inputBuf_ ), input_text_flags, &TextEditCallbackStub, (void *)this )) {
160+ char * s = inputBuf_ ;
161161 Strtrim (s);
162162 if (s[0 ])
163163 ExecCommand (s);
@@ -176,15 +176,15 @@ void ImConsole::Draw(ImConfig &cfg) {
176176void ImConsole::ExecCommand (const char * command_line) {
177177 // Insert into history. First find match and delete it so it can be pushed to the back.
178178 // This isn't trying to be smart or optimal.
179- HistoryPos = -1 ;
180- for (int i = History .Size - 1 ; i >= 0 ; i--) {
181- if (Stricmp (History [i], command_line) == 0 ) {
182- ImGui::MemFree (History [i]);
183- History .erase (History .begin () + i);
179+ historyPos_ = -1 ;
180+ for (int i = history_ .Size - 1 ; i >= 0 ; i--) {
181+ if (Stricmp (history_ [i], command_line) == 0 ) {
182+ ImGui::MemFree (history_ [i]);
183+ history_ .erase (history_ .begin () + i);
184184 break ;
185185 }
186186 }
187- History .push_back (Strdup (command_line));
187+ history_ .push_back (Strdup (command_line));
188188
189189 g_lua.Print (LogLineType::Cmd, std::string (command_line));
190190
@@ -196,15 +196,15 @@ void ImConsole::ExecCommand(const char* command_line) {
196196 g_lua.Print (LogLineType::Url, " https://www.lua.org/manual/5.3/" );
197197 // TODO: Also print available Lua commands.
198198 } else if (Stricmp (command_line, " history" ) == 0 ) {
199- int first = History .Size - 10 ;
200- for (int i = first > 0 ? first : 0 ; i < History .Size ; i++)
201- g_lua.Print (StringFromFormat (" %3d: %s" , i, History [i]));
199+ int first = history_ .Size - 10 ;
200+ for (int i = first > 0 ? first : 0 ; i < history_ .Size ; i++)
201+ g_lua.Print (StringFromFormat (" %3d: %s" , i, history_ [i]));
202202 } else {
203203 g_lua.ExecuteConsoleCommand (command_line);
204204 }
205205
206206 // On command input, we scroll to bottom even if AutoScroll==false
207- ScrollToBottom = true ;
207+ scrollToBottom_ = true ;
208208}
209209
210210int ImConsole::TextEditCallback (ImGuiInputTextCallbackData* data) {
@@ -279,21 +279,21 @@ int ImConsole::TextEditCallback(ImGuiInputTextCallbackData* data) {
279279 case ImGuiInputTextFlags_CallbackHistory:
280280 {
281281 // Example of HISTORY
282- const int prev_history_pos = HistoryPos ;
282+ const int prev_history_pos = historyPos_ ;
283283 if (data->EventKey == ImGuiKey_UpArrow) {
284- if (HistoryPos == -1 )
285- HistoryPos = History .Size - 1 ;
286- else if (HistoryPos > 0 )
287- HistoryPos --;
284+ if (historyPos_ == -1 )
285+ historyPos_ = history_ .Size - 1 ;
286+ else if (historyPos_ > 0 )
287+ historyPos_ --;
288288 } else if (data->EventKey == ImGuiKey_DownArrow) {
289- if (HistoryPos != -1 )
290- if (++HistoryPos >= History .Size )
291- HistoryPos = -1 ;
289+ if (historyPos_ != -1 )
290+ if (++historyPos_ >= history_ .Size )
291+ historyPos_ = -1 ;
292292 }
293293
294294 // A better implementation would preserve the data on the current input line along with cursor position.
295- if (prev_history_pos != HistoryPos ) {
296- const char * history_str = (HistoryPos >= 0 ) ? History[HistoryPos ] : " " ;
295+ if (prev_history_pos != historyPos_ ) {
296+ const char * history_str = (historyPos_ >= 0 ) ? history_[historyPos_ ] : " " ;
297297 data->DeleteChars (0 , data->BufTextLen );
298298 data->InsertChars (0 , history_str);
299299 }
0 commit comments