azawawi / raku-ncurses Goto Github PK
View Code? Open in Web Editor NEWRaku interface to NCurses library
License: MIT License
Raku interface to NCurses library
License: MIT License
use libncursesw if it is installed
providing a function to know which library is being used would be very useful too
This is used in the examples, is in the lib/ dir, but isn't installed.
When I try to use NCurses in another module between my pl6 file and NCurses, I get this error upon running the script:
$ ./ncurses-test.pl6
===SORRY!===
Cannot invoke this object (REPR: Null; VMNull)
I've attached a small zip file containing two perl6 files that exhibit this behavior.
Arch Linux
rakudo 2017.03 (AUR),
rakudo 2017.4.2 (rakudobrew)
When I pass some Chinese to mvaddstr
function, for example: 你好
, the output is OK, but when I pass some other Chinese/Japanese to mvaddstr
, such as 彩虹
, 哈哈
, ウルヰ
, the out put is not ok.
use v6;
use NCurses;
# Initialize curses window
my $win = initscr() or die "Failed to initialize ncurses\n";
start_color;
# Initialize colors
init_pair(1, COLOR_WHITE, COLOR_RED);
init_pair(2, COLOR_WHITE, COLOR_BLUE);
# Print Hello World
color_set(1, 0);
mvaddstr( 10, 10, "你好"); # ok
mvaddstr( 15, 10, "彩虹"); # not ok, becomes: 彩?~Y?
mvaddstr( 15, 10, "哈哈"); # not ok, becomes: ?~S~H?~S~H
color_set(2, 0);
mvaddstr( LINES() - 2, 2, "Press any key to exit..." );
# Refresh (this is needed)
nc_refresh;
# Wait for a keypress
getch;
# Cleanup
LEAVE {
delwin($win) if $win;
endwin;
}
It's my understanding that wrefresh(stdscr) should work exactly the same as nc_refresh(), but I seem to be getting a segfault.
The failing code:
use NCurses;
initscr; endwin; # To make sure stdscr is set
wrefresh(stdscr);
endwin;
On the other hand, the following works:
use NCurses;
use NativeCall;
initscr; endwin; # Again, make sure stdscr is set.
my \intptr_t = (nativesizeof(Pointer) == 8) int64 ?? int32;
wrefresh(Pointer.new(cglobal(library,'stdscr',intptr_t));
endwin;
I'm not entirely convinced this is an NCurses problem (I've opened a bug on rakudo/rakudo), but I was advised on the Perl6 IRC to bring it up here and at this point I'm just referring the issue to anyone who might know what's going on.
Hello, would it be possible to add something that returns the NCURSES_MOUSE_VERSION?
One of the tests of this module is broken on HEAD. See https://gist.github.com/041296026d1624fbde86d17196ea8ec4.
Bisectable points to rakudo/rakudo@4b02b8a
Term::Choose, Term::Choose::Util, and Term::TablePrint depend on this module and therefore are shown as burnt in the toaster.
See also RT #132030.
Sister tickets:
COLS() - Not only uses a tremendous amount of cpu to return the number of columns,
each iteration of the call consumes more and more memory until all memory is consumed and it crashes.
I suspect LINES() does the same, but I haven't tested it.
root@FreeBSD11:~ # uname -sr
FreeBSD 11.2-RELEASE
OR
root@host:~ % uname -sr
Linux 4.13.0-46-generic
root@FreeBSD11:~ # perl6 --version
This is Rakudo Star version 2018.06 built on MoarVM version 2018.06
implementing Perl 6.c.
I suspect this is a problem with moarvm, but figured I'd start here.
+++++++++++++++++++++++++++++++++++++++++++++++
#!/usr/bin/env perl6
use NCurses;
sub MAIN()
{
my $win = initscr() or die("Failed to initialize ncurses\n");
loop {
say COLS();
sleep(1);
}
delwin($win) if $win;
endwin;
}
I'm using arch linux, which uses version 6 of ncurses, and thus has no /usr/lib/libncursesw.so.5
. Running anything using this library then results in:
Cannot locate native library 'libncursesw.so.5': libncursesw.so.5: cannot open shared object file: No such file or directory
Symlinking /usr/lib/libncursesw.so.6.0 to /usr/lib/libncursesw.so.5 hackishly "solves" the issue, but isn't exactly a great solution.
As is, the signature for wborder is (NCurses::WINDOW, int32, int32, int32, int32, int32, int32, int32, int32 --> int32). In order to accept characters shouldn't that be (NCurses::WINDOW, int, int, int, int, int, int, int, int --> int) such that wborder( $window, ' '.ord, ' '.ord, ' '.ord, ' '.ord, ' '.ord, ' '.ord ); would work?
Programs running a la windows(not the os)/terminals that resize generally deliver a SIGWINCH upon that resize occuring.
COLS() and LINES() should always contain the current window dimensions. Currently they only return the dimensions that they were initially invoked with.
Example:
sub x()
{
say COLS();
}
initscr();
signal(SIGWINCH).tap: { x() }
loop {
sleep(1);
}
Hey,
I installed this NCurses via panda and used the Rakudo Star 2015.02 version for that. When executing
perl6 hello-world.pl
Nothing happens. There is no error message and after a short screen flickering, a new prompt appears. I checked with a c++ test program if ncurses works in my terminal (xterm) successfully.
It seems, that getch
does not work properly. When I remove the last line (endwin
) I can see the Text 'Hello World !!!' before the prompt.
I'm using ncurses 5.9-7.
The idea here is to provide a simpler & fun OO-based API while providing backward-compatibility. Study the following API first:
Some cool names suggested by timotimo
from #perl6
:
NCurses::Exorcism
NCurses::Lift
Hello,
From archlinux (zsh shell with features), command:
find /usr -name "libncurses.so*"
show that i have libncurses installed
but zef is not happy because an other request is to also have a bigger libncurses (error from zef)
then i do:
la /usr/lib/libncurses*
and see that libncurses.so is not a symbolic link, but the real lib is libncursesw.so.6.0
content of libncurses.so is:
INPUT(-lncursesw)
so actually, this module can not be installed on archlinux without break my archlinux organisation (and my packager will not be happy with that...).
NCurses do things the way it can not be used by all OS Linux.
export PERL6_NCURSES_LIB=/usr/lib/libncursesw.so.6.0
then add this line in /etc/profile
and also in ~/.zshrc
do the job and resolve the problem (but this thread post should not be close).
:constants
:output
etc...
Currently, the module hardcodes the DLL location. Perhaps it can accept an environment variable indicating the path to the library.
This would allow compatibility with Windows if I'm not mistaken.
===> Searching for: NCurses
===> Searching for missing dependencies: LibraryCheck
===> Testing: LibraryCheck:ver<0.0.6>:authgithub:jonathanstowe
===> Testing [OK] for LibraryCheck:ver<0.0.6>:authgithub:jonathanstowe
===> Testing: NCurses:ver<0.6.3>:authgithub:azawawi
===> Testing [FAIL]: NCurses:ver<0.6.3>:authgithub:azawawi
Aborting due to test failure: NCurses:ver<0.6.3>:authgithub:azawawi (use --force-test to override)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.