88using System . Data ;
99using System . Diagnostics ;
1010using System . Drawing ;
11+ using System . Dynamic ;
1112using System . Linq ;
1213using System . Media ;
1314using System . Text ;
2728using Window = Terminal . Gui . Window ;
2829using System . Xml . Linq ;
2930using Kantan . Console ;
31+ using Kantan . Text ;
3032using Novus . OS ;
3133using Attribute = Terminal . Gui . Attribute ;
3234using Color = Terminal . Gui . Color ;
@@ -201,7 +203,7 @@ public GuiMode(string[] args) : base(args, SearchQuery.Null)
201203 /*
202204 * Check if clipboard contains valid query input
203205 */
204-
206+
205207 m_cbCallbackTok = Application . MainLoop . AddTimeout ( TimeoutTimeSpan , ClipboardCallback ) ;
206208
207209 m_clipboard = new List < ustring > ( ) ;
@@ -232,6 +234,7 @@ public GuiMode(string[] args) : base(args, SearchQuery.Null)
232234 new ( nameof ( SearchResultItem . Site ) , typeof ( string ) ) ,
233235 new ( nameof ( SearchResultItem . Width ) , typeof ( double ) ) ,
234236 new ( nameof ( SearchResultItem . Height ) , typeof ( double ) ) ,
237+ new ( nameof ( SearchResultItem . Metadata ) , typeof ( object ) ) ,
235238 } ;
236239
237240 Dt_Results . Columns . AddRange ( col ) ;
@@ -271,7 +274,7 @@ public GuiMode(string[] args) : base(args, SearchQuery.Null)
271274 Btn_Clear . Clicked += OnClear ;
272275 Btn_Config . Clicked += OnConfigDialog ;
273276 Btn_Cancel . Clicked += OnCancel ;
274-
277+
275278 Lbl_InputInfo . Clicked += ( ) =>
276279 {
277280 if ( ! IsQueryReady ( ) ) {
@@ -286,6 +289,7 @@ public GuiMode(string[] args) : base(args, SearchQuery.Null)
286289 }
287290
288291 } ;
292+
289293 Lbl_QueryUpload . Clicked += ( ) =>
290294 {
291295 HttpUtilities . TryOpenUrl ( Query . Upload ) ;
@@ -323,14 +327,23 @@ public override void OnResult(object o, SearchResult r)
323327 Application . MainLoop . Invoke ( ( ) =>
324328 {
325329 Dt_Results . Rows . Add ( $ "{ r . Engine . Name } (Raw)", r . RawUrl , 0 , null , null ,
326- r . Status . ToString ( ) , null , null , null , null , null ) ;
330+ r . Status . ToString ( ) , null , null , null , null , null , null ) ;
327331
328332 for ( int i = 0 ; i < r . Results . Count ; i ++ ) {
329333 SearchResultItem sri = r . Results [ i ] ;
330334
335+ object ? meta = sri . Metadata switch
336+ {
337+ string [ ] rg => rg . QuickJoin ( ) ,
338+ Array rg => rg . QuickJoin ( ) ,
339+ ICollection c => c . QuickJoin ( ) ,
340+ string s => s ,
341+ _ => null ,
342+ } ;
343+
331344 Dt_Results . Rows . Add ( $ "{ r . Engine . Name } #{ i + 1 } ",
332345 sri . Url , sri . Score , sri . Similarity , sri . Artist , sri . Description , sri . Source ,
333- sri . Title , sri . Site , sri . Width , sri . Height ) ;
346+ sri . Title , sri . Site , sri . Width , sri . Height , meta ) ;
334347 }
335348
336349 Pbr_Status . Fraction = ( float ) ++ ResultCount / ( Client . Engines . Length ) ;
@@ -429,9 +442,9 @@ private async Task<bool> SetQuery(ustring text)
429442
430443 }
431444 else {
432- Lbl_InputOk . Text = Values . Err ;
433- Lbl_InputInfo . Text = "Error: invalid input" ;
434- Btn_Run . Enabled = true ;
445+ Lbl_InputOk . Text = Values . Err ;
446+ Lbl_InputInfo . Text = "Error: invalid input" ;
447+ Btn_Run . Enabled = true ;
435448 Lbl_QueryUpload . Text = ustring . Empty ;
436449
437450 return false ;
0 commit comments