A work-in-progress collection of auto-generated ISO C binding interfaces to ncurses for Fortran 2018, similar to M_ncurses.
Execute the Makefile to build and install the library:
$ make
$ make install PREFIX=/opt
Depending on the ncurses library installed locally, you may have to generate the
constants module ncurses_const.f90, for instance:
$ make mkconst
$ ./mkconst src/ncurses_const.f90
To build all example programs:
$ make examples
Basic example program to initialise ncurses and output a string:
! example.f90
program main
use :: ncurses
implicit none (type, external)
integer :: ch, rc
stdscr = initscr()
rc = noecho()
rc = curs_set(0)
rc = printw('Hello, World!' // c_null_char)
ch = getch()
rc = endwin()
end program mainCompile, link, and run the program:
$ gfortran -I/opt/include/libfortran-ncurses -o example example.f90 /opt/lib/libfortran-ncurses.a -lncurses
$ ./example
You can add fortran-ncurses as an FPM dependency to your fpm.toml:
[dependencies]
fortran-ncurses = { git = "https://github.com/interkosmos/fortran-ncurses.git" }- All character strings passed to the interfaces have to be null-terminated
with
c_null_char. - The ncurses macros
COLOR_PAIR,COLOR_PAIRS,COLORS,COLS,LINESandPAIR_NUMBERare bound through functions of the same name.
- Pradeep Padala, Thomas E. Dickey: NCURSES Programming HOWTO
- Eric S. Raymond, Zeyd M. Ben-Halim, Thomas E. Dickey: Writing Programs with NCURSES
- ncurses manuals
ISC