Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
79857249
Commit
79857249
authored
Aug 27, 2015
by
Hisham Muhammad
Browse files
Fixes for color glitches in ncurses ABI6.
Could no longer reproduce #244 after these fixes.
parent
bdadd45a
Changes
2
Show whitespace changes
Inline
Side-by-side
RichString.c
View file @
79857249
...
...
@@ -44,7 +44,7 @@ in the source distribution for its full text.
#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 RichString_setChar(this, at, ch) do{ (this)->chptr[(at)]
= (CharType) { .chars = { ch, 0 } }
; } while(0)
#define CharType cchar_t
#else
#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr)
...
...
@@ -71,16 +71,16 @@ typedef struct RichString_ {
static
void
RichString_extendLen
(
RichString
*
this
,
int
len
)
{
if
(
this
->
chlen
<=
RICHSTRING_MAXLEN
)
{
if
(
len
>
RICHSTRING_MAXLEN
)
{
this
->
chptr
=
malloc
(
charBytes
(
len
+
1
));
memcpy
(
this
->
chptr
,
this
->
chstr
,
charBytes
(
this
->
chlen
+
1
));
this
->
chptr
=
malloc
(
charBytes
(
len
+
1
));
memcpy
(
this
->
chptr
,
this
->
chstr
,
charBytes
(
this
->
chlen
));
}
}
else
{
if
(
len
<=
RICHSTRING_MAXLEN
)
{
memcpy
(
this
->
chstr
,
this
->
chptr
,
charBytes
(
this
->
ch
len
));
memcpy
(
this
->
chstr
,
this
->
chptr
,
charBytes
(
len
));
free
(
this
->
chptr
);
this
->
chptr
=
this
->
chstr
;
}
else
{
this
->
chptr
=
realloc
(
this
->
chptr
,
charBytes
(
len
+
1
));
this
->
chptr
=
realloc
(
this
->
chptr
,
charBytes
(
len
+
1
));
}
}
...
...
@@ -95,17 +95,14 @@ static void RichString_extendLen(RichString* this, int len) {
static
inline
void
RichString_writeFrom
(
RichString
*
this
,
int
attrs
,
const
char
*
data_c
,
int
from
,
int
len
)
{
wchar_t
data
[
len
+
1
];
len
=
mbstowcs
(
data
,
data_c
,
len
);
if
(
len
<
0
)
if
(
len
<
0
)
return
;
int
newLen
=
from
+
len
;
RichString_setLen
(
this
,
newLen
);
for
(
int
i
=
from
,
j
=
0
;
i
<
newLen
;
i
++
,
j
++
)
{
CharType
*
c
=
&
(
this
->
chptr
[
i
]);
c
->
attr
=
attrs
;
c
->
chars
[
0
]
=
(
iswprint
(
data
[
j
])
?
data
[
j
]
:
'?'
);
c
->
chars
[
1
]
=
0
;
*
c
=
(
CharType
)
{
.
attr
=
attrs
,
.
chars
=
{
(
iswprint
(
data
[
j
])
?
data
[
j
]
:
'?'
)
}
};
}
this
->
chptr
[
newLen
].
chars
[
0
]
=
0
;
}
inline
void
RichString_setAttrn
(
RichString
*
this
,
int
attrs
,
int
start
,
int
finish
)
{
...
...
RichString.h
View file @
79857249
...
...
@@ -42,7 +42,7 @@ in the source distribution for its full text.
#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 RichString_setChar(this, at, ch) do{ (this)->chptr[(at)]
= (CharType) { .chars = { ch, 0 } }
; } while(0)
#define CharType cchar_t
#else
#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment