summaryrefslogtreecommitdiff
path: root/interface.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2000-11-01 18:00:00 +0100
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2000-11-01 18:00:00 +0100
commita69b3211dc4f9b34eef440067d5ba304fbfbad94 (patch)
tree7701ccce8cef832eb5ab56293a7ae99aca40b78e /interface.c
parenta379eb714f7f5ef9a12efbe7588bb3509faba056 (diff)
downloadvdr-patch-lnbsharing-a69b3211dc4f9b34eef440067d5ba304fbfbad94.tar.gz
vdr-patch-lnbsharing-a69b3211dc4f9b34eef440067d5ba304fbfbad94.tar.bz2
Version 0.67vdr-0.67
- The EIT information is now gathered in a separate thread. - The sytem time can now be synchronized to the time broadcast in the DVB data stream. This can be enabled in the "Setup" menu by setting "SetSystemTime" to 1. Note that this works only if VDR is running under a user id that has permisson to set the system time. - The new item "Schedule" in the "Main" menu opens VDR's EPG (thanks to Robert Schneider). See the MANUAL file for a detailed description. - The new setup parameters MarginStart and MarginStop define how long (in minutes) before the official start time of a broadcast VDR shall begin recording, and how long after the official end time it shall stop recording. These are used when a recording is programmed from the "Schedules" menu. - The delay value in the dvb.c.071.diff patch to the driver has been increased to '3', because on some systems the OSD was not displayed correctly. If you are running an already patched version 0.71 driver and encounter problems with the OSD, please make sure the parameter in the ddelay call is '3', not '2'. - Fixed initializing the RCU remote control code (didn't work after switching on the system). - Problematic characters in recording names (which can come from timers that are programmed via the "Schedules" menu) are now replaced by suitable substitutes.
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c157
1 files changed, 91 insertions, 66 deletions
diff --git a/interface.c b/interface.c
index 5940195..810270f 100644
--- a/interface.c
+++ b/interface.c
@@ -4,14 +4,12 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: interface.c 1.25 2000/10/08 16:34:17 kls Exp $
+ * $Id: interface.c 1.28 2000/11/01 15:27:52 kls Exp $
*/
#include "interface.h"
+#include <ctype.h>
#include <unistd.h>
-#include "eit.h"
-
-cEIT EIT;
cInterface *Interface = NULL;
@@ -19,6 +17,7 @@ cInterface::cInterface(int SVDRPport)
{
open = 0;
cols[0] = 0;
+ width = height = 0;
keyFromWait = kNone;
rcIo = NULL;
SVDRP = NULL;
@@ -43,15 +42,17 @@ cInterface::~cInterface()
void cInterface::Open(int NumCols, int NumLines)
{
if (!open++)
- cDvbApi::PrimaryDvbApi->Open(NumCols, NumLines);
+ cDvbApi::PrimaryDvbApi->Open(width = NumCols, height = NumLines);
}
void cInterface::Close(void)
{
if (open == 1)
Clear();
- if (!--open)
+ if (!--open) {
cDvbApi::PrimaryDvbApi->Close();
+ width = height = 0;
+ }
}
unsigned int cInterface::GetCh(bool Wait, bool *Repeat, bool *Release)
@@ -114,6 +115,18 @@ void cInterface::ClearEol(int x, int y, eDvbColor Color)
cDvbApi::PrimaryDvbApi->ClrEol(x, y, Color);
}
+void cInterface::Fill(int x, int y, int w, int h, eDvbColor Color)
+{
+ if (open)
+ cDvbApi::PrimaryDvbApi->Fill(x, y, w, h, Color);
+}
+
+void cInterface::Flush(void)
+{
+ if (open)
+ cDvbApi::PrimaryDvbApi->Flush();
+}
+
void cInterface::SetCols(int *c)
{
for (int i = 0; i < MaxCols; i++) {
@@ -123,6 +136,74 @@ void cInterface::SetCols(int *c)
}
}
+char *cInterface::WrapText(const char *Text, int Width, int *Height)
+{
+ // Wraps the Text to make it fit into the area defined by the given Width
+ // (which is given in character cells).
+ // The actual number of lines resulting from this operation is returned in
+ // Height.
+ // The returned string is newly created on the heap and the caller
+ // is responsible for deleting it once it is no longer used.
+ // Wrapping is done by inserting the necessary number of newline
+ // characters into the string.
+
+ int Lines = 1;
+ char *t = strdup(Text);
+ char *Blank = NULL;
+ char *Delim = NULL;
+ int w = 0;
+
+ Width *= cDvbApi::PrimaryDvbApi->CellWidth();
+
+ while (*t && t[strlen(t) - 1] == '\n')
+ t[strlen(t) - 1] = 0; // skips trailing newlines
+
+ for (char *p = t; *p; ) {
+ if (*p == '\n') {
+ Lines++;
+ w = 0;
+ Blank = Delim = NULL;
+ p++;
+ continue;
+ }
+ else if (isspace(*p))
+ Blank = p;
+ int cw = cDvbApi::PrimaryDvbApi->Width(*p);
+ if (w + cw > Width) {
+ if (Blank) {
+ *Blank = '\n';
+ p = Blank;
+ continue;
+ }
+ else {
+ // Here's the ugly part, where we don't have any whitespace to
+ // punch in a newline, so we need to make room for it:
+ if (Delim)
+ p = Delim + 1; // let's fall back to the most recent delimiter
+ char *s = new char[strlen(t) + 2]; // The additional '\n' plus the terminating '\0'
+ int l = p - t;
+ strncpy(s, t, l);
+ s[l] = '\n';
+ strcpy(s + l + 1, p);
+ delete t;
+ t = s;
+ p = t + l;
+ continue;
+ }
+ }
+ else
+ w += cw;
+ if (strchr("-.,:;!?_", *p)) {
+ Delim = p;
+ Blank = NULL;
+ }
+ p++;
+ }
+
+ *Height = Lines;
+ return t;
+}
+
void cInterface::Write(int x, int y, const char *s, eDvbColor FgColor, eDvbColor BgColor)
{
if (open)
@@ -157,7 +238,7 @@ void cInterface::WriteText(int x, int y, const char *s, eDvbColor FgColor, eDvbC
void cInterface::Title(const char *s)
{
- int x = (MenuColumns - strlen(s)) / 2;
+ int x = (Width() - strlen(s)) / 2;
if (x < 0)
x = 0;
ClearEol(0, 0, clrCyan);
@@ -206,7 +287,7 @@ bool cInterface::Confirm(const char *s)
void cInterface::HelpButton(int Index, const char *Text, eDvbColor FgColor, eDvbColor BgColor)
{
if (open && Text) {
- const int w = MenuColumns / 4;
+ const int w = Width() / 4;
int l = (w - strlen(Text)) / 2;
if (l < 0)
l = 0;
@@ -334,65 +415,9 @@ void cInterface::LearnKeys(void)
}
}
-eKeys cInterface::DisplayChannel(int Number, const char *Name, bool WithInfo)
+void cInterface::DisplayChannelNumber(int Number)
{
- // Number = 0 is used for channel group display and no EIT
- if (Number)
- rcIo->Number(Number);
- if (Name && !Recording()) {
- Open(MenuColumns, 5);
- cDvbApi::PrimaryDvbApi->Fill(0, 0, MenuColumns, 1, clrBackground);
- int BufSize = MenuColumns + 1;
- char buffer[BufSize];
- if (Number)
- snprintf(buffer, BufSize, "%d %s", Number, Name ? Name : "");
- else
- snprintf(buffer, BufSize, "%s", Name ? Name : "");
- Write(0, 0, buffer);
- time_t t = time(NULL);
- struct tm *now = localtime(&t);
- snprintf(buffer, BufSize, "%02d:%02d", now->tm_hour, now->tm_min);
- Write(-5, 0, buffer);
- cDvbApi::PrimaryDvbApi->Flush();
-
- char *RunningTitle = "", *RunningSubtitle = "", *NextTitle = "", *NextSubtitle = "";
- int Lines = 0;
- if (Number && WithInfo && EIT.IsValid()) {
- if (*(RunningTitle = EIT.GetRunningTitle())) Lines++;
- if (*(RunningSubtitle = EIT.GetRunningSubtitle())) Lines++;
- if (*(NextTitle = EIT.GetNextTitle())) Lines++;
- if (*(NextSubtitle = EIT.GetNextSubtitle())) Lines++;
- }
- if (Lines > 0) {
- const int t = 6;
- int l = 1;
- cDvbApi::PrimaryDvbApi->Fill(0, 1, MenuColumns, Lines, clrBackground);
- if (*RunningTitle) {
- Write(0, l, EIT.GetRunningTime(), clrYellow, clrBackground);
- Write(t, l, RunningTitle, clrCyan, clrBackground);
- l++;
- }
- if (*RunningSubtitle) {
- Write(t, l, RunningSubtitle, clrCyan, clrBackground);
- l++;
- }
- if (*NextTitle) {
- Write(0, l, EIT.GetNextTime(), clrYellow, clrBackground);
- Write(t, l, NextTitle, clrCyan, clrBackground);
- l++;
- }
- if (*NextSubtitle) {
- Write(t, l, NextSubtitle, clrCyan, clrBackground);
- }
- cDvbApi::PrimaryDvbApi->Flush();
- }
- eKeys Key = Wait(5, true);
- if (Key == kOk)
- GetKey();
- Close();
- return Key;
- }
- return kNone;
+ rcIo->Number(Number);
}
void cInterface::DisplayRecording(int Index, bool On)