Fixed LayoutBase::FocusPrev, and wired up shift+tab support in Main.cpp.

This commit is contained in:
casey 2016-06-12 13:24:39 -07:00
parent c3217bf65c
commit c7a0377632
2 changed files with 23 additions and 8 deletions

View File

@ -122,13 +122,7 @@ static void changeLayout(WindowState& current, ILayoutPtr newLayout) {
}
}
static void focusNextInLayout(WindowState& current) {
if (!current.layout) {
return;
}
updateFocusedWindow(current, current.layout->FocusNext());
static void checkDrawCursor(WindowState& current) {
if (current.input != NULL) {
curs_set(1);
@ -141,6 +135,24 @@ static void focusNextInLayout(WindowState& current) {
}
}
static void focusNextInLayout(WindowState& current) {
if (!current.layout) {
return;
}
updateFocusedWindow(current, current.layout->FocusNext());
checkDrawCursor(current);
}
static void focusPrevInLayout(WindowState& current) {
if (!current.layout) {
return;
}
updateFocusedWindow(current, current.layout->FocusPrev());
checkDrawCursor(current);
}
static inline std::string readKeyPress(int64 ch) {
std::string kn = keyname((int)ch);
@ -285,6 +297,9 @@ int main(int argc, char* argv[])
if (ch == '\t') { /* tab */
focusNextInLayout(state);
}
else if (kn == "KEY_BTAB") { /* shift-tab */
focusPrevInLayout(state);
}
else if (kn == "^D") { /* ctrl+d quits */
quit = true;
}

View File

@ -236,7 +236,7 @@ IWindowPtr LayoutBase::FocusNext() {
IWindowPtr LayoutBase::FocusPrev() {
IWindowPtr oldFocus = GetFocus();
if (--this->focused <= 0) {
if (--this->focused < 0) {
this->focused = (int) this->focusable.size() - 1;
}