[UP]


Manual Reference Pages  - M_readline (3)

NAME

M_readline(3fm) - [M_readline] Calling readline(3c) from Fortran (LICENSE:PD)

CONTENTS

Synopsis
Description
Example
Author
License

SYNOPSIS

Use M_readline, only : system_readline

DESCRIPTION

The M_readline(3fm) module uses the ISO_C_BINDING module to create a binding to the GNU readline(3c) procedure from Fortran programs.

EXAMPLE

The test program is basically just a read loop that prompts for lines of input read with readline(3c). You can edit the line being read with readline(3c) per its documentation. At a minimum, you can probably move around the line with the left and right arrow keys, and insert characters by typing them wherever you moved the cursor to, and use the DEL/ RUBOUT key to delete characters and such. If you use a GNU/Linux shell with command line editing, you are probably familiar with readline(3c)’s function.

It quits if you enter ’q’ on an input line, and it dumps the history if you enter ’h’.

the test program

   program demo_M_readline
      use M_readline
      implicit none
      character(len=256):: line
      integer                       :: cstat
      character(len=256)            :: sstat

write(*,*)’ ____________________________________________________________’ write(*,*)’ Your input lines are now editable using the GNU’ write(*,*)’ readline(3C) procedure. By default, up-arrow and’ write(*,*)’ down-arrow go thru the history lines; left and right arrow’ write(*,*)’ keys and delete and just typing characters let you do’ write(*,*)’ simple editing. Far more input control is available.’ write(*,*)’ See the browser pages and man(1) pages for readline(3c).’ write(*,*)’ ____________________________________________________________’ write(*,*)’ Enter text and then edit it. "q" quits; "h" display history:’

do call system_readline(line,’readline>’) ! read editable input line if(line.eq.’q’) stop !call system(trim(line)) ! common extension call execute_command_line(trim(line),cmdstat=cstat,cmdmsg=sstat) ! f08 equivalent enddo end program demo_M_readline

AUTHOR

John S. Urban

LICENSE

Public Domain

Although this interface to readline(3c) is released as Public Domain, note that the Readline library itself is free software, distributed under the terms of the [GNU] General Public License, version 2.


M_readline (3) October 17, 2020
Generated by manServer 1.08 from f299e4f6-d39e-4308-b7b9-6209a2bb1b78 using man macros.