RichString.h 2.38 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
30
31
32
#define RichString_size(this) ((this)->chlen)
#define RichString_sizeVal(this) ((this).chlen)

#define RichString_begin(this) RichString (this); (this).chlen = 0; (this).chptr = (this).chstr;
#define RichString_beginAllocated(this) (this).chlen = 0; (this).chptr = (this).chstr;
#define RichString_end(this) RichString_prune(&(this));
33

34
#ifdef HAVE_LIBNCURSESW
35
36
37
38
39
#define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr)
#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + off, n)
#define RichString_getCharVal(this, i) ((this).chptr[i].chars[0] & 255)
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)].chars[0] = ch; } while(0)
#define CharType cchar_t
40
#else
41
42
43
44
45
#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr)
#define RichString_printoffnVal(this, y, x, off, n) mvaddchnstr(y, x, (this).chptr + off, n)
#define RichString_getCharVal(this, i) ((this).chptr[i])
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = ch; } while(0)
#define CharType chtype
46
47
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
48
typedef struct RichString_ {
49
50
51
   int chlen;
   CharType chstr[RICHSTRING_MAXLEN+1];
   CharType* chptr;
Hisham Muhammad's avatar
Hisham Muhammad committed
52
53
54
} RichString;


Hisham Muhammad's avatar
Hisham Muhammad committed
55
56
57
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
58

59
60
#define charBytes(n) (sizeof(CharType) * (n)) 

61
#ifdef HAVE_LIBNCURSESW
Hisham Muhammad's avatar
Hisham Muhammad committed
62

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

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

67
int RichString_findChar(RichString* this, char c, int start);
68
69
70

#else

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

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

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

#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
78

Hisham Muhammad's avatar
Hisham Muhammad committed
79
80
void RichString_prune(RichString* this);

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

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

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

#endif