Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] A hodgepodge of tiny changes #1146

Merged
merged 1 commit into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -601,23 +601,47 @@ include(CMakePackageConfigHelpers)
configure_file(tools/version.h.in include/version.h)
configure_file(tools/builddef.h.in include/builddef.h)

configure_package_config_file(tools/NotcursesConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NotcursesConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/notcurses/cmake
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/NotcursesConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/Notcurses++ConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)

# Installation
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/NotcursesConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/NotcursesConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Notcurses"
)

install(TARGETS notcurses
EXPORT "NotcursesTargets"
)

install(EXPORT "NotcursesTargets"
NAMESPACE "notcurses::"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Notcurses"
FILE "NotcursesConfig.cmake"
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/Notcurses++ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Notcurses++"
)

install(TARGETS notcurses++
EXPORT "Notcurses++Targets"
)

install(EXPORT "Notcurses++Targets"
NAMESPACE "notcurses++::"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Notcurses++"
FILE "Notcurses++Config.cmake"
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/notcurses.pc
DESTINATION ${PKGCONFIG_DIR}
Expand Down
6 changes: 3 additions & 3 deletions doc/man/man3/notcurses_cell.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ typedef struct cell {

**unsigned cell_styles(const cell* ***c***);**

**void cell_styles_on(cell* ***c***, unsigned ***stylebits***);**
**void cell_on_styles(cell* ***c***, unsigned ***stylebits***);**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. I'd rather switch cell_{on, off}_styles in the actual API to match ncplane_styles_*, but Allah, the All-Powerful, has fucked us once again. Guess I just missed this in 2.0 API review. Bah! Thanks a lot for this find.

I'm going to go ahead and fix it in USAGE.md as well.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it in USAGE.md. cell_load_char() was already correct there.


**void cell_styles_off(cell* ***c***, unsigned ***stylebits***);**
**void cell_off_styles(cell* ***c***, unsigned ***stylebits***);**

**void cell_set_fg_default(cell* ***c***);**

Expand All @@ -74,7 +74,7 @@ typedef struct cell {

**char* cell_strdup(const struct ncplane* ***n***, const cell* ***c***);**

**int cell_load_simple(struct ncplane* ***n***, cell* ***c***, char ***ch***);**
**int cell_load_char(struct ncplane* ***n***, cell* ***c***, char ***ch***);**

**char* cell_extract(const struct ncplane* ***n***, const cell* ***c***, uint16_t* ***stylemask***, uint64_t* ***channels***);**

Expand Down
61 changes: 45 additions & 16 deletions include/ncpp/Plane.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ namespace ncpp
plane = create_plane (*n, rows, cols, yoff, xoff, opaque);
}

explicit Plane (Plane *n, ncplane_options const& nopts, NotCurses *ncinst = nullptr)
: Plane (static_cast<const Plane*>(n), nopts, ncinst)
{}

explicit Plane (const Plane *n, ncplane_options const& nopts, NotCurses *ncinst = nullptr)
: Root (ncinst)
{
if (n == nullptr) {
throw invalid_argument ("'n' must be a valid pointer");
}

plane = create_plane (*n, nopts);
}

explicit Plane (const Plane &n, int rows, int cols, int yoff, int xoff, void *opaque = nullptr)
: Root (nullptr)
{
Expand All @@ -69,7 +83,7 @@ namespace ncpp
explicit Plane (int rows, int cols, int yoff, int xoff, void *opaque = nullptr, NotCurses *ncinst = nullptr)
: Root (ncinst)
{
struct ncplane_options nopts = {
ncplane_options nopts = {
.y = yoff,
.x = xoff,
.rows = rows,
Expand Down Expand Up @@ -102,6 +116,16 @@ namespace ncpp
plane = create_plane (const_cast<Plane&>(n), rows, cols, yoff, align, opaque);
}

explicit Plane (Plane &n, ncplane_options const& nopts, NotCurses *ncinst = nullptr)
: Plane (static_cast<Plane const&>(n), nopts, ncinst)
{}

explicit Plane (Plane const& n, ncplane_options const& nopts, NotCurses *ncinst = nullptr)
: Root (ncinst)
{
plane = create_plane (n, nopts);
}

explicit Plane (Plane *n, int rows, int cols, int yoff, NCAlign align, void *opaque = nullptr)
: Root (nullptr)
{
Expand Down Expand Up @@ -1130,6 +1154,16 @@ namespace ncpp
return error_guard (ncplane_rotate_ccw (plane), -1);
}

char* strdup (Cell const& cell) const noexcept
{
return cell_strdup (plane, cell);
}

char* extract (Cell const& cell, uint16_t *stylemask = nullptr, uint64_t *channels = nullptr)
{
return cell_extract (plane, cell, stylemask, channels);
}

const char* get_extended_gcluster (Cell &cell) const noexcept
{
return cell_extended_gcluster (plane, cell);
Expand Down Expand Up @@ -1227,27 +1261,17 @@ namespace ncpp
private:
ncplane* create_plane (const Plane &n, int rows, int cols, int yoff, int xoff, void *opaque)
{
struct ncplane_options nopts = {
ncplane_options nopts = {
.y = yoff,
.x = xoff,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad

.x = xoff,
.rows = rows,
.cols = cols,
.userptr = opaque,
.name = nullptr,
.resizecb = nullptr,
.flags = 0,
};
ncplane *ret = ncplane_create (
n.plane,
&nopts
);

if (ret == nullptr)
throw init_error ("Notcurses failed to create a new plane");

map_plane (plane, this);

return ret;
return create_plane (n, nopts);
}

ncplane* create_plane (Plane &n, int rows, int cols, int yoff, NCAlign align, void *opaque)
Expand All @@ -1262,16 +1286,21 @@ namespace ncpp
nullptr,
0,
};
return create_plane (n, nopts);
}

ncplane* create_plane (const Plane &n, ncplane_options const& nopts)
{
ncplane *ret = ncplane_create (
n.plane,
&nopts
);

if (ret == nullptr)
if (ret == nullptr) {
throw init_error ("Notcurses failed to create an aligned plane");
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you


map_plane (plane, this);

return ret;
}

Expand Down
9 changes: 0 additions & 9 deletions tools/NotcursesConfig.cmake.in

This file was deleted.