{
// Very basic dispense interface
for( i = 0; i < giNumItems; i ++ ) {
- printf("%2i %s:%i\t%3i %s\n", i, gaItems[i].Type, gaItems[i].ID,
- gaItems[i].Price, gaItems[i].Desc);
+ if( strcmp(gaItems[i].Desc, "-") == 0 )
+ printf("\n");
+ else
+ printf("%2i %s:%i\t%3i %s\n", i, gaItems[i].Type, gaItems[i].ID,
+ gaItems[i].Price, gaItems[i].Desc);
}
printf(" q Quit\n");
for(;;)
printw("| ");
}
- // Check for ... row
+ // Check for the '...' row
// - Oh god, magic numbers!
if( i == 0 && itemBase > 0 ) {
printw(" ...");
// itemBase ++;
if( currentItem < giNumItems - 1 )
currentItem ++;
- if( itemBase + itemCount - 1 <= currentItem && itemBase + itemCount < giNumItems )
- itemBase ++;
+ else {
+ currentItem = 0;
+ }
break;
case 'A':
//if( itemBase > 0 )
// itemBase --;
if( currentItem > 0 )
currentItem --;
- if( itemBase + 1 > currentItem && itemBase > 0 )
- itemBase --;
+ else {
+ currentItem = giNumItems - 1;
+ }
break;
}
}
else {
}
+
+ if( currentItem < itemBase + 1 && itemBase > 0 )
+ itemBase = currentItem - 1;
+ if( currentItem > itemBase + itemCount - 1 && itemBase < itemCount-1 )
+ itemBase = currentItem - itemCount + 1;
+
+ #if 0
+ if( itemBase + itemCount - 1 <= currentItem && itemBase + itemCount < giNumItems )
+ {
+ itemBase += ;
+ }
+ if( itemBase + 1 > currentItem && itemBase > 0 )
+ itemBase --;
+ #endif
}
else {
switch(ch)
name = gaItems[Index].Desc;
price = gaItems[Index].Price;
}
+
+ // Spacer hack (Desc = "-")
+ if( gaItems[Index].Desc[0] == '-' && gaItems[Index].Desc[1] == '\0' )
+ {
+ return;
+ }
printw("%02i %s", Index, name);
int giNumItems = 0;
tItem *gaItems = NULL;
tHandler gPseudo_Handler = {Name:"pseudo"};
-tHandler *gaHandlers[] = {&gPseudo_Handler, &gCoke_Handler, &gSnack_Handler, &gDoor_Handler};
+tHandler gSpacer_Handler = {Name:"spacer"};
+tHandler *gaHandlers[] = {&gSpacer_Handler, &gPseudo_Handler, &gCoke_Handler, &gSnack_Handler, &gDoor_Handler};
int giNumHandlers = sizeof(gaHandlers)/sizeof(gaHandlers[0]);
char *gsItemListFile = DEFAULT_ITEM_FILE;
#if USE_INOTIFY
regex_t regex;
regmatch_t matches[5];
- i = regcomp(®ex, "^-?([a-zA-Z][a-zA-Z0-9]*)\\s+([0-9]+)\\s+([0-9]+)\\s+(.*)", REG_EXTENDED);
+ i = regcomp(®ex, "^-?([a-zA-Z][a-zA-Z]*)\\s+([0-9]+)\\s+([0-9]+)\\s+(.*)", REG_EXTENDED);
if( i )
{
size_t len = regerror(i, ®ex, NULL, 0);