| 165 ::refresh(); |
165 ::refresh(); |
| 166 ::timeout(0); |
166 ::timeout(0); |
| 167 m_inputHistory.clear(); |
167 m_inputHistory.clear(); |
| 168 m_inputHistory.push_back(""); |
168 m_inputHistory.push_back(""); |
| 169 m_outputLines.clear(); |
169 m_outputLines.clear(); |
| 170 m_outputLines << ColoredLine(); |
170 m_outputLines.push_back(ColoredLine()); |
| 171 m_session.setInterface(this); |
171 m_session.setInterface(this); |
| 172 resetTitle(); |
172 resetTitle(); |
| 173 |
173 |
| 174 if (::has_colors()) |
174 if (::has_colors()) |
| 175 { |
175 { |
| 302 void Interface::renderOutput() |
302 void Interface::renderOutput() |
| 303 { |
303 { |
| 304 if (m_outputLines.size() == 1) |
304 if (m_outputLines.size() == 1) |
| 305 return; |
305 return; |
| 306 |
306 |
| 307 m_outputScroll = clamp(m_outputScroll, 0, m_outputLines.size() - 1); |
307 m_outputScroll = clamp(m_outputScroll, 0, static_cast<signed>(m_outputLines.size() - 1)); |
| 308 |
308 |
| 309 int height = LINES - 3; |
309 int height = LINES - 3; |
| 310 int width = COLS - nicklistWidth(); |
310 int width = COLS - nicklistWidth(); |
| 311 int printOffset = 0; |
311 int printOffset = 0; |
| 312 int end = m_outputLines.size() - 1 - m_outputScroll; |
312 int end = m_outputLines.size() - 1 - m_outputScroll; |
| 961 |
961 |
| 962 for (char ch : message) |
962 for (char ch : message) |
| 963 { |
963 { |
| 964 if (ch == '\n') |
964 if (ch == '\n') |
| 965 { |
965 { |
| 966 m_outputLines.last().finalize(); |
966 zfc::last(m_outputLines).finalize(); |
| 967 m_outputLines << ColoredLine(); |
967 m_outputLines.push_back({}); |
| 968 continue; |
968 continue; |
| 969 } |
969 } |
| 970 |
970 |
| 971 if (m_outputLines.last().length() == 0) |
971 if (zfc::last(m_outputLines).length() == 0) |
| 972 { |
972 { |
| 973 time_t now; |
973 time_t now; |
| 974 time(&now); |
974 time(&now); |
| 975 char timestamp[32]; |
975 char timestamp[32]; |
| 976 strftime(timestamp, sizeof timestamp, "[%H:%M:%S] ", localtime(&now)); |
976 strftime(timestamp, sizeof timestamp, "[%H:%M:%S] ", localtime(&now)); |
| 977 |
977 |
| 978 for (char ch : String(timestamp)) |
978 for (char ch : String(timestamp)) |
| 979 m_outputLines.last().addChar(ch); |
979 zfc::last(m_outputLines).addChar(ch); |
| 980 } |
980 } |
| 981 |
981 |
| 982 // Remove some lines if there's too many of them. 20,000 should be enough, I hope. |
982 // Remove some lines if there's too many of them. 20,000 should be enough, I hope. |
| 983 while (m_outputLines.size() > 20000) |
983 while (m_outputLines.size() > 20000) |
| 984 m_outputLines.remove_at(0); |
984 m_outputLines.erase(m_outputLines.begin()); |
| 985 |
985 |
| 986 m_outputLines.last().addChar(ch); |
986 zfc::last(m_outputLines).addChar(ch); |
| 987 } |
987 } |
| 988 |
988 |
| 989 m_needOutputRender = true; |
989 m_needOutputRender = true; |
| 990 } |
990 } |
| 991 |
991 |