我编写代码从 xmltv 列表中提取数据并将它们显示在 15 行的 osd 页面中。 如何在页面中逐行向上和向下滚动,直到每个 channel 的列表信息结束,然后它们移动到显示另一个 channel 信息的下一页?
channel 1:
| line1 | | line2 | |-----------|
| line2 | | line3 | |-----------|
| line3 | scroll down line => | line4 | then clear => | lastline |
| line4 | |-----------| | |
|-----------| | line15 | | |
| line15 | | line16 | | |
然后移动到 => channel 2:
| line1 | | line2 | |-----------|
| line2 | | line3 | |-----------|
| line3 | scroll down line => | line4 | then clear => | lastline |
| line4 | |-----------| | |
|-----------| | line15 | | |
| line15 | | line16 | | |
等等
代码:
int epg_show_perchannel( tvtime_osd_t* osd, int page, station_mgr_t *stationmgr, xmltv_t *xmltv, int channel )
{
if (!page)
return 0;
if ( xmltv ){
const int buf_length = 255;
const int max_num_lines = 15;
const int num_stations = station_get_num_stations( stationmgr );
char *old_channel = strdup( xmltv_get_channel( xmltv ) );
char buf[buf_length+1];
int i, cur = 0;
time_t curtime = time( 0 );
const char *xmltv_id = 0;
if (channel > num_stations)
channel = 1;
else if (channel < 1 )
channel = num_stations;
if (!(xmltv_id = station_get_xmltv_id( stationmgr, channel-1 )))
xmltv_id = xmltv_lookup_channel( xmltv, station_get_name( stationmgr, channel-1 ));
xmltv_set_channel( xmltv, xmltv_id);
xmltv_refresh_withtime( xmltv, curtime );
/* Header with channel number + name */
snprintf(buf, buf_length, "%d Next on [%s] %s:", channel, station_get_channel(stationmgr,channel-1), station_get_name( stationmgr, channel-1));
tvtime_osd_list_set_text( osd, cur++, buf );
tvtime_osd_list_set_hilight(osd, -1);
for( i = 0; i < max_num_lines; i++ ) {
xmltv_refresh_withtime( xmltv, curtime );
if (xmltv_get_title( xmltv )) {
char start_time[50];
time_t start_timestamp = xmltv_get_start_time( xmltv );
time_t end_timestamp = xmltv_get_end_time( xmltv );
strftime( start_time, 50, "%H:%M", localtime( &start_timestamp ) );
/* starttime of current program + Now showing program */
snprintf(buf, buf_length, "%s %s", start_time, xmltv_get_title( xmltv ));
if (xmltv_get_sub_title( xmltv )){
strncat(buf," (",buf_length-strlen(buf));
strncat(buf,xmltv_get_sub_title( xmltv ),buf_length-strlen(buf));
strncat(buf,")",buf_length-strlen(buf));
}
tvtime_osd_list_set_multitext( osd, cur++, buf, 1);
if (!xmltv_get_next_title( xmltv )) {
char end_time[50];
/* no next program, print endtime of current programme */
strftime( end_time, 50, "%H:%M", localtime( &end_timestamp ) );
snprintf(buf, buf_length, "%s %s", end_time, "");
tvtime_osd_list_set_multitext( osd, cur++, buf, 1);
}
curtime = end_timestamp;
} else {
/* No XMLTV information for this channel */
tvtime_osd_list_set_text( osd, cur++, "");
}
}
tvtime_osd_list_set_lines( osd, cur );
tvtime_osd_show_list( osd, 1, 1 );
xmltv_set_channel(xmltv, old_channel);
free(old_channel);
xmltv_refresh( xmltv );
} else {
tvtime_osd_list_set_text( osd, 0, "No XMLTV information available" );
tvtime_osd_list_set_lines( osd, 1 );
tvtime_osd_show_list( osd, 1, 1 );
}
return channel;
}
代码,当前显示页面只有15行,然后转到下一个 channel 。
我想向下滚动列表直到来自 xmltv channel 列表的信息结束(包含 3-4 天的信息),然后移动到下一个 channel :
最佳答案
评论中提到的应用程序在 终端 上进行滚动(可能带有终端转义序列),但您似乎是在使用一些特殊的 API 来显示文本,而这在 cleary 没有的东西上看起来像一个终端,所以我猜这种方法行不通。
你应该重新创建文本,也许你必须删除以前的文本,老实说我不知道......检查文档。
关于c - 在c中逐行(从缓冲区)上下滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9358313/