mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
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
This commit is contained in:
parent
4d877603c3
commit
4571b57ece
16
doc/FreeBSD-Makefile
Normal file
16
doc/FreeBSD-Makefile
Normal file
@ -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
Normal file
6
rust/Cargo.lock
generated
Normal file
@ -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"
|
||||
|
13
rust/Cargo.toml
Normal file
13
rust/Cargo.toml
Normal file
@ -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]
|
7
rust/src/lib.rs
Normal file
7
rust/src/lib.rs
Normal file
@ -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…
Reference in New Issue
Block a user