@@ -3,8 +3,9 @@ use crate::{
3
3
cmdbar:: CommandBar ,
4
4
components:: {
5
5
event_pump, CommandBlocking , CommandInfo , CommitComponent ,
6
- Component , DrawableComponent , HelpComponent , MsgComponent ,
7
- ResetComponent , StashMsgComponent ,
6
+ Component , DrawableComponent , HelpComponent ,
7
+ InspectCommitComponent , MsgComponent , ResetComponent ,
8
+ StashMsgComponent ,
8
9
} ,
9
10
keys,
10
11
queue:: { Action , InternalEvent , NeedsUpdate , Queue } ,
@@ -33,6 +34,7 @@ pub struct App {
33
34
reset : ResetComponent ,
34
35
commit : CommitComponent ,
35
36
stashmsg_popup : StashMsgComponent ,
37
+ inspect_commit_popup : InspectCommitComponent ,
36
38
cmdbar : CommandBar ,
37
39
tab : usize ,
38
40
revlog : Revlog ,
@@ -58,12 +60,15 @@ impl App {
58
60
queue. clone ( ) ,
59
61
& theme,
60
62
) ,
63
+ inspect_commit_popup : InspectCommitComponent :: new (
64
+ & queue, sender, & theme,
65
+ ) ,
61
66
do_quit : false ,
62
67
cmdbar : CommandBar :: new ( & theme) ,
63
68
help : HelpComponent :: new ( & theme) ,
64
69
msg : MsgComponent :: new ( & theme) ,
65
70
tab : 0 ,
66
- revlog : Revlog :: new ( sender, & theme) ,
71
+ revlog : Revlog :: new ( & queue , sender, & theme) ,
67
72
status_tab : Status :: new ( sender, & queue, & theme) ,
68
73
stashing_tab : Stashing :: new ( sender, & queue, & theme) ,
69
74
stashlist_tab : StashList :: new ( & queue, & theme) ,
@@ -159,8 +164,11 @@ impl App {
159
164
if flags. contains ( NeedsUpdate :: ALL ) {
160
165
self . update ( ) ?;
161
166
}
167
+ //TODO: make this a queue event?
168
+ //NOTE: set when any tree component changed selection
162
169
if flags. contains ( NeedsUpdate :: DIFF ) {
163
170
self . status_tab . update_diff ( ) ?;
171
+ self . inspect_commit_popup . update_diff ( ) ?;
164
172
}
165
173
if flags. contains ( NeedsUpdate :: COMMANDS ) {
166
174
self . update_commands ( ) ;
@@ -191,6 +199,7 @@ impl App {
191
199
self . status_tab . update_git ( ev) ?;
192
200
self . stashing_tab . update_git ( ev) ?;
193
201
self . revlog . update_git ( ev) ?;
202
+ self . inspect_commit_popup . update_git ( ev) ?;
194
203
195
204
if let AsyncNotification :: Status = ev {
196
205
//TODO: is that needed?
@@ -210,6 +219,7 @@ impl App {
210
219
self . status_tab . anything_pending ( )
211
220
|| self . revlog . any_work_pending ( )
212
221
|| self . stashing_tab . anything_pending ( )
222
+ || self . inspect_commit_popup . any_work_pending ( )
213
223
}
214
224
}
215
225
@@ -222,6 +232,7 @@ impl App {
222
232
reset,
223
233
commit,
224
234
stashmsg_popup,
235
+ inspect_commit_popup,
225
236
help,
226
237
revlog,
227
238
status_tab,
@@ -356,6 +367,10 @@ impl App {
356
367
self . stashmsg_popup . show ( ) ?
357
368
}
358
369
InternalEvent :: TabSwitch => self . set_tab ( 0 ) ?,
370
+ InternalEvent :: InspectCommit ( id) => {
371
+ self . inspect_commit_popup . open ( id) ?;
372
+ flags. insert ( NeedsUpdate :: ALL | NeedsUpdate :: COMMANDS )
373
+ }
359
374
} ;
360
375
361
376
Ok ( flags)
@@ -407,19 +422,31 @@ impl App {
407
422
|| self . help . is_visible ( )
408
423
|| self . reset . is_visible ( )
409
424
|| self . msg . is_visible ( )
425
+ || self . stashmsg_popup . is_visible ( )
426
+ || self . inspect_commit_popup . is_visible ( )
410
427
}
411
428
412
429
fn draw_popups < B : Backend > (
413
430
& mut self ,
414
431
f : & mut Frame < B > ,
415
432
) -> Result < ( ) > {
416
- let size = f. size ( ) ;
433
+ let size = Layout :: default ( )
434
+ . direction ( Direction :: Vertical )
435
+ . constraints (
436
+ [
437
+ Constraint :: Min ( 1 ) ,
438
+ Constraint :: Length ( self . cmdbar . height ( ) ) ,
439
+ ]
440
+ . as_ref ( ) ,
441
+ )
442
+ . split ( f. size ( ) ) [ 0 ] ;
417
443
418
444
self . commit . draw ( f, size) ?;
419
445
self . stashmsg_popup . draw ( f, size) ?;
420
446
self . reset . draw ( f, size) ?;
421
447
self . help . draw ( f, size) ?;
422
448
self . msg . draw ( f, size) ?;
449
+ self . inspect_commit_popup . draw ( f, size) ?;
423
450
424
451
Ok ( ( ) )
425
452
}
0 commit comments