RichString.h 2.76 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 350
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

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

30
31
32
33
#ifdef HAVE_LIBNCURSESW
#include <wctype.h>
#endif

34
35
36
#define RichString_size(this) ((this)->chlen)
#define RichString_sizeVal(this) ((this).chlen)

37
38
#define RichString_begin(this) RichString (this); memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr;
#define RichString_beginAllocated(this) memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr;
39
#define RichString_end(this) RichString_prune(&(this));
40

41
#ifdef HAVE_LIBNCURSESW
42
43
44
#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)
45
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = (CharType) { .chars = { ch, 0 } }; } while(0)
46
#define CharType cchar_t
47
#else
48
49
50
51
52
#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
53
54
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
55
typedef struct RichString_ {
56
57
   int chlen;
   CharType* chptr;
Hisham Muhammad's avatar
Hisham Muhammad committed
58
   CharType chstr[RICHSTRING_MAXLEN+1];
Hisham Muhammad's avatar
Hisham Muhammad committed
59
60
61
} RichString;


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

Hisham Muhammad's avatar
Hisham Muhammad committed
64
#define RichString_setLen(this, len) do{ if(len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) { RichString_setChar(this,len,0); this->chlen=len; } else RichString_extendLen(this,len); }while(0)
Hisham Muhammad's avatar
Hisham Muhammad committed
65

66
#ifdef HAVE_LIBNCURSESW
Hisham Muhammad's avatar
Hisham Muhammad committed
67

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

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

#else

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

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

#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
79

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

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

84
85
86
void RichString_append(RichString* this, int attrs, const char* data);

void RichString_appendn(RichString* this, int attrs, const char* data, int len);
87

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

#endif