comparison dep/animia/src/strategist.cc @ 156:cdf79282d647

dep/animia: add VERY early x11 window stuff
author Paper <mrpapersonic@gmail.com>
date Wed, 15 Nov 2023 18:04:04 -0500
parents bd439dd6ffc5
children bc1ae1810855
comparison
equal deleted inserted replaced
155:d2bbb5773616 156:cdf79282d647
1 #include <regex>
2
3 #include "animia.h"
4 #include "animia/fd.h"
1 #include "animia/strategies.h" 5 #include "animia/strategies.h"
2 #include "animia/util.h" 6 #include "animia/util.h"
3 #include "animia/fd.h"
4 #include "animia.h"
5
6 #include <iostream>
7
8 #include <regex>
9 7
10 namespace animia::internal { 8 namespace animia::internal {
11 9
12 class Strategist { 10 class Strategist {
13 public: 11 public:
26 24
27 bool Strategist::ApplyStrategies() { 25 bool Strategist::ApplyStrategies() {
28 bool success = false; 26 bool success = false;
29 27
30 switch (result_.type) { 28 switch (result_.type) {
31 case ResultType::Process: 29 case ResultType::Process: success |= ApplyOpenFilesStrategy(); break;
32 success |= ApplyOpenFilesStrategy(); 30 case ResultType::Window: success |= ApplyWindowTitleStrategy(); break;
33 break;
34 case ResultType::Window:
35 success |= ApplyWindowTitleStrategy();
36 break;
37 } 31 }
38 32
39 return success; 33 return success;
40 } 34 }
41 35
78 return true; 72 return true;
79 } 73 }
80 74
81 static MediaInfoType InferMediaInformationType(const std::string& str) { 75 static MediaInfoType InferMediaInformationType(const std::string& str) {
82 const std::regex path_pattern(R"(^(?:[A-Za-z]:[/\\]|\\\\)[^<>:"/\\|?*]+)"); 76 const std::regex path_pattern(R"(^(?:[A-Za-z]:[/\\]|\\\\)[^<>:"/\\|?*]+)");
83 return (std::regex_search(str, path_pattern)) 77 return (std::regex_search(str, path_pattern)) ? MediaInfoType::File : MediaInfoType::Unknown;
84 ? MediaInfoType::File : MediaInfoType::Unknown;
85 } 78 }
86 79
87 bool Strategist::ApplyWindowTitleStrategy() { 80 bool Strategist::ApplyWindowTitleStrategy() {
88 auto title = result_.window.text; 81 auto title = result_.window.text;
89 ApplyWindowTitleFormat(result_.player.window_title_format, title); 82 ApplyWindowTitleFormat(result_.player.window_title_format, title);
117 result_.media.push_back(std::move(media)); 110 result_.media.push_back(std::move(media));
118 111
119 return true; 112 return true;
120 } 113 }
121 114
122 } 115 } // namespace animia::internal