RichString.h 2.57 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

#ifndef HEADER_RichString
#define HEADER_RichString
Hisham Muhammad's avatar
Hisham Muhammad committed
5
6
7
8
9
10
/*
htop - RichString.h
(C) 2004,2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
Hisham Muhammad's avatar
Hisham Muhammad committed
11

Hisham Muhammad's avatar
Hisham Muhammad committed
12
#define RICHSTRING_MAXLEN 300
Hisham Muhammad's avatar
Hisham Muhammad committed
13

14
#include "config.h"
15
#include <ctype.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
16
17
18

#include "debug.h"
#include <assert.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
19
#ifdef HAVE_NCURSESW_CURSES_H
20
21
22
#include <ncursesw/curses.h>
#elif HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
23
24
25
26
#elif HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_CURSES_H
#include <curses.h>
27
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
28

29
30
31
32
33
34
#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));
35

36
#ifdef HAVE_LIBNCURSESW
37
38
39
40
41
#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
42
#else
43
44
45
46
47
#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
48
49
#endif

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


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

61
62
#define charBytes(n) (sizeof(CharType) * (n)) 

63
#ifdef HAVE_LIBNCURSESW
Hisham Muhammad's avatar
Hisham Muhammad committed
64

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

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

69
int RichString_findChar(RichString* this, char c, int start);
70
71
72

#else

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

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

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

#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
80

Hisham Muhammad's avatar
Hisham Muhammad committed
81
82
void RichString_prune(RichString* this);

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

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

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

#endif