mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
[py] Split out fg and bg params to box().
This commit is contained in:
parent
9cdcd283d0
commit
f049b61b34
@ -13,22 +13,22 @@ BOX_CHARS = (
|
||||
nc.NCBOXROUND,
|
||||
)
|
||||
|
||||
CHANNELS = (
|
||||
0,
|
||||
0x0000000040808080, # default on grey
|
||||
0x40ff000000000000, # red on default
|
||||
0x4000ff00400000ff, # green on blue
|
||||
COLORS = (
|
||||
(0x00000000, 0x00000000),
|
||||
(0x00000000, 0x40808080), # default on grey
|
||||
(0x40ff0000, 0x00000000), # red on default
|
||||
(0x4000ff00, 0x400000ff), # green on blue
|
||||
)
|
||||
|
||||
SY = 7
|
||||
SX = 10
|
||||
|
||||
for y, channels in enumerate(CHANNELS):
|
||||
for y, (fg, bg) in enumerate(COLORS):
|
||||
for x, box_chars in enumerate(BOX_CHARS):
|
||||
nc.box(
|
||||
plane, (y + 1) * SY - 1, (x + 1) * SX - 1, y * SY + 1, x * SX + 1,
|
||||
box_chars,
|
||||
channels=channels,
|
||||
fg=fg, bg=bg,
|
||||
# ctlword=0x1f9
|
||||
)
|
||||
|
||||
|
@ -4,17 +4,16 @@
|
||||
#include "notcurses-python.h"
|
||||
|
||||
// TODO: function to construct channels: channel(None | pindex | color, alpha=0)
|
||||
// TODO: split channels into two args
|
||||
// TODO: perimeter version
|
||||
// TODO: rationalize coordinate / size args
|
||||
// TODO: provide a way to set channels for each corne
|
||||
// TODO: provide a way to set channels for each corner
|
||||
// TODO: docstring
|
||||
// TODO: test
|
||||
// TODO: unit test
|
||||
|
||||
static PyObject*
|
||||
pync_meth_box(PyObject* Py_UNUSED(self), PyObject* args, PyObject* kwargs) {
|
||||
static char* keywords[] = {
|
||||
"plane", "ystop", "xstop", "y", "x", "box_chars", "styles", "channels",
|
||||
"plane", "ystop", "xstop", "y", "x", "box_chars", "styles", "fg", "bg",
|
||||
"ctlword", NULL
|
||||
};
|
||||
NcPlaneObject* plane_arg;
|
||||
@ -24,20 +23,21 @@ pync_meth_box(PyObject* Py_UNUSED(self), PyObject* args, PyObject* kwargs) {
|
||||
int x = -1;
|
||||
const char* box_chars = NCBOXASCII;
|
||||
uint16_t styles = 0;
|
||||
uint64_t channels = 0;
|
||||
uint32_t fg = 0;
|
||||
uint32_t bg = 0;
|
||||
unsigned ctlword = 0;
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwargs, "O!II|iis$HKI:box", keywords,
|
||||
args, kwargs, "O!II|iis$HIII:box", keywords,
|
||||
&NcPlane_Type, &plane_arg,
|
||||
&ystop, &xstop, &y, &x, &box_chars, &styles, &channels, &ctlword))
|
||||
&ystop, &xstop, &y, &x, &box_chars, &styles, &fg, &bg, &ctlword))
|
||||
return NULL;
|
||||
|
||||
struct ncplane* const plane = plane_arg->ncplane_ptr;
|
||||
|
||||
if (!notcurses_canutf8(ncplane_notcurses(plane)))
|
||||
// No UTF-8 support; force ASCII.
|
||||
box_chars = NCBOXASCII;
|
||||
|
||||
struct ncplane* const plane = plane_arg->ncplane_ptr;
|
||||
|
||||
int ret;
|
||||
nccell ul = NCCELL_TRIVIAL_INITIALIZER;
|
||||
nccell ur = NCCELL_TRIVIAL_INITIALIZER;
|
||||
@ -45,6 +45,7 @@ pync_meth_box(PyObject* Py_UNUSED(self), PyObject* args, PyObject* kwargs) {
|
||||
nccell lr = NCCELL_TRIVIAL_INITIALIZER;
|
||||
nccell hl = NCCELL_TRIVIAL_INITIALIZER;
|
||||
nccell vl = NCCELL_TRIVIAL_INITIALIZER;
|
||||
uint64_t channels = (uint64_t) fg << 32 | bg;
|
||||
ret = nccells_load_box(
|
||||
plane, styles, channels, &ul, &ur, &ll, &lr, &hl, &vl, box_chars);
|
||||
if (ret == -1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user