diff options
Diffstat (limited to 'interface.c')
-rw-r--r-- | interface.c | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/interface.c b/interface.c index a546513..446f9c4 100644 --- a/interface.c +++ b/interface.c @@ -1,19 +1,16 @@ /* * interface.c: Abstract user interface layer * - * See the main source file 'osm.c' for copyright information and + * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: interface.c 1.3 2000/04/15 17:38:11 kls Exp $ + * $Id: interface.c 1.6 2000/04/24 09:44:23 kls Exp $ */ #include "interface.h" #include <unistd.h> #include "remote.h" -#define MenuLines 15 -#define MenuColumns 40 - #ifndef DEBUG_REMOTE cRcIo RcIo("/dev/ttyS1"); #endif @@ -26,6 +23,7 @@ cInterface::cInterface(void) { open = 0; cols[0] = 0; + keyFromWait = kNone; } void cInterface::Init(void) @@ -35,10 +33,10 @@ void cInterface::Init(void) #endif } -void cInterface::Open(void) +void cInterface::Open(int NumCols, int NumLines) { if (!open++) - DvbApi.Open(MenuColumns, MenuLines); + DvbApi.Open(NumCols, NumLines); } void cInterface::Close(void) @@ -49,35 +47,45 @@ void cInterface::Close(void) DvbApi.Close(); } -unsigned int cInterface::GetCh(void) +unsigned int cInterface::GetCh(bool Wait) { #ifdef DEBUG_REMOTE + timeout(Wait ? 1000 :10); int c = getch(); return (c > 0) ? c : 0; #else -//XXX #ifdef DEBUG_OSD -//XXX wrefresh(window);//XXX -//XXX #endif - unsigned int Command; - return RcIo.GetCommand(&Command) ? Command : 0; +#ifdef DEBUG_OSD + timeout(0); + getch(); // just to make 'ncurses' display the window: +#endif + if (Wait || RcIo.InputAvailable()) { + unsigned int Command; + return RcIo.GetCommand(&Command, NULL) ? Command : 0; + } + return 0; #endif } -eKeys cInterface::GetKey(void) +eKeys cInterface::GetKey(bool Wait) { - return Keys.Get(GetCh()); + eKeys Key = keyFromWait != kNone ? keyFromWait : Keys.Get(GetCh(Wait)); + keyFromWait = kNone; + return Key; } -eKeys cInterface::Wait(int Seconds) +eKeys cInterface::Wait(int Seconds, bool KeepChar) { int t0 = time_ms(); + eKeys Key = kNone; while (time_ms() - t0 < Seconds * 1000) { - eKeys Key = GetKey(); + Key = GetKey(); if (Key != kNone) - return Key; + break; } - return kNone; + if (KeepChar) + keyFromWait = Key; + return Key; } void cInterface::Clear(void) @@ -312,8 +320,20 @@ void cInterface::LearnKeys(void) void cInterface::DisplayChannel(int Number, const char *Name) { -//TODO #ifndef DEBUG_REMOTE RcIo.Number(Number); #endif + if (Name) { + Open(MenuColumns, 1); + char buffer[MenuColumns + 1]; + snprintf(buffer, sizeof(buffer), "%d %s", Number, Name ? Name : ""); + Write(0, 0, buffer); + time_t t = time(NULL); + struct tm *now = localtime(&t); + snprintf(buffer, sizeof(buffer), "%02d:%02d", now->tm_hour, now->tm_min); + Write(-5, 0, buffer); + if (Wait(2, true) == kOk) + GetKey(); + Close(); + } } |