Closed joseluis closed 2 years ago
ack! looking into this ASAP.
Ok I've updated the example.
:%016x
only printed the first 4 bytes, so It's necessary to use :%016llx
to print the full 8 bytes.ncchannels_set_[bg]channel
functions in notcurses.h doesn't work correctly, but when copy pasting the same functions to the current file they does seem to work !!! I'm puzzled by this:#include <notcurses/notcurses.h>
// 0 OLD FUNCTIONS COPIED
static inline uint64_t
ncchannels_set_bchannel0(uint64_t* channels, uint32_t channel){
return *channels = (*channels & 0xffffffff00000000llu) | channel;
}
static inline uint64_t
ncchannels_set_fchannel0(uint64_t* channels, uint32_t channel){
return *channels = (*channels & 0xfffffffflu) | ((uint64_t)channel << 32u);
}
// 1 ... (current functions called from notcurses.h)
// 2 CURRENT FUNCTIONS COPIED from notcurses.h
static inline uint64_t
ncchannels_set_bchannel2(uint64_t* channels, uint32_t channel){
// drop the background color and alpha bit
*channels &= ((0xffffffffllu << 32u) | NC_NOBACKGROUND_MASK);
*channels |= (uint32_t)(channel & ~NC_NOBACKGROUND_MASK);
return *channels;
}
static inline uint64_t
ncchannels_set_fchannel2(uint64_t* channels, uint32_t channel){
// drop the foreground color and alpha bit
*channels &= (0xffffffffllu | ((uint64_t)NC_NOBACKGROUND_MASK << 32u));
*channels |= (uint64_t)(channel & ~NC_NOBACKGROUND_MASK) << 32u;
return *channels;
}
int main(void){
uint64_t orig0 = 0x6677777788999999ull; // for old functions
uint64_t orig1 = 0x6677777788999999ull; // for current functions
uint64_t orig2 = 0x6677777788999999ull; // for current functions, copied
fprintf(stderr, "starting fg+bg: 0x%016llx\n", orig0);
uint32_t bc = 0x112233;
uint32_t fc = 0x445566;
fprintf(stderr, "new set values: fg:0x%08x bg:0x%08x \n", fc, bc);
fprintf(stderr, "\nusing old functions (from jan) copied to this file\n");
ncchannels_set_fchannel0(&orig0, fc);
fprintf(stderr, "- %016llx updated fg\n", orig0);
ncchannels_set_bchannel0(&orig0, bc);
fprintf(stderr, "- %016llx updated bg\n", orig0);
fprintf(stderr, "\nusing current functions in notcurses.h\n");
ncchannels_set_fchannel(&orig1, fc);
fprintf(stderr, "- %016llx updated fg\n", orig1);
ncchannels_set_bchannel(&orig1, bc);
fprintf(stderr, "- %016llx updated bg\n", orig1);
fprintf(stderr, "\nusing the same current functions COPIED to this file\n");
ncchannels_set_fchannel2(&orig2, fc);
fprintf(stderr, "- %016llx updated fg\n", orig2);
ncchannels_set_bchannel2(&orig2, bc);
fprintf(stderr, "- %016llx updated bg\n", orig2);
}
starting fg+bg: 0x6677777788999999
new set values: fg:0x00445566 bg:0x00112233
using the old functions (from jan) copied to this file
- 0044556688999999 updated fg
- 0044556600112233 updated bg
using the current functions in notcurses.h
- 0000000000445566 updated fg
- 0000000000112233 updated bg
using the same current functions COPIED to this file
- 0044556688999999 updated fg
- 0044556600112233 updated bg
ok looking into this now
[schwarzgerat](0) $ ./jose
starting fg+bg: 0x6677777788999999
new set values: fg:0x00445566 bg:0x00112233
using old functions (from jan) copied to this file
- 0044556688999999 updated fg
- 0044556600112233 updated bg
using current functions in notcurses.h
- 0044556688999999 updated fg
- 0044556600112233 updated bg
using the same current functions COPIED to this file
- 0044556688999999 updated fg
- 0044556600112233 updated bg
[schwarzgerat](0) $
so i get a different result for "using current functions in notcurses.h"; i get the same results there as i do in "current functions COPIED to this file", whereas you have a different value there. hrmmm.
Uff. It turns out the notcurses C folder was corrupted with a lot of dangling commits :S. I had to delete it and clone the repo again and now the example works fine. Sorry for that!!
no problem mang, just glad to know it's working =]
I was updating the libnotcurses-sys library from compatibility with nc
v3.0.5
tov3.0.7
, and more specifically all the updates to the static channel functions, and I noticed multiple related Rust tests failing. I started to recreate them in C and made this minimal failing example: