Rust/FreeBSD (#221)

* rust bindings
* update release documentation with Rust info
* panelreel tester: accept command-line options#180
* input: char32_t not wchar_t in output
* freebsd compilation issues #196
pull/225/head
Nick Black 5 years ago committed by GitHub
parent 4d877603c3
commit 4571b57ece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,16 @@
# $FreeBSD$
PORTNAME=notcurses
DISTVERSION=0.9.2
CATEGORIES=graphics
MASTER_SITES=https://nick-black.com/dankwiki/index.php/Notcurses
MAINTAINER=dankamongmen@gmail.com
COMMENT=TUI library for modern terminal emulators
USES=cmake
LICENSE=Apache-2.0
USE_GITHUB=yes
GH_ACCOUNT=dankamongmen
.include <bsd.port.mk>

@ -1,5 +1,6 @@
* Verify version in CMakeLists.txt
* Finalize Debian changelog with `dch -r`
* Update version in rust/Cargo.toml
* git commit -a -m v$VERSION
* Tag with `git tag -a v$VERSION -m "v$VERSION"`
* `git push && git push origin --tags`
@ -16,5 +17,6 @@
* `makepkg --printsrcinfo > .SRCINFO`
* Test that package builds with `makepkg`
* `git commit -a`
* Upload new Rust crate with `cargo upload`
* Update Debian changelog with `dch -v $NEXTVERSION-1`
* Update CMakeLists.txt with next version

6
rust/Cargo.lock generated

@ -0,0 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "notcurses"
version = "0.9.2"

@ -0,0 +1,13 @@
[package]
name = "notcurses"
version = "0.9.2"
authors = ["nick black <dankamongmen@gmail.com>"]
edition = "2018"
license = "Apache-2.0"
description = "Rust bindings for the notcurses C library."
repository = "https://github.com/dankamongmen/notcurses"
homepage = "https://nick-black.com/dankwiki/index.php/Notcurses"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

@ -0,0 +1,7 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

@ -1,6 +1,7 @@
#include <ncurses.h> // needed for some definitions, see terminfo(3ncurses)
#include <term.h>
#include <ctype.h>
#include <signal.h>
#include <sys/poll.h>
#include "internal.h"
@ -74,7 +75,7 @@ notcurses_add_input_escape(notcurses* nc, const char* esc, char32_t special){
return -1;
}
if(!wchar_supppuab_p(special) && special != NCKEY_CSI){
fprintf(stderr, "Not a supplementary-b PUA char: %lc (0x%x)\n", special, special);
fprintf(stderr, "Not a supplementary-b PUA char: %u (0x%x)\n", special, special);
return -1;
}
esctrie** cur = &nc->inputescapes;
@ -249,7 +250,7 @@ static int
block_on_input(FILE* fp, const struct timespec* ts, sigset_t* sigmask){
struct pollfd pfd = {
.fd = fileno(fp),
.events = POLLIN | POLLRDHUP,
.events = POLLIN,
.revents = 0,
};
sigset_t scratchmask;
@ -261,6 +262,9 @@ block_on_input(FILE* fp, const struct timespec* ts, sigset_t* sigmask){
sigdelset(sigmask, SIGINT);
sigdelset(sigmask, SIGQUIT);
sigdelset(sigmask, SIGSEGV);
#ifdef POLLRDHUP
pfd.events |= POLLRDHUP;
#endif
return ppoll(&pfd, 1, ts, sigmask);
}

@ -1,5 +1,8 @@
#include <cstdlib>
#include <clocale>
#include <sstream>
#include <getopt.h>
#include <iostream>
#include <notcurses.h>
// FIXME ought be able to get pr from tablet, methinks?
@ -27,11 +30,46 @@ int tabletfxn(struct tablet* t, int begx, int begy, int maxx, int maxy,
return tctx->getLines() > maxy - begy ? maxy - begy : tctx->getLines();
}
int main(void){
void usage(const char* argv0, std::ostream& c, int status){
c << "usage: " << argv0 << " [ -h ] | [ -b bordermask ] [ -t tabletmask ]\n";
c << " -b bordermask: hex panelreel border mask (0x0..0xf)\n";
c << " -t tabletmask: hex tablet border mask (0x0..0xf)" << std::endl;
exit(status);
}
void parse_args(int argc, char** argv, struct notcurses_options* opts,
struct panelreel_options* popts){
int c;
while((c = getopt(argc, argv, "b:t:h")) != -1){
switch(c){
case 'b':{
std::stringstream ss;
ss << std::hex << optarg;
ss >> popts->bordermask;
break;
}case 't':
// FIXME
break;
case 'h':
usage(argv[0], std::cout, EXIT_SUCCESS);
break;
default:
std::cerr << "Unknown option\n";
usage(argv[0], std::cerr, EXIT_FAILURE);
break;
}
}
opts->suppress_bannner = true;
opts->clear_screen_start = true;
}
int main(int argc, char** argv){
if(setlocale(LC_ALL, "") == nullptr){
return EXIT_FAILURE;
}
struct notcurses_options opts{};
struct panelreel_options popts{};
parse_args(argc, argv, &opts, &popts);
struct notcurses* nc = notcurses_init(&opts, stdout);
if(!nc){
return EXIT_FAILURE;
@ -52,11 +90,8 @@ int main(void){
notcurses_stop(nc);
return EXIT_FAILURE;
}
struct panelreel_options popts{};
channels_set_fg(&popts.focusedchan, 0xffffff);
channels_set_bg(&popts.focusedchan, 0x00c080);
popts.bordermask = NCBOXMASK_BOTTOM | NCBOXMASK_TOP |
NCBOXMASK_RIGHT | NCBOXMASK_LEFT;
struct panelreel* pr = panelreel_create(n, &popts, -1);
if(!pr || notcurses_render(nc)){
notcurses_stop(nc);

Loading…
Cancel
Save