File: ncurses.c

package info (click to toggle)
groovycd 0.51-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 128 kB
  • ctags: 200
  • sloc: ansic: 1,818; makefile: 75
file content (91 lines) | stat: -rw-r--r-- 1,566 bytes parent folder | download | duplicates (2)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <string.h>

#include "gcd.h"
#include "numbers.h"

/* Miroslav Vasko (vasko@ies.sk) - 7 bit characters flag */
extern int ascii;               /* from main.c */

WINDOW *wbignums = NULL;

void print_number(int y, int x, char *s, int color)
{
   int i, z;
   
   if (wbignums == NULL)
     wbignums = newwin(5,80,0,0);
   
   if (ascii) bnums = bnums7;
   else bnums = bnums8;
   
   for (i=0; i<strlen(s); i++)
   {       
      switch(s[i])
      { 
        case ':':
          z = 10;
          break;
        case '-':
          z = 11;
          break;
        case ' ':
          z = 12;
          break;
        default:
          if (s[i] < '0' || s[i] > '9')
            continue;
          z = s[i] - '0';
          break;
      }

      wattrset(wbignums, color);
      mvwprintw(wbignums, y, x, bnums[z].li1);
      mvwprintw(wbignums, y+1, x, bnums[z].li2);
      mvwprintw(wbignums, y+2, x, bnums[z].li3);
      mvwprintw(wbignums, y+3, x, bnums[z].li4);
      
      x += 8;
   }
   
   wrefresh(wbignums);
}

void draw_line(int y, int x, int len)
{
   int i;
   char s[121];
   
   for (i=0; i<len; i++)
      s[i]=32;
   s[i]=0;
   
   mvaddstr(y,x,s);
   refresh();
} 


void center(int y, char *s)
{
   int x;
   
   x = 40-(strlen(s)/2);
   mvprintw(y,x,s);
   refresh();
}

void lite(int color, int y, char *s)
{
   attrset(color);
   draw_line(y, 20, 40);
   center(y, s);
}

void delite(int y, char *s)
{
   lite(COLOR_PAIR(C_BLACK)|A_BOLD, y, s);
}

void hilite(int y, char *s)
{
   lite(COLOR_PAIR(C_GREEN_HL)|A_BOLD, y, s);
}