Compare commits

...

2 Commits

Author SHA1 Message Date
blankie b21c31ad97
Add QoL for editing filter titles 2023-02-07 13:51:18 +07:00
blankie c43dd3a4db
Clear logcat entries when (re)starting logcat 2023-02-07 13:36:51 +07:00
3 changed files with 15 additions and 2 deletions

View File

@ -24,11 +24,18 @@ static void render_filter(Filter* filter, std::string* title, bool* request_remo
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::Text("Title:%s%s", title->empty() ? "" : " ", title->c_str()); ImGui::Text("Title:%s%s", title->empty() ? "" : " ", title->c_str());
ImGui::SameLine(); ImGui::SameLine();
bool popup_just_opened = false;
if (ImGui::Button("Edit")) { if (ImGui::Button("Edit")) {
ImGui::OpenPopup("change_filter_title"); ImGui::OpenPopup("change_filter_title");
popup_just_opened = true;
} }
if (ImGui::BeginPopup("change_filter_title")) { if (ImGui::BeginPopup("change_filter_title")) {
ImGui::InputText("##title", title); ImGui::SetKeyboardFocusHere();
bool enter_pressed = ImGui::InputText("##title", title, ImGuiInputTextFlags_EnterReturnsTrue);
if (enter_pressed || (!popup_just_opened && !ImGui::IsItemActive())) {
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup(); ImGui::EndPopup();
} }
ImGui::SameLine(); ImGui::SameLine();
@ -223,7 +230,8 @@ static void try_write_config(const Config& config) {
void filters_fragment(Config& active_config, Filters& __restrict active_filters, Filters& __restrict inactive_filters, void filters_fragment(Config& active_config, Filters& __restrict active_filters, Filters& __restrict inactive_filters,
const std::vector<LogcatEntry>& logcat_entries, std::vector<size_t>& filtered_logcat_entry_offsets, const std::vector<LogcatEntry>& logcat_entries, std::vector<size_t>& filtered_logcat_entry_offsets,
bool* p_open) { bool* p_open) {
ImGui::TextUnformatted("You can use regex for strings by prepending \"regex:\""); ImGui::TextWrapped("You can use regex for strings by prepending \"regex:\". "
"While editing titles, press Enter to use the new title or press Escape to keep the old one");
for (Filters::iterator it = inactive_filters.begin(); it != inactive_filters.end();) { for (Filters::iterator it = inactive_filters.begin(); it != inactive_filters.end();) {
bool removal_requested = false; bool removal_requested = false;

View File

@ -302,6 +302,7 @@ bool LogcatThread::_handle_start_request() {
} }
}; };
// TODO what if *this->_logcat_command was mutated during copying?
std::string logcat_command = *this->_logcat_command; std::string logcat_command = *this->_logcat_command;
if (logcat_command.empty()) { if (logcat_command.empty()) {
logcat_command = default_logcat_command; logcat_command = default_logcat_command;

View File

@ -100,6 +100,8 @@ void main_window(bool latest_log_entries_read, ImFont* monospace_font, LogcatThr
} }
if (ImGui::Button("Start", !logcat_running)) { if (ImGui::Button("Start", !logcat_running)) {
logcat_entries.clear();
filtered_logcat_entry_offsets.clear();
logcat_thread.logcat_process_request.store(LogcatProcessRequest::Start); logcat_thread.logcat_process_request.store(LogcatProcessRequest::Start);
} }
ImGui::SameLine(); ImGui::SameLine();
@ -108,6 +110,8 @@ void main_window(bool latest_log_entries_read, ImFont* monospace_font, LogcatThr
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Restart", logcat_running)) { if (ImGui::Button("Restart", logcat_running)) {
logcat_entries.clear();
filtered_logcat_entry_offsets.clear();
logcat_thread.logcat_process_request.store(LogcatProcessRequest::Start); logcat_thread.logcat_process_request.store(LogcatProcessRequest::Start);
} }