Pad things out

This commit is contained in:
blankie 2023-01-21 15:52:55 +07:00
parent 5a31b38ef0
commit d1d096d3cb
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 13 additions and 6 deletions

View File

@ -5,6 +5,13 @@
#include "config.h"
#include "logcat_thread.h"
static std::string leftpad(std::string str, size_t characters) {
if (str.size() < characters) {
return str.insert(0, characters - str.size(), ' ');
}
return str;
}
static inline void write_config_and_update_structures(const Config& config) {
try {
write_config(config);
@ -143,12 +150,12 @@ static inline void main_window(bool latest_log_entries_read, ImFont* monospace_f
char time_as_str[128] = {0};
strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&logcat_entry->time));
std::string header = std::string(1, '[') + time_as_str + " ";
header += logcat_entry->user.value_or(" ") + " ";
header += std::to_string(logcat_entry->pid) + " ";
header += std::to_string(logcat_entry->tid) + " ";
header += std::string(buffer_to(logcat_entry->buffer)) + " ";
header += std::string(priority_to(logcat_entry->priority)) + "] ";
std::string header = std::string(1, '[') + time_as_str + ' '
+ leftpad(logcat_entry->user.value_or(" "), 5) + ' '
+ leftpad(std::to_string(logcat_entry->pid), 5) + ' '
+ leftpad(std::to_string(logcat_entry->tid), 5) + ' '
+ leftpad(buffer_to(logcat_entry->buffer), 6) + ' '
+ leftpad(priority_to(logcat_entry->priority), 7) + "] ";
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
ImGui::TextUnformatted(header.data(), &header[header.size()]);
ImGui::PopStyleColor();