update libzvbi
[opendreambox.git] / meta-opendreambox / recipes-multimedia / zvbi / zvbi-0.2.35 / 0005-fix-top-navigation.patch
1 From 12140c56014080e61170461d7fb1052fbd4088e8 Mon Sep 17 00:00:00 2001
2 From: Andreas Oberritter <obi@opendreambox.org>
3 Date: Fri, 8 Jun 2012 01:02:07 +0200
4 Subject: [PATCH 5/6] fix top navigation
5
6 * patch by Roland Meier
7 ---
8  src/teletext.c |   94 +++++++++++++++++++++++++++-----------------------------
9  1 file changed, 46 insertions(+), 48 deletions(-)
10
11 diff --git a/src/teletext.c b/src/teletext.c
12 index deeec6a..3360cbd 100644
13 --- a/src/teletext.c
14 +++ b/src/teletext.c
15 @@ -156,15 +156,21 @@ static void screen_color(vbi_page *pg, int flags, int color);
16  
17  static vbi_bool
18  top_label(vbi_decoder *vbi, vbi_page *pg, struct vbi_font_descr *font,
19 -         int index, int pgno, int foreground, int ff)
20 +         int index, int pgno, int foreground, int background)
21  {
22 -       int column = index * 13 + 1;
23 +       int column = index * 10 + 1;
24         vbi_char *acp;
25         struct ttx_ait_title *ait;
26         int i, j;
27  
28         acp = &pg->text[LAST_ROW + column];
29  
30 +       for (i = 0; i < 10; i++) 
31 +       {
32 +               acp[i].foreground = foreground;
33 +               acp[i].background = background;
34 +       }
35 +       
36         for (i = 0; i < 8; i++)
37                 if (PAGE_FUNCTION_AIT == vbi->cn->btt_link[i].function) {
38                         cache_page *vtp;
39 @@ -191,37 +197,25 @@ top_label(vbi_decoder *vbi, vbi_page *pg, struct vbi_font_descr *font,
40                                         pg->nav_link[index].pgno = pgno;
41                                         pg->nav_link[index].subno = VBI_ANY_SUBNO;
42  
43 -                                       for (i = 11; i >= 0; i--)
44 +                                       for (i = 9; i >= 0; i--)
45                                                 if (ait->text[i] > 0x20)
46                                                         break;
47 +                                       j = i; /* index of last char != " " */
48  
49 -                                       if (ff && (i <= (11 - ff))) {
50 -                                               acp += (11 - ff - i) >> 1;
51 -                                               column += (11 - ff - i) >> 1;
52 -
53 -                                               acp[i + 1].link = TRUE;
54 -                                               pg->nav_index[column + i + 1] = index;
55 -
56 -                                               acp[i + 2].unicode = 0x003E;
57 -                                               acp[i + 2].foreground = foreground;
58 -                                               acp[i + 2].link = TRUE;
59 -                                               pg->nav_index[column + i + 2] = index;
60 -
61 -                                               if (ff > 1) {
62 -                                                       acp[i + 3].unicode = 0x003E;
63 -                                                       acp[i + 3].foreground = foreground;
64 -                                                       acp[i + 3].link = TRUE;
65 -                                                       pg->nav_index[column + i + 3] = index;
66 -                                               }
67 -                                       } else {
68 -                                               acp += (11 - i) >> 1;
69 -                                               column += (11 - i) >> 1;
70 +                                       if (!i) 
71 +                                       {
72 +                                               i = 3; /* no text: display number */
73                                         }
74  
75 +                                       /* center text */
76 +                                       acp += (9 - i) >> 1;
77 +                                       column += (9 - i) >> 1;
78 +
79                                         for (; i >= 0; i--) {
80                                                 acp[i].unicode = vbi_teletext_unicode(font->G0, font->subset,
81 -                                                       (ait->text[i] < 0x20) ? 0x20 : ait->text[i]);
82 -                                               acp[i].foreground = foreground;
83 +                                                                                     j ? ((ait->text[i] < 0x20) ? 0x20 : ait->text[i])
84 +                                                                                     : 0x30 + (pgno % 10));
85 +                                               pgno /= 10;
86                                                 acp[i].link = TRUE;
87                                                 pg->nav_index[column + i] = index;
88                                         }
89 @@ -241,8 +235,8 @@ top_label(vbi_decoder *vbi, vbi_page *pg, struct vbi_font_descr *font,
90  }
91  
92  static __inline__ vbi_pgno
93 -add_modulo                     (vbi_pgno               pgno,
94 -                                int                    incr)
95 +add_modulo(vbi_pgno            pgno,
96 +          int                  incr)
97  {
98         return ((pgno - 0x100 + incr) & 0x7FF) + 0x100;
99  }
100 @@ -253,8 +247,7 @@ top_navigation_bar(vbi_decoder *vbi, vbi_page *pg,
101  {
102         struct ttx_page_stat *ps;
103         vbi_char ac;
104 -       vbi_pgno pgno1;
105 -       int i, got;
106 +       int i, idx=0;
107  
108         ps = cache_network_page_stat (vbi->cn, vtp->pgno);
109         printv("PAGE MIP/BTT: %d\n", ps->page_type);
110 @@ -272,35 +265,38 @@ top_navigation_bar(vbi_decoder *vbi, vbi_page *pg,
111         if (pg->page_opacity[1] != VBI_OPAQUE)
112                 return;
113  
114 -       pgno1 = add_modulo (vtp->pgno, 1);
115 -
116 -       for (i = vtp->pgno; i != pgno1; i = add_modulo (i, -1)) {
117 +       for (i = add_modulo (vtp->pgno, -1); i != vtp->pgno; i = add_modulo (i, -1)) {
118                 struct ttx_page_stat *ps;
119  
120                 ps = cache_network_page_stat (vbi->cn, i);
121 -               if (ps->page_type == VBI_TOP_BLOCK ||
122 -                   ps->page_type == VBI_TOP_GROUP) {
123 -                       top_label(vbi, pg, pg->font[0], 0, i, 32 + VBI_WHITE, 0);
124 +               if (ps->page_type == VBI_TOP_BLOCK) {
125 +                       top_label(vbi, pg, pg->font[0], idx++, i, VBI_WHITE, VBI_RED);
126                         break;
127                 }
128         }
129  
130 -       for (i = pgno1, got = FALSE; i != vtp->pgno; i = add_modulo (i, 1)) {
131 +       for (i = add_modulo (vtp->pgno, 1); i != vtp->pgno; i = add_modulo (i, 1)) {
132                 struct ttx_page_stat *ps;
133  
134                 ps = cache_network_page_stat (vbi->cn, i);
135                 switch (ps->page_type) {
136 -               case VBI_TOP_BLOCK:
137 -                       top_label(vbi, pg, pg->font[0], 2, i, 32 + VBI_YELLOW, 2);
138 -                       return;
139 -
140 -               case VBI_TOP_GROUP:
141 -                       if (!got) {
142 -                               top_label(vbi, pg, pg->font[0], 1, i, 32 + VBI_GREEN, 1);
143 -                               got = TRUE;
144 -                       }
145 -
146 -                       break;
147 +                       case VBI_TOP_BLOCK:
148 +                               if (idx == 3)
149 +                               {
150 +                                       top_label(vbi, pg, pg->font[0], idx, i, VBI_WHITE, VBI_BLUE);
151 +                                       return;
152 +                               }
153 +                               /* fallthrough */
154 +                       case VBI_TOP_GROUP:
155 +                               if (idx == 1)
156 +                               {
157 +                                       top_label(vbi, pg, pg->font[0], idx++, i, VBI_BLACK, VBI_GREEN);
158 +                               }
159 +                               else if (idx == 2)
160 +                               {
161 +                                       top_label(vbi, pg, pg->font[0], idx++, i, VBI_BLACK, VBI_YELLOW);
162 +                               }
163 +                               break;
164                 }
165         }
166  }
167 @@ -2876,5 +2872,7 @@ vbi_fetch_vt_page(vbi_decoder *vbi, vbi_page *pg,
168  Local variables:
169  c-set-style: K&R
170  c-basic-offset: 8
171 +tab-width: 8
172 +indent-tabs-mode: t
173  End:
174  */
175 -- 
176 1.7.9.5
177