OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/gn/standard_out.h" | 5 #include "tools/gn/standard_out.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 DECORATION_DIM); | 160 DECORATION_DIM); |
161 } | 161 } |
162 | 162 |
163 OutputString(line.substr(first_normal) + "\n"); | 163 OutputString(line.substr(first_normal) + "\n"); |
164 } | 164 } |
165 | 165 |
166 void PrintLongHelp(const std::string& text) { | 166 void PrintLongHelp(const std::string& text) { |
167 std::vector<std::string> lines; | 167 std::vector<std::string> lines; |
168 base::SplitStringDontTrim(text, '\n', &lines); | 168 base::SplitStringDontTrim(text, '\n', &lines); |
169 | 169 |
170 for (size_t i = 0; i < lines.size(); i++) { | 170 for (const auto& line : lines) { |
171 const std::string& line = lines[i]; | |
172 | |
173 // Check for a heading line. | 171 // Check for a heading line. |
174 if (!line.empty() && line[0] != ' ') { | 172 if (!line.empty() && line[0] != ' ') { |
175 // Highlight up to the colon (if any). | 173 // Highlight up to the colon (if any). |
176 size_t chars_to_highlight = line.find(':'); | 174 size_t chars_to_highlight = line.find(':'); |
177 if (chars_to_highlight == std::string::npos) | 175 if (chars_to_highlight == std::string::npos) |
178 chars_to_highlight = line.size(); | 176 chars_to_highlight = line.size(); |
179 OutputString(line.substr(0, chars_to_highlight), DECORATION_YELLOW); | 177 OutputString(line.substr(0, chars_to_highlight), DECORATION_YELLOW); |
180 OutputString(line.substr(chars_to_highlight) + "\n"); | 178 OutputString(line.substr(chars_to_highlight) + "\n"); |
181 continue; | 179 continue; |
182 } | 180 } |
183 | 181 |
184 // Check for a comment. | 182 // Check for a comment. |
185 TextDecoration dec = DECORATION_NONE; | 183 TextDecoration dec = DECORATION_NONE; |
186 for (size_t char_i = 0; char_i < line.size(); char_i++) { | 184 for (size_t char_i = 0; char_i < line.size(); char_i++) { |
187 if (line[char_i] == '#') { | 185 if (line[char_i] == '#') { |
188 // Got a comment, draw dimmed. | 186 // Got a comment, draw dimmed. |
189 dec = DECORATION_DIM; | 187 dec = DECORATION_DIM; |
190 break; | 188 break; |
191 } else if (line[char_i] != ' ') { | 189 } else if (line[char_i] != ' ') { |
192 break; | 190 break; |
193 } | 191 } |
194 } | 192 } |
195 | 193 |
196 OutputString(line + "\n", dec); | 194 OutputString(line + "\n", dec); |
197 } | 195 } |
198 } | 196 } |
199 | 197 |
OLD | NEW |