File: term_curses.c

package info (click to toggle)
cpmtools 2.23-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,092 kB
  • sloc: ansic: 5,471; sh: 3,394; makefile: 107
file content (88 lines) | stat: -rw-r--r-- 1,199 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
/* #includes */ /*{{{C}}}*//*{{{*/
#include "config.h"

#include <assert.h>
#include <ctype.h>
#ifdef NEED_NCURSES
#ifdef HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif
#else
#include <curses.h>
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "term.h"
/*}}}*/

void term_init(void) /*{{{*/
{
  initscr();
  noecho();
  raw();
  nonl();
  idlok(stdscr,TRUE);
  idcok(stdscr,TRUE);
  keypad(stdscr,TRUE);
  clear();
}
/*}}}*/
void term_exit(void) /*{{{*/
{
  move(LINES-1,0);
  refresh();
  echo();
  noraw();
  endwin();
}
/*}}}*/
void term_clear(void) /*{{{*/
{
  clear();
}
/*}}}*/
void term_xy(int x, int y) /*{{{*/
{
  move(y,x);
}
/*}}}*/
void term_printf(char const *fmt, ...) /*{{{*/
{
  va_list ap;

  va_start(ap, fmt);
  vw_printw(stdscr, fmt, ap);
  va_end(ap);
}
/*}}}*/
void term_putch(char ch) /*{{{*/
{
  addch(ch);
}
/*}}}*/
int term_getch(void) /*{{{*/
{
  return getch();
}
/*}}}*/
void term_reverse(int on) /*{{{*/
{
  if (on) attron(A_REVERSE);
  else attroff(A_REVERSE);
}
/*}}}*/
int term_lines(void) /*{{{*/
{
  return LINES;
}
/*}}}*/
int term_cols(void) /*{{{*/
{
  return COLS;
}
/*}}}*/