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 "config.h"
#include "logcat_thread.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) { static inline void write_config_and_update_structures(const Config& config) {
try { try {
write_config(config); 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}; char time_as_str[128] = {0};
strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&logcat_entry->time)); strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&logcat_entry->time));
std::string header = std::string(1, '[') + time_as_str + " "; std::string header = std::string(1, '[') + time_as_str + ' '
header += logcat_entry->user.value_or(" ") + " "; + leftpad(logcat_entry->user.value_or(" "), 5) + ' '
header += std::to_string(logcat_entry->pid) + " "; + leftpad(std::to_string(logcat_entry->pid), 5) + ' '
header += std::to_string(logcat_entry->tid) + " "; + leftpad(std::to_string(logcat_entry->tid), 5) + ' '
header += std::string(buffer_to(logcat_entry->buffer)) + " "; + leftpad(buffer_to(logcat_entry->buffer), 6) + ' '
header += std::string(priority_to(logcat_entry->priority)) + "] "; + leftpad(priority_to(logcat_entry->priority), 7) + "] ";
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]); ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
ImGui::TextUnformatted(header.data(), &header[header.size()]); ImGui::TextUnformatted(header.data(), &header[header.size()]);
ImGui::PopStyleColor(); ImGui::PopStyleColor();