RichString.h 1.99 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
/* Do not edit this file. It was automatically generated. */
Hisham Muhammad's avatar
Hisham Muhammad committed
2
3
4
5
6

#ifndef HEADER_RichString
#define HEADER_RichString


7
8
9
10
11
#ifndef CONFIG_H
#define CONFIG_H
#include "config.h"
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
12
13
#include <stdlib.h>
#include <string.h>
14
#include <ctype.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
15
16
17

#include "debug.h"
#include <assert.h>
18
#ifdef HAVE_LIBNCURSESW
Hisham Muhammad's avatar
Hisham Muhammad committed
19
#include <ncursesw/curses.h>
20
21
#else
#include <curses.h>
22
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
23
24
25
26

#define RICHSTRING_MAXLEN 300


27
28
29
#define RichString_init(this) (this)->len = 0
#define RichString_initVal(this) (this).len = 0

30
31
32
33
34
35
36
37
38
39
#ifdef HAVE_LIBNCURSESW
#define RichString_printVal(this, y, x) mvadd_wchstr(y, x, this.chstr)
#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, this.chstr + off, n)
#define RichString_getCharVal(this, i) (this.chstr[i].chars[0] & 255)
#else
#define RichString_printVal(this, y, x) mvaddchstr(y, x, this.chstr)
#define RichString_printoffnVal(this, y, x, off, n) mvaddchnstr(y, x, this.chstr + off, n)
#define RichString_getCharVal(this, i) (this.chstr[i])
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
40
41
typedef struct RichString_ {
   int len;
42
43
44
#ifdef HAVE_LIBNCURSESW
   cchar_t chstr[RICHSTRING_MAXLEN+1];
#else
Hisham Muhammad's avatar
Hisham Muhammad committed
45
   chtype chstr[RICHSTRING_MAXLEN+1];
46
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
47
48
49
} RichString;


Hisham Muhammad's avatar
Hisham Muhammad committed
50
51
52
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
53

54
#ifdef HAVE_LIBNCURSESW
Hisham Muhammad's avatar
Hisham Muhammad committed
55

Hisham Muhammad's avatar
Hisham Muhammad committed
56
extern void RichString_appendn(RichString* this, int attrs, const char* data_c, int len);
Hisham Muhammad's avatar
Hisham Muhammad committed
57

58
59
60
61
62
63
extern void RichString_setAttrn(RichString *this, int attrs, int start, int finish);

int RichString_findChar(RichString *this, char c, int start);

#else

Hisham Muhammad's avatar
Hisham Muhammad committed
64
extern void RichString_appendn(RichString* this, int attrs, const char* data_c, int len);
65
66
67
68
69
70

void RichString_setAttrn(RichString *this, int attrs, int start, int finish);

int RichString_findChar(RichString *this, char c, int start);

#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
71

Hisham Muhammad's avatar
Hisham Muhammad committed
72
73
void RichString_prune(RichString* this);

Hisham Muhammad's avatar
Hisham Muhammad committed
74
75
void RichString_setAttr(RichString *this, int attrs);

Hisham Muhammad's avatar
Hisham Muhammad committed
76
extern void RichString_append(RichString* this, int attrs, const char* data);
77

Hisham Muhammad's avatar
Hisham Muhammad committed
78
void RichString_write(RichString* this, int attrs, const char* data);
Hisham Muhammad's avatar
Hisham Muhammad committed
79

Hisham Muhammad's avatar
Hisham Muhammad committed
80
RichString RichString_quickString(int attrs, const char* data);
Hisham Muhammad's avatar
Hisham Muhammad committed
81
82

#endif