1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
//! A powerful formatting library for window information with multiple output formats and templates.
//!
//! This crate provides flexible formatting capabilities for window information,
//! supporting various output formats and customizable templates.
//!
//! # Features
//!
//! - **Multiple Formats**: JSON, YAML, CSV, Table, Simple, and Detailed formats
//! - **Template System**: Field selection, key-value pairs, and custom templates
//! - **Highly Configurable**: Title truncation, header control, and output customization
//! - **Easy to Use**: Simple API with rich examples and builder pattern
//! - **Flexible**: Works standalone or with `window-enumerator` integration
//! - **Optional Dependencies**: Minimal required dependencies
//!
//! # Quick Start
//!
//! ## Standalone Usage
//!
//! ```
//! use window_enumerator_formatter::{
//! WindowInfo, WindowPosition, OutputFormat, WindowListFormat
//! };
//! use std::path::PathBuf;
//!
//! // Create window data using builder pattern
//! let window = WindowInfo::builder()
//! .hwnd(12345)
//! .pid(1234)
//! .title("Test Window".to_string())
//! .class_name("TestClass".to_string())
//! .process_name("test.exe".to_string())
//! .process_file(PathBuf::from("test.exe"))
//! .index(1)
//! .position(WindowPosition::default())
//! .build();
//!
//! let windows = vec![window];
//!
//! // Format with different output formats
//! println!("JSON: {}", windows.format_with(OutputFormat::Json));
//! println!("Table: {}", windows.format_with(OutputFormat::Table));
//! println!("CSV: {}", windows.format_with(OutputFormat::Csv));
//!
//! // Individual window formatting
//! println!("Single window: {}", windows[0].format_with(OutputFormat::Simple));
//! ```
//!
//! ## Using different output formats:
//! ```
//! use window_enumerator_formatter::{
//! WindowInfo, WindowPosition, OutputFormat, WindowListFormat, FormatConfig
//! };
//! use std::path::PathBuf;
//!
//! let windows = vec![
//! WindowInfo::builder()
//! .hwnd(12345)
//! .pid(1234)
//! .title("Browser".to_string())
//! .class_name("Chrome_WidgetWin_1".to_string())
//! .process_name("chrome.exe".to_string())
//! .process_file(PathBuf::from("C:\\Program Files\\Google\\Chrome\\chrome.exe"))
//! .index(1)
//! .position(WindowPosition { x: 100, y: 100, width: 1920, height: 1080 })
//! .build(),
//! WindowInfo::builder()
//! .hwnd(67890)
//! .pid(5678)
//! .title("Text Editor".to_string())
//! .class_name("Notepad".to_string())
//! .process_name("notepad.exe".to_string())
//! .process_file(PathBuf::from("C:\\Windows\\notepad.exe"))
//! .index(2)
//! .position(WindowPosition { x: 50, y: 50, width: 800, height: 600 })
//! .build(),
//! ];
//!
//! // JSON format
//! println!("JSON:\n{}", windows.format_with(OutputFormat::Json));
//!
//! // Table format
//! println!("\nTable:\n{}", windows.format_with(OutputFormat::Table));
//!
//! // CSV format
//! println!("\nCSV:\n{}", windows.format_with(OutputFormat::Csv));
//!
//! // Simple format
//! println!("\nSimple:\n{}", windows.format_with(OutputFormat::Simple));
//! ```
//!
//! ## Using custom templates:
//! ```
//! use window_enumerator_formatter::{
//! WindowInfo, WindowPosition, OutputFormat, TemplateFormat, FormatConfig
//! };
//! use std::path::PathBuf;
//!
//! let window = WindowInfo::builder()
//! .hwnd(12345)
//! .pid(1234)
//! .title("My Application".to_string())
//! .class_name("MyAppClass".to_string())
//! .process_name("myapp.exe".to_string())
//! .process_file(PathBuf::from("myapp.exe"))
//! .index(1)
//! .position(WindowPosition { x: 100, y: 200, width: 1024, height: 768 })
//! .build();
//!
//! // Field values only template
//! let config = FormatConfig {
//! format: OutputFormat::Custom,
//! template: Some(TemplateFormat::Fields(vec![
//! "index".into(),
//! "pid".into(),
//! "title".into()
//! ])),
//! ..Default::default()
//! };
//! println!("Fields: {}", window.format(&config));
//!
//! // Key-value template
//! let config = FormatConfig {
//! format: OutputFormat::Custom,
//! template: Some(TemplateFormat::KeyValue(vec![
//! "index".into(),
//! "hwnd".into(),
//! "title".into()
//! ])),
//! ..Default::default()
//! };
//! println!("Key-Value: {}", window.format(&config));
//!
//! // Custom template string
//! let config = FormatConfig {
//! format: OutputFormat::Custom,
//! template: Some(TemplateFormat::Custom(
//! "Window[{index}] | PID:{pid} | Title:{title}".into()
//! )),
//! ..Default::default()
//! };
//! println!("Custom: {}", window.format(&config));
//! ```
//!
//! ## Advanced configuration:
//! ```
//! use window_enumerator_formatter::{
//! WindowInfo, WindowPosition, OutputFormat, FormatConfig, WindowListFormat
//! };
//! use std::path::PathBuf;
//!
//! let windows = vec![
//! WindowInfo::builder()
//! .hwnd(12345)
//! .pid(1234)
//! .title("This is a very long window title that might need truncation".to_string())
//! .class_name("SomeClass".to_string())
//! .process_name("app.exe".to_string())
//! .process_file(PathBuf::from("app.exe"))
//! .index(1)
//! .position(WindowPosition::default())
//! .build(),
//! ];
//!
//! let config = FormatConfig {
//! format: OutputFormat::Table,
//! show_headers: false,
//! max_title_length: Some(20),
//! ..Default::default()
//! };
//!
//! println!("{}", windows.format_output(&config));
//! ```
//!
//! ## With window-enumerator integration (requires feature):
//! ```ignore
//! // This example requires the `window-enumerator` feature
//! use window_enumerator::WindowEnumerator;
//! use window_enumerator_formatter::{OutputFormat, WindowListFormat};
//!
//! let mut enumerator = WindowEnumerator::new();
//! enumerator.enumerate_all_windows().unwrap();
//! let windows: Vec<_> = enumerator.get_windows().iter().map(|w| w.into()).collect();
//!
//! // Format as pretty JSON
//! println!("{}", windows.format_with(OutputFormat::JsonPretty));
//!
//! // Format as YAML
//! println!("{}", windows.format_with(OutputFormat::Yaml));
//!
//! // Format as detailed list
//! println!("{}", windows.format_with(OutputFormat::Detail));
//! ```
pub use FormatError;
pub use ;
pub use ;
// 为 WindowInfo 实现格式化方法,消除循环依赖
/// Prelude module for convenient imports.