add ncplane_cursor_y()/ncplane_cursor_x()

This commit is contained in:
nick black 2021-12-17 07:26:18 -05:00 committed by nick black
parent 189ed256f4
commit 041a083a0f
5 changed files with 46 additions and 1 deletions

View File

@ -1,7 +1,10 @@
This document attempts to list user-visible changes and any major internal This document attempts to list user-visible changes and any major internal
rearrangements of Notcurses. rearrangements of Notcurses.
* 3.0.1 (not yet released) * 3.0.2 (not yet released)
* Added `ncplane_cursor_y()` and `ncplane_cursor_x()`.
* 3.0.1 (2021-12-14)
* Added the `NCPLANE_OPTION_VSCROLL` flag. Creating an `ncplane` with this * Added the `NCPLANE_OPTION_VSCROLL` flag. Creating an `ncplane` with this
flag is equivalent to immediately calling `ncplane_set_scrolling(true)`. flag is equivalent to immediately calling `ncplane_set_scrolling(true)`.
* Added the `NCPLANE_OPTION_AUTOGROW` flag and the `ncplane_set_autogrow()` * Added the `NCPLANE_OPTION_AUTOGROW` flag and the `ncplane_set_autogrow()`

View File

@ -1262,6 +1262,20 @@ int ncplane_cursor_move_rel(struct ncplane* n, int y, int x);
// Get the current position of the cursor within n. y and/or x may be NULL. // Get the current position of the cursor within n. y and/or x may be NULL.
void ncplane_cursor_yx(const struct ncplane* n, int* restrict y, int* restrict x); void ncplane_cursor_yx(const struct ncplane* n, int* restrict y, int* restrict x);
static inline unsigned
ncplane_cursor_y(const struct ncplane* n){
unsigned y;
ncplane_cursor_yx(n, &y, NULL);
return y;
}
static inline unsigned
ncplane_cursor_x(const struct ncplane* n){
unsigned x;
ncplane_cursor_yx(n, NULL, &x);
return x;
}
// Replace the cell at the specified coordinates with the provided cell 'c', // Replace the cell at the specified coordinates with the provided cell 'c',
// and advance the cursor by the width of the cell (but not past the end of the // and advance the cursor by the width of the cell (but not past the end of the
// plane). On success, returns the number of columns the cursor was advanced. // plane). On success, returns the number of columns the cursor was advanced.

View File

@ -135,6 +135,10 @@ typedef struct ncplane_options {
**void ncplane_cursor_yx(const struct ncplane* ***n***, unsigned* restrict ***y***, unsigned* restrict ***x***);** **void ncplane_cursor_yx(const struct ncplane* ***n***, unsigned* restrict ***y***, unsigned* restrict ***x***);**
**unsigned ncplane_cursor_y(const struct ncplane* ***n***);**
**unsigned ncplane_cursor_x(const struct ncplane* ***n***);**
**void ncplane_translate(const struct ncplane* ***src***, const struct ncplane* ***dst***, int* restrict ***y***, int* restrict ***x***);** **void ncplane_translate(const struct ncplane* ***src***, const struct ncplane* ***dst***, int* restrict ***y***, int* restrict ***x***);**
**bool ncplane_translate_abs(const struct ncplane* ***n***, int* restrict ***y***, int* restrict ***x***);** **bool ncplane_translate_abs(const struct ncplane* ***n***, int* restrict ***y***, int* restrict ***x***);**

View File

@ -483,6 +483,16 @@ namespace ncpp
get_cursor_yx (&y, &x); get_cursor_yx (&y, &x);
} }
unsigned cursor_y() const noexcept
{
return ncplane_cursor_y(plane);
}
unsigned cursor_x() const noexcept
{
return ncplane_cursor_x(plane);
}
int putc (const Cell &c) const NOEXCEPT_MAYBE int putc (const Cell &c) const NOEXCEPT_MAYBE
{ {
return error_guard<int> (ncplane_putc (plane, c), -1); return error_guard<int> (ncplane_putc (plane, c), -1);

View File

@ -1981,6 +1981,20 @@ API void ncplane_home(struct ncplane* n)
API void ncplane_cursor_yx(const struct ncplane* n, unsigned* RESTRICT y, unsigned* RESTRICT x) API void ncplane_cursor_yx(const struct ncplane* n, unsigned* RESTRICT y, unsigned* RESTRICT x)
__attribute__ ((nonnull (1))); __attribute__ ((nonnull (1)));
static inline unsigned
ncplane_cursor_y(const struct ncplane* n){
unsigned y;
ncplane_cursor_yx(n, &y, NULL);
return y;
}
static inline unsigned
ncplane_cursor_x(const struct ncplane* n){
unsigned x;
ncplane_cursor_yx(n, NULL, &x);
return x;
}
// Get the current channels or attribute word for ncplane 'n'. // Get the current channels or attribute word for ncplane 'n'.
API uint64_t ncplane_channels(const struct ncplane* n) API uint64_t ncplane_channels(const struct ncplane* n)
__attribute__ ((nonnull (1))); __attribute__ ((nonnull (1)));