diff -r da7d5a8e608f -r e49aa4aa98c0 sources/interface.cpp --- a/sources/interface.cpp Wed Jul 20 14:59:20 2016 +0300 +++ b/sources/interface.cpp Wed Jul 20 15:01:26 2016 +0300 @@ -41,12 +41,12 @@ // ------------------------------------------------------------------------------------------------- // -chtype Interface::getColorPair (Color fg, Color bg) +chtype Interface::getColorPair(Color fg, Color bg) { if (fg == DEFAULT && bg == DEFAULT) return 0; else - return COLOR_PAIR (1 + (int (fg) * NUM_COLORS) + int (bg)); + return COLOR_PAIR(1 + (int(fg) * NUM_COLORS) + int(bg)); } // ------------------------------------------------------------------------------------------------- @@ -58,7 +58,7 @@ // ------------------------------------------------------------------------------------------------- // -// Makes current_input() the lastmost input (so that we won't modify history) +// Makes current_input() the lastmost input(so that we won't modify history) // void Interface::detachInput() { @@ -80,7 +80,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::moveInputCursor (int delta) +void Interface::moveInputCursor(int delta) { // No input history when inputting addresses or passwords if (m_inputState != INPUTSTATE_NORMAL) @@ -90,7 +90,7 @@ } int oldcursor = m_inputCursor; - m_inputCursor = clamp (m_inputCursor + delta, 0, m_inputHistory.size() - 1); + m_inputCursor = clamp(m_inputCursor + delta, 0, m_inputHistory.size() - 1); if (m_inputCursor != oldcursor) { @@ -118,9 +118,9 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::setInputState (InputState newstate) +void Interface::setInputState(InputState newstate) { - // Clear the input row (unless going to or from confirm state) + // Clear the input row(unless going to or from confirm state) if (newstate != INPUTSTATE_CONFIRM_DISCONNECTION and m_inputState != INPUTSTATE_CONFIRM_DISCONNECTION) { @@ -132,7 +132,7 @@ { case INPUTSTATE_ADDRESS: if (m_remoteAddress.host != 0) - getEditableInput() = m_remoteAddress.to_string (IPAddress::WITH_PORT); + getEditableInput() = m_remoteAddress.to_string(IPAddress::WITH_PORT); break; default: @@ -146,35 +146,35 @@ // ------------------------------------------------------------------------------------------------- // Interface::Interface() : - m_inputCursor (0), - m_cursorPosition (0), - m_inputPanning (0), - m_needRefresh (false), - m_needStatusBarRender (false), - m_needInputRender (false), - m_needOutputRender (false), - m_needNicklistRender (false), - m_outputScroll (0), - m_inputState (INPUTSTATE_NORMAL), - m_disconnectCallback (nullptr) + m_inputCursor(0), + m_cursorPosition(0), + m_inputPanning(0), + m_needRefresh(false), + m_needStatusBarRender(false), + m_needInputRender(false), + m_needOutputRender(false), + m_needNicklistRender(false), + m_outputScroll(0), + m_inputState(INPUTSTATE_NORMAL), + m_disconnectCallback(nullptr) { ::initscr(); ::raw(); - ::keypad (stdscr, true); + ::keypad(stdscr, true); ::noecho(); ::refresh(); - ::timeout (0); + ::timeout(0); m_inputHistory.clear(); m_inputHistory << ""; m_outputLines.clear(); m_outputLines << ColoredLine(); - m_session.set_interface (this); + m_session.set_interface(this); resetTitle(); if (::has_colors()) { ::start_color(); - bool hasDefaultColors = (::use_default_colors() == OK); + bool hasDefaultColors =(::use_default_colors() == OK); int defaultFg = hasDefaultColors ? -1 : COLOR_WHITE; int defaultBg = hasDefaultColors ? -1 : COLOR_BLACK; @@ -183,13 +183,13 @@ for (int j : range(NUM_COLORS)) { int pairnum = 1 + (i * NUM_COLORS + j); - int fg = (i == DEFAULT) ? defaultFg : i; - int bg = (j == DEFAULT) ? defaultBg : j; + int fg =(i == DEFAULT) ? defaultFg : i; + int bg =(j == DEFAULT) ? defaultBg : j; if (fg != -1 || bg != -1) { - if (::init_pair (pairnum, fg, bg) == ERR) - printWarning ("Unable to initialize color pair %d (%d, %d)\n", pairnum, fg, bg); + if (::init_pair(pairnum, fg, bg) == ERR) + printWarning("Unable to initialize color pair %d(%d, %d)\n", pairnum, fg, bg); } } } @@ -205,14 +205,14 @@ { if (m_title.length() <= COLS) { - chtype pair = getColorPair (WHITE, BLUE); - int startx = (COLS - m_title.length()) / 2; + chtype pair = getColorPair(WHITE, BLUE); + int startx =(COLS - m_title.length()) / 2; int endx = startx + m_title.length(); - attron (pair); - mvprintw (0, startx, "%s", m_title.chars()); - mvhline (0, 0, ' ', startx); - mvhline (0, endx, ' ', COLS - endx); - attroff (pair); + attron(pair); + mvprintw(0, startx, "%s", m_title.chars()); + mvhline(0, 0, ' ', startx); + mvhline(0, endx, ' ', COLS - endx); + attroff(pair); } m_needRefresh = true; @@ -220,7 +220,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::setTitle (const String& title) +void Interface::setTitle(const String& title) { m_title = title; renderTitlebar(); @@ -228,12 +228,12 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::safeDisconnect (std::function afterwards) +void Interface::safeDisconnect(std::function afterwards) { if (m_session.is_active()) { m_disconnectCallback = afterwards; - setInputState (INPUTSTATE_CONFIRM_DISCONNECTION); + setInputState(INPUTSTATE_CONFIRM_DISCONNECTION); } else afterwards(false); @@ -244,20 +244,20 @@ int Interface::nicklistWidth() { // Allocate at least 12 characters, at most 24 characters, for the nicklist. If we cannot - // afford that (o_O) then we probably shouldn't draw the nicklist at all I think. + // afford that(o_O) then we probably shouldn't draw the nicklist at all I think. int nicklistWidth = COLS / 4; if (nicklistWidth < 12) return 0; - return min (nicklistWidth, 24); + return min(nicklistWidth, 24); } // ------------------------------------------------------------------------------------------------- // Renders the given colored line onto the screen. Will wrap if allowWrap is true. Returns the // 'y' value for the next line. // -int Interface::renderColorline (int y, int x0, int width, const ColoredLine& line, bool allowWrap) +int Interface::renderColorline(int y, int x0, int width, const ColoredLine& line, bool allowWrap) { int x = x0; @@ -272,24 +272,24 @@ ++y; } - if (byte < 256 && isprint (byte)) + if (byte < 256 && isprint(byte)) { - mvaddch (y, x, char (byte)); + mvaddch(y, x, char(byte)); ++x; } - else if (byte >= RLINE_ON_COLOR and byte < (RLINE_ON_COLOR + 16)) + else if (byte >= RLINE_ON_COLOR and byte <(RLINE_ON_COLOR + 16)) { - auto attrfunction = (byte < RLINE_OFF_COLOR ? &attron : &attroff); - (*attrfunction) (getColorPair (Color ((byte - RLINE_ON_COLOR) & 7), DEFAULT)); + auto attrfunction =(byte < RLINE_OFF_COLOR ? &attron : &attroff); + (*attrfunction)(getColorPair(Color((byte - RLINE_ON_COLOR) & 7), DEFAULT)); } else switch (byte) { case RLINE_ON_BOLD: - attron (A_BOLD); + attron(A_BOLD); break; case RLINE_OFF_BOLD: - attroff (A_BOLD); + attroff(A_BOLD); break; } } @@ -304,7 +304,7 @@ if (m_outputLines.size() == 1) return; - m_outputScroll = clamp (m_outputScroll, 0, m_outputLines.size() - 1); + m_outputScroll = clamp(m_outputScroll, 0, m_outputLines.size() - 1); int height = LINES - 3; int width = COLS - nicklistWidth(); @@ -318,7 +318,7 @@ // Where to start? while (start > 0) { - int rows = m_outputLines[start - 1].rows (width); + int rows = m_outputLines[start - 1].rows(width); if (usedHeight + rows > height) { @@ -331,12 +331,12 @@ usedHeight += rows; } - // See if there's any more rows to use (end may be too small) + // See if there's any more rows to use(end may be too small) if (not tightFit) { while (end < m_outputLines.size()) { - int rows = m_outputLines[end].rows (width); + int rows = m_outputLines[end].rows(width); if (usedHeight + rows > height) { @@ -357,17 +357,17 @@ if (start < 0 or start == end or printOffset >= height) return; - assert (start <= end and start - end <= height); + assert(start <= end and start - end <= height); // Clear the display for (int i : range(height)) - mvhline (y + i, 0, ' ', width); + mvhline(y + i, 0, ' ', width); // Print the lines y += printOffset; for (int i : range(start, end)) - y = renderColorline (y, 0, width, m_outputLines[i], true); + y = renderColorline(y, 0, width, m_outputLines[i], true); m_needOutputRender = false; m_needRefresh = true; @@ -387,10 +387,10 @@ for (int i : range(height)) { - mvhline (y, x, ' ', width); + mvhline(y, x, ' ', width); if (i < m_playerNames.size()) - renderColorline (y, x, width, m_playerNames[i], false); + renderColorline(y, x, width, m_playerNames[i], false); y++; } @@ -403,16 +403,16 @@ // void Interface::renderInput() { - chtype promptColor = getColorPair (WHITE, BLUE); + chtype promptColor = getColorPair(WHITE, BLUE); // If we're asking the user if they want to disconnect, we don't render any input strings, // just the confirmation message. if (m_inputState == INPUTSTATE_CONFIRM_DISCONNECTION) { - attron (promptColor); - mvhline (LINES - 2, 0, ' ', COLS); - mvprintw (LINES - 2, 0, "Are you sure you want to disconnect? y/n"); - attroff (promptColor); + attron(promptColor); + mvhline(LINES - 2, 0, ' ', COLS); + mvprintw(LINES - 2, 0, "Are you sure you want to disconnect? y/n"); + attroff(promptColor); m_needRefresh = true; return; } @@ -430,7 +430,7 @@ } // Ensure the cursor is within bounds - m_cursorPosition = clamp (m_cursorPosition, 0, displayString.length()); + m_cursorPosition = clamp(m_cursorPosition, 0, displayString.length()); // Ensure that the cursor is always in view, adjust panning if this is not the case if (m_cursorPosition > m_inputPanning + displayLength) @@ -440,19 +440,19 @@ // What part of the string to draw? int start = m_inputPanning; - int end = min (displayString.length(), start + displayLength); - assert (m_cursorPosition >= start and m_cursorPosition <= end); + int end = min(displayString.length(), start + displayLength); + assert(m_cursorPosition >= start and m_cursorPosition <= end); // Render the input string - mvhline (LINES - 2, 0, ' ', COLS); - mvprintw (y, prompt.length() + 1, "%s", displayString.mid (start, end).chars()); + mvhline(LINES - 2, 0, ' ', COLS); + mvprintw(y, prompt.length() + 1, "%s", displayString.mid(start, end).chars()); // Render the prompt - attron (promptColor); - mvprintw (y, 0, "%s", prompt.chars()); - attroff (promptColor); + attron(promptColor); + mvprintw(y, 0, "%s", prompt.chars()); + attroff(promptColor); - // Store in memory where the cursor is now (so that we can re-draw it to position the terminal + // Store in memory where the cursor is now(so that we can re-draw it to position the terminal // cursor). m_cursorCharacter.ch = m_cursorPosition != 0 ? displayString[m_cursorPosition - 1] : '\0'; m_cursorCharacter.x = prompt.length() + (m_cursorPosition - m_inputPanning); @@ -464,12 +464,12 @@ // void Interface::renderStatusBar() { - chtype color = getColorPair (WHITE, BLUE); + chtype color = getColorPair(WHITE, BLUE); int y = LINES - 1; - attron (color); - mvhline (y, 0, ' ', COLS); - mvprintw (y, 0, "%s", m_statusBarText.chars()); - attroff (color); + attron(color); + mvhline(y, 0, ' ', COLS); + mvprintw(y, 0, "%s", m_statusBarText.chars()); + attroff(color); m_needRefresh = true; m_needStatusBarRender = false; } @@ -488,7 +488,7 @@ case RCON_CONNECTING: case RCON_AUTHENTICATING: - text = "Connecting to " + m_session.address().to_string (IPAddress::WITH_PORT) + "..."; + text = "Connecting to " + m_session.address().to_string(IPAddress::WITH_PORT) + "..."; break; case RCON_CONNECTED: @@ -501,12 +501,12 @@ } else { - adminText.sprintf ("%d other admin%s", m_session.num_admins(), + adminText.sprintf("%d other admin%s", m_session.num_admins(), m_session.num_admins() != 1 ? "s" : ""); } - text.sprintf ("%s | %s | %s", - m_session.address().to_string (IPAddress::WITH_PORT).chars(), + text.sprintf("%s | %s | %s", + m_session.address().to_string(IPAddress::WITH_PORT).chars(), m_session.level().chars(), adminText.chars()); } @@ -517,7 +517,7 @@ text += " | "; text += "Ctrl+N to connect, Ctrl+Q to "; - text += (m_session.state() == RCON_DISCONNECTED) ? "quit" : "disconnect"; + text +=(m_session.state() == RCON_DISCONNECTED) ? "quit" : "disconnect"; if (text != m_statusBarText) { @@ -549,9 +549,9 @@ int y = LINES - 2; if (m_cursorCharacter.ch != '\0') - mvprintw (y, m_cursorCharacter.x, "%c", m_cursorCharacter.ch); + mvprintw(y, m_cursorCharacter.x, "%c", m_cursorCharacter.ch); else - mvprintw (y, getPromptString().length(), " "); + mvprintw(y, getPromptString().length(), " "); } // ------------------------------------------------------------------------------------------------- @@ -562,11 +562,11 @@ int pos = m_cursorPosition; // Move past whitespace - while (pos > 0 and isspace (input[pos - 1])) + while (pos > 0 and isspace(input[pos - 1])) pos--; // Move past the word - while (pos > 0 and not isspace (input[pos - 1])) + while (pos > 0 and not isspace(input[pos - 1])) pos--; return pos; @@ -580,11 +580,11 @@ int pos = m_cursorPosition; // Move past current whitespace - while (pos < input.length() and isspace (input[pos])) + while (pos < input.length() and isspace(input[pos])) pos++; // Move past the word - while (input[pos] != '\0' and not isspace (input[pos])) + while (input[pos] != '\0' and not isspace(input[pos])) pos++; return pos; @@ -592,7 +592,7 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::yank (int a, int b) +void Interface::yank(int a, int b) { if (a >= b) return; @@ -601,8 +601,8 @@ m_cursorPosition = a; String& input = getEditableInput(); - m_pasteBuffer = input.mid (a, b); - input.remove (a, b - a); + m_pasteBuffer = input.mid(a, b); + input.remove(a, b - a); m_needInputRender = true; } @@ -630,14 +630,14 @@ m_disconnectCallback(true); } else if (ch == 'n' or ch == 'N') - setInputState (INPUTSTATE_NORMAL); + setInputState(INPUTSTATE_NORMAL); return; } if (ch >= 0x20 and ch <= 0x7E) { - getEditableInput().insert (m_cursorPosition++, char (ch)); + getEditableInput().insert(m_cursorPosition++, char(ch)); m_needInputRender = true; } else switch (ch) @@ -649,11 +649,11 @@ break; case INPUTSTATE_NORMAL: - safeDisconnect ([&](bool hadsession) + safeDisconnect([&](bool hadsession) { if (hadsession) { - setInputState (INPUTSTATE_NORMAL); + setInputState(INPUTSTATE_NORMAL); } else { @@ -664,11 +664,11 @@ break; case INPUTSTATE_PASSWORD: - setInputState (INPUTSTATE_ADDRESS); + setInputState(INPUTSTATE_ADDRESS); break; case INPUTSTATE_ADDRESS: - setInputState (INPUTSTATE_NORMAL); + setInputState(INPUTSTATE_NORMAL); } break; @@ -692,7 +692,7 @@ case KEY_DOWN: case KEY_UP: - moveInputCursor (ch == KEY_DOWN ? -1 : 1); + moveInputCursor(ch == KEY_DOWN ? -1 : 1); break; case KEY_HOME: @@ -717,7 +717,7 @@ case '\b': if (m_cursorPosition > 0) { - getEditableInput().remove_at (--m_cursorPosition); + getEditableInput().remove_at(--m_cursorPosition); m_needInputRender = true; } break; @@ -726,41 +726,41 @@ case 'D' - 'A' + 1: // readline ^D if (m_cursorPosition < getCurrentInput().length()) { - getEditableInput().remove_at (m_cursorPosition); + getEditableInput().remove_at(m_cursorPosition); m_needInputRender = true; } break; case KEY_PPAGE: - m_outputScroll += min (PAGE_SIZE, LINES / 2); + m_outputScroll += min(PAGE_SIZE, LINES / 2); m_needOutputRender = true; break; case KEY_NPAGE: - m_outputScroll -= min (PAGE_SIZE, LINES / 2); + m_outputScroll -= min(PAGE_SIZE, LINES / 2); m_needOutputRender = true; break; case 'U' - 'A' + 1: // readline ^U - delete from start to cursor if (m_cursorPosition > 0) { - yank (0, m_cursorPosition); + yank(0, m_cursorPosition); m_cursorPosition = 0; } break; case 'K' - 'A' + 1: // readline ^K - delete from cursor to end - yank (m_cursorPosition, getEditableInput().length()); + yank(m_cursorPosition, getEditableInput().length()); break; case 'W' - 'A' + 1: // readline ^W - delete from previous word bounary to current - yank (findPreviousWord(), m_cursorPosition); + yank(findPreviousWord(), m_cursorPosition); break; case 'Y' - 'A' + 1: // readline ^Y - paste previously deleted text if (not m_pasteBuffer.is_empty()) { - getEditableInput().insert (m_cursorPosition, m_pasteBuffer); + getEditableInput().insert(m_cursorPosition, m_pasteBuffer); m_cursorPosition += m_pasteBuffer.length(); m_needInputRender = true; } @@ -768,14 +768,14 @@ case '\t': { - int space = getCurrentInput().find (" "); + int space = getCurrentInput().find(" "); if (m_inputState == INPUTSTATE_NORMAL and m_cursorPosition > 0 - and (space == -1 or space >= m_cursorPosition)) + and(space == -1 or space >= m_cursorPosition)) { - String start = getCurrentInput().mid (0, m_cursorPosition); - m_session.request_tab_complete (start); + String start = getCurrentInput().mid(0, m_cursorPosition); + m_session.request_tab_complete(start); } } break; @@ -791,27 +791,27 @@ case INPUTSTATE_ADDRESS: try { - m_remoteAddress = IPAddress::from_string (getCurrentInput()); + m_remoteAddress = IPAddress::from_string(getCurrentInput()); } catch (std::exception& e) { - print ("%s\n", e.what()); + print("%s\n", e.what()); return; } if (m_remoteAddress.port == 0) m_remoteAddress.port = 10666; - setInputState (INPUTSTATE_PASSWORD); + setInputState(INPUTSTATE_PASSWORD); break; case INPUTSTATE_PASSWORD: if (m_inputState == INPUTSTATE_PASSWORD and not getCurrentInput().is_empty()) { m_session.disconnect(); - m_session.set_password (getCurrentInput()); - m_session.connect (m_remoteAddress); - setInputState (INPUTSTATE_NORMAL); + m_session.set_password(getCurrentInput()); + m_session.connect(m_remoteAddress); + setInputState(INPUTSTATE_NORMAL); } break; @@ -821,7 +821,7 @@ handleCommand(getCurrentInput()); flushInput(); } - else if (m_session.send_command (getCurrentInput())) + else if (m_session.send_command(getCurrentInput())) { flushInput(); } @@ -831,7 +831,7 @@ case 'N' - 'A' + 1: // ^N if (m_inputState == INPUTSTATE_NORMAL) - safeDisconnect ([&](bool){setInputState (INPUTSTATE_ADDRESS);}); + safeDisconnect([&](bool){setInputState(INPUTSTATE_ADDRESS);}); break; case '\x1b': // Escape @@ -859,12 +859,12 @@ case 'd': case 'D': // readline alt-d - delete from here till next word boundary - yank (m_cursorPosition, findNextWord()); + yank(m_cursorPosition, findNextWord()); break; case KEY_BACKSPACE: // alt+backspace, remove previous word case '\b': - yank (findPreviousWord(), m_cursorPosition); + yank(findPreviousWord(), m_cursorPosition); break; } } @@ -872,9 +872,9 @@ { // No alt-key, handle pure escape if (m_inputState == INPUTSTATE_PASSWORD) - setInputState (INPUTSTATE_ADDRESS); + setInputState(INPUTSTATE_ADDRESS); else if (m_inputState == INPUTSTATE_ADDRESS) - setInputState (INPUTSTATE_NORMAL); + setInputState(INPUTSTATE_NORMAL); } break; } @@ -901,63 +901,63 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::vprint (const char* fmtstr, va_list args) +void Interface::vprint(const char* fmtstr, va_list args) { String message; - message.vsprintf (fmtstr, args); - printToConsole (message); + message.vsprintf(fmtstr, args); + printToConsole(message); } // ------------------------------------------------------------------------------------------------- // -void __cdecl Interface::printText (const char* fmtstr, ...) +void __cdecl Interface::printText(const char* fmtstr, ...) { va_list args; - va_start (args, fmtstr); - vprint (fmtstr, args); - va_end (args); + va_start(args, fmtstr); + vprint(fmtstr, args); + va_end(args); } // ------------------------------------------------------------------------------------------------- // -void __cdecl Interface::print (const char* fmtstr, ...) +void __cdecl Interface::print(const char* fmtstr, ...) { va_list args; - va_start (args, fmtstr); - printToConsole (TEXTCOLOR_BrightBlue); - vprint (fmtstr, args); - va_end (args); + va_start(args, fmtstr); + printToConsole(TEXTCOLOR_BrightBlue); + vprint(fmtstr, args); + va_end(args); } // ------------------------------------------------------------------------------------------------- // -void __cdecl Interface::printWarning (const char* fmtstr, ...) +void __cdecl Interface::printWarning(const char* fmtstr, ...) { va_list args; - va_start (args, fmtstr); - printToConsole (TEXTCOLOR_BrightYellow "-!- "); - vprint (fmtstr, args); - va_end (args); + va_start(args, fmtstr); + printToConsole(TEXTCOLOR_BrightYellow "-!- "); + vprint(fmtstr, args); + va_end(args); } // ------------------------------------------------------------------------------------------------- // -void __cdecl Interface::printError (const char* fmtstr, ...) +void __cdecl Interface::printError(const char* fmtstr, ...) { va_list args; - va_start (args, fmtstr); - printToConsole (TEXTCOLOR_BrightRed "!!! "); - vprint (fmtstr, args); - va_end (args); + va_start(args, fmtstr); + printToConsole(TEXTCOLOR_BrightRed "!!! "); + vprint(fmtstr, args); + va_end(args); } // ------------------------------------------------------------------------------------------------- // -void Interface::printToConsole (String message) +void Interface::printToConsole(String message) { // Zandronum sometimes sends color codes as "\\c" and sometimes as "\x1C". // Let's correct that on our end and hope this won't cause conflicts. - message.replace ("\\c", "\x1C"); + message.replace("\\c", "\x1C"); for (char ch : message) { @@ -971,19 +971,19 @@ if (m_outputLines.last().length() == 0) { time_t now; - time (&now); + time(&now); char timestamp[32]; - strftime (timestamp, sizeof timestamp, "[%H:%M:%S] ", localtime (&now)); + strftime(timestamp, sizeof timestamp, "[%H:%M:%S] ", localtime(&now)); for (char ch : String(timestamp)) - m_outputLines.last().add_char (ch); + m_outputLines.last().add_char(ch); } // Remove some lines if there's too many of them. 20,000 should be enough, I hope. while (m_outputLines.size() > 20000) m_outputLines.remove_at(0); - m_outputLines.last().add_char (ch); + m_outputLines.last().add_char(ch); } m_needOutputRender = true; @@ -991,15 +991,15 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::connect (String address, String password) +void Interface::connect(String address, String password) { try { - m_remoteAddress = IPAddress::from_string (address); + m_remoteAddress = IPAddress::from_string(address); } catch (std::exception& e) { - print ("%s\n", e.what()); + print("%s\n", e.what()); return; } @@ -1007,22 +1007,22 @@ m_remoteAddress.port = 10666; m_session.disconnect(); - m_session.set_password (password); - m_session.connect (m_remoteAddress); + m_session.set_password(password); + m_session.connect(m_remoteAddress); } // ------------------------------------------------------------------------------------------------- // -void Interface::setPlayerNames (const StringList& names) +void Interface::setPlayerNames(const StringList& names) { m_playerNames.clear(); for (const String& name : names) { ColoredLine coloredname; - coloredname.add_string (name); + coloredname.add_string(name); coloredname.finalize(); - m_playerNames.append (coloredname); + m_playerNames.append(coloredname); } m_needNicklistRender = true; @@ -1030,16 +1030,16 @@ // ------------------------------------------------------------------------------------------------- // -void Interface::tabComplete (const String& part, String complete) +void Interface::tabComplete(const String& part, String complete) { String& input = getEditableInput(); - if (input.starts_with (part)) + if (input.starts_with(part)) { if (input[part.length()] != ' ') complete += ' '; - input.replace (0, part.length(), complete); + input.replace(0, part.length(), complete); m_cursorPosition = complete.length(); m_needInputRender = true; } @@ -1111,14 +1111,14 @@ // void Interface::resetTitle() { - m_title.sprintf ("%s %s (%s)", application_name(), full_version_string(), changeset_date_string()); + m_title.sprintf("%s %s (%s)", application_name(), full_version_string(), changeset_date_string()); } // ------------------------------------------------------------------------------------------------- // void Interface::flushInput() { - m_inputHistory.insert (0, ""); + m_inputHistory.insert(0, ""); m_inputCursor = 0; m_needInputRender = true; }