diff options
author | Daniel Burrows <Daniel_Burrows@alumni.brown.edu> | 2006-10-04 03:13:02 +0000 |
---|---|---|
committer | Daniel Burrows <Daniel_Burrows@alumni.brown.edu> | 2006-10-04 03:13:02 +0000 |
commit | 993cee01fb234873352553fb1b9be0ffbc887870 (patch) | |
tree | da218ff5cfd146fd2992f59ed68ff7c2658a8996 | |
parent | 887cdcc2232302e54656e3ebebd76c2f198d20d5 (diff) | |
download | aptitude-993cee01fb234873352553fb1b9be0ffbc887870.tar.gz |
[aptitude @ Add a hack to force the post-search selection to be at the top of the screen, so it's visible under the search dialog. (Closes: #389763)]
-rw-r--r-- | src/vscreen/vs_tree.cc | 8 | ||||
-rw-r--r-- | src/vscreen/vs_tree.h | 11 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/vscreen/vs_tree.cc b/src/vscreen/vs_tree.cc index ee50973d..5447733f 100644 --- a/src/vscreen/vs_tree.cc +++ b/src/vscreen/vs_tree.cc @@ -1,6 +1,6 @@ // vs_tree.cc // -// Copyright 1999-2002, 2004-2005 Daniel Burrows +// Copyright 1999-2002, 2004-2006 Daniel Burrows // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -218,7 +218,7 @@ bool vs_tree::item_visible(vs_treeiterator pkg) return height>0 && i!=end; } -void vs_tree::set_selection(vs_treeiterator to) +void vs_tree::set_selection(vs_treeiterator to, bool force_to_top) { // Expand all its parents so that it's possible to make it visible. vs_treeiterator curr = to; @@ -266,7 +266,7 @@ void vs_tree::set_selection(vs_treeiterator to) ++l; } - while(l > height) + while(l > (force_to_top ? 1 : height)) { eassert(top != end); @@ -799,7 +799,7 @@ void vs_tree::search_for(vs_tree_search_func &matches) beep(); else { - set_selection(curr); + set_selection(curr, true); vscreen_update(); } } diff --git a/src/vscreen/vs_tree.h b/src/vscreen/vs_tree.h index c53e91c8..23708ca3 100644 --- a/src/vscreen/vs_tree.h +++ b/src/vscreen/vs_tree.h @@ -147,7 +147,16 @@ public: virtual void paint(const style &st); virtual void dispatch_mouse(short id, int x, int y, int z, mmask_t bstate); - void set_selection(vs_treeiterator to); + /** \brief Directly sets the selection to the given element. + * + * \param to The element to select. + * \param force_to_top If true, the element will be placed at the + * top of the list if the list scrolls. + * + * If the element's parents are not currently expanded, they will + * be immediately expanded. + */ + void set_selection(vs_treeiterator to, bool force_to_top = false); // Directly sets the selection to a given item. [ the item must be // visible -- ie, all its parents must be expanded ] // Causes a redraw. |