sources/interface.cpp

changeset 179
7fc34735178e
parent 156
ce66d7e374bf
child 181
e254398fcc7c
equal deleted inserted replaced
173:248fba6d1e76 179:7fc34735178e
88 m_inputCursor = 0; 88 m_inputCursor = 0;
89 return; 89 return;
90 } 90 }
91 91
92 int oldcursor = m_inputCursor; 92 int oldcursor = m_inputCursor;
93 m_inputCursor = clamp(m_inputCursor + delta, 0, m_inputHistory.size() - 1); 93 m_inputCursor = clamp(m_inputCursor + delta, 0, static_cast<int>(m_inputHistory.size() - 1));
94 94
95 if (m_inputCursor != oldcursor) 95 if (m_inputCursor != oldcursor)
96 { 96 {
97 m_cursorPosition = getCurrentInput().length(); 97 m_cursorPosition = getCurrentInput().length();
98 m_needInputRender = true; 98 m_needInputRender = true;
163 ::keypad(stdscr, true); 163 ::keypad(stdscr, true);
164 ::noecho(); 164 ::noecho();
165 ::refresh(); 165 ::refresh();
166 ::timeout(0); 166 ::timeout(0);
167 m_inputHistory.clear(); 167 m_inputHistory.clear();
168 m_inputHistory << ""; 168 m_inputHistory.push_back("");
169 m_outputLines.clear(); 169 m_outputLines.clear();
170 m_outputLines << ColoredLine(); 170 m_outputLines << ColoredLine();
171 m_session.setInterface(this); 171 m_session.setInterface(this);
172 resetTitle(); 172 resetTitle();
173 173
387 387
388 for (int i : range(height)) 388 for (int i : range(height))
389 { 389 {
390 mvhline(y, x, ' ', width); 390 mvhline(y, x, ' ', width);
391 391
392 if (i < m_playerNames.size()) 392 if (i < static_cast<signed>(m_playerNames.size()))
393 renderColorline(y, x, width, m_playerNames[i], false); 393 renderColorline(y, x, width, m_playerNames[i], false);
394 394
395 y++; 395 y++;
396 } 396 }
397 397
1020 for (const String& name : names) 1020 for (const String& name : names)
1021 { 1021 {
1022 ColoredLine coloredname; 1022 ColoredLine coloredname;
1023 coloredname.addString(name); 1023 coloredname.addString(name);
1024 coloredname.finalize(); 1024 coloredname.finalize();
1025 m_playerNames.append(coloredname); 1025 m_playerNames.push_back(coloredname);
1026 } 1026 }
1027 1027
1028 m_needNicklistRender = true; 1028 m_needNicklistRender = true;
1029 } 1029 }
1030 1030
1052 if (input[0] != '/') 1052 if (input[0] != '/')
1053 return; 1053 return;
1054 1054
1055 StringList args = input.right(input.length() - 1).split(" "); 1055 StringList args = input.right(input.length() - 1).split(" ");
1056 String command = args[0].toLowerCase(); 1056 String command = args[0].toLowerCase();
1057 args.remove_at(0); 1057 args.erase(args.begin());
1058 1058
1059 if (command == "connect") 1059 if (command == "connect")
1060 { 1060 {
1061 if (args.size() != 2) 1061 if (args.size() != 2)
1062 { 1062 {
1116 1116
1117 // ------------------------------------------------------------------------------------------------- 1117 // -------------------------------------------------------------------------------------------------
1118 // 1118 //
1119 void Interface::flushInput() 1119 void Interface::flushInput()
1120 { 1120 {
1121 m_inputHistory.insert(0, ""); 1121 m_inputHistory.insert(m_inputHistory.begin(), "");
1122 m_inputCursor = 0; 1122 m_inputCursor = 0;
1123 m_needInputRender = true; 1123 m_needInputRender = true;
1124 } 1124 }
1125 1125
1126 END_ZFC_NAMESPACE 1126 END_ZFC_NAMESPACE

mercurial