@@ -75,6 +75,8 @@ void search_and_highlight(GtkWidget* /*widget*/, ezgl::application* app) {
75
75
std::stringstream ss (user_input);
76
76
77
77
auto search_type = get_search_type (app);
78
+ if (search_type == " " )
79
+ return ;
78
80
79
81
// reset
80
82
deselect_all ();
@@ -121,22 +123,22 @@ void search_and_highlight(GtkWidget* /*widget*/, ezgl::application* app) {
121
123
122
124
AtomBlockId atom_blk_id = atom_ctx.nlist .find_block (block_name);
123
125
if (atom_blk_id != AtomBlockId::INVALID ()) {
124
- ClusterBlockId block_id = atom_ctx.lookup .atom_clb (atom_blk_id);
125
- if (!highlight_atom_block (atom_blk_id, block_id , app)) {
126
- highlight_cluster_block (block_id );
126
+ ClusterBlockId cluster_block_id = atom_ctx.lookup .atom_clb (atom_blk_id);
127
+ if (!highlight_atom_block (atom_blk_id, cluster_block_id , app)) {
128
+ highlight_cluster_block (cluster_block_id );
127
129
}
128
130
return ;
129
131
}
130
132
131
133
// Continues if atom block not found (Checking if user searched a clb)
132
- ClusterBlockId block_id = ClusterBlockId::INVALID ();
133
- block_id = cluster_ctx.clb_nlist .find_block (block_name);
134
+ ClusterBlockId cluster_block_id = ClusterBlockId::INVALID ();
135
+ cluster_block_id = cluster_ctx.clb_nlist .find_block (block_name);
134
136
135
- if (block_id == ClusterBlockId::INVALID ()) {
137
+ if (cluster_block_id == ClusterBlockId::INVALID ()) {
136
138
warning_dialog_box (" Invalid Block Name" );
137
139
return ; // name not exist
138
140
}
139
- highlight_cluster_block (block_id ); // found block
141
+ highlight_cluster_block (cluster_block_id ); // found block
140
142
}
141
143
142
144
else if (search_type == " Net ID" ) {
@@ -340,10 +342,11 @@ bool highlight_atom_block(AtomBlockId atom_blk, ClusterBlockId cl_blk, ezgl::app
340
342
t_pb* find_atom_block_in_pb (std::string name, t_pb* pb) {
341
343
// Checking if block is one being searched for
342
344
std::string pbName (pb->name );
343
- if (pbName == name) return pb;
345
+ if (pbName == name)
346
+ return pb;
344
347
// If block has no children, returning
345
- if (pb->child_pbs == nullptr ) return nullptr ;
346
-
348
+ if (pb->child_pbs == nullptr )
349
+ return nullptr ;
347
350
int num_child_types = pb->get_num_child_types ();
348
351
// Iterating through all child types
349
352
for (int i = 0 ; i < num_child_types; ++i) {
@@ -373,10 +376,7 @@ void highlight_nets(ClusterNetId net_id) {
373
376
374
377
// If routing does not exist return
375
378
if (int (route_ctx.trace .size ()) == 0 ) return ;
376
-
377
- for (tptr = route_ctx.trace [net_id].head ; tptr != nullptr ; tptr = tptr->next ) {
378
- draw_state->net_color [net_id] = ezgl::MAGENTA;
379
- }
379
+ draw_state->net_color [net_id] = ezgl::MAGENTA;
380
380
}
381
381
382
382
void warning_dialog_box (const char * message) {
@@ -445,13 +445,14 @@ void search_type_changed(GtkComboBox* self, ezgl::application* app) {
445
445
446
446
/* *
447
447
* @brief A non-default matching function. As opposed to simply searching for a prefix(default),
448
- * searches string for presence of a substring. Ignores cases.
448
+ * searches string for presence of a substring. Case-insensitive
449
449
*
450
450
* @param completer the GtkEntryCompletion being used
451
451
* @param key a normalized and case-folded key representing the text
452
452
* @param iter GtkTreeIter pointing at the current entry being compared
453
453
* @param user_data null
454
- * @return gboolean
454
+ * @return true | if the string pointed to by iter contains key (case-insensitive)
455
+ * @return false | if the string pointed to does not contain key
455
456
*/
456
457
gboolean customMatchingFunction (
457
458
GtkEntryCompletion* completer,
@@ -471,7 +472,8 @@ gboolean customMatchingFunction(
471
472
}
472
473
473
474
/* *
474
- * @brief Creates a GdkEvent that simulates user pressing key "key"
475
+ * @brief Creates a GdkEvent that simulates user pressing key "key".
476
+ * Currently used to fool GtkEntryCompletion into showing options w/o receiving a new input
475
477
*
476
478
* @param key character value
477
479
* @param window GdkWindow
@@ -502,13 +504,36 @@ GdkEvent simulate_keypress(char key, GdkWindow* window) {
502
504
* as the user hits the "Enter" key. To accomplish this, a fake Gdk event is created
503
505
* to simulate the user hitting a key.
504
506
*
507
+ * This was done for usability reasons; if this is not done, user will need to input another key before seeing
508
+ * autocomplete results. Considering the enter is supposed to be a search, we want to search for the users
509
+ * key, not the key + another char
510
+ *
511
+ * PERFORMANCE DATA
512
+ * Correlation between key length and time is shaky; there might be some correlation to
513
+ * how many strings are similar to it. All tests are performed with the key "1" - pretty common
514
+ * Tests are searched three times then average
515
+ * MODEL 1: EARCH + TSENG.BLIF
516
+ * NETS 1483
517
+ * NET SRCH. 19392
518
+ * BLOCKS 1835
519
+ * BLOCK SRCH. 21840
520
+ * For second model (much larger, much longer CPU times) observed large dropoff in times from one char to two chars (about 2 times faster) but after stayed consistent
521
+ * Maybe when I ahve more time, will make a cute graph or something, no time right now
522
+ * MODEL 2: Strativix arch + MES_NOC (TITAN)
523
+ * NETS 577696
524
+ * NET SRCH. 4.93438e+06
525
+ * BLOCKS 572148
526
+ * BLOCKS SRCH. 4.8654e+06
527
+ * Obviously much slower w. more nets/blocks. However, it only performs a single search, pretty bearable considering its searching in strings
505
528
* @param app ezgl app
506
529
*/
507
530
void enable_autocomplete (ezgl::application* app) {
508
531
GtkEntryCompletion* completion = GTK_ENTRY_COMPLETION (app->get_object (" Completion" ));
509
532
GtkEntry* searchBar = GTK_ENTRY (app->get_object (" TextInput" ));
510
533
511
534
std::string searchType = get_search_type (app);
535
+ if (searchType == " " )
536
+ return ;
512
537
// Checking to make sure that we are on a mode that uses auto-complete
513
538
if (gtk_entry_completion_get_model (completion) == NULL ) {
514
539
std::cout << " NO MODEL SELECTED" << std::endl;
@@ -538,14 +563,15 @@ void enable_autocomplete(ezgl::application* app) {
538
563
gdk_event_put (&new_event);
539
564
}
540
565
566
+ // Returns current search type. Returns empty string if fails
541
567
std::string get_search_type (ezgl::application* app) {
542
568
GObject* combo_box = (GObject*)app->get_object (" SearchType" );
543
569
gchar* type = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo_box));
544
570
// Checking that a type is selected
545
- if (type && type[0 ] == ' \0 ' ) {
571
+ if (! type || (type && type[0 ] == ' \0 ' ) ) {
546
572
warning_dialog_box (" Please select a search type" );
547
573
app->refresh_drawing ();
548
- return " Failed lol " ;
574
+ return " " ;
549
575
}
550
576
std::string searchType (type);
551
577
return searchType;
0 commit comments