aboutsummaryrefslogtreecommitdiffstats
path: root/Text.c
blob: fc3ba33c040b46a4e39ffd845c0a45e6524db685 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
linuxtv-dvb-apps-1.?
======================

Linux DVB API applications and utilities.

All applications support the DVB-S, DVB-C, DVB-T, and ATSC standards.

Main User Applications:
util/scan	- Scan for channels on your digital TV device.
util/gnutv	- Tune, watch and stream your TV.

General Utilities:
util/dvbdate	- Set your clock from digital TV.
util/dvbnet	- Control digital data network interfaces.
util/dvbtraffic	- Monitor traffic on a digital device.
util/femon	- Monitor the tuning on a digital TV device.
util/zap	- *Just* tunes a digital device - really intended for developers.
util/gotox	- Simple Rotor control utility
util/alevt	- Teletext capture and display utility

Hardware Specific Utilities:
util/av7110_loadkeys	- Load remote keys into an av7110 based card
util/dib3000-watch	- Monitor DIB3000 demodulators
util/dst-utils		- Utilities for DST based cards.
util/ttusb_dec_reset	- Reset a TechnoTrends TTUSB DEC device.

Libraries:
lib/libdvbapi	- Interface library to digital TV devices.
lib/libdvbcfg	- Library to parse/create digital TV channel configuration files.
lib/libdvbsec	- Library for Satellite Equipment Control operations.
lib/libucsi	- Fast MPEG2 Transport Stream SI table parsing library.
lib/libdvben50221- Complete implementation of a Cenelec EN 50221 CAM stack.
lib/libdvbmisc	- Miscellaneous utilities used by the other libraries.

Various testing applications also live in test.

For convenience, dvb-apps contains a copy of the DVB API include
files as they are contained in the linuxtv-dvb-1.? release
and the 2.6.x Linux kernel.

AleVT is not compiled by the main Makefile, because it depends on external
libraries which might not be available in your system (see util/alevt/README for
details). If you have the required libraries, to compile AleVT go to util/alevt/
and type "make".

Johannes Stezenbach <js@convergence.de>
Andrew de Quincey <adq_dvb@lidskialf.net>
/* $Id: Text.c,v 1.12 2003/10/05 17:58:50 reinelt Exp $
 *
 * pure ncurses based text driver
 *
 * Copyright 2001 Leopold T�tsch <lt@toetsch.at>
 *
 * This file is part of LCD4Linux.
 *
 * LCD4Linux is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * LCD4Linux is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 * $Log: Text.c,v $
 * Revision 1.12  2003/10/05 17:58:50  reinelt
 * libtool junk; copyright messages cleaned up
 *
 * Revision 1.11  2003/09/13 06:45:43  reinelt
 * icons for all remaining drivers
 *
 * Revision 1.10  2003/08/24 05:17:58  reinelt
 * liblcd4linux patch from Patrick Schemitz
 *
 * Revision 1.9  2003/07/24 04:48:09  reinelt
 * 'soft clear' needed for virtual rows
 *
 * Revision 1.8  2003/02/22 07:53:10  reinelt
 * cfg_get(key,defval)
 *
 * Revision 1.7  2003/02/17 04:27:58  reinelt
 * Text (curses) driver: cosmetic changes
 *
 * Revision 1.6  2002/08/30 03:54:01  reinelt
 * bug in curses driver fixed
 *
 * Revision 1.5  2002/08/19 04:41:20  reinelt
 * introduced bar.c, moved bar stuff from display.h to bar.h
 *
 * Revision 1.4  2001/03/16 16:40:17  ltoetsch
 * implemented time bar
 *
 * Revision 1.3  2001/03/16 09:28:08  ltoetsch
 * bugfixes
 *
 * Revision 1.2  2001/03/09 15:04:53  reinelt
 *
 * rename 'raster' to 'Text in Text.c
 * added TOTO item
 *
 * Revision 1.1  2001/03/09 13:08:11  ltoetsch
 * Added Text driver
 *
 *
 */

/* 
 *
 * exported fuctions:
 *
 * struct LCD Text[]
 *
 */

#include <stdlib.h>
#include <stdio.h>
#include <curses.h>

#define min(x,y) (x)<(y)?x:y


#ifdef STANDALONE

int main(int argc, char *argv[]) 
{
  WINDOW *w;
  int x,y;
  
  w = initscr();
  
  for (x=0; x < 255; x++)
    addch(acs_map[x]);    
  refresh();
  sleep(5);
  endwin();
  return 0;
  
}

