| 150 | } |
| 151 | |
| 152 | string ShellProgressBar::GenerateProgressBar(ShellState &state, idx_t terminal_width) { |
| 153 | string lhs; |
| 154 | string rhs; |
| 155 | idx_t total_render_length = 0; |
| 156 | for (auto &component : components) { |
| 157 | auto text = component->GeneratePrompt(state); |
| 158 | if (!component->does_not_contain.empty()) { |
| 159 | if (StringUtil::Contains(text, component->does_not_contain)) { |
| 160 | continue; |
| 161 | } |
| 162 | } |
| 163 | auto render_length = state.RenderLength(text); |
| 164 | component->AddPaddingIfRequired(text, render_length); |
| 165 | |
| 166 | if (total_render_length + render_length > terminal_width) { |
| 167 | // exceeds terminal width - don't stop rendering |
| 168 | break; |
| 169 | } |
| 170 | total_render_length += render_length; |
| 171 | if (component->alignment == ProgressBarAlignment::LEFT) { |
| 172 | lhs += text; |
| 173 | } else { |
| 174 | rhs += text; |
| 175 | } |
| 176 | } |
| 177 | string result; |
| 178 | result = lhs; |
| 179 | if (total_render_length < terminal_width) { |
| 180 | result += string(terminal_width - total_render_length, ' '); |
| 181 | result += rhs; |
| 182 | } |
| 183 | return result; |
| 184 | } |
| 185 | |
| 186 | ShellProgressBarDisplay::ShellProgressBarDisplay() { |
| 187 | } |
no test coverage detected