Skip to content

interkosmos/fortran-ncurses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fortran-ncurses

A work-in-progress collection of auto-generated ISO C binding interfaces to ncurses for Fortran 2018, similar to M_ncurses.

Build Instructions

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

Example

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 main

Compile, link, and run the program:

$ gfortran -I/opt/include/libfortran-ncurses -o example example.f90 /opt/lib/libfortran-ncurses.a -lncurses
$ ./example

Fortran Package Manager

You can add fortran-ncurses as an FPM dependency to your fpm.toml:

[dependencies]
fortran-ncurses = { git = "https://github.com/interkosmos/fortran-ncurses.git" }

Compatibility

  • 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, LINES and PAIR_NUMBER are bound through functions of the same name.

References

Licence

ISC

About

Fortran 2018 interface bindings to ncurses

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published