@@ -3,8 +3,9 @@ use crate::{
33 cmdbar:: CommandBar ,
44 components:: {
55 event_pump, CommandBlocking , CommandInfo , CommitComponent ,
6- Component , DrawableComponent , HelpComponent , MsgComponent ,
7- ResetComponent , StashMsgComponent ,
6+ Component , DrawableComponent , HelpComponent ,
7+ InspectCommitComponent , MsgComponent , ResetComponent ,
8+ StashMsgComponent ,
89 } ,
910 keys,
1011 queue:: { Action , InternalEvent , NeedsUpdate , Queue } ,
@@ -33,6 +34,7 @@ pub struct App {
3334 reset : ResetComponent ,
3435 commit : CommitComponent ,
3536 stashmsg_popup : StashMsgComponent ,
37+ inspect_commit_popup : InspectCommitComponent ,
3638 cmdbar : CommandBar ,
3739 tab : usize ,
3840 revlog : Revlog ,
@@ -58,12 +60,15 @@ impl App {
5860 queue. clone ( ) ,
5961 & theme,
6062 ) ,
63+ inspect_commit_popup : InspectCommitComponent :: new (
64+ & queue, sender, & theme,
65+ ) ,
6166 do_quit : false ,
6267 cmdbar : CommandBar :: new ( & theme) ,
6368 help : HelpComponent :: new ( & theme) ,
6469 msg : MsgComponent :: new ( & theme) ,
6570 tab : 0 ,
66- revlog : Revlog :: new ( sender, & theme) ,
71+ revlog : Revlog :: new ( & queue , sender, & theme) ,
6772 status_tab : Status :: new ( sender, & queue, & theme) ,
6873 stashing_tab : Stashing :: new ( sender, & queue, & theme) ,
6974 stashlist_tab : StashList :: new ( & queue, & theme) ,
@@ -159,8 +164,11 @@ impl App {
159164 if flags. contains ( NeedsUpdate :: ALL ) {
160165 self . update ( ) ?;
161166 }
167+ //TODO: make this a queue event?
168+ //NOTE: set when any tree component changed selection
162169 if flags. contains ( NeedsUpdate :: DIFF ) {
163170 self . status_tab . update_diff ( ) ?;
171+ self . inspect_commit_popup . update_diff ( ) ?;
164172 }
165173 if flags. contains ( NeedsUpdate :: COMMANDS ) {
166174 self . update_commands ( ) ;
@@ -191,6 +199,7 @@ impl App {
191199 self . status_tab . update_git ( ev) ?;
192200 self . stashing_tab . update_git ( ev) ?;
193201 self . revlog . update_git ( ev) ?;
202+ self . inspect_commit_popup . update_git ( ev) ?;
194203
195204 if let AsyncNotification :: Status = ev {
196205 //TODO: is that needed?
@@ -210,6 +219,7 @@ impl App {
210219 self . status_tab . anything_pending ( )
211220 || self . revlog . any_work_pending ( )
212221 || self . stashing_tab . anything_pending ( )
222+ || self . inspect_commit_popup . any_work_pending ( )
213223 }
214224}
215225
@@ -222,6 +232,7 @@ impl App {
222232 reset,
223233 commit,
224234 stashmsg_popup,
235+ inspect_commit_popup,
225236 help,
226237 revlog,
227238 status_tab,
@@ -356,6 +367,10 @@ impl App {
356367 self . stashmsg_popup . show ( ) ?
357368 }
358369 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+ }
359374 } ;
360375
361376 Ok ( flags)
@@ -407,19 +422,31 @@ impl App {
407422 || self . help . is_visible ( )
408423 || self . reset . is_visible ( )
409424 || self . msg . is_visible ( )
425+ || self . stashmsg_popup . is_visible ( )
426+ || self . inspect_commit_popup . is_visible ( )
410427 }
411428
412429 fn draw_popups < B : Backend > (
413430 & mut self ,
414431 f : & mut Frame < B > ,
415432 ) -> 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 ] ;
417443
418444 self . commit . draw ( f, size) ?;
419445 self . stashmsg_popup . draw ( f, size) ?;
420446 self . reset . draw ( f, size) ?;
421447 self . help . draw ( f, size) ?;
422448 self . msg . draw ( f, size) ?;
449+ self . inspect_commit_popup . draw ( f, size) ?;
423450
424451 Ok ( ( ) )
425452 }
0 commit comments