Skip to content

Commit a5d0c24

Browse files
new draw struct mem to track completion/toggle off
1 parent 031ae9a commit a5d0c24

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

vpr/src/draw/draw.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,20 @@ bool draw_if_net_highlighted(ClusterNetId inet) {
682682
void act_on_key_press(ezgl::application* app, GdkEventKey* /*event*/, char* key_name) {
683683
std::string key(key_name);
684684
GtkWidget* searchBar = GTK_WIDGET(app->get_object("TextInput"));
685+
std::string text(gtk_entry_get_text(GTK_ENTRY(searchBar)));
686+
t_draw_state* draw_state = get_draw_state_vars();
685687
if (gtk_widget_is_focus(searchBar)) {
686688
if (key == "Return") {
687-
std::string oldText(gtk_entry_get_text(GTK_ENTRY(searchBar)));
688689
enable_autocomplete(app);
689-
gtk_editable_set_position(GTK_EDITABLE(searchBar), oldText.length());
690+
gtk_editable_set_position(GTK_EDITABLE(searchBar), text.length());
691+
return;
690692
}
691693
}
694+
if (draw_state->justEnabled) {
695+
draw_state->justEnabled = false;
696+
} else {
697+
gtk_entry_set_completion(GTK_ENTRY(searchBar), nullptr);
698+
}
692699
}
693700

694701
void act_on_mouse_press(ezgl::application* app, GdkEventButton* event, double x, double y) {

vpr/src/draw/draw_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ struct t_draw_state {
217217
bool show_noc_button = false;
218218
e_draw_noc draw_noc = DRAW_NO_NOC;
219219
std::shared_ptr<const vtr::ColorMap> noc_usage_color_map = nullptr; // color map used to display noc link bandwidth usage
220+
bool justEnabled = false; //Whether auto-complete was just enabled
220221

221222
std::vector<Breakpoint> list_of_breakpoints;
222223

vpr/src/draw/search_bar.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ t_pb* find_atom_block_in_pb(std::string name, t_pb* pb) {
369369
}
370370

371371
void highlight_nets(ClusterNetId net_id) {
372-
t_trace* tptr;
373372
auto& route_ctx = g_vpr_ctx.routing();
374373

375374
t_draw_state* draw_state = get_draw_state_vars();
@@ -524,12 +523,13 @@ GdkEvent simulate_keypress(char key, GdkWindow* window) {
524523
* NET SRCH. 4.93438e+06
525524
* BLOCKS 572148
526525
* 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
526+
* Obviously much slower w. more nets/blocks. However, it only performs a single search after each enter key press, pretty bearable considering its searching in strings
528527
* @param app ezgl app
529528
*/
530529
void enable_autocomplete(ezgl::application* app) {
531530
GtkEntryCompletion* completion = GTK_ENTRY_COMPLETION(app->get_object("Completion"));
532531
GtkEntry* searchBar = GTK_ENTRY(app->get_object("TextInput"));
532+
auto draw_state = get_draw_state_vars();
533533

534534
std::string searchType = get_search_type(app);
535535
if (searchType == "")
@@ -550,6 +550,8 @@ void enable_autocomplete(ezgl::application* app) {
550550
//Setting min key length to either 0 or 1 less than key length (max option)
551551
gtk_entry_completion_set_minimum_key_length(completion, std::max(0, (int)(oldText.length() - 1)));
552552

553+
draw_state->justEnabled = true;
554+
553555
//If string len is 0, reutrning
554556
if (oldText.length() == 0) return;
555557

0 commit comments

Comments
 (0)