3333using Attribute = Terminal . Gui . Attribute ;
3434using Color = Terminal . Gui . Color ;
3535using SmartImage . UI ;
36+ using Size = Terminal . Gui . Size ;
3637
3738// ReSharper disable InconsistentNaming
3839
@@ -207,15 +208,10 @@ public GuiMode(string[] args) : base(args, SearchQuery.Null)
207208 m_cbCallbackTok = Application . MainLoop . AddTimeout ( TimeoutTimeSpan , ClipboardCallback ) ;
208209
209210 m_clipboard = new List < ustring > ( ) ;
210-
211- /*m_tok = Application.MainLoop.AddIdle(() =>
212- {
213- return ClipboardCallback(null);
214- });*/
215-
211+
216212 Mb_Menu . Menus = new MenuBarItem [ ]
217213 {
218- // new("_Config ", null, ConfigDialog ),
214+ new ( "_About " , null , AboutDialog ) ,
219215 } ;
220216
221217 Top . Add ( Mb_Menu ) ;
@@ -454,8 +450,7 @@ private async Task<bool> SetQuery(ustring text)
454450
455451 Lbl_InputOk . Text = Values . OK ;
456452
457- Query = sq ;
458- // QueryMat = Mat.FromImageData(Query.Stream.ToByteArray()); // todo: advances stream position?
453+ Query = sq ;
459454 Status = ProgramStatus . Signal ;
460455
461456 Lbl_InputInfo . Text = $ "[{ ( sq . IsFile ? "File" : "Uri" ) } ] ({ sq . FileTypes . First ( ) } )";
@@ -474,7 +469,8 @@ private bool ClipboardCallback(MainLoop c)
474469 * - Input is already semiprimed
475470 * - Clipboard history contains it already
476471 */
477- if ( Integration . ReadClipboard ( out var str ) && ! IsInputValidIndicator ( ) && ! m_clipboard . Contains ( str ) ) {
472+ if ( Integration . ReadClipboard ( out var str ) &&
473+ ! IsInputValidIndicator ( ) && ! m_clipboard . Contains ( str ) ) {
478474 SetInputText ( str ) ;
479475 // Lbl_InputOk.Text = Values.Clp;
480476 Lbl_InputInfo . Text = $ "Clipboard data";
@@ -502,13 +498,56 @@ private void OnClear()
502498 Tf_Input . DeleteAll ( ) ;
503499 Lbl_InputOk . Text = Values . NA ;
504500 Lbl_InputOk . SetNeedsDisplay ( ) ;
505- Lbl_InputInfo . Text = ustring . Empty ;
501+ Lbl_InputInfo . Text = ustring . Empty ;
506502 Lbl_InputInfo2 . Text = ustring . Empty ;
507503 }
508504
505+ private void AboutDialog ( )
506+ {
507+ var d = new Dialog ( )
508+ {
509+ Text = $ "{ R2 . Name } ",
510+ Title = R2 . Name ,
511+ AutoSize = true ,
512+ Width = Dim . Percent ( 30 ) ,
513+ Height = Dim . Percent ( 30 ) ,
514+ } ;
515+
516+ void RefreshDialog ( )
517+ {
518+ d . SetNeedsDisplay ( ) ;
519+ }
520+
521+ var b1 = new Button ( ) { AutoSize = true , Text = $ "Repo", } ;
522+
523+ b1 . Clicked += ( ) =>
524+ {
525+ HttpUtilities . TryOpenUrl ( R2 . Repo_Url ) ;
526+ RefreshDialog ( ) ;
527+ } ;
528+
529+ var b2 = new Button ( ) { AutoSize = true , Text = $ "Wiki", } ;
530+
531+ b2 . Clicked += ( ) =>
532+ {
533+ HttpUtilities . TryOpenUrl ( R2 . Wiki_Url ) ;
534+ RefreshDialog ( ) ;
535+ } ;
536+
537+ var b3 = new Button ( ) { Text = $ "Ok", AutoSize = true , } ;
538+
539+ b3 . Clicked += ( ) => { Application . RequestStop ( ) ; } ;
540+
541+ d . AddButton ( b1 ) ;
542+ d . AddButton ( b2 ) ;
543+ d . AddButton ( b3 ) ;
544+
545+ Application . Run ( d ) ;
546+ }
547+
509548 private void OnConfigDialog ( )
510549 {
511- var about = new Dialog ( "Configuration" )
550+ var dlCfg = new Dialog ( "Configuration" )
512551 {
513552 Text = ustring . Empty ,
514553 AutoSize = false ,
@@ -523,13 +562,31 @@ private void OnConfigDialog()
523562 const int WIDTH = 15 ;
524563 const int HEIGHT = 20 ;
525564
565+ Label lbSearchEngines = new ( R1 . S_SearchEngines )
566+ {
567+ X = 0 ,
568+ Y = 0 ,
569+ AutoSize = true ,
570+ ColorScheme = Styles . Cs_Lbl1
571+ } ;
572+
526573 ListView lvSearchEngines = new ( ConsoleUtil . EngineOptions )
527574 {
528575 AllowsMultipleSelection = true ,
529576 AllowsMarking = true ,
530577 AutoSize = true ,
531578 Width = WIDTH ,
532579 Height = HEIGHT ,
580+
581+ Y = Pos . Bottom ( lbSearchEngines )
582+ } ;
583+
584+ Label lbPriorityEngines = new ( R1 . S_PriorityEngines )
585+ {
586+ X = Pos . Right ( lbSearchEngines ) + 1 ,
587+ Y = 0 ,
588+ AutoSize = true ,
589+ ColorScheme = Styles . Cs_Lbl1
533590 } ;
534591
535592 ListView lvPriorityEngines = new ( ConsoleUtil . EngineOptions )
@@ -539,13 +596,15 @@ private void OnConfigDialog()
539596 AutoSize = true ,
540597 Width = WIDTH ,
541598 Height = HEIGHT ,
542- X = Pos . Right ( lvSearchEngines )
599+
600+ Y = Pos . Bottom ( lbPriorityEngines ) ,
601+ X = Pos . Right ( lvSearchEngines ) + 1
543602 } ;
544603
545604 CheckBox cbContextMenu = new ( R2 . Int_ContextMenu )
546605 {
547606 Y = Pos . Bottom ( lvSearchEngines ) ,
548- Width = 15 ,
607+ Width = WIDTH ,
549608 Height = 1 ,
550609 } ;
551610
@@ -558,16 +617,35 @@ private void OnConfigDialog()
558617 {
559618 X = Pos . Right ( cbContextMenu ) ,
560619 Y = Pos . Bottom ( lvPriorityEngines ) ,
561- Width = 15 ,
620+ Width = WIDTH ,
562621 Height = 1 ,
563622 } ;
564623
624+ var cfgInfo = new FileInfo ( SearchConfig . Configuration . FilePath ) ;
625+
626+ ustring s = $ "Config";
627+
628+ Label lbConfig = new ( s )
629+ {
630+ X = Pos . Right ( lbPriorityEngines ) + 1 ,
631+ Y = 0 ,
632+ AutoSize = true ,
633+ ColorScheme = Styles . Cs_Lbl1
634+ // Height = 10,
635+ } ;
636+
565637 var tvConfig = new TableView ( dtConfig )
566638 {
567639 AutoSize = true ,
568- X = Pos . Right ( lvPriorityEngines ) ,
640+ Y = Pos . Bottom ( lbConfig ) ,
641+ X = Pos . Right ( lvPriorityEngines ) + 1 ,
569642 Width = Dim . Fill ( WIDTH ) ,
570- Height = 10 ,
643+ Height = 7 ,
644+ } ;
645+
646+ lbConfig . Clicked += ( ) =>
647+ {
648+ FileSystem . ExploreFile ( cfgInfo . FullName ) ;
571649 } ;
572650
573651 cbOnTop . Toggled += b =>
@@ -599,7 +677,7 @@ void ReloadDialog()
599677 {
600678 tvConfig . Table = Config . ToTable ( ) ;
601679 tvConfig . SetNeedsDisplay ( ) ;
602- about . SetNeedsDisplay ( ) ;
680+ dlCfg . SetNeedsDisplay ( ) ;
603681 }
604682
605683 lvSearchEngines . FromEnum ( Config . SearchEngines ) ;
@@ -620,14 +698,14 @@ void ReloadDialog()
620698 ReloadDialog ( ) ;
621699 } ;
622700
623- about . Add ( tvConfig , lvSearchEngines , lvPriorityEngines ,
624- cbContextMenu , cbOnTop ) ;
701+ dlCfg . Add ( tvConfig , lvSearchEngines , lvPriorityEngines ,
702+ cbContextMenu , cbOnTop , lbConfig , lbSearchEngines , lbPriorityEngines ) ;
625703
626- about . AddButton ( btnRefresh ) ;
627- about . AddButton ( btnOk ) ;
628- about . AddButton ( btnSave ) ;
704+ dlCfg . AddButton ( btnRefresh ) ;
705+ dlCfg . AddButton ( btnOk ) ;
706+ dlCfg . AddButton ( btnSave ) ;
629707
630- Application . Run ( about ) ;
708+ Application . Run ( dlCfg ) ;
631709
632710 Tf_Input . SetFocus ( ) ;
633711 Tf_Input . EnsureFocus ( ) ;
@@ -639,7 +717,7 @@ private void ClearControls()
639717 Tf_Input . ClearHistoryChanges ( ) ;
640718
641719 Query = SearchQuery . Null ;
642-
720+
643721 Lbl_InputOk . Text = Values . NA ;
644722 Lbl_InputOk . SetNeedsDisplay ( ) ;
645723
@@ -658,16 +736,6 @@ private void ClearControls()
658736 Tf_Input . SetFocus ( ) ;
659737 Tf_Input . EnsureFocus ( ) ;
660738 Btn_Cancel . Enabled = false ;
661-
662- /*Application.MainLoop.Invoke(() =>
663- { });*/
664-
665- /*try {
666- // Application.Refresh();
667- }
668- catch (Exception e) {
669- Debug.WriteLine($"{e.Message}", nameof(ClearControls));
670- }*/
671739 }
672740
673741 private void OnRestart ( )
@@ -681,22 +749,20 @@ private void OnRestart()
681749 Tv_Results . RowOffset = 0 ;
682750 Tv_Results . ColumnOffset = 0 ;
683751 Dt_Results . Clear ( ) ;
752+ Tv_Results . Visible = false ;
684753
685754 m_clipboard . Clear ( ) ;
686755
687756 Status = ProgramStatus . Restart ;
688757 Btn_Restart . Enabled = false ;
689- Btn_Cancel . Enabled = false ;
758+ Btn_Cancel . Enabled = false ;
690759 Btn_Run . Enabled = true ;
691760
692761 Token . Dispose ( ) ;
693762 Token = new ( ) ;
694763
695764 Tf_Input . SetFocus ( ) ;
696765 Tf_Input . EnsureFocus ( ) ;
697-
698- /*Application.MainLoop.Invoke(() =>
699- { });*/
700766 }
701767
702768 private void OnCellActivated ( TableView . CellActivatedEventArgs args )
@@ -757,11 +823,14 @@ private async void OnRun()
757823 {
758824 Btn_Run . Enabled = false ;
759825 Btn_Cancel . Enabled = true ;
826+ Tv_Results . Visible = true ;
760827 var text = Tf_Input . Text ;
761828
762- Debug . WriteLine ( $ "{ text } ", nameof ( OnRun ) ) ;
829+ Debug . WriteLine ( $ "Input: { text } ", nameof ( OnRun ) ) ;
830+
763831 var ok = await SetQuery ( text ) ;
764832 Btn_Cancel . Enabled = ok ;
833+
765834 if ( ! ok ) {
766835 return ;
767836 }
0 commit comments