diff --git a/src/aaddressbar.cc b/src/aaddressbar.cc index 397c51ef2..3b746721d 100644 --- a/src/aaddressbar.cc +++ b/src/aaddressbar.cc @@ -36,12 +36,12 @@ bool AddressBar::handleKey(const XKeyEvent &key) { else if (k == XK_Up || (k == XK_KP_Up && !(key.state & xapp->NumLockMask))) { - return changeLocation(location - 1); + return changeLocation(location - 1), true; } else if (k == XK_Down || (k == XK_KP_Down && !(key.state & xapp->NumLockMask))) { - return changeLocation(location + 1); + return changeLocation(location + 1), true; } } return YInputLine::handleKey(key); @@ -80,17 +80,11 @@ bool AddressBar::handleReturn(int mask) { return true; } -bool AddressBar::changeLocation(int newLocation) { - if (inrange(newLocation, 0, history.getCount())) { - location = newLocation; - if (location == history.getCount()) { - setText(null); - } - else { - setText(history[location]); - } - } - return true; +void AddressBar::changeLocation(int newLocation) { + if (! inrange(newLocation, 0, history.getCount())) + return; + location = newLocation; + setText(location == history.getCount() ? null : history[location], true); } void AddressBar::showNow() { diff --git a/src/aaddressbar.h b/src/aaddressbar.h index 68198920c..b4dbc7580 100644 --- a/src/aaddressbar.h +++ b/src/aaddressbar.h @@ -17,7 +17,7 @@ class AddressBar: public YInputLine { void hideNow(); private: - bool changeLocation(int newLocation); + void changeLocation(int newLocation); bool handleReturn(int mask); IApp *app; diff --git a/src/yinput.cc b/src/yinput.cc index 8c55cd427..3c8267195 100644 --- a/src/yinput.cc +++ b/src/yinput.cc @@ -53,11 +53,11 @@ YInputLine::YInputLine(YWindow *parent): YInputLine::~YInputLine() { } -void YInputLine::setText(const ustring &text) { +void YInputLine::setText(const ustring &text, bool asMarked) { fText = text; leftOfs = 0; curPos = fText.length(); - markPos = curPos; + markPos = asMarked ? 0 : curPos; limit(); repaint(); } @@ -680,10 +680,12 @@ void YInputLine::autoScroll(int delta, const XMotionEvent *motion) { void YInputLine::complete() { char* res = 0; - if (1 <= globit_best(cstring(fText), &res, 0, 0)) - setText(res); - // FIXME: even for max. prefix the text gets marked like for a full match; - // that might be intended or might be a bug in limit() or paint() + int res_count = globit_best(cstring(fText), &res, 0, 0); + // directory is not a final match + if(res_count == 1 && upath(res).dirExists()) + res_count++; + if (1 <= res_count) + setText(res, res_count == 1); free(res); } diff --git a/src/yinputline.h b/src/yinputline.h index 822de1ce1..a5ff6848b 100644 --- a/src/yinputline.h +++ b/src/yinputline.h @@ -13,7 +13,7 @@ class YInputLine: public YWindow, public YTimerListener, public YActionListener YInputLine(YWindow *parent = 0); virtual ~YInputLine(); - void setText(const ustring &text); + void setText(const ustring &text, bool asMarked); ustring getText(); virtual void paint(Graphics &g, const YRect &r);