#else

#include <string.h>
#include "debug.h"
#include "cfg.h"
#include "display.h"
#include "bar.h"

extern int running_foreground;

static LCD Lcd;
static WINDOW *w, *err_win;
static int err_rows;


int Text_clear (int full)
{
  if (full) {
    werase(w);
    box(w, 0, 0);
  }
  return 0;
}


int Text_quit(void) {
  endwin();
  return 0;
}


int Text_init (LCD *Self)
{
  int cols=-1, rows=-1;
  int scr_cols, scr_rows;
  char *s;
  if (!running_foreground) {
    error("Text: you want me to display on /dev/null: sorry, I can't");
    error("Text: Maybe you want me to run in foreground? Try '-F'");
    return -1;
  }
  
  if (sscanf(s=cfg_get("size","20x4"), "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) {
    error ("Text: bad size '%s'", s);
    return -1;
  }
  Self->rows=rows;
  Self->cols=cols;
  Self->xres=1;
  Self->yres=1;
  Lcd=*Self;
  
  initscr();
  scr_cols=COLS;
  scr_rows=LINES;
  debug ("curses thinks that COLS=%d LINES=%d", COLS, LINES);
  w = newwin(rows+2,cols+2,0,0);
  err_rows = scr_rows-rows-3;
  err_rows = min(99, err_rows);
  debug ("err_rows=%d", err_rows);
  if (err_rows >= 4) {
    err_win = newwin(err_rows, scr_cols, rows+3, 0);
    err_rows -= 3;
    box(err_win, 0, 0);
    mvwprintw(err_win,0,3, "Stderr:");
    wmove(err_win, 1 , 0);
    wrefresh(err_win);
  }
  Text_clear(1);
  return w ? 0 : -1;
}


/* ncures scroll SIGSEGVs on my system, so this is a workaroud */

int curs_err(char *buffer) 
{
  static int lines;
  static char *lb[100];
  int start, i;
  char *p;
  
  if (err_win) {
    /* replace \r, \n with underscores */
    while ((p = strpbrk(buffer, "\r\n")) != NULL)
      *p='_';
    if (lines >= err_rows) {
      free(lb[0]);
      for (i=1; i<=err_rows; i++) 
	lb[i-1] = lb[i];
      start = 0;
    }
    else
      start = lines;
    lb[lines] = strdup(buffer);
    for (i=start; i<=lines; i++) {
      mvwprintw(err_win,i+1,1, "%s", lb[i]);
      wclrtoeol(err_win);
    }
    box(err_win, 0, 0);
    mvwprintw(err_win,0,3, "Stderr:");
    wrefresh(err_win);
    if (lines < err_rows)
      lines++;
    return 1;
  }
  return 0;
}


int Text_put (int row, int col, char *text)
{
  char *p;
  
  while ((p = strpbrk(text, "\r\n")) != NULL) {
    *p='\0';
  }
  if (col < Lcd.cols) {
    mvwprintw(w, row+1 , col+1, "%.*s", Lcd.cols-col, text);
  }
  return 0;
}


int Text_bar (int type, int row, int col, int max, int len1, int len2)
{
  int len, i;
  if (cfg_get("TextBar", NULL)) 
    mvwprintw(w, row+1 , col+1, "%d %d %d", max, len1, len2);
  else {
    len = min(len1, len2);
    len = min(len, Lcd.cols-col-1);
    if (len) {
      wmove(w, row+1 , col+1);
      for (i=0; i<len;i++)
        waddch(w,ACS_BLOCK);
    }
    col += len;
    len1 -= len;
    len2 -= len;
    len1 = min(len1, Lcd.cols-col-1);
    for (i=0; i<len1;i++)
      waddch(w,ACS_S1);
    len2 = min(len2, Lcd.cols-col-1);
    for (i=0; i<len2;i++)
      waddch(w,ACS_S9);
  }
  
  return 0;
}


int Text_flush (void)
{
  box(w, 0, 0);
  wrefresh(w);  
  return 0;
}


LCD Text[] = {
  { name: "Text",
    rows:  4,
    cols:  20,
    xres:  1,
    yres:  1,
    bars:  BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2,
    icons: 0,
    gpos:  0,
    init:  Text_init,
    clear: Text_clear,
    put:   Text_put,
    bar:   Text_bar,
    icon:  NULL,
    gpo:   NULL,
    flush: Text_flush,
    quit:  Text_quit 
  },
  { NULL }
};

#endif