mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-04 06:00:30 +00:00
notcurses_align: return error on negative column count
This commit is contained in:
parent
df8ee463c4
commit
e6bc09084c
@ -1300,6 +1300,9 @@ API void ncplane_center_abs(const struct ncplane* n, int* RESTRICT y,
|
||||
// requirements of 'align'.
|
||||
static inline int
|
||||
notcurses_align(int availcols, ncalign_e align, int cols){
|
||||
if(cols < 0){
|
||||
return -INT_MAX;
|
||||
}
|
||||
if(align == NCALIGN_LEFT){
|
||||
return 0;
|
||||
}
|
||||
@ -1488,6 +1491,9 @@ ncplane_putwstr_aligned(struct ncplane* n, int y, ncalign_e align,
|
||||
const wchar_t* gclustarr){
|
||||
int width = wcswidth(gclustarr, INT_MAX);
|
||||
int xpos = ncplane_align(n, align, width);
|
||||
if(xpos < 0){
|
||||
return -1;
|
||||
}
|
||||
return ncplane_putwstr_yx(n, y, xpos, gclustarr);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,9 @@ TEST_CASE("Fade") {
|
||||
ts.tv_nsec = 75000000;
|
||||
ncplane_erase(n_);
|
||||
ncplane_set_fg_rgb(n_, 0xffd700);
|
||||
CHECK(0 < ncplane_printf_aligned(n_, dimy - 1, NCALIGN_LEFT, "pulllllllse"));
|
||||
CHECK(0 < ncplane_printf_aligned(n_, dimy - 1, NCALIGN_CENTER, "pulllllllse"));
|
||||
CHECK(0 < ncplane_printf_aligned(n_, dimy - 1, NCALIGN_RIGHT, "pulllllllse"));
|
||||
struct timespec pulsestart;
|
||||
clock_gettime(CLOCK_MONOTONIC, &pulsestart);
|
||||
CHECK(0 < ncplane_pulse(n_, &ts, pulser, &pulsestart));
|
||||
|
Loading…
Reference in New Issue
Block a user