From: John Hodge Date: Fri, 25 Feb 2011 00:42:47 +0000 (+0800) Subject: Fixing client (clipping item names, balance display), made server delete pidfile X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=7dcb4f540cf662f60433cd9822f73969d5800cce;p=tpg%2Fopendispense2.git Fixing client (clipping item names, balance display), made server delete pidfile --- diff --git a/src/client/main.c b/src/client/main.c index ddc0e39..9863814 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -661,7 +661,7 @@ int ShowNCursesUI(void) username = pwd->pw_name; } // Get balance - snprintf(balance_str, sizeof balance_str, "$%i.%02i", giUserBalance/100, giUserBalance%100); + snprintf(balance_str, sizeof balance_str, "$%i.%02i", giUserBalance/100, abs(giUserBalance)%100); // Enter curses mode initscr(); @@ -885,6 +885,8 @@ int ShowItemAt(int Row, int Col, int Width, int Index, int bHilighted) // Width = 0, don't print if( Width > 0 ) { + // 4 preceding, 5 price + int nameWidth = Width - 4 - 5; move( Row, Col ); if( Index >= 0 ) @@ -894,26 +896,26 @@ int ShowItemAt(int Row, int Col, int Width, int Index, int bHilighted) { case 0: if( bHilighted ) - printw("-> "); + printw("-> "); else - printw(" "); + printw(" "); break; case 1: - printw("SLD"); + printw("SLD "); break; default: case -1: - printw("ERR"); + printw("ERR "); break; } - printw(" %s", name); + printw("%-*.*s", nameWidth, nameWidth, name); - getyx(stdscr, _y, _x); +// getyx(stdscr, _y, _x); // Assumes max 4 digit prices - times = Width - 5 - (_x - Col); // TODO: Better handling for large prices - while(times--) addch(' '); +// times = Width - 5 - (_x - Col); // TODO: Better handling for large prices +// while(times--) addch(' '); printw(" %4i", price); } diff --git a/src/server/server.c b/src/server/server.c index 2557436..5102f62 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -217,6 +217,7 @@ void Server_Cleanup(void) { printf("\nClose(%i)\n", giServer_Socket); close(giServer_Socket); + unlink("/var/run/dispsrv"); } /**