vdr 2.6.9
skincurses.c
Go to the documentation of this file.
1/*
2 * skincurses.c: A plugin for the Video Disk Recorder
3 *
4 * See the README file for copyright information and how to reach the author.
5 *
6 * $Id: skincurses.c 5.1 2021/07/01 15:40:46 kls Exp $
7 */
8
9#include <ncurses.h>
10#include <vdr/osd.h>
11#include <vdr/plugin.h>
12#include <vdr/skins.h>
13#include <vdr/videodir.h>
14
15static const char *VERSION = "2.4.3";
16static const char *DESCRIPTION = trNOOP("A text only skin");
17static const char *MAINMENUENTRY = NULL;
18
19// --- cCursesFont -----------------------------------------------------------
20
21class cCursesFont : public cFont {
22public:
23 virtual int Width(void) const { return 1; }
24 virtual int Width(uint c) const { return 1; }
25 virtual int Width(const char *s) const { return s ? Utf8StrLen(s) : 0; }
26 virtual int Height(void) const { return 1; }
27 virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {}
28 virtual void DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {}
29 };
30
31static const cCursesFont Font = cCursesFont(); // w/o the '= cCursesFont()' gcc 4.6 complains - can anybody explain why this is necessary?
32
33// --- cCursesOsd ------------------------------------------------------------
34
35#define clrBackground COLOR_BLACK
36#define clrTransparent clrBackground
37#define clrBlack clrBackground
38#define clrRed COLOR_RED
39#define clrGreen COLOR_GREEN
40#define clrYellow COLOR_YELLOW
41#define clrBlue COLOR_BLUE
42#define clrMagenta COLOR_MAGENTA
43#define clrCyan COLOR_CYAN
44#define clrWhite COLOR_WHITE
45
46static int clrMessage[] = {
48 clrCyan,
54 clrRed
55 };
56
57static int ScOsdWidth = 50;
58static int ScOsdHeight = 20;
59
60class cCursesOsd : public cOsd {
61private:
62 WINDOW *savedRegion;
64 void SetColor(int colorFg, int colorBg = clrBackground);
65public:
66 cCursesOsd(int Left, int Top);
67 virtual ~cCursesOsd();
68 virtual void SaveRegion(int x1, int y1, int x2, int y2);
69 virtual void RestoreRegion(void);
70 virtual void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault);
71 virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color);
72 virtual void Flush(void);
73 };
74
75cCursesOsd::cCursesOsd(int Left, int Top)
76:cOsd(Left, Top, 0)
77{
78 savedRegion = NULL;
79
80 start_color();
81 leaveok(stdscr, true);
82 refresh(); // to react on changes to screen size
83
84 int begy, begx;
85 int maxy, maxx;
86 getmaxyx(stdscr, maxy, maxx);
87 getbegyx(stdscr, begy, begx);
88 ScOsdWidth = maxx - begx;
89 ScOsdHeight = maxy - begy;
90}
91
93{
94 erase();
95 Flush();
96}
97
98void cCursesOsd::SetColor(int colorFg, int colorBg)
99{
100 int color = (colorBg << 16) | colorFg | 0x80000000;
101 int i = colorPairs.IndexOf(color);
102 if (i < 0) {
103 colorPairs.Append(color);
104 i = colorPairs.Size() - 1;
105 init_pair(i + 1, colorFg, colorBg);
106 }
107 attrset(COLOR_PAIR(i + 1));
108}
109
110void cCursesOsd::SaveRegion(int x1, int y1, int x2, int y2)
111{
112 if (savedRegion) {
113 delwin(savedRegion);
114 savedRegion = NULL;
115 }
116 savedRegion = newwin(y2 - y1 + 1, x2 - x1 + 1, y1, x1);
117 if (savedRegion)
118 copywin(stdscr, savedRegion, y1, x1, 0, 0, y2 - y1, x2 - x1, false);
119}
120
122{
123 if (savedRegion) {
124 overwrite(savedRegion, stdscr);
125 delwin(savedRegion);
126 savedRegion = NULL;
127 }
128}
129
130void cCursesOsd::DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment)
131{
132 int w = Font->Width(s);
133 int h = Font->Height();
134 if (Width || Height) {
135 int cw = Width ? Width : w;
136 int ch = Height ? Height : h;
137 DrawRectangle(x, y, x + cw - 1, y + ch - 1, ColorBg);
138 if (Width) {
139 if ((Alignment & taLeft) != 0)
140 ;
141 else if ((Alignment & taRight) != 0) {
142 if (w < Width)
143 x += Width - w;
144 }
145 else { // taCentered
146 if (w < Width)
147 x += (Width - w) / 2;
148 }
149 }
150 if (Height) {
151 if ((Alignment & taTop) != 0)
152 ;
153 else if ((Alignment & taBottom) != 0) {
154 if (h < Height)
155 y += Height - h;
156 }
157 else { // taCentered
158 if (h < Height)
159 y += (Height - h) / 2;
160 }
161 }
162 }
163 SetColor(ColorFg, ColorBg);
164 mvaddnstr(y, x, s, Width ? Width : ScOsdWidth - x);
165}
166
167void cCursesOsd::DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
168{
169 SetColor(Color, Color);
170 int dx = x2 - x1;
171 int dy = y2 - y1;
172 if (dx >= dy) {
173 for (int y = y1; y <= y2; y++)
174 mvhline(y, x1, ' ', dx + 1);
175 }
176 else {
177 for (int x = x1; x <= x2; x++)
178 mvvline(y1, x, ' ', dy + 1);
179 }
180}
181
183{
184 refresh();
185}
186
187// --- cSkinCursesDisplayChannel ---------------------------------------------
188
190private:
194public:
195 cSkinCursesDisplayChannel(bool WithInfo);
197 virtual void SetChannel(const cChannel *Channel, int Number);
198 virtual void SetEvents(const cEvent *Present, const cEvent *Following);
199 virtual void SetMessage(eMessageType Type, const char *Text);
200 virtual void Flush(void);
201 };
202
204{
205 int Lines = WithInfo ? 5 : 1;
206 message = false;
207 osd = new cCursesOsd(0, Setup.ChannelInfoPos ? 0 : ScOsdHeight - Lines);
208 timeWidth = strlen("00:00");
209 osd->DrawRectangle(0, 0, ScOsdWidth - 1, Lines - 1, clrBackground);
210}
211
216
217void cSkinCursesDisplayChannel::SetChannel(const cChannel *Channel, int Number)
218{
220 osd->DrawText(0, 0, ChannelString(Channel, Number), clrWhite, clrBackground, &Font);
221}
222
223void cSkinCursesDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Following)
224{
225 osd->DrawRectangle(0, 1, timeWidth - 1, 4, clrRed);
227 for (int i = 0; i < 2; i++) {
228 const cEvent *e = !i ? Present : Following;
229 if (e) {
230 osd->DrawText( 0, 2 * i + 1, e->GetTimeString(), clrWhite, clrRed, &Font);
231 osd->DrawText(timeWidth + 1, 2 * i + 1, e->Title(), clrCyan, clrBackground, &Font);
232 osd->DrawText(timeWidth + 1, 2 * i + 2, e->ShortText(), clrYellow, clrBackground, &Font);
233 }
234 }
235}
236
238{
239 if (Text) {
240 osd->SaveRegion(0, 0, ScOsdWidth - 1, 0);
241 osd->DrawText(0, 0, Text, clrMessage[2 * Type], clrMessage[2 * Type + 1], &Font, ScOsdWidth, 0, taCenter);
242 message = true;
243 }
244 else {
246 message = false;
247 }
248}
249
251{
252 if (!message) {
253 cString date = DayDateTime();
255 }
256 osd->Flush();
257}
258
259// --- cSkinCursesDisplayMenu ------------------------------------------------
260
262private:
266 void DrawTitle(void);
267 void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown);
268 void SetTextScrollbar(void);
269public:
271 virtual ~cSkinCursesDisplayMenu();
272 virtual void Scroll(bool Up, bool Page);
273 virtual int MaxItems(void);
274 virtual void Clear(void);
275 virtual void SetTitle(const char *Title);
276 virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL);
277 virtual void SetMessage(eMessageType Type, const char *Text);
278 virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable);
279 virtual void SetScrollbar(int Total, int Offset);
280 virtual void SetEvent(const cEvent *Event);
281 virtual void SetRecording(const cRecording *Recording);
282 virtual void SetText(const char *Text, bool FixedFont);
283 virtual const cFont *GetTextAreaFont(bool FixedFont) const { return &Font; }
284 virtual void Flush(void);
285 };
286
293
298
299void cSkinCursesDisplayMenu::DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
300{
301 if (Total > 0 && Total > Shown) {
302 int yt = Top;
303 int yb = yt + Height;
304 int st = yt;
305 int sb = yb;
306 int th = max(int((sb - st) * double(Shown) / Total + 0.5), 1);
307 int tt = min(int(st + (sb - st) * double(Offset) / Total + 0.5), sb - th);
308 int tb = min(tt + th, sb);
309 int xl = ScOsdWidth - 1;
310 osd->DrawRectangle(xl, st, xl, sb - 1, clrWhite);
311 osd->DrawRectangle(xl, tt, xl, tb - 1, clrCyan);
312 }
313}
314
320
321void cSkinCursesDisplayMenu::Scroll(bool Up, bool Page)
322{
323 cSkinDisplayMenu::Scroll(Up, Page);
325}
326
328{
329 return ScOsdHeight - 4;
330}
331
337
339{
340 bool WithDisk = MenuCategory() == mcMain || MenuCategory() == mcRecording;
342}
343
344void cSkinCursesDisplayMenu::SetTitle(const char *Title)
345{
346 title = Title;
347 DrawTitle();
348}
349
350void cSkinCursesDisplayMenu::SetButtons(const char *Red, const char *Green, const char *Yellow, const char *Blue)
351{
352 int w = ScOsdWidth;
353 int t0 = 0;
354 int t1 = 0 + w / 4;
355 int t2 = 0 + w / 2;
356 int t3 = w - w / 4;
357 int t4 = w;
358 int y = ScOsdHeight - 1;
359 osd->DrawText(t0, y, Red, clrWhite, Red ? clrRed : clrBackground, &Font, t1 - t0, 0, taCenter);
360 osd->DrawText(t1, y, Green, clrBlack, Green ? clrGreen : clrBackground, &Font, t2 - t1, 0, taCenter);
361 osd->DrawText(t2, y, Yellow, clrBlack, Yellow ? clrYellow : clrBackground, &Font, t3 - t2, 0, taCenter);
362 osd->DrawText(t3, y, Blue, clrWhite, Blue ? clrBlue : clrBackground, &Font, t4 - t3, 0, taCenter);
363}
364
366{
367 if (Text)
368 osd->DrawText(0, ScOsdHeight - 2, Text, clrMessage[2 * Type], clrMessage[2 * Type + 1], &Font, ScOsdWidth, 0, taCenter);
369 else
371}
372
373void cSkinCursesDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable)
374{
375 int y = 2 + Index;
376 int ColorFg, ColorBg;
377 if (Current) {
378 ColorFg = clrBlack;
379 ColorBg = clrCyan;
380 }
381 else {
382 ColorFg = Selectable ? clrWhite : clrCyan;
383 ColorBg = clrBackground;
384 }
385 for (int i = 0; i < MaxTabs; i++) {
386 const char *s = GetTabbedText(Text, i);
387 if (s) {
388 int xt = Tab(i) / AvgCharWidth();// Tab() is in "pixel" - see also skins.c!!!
389 osd->DrawText(xt, y, s, ColorFg, ColorBg, &Font, ScOsdWidth - 2 - xt);
390 }
391 if (!Tab(i + 1))
392 break;
393 }
394 SetEditableWidth(ScOsdWidth - 2 - Tab(1) / AvgCharWidth()); // Tab() is in "pixel" - see also skins.c!!!
395}
396
397void cSkinCursesDisplayMenu::SetScrollbar(int Total, int Offset)
398{
399 DrawScrollbar(Total, Offset, MaxItems(), 2, MaxItems(), Offset > 0, Offset + MaxItems() < Total);
400}
401
403{
404 if (!Event)
405 return;
406 int y = 2;
407 cTextScroller ts;
408 cString t = cString::sprintf("%s %s - %s", *Event->GetDateString(), *Event->GetTimeString(), *Event->GetEndTimeString());
409 ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, t, &Font, clrYellow, clrBackground);
410 if (Event->Vps() && Event->Vps() != Event->StartTime()) {
411 cString buffer = cString::sprintf(" VPS: %s", *Event->GetVpsString());
412 osd->DrawText(ScOsdWidth - Utf8StrLen(buffer), y, buffer, clrBlack, clrYellow, &Font);
413 }
414 y += ts.Height();
415 if (Event->ParentalRating()) {
416 cString buffer = cString::sprintf(" %s ", *Event->GetParentalRatingString());
417 osd->DrawText(ScOsdWidth - Utf8StrLen(buffer), y, buffer, clrBlack, clrYellow, &Font);
418 }
419 y += 1;
420 ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, Event->Title(), &Font, clrCyan, clrBackground);
421 y += ts.Height();
422 if (!isempty(Event->ShortText())) {
423 ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, Event->ShortText(), &Font, clrYellow, clrBackground);
424 y += ts.Height();
425 }
426 for (int i = 0; Event->Contents(i); i++) {
427 const char *s = Event->ContentToString(Event->Contents(i));
428 if (!isempty(s)) {
429 ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, s, &Font, clrYellow, clrBackground);
430 y += 1;
431 }
432 }
433 y += 1;
434 if (!isempty(Event->Description())) {
437 }
438}
439
441{
442 if (!Recording)
443 return;
444 const cRecordingInfo *Info = Recording->Info();
445 int y = 2;
446 cTextScroller ts;
447 cString t = cString::sprintf("%s %s %s", *DateString(Recording->Start()), *TimeString(Recording->Start()), Info->ChannelName() ? Info->ChannelName() : "");
448 ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, t, &Font, clrYellow, clrBackground);
449 y += ts.Height();
450 int xt = ScOsdWidth;
451 if (Info->GetEvent()->ParentalRating()) {
452 cString buffer = cString::sprintf(" %s ", *Info->GetEvent()->GetParentalRatingString());
453 int w = Utf8StrLen(buffer);
454 osd->DrawText(xt - w, y, buffer, clrBlack, clrYellow, &Font);
455 xt -= w + 1;
456 }
457 if (Info->Errors() > 0) {
458 cString buffer = cString::sprintf(" %d %s ", Info->Errors(), tr("errors"));
459 int w = Utf8StrLen(buffer);
460 osd->DrawText(xt - w, y, buffer, clrBlack, clrYellow, &Font);
461 xt -= w + 1;
462 }
463 y += 1;
464 const char *Title = Info->Title();
465 if (isempty(Title))
466 Title = Recording->Name();
467 ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, Title, &Font, clrCyan, clrBackground);
468 y += ts.Height();
469 if (!isempty(Info->ShortText())) {
470 ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, Info->ShortText(), &Font, clrYellow, clrBackground);
471 y += ts.Height();
472 }
473 for (int i = 0; Info->GetEvent()->Contents(i); i++) {
474 const char *s = Info->GetEvent()->ContentToString(Info->GetEvent()->Contents(i));
475 if (!isempty(s)) {
476 ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, s, &Font, clrYellow, clrBackground);
477 y += 1;
478 }
479 }
480 y += 1;
481 if (!isempty(Info->Description())) {
484 }
485}
486
487void cSkinCursesDisplayMenu::SetText(const char *Text, bool FixedFont)
488{
491}
492
501
502// --- cSkinCursesDisplayReplay ----------------------------------------------
503
505private:
508public:
509 cSkinCursesDisplayReplay(bool ModeOnly);
511 virtual void SetTitle(const char *Title);
512 virtual void SetMode(bool Play, bool Forward, int Speed);
513 virtual void SetProgress(int Current, int Total);
514 virtual void SetCurrent(const char *Current);
515 virtual void SetTotal(const char *Total);
516 virtual void SetJump(const char *Jump);
517 virtual void SetMessage(eMessageType Type, const char *Text);
518 virtual void Flush(void);
519 };
520
522{
523 message = false;
524 osd = new cCursesOsd(0, ScOsdHeight - 3);
525 osd->DrawRectangle(0, 0, ScOsdWidth - 1, 2, ModeOnly ? clrTransparent : clrBackground);
526}
527
532
534{
536}
537
538void cSkinCursesDisplayReplay::SetMode(bool Play, bool Forward, int Speed)
539{
540 if (Setup.ShowReplayMode) {
541 const char *Mode;
542 if (Speed == -1) Mode = Play ? " > " : " || ";
543 else if (Play) Mode = Forward ? " X>> " : " <<X ";
544 else Mode = Forward ? " X|> " : " <|X ";
545 char buf[16];
546 strn0cpy(buf, Mode, sizeof(buf));
547 char *p = strchr(buf, 'X');
548 if (p)
549 *p = Speed > 0 ? '1' + Speed - 1 : ' ';
550 SetJump(buf);
551 }
552}
553
554void cSkinCursesDisplayReplay::SetProgress(int Current, int Total)
555{
556 int p = Total > 0 ? ScOsdWidth * Current / Total : 0;
557 osd->DrawRectangle(0, 1, p, 1, clrGreen);
559}
560
562{
564}
565
567{
569}
570
572{
574}
575
577{
578 if (Text) {
579 osd->SaveRegion(0, 2, ScOsdWidth - 1, 2);
580 osd->DrawText(0, 2, Text, clrMessage[2 * Type], clrMessage[2 * Type + 1], &Font, ScOsdWidth, 0, taCenter);
581 message = true;
582 }
583 else {
585 message = false;
586 }
587}
588
590{
591 osd->Flush();
592}
593
594// --- cSkinCursesDisplayVolume ----------------------------------------------
595
597private:
599public:
602 virtual void SetVolume(int Current, int Total, bool Mute);
603 virtual void Flush(void);
604 };
605
610
615
616void cSkinCursesDisplayVolume::SetVolume(int Current, int Total, bool Mute)
617{
618 if (Mute) {
620 osd->DrawText(0, 0, tr("Key$Mute"), clrGreen, clrBackground, &Font);
621 }
622 else {
623 // TRANSLATORS: note the trailing blank!
624 const char *Prompt = tr("Volume ");
625 int l = Utf8StrLen(Prompt);
626 int p = (ScOsdWidth - l) * Current / Total;
627 osd->DrawText(0, 0, Prompt, clrGreen, clrBackground, &Font);
628 osd->DrawRectangle(l, 0, l + p - 1, 0, clrGreen);
629 osd->DrawRectangle(l + p, 0, ScOsdWidth - 1, 0, clrWhite);
630 }
631}
632
634{
635 osd->Flush();
636}
637
638// --- cSkinCursesDisplayTracks ----------------------------------------------
639
641private:
645 void SetItem(const char *Text, int Index, bool Current);
646public:
647 cSkinCursesDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
649 virtual void SetTrack(int Index, const char * const *Tracks);
650 virtual void SetAudioChannel(int AudioChannel) {}
651 virtual void Flush(void);
652 };
653
654cSkinCursesDisplayTracks::cSkinCursesDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
655{
656 currentIndex = -1;
657 itemsWidth = Font.Width(Title);
658 for (int i = 0; i < NumTracks; i++)
659 itemsWidth = max(itemsWidth, Font.Width(Tracks[i]));
661 osd = new cCursesOsd(0, 0);
663 osd->DrawText(0, 0, Title, clrBlack, clrCyan, &Font, itemsWidth);
664 for (int i = 0; i < NumTracks; i++)
665 SetItem(Tracks[i], i, false);
666}
667
672
673void cSkinCursesDisplayTracks::SetItem(const char *Text, int Index, bool Current)
674{
675 int y = 1 + Index;
676 int ColorFg, ColorBg;
677 if (Current) {
678 ColorFg = clrBlack;
679 ColorBg = clrCyan;
680 currentIndex = Index;
681 }
682 else {
683 ColorFg = clrWhite;
684 ColorBg = clrBackground;
685 }
686 osd->DrawText(0, y, Text, ColorFg, ColorBg, &Font, itemsWidth);
687}
688
689void cSkinCursesDisplayTracks::SetTrack(int Index, const char * const *Tracks)
690{
691 if (currentIndex >= 0)
692 SetItem(Tracks[currentIndex], currentIndex, false);
693 SetItem(Tracks[Index], Index, true);
694}
695
697{
698 osd->Flush();
699}
700
701// --- cSkinCursesDisplayMessage ---------------------------------------------
702
704private:
706public:
709 virtual void SetMessage(eMessageType Type, const char *Text);
710 virtual void Flush(void);
711 };
712
717
722
724{
725 osd->DrawText(0, 0, Text, clrMessage[2 * Type], clrMessage[2 * Type + 1], &Font, ScOsdWidth, 0, taCenter);
726}
727
729{
730 osd->Flush();
731}
732
733// --- cSkinCurses -----------------------------------------------------------
734
735class cSkinCurses : public cSkin {
736public:
737 cSkinCurses(void);
738 virtual const char *Description(void);
739 virtual cSkinDisplayChannel *DisplayChannel(bool WithInfo);
740 virtual cSkinDisplayMenu *DisplayMenu(void);
741 virtual cSkinDisplayReplay *DisplayReplay(bool ModeOnly);
742 virtual cSkinDisplayVolume *DisplayVolume(void);
743 virtual cSkinDisplayTracks *DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
744 virtual cSkinDisplayMessage *DisplayMessage(void);
745 };
746
748:cSkin("curses")
749{
750}
751
753{
754 return tr("Text mode");
755}
756
758{
759 return new cSkinCursesDisplayChannel(WithInfo);
760}
761
766
768{
769 return new cSkinCursesDisplayReplay(ModeOnly);
770}
771
776
777cSkinDisplayTracks *cSkinCurses::DisplayTracks(const char *Title, int NumTracks, const char * const *Tracks)
778{
779 return new cSkinCursesDisplayTracks(Title, NumTracks, Tracks);
780}
781
786
787// --- cPluginSkinCurses -----------------------------------------------------
788
790private:
791 // Add any member variables or functions you may need here.
792public:
793 cPluginSkinCurses(void);
794 virtual ~cPluginSkinCurses();
795 virtual const char *Version(void) { return VERSION; }
796 virtual const char *Description(void) { return tr(DESCRIPTION); }
797 virtual const char *CommandLineHelp(void);
798 virtual bool ProcessArgs(int argc, char *argv[]);
799 virtual bool Initialize(void);
800 virtual bool Start(void);
801 virtual void Housekeeping(void);
802 virtual const char *MainMenuEntry(void) { return tr(MAINMENUENTRY); }
803 virtual cOsdObject *MainMenuAction(void);
804 virtual cMenuSetupPage *SetupMenu(void);
805 virtual bool SetupParse(const char *Name, const char *Value);
806 };
807
809{
810 // Initialize any member variables here.
811 // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
812 // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
813}
814
816{
817 // Clean up after yourself!
818 endwin();
819}
820
822{
823 // Return a string that describes all known command line options.
824 return NULL;
825}
826
827bool cPluginSkinCurses::ProcessArgs(int argc, char *argv[])
828{
829 // Implement command line argument processing here if applicable.
830 return true;
831}
832
834{
835 // Initialize any background activities the plugin shall perform.
836 if (initscr())
837 return true;
838 return false;
839}
840
842{
843 // Start any background activities the plugin shall perform.
844 cSkin *Skin = new cSkinCurses;
845 // This skin is normally used for debugging, so let's make it the current one:
846 Skins.SetCurrent(Skin->Name());
847 return true;
848}
849
851{
852 // Perform any cleanup or other regular tasks.
853}
854
856{
857 // Perform the action when selected from the main VDR menu.
858 return NULL;
859}
860
862{
863 // Return a setup menu in case the plugin supports one.
864 return NULL;
865}
866
867bool cPluginSkinCurses::SetupParse(const char *Name, const char *Value)
868{
869 // Parse your own setup parameters and store their values.
870 return false;
871}
872
cString ChannelString(const cChannel *Channel, int Number)
Definition channels.c:1140
Definition osd.h:169
virtual int Width(uint c) const
Returns the width of the given character in pixel.
Definition skincurses.c:24
virtual int Width(const char *s) const
Returns the width of the given string in pixel.
Definition skincurses.c:25
virtual int Width(void) const
Returns the original character width as requested when the font was created, or 0 if the default widt...
Definition skincurses.c:23
virtual int Height(void) const
Returns the height of this font in pixel (all characters have the same height).
Definition skincurses.c:26
virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const
Draws the given text into the Bitmap at position (x, y) with the given colors.
Definition skincurses.c:27
virtual void DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const
Definition skincurses.c:28
virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
Draws a filled rectangle defined by the upper left (x1, y1) and lower right (x2, y2) corners with the...
Definition skincurses.c:167
cVector< int > colorPairs
Definition skincurses.c:63
virtual void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)
Draws the given string at coordinates (x, y) with the given foreground and background color and font.
Definition skincurses.c:130
cCursesOsd(int Left, int Top)
Definition skincurses.c:75
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
Definition skincurses.c:121
WINDOW * savedRegion
Definition skincurses.c:62
void SetColor(int colorFg, int colorBg=clrBackground)
Definition skincurses.c:98
virtual void SaveRegion(int x1, int y1, int x2, int y2)
Saves the region defined by the given coordinates for later restoration through RestoreRegion().
Definition skincurses.c:110
virtual void Flush(void)
Actually commits all data to the OSD hardware.
Definition skincurses.c:182
virtual ~cCursesOsd()
Definition skincurses.c:92
Definition epg.h:73
const char * ShortText(void) const
Definition epg.h:106
time_t Vps(void) const
Definition epg.h:114
static const char * ContentToString(uchar Content)
Definition epg.c:279
cString GetDateString(void) const
Definition epg.c:428
uchar Contents(int i=0) const
Definition epg.h:109
const char * Description(void) const
Definition epg.h:107
int ParentalRating(void) const
Definition epg.h:110
time_t StartTime(void) const
Definition epg.h:111
cString GetTimeString(void) const
Definition epg.c:433
const char * Title(void) const
Definition epg.h:105
cString GetEndTimeString(void) const
Definition epg.c:438
cString GetVpsString(void) const
Definition epg.c:443
cString GetParentalRatingString(void) const
Definition epg.c:421
Definition font.h:37
The cOsd class is the interface to the "On Screen Display".
Definition osd.h:753
int Width(void)
Definition osd.h:844
virtual void SaveRegion(int x1, int y1, int x2, int y2)
Saves the region defined by the given coordinates for later restoration through RestoreRegion().
Definition osd.c:2127
virtual void Flush(void)
Actually commits all data to the OSD hardware.
Definition osd.c:2266
virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
Draws a filled rectangle defined by the upper left (x1, y1) and lower right (x2, y2) corners with the...
Definition osd.c:2236
int Left(void)
Definition osd.h:842
int Top(void)
Definition osd.h:843
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
Definition osd.c:2143
int Height(void)
Definition osd.h:845
virtual void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)
Draws the given string at coordinates (x, y) with the given foreground and background color and font.
Definition osd.c:2226
Definition osd.h:459
virtual bool Start(void)
Definition skincurses.c:841
virtual ~cPluginSkinCurses()
Definition skincurses.c:815
virtual bool Initialize(void)
Definition skincurses.c:833
virtual cOsdObject * MainMenuAction(void)
Definition skincurses.c:855
virtual const char * Version(void)
Definition skincurses.c:795
virtual void Housekeeping(void)
Definition skincurses.c:850
virtual const char * CommandLineHelp(void)
Definition skincurses.c:821
virtual bool ProcessArgs(int argc, char *argv[])
Definition skincurses.c:827
virtual cMenuSetupPage * SetupMenu(void)
Definition skincurses.c:861
virtual const char * MainMenuEntry(void)
Definition skincurses.c:802
virtual bool SetupParse(const char *Name, const char *Value)
Definition skincurses.c:867
virtual const char * Description(void)
Definition skincurses.c:796
const char * Name(void)
Definition plugin.h:36
const char * ChannelName(void) const
Definition recording.h:87
const cEvent * GetEvent(void) const
Definition recording.h:88
int Errors(void) const
Definition recording.h:105
const char * ShortText(void) const
Definition recording.h:90
const char * Title(void) const
Definition recording.h:89
const char * Description(void) const
Definition recording.h:91
const char * Name(void) const
Returns the full name of the recording (without the video directory).
Definition recording.h:162
time_t Start(void) const
Definition recording.h:147
cRecordingInfo * Info(void) const
Definition recording.h:169
int ShowReplayMode
Definition config.h:352
int ChannelInfoPos
Definition config.h:329
virtual void SetEvents(const cEvent *Present, const cEvent *Following)
Sets the Present and Following EPG events.
Definition skincurses.c:223
virtual void SetChannel(const cChannel *Channel, int Number)
Sets the current channel to Channel.
Definition skincurses.c:217
cSkinCursesDisplayChannel(bool WithInfo)
Definition skincurses.c:203
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition skincurses.c:250
virtual ~cSkinCursesDisplayChannel()
Definition skincurses.c:212
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition skincurses.c:237
virtual void SetTitle(const char *Title)
Sets the title of this menu to Title.
Definition skincurses.c:344
virtual const cFont * GetTextAreaFont(bool FixedFont) const
Returns a pointer to the font which is used to display text with SetText().
Definition skincurses.c:283
virtual void SetEvent(const cEvent *Event)
Sets the Event that shall be displayed, using the entire central area of the menu.
Definition skincurses.c:402
virtual void Clear(void)
Clears the entire central area of the menu.
Definition skincurses.c:332
virtual void SetRecording(const cRecording *Recording)
Sets the Recording that shall be displayed, using the entire central area of the menu.
Definition skincurses.c:440
virtual void SetButtons(const char *Red, const char *Green=NULL, const char *Yellow=NULL, const char *Blue=NULL)
Sets the color buttons to the given strings.
Definition skincurses.c:350
void DrawScrollbar(int Total, int Offset, int Shown, int Top, int Height, bool CanScrollUp, bool CanScrollDown)
Definition skincurses.c:299
virtual void SetText(const char *Text, bool FixedFont)
Sets the Text that shall be displayed, using the entire central area of the menu.
Definition skincurses.c:487
virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable)
Sets the item at the given Index to Text.
Definition skincurses.c:373
virtual int MaxItems(void)
Returns the maximum number of items the menu can display.
Definition skincurses.c:327
virtual void Scroll(bool Up, bool Page)
If this menu contains a text area that can be scrolled, this function will be called to actually scro...
Definition skincurses.c:321
void SetTextScrollbar(void)
Definition skincurses.c:315
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition skincurses.c:493
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition skincurses.c:365
virtual ~cSkinCursesDisplayMenu()
Definition skincurses.c:294
virtual void SetScrollbar(int Total, int Offset)
Sets the Total number of items in the currently displayed list, and the Offset of the first item that...
Definition skincurses.c:397
virtual void SetMessage(eMessageType Type, const char *Text)
< This class implements a simple message display.
Definition skincurses.c:723
virtual ~cSkinCursesDisplayMessage()
Definition skincurses.c:718
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition skincurses.c:728
cSkinCursesDisplayReplay(bool ModeOnly)
Definition skincurses.c:521
virtual ~cSkinCursesDisplayReplay()
Definition skincurses.c:528
virtual void SetMessage(eMessageType Type, const char *Text)
Sets a one line message Text, with the given Type.
Definition skincurses.c:576
virtual void SetCurrent(const char *Current)
Sets the current position within the recording, as a user readable string in the form "h:mm:ss....
Definition skincurses.c:561
virtual void SetProgress(int Current, int Total)
This function will be called whenever the position in or the total length of the recording has change...
Definition skincurses.c:554
virtual void SetMode(bool Play, bool Forward, int Speed)
Sets the current replay mode, which can be used to display some indicator, showing the user whether w...
Definition skincurses.c:538
virtual void SetJump(const char *Jump)
Sets the prompt that allows the user to enter a jump point.
Definition skincurses.c:571
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition skincurses.c:589
virtual void SetTotal(const char *Total)
Sets the total length of the recording, as a user readable string in the form "h:mm:ss".
Definition skincurses.c:566
virtual void SetTitle(const char *Title)
Sets the title of the recording.
Definition skincurses.c:533
cSkinCursesDisplayTracks(const char *Title, int NumTracks, const char *const *Tracks)
Definition skincurses.c:654
void SetItem(const char *Text, int Index, bool Current)
Definition skincurses.c:673
virtual void SetAudioChannel(int AudioChannel)
Sets the audio channel indicator.
Definition skincurses.c:650
virtual void SetTrack(int Index, const char *const *Tracks)
< This class implements the track display.
Definition skincurses.c:689
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition skincurses.c:696
virtual ~cSkinCursesDisplayTracks()
Definition skincurses.c:668
virtual ~cSkinCursesDisplayVolume()
Definition skincurses.c:611
virtual void Flush(void)
Actually draws the OSD display to the output device.
Definition skincurses.c:633
virtual void SetVolume(int Current, int Total, bool Mute)
< This class implements the volume/mute display.
Definition skincurses.c:616
virtual cSkinDisplayMenu * DisplayMenu(void)
Creates and returns a new object for displaying a menu.
Definition skincurses.c:762
virtual cSkinDisplayChannel * DisplayChannel(bool WithInfo)
Creates and returns a new object for displaying the current channel.
Definition skincurses.c:757
virtual const char * Description(void)
Returns a user visible, single line description of this skin, which may consist of arbitrary text and...
Definition skincurses.c:752
virtual cSkinDisplayTracks * DisplayTracks(const char *Title, int NumTracks, const char *const *Tracks)
Creates and returns a new object for displaying the available tracks.
Definition skincurses.c:777
virtual cSkinDisplayReplay * DisplayReplay(bool ModeOnly)
Creates and returns a new object for displaying replay progress.
Definition skincurses.c:767
cSkinCurses(void)
Definition skincurses.c:747
virtual cSkinDisplayMessage * DisplayMessage(void)
Creates and returns a new object for displaying a message.
Definition skincurses.c:782
virtual cSkinDisplayVolume * DisplayVolume(void)
Creates and returns a new object for displaying the current volume.
Definition skincurses.c:772
virtual void Scroll(bool Up, bool Page)
If this menu contains a text area that can be scrolled, this function will be called to actually scro...
Definition skins.c:107
cTextScroller textScroller
Definition skins.h:173
int Tab(int n)
Returns the offset of the given tab from the left border of the item display area.
Definition skins.h:174
eMenuCategory MenuCategory(void) const
Returns the menu category, set by a previous call to SetMenuCategory().
Definition skins.h:183
const char * GetTabbedText(const char *s, int Tab)
Returns the part of the given string that follows the given Tab (where 0 indicates the beginning of t...
Definition skins.c:112
static cSkinDisplay * Current(void)
Returns the currently active cSkinDisplay.
Definition skins.h:61
void SetEditableWidth(int Width)
If an item is set through a call to cSkinDisplayMenu::SetItem(), this function shall be called to set...
Definition skins.h:49
static int AvgCharWidth(void)
Returns the average width of a character in pixel (just a raw estimate).
Definition skins.h:46
Definition skins.h:401
const char * Name(void)
Definition skins.h:420
bool SetCurrent(const char *Name=NULL)
Sets the current skin to the one indicated by name.
Definition skins.c:231
static cString sprintf(const char *fmt,...) __attribute__((format(printf
Definition tools.c:1180
int Height(void)
Definition osd.h:1088
bool CanScroll(void)
Definition osd.h:1092
int Total(void)
Definition osd.h:1089
int Top(void)
Definition osd.h:1086
int Offset(void)
Definition osd.h:1090
void Set(cOsd *Osd, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg)
Definition osd.c:2421
void Reset(void)
Definition osd.c:2438
int Shown(void)
Definition osd.h:1091
bool CanScrollDown(void)
Definition osd.h:1094
bool CanScrollUp(void)
Definition osd.h:1093
int Size(void) const
Definition tools.h:767
int IndexOf(const T &Data)
Definition tools.h:759
virtual void Append(T Data)
Definition tools.h:787
static bool HasChanged(int &State)
Returns true if the usage of the video disk space has changed since the last call to this function wi...
Definition videodir.c:210
static cString String(void)
Returns a localized string of the form "Disk nn% - hh:mm free".
Definition videodir.c:234
cSetup Setup
Definition config.c:372
uint32_t tColor
Definition font.h:30
#define tr(s)
Definition i18n.h:85
#define trNOOP(s)
Definition i18n.h:88
@ taCenter
Definition osd.h:158
@ taTop
Definition osd.h:161
@ taBottom
Definition osd.h:162
@ taRight
Definition osd.h:160
@ taDefault
Definition osd.h:164
@ taLeft
Definition osd.h:159
#define VDRPLUGINCREATOR(PluginClass)
Definition plugin.h:18
static const char * VERSION
Definition skincurses.c:15
static const char * DESCRIPTION
Definition skincurses.c:16
static int ScOsdWidth
Definition skincurses.c:57
#define clrBlue
Definition skincurses.c:41
#define clrTransparent
Definition skincurses.c:36
#define clrBlack
Definition skincurses.c:37
#define clrWhite
Definition skincurses.c:44
#define clrGreen
Definition skincurses.c:39
static int clrMessage[]
Definition skincurses.c:46
static int ScOsdHeight
Definition skincurses.c:58
#define clrRed
Definition skincurses.c:38
#define clrYellow
Definition skincurses.c:40
#define clrBackground
Definition skincurses.c:35
#define clrCyan
Definition skincurses.c:43
static const cCursesFont Font
Definition skincurses.c:31
static const char * MAINMENUENTRY
Definition skincurses.c:17
cSkins Skins
Definition skins.c:219
@ mcMain
Definition skins.h:107
@ mcRecording
Definition skins.h:115
eMessageType
Definition skins.h:37
cString TimeString(time_t t)
Converts the given time to a string of the form "hh:mm".
Definition tools.c:1286
bool isempty(const char *s)
Definition tools.c:354
int Utf8StrLen(const char *s)
Returns the number of UTF-8 symbols formed by the given string of character bytes.
Definition tools.c:892
cString DateString(time_t t)
Converts the given time to a string of the form "www dd.mm.yyyy".
Definition tools.c:1266
cString DayDateTime(time_t t)
Converts the given time to a string of the form "www dd.mm. hh:mm".
Definition tools.c:1245
char * strn0cpy(char *dest, const char *src, size_t n)
Definition tools.c:131
T min(T a, T b)
Definition tools.h:63
T max(T a, T b)
Definition tools.h:64