@@ -127,7 +127,7 @@ impl TaskView {
127
127
)
128
128
} ;
129
129
130
- let stats_area = Layout :: default ( )
130
+ let stats_area_check = Layout :: default ( )
131
131
. direction ( layout:: Direction :: Horizontal )
132
132
. constraints (
133
133
[
@@ -138,6 +138,51 @@ impl TaskView {
138
138
)
139
139
. split ( stats_area) ;
140
140
141
+ let mut location_lines_vector: Vec < String > = vec ! [ ] ;
142
+ let title = "Location: " ;
143
+ let location_max_width = stats_area_check[ 0 ] . width as usize - 2 - title. len ( ) ; // NOTE: -2 for the border
144
+ let stats_area = if task. location ( ) . len ( ) > location_max_width {
145
+ let max_width_stats_area = area. width - 45 ;
146
+ if max_width_stats_area < task. location ( ) . len ( ) as u16 {
147
+ location_lines_vector = task
148
+ . location ( )
149
+ . to_string ( )
150
+ . chars ( )
151
+ . collect :: < Vec < char > > ( )
152
+ . chunks ( max_width_stats_area as usize )
153
+ . map ( |chunk| chunk. iter ( ) . collect ( ) )
154
+ . collect ( ) ;
155
+
156
+ let area_needed_to_render_location = task. location ( ) . len ( ) as u16 ;
157
+ Layout :: default ( )
158
+ . direction ( layout:: Direction :: Horizontal )
159
+ . constraints (
160
+ [
161
+ layout:: Constraint :: Min ( area_needed_to_render_location + 15 ) , //Note: 15 is the length of "| Location: |"
162
+ layout:: Constraint :: Min ( 32 ) ,
163
+ ]
164
+ . as_ref ( ) ,
165
+ )
166
+ . split ( stats_area)
167
+ } else {
168
+ let area_needed_to_render_location = task. location ( ) . len ( ) as u16 ;
169
+ location_lines_vector. push ( task. location ( ) . to_string ( ) ) ;
170
+ Layout :: default ( )
171
+ . direction ( layout:: Direction :: Horizontal )
172
+ . constraints (
173
+ [
174
+ layout:: Constraint :: Min ( area_needed_to_render_location + 15 ) , //Note: 15 is the length of "| Location: |"
175
+ layout:: Constraint :: Min ( 32 ) ,
176
+ ]
177
+ . as_ref ( ) ,
178
+ )
179
+ . split ( stats_area)
180
+ }
181
+ } else {
182
+ location_lines_vector. push ( task. location ( ) . to_string ( ) ) ;
183
+ stats_area_check
184
+ } ;
185
+
141
186
// Just preallocate capacity for ID, name, target, total, busy, and idle.
142
187
let mut overview = Vec :: with_capacity ( 8 ) ;
143
188
overview. push ( Line :: from ( vec ! [
@@ -152,17 +197,13 @@ impl TaskView {
152
197
153
198
overview. push ( Line :: from ( vec ! [ bold( "Target: " ) , Span :: raw( task. target( ) ) ] ) ) ;
154
199
155
- let title = "Location: " ;
156
- let location_max_width = stats_area[ 0 ] . width as usize - 2 - title. len ( ) ; // NOTE: -2 for the border
157
- let location = if task. location ( ) . len ( ) > location_max_width {
158
- let ellipsis = styles. if_utf8 ( "\u{2026} " , "..." ) ;
159
- let start = task. location ( ) . len ( ) - location_max_width + ellipsis. chars ( ) . count ( ) ;
160
- format ! ( "{}{}" , ellipsis, & task. location( ) [ start..] )
161
- } else {
162
- task. location ( ) . to_string ( )
163
- } ;
164
-
165
- overview. push ( Line :: from ( vec ! [ bold( title) , Span :: raw( location) ] ) ) ;
200
+ let first_line = location_lines_vector[ 0 ] . clone ( ) ;
201
+ location_lines_vector. remove ( 0 ) ;
202
+ let location_vector = vec ! [ bold( title) , Span :: raw( first_line) ] ;
203
+ overview. push ( Line :: from ( location_vector) ) ;
204
+ for line in location_lines_vector {
205
+ overview. push ( Line :: from ( Span :: raw ( format ! ( " {}" , line) ) ) ) ;
206
+ }
166
207
167
208
let total = task. total ( now) ;
168
209
@@ -185,28 +226,37 @@ impl TaskView {
185
226
186
227
let mut waker_stats = vec ! [ Line :: from( vec![
187
228
bold( "Current wakers: " ) ,
188
- Span :: from( format!( "{} (" , task. waker_count( ) ) ) ,
189
- bold( "clones: " ) ,
190
- Span :: from( format!( "{}, " , task. waker_clones( ) ) ) ,
191
- bold( "drops: " ) ,
192
- Span :: from( format!( "{})" , task. waker_drops( ) ) ) ,
229
+ Span :: from( format!( "{} " , task. waker_count( ) ) ) ,
193
230
] ) ] ;
231
+ let waker_stats_clones = vec ! [
232
+ bold( " Clones: " ) ,
233
+ Span :: from( format!( "{}, " , task. waker_clones( ) ) ) ,
234
+ ] ;
235
+
236
+ let waker_stats_drops = vec ! [
237
+ bold( " Drops: " ) ,
238
+ Span :: from( format!( "{}" , task. waker_drops( ) ) ) ,
239
+ ] ;
194
240
195
- let mut wakeups = vec ! [
241
+ let wakeups = vec ! [
196
242
bold( "Woken: " ) ,
197
243
Span :: from( format!( "{} times" , task. wakes( ) ) ) ,
198
244
] ;
199
245
246
+ let mut last_woken_line = vec ! [ ] ;
247
+
200
248
// If the task has been woken, add the time since wake to its stats as well.
201
249
if let Some ( since) = task. since_wake ( now) {
202
- wakeups. reserve ( 3 ) ;
203
- wakeups. push ( Span :: raw ( ", " ) ) ;
204
- wakeups. push ( bold ( "last woken: " ) ) ;
205
- wakeups. push ( styles. time_units ( since, view:: DUR_LIST_PRECISION , None ) ) ;
206
- wakeups. push ( Span :: raw ( " ago" ) ) ;
250
+ last_woken_line. reserve ( 3 ) ;
251
+ last_woken_line. push ( bold ( "Last woken: " ) ) ;
252
+ last_woken_line. push ( styles. time_units ( since, view:: DUR_LIST_PRECISION , None ) ) ;
253
+ last_woken_line. push ( Span :: raw ( " ago" ) ) ;
207
254
}
208
255
256
+ waker_stats. push ( Line :: from ( waker_stats_clones) ) ;
257
+ waker_stats. push ( Line :: from ( waker_stats_drops) ) ;
209
258
waker_stats. push ( Line :: from ( wakeups) ) ;
259
+ waker_stats. push ( Line :: from ( last_woken_line) ) ;
210
260
211
261
if task. self_wakes ( ) > 0 {
212
262
waker_stats. push ( Line :: from ( vec ! [
0 commit comments