X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fclient%2Fmain.c;h=c1883b4f14bf86eb619e46edc9b2e52b0361a8bf;hb=2f6ba83a4dbe0c6c9cfdd991f0f72f2a4f018b27;hp=595d3e6702f51839159dd2c6df859d2dea9180e1;hpb=da639e3f13ee62627f4e7b29eccfcac70aad681d;p=tpg%2Fopendispense2.git diff --git a/src/client/main.c b/src/client/main.c index 595d3e6..c1883b4 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -904,7 +904,37 @@ int ShowNCursesUI(void) struct passwd *pwd; int height, width; - + + void _ItemDown(void) + { + currentItem ++; + // Skip over spacers + while( ShowItemAt(0, 0, 0, currentItem, 0) == -1 ) + currentItem ++; + + if( currentItem >= maxItemIndex ) { + currentItem = 0; + // Skip over spacers + while( ShowItemAt(0, 0, 0, currentItem, 0) == -1 ) + currentItem ++; + } + } + + void _ItemUp(void) + { + currentItem --; + // Skip over spacers + while( ShowItemAt(0, 0, 0, currentItem, 0) == -1 ) + currentItem --; + + if( currentItem < 0 ) { + currentItem = maxItemIndex - 1; + // Skip over spacers + while( ShowItemAt(0, 0, 0, currentItem, 0) == -1 ) + currentItem --; + } + } + // Get Username if( gsEffectiveUser ) username = gsEffectiveUser; @@ -1017,53 +1047,13 @@ int ShowNCursesUI(void) switch(ch) { - case 'B': - currentItem ++; - // Skip over spacers - while( ShowItemAt(0, 0, 0, currentItem, 0) == -1 ) - currentItem ++; - - if( currentItem >= maxItemIndex ) { - currentItem = 0; - // Skip over spacers - while( ShowItemAt(0, 0, 0, currentItem, 0) == -1 ) - currentItem ++; - } - break; - case 'A': - currentItem --; - // Skip over spacers - while( ShowItemAt(0, 0, 0, currentItem, 0) == -1 ) - currentItem --; - - if( currentItem < 0 ) { - currentItem = maxItemIndex - 1; - // Skip over spacers - while( ShowItemAt(0, 0, 0, currentItem, 0) == -1 ) - currentItem --; - } - break; + case 'B': _ItemDown(); break; + case 'A': _ItemUp(); break; } } else { } - - // Scroll only if needed - if( items_in_view < maxItemIndex ) - { - // - If the current item is above the second item shown, and we're not at the top - if( currentItem < itemBase + 2 && itemBase > 0 ) { - itemBase = currentItem - 2; - if(itemBase < 0) itemBase = 0; - } - // - If the current item is below the second item show, and we're not at the bottom - if( currentItem > itemBase + items_in_view - 2 && itemBase + items_in_view < maxItemIndex ) { - itemBase = currentItem - items_in_view + 2; - if( itemBase > maxItemIndex - items_in_view ) - itemBase = maxItemIndex - items_in_view; - } - } } else { switch(ch) @@ -1071,6 +1061,10 @@ int ShowNCursesUI(void) case '\n': ret = ShowItemAt(0, 0, 0, currentItem, 0); break; + case 'h': break; + case 'j': _ItemDown(); break; + case 'k': _ItemUp(); break; + case 'l': break; case 0x1b: // Escape case 'q': ret = -1; // -1: Return with no dispense @@ -1081,6 +1075,21 @@ int ShowNCursesUI(void) if( ret != -2 ) break; } + // Scroll only if needed + if( items_in_view < maxItemIndex ) + { + // - If the current item is above the second item shown, and we're not at the top + if( currentItem < itemBase + 2 && itemBase > 0 ) { + itemBase = currentItem - 2; + if(itemBase < 0) itemBase = 0; + } + // - If the current item is below the second item show, and we're not at the bottom + if( currentItem > itemBase + items_in_view - 2 && itemBase + items_in_view < maxItemIndex ) { + itemBase = currentItem - items_in_view + 2; + if( itemBase > maxItemIndex - items_in_view ) + itemBase = maxItemIndex - items_in_view; + } + } } @@ -1334,7 +1343,7 @@ int Authenticate_AutoAuth(int Socket, const char *Username) break; case 401: // Untrusted - fprintf(stderr, "Untrusted host, AUTOAUTH unavaliable\n"); +// fprintf(stderr, "Untrusted host, AUTOAUTH unavaliable\n"); ret = RV_PERMISSIONS; break; case 404: // Bad Username @@ -1373,7 +1382,7 @@ int Authenticate_AuthIdent(int Socket) break; case 401: // Untrusted - fprintf(stderr, "Untrusted host, AUTOAUTH unavaliable\n"); +// fprintf(stderr, "Untrusted host, AUTHIDENT unavaliable\n"); ret = RV_PERMISSIONS; break;