diff -r 8a4690db252e -r 485cb6d6b98c sources/interface.cpp --- a/sources/interface.cpp Fri May 15 22:46:53 2015 +0300 +++ b/sources/interface.cpp Wed Jul 20 14:48:47 2016 +0300 @@ -179,8 +179,8 @@ int defaultBg = hasDefaultColors ? -1 : COLOR_BLACK; // Initialize color pairs - for (int i = 0; i < NUM_COLORS; ++i) - for (int j = 0; j < NUM_COLORS; ++j) + for (int i : range(NUM_COLORS)) + for (int j : range(NUM_COLORS)) { int pairnum = 1 + (i * NUM_COLORS + j); int fg = (i == DEFAULT) ? defaultFg : i; @@ -261,10 +261,8 @@ { int x = x0; - for (int i = 0; i < line.data().size(); ++i) + for (int byte : line.data()) { - int byte = line.data()[i]; - if (x == x0 + width) { if (not allowWrap) @@ -362,13 +360,13 @@ assert (start <= end and start - end <= height); // Clear the display - for (int i = y; i < y + height; ++i) - mvhline (i, 0, ' ', width); + for (int i : range(height)) + mvhline (y + i, 0, ' ', width); // Print the lines y += printOffset; - for (int i = start; i < end; ++i) + for (int i : range(start, end)) y = render_colorline (y, 0, width, m_outputLines[i], true); m_needOutputRender = false; @@ -384,10 +382,10 @@ int y = 1; int x = COLS - width; - if (width == 0) + if (width > 0) return; - for (int i = 0; i < height; ++i) + for (int i : range(height)) { mvhline (y, x, ' ', width); @@ -427,8 +425,8 @@ // If we're inputting a password, replace it with asterisks if (m_inputState == INPUTSTATE_PASSWORD) { - for (int i = 0; i < displayString.length(); ++i) - displayString[i] = '*'; + for (char &ch : displayString) + ch = '*'; } // Ensure the cursor is within bounds @@ -961,10 +959,8 @@ // Let's correct that on our end and hope this won't cause conflicts. message.replace ("\\c", "\x1C"); - for (int i = 0; i < message.length(); ++i) + for (char ch : message) { - char ch = message[i]; - if (ch == '\n') { m_outputLines.last().finalize(); @@ -979,8 +975,8 @@ char timestamp[32]; strftime (timestamp, sizeof timestamp, "[%H:%M:%S] ", localtime (&now)); - for (char* cp = timestamp; *cp != '\0'; ++cp) - m_outputLines.last().add_char (*cp); + for (char ch : String(timestamp)) + m_outputLines.last().add_char (ch); } // Remove some lines if there's too many of them. 20,000 should be enough, I hope.