@@ -39,15 +39,42 @@ public sealed partial class ShellMode
3939 private const int COL_STATUS = 1 ;
4040 private const int COL_METADATA = 12 ;
4141
42+ private static readonly Color [ ] ColorValues = Enum . GetValues < Color > ( ) ;
43+
4244 private static readonly ConcurrentDictionary < object , string > Downloaded = new ( ) ;
4345
44- private static readonly Dictionary < BaseSearchEngine , ColorScheme > Colors = new ( )
45- { } ;
46+ private static ConcurrentDictionary < BaseSearchEngine , ColorScheme > EngineColors = new ( ) ;
47+
48+ private static ConcurrentDictionary < int , ColorScheme > IndexColors = new ( ) ;
49+
50+ private static ColorScheme GetColor ( BaseSearchEngine baseSearchEngine )
51+ {
52+ if ( EngineColors . TryGetValue ( baseSearchEngine , out var cs ) ) {
53+ return cs ;
54+
55+ }
56+ else {
57+ var cc = ColorValues [
58+ Array . IndexOf ( UI . EngineOptions , baseSearchEngine . EngineOption ) % UI . EngineOptions . Length ] ;
59+
60+ cs = new ColorScheme ( )
61+ {
62+ Normal = Attribute . Make ( cc , Color . Black ) ,
63+ Focus = Attribute . Make ( Color . White , cc ) ,
64+
65+ } ;
66+ cs = cs . NormalizeHot ( ) ;
67+ EngineColors . TryAdd ( baseSearchEngine , cs ) ;
68+
69+ }
70+
71+ return cs ;
72+ }
4673
4774 private async Task < bool > Input_TextChanging ( TextChangingEventArgs tc )
4875 {
4976
50- var text = tc . NewText . ToString ( ) . TrimStart ( '\" ' ) ;
77+ var text = tc . NewText ? . ToString ( ) ? . TrimStart ( '\" ' ) ;
5178
5279 // Debug.WriteLine($"testing {text}", nameof(Input_TextChanging));
5380
@@ -246,7 +273,7 @@ private static void Clear_Clicked()
246273 // Btn_Run.Enabled = false;
247274 Tf_Input . SetFocus ( ) ;
248275 Btn_Delete . Enabled = false ;
249-
276+ IndexColors . Clear ( ) ;
250277 }
251278
252279 private void Cancel_Clicked ( )
@@ -365,7 +392,10 @@ private void ResultTable_CellActivated(TableView.CellActivatedEventArgs args)
365392
366393 private ColorScheme ? ResultTable_RowColor ( TableView . RowColorGetterArgs r )
367394 {
368- // var eng=args.Table.Rows[args.RowIndex]["Engine"];
395+ // var ar = r.Table.Rows[r.RowIndex];
396+ return IndexColors [ r . RowIndex ] ;
397+
398+ /*// var eng=args.Table.Rows[args.RowIndex]["Engine"];
369399
370400 ColorScheme? cs = null;
371401
@@ -377,44 +407,24 @@ private void ResultTable_CellActivated(TableView.CellActivatedEventArgs args)
377407 goto ret;
378408 }
379409
380- var eng2 = Client . Engines . FirstOrDefault ( f => eng . ToString ( ) . Contains ( f . Name ) ) ;
410+ // var eng2 = Client.Engines.FirstOrDefault(f => eng.ToString().Contains(f.Name));
381411
382- if ( eng2 == null ) {
383- goto ret ;
384- }
385-
386- if ( ! Colors . ContainsKey ( eng2 ) ) {
387- var colors = Enum . GetValues < Color > ( ) ;
412+ BaseSearchEngine? eng2 = null;
388413
389- var cc = colors [ Array . IndexOf ( UI . EngineOptions , eng2 . EngineOption ) % UI . EngineOptions . Length ] ;
390-
391- Color cc2 ;
392-
393- switch ( cc ) {
394- case Color . Cyan :
395- cc2 = Color . BrightCyan ;
396- break ;
397- default :
398- cc2 = cc ;
399- break ;
414+ foreach (BaseSearchEngine csx in Client.Engines) {
415+ if (eng.ToString().Contains(csx.Name)) {
416+ eng2 = csx;
417+ break;
400418 }
401-
402- cs = new ColorScheme ( )
403- {
404- Normal = Attribute . Make ( cc , Color . Black ) ,
405- Focus = Attribute . Make ( cc2 , Color . DarkGray ) ,
406-
407- } ;
408- cs = cs . NormalizeHot ( ) ;
409-
410- Colors . Add ( eng2 , cs ) ;
411419 }
412- else {
413- cs = Colors [ eng2 ] ;
420+
421+ if (eng2 == null) {
422+ goto ret;
414423 }
415424
425+ cs = Colors[eng2];
416426 ret:
417- return cs ;
427+ return cs;*/
418428 }
419429
420430 private async void ResultTable_KeyPress ( View . KeyEventEventArgs eventArgs )
@@ -540,9 +550,10 @@ private async void ResultTable_KeyPress(View.KeyEventEventArgs eventArgs)
540550 case Key . X :
541551 //TODO: WIP
542552 break ;
553+ default :
554+ eventArgs . Handled = false ;
555+ break ;
543556 }
544-
545- // eventArgs.Handled = false;
546557 }
547558
548559#if ALT
0 commit comments