Browse Source

* Support for version 5.6 of ncurses, by Tolstov Igor

git-svn-id: trunk@10573 -
michael 17 years ago
parent
commit
6fb20aabf6

+ 12 - 0
.gitattributes

@@ -3219,6 +3219,7 @@ packages/ncurses/examples/ocrt_demo.pp svneol=native#text/plain
 packages/ncurses/examples/screen_demo.pp svneol=native#text/plain
 packages/ncurses/fpmake.pp svneol=native#text/plain
 packages/ncurses/src/eti.inc svneol=native#text/plain
+packages/ncurses/src/form.pp svneol=native#text/plain
 packages/ncurses/src/menu.pp svneol=native#text/plain
 packages/ncurses/src/ncrt.inc svneol=native#text/plain
 packages/ncurses/src/ncrt.pp svneol=native#text/plain
@@ -3227,7 +3228,18 @@ packages/ncurses/src/ocrt.pp svneol=native#text/plain
 packages/ncurses/src/panel.pp svneol=native#text/plain
 packages/ncurses/src/pxpic.inc svneol=native#text/plain
 packages/ncurses/src/pxpic.txt svneol=native#text/plain
+packages/ncurses/tests/cotest.pp svneol=native#text/plain
+packages/ncurses/tests/t1form.pp svneol=native#text/plain
+packages/ncurses/tests/t1menu.pp svneol=native#text/plain
+packages/ncurses/tests/t2form.pp svneol=native#text/plain
+packages/ncurses/tests/t2menu.pp svneol=native#text/plain
+packages/ncurses/tests/t3form.pp svneol=native#text/plain
+packages/ncurses/tests/tbackground.pp svneol=native#text/plain
+packages/ncurses/tests/tclock.pp svneol=native#text/plain
 packages/ncurses/tests/testn.pp svneol=native#text/plain
+packages/ncurses/tests/tevent.pp svneol=native#text/plain
+packages/ncurses/tests/tmouse.pp svneol=native#text/plain
+packages/ncurses/tests/tnlshello.pp svneol=native#text/plain
 packages/newt/Makefile svneol=native#text/plain
 packages/newt/Makefile.fpc svneol=native#text/plain
 packages/newt/README svneol=native#text/plain

+ 59 - 100
packages/ncurses/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/03/24]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/03/20]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
@@ -167,17 +167,6 @@ OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
 endif
 FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
 FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
-ifeq ($(CPU_TARGET),armeb)
-ARCH=arm
-override FPCOPT+=-Cb
-else
-ifeq ($(CPU_TARGET),armel)
-ARCH=arm
-override FPCOPT+=-CaEABI
-else
-ARCH=$(CPU_TARGET)
-endif
-endif
 ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
 TARGETSUFFIX=$(OS_TARGET)
 SOURCESUFFIX=$(OS_SOURCE)
@@ -199,7 +188,7 @@ endif
 ifeq ($(OS_TARGET),linux)
 linuxHier=1
 endif
-export OS_TARGET OS_SOURCE ARCH CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
 ifdef FPCDIR
 override FPCDIR:=$(subst \,/,$(FPCDIR))
 ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
@@ -254,172 +243,166 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(F
 override PACKAGE_NAME=ncurses
 override PACKAGE_VERSION=2.0.0
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
-endif
-ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
-endif
-ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_UNITS+=ncurses panel ncrt ocrt menu
+override TARGET_UNITS+=ncurses panel ncrt ocrt menu form
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
@@ -583,12 +566,6 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
 endif
-ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
-endif
-ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_EXAMPLES+=firework testn ocrt_demo edit_demo db_demo screen_demo
-endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_INCLUDEDIR+=src
@@ -752,12 +729,6 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 override COMPILER_INCLUDEDIR+=src
 endif
-ifeq ($(FULL_TARGET),armeb-linux)
-override COMPILER_INCLUDEDIR+=src
-endif
-ifeq ($(FULL_TARGET),armeb-embedded)
-override COMPILER_INCLUDEDIR+=src
-endif
 ifeq ($(FULL_TARGET),i386-linux)
 override COMPILER_SOURCEDIR+=src tests examples
 endif
@@ -920,12 +891,6 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 override COMPILER_SOURCEDIR+=src tests examples
 endif
-ifeq ($(FULL_TARGET),armeb-linux)
-override COMPILER_SOURCEDIR+=src tests examples
-endif
-ifeq ($(FULL_TARGET),armeb-embedded)
-override COMPILER_SOURCEDIR+=src tests examples
-endif
 ifdef REQUIRE_UNITSDIR
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 endif
@@ -1867,12 +1832,6 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 REQUIRE_PACKAGES_RTL=1
 endif
-ifeq ($(FULL_TARGET),armeb-linux)
-REQUIRE_PACKAGES_RTL=1
-endif
-ifeq ($(FULL_TARGET),armeb-embedded)
-REQUIRE_PACKAGES_RTL=1
-endif
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_RTL),)
@@ -1900,13 +1859,13 @@ override COMPILER_UNITDIR+=$(UNITDIR_RTL)
 endif
 endif
 ifndef NOCPUDEF
-override FPCOPTDEF=$(ARCH)
+override FPCOPTDEF=$(CPU_TARGET)
 endif
 ifneq ($(OS_TARGET),$(OS_SOURCE))
 override FPCOPT+=-T$(OS_TARGET)
 endif
 ifneq ($(CPU_TARGET),$(CPU_SOURCE))
-override FPCOPT+=-P$(ARCH)
+override FPCOPT+=-P$(CPU_TARGET)
 endif
 ifeq ($(OS_SOURCE),openbsd)
 override FPCOPT+=-FD$(NEW_BINUTILS_PATH)

+ 1 - 1
packages/ncurses/Makefile.fpc

@@ -7,7 +7,7 @@ name=ncurses
 version=2.0.0
 
 [target]
-units=ncurses panel ncrt ocrt menu
+units=ncurses panel ncrt ocrt menu form
 examples=firework testn ocrt_demo edit_demo db_demo screen_demo
 
 [require]

+ 12 - 3
packages/ncurses/examples/firework.pp

@@ -1,11 +1,16 @@
 {
 }
+//{$mode objfpc}
+{$INLINE OFF}
+{$ifdef FPC_PROFILE}
+{$INLINE OFF}
+{$endif FPC_PROFILE}
 program firework;
 uses
   ncurses;
 
 CONST
-  my_bg : LONGINT = COLOR_BLACK;
+  my_bg = COLOR_BLACK;
 
 Procedure showit;
 begin
@@ -87,12 +92,14 @@ Var
 begin
   flag:=0;
   initscr;
-  if (has_colors<>0) then
+  //if (has_colors<>0) then
+  if has_colors then
    start_color;
   curs_set(0);
   randomize;
   cbreak;
-  While true do
+  nodelay(stdscr, true);
+  While getch=ERR do
    begin
      repeat
        startp:=random (COLS -3);
@@ -133,4 +140,6 @@ begin
      erase;
      showit;
    end;
+   endwin();
+   halt(0);
 end.

+ 10 - 0
packages/ncurses/src/eti.inc

@@ -28,6 +28,8 @@
   {
        Author: Juergen Pfeifer <[email protected]> 1995,1997
                                                                                }
+{$IFNDEF _ETI_INCLUDED_}
+
   const
      E_OK = 0;
      E_SYSTEM_ERROR = -(1);
@@ -44,3 +46,11 @@
      E_REQUEST_DENIED = -(12);
      E_INVALID_FIELD = -(13);
      E_CURRENT = -(14);
+
+{$DEFINE _ETI_INCLUDED_}
+
+{$ELSE _ETI_INCLUDED_}
+
+{$WARNING eti.inc already included}
+
+{$ENDIF _ETI_INCLUDED_}

+ 386 - 0
packages/ncurses/src/form.pp

@@ -0,0 +1,386 @@
+{$MODE OBJFPC}
+unit form;
+interface
+
+uses
+  ncurses, ctypes;
+
+{$LINKLIB formw}
+const
+   libform = 'formw';
+
+{$PACKRECORDS C}
+{$INCLUDE eti.inc}
+
+
+type
+   //Pva_list = ^va_list;
+   //va_list = char;
+  Pva_list  = Pointer;
+  FIELD_CELL = Pointer;
+  Form_Options = Longint;
+  Field_Options = Longint;
+
+
+(* _PAGE  *)
+
+  _PAGE = record
+    pmin : Smallint;  { index of first field on page       }
+    pmax : Smallint;  { index of last field on page      }
+    smin : Smallint;  { index of top leftmost field on page    }
+    smax : Smallint;  { index of bottom rightmost field on page  }
+  end;
+
+
+
+(*  FIELD  *)
+
+  PPFIELD = ^PFIELD;
+  PFIELDTYPE  = ^TFIELDTYPE;
+  PFIELD  = ^TFIELD;
+  PFORM  = ^TFORM;
+
+  TFIELD = record
+     status : Word;        { flags      }
+     rows : Smallint;      { size in rows       }
+     cols : Smallint;      { size in cols       }
+     frow : Smallint;      { first row      }
+     fcol : Smallint;      { first col      }
+     drows : Longint;      { dynamic rows       }
+     dcols : Longint;      { dynamic cols       }
+     maxgrow : Longint;    { maximum field growth     }
+     nrow : Longint;       { off-screen rows    }
+     nbuf : Smallint;      { additional buffers     }
+     just : Smallint;      { justification    }
+     page : Smallint;      { page on form       }
+     index : Smallint;     { into form -> field     }
+     pad : Longint;        { pad character    }
+     fore : chtype;        { foreground attribute     }
+     back : chtype;        { background attribute     }
+     opts : Field_Options; { options      }
+     snext : PFIELD;       { sorted order pointer     }
+     sprev : PFIELD;       { sorted order pointer     }
+     link : PFIELD;        { linked field chain     }
+     form : PFORM;         { containing form    }
+     _type : PFIELDTYPE;   { field type       }
+     arg : Pointer;        { argument for type    }
+     buf : ^FIELD_CELL;    { field buffers    }
+     usrptr : Pointer;     { user pointer       }
+  end;
+  //fieldnode = TFIELD;
+{
+  The wide-character configuration requires extra information.  Because
+  there are existing applications that manipulate the members of FIELD
+  directly, we cannot make the struct opaque.  Offsets of members up to
+  this point are the same in the narrow- and wide-character configuration.
+  But note that the type of buf depends on the configuration, and is made
+  opaque for that reason.
+}
+
+
+
+(*  FIELDTYPE  *)
+
+  TFieldCheck = function (_para1:PFIELD; _para2:Pointer):Bool; cdecl;
+  TCharCheck = function (_para1:Longint; _para2:Pointer):Bool; cdecl;
+  TMakearg = function (_para1:Pva_list):Pointer; cdecl;
+  TCopy_arg = function (_para1:Pointer):Pointer; cdecl;
+  TFree_arg = procedure (_para1:Pointer); cdecl;
+
+  TFIELDTYPE = record
+    status : Word;                                      { flags     }
+    ref : clong;                                        { reference count  }
+    left : PFIELDTYPE;                                  { ptr to operand for |  }
+    right : PFIELDTYPE;                                 { ptr to operand for |  }
+    //makearg : function (_para1:Pva_list):Pointer;cdecl;
+    makearg : TMakearg;                                 { make fieldtype arg  }
+    //copyarg : function (_para1:Pointer):Pointer;
+    copyarg : TCopy_arg;                                { copy fieldtype arg   }
+    //freearg : procedure (_para1:Pointer);
+    freearg : TFree_arg;                                { field validation  }
+    //fcheck : function (_para1:PFIELD; _para2:Pointer):bool;
+    fcheck : TFieldCheck;                               { free fieldtype arg  }
+    //ccheck : function (_para1:Longint; _para2:Pointer):bool;
+    ccheck : TCharCheck;                                { character validation  }
+    //next : function (_para1:PFIELD; _para2:Pointer):bool;
+    next : TFieldCheck;                                 { enumerate next value  }
+    //prev : function (_para1:PFIELD;  _para2:Pointer):bool;
+    prev : TFieldCheck;                                 { enumerate prev value  }
+  end;
+  //typenode = FIELDTYPE;
+
+
+(* FORM  *)
+
+  Form_Hook = procedure (_para1:PFORM); cdecl;
+  TFORM = record
+    status : Word;          { flags       }
+    rows : Smallint;        { size in rows       }
+    cols : Smallint;        { size in cols       }
+    currow : Longint;       { current row in field window  }
+    curcol : Longint;       { current col in field window  }
+    toprow : Longint;       { in scrollable field window   }
+    begincol : Longint;     { in horiz. scrollable field   }
+    maxfield : Smallint;    { number of fields     }
+    maxpage : Smallint;     { number of pages     }
+    curpage : Smallint;     { index into page     }
+    opts : Form_Options;    { options      }
+    win : PWINDOW;          { window       }
+    sub : PWINDOW;          { subwindow      }
+    w : PWINDOW;            { window for current field   }
+    field : PPFIELD;        { field [maxfield]     }
+    current : PFIELD;       { current field     }
+    page : ^_PAGE;          { page [maxpage]     }
+    usrptr : Pointer;       { user pointer      }
+    //forminit : procedure (_para1:PFORM); cdecl;
+    forminit : Form_Hook;
+    //formterm : procedure (_para1:PFORM); cdecl;
+    formterm : Form_Hook;
+    //fieldinit : procedure (_para1:PFORM); cdecl;
+    fieldinit : Form_Hook;
+    //fieldterm : procedure (_para1:PFORM); cdecl;
+    fieldterm : Form_Hook;
+  end;
+  //formnode = TFORM;
+
+
+
+(* field justification *)
+const
+  NO_JUSTIFICATION = 0;
+  JUSTIFY_LEFT = 1;
+  JUSTIFY_CENTER = 2;
+  JUSTIFY_RIGHT = 3;
+
+
+(* field options *)
+  O_VISIBLE = $0001;
+  O_ACTIVE = $0002;
+  O_PUBLIC = $0004;
+  O_EDIT = $0008;
+  O_WRAP = $0010;
+  O_BLANK = $0020;
+  O_AUTOSKIP = $0040;
+  O_NULLOK = $0080;
+  O_PASSOK = $0100;
+  O_STATIC = $0200;
+  O_NL_OVERLOAD = $0001;
+  O_BS_OVERLOAD = $0002;
+
+
+(* form driver commands *)
+   REQ_NEXT_PAGE = KEY_MAX + 1;     { move to next page    }
+   REQ_PREV_PAGE = KEY_MAX + 2;     { move to previous page  }
+   REQ_FIRST_PAGE = KEY_MAX + 3;    { move to first page    }
+   REQ_LAST_PAGE = KEY_MAX + 4;     { move to last page    }
+   REQ_NEXT_FIELD = KEY_MAX + 5;    { move to next field    }
+   REQ_PREV_FIELD = KEY_MAX + 6;    { move to previous field  }
+   REQ_FIRST_FIELD = KEY_MAX + 7;   { move to first field    }
+   REQ_LAST_FIELD = KEY_MAX + 8;    { move to last field    }
+   REQ_SNEXT_FIELD = KEY_MAX + 9;   { move to sorted next field  }
+   REQ_SPREV_FIELD = KEY_MAX + 10;  { move to sorted prev field   }
+   REQ_SFIRST_FIELD = KEY_MAX + 11; { move to sorted first field   }
+   REQ_SLAST_FIELD = KEY_MAX + 12;  { move to sorted last field   }
+   REQ_LEFT_FIELD = KEY_MAX + 13;   { move to left to field  }
+   REQ_RIGHT_FIELD = KEY_MAX + 14;  { move to right to field  }
+   REQ_UP_FIELD = KEY_MAX + 15;     { move to up to field    }
+   REQ_DOWN_FIELD = KEY_MAX + 16;   { move to down to field  }
+   REQ_NEXT_CHAR = KEY_MAX + 17;    { move to next char in field  }
+   REQ_PREV_CHAR = KEY_MAX + 18;    { move to prev char in field  }
+   REQ_NEXT_LINE = KEY_MAX + 19;    { move to next line in field  }
+   REQ_PREV_LINE = KEY_MAX + 20;    { move to prev line in field  }
+   REQ_NEXT_WORD = KEY_MAX + 21;    { move to next word in field  }
+   REQ_PREV_WORD = KEY_MAX + 22;    { move to prev word in field  }
+   REQ_BEG_FIELD = KEY_MAX + 23;    { move to first char in field   }
+   REQ_END_FIELD = KEY_MAX + 24;    { move after last char in fld   }
+   REQ_BEG_LINE = KEY_MAX + 25;     { move to beginning of line  }
+   REQ_END_LINE = KEY_MAX + 26;     { move after last char in line   }
+   REQ_LEFT_CHAR = KEY_MAX + 27;    { move left in field    }
+   REQ_RIGHT_CHAR = KEY_MAX + 28;   { move right in field    }
+   REQ_UP_CHAR = KEY_MAX + 29;      { move up in field    }
+   REQ_DOWN_CHAR = KEY_MAX + 30;    { move down in field    }
+   REQ_NEW_LINE = KEY_MAX + 31;     { insert/overlay new line  }
+   REQ_INS_CHAR = KEY_MAX + 32;     { insert blank char at cursor  }
+   REQ_INS_LINE = KEY_MAX + 33;     { insert blank line at cursor  }
+   REQ_DEL_CHAR = KEY_MAX + 34;     { delete char at cursor  }
+   REQ_DEL_PREV = KEY_MAX + 35;     { delete char before cursor  }
+   REQ_DEL_LINE = KEY_MAX + 36;     { delete line at cursor  }
+   REQ_DEL_WORD = KEY_MAX + 37;     { delete word at cursor  }
+   REQ_CLR_EOL = KEY_MAX + 38;      { clear to end of line    }
+   REQ_CLR_EOF = KEY_MAX + 39;      { clear to end of field   }
+   REQ_CLR_FIELD = KEY_MAX + 40;    { clear entire field    }
+   REQ_OVL_MODE = KEY_MAX + 41;     { begin overlay mode     }
+   REQ_INS_MODE = KEY_MAX + 42;     { begin insert mode    }
+   REQ_SCR_FLINE = KEY_MAX + 43;    { scroll field forward a line   }
+   REQ_SCR_BLINE = KEY_MAX + 44;    { scroll field backward a line  }
+   REQ_SCR_FPAGE = KEY_MAX + 45;    { scroll field forward a page   }
+   REQ_SCR_BPAGE = KEY_MAX + 46;    { scroll field backward a page  }
+   REQ_SCR_FHPAGE = KEY_MAX + 47;   { scroll field forward   half page  }
+   REQ_SCR_BHPAGE = KEY_MAX + 48;   { scroll field backward half page  }
+   REQ_SCR_FCHAR = KEY_MAX + 49;    { horizontal scroll char  }
+   REQ_SCR_BCHAR = KEY_MAX + 50;    { horizontal scroll char  }
+   REQ_SCR_HFLINE = KEY_MAX + 51;   { horizontal scroll line   }
+   REQ_SCR_HBLINE = KEY_MAX + 52;   { horizontal scroll line   }
+   REQ_SCR_HFHALF = KEY_MAX + 53;   { horizontal scroll half line  }
+   REQ_SCR_HBHALF = KEY_MAX + 54;   { horizontal scroll half line  }
+   REQ_VALIDATION = KEY_MAX + 55;   { validate field     }
+   REQ_NEXT_CHOICE = KEY_MAX + 56;  { display next field choice   }
+   REQ_PREV_CHOICE = KEY_MAX + 57;  { display prev field choice   }
+   MIN_FORM_COMMAND = KEY_MAX + 1;  { used by form_driver     }
+   MAX_FORM_COMMAND = KEY_MAX + 57; { used by form_driver    }
+
+
+(* standard field types *)
+
+var
+{$ifndef darwin}
+  TYPE_ALPHA : PFIELDTYPE;cvar;external;
+  TYPE_ALNUM : PFIELDTYPE;cvar;external;
+  TYPE_ENUM : PFIELDTYPE;cvar;external;
+  TYPE_INTEGER : PFIELDTYPE;cvar;external;
+  TYPE_NUMERIC : PFIELDTYPE;cvar;external;
+  TYPE_REGEXP : PFIELDTYPE;cvar;external;
+{$else darwin}
+  TYPE_ALPHA : PFIELDTYPE external libform name 'TYPE_ALPHA';
+  TYPE_ALNUM : PFIELDTYPE external libform name 'TYPE_ALNUM';
+  TYPE_ENUM : PFIELDTYPE external libform name 'TYPE_ENUM';
+  TYPE_INTEGER : PFIELDTYPE external libform name 'TYPE_INTEGER';
+  TYPE_NUMERIC : PFIELDTYPE external libform name 'TYPE_NUMERIC';
+  TYPE_REGEXP : PFIELDTYPE external libform name 'TYPE_REGEXP';
+{$endif darwin}
+(***********************************
+	*  built-in additional field types *
+	*  They are not defined in SVr4    *
+	***********************************)
+
+{$ifndef darwin}
+  TYPE_IPV4 : PFIELDTYPE;cvar;external; { Internet IP Version 4 address  }
+{$else darwin}
+  TYPE_IPV4 : PFIELDTYPE external libform name 'TYPE_IPV4';
+{$endif darwin}
+
+(* Default objects  *)
+{$ifndef darwin}
+  _nc_Default_Form : PFORM;cvar;external;
+  _nc_Default_Field : PFIELD;cvar;external;
+{$else darwin}
+  _nc_Default_Form : PFORM external libform name '_nc_Default_Form';
+  _nc_Default_Field : PFIELD external libform name '_nc_Default_Field';
+{$endif darwin}
+
+(* FIELDTYPE routines *)
+(* Const before declarator ignored *)
+(* Const before type ignored *)
+{
+function new_fieldtype(field_check:function (_para1:PFIELD;_para2:Pointer):bool; char_check:function (_para1:Longint;_para2:Pointer):bool):PFIELDTYPE;cdecl;external;
+}
+
+function new_fieldtype(field_check: TFieldCheck; char_check:TCharCheck):PFIELDTYPE; cdecl;external libform;
+
+function link_fieldtype(_para1:PFIELDTYPE; _para2:PFIELDTYPE):PFIELDTYPE; cdecl;external libform;
+function free_fieldtype(_para1:PFIELDTYPE):Longint; cdecl;external libform;
+
+{TMakearg   TCopy_arg TFree_arg
+extern int set_fieldtype_arg (FIELDTYPE *,
+      void * (* const make_arg)(va_list *),
+      void * (* const copy_arg)(const void *),
+      void (* const free_arg)(void *));
+
+function set_fieldtype_arg(_para1:PFIELDTYPE; make_arg:function (_para1:Pva_list):Pointer; copy_arg:function (_para1:Pointer):Pointer; free_arg:procedure (_para1:Pointer)):Longint;cdecl;external;
+}
+function set_fieldtype_arg(fieldtype: PFIELDTYPE; make_arg: TMakearg; copy_arg: TCopy_arg; free_arg: TFree_arg): Longint;cdecl;external libform;
+
+{
+extern int set_fieldtype_choice (FIELDTYPE *,
+      bool (* const next_choice)(FIELD *,const void *),
+            bool (* const prev_choice)(FIELD *,const void *));
+
+(* Const before declarator ignored *)
+(* Const before type ignored *)
+(* Const before declarator ignored *)
+(* Const before type ignored *)
+function set_fieldtype_choice(_para1:PFIELDTYPE; next_choice:function (_para1:PFIELD; _para2:Pointer):bool; prev_choice:function (_para1:PFIELD; _para2:Pointer):bool):Longint;cdecl;external;
+}
+
+function set_fieldtype_choice(_para1:PFIELDTYPE; next_choice:TFieldCheck; prev_choice:TFieldCheck):Longint; cdecl;external libform;
+
+(* FIELD routines *)
+
+function new_field(_pa1,_pa2,_pa3,_pa4,_pa5,_pa6:Longint):PFIELD; cdecl;external libform;
+function dup_field(_para1:PFIELD; _para2:Longint; _para3:Longint):PFIELD; cdecl;external libform;
+function link_field(_para1:PFIELD; _para2:Longint; _para3:Longint):PFIELD; cdecl;external libform;
+function free_field(_para1:PFIELD):Longint; cdecl;external libform;
+function field_info(_para1:PFIELD; _para2:Pcint; _para3:Pcint; _para4:Pcint; _para5:Pcint; 
+           _para6:Pcint; _para7:Pcint):Longint; cdecl;external libform;
+function dynamic_field_info(_para1:PFIELD; _para2:Pcint; _para3:Pcint; _para4:Pcint):Longint; cdecl;external libform;
+function set_max_field(_para1:PFIELD; _para2:Longint):Longint; cdecl;external libform;
+function move_field(_para1:PFIELD; _para2:Longint; _para3:Longint):Longint; cdecl;external libform;
+//function set_field_type(_para1:PFIELD; _para2:PFIELDTYPE; args:array of const):Longint; cdecl;external libform;
+function set_field_type(_field:PFIELD; _type:PFIELDTYPE):Longint;cdecl;varargs;external libform;
+
+function set_new_page(_para1:PFIELD; _para2:Bool):Longint; cdecl;external libform;
+function set_field_just(_para1:PFIELD; _para2:Longint):Longint; cdecl;external libform;
+function field_just(_para1:PFIELD):Longint; cdecl;external libform;
+function set_field_fore(_para1:PFIELD; _para2:chtype):Longint; cdecl;external libform;
+function set_field_back(_para1:PFIELD; _para2:chtype):Longint; cdecl;external libform;
+function set_field_pad(_para1:PFIELD; _para2:Longint):Longint; cdecl;external libform;
+function field_pad(_para1:PFIELD):Longint; cdecl;external libform;
+function set_field_buffer(_para1:PFIELD; _para2:Longint;_para3:PChar):Longint; cdecl;external libform;
+function set_field_status(_para1:PFIELD; _para2:Bool):Longint; cdecl;external libform;
+function set_field_userptr(_para1:PFIELD; _para2:Pointer):Longint; cdecl;external libform;
+function set_field_opts(_para1:PFIELD; _para2:Field_Options):Longint; cdecl;external libform;
+function field_opts_on(_para1:PFIELD; _para2:Field_Options):Longint; cdecl;external libform;
+function field_opts_off(_para1:PFIELD; _para2:Field_Options):Longint; cdecl;external libform;
+function field_fore(_para1:PFIELD):chtype; cdecl;external libform;
+function field_back(_para1:PFIELD):chtype; cdecl;external libform;
+function new_page(_para1:PFIELD):Bool; cdecl;external libform;
+function field_status(_para1:PFIELD):Bool; cdecl;external libform;
+function field_arg(_para1:PFIELD):Pointer; cdecl;external libform;
+function field_userptr(_para1:PFIELD):Pointer; cdecl;external libform;
+function field_type(_para1:PFIELD):PFIELDTYPE; cdecl;external libform;
+function field_buffer(_para1:PFIELD; _para2:Longint):PChar; cdecl;external libform;
+function field_opts(_para1:PFIELD):Field_Options; cdecl;external libform;
+
+(*  FORM routines  *)
+function new_form(_para1:PPFIELD):PFORM; cdecl;external libform;
+function form_fields(_para1:PFORM):PPFIELD; cdecl;external libform;
+function current_field(_para1:PFORM):PFIELD; cdecl;external libform;
+function form_win(_para1:PFORM):PWINDOW; cdecl;external libform;
+function form_sub(_para1:PFORM):PWINDOW; cdecl;external libform;
+function form_init(_para1:PFORM):Form_Hook; cdecl;external libform;
+function form_term(_para1:PFORM):Form_Hook; cdecl;external libform;
+function field_init(_para1:PFORM):Form_Hook; cdecl;external libform;
+function field_term(_para1:PFORM):Form_Hook; cdecl;external libform;
+function free_form(_para1:PFORM):Longint; cdecl;external libform;
+function set_form_fields(_para1:PFORM; _para2:PPFIELD):Longint; cdecl;external libform;
+function field_count(_para1:PFORM):Longint; cdecl;external libform;
+function set_form_win(_para1:PFORM; _para2:PWINDOW):Longint; cdecl;external libform;
+function set_form_sub(_para1:PFORM; _para2:PWINDOW):Longint; cdecl;external libform;
+function set_current_field(_para1:PFORM; _para2:PFIELD):Longint; cdecl;external libform;
+function field_index(_para1:PFIELD):Longint; cdecl;external libform;
+function set_form_page(_para1:PFORM; _para2:Longint):Longint; cdecl;external libform;
+function form_page(_para1:PFORM):Longint; cdecl;external libform;
+function scale_form(_para1:PFORM; _para2:Pcint; _para3:Pcint):Longint; cdecl;external libform;
+function set_form_init(_para1:PFORM; _para2:Form_Hook):Longint; cdecl;external libform;
+function set_form_term(_para1:PFORM; _para2:Form_Hook):Longint; cdecl;external libform;
+function set_field_init(_para1:PFORM; _para2:Form_Hook):Longint; cdecl;external libform;
+function set_field_term(_para1:PFORM; _para2:Form_Hook):Longint; cdecl;external libform;
+function post_form(_para1:PFORM):Longint; cdecl;external libform;
+function unpost_form(_para1:PFORM):Longint; cdecl;external libform;
+function pos_form_cursor(_para1:PFORM):Longint; cdecl;external libform;
+function form_driver(_para1:PFORM; _para2:Longint):Longint; cdecl;external libform;
+function set_form_userptr(_para1:PFORM; _para2:Pointer):Longint; cdecl;external libform;
+function set_form_opts(_para1:PFORM; _para2:Form_Options):Longint; cdecl;external libform;
+function form_opts_on(_para1:PFORM; _para2:Form_Options):Longint; cdecl;external libform;
+function form_opts_off(_para1:PFORM; _para2:Form_Options):Longint; cdecl;external libform;
+function form_request_by_name(_para1:PChar):Longint; cdecl;external libform;
+function form_request_name(_para1:Longint):PChar; cdecl;external libform;
+function form_userptr(_para1:PFORM):Pointer; cdecl;external libform;
+function form_opts(_para1:PFORM):Form_Options; cdecl;external libform;
+function data_ahead(_para1:PFORM):Bool; cdecl;external libform;
+function data_behind(_para1:PFORM):Bool; cdecl;external libform;
+
+implementation
+
+
+end.

+ 206 - 278
packages/ncurses/src/menu.pp

@@ -1,284 +1,212 @@
+{$MODE OBJFPC}
 unit menu;
-{---------------------------------------------------------------------------
-                                 CncWare
-----------------------------------------------------------------------------
-  Filename..: menu.pp
-  Programmer: Ken J. Wright
-  Date......: 07/12/2000
 
-  Purpose - Link to the Linux 'menu' library for ncurses menuing
-            functions.
-
--------------------------------< Revisions >---------------------------------
- Revision|   Date   | Prog| Description
------------------------------------------------------------------------------
- 1.00    | 07/12/00 | kjw | Initial release.
------------------------------------------------------------------------------
-}
-{  Automatically converted by H2PAS.EXE from menu.h
-   Utility made by Florian Klaempfl 25th-28th september 96
-   Improvements made by Mark A. Malakanov 22nd-25th may 97
-   Further improvements by Michael Van Canneyt, April 1998
-   define handling and error recovery by Pierre Muller, June 1998 }
-
-
-  interface
-
-  { C default packing is dword }
-
-{$PACKRECORDS 4}
-  {
-     Copyright (c) 1998 Free Software Foundation, Inc.
-
-     Permission is hereby granted, free of charge, to any person obtaining a
-     copy of this software and associated documentation files (the
-     "Software"), to deal in the Software without restriction, including
-     without limitation the rights to use, copy, modify, merge, publish,
-     distribute, distribute with modifications, sublicense, and/or sell
-     copies of the Software, and to permit persons to whom the Software is
-     furnished to do so, subject to the following conditions:
-
-     The above copyright notice and this permission notice shall be included
-     in all copies or substantial portions of the Software.
-
-     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-     IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-     OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
-     THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-     Except as contained in this notice, the name(s) of the above copyright
-     holders shall not be used in advertising or otherwise to promote the
-     sale, use or other dealings in this Software without prior written
-     authorization.
-                                                                               }
-  {
-       Author: Juergen Pfeifer <[email protected]> 1995,1997
+interface
+
+uses
+  ncurses;
+
+{$LINKLIB menuw}
+{$PACKRECORDS C}
+{$INCLUDE eti.inc}
+
+const
+   libmenu = 'menuw';
+
+type
+   cuchar = Byte;
+   Menu_Options = Longint;
+   Item_Options = Longint;
+
+const
+//    TEXT = TEXT_ncurses;
+{ Menu options:  }
+   O_ONEVALUE = $01;   { Only one item can be selected for this menu. }
+   O_SHOWDESC = $02;   { Display the item descriptions when the menu is posted.  }
+   O_ROWMAJOR = $04;   { Display the menu in row-major order.  }
+   O_IGNORECASE = $08; { Ignore the case when pattern-matching. }
+   O_SHOWMATCH = $10;  { Move the cursor to within the item name while pattern-matching.  }
+   O_NONCYCLIC = $20;  { Don't wrap around next-item and previous-item, requests to the other end of the menu. }
+{ Item options:  }
+   O_SELECTABLE = $01;
+
+type
+   TTEXT = record
+        str : PChar;
+        length : Word;
+     end;
+
+   ppITEM = ^pITEM;
+   pITEM  = ^tITEM;
+
+   pMENU = ^tMENU;
+   ppMENU = ^pMENU;
+
+   tITEM = record
+        name : TTEXT;         { name of menu item                          }
+        description : TTEXT;  { description of item, optional in display   }
+        imenu : pMENU;        { Pointer to parent menu                     }
+        userptr : Pointer;    { Pointer to user defined per item data      }
+        opt : Item_Options;   { Item options                               }
+        index : Smallint;     { Item number if connected to a menu         }
+        y : Smallint;         { y and x location of item in menu           }
+        x : Smallint;
+        value : Bool;         { Selection value                            }
+        left : pITEM;         { neighbor items                             }
+        right : pITEM;
+        up : pITEM;
+        down : pITEM;
+     end;
+
+
+
+   tagITEM = tITEM;
+
+   Menu_Hook = procedure (_para1:pMENU);cdecl;
+
+   tMENU = record
+        height : Smallint;      { Nr. of chars high                }
+        width : Smallint;       { Nr. of chars wide                }
+        rows : Smallint;        { Nr. of items high                }
+        cols : Smallint;        { Nr. of items wide                }
+        frows : Smallint;       { Nr. of formatted items high      }
+        fcols : Smallint;       { Nr. of formatted items wide      }
+        arows : Smallint;       { Nr. of items high (actual)       }
+        namelen : Smallint;     { Max. name length                 }
+        desclen : Smallint;     { Max. description length          }
+        marklen : Smallint;     { Length of mark, if any           }
+        itemlen : Smallint;     { Length of one item               }
+        spc_desc : Smallint;    { Spacing for descriptor           }
+        spc_cols : Smallint;    { Spacing for columns              }
+        spc_rows : Smallint;    { Spacing for rows                 }
+        pattern : PChar;        { Buffer to store match chars      }
+        pindex : Smallint;      { Index into pattern buffer        }
+        win : PWINDOW;          { Window containing menu           }
+        sub : PWINDOW;          { Subwindow for menu display       }
+        userwin : PWINDOW;      { User's window                    }
+        usersub : PWINDOW;      { User's subwindow                 }
+        items : ppITEM;         { array of items                   }
+        nitems : Smallint;      { Nr. of items in menu             }
+        curitem : pITEM;        { Current item                     }
+        toprow : Smallint;      { Top row of menu                  }
+        fore : chtype;          { Selection attribute              }
+        back : chtype;          { Nonselection attribute           }
+        grey : chtype;          { Inactive attribute               }
+        pad : cuchar;           { Pad character                    }
+        menuinit : Menu_Hook;   { User hooks                       }
+        menuterm : Menu_Hook;
+        iteminit : Menu_Hook;
+        itemterm : Menu_Hook;
+        userptr : Pointer;      { Pointer to menus user data       }
+        mark : PChar;           { Pointer to marker string         }
+        opt : Menu_Options;     { Menu options                     }
+        status : Word;          { Internal state of menu           }
+     end;
+
+
+
+
+   tagMENU = tMENU;
+
+{ Define keys  }
+
+const
+   REQ_LEFT_ITEM     = KEY_MAX + 1;
+   REQ_RIGHT_ITEM    = KEY_MAX + 2;
+   REQ_UP_ITEM       = KEY_MAX + 3;
+   REQ_DOWN_ITEM     = KEY_MAX + 4;
+   REQ_SCR_ULINE     = KEY_MAX + 5;
+   REQ_SCR_DLINE     = KEY_MAX + 6;
+   REQ_SCR_DPAGE     = KEY_MAX + 7;
+   REQ_SCR_UPAGE     = KEY_MAX + 8;
+   REQ_FIRST_ITEM    = KEY_MAX + 9;
+   REQ_LAST_ITEM     = KEY_MAX + 10;
+   REQ_NEXT_ITEM     = KEY_MAX + 11;
+   REQ_PREV_ITEM     = KEY_MAX + 12;
+   REQ_TOGGLE_ITEM   = KEY_MAX + 13;
+   REQ_CLEAR_PATTERN = KEY_MAX + 14;
+   REQ_BACK_PATTERN  = KEY_MAX + 15;
+   REQ_NEXT_MATCH    = KEY_MAX + 16;
+   REQ_PREV_MATCH    = KEY_MAX + 17;
+   MIN_MENU_COMMAND  = KEY_MAX + 1;
+   MAX_MENU_COMMAND  = KEY_MAX + 17;
+
+{
+ * Some AT&T code expects MAX_COMMAND to be out-of-band not
+ * just for menu commands but for forms ones as well.
   }
+{ --------- prototypes for libmenu functions -----------------------------  }
+
+function menu_items(_para1:PMENU):ppITEM; cdecl;external libncurses;
+function current_item(_para1:PMENU):pITEM; cdecl;external libncurses;
+function new_item(_para1:PChar; _para2:PChar):pITEM; cdecl;external libncurses;
+function new_menu(_para1:PPITEM):pMENU; cdecl;external libncurses;
+function item_opts(_para1:PITEM):Item_Options; cdecl;external libncurses;
+function menu_opts(_para1:PMENU):Menu_Options; cdecl;external libncurses;
+function item_init(_para1:PMENU):Menu_Hook; cdecl;external libncurses;
+function item_term(_para1:PMENU):Menu_Hook; cdecl;external libncurses;
+function menu_init(_para1:PMENU):Menu_Hook; cdecl;external libncurses;
+function menu_term(_para1:PMENU):Menu_Hook; cdecl;external libncurses;
+function menu_sub(_para1:PMENU):PWINDOW; cdecl;external libncurses;
+function menu_win(_para1:PMENU):PWINDOW; cdecl;external libncurses;
+function item_description(_para1:PITEM):PChar; cdecl;external libncurses;
+function item_name(_para1:PITEM):PChar; cdecl;external libncurses;
+function menu_mark(_para1:PMENU):PChar; cdecl;external libncurses;
+function menu_request_name(_para1:Longint):PChar; cdecl;external libncurses;
+function menu_pattern(_para1:PMENU):PChar; cdecl;external libncurses;
+function menu_userptr(_para1:PMENU):Pointer; cdecl;external libncurses;
+function item_userptr(_para1:PITEM):Pointer; cdecl;external libncurses;
+function menu_back(_para1:PMENU):chtype; cdecl;external libncurses;
+function menu_fore(_para1:PMENU):chtype; cdecl;external libncurses;
+function menu_grey(_para1:PMENU):chtype; cdecl;external libncurses;
+function free_item(_para1:PITEM):Longint; cdecl;external libncurses;
+function free_menu(_para1:PMENU):Longint; cdecl;external libncurses;
+function item_count(_para1:PMENU):Longint; cdecl;external libncurses;
+function item_index(_para1:PITEM):Longint; cdecl;external libncurses;
+function item_opts_off(_para1:PITEM; _para2:Item_Options):Longint; cdecl;external libncurses;
+function item_opts_on(_para1:PITEM; _para2:Item_Options):Longint; cdecl;external libncurses;
+function menu_driver(_para1:PMENU; _para2:Longint):Longint; cdecl;external libncurses;
+function menu_opts_off(_para1:PMENU; _para2:Menu_Options):Longint; cdecl;external libncurses;
+function menu_opts_on(_para1:PMENU; _para2:Menu_Options):Longint; cdecl;external libncurses;
+function menu_pad(_para1:PMENU):Longint; cdecl;external libncurses;
+function pos_menu_cursor(_para1:PMENU):Longint; cdecl;external libncurses;
+function post_menu(_para1:PMENU):Longint; cdecl;external libncurses;
+function scale_menu(_para1:PMENU; _para2:PLongint; _para3:PLongint):Longint; cdecl;external libncurses;
+function set_current_item(menu:PMENU; item:PITEM):Longint; cdecl;external libncurses;
+//function set_item_init(_para1:PMENU; _para2:procedure (_para1:PMENU)):Longint; cdecl;external libncurses;
+function set_item_init(_para1:PMENU; _para2:Menu_Hook):Longint; cdecl;external libncurses;
+function set_item_opts(_para1:PITEM; _para2:Item_Options):Longint; cdecl;external libncurses;
+//function set_item_term(_para1:PMENU; _para2:procedure (_para1:PMENU)):Longint; cdecl;external libncurses;
+function set_item_term(_para1:PMENU; _para2:Menu_Hook):Longint; cdecl;external libncurses;
+function set_item_userptr(_para1:PITEM; _para2:Pointer):Longint; cdecl;external libncurses;
+function set_item_value(_para1:PITEM; _para2:Bool):Longint; cdecl;external libncurses;
+function set_menu_back(_para1:PMENU; _para2:chtype):Longint; cdecl;external libncurses;
+function set_menu_fore(_para1:PMENU; _para2:chtype):Longint; cdecl;external libncurses;
+function set_menu_format(_para1:PMENU; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
+function set_menu_grey(_para1:PMENU; _para2:chtype):Longint; cdecl;external libncurses;
+//function set_menu_init(_para1:PMENU; _para2:procedure (_para1:PMENU)):Longint; cdecl;external libncurses;
+function set_menu_init(_para1:PMENU; _para2:Menu_Hook):Longint; cdecl;external libncurses;
+function set_menu_items(_para1:PMENU; _para2:PPITEM):Longint; cdecl;external libncurses;
+function set_menu_mark(_para1:PMENU; _para2:PChar):Longint; cdecl;external libncurses;
+function set_menu_opts(_para1:PMENU; _para2:Menu_Options):Longint; cdecl;external libncurses;
+function set_menu_pad(_para1:PMENU; _para2:Longint):Longint; cdecl;external libncurses;
+function set_menu_pattern(_para1:PMENU; _para2:PChar):Longint; cdecl;external libncurses;
+function set_menu_sub(_para1:PMENU; _para2:PWINDOW):Longint; cdecl;external libncurses;
+//function set_menu_term(_para1:PMENU; _para2:procedure (_para1:PMENU)):Longint; cdecl;external libncurses;
+function set_menu_term(_para1:PMENU; _para2:Menu_Hook):Longint; cdecl;external libncurses;
+function set_menu_userptr(_para1:PMENU; _para2:Pointer):Longint; cdecl;external libncurses;
+function set_menu_win(_para1:PMENU; _para2:PWINDOW):Longint; cdecl;external libncurses;
+function set_top_row(_para1:PMENU; _para2:Longint):Longint; cdecl;external libncurses;
+function top_row(_para1:PMENU):Longint; cdecl;external libncurses;
+function unpost_menu(_para1:PMENU):Longint; cdecl;external libncurses;
+function menu_request_by_name(_para1:PChar):Longint; cdecl;external libncurses;
+function set_menu_spacing(_para1:PMENU; _para2:Longint; _para3:Longint; _para4:Longint):Longint; cdecl;external libncurses;
+function menu_spacing(_para1:PMENU; _para2:PLongint; _para3:PLongint; _para4:PLongint):Longint; cdecl;external libncurses;
+function item_value(_para1:PITEM):Bool; cdecl;external libncurses;
+function item_visible(_para1:PITEM):Bool; cdecl;external libncurses;
+procedure menu_format(_para1:PMENU; _para2:PLongint; _para3:PLongint); cdecl;external libncurses;
+
+implementation
 
-{$linklib menu}
-
-uses ncurses;
-
-{$include eti.inc}
-
-  const
-    libmenu = 'menu';
-
-  type
-     Menu_Options = longint;
-     Item_Options = longint;
-
-
-  const
-  { Menu options:  }
-     O_ONEVALUE = $01;
-     O_SHOWDESC = $02;
-     O_ROWMAJOR = $04;
-     O_IGNORECASE = $08;
-     O_SHOWMATCH = $10;
-     O_NONCYCLIC = $20;
-  { Item options:  }
-     O_SELECTABLE = $01;
-
-  type
-
-     tTEXT = record
-          str : pchar;
-          length : word;
-       end;
-
-     tITEM = record
-          name : tTEXT;        { name of menu item                          }
-          description : tTEXT; { description of item, optional in display   }
-          imenu : ^tagMENU;    { Pointer to parent menu                     }
-          userptr : pointer;   { Pointer to user defined per item data      }
-          opt : Item_Options;  { Item options                               }
-          index : integer;     { Item number if connected to a menu         }
-          y : integer;         { y and x location of item in menu           }
-          x : integer;
-          value : bool;        { Selection value                            }
-          left : ^tagITEM;     { neighbour items                            }
-          right : ^tagITEM;
-          up : ^tagITEM;
-          down : ^tagITEM;
-       end;
-
-     pITEM = ^tITEM;
-     ppITEM = ^pITEM;
-
-     tagITEM = tITEM;
-
-     Menu_Hook = procedure;cdecl;
-
-     tMENU = record
-          height : integer;       { Nr. of chars high                }
-          width : integer;        { Nr. of chars wide                }
-          rows : integer;         { Nr. of items high                }
-          cols : integer;         { Nr. of items wide                }
-          frows : integer;        { Nr. of formatted items high      }
-          fcols : integer;        { Nr. of formatted items wide      }
-          arows : integer;        { Nr. of items high (actual)       }
-          namelen : integer;      { Max. name length                 }
-          desclen : integer;      { Max. description length          }
-          marklen : integer;      { Length of mark, if any           }
-          itemlen : integer;      { Length of one item               }
-          spc_desc : integer;     { Spacing for descriptor           }
-          spc_cols : integer;     { Spacing for columns              }
-          spc_rows : integer;     { Spacing for rows                 }
-          pattern : ^char;        { Buffer to store match chars      }
-          pindex : integer;       { Index into pattern buffer        }
-          win : ^WINDOW;          { Window containing menu           }
-          sub : ^WINDOW;          { Subwindow for menu display       }
-          userwin : ^WINDOW;      { User's window                    }
-          usersub : ^WINDOW;      { User's subwindow                 }
-          items : ^pITEM;         { array of items                   }
-          nitems : integer;       { Nr. of items in menu             }
-          curitem : pITEM;        { Current item                     }
-          toprow : integer;       { Top row of menu                  }
-          fore : chtype;          { Selection attribute              }
-          back : chtype;          { Nonselection attribute           }
-          grey : chtype;          { Inactive attribute               }
-          pad : byte;             { Pad character                    }
-          menuinit : Menu_Hook;   { User hooks                       }
-          menuterm : Menu_Hook;
-          iteminit : Menu_Hook;
-          itemterm : Menu_Hook;
-          userptr : pointer;      { Pointer to menus user data       }
-          mark : pchar;           { Pointer to marker string         }
-          opt : Menu_Options;     { Menu options                     }
-          status : word;          { Internal state of menu           }
-       end;
-
-     pMENU = ^tMENU;
-     ppMENU = ^pMENU;
-
-     tagMENU = tMENU;
-
-  const
-  { Define keys  }
-     REQ_LEFT_ITEM      = KEY_MAX + 1;
-     REQ_RIGHT_ITEM     = KEY_MAX + 2;
-     REQ_UP_ITEM        = KEY_MAX + 3;
-     REQ_DOWN_ITEM      = KEY_MAX + 4;
-     REQ_SCR_ULINE      = KEY_MAX + 5;
-     REQ_SCR_DLINE      = KEY_MAX + 6;
-     REQ_SCR_DPAGE      = KEY_MAX + 7;
-     REQ_SCR_UPAGE      = KEY_MAX + 8;
-     REQ_FIRST_ITEM     = KEY_MAX + 9;
-     REQ_LAST_ITEM      = KEY_MAX + 10;
-     REQ_NEXT_ITEM      = KEY_MAX + 11;
-     REQ_PREV_ITEM      = KEY_MAX + 12;
-     REQ_TOGGLE_ITEM    = KEY_MAX + 13;
-     REQ_CLEAR_PATTERN  = KEY_MAX + 14;
-     REQ_BACK_PATTERN   = KEY_MAX + 15;
-     REQ_NEXT_MATCH     = KEY_MAX + 16;
-     REQ_PREV_MATCH     = KEY_MAX + 17;
-     MIN_MENU_COMMAND   = KEY_MAX + 1;
-     MAX_MENU_COMMAND   = KEY_MAX + 17;
-  {
-     Some AT&T code expects MAX_COMMAND to be out-of-band not
-     just for menu commands but for forms ones as well.
-     /
-  #if defined(MAX_COMMAND)
-  #  if (MAX_MENU_COMMAND > MAX_COMMAND)
-  #    error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND
-  #  elif (MAX_COMMAND != (KEY_MAX + 128))
-  #    error Something is wrong -- MAX_COMMAND is already inconsistently defined.
-  #  endif
-  #else
-  #  define MAX_COMMAND (KEY_MAX + 128)
-  #endif
-   }
-  { --------- prototypes for libmenu functions -----------------------------  }
-
-  function menu_items(_para1:pMENU):ppITEM;cdecl;external libmenu;
-  function current_item(_para1:pMENU):pITEM;cdecl;external libmenu;
-  function new_item(_para1:pchar; _para2:pchar):pITEM;cdecl;external libmenu;
-  function new_menu(_para1:ppITEM):pMENU;cdecl;external libmenu;
-  function item_opts(_para1:pITEM):Item_Options;cdecl;external libmenu;
-  function menu_opts(_para1:pMENU):Menu_Options;cdecl;external libmenu;
-(*
-  function item_init(_para1:pMENU):Menu_Hook;
-    begin
-       { You must implemented this function }
-    end;
-  function item_term(_para1:pMENU):Menu_Hook;
-    begin
-       { You must implemented this function }
-    end;
-  function menu_init(_para1:pMENU):Menu_Hook;
-    begin
-       { You must implemented this function }
-    end;
-  function menu_term(_para1:pMENU):Menu_Hook;
-    begin
-       { You must implemented this function }
-    end;
-*)
-  function menu_sub(_para1:pMENU):pWINDOW;cdecl;external libmenu;
-  function menu_win(_para1:pMENU):pWINDOW;cdecl;external libmenu;
-  function item_description(_para1:pITEM):pchar;cdecl;external libmenu;
-  function item_name(_para1:pITEM):pchar;cdecl;external libmenu;
-  function menu_mark(_para1:pMENU):pchar;cdecl;external libmenu;
-  function menu_request_name(_para1:longint):pchar;cdecl;external libmenu;
-  function menu_pattern(_para1:pMENU):pchar;cdecl;external libmenu;
-  function menu_userptr(_para1:pMENU):pointer;cdecl;external libmenu;
-  function item_userptr(_para1:pITEM):pointer;cdecl;external libmenu;
-  function menu_back(_para1:pMENU):chtype;cdecl;external libmenu;
-  function menu_fore(_para1:pMENU):chtype;cdecl;external libmenu;
-  function menu_grey(_para1:pMENU):chtype;cdecl;external libmenu;
-  function free_item(_para1:pITEM):longint;cdecl;external libmenu;
-  function free_menu(_para1:pMENU):longint;cdecl;external libmenu;
-  function item_count(_para1:pMENU):longint;cdecl;external libmenu;
-  function item_index(_para1:pITEM):longint;cdecl;external libmenu;
-  function item_opts_off(_para1:pITEM; _para2:Item_Options):longint;cdecl;external libmenu;
-  function item_opts_on(_para1:pITEM; _para2:Item_Options):longint;cdecl;external libmenu;
-  function menu_driver(_para1:pMENU; _para2:longint):longint;cdecl;external libmenu;
-  function menu_opts_off(_para1:pMENU; _para2:Menu_Options):longint;cdecl;external libmenu;
-  function menu_opts_on(_para1:pMENU; _para2:Menu_Options):longint;cdecl;external libmenu;
-  function menu_pad(_para1:pMENU):longint;cdecl;external libmenu;
-  function pos_menu_cursor(_para1:pMENU):longint;cdecl;external libmenu;
-  function post_menu(_para1:pMENU):longint;cdecl;external libmenu;
-  function scale_menu(_para1:pMENU; _para2:plongint; _para3:plongint):longint;cdecl;external libmenu;
-  function set_current_item(menu:pMENU; item:pITEM):longint;cdecl;external libmenu;
-{  function set_item_init(_para1:pMENU; _para2:Menu_Hook):longint;cdecl;external libmenu;}
-  function set_item_opts(_para1:pITEM; _para2:Item_Options):longint;cdecl;external libmenu;
-{  function set_item_term(_para1:pMENU; _para2:Menu_Hook):longint;cdecl;external libmenu;}
-  function set_item_userptr(_para1:pITEM; _para2:pointer):longint;cdecl;external libmenu;
-  function set_item_value(_para1:pITEM; _para2:bool):longint;cdecl;external libmenu;
-  function set_menu_back(_para1:pMENU; _para2:chtype):longint;cdecl;external libmenu;
-  function set_menu_fore(_para1:pMENU; _para2:chtype):longint;cdecl;external libmenu;
-  function set_menu_format(_para1:pMENU; _para2:longint; _para3:longint):longint;cdecl;external libmenu;
-  function set_menu_grey(_para1:pMENU; _para2:chtype):longint;cdecl;external libmenu;
-{  function set_menu_init(_para1:pMENU; _para2:Menu_Hook):longint;cdecl;external libmenu;}
-  function set_menu_items(_para1:pMENU; _para2:ppITEM):longint;cdecl;external libmenu;
-  function set_menu_mark(_para1:pMENU; _para2:pchar):longint;cdecl;external libmenu;
-  function set_menu_opts(_para1:pMENU; _para2:Menu_Options):longint;cdecl;external libmenu;
-  function set_menu_pad(_para1:pMENU; _para2:longint):longint;cdecl;external libmenu;
-  function set_menu_pattern(_para1:pMENU; _para2:pchar):longint;cdecl;external libmenu;
-  function set_menu_sub(_para1:pMENU; _para2:pWINDOW):longint;cdecl;external libmenu;
-{  function set_menu_term(_para1:pMENU; _para2:Menu_Hook):longint;cdecl;external libmenu;}
-  function set_menu_userptr(_para1:pMENU; _para2:pointer):longint;cdecl;external libmenu;
-  function set_menu_win(_para1:pMENU; _para2:pWINDOW):longint;cdecl;external libmenu;
-  function set_top_row(_para1:pMENU; _para2:longint):longint;cdecl;external libmenu;
-  function top_row(_para1:pMENU):longint;cdecl;external libmenu;
-  function unpost_menu(_para1:pMENU):longint;cdecl;external libmenu;
-  function menu_request_by_name(_para1:pchar):longint;cdecl;external libmenu;
-  function set_menu_spacing(_para1:pMENU; _para2:longint; _para3:longint; _para4:longint):longint;cdecl;external libmenu;
-  function menu_spacing(_para1:pMENU; _para2:plongint; _para3:plongint; _para4:plongint):longint;cdecl;external libmenu;
-  function item_value(_para1:pITEM):bool;cdecl;external libmenu;
-  function item_visible(_para1:pITEM):bool;cdecl;external libmenu;
-(*
-  procedure menu_format(_para1:pMENU; _para2:plongint; _para3:plongint);
-    begin
-       { You must implemented this function }
-    end;
-*)
-
-  implementation
 
-begin
 end.

+ 2306 - 1165
packages/ncurses/src/ncurses.pp

@@ -1,1708 +1,2849 @@
-{
-    Copyright (c) 1998 by Michael Van Canneyt
-    member of the Free Pascal development team
-
-    Unit to access the ncurses library
+{$MODE OBJFPC}
 
-    See the file COPYING.FPC included in this distribution,
-    for details about the copyright.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- **********************************************************************}
-{$mode objfpc}
-{
-  Many thanks to Ken Wright for his patches !
-}
 unit ncurses;
 interface
 
-{$packrecords C}
-{$ifdef OpenBSD}                // openbsd curses=ncurses. Openbsd ocurses=old curses.
-{$linklib curses}
-{$else}
-{$linklib ncurses}
-{$endif}
-{$linklib c}
 
-{ Manually Added types }
-type
-  Bool = byte;
-  PINTEGER = ^Longint;
-  PLongint = ^ longint;
-  PFILE = pointer;
+{$PACKRECORDS C}
+{$LINKLIB ncursesw}
+{$LINKLIB c}
+
+{$DEFINE USE_FPC_BYTEBOOL}
 
 const
-{$ifndef openbsd}
-  libncurses = 'ncurses';
-{$else openbsd}
-  libncurses = 'curses';
-{$endif openbsd}
-  NCURSES_VERSION_MAJOR = 5;
-  NCURSES_VERSION_MINOR = 0;
-  NCURSES_VERSION_PATCH = 19991023;
-  NCURSES_VERSION = '5.0';
+   libncurses = 'ncursesw';
+
+type
+   PFILE = Pointer;
+{$IFDEF USE_FPC_BYTEBOOL}
+   Bool = ByteBool;
+{$ELSE USE_FPC_BYTEBOOL}
+   Bool = Byte;
+{$ENDIF USE_FPC_BYTEBOOL}
+
 
 type
-  chtype  = longint;
-  pchtype = pchar;
+   //cint = Longint;
+   wchar_t = Widechar;
+   pwchar_t = ^wchar_t;
+
+const
+{$IFDEF USE_FPC_BYTEBOOL}
+   NC_FPC_TRUE  = true;
+   NC_FPC_FALSE = false;
+{$ELSE USE_FPC_BYTEBOOL}
+   NC_FPC_TRUE  = 1;
+   NC_FPC_FALSE = 0;
+{$ENDIF USE_FPC_BYTEBOOL}
 
 const
-  CXX_BUILTIN_BOOL = 1;
+   NCURSES_VERSION_MAJOR = 5;
+   NCURSES_VERSION_MINOR = 6;
+   NCURSES_VERSION_PATCH = 20061217;
+   NCURSES_VERSION = '5.6';
+   NCURSES_MOUSE_VERSION = 1;
+
+
 type
-  CXX_TYPE_OF_BOOL = char;
+   pchtype = ^chtype;
+   //chtype  = Longword;
+   chtype  = Longint;
+   pmmask_t = ^mmask_t;
+   //mmask_t  = Longword;
+   mmask_t  = Longint;
+
+
+{ colors  }
 
 var
-{$ifndef darwin}
-    COLORS : longint; cvar; external;
-    COLOR_PAIRS : longint; cvar; external;
-{$else darwin}
-    COLORS : longint; external libncurses name 'COLORS';
-    COLOR_PAIRS : longint; external libncurses name 'COLOR_PAIRS';
-{$endif darwin}
-
-    const
-       COLOR_BLACK = 0;
-       COLOR_RED = 1;
-       COLOR_GREEN = 2;
-       COLOR_YELLOW = 3;
-       COLOR_BLUE = 4;
-       COLOR_MAGENTA = 5;
-       COLOR_CYAN = 6;
-       COLOR_WHITE = 7;
+{$IFNDEF darwin}
+   COLORS : Longint cvar; external;
+   COLOR_PAIRS : Longint cvar; external;
+{$ELSE darwin}
+   COLORS : Longint external libncurses name 'COLORS';
+   COLOR_PAIRS : Longint external libncurses name 'COLOR_PAIRS';
+{$ENDIF darwin}
+
+
+const
+   COLOR_BLACK = 0;
+   COLOR_RED = 1;
+   COLOR_GREEN = 2;
+   COLOR_YELLOW = 3;
+   COLOR_BLUE = 4;
+   COLOR_MAGENTA = 5;
+   COLOR_CYAN = 6;
+   COLOR_WHITE = 7;
+
 
 type
-    tacs_map = array [char] of chtype;
-    pacs_map = ^tacs_map;
+   pNC_FPC_COLOR = ^NC_FPC_COLOR;
+   NC_FPC_COLOR = Smallint;
+
+{ line graphics  }
+type
+   tacs_map = array [char] of chtype;
+   pacs_map = ^tacs_map;
 
 var
-{$ifndef darwin}
-    acs_map : tacs_map; cvar; external;
-{$else darwin}
-    acs_map : tacs_map; external libncurses name 'acs_map';
-{$endif darwin}
-
-    function ACS_ULCORNER : chtype;
-    function ACS_LLCORNER : chtype;
-    function ACS_URCORNER : chtype;
-    function ACS_LRCORNER : chtype;
-    function ACS_LTEE     : chtype;
-    function ACS_RTEE     : chtype;
-    function ACS_BTEE     : chtype;
-    function ACS_TTEE     : chtype;
-    function ACS_HLINE    : chtype;
-    function ACS_VLINE    : chtype;
-    function ACS_PLUS     : chtype;
-    function ACS_S1       : chtype;
-    function ACS_S9       : chtype;
-    function ACS_DIAMOND  : chtype;
-    function ACS_CKBOARD  : chtype;
-    function ACS_DEGREE   : chtype;
-    function ACS_PLMINUS  : chtype;
-    function ACS_BULLET   : chtype;
-    function ACS_LARROW   : chtype;
-    function ACS_RARROW   : chtype;
-    function ACS_DARROW   : chtype;
-    function ACS_UARROW   : chtype;
-    function ACS_BOARD    : chtype;
-    function ACS_LANTERN  : chtype;
-    function ACS_BLOCK    : chtype;
-    function ACS_S3       : chtype;
-    function ACS_S7       : chtype;
-    function ACS_LEQUAL   : chtype;
-    function ACS_GEQUAL   : chtype;
-    function ACS_PI       : chtype;
-    function ACS_NEQUAL   : chtype;
-    function ACS_STERLING : chtype;
-    {
-       Line drawing ACS names are of the form ACS_trbl, where t is the top, r
-       is the right, b is the bottom, and l is the left.  t, r, b, and l might
-       be B (blank), S (single), D (double), or T (thick).  The subset defined
-       here only uses B and S.
-     }
-    {
-    #define ACS_BSSB    ACS_ULCORNER
-    #define ACS_SSBB    ACS_LLCORNER
-    #define ACS_BBSS    ACS_URCORNER
-    #define ACS_SBBS    ACS_LRCORNER
-    #define ACS_SBSS    ACS_RTEE
-    #define ACS_SSSB    ACS_LTEE
-    #define ACS_SSBS    ACS_BTEE
-    #define ACS_BSSS    ACS_TTEE
-    #define ACS_BSBS    ACS_HLINE
-    #define ACS_SBSB    ACS_VLINE
-    #define ACS_SSSS    ACS_PLUS
-    }
-
-    const
-       ERR = -(1);
-       OK = 0;
-       _SUBWIN = $01;
-       _ENDLINE = $02;
-       _FULLWIN = $04;
-       _SCROLLWIN = $08;
-       _ISPAD = $10;
-       _HASMOVED = $20;
-       _WRAPPED = $40;
-    {
-       this value is used in the firstchar and lastchar fields to mark
-       unchanged lines
-     }
-       _NOCHANGE = -(1);
-    {
-       this value is used in the oldindex field to mark lines created by insertions
-       and scrolls.
-     }
-       _NEWINDEX = -(1);
-    {
-    typedef struct screen  SCREEN;
-    typedef struct _win_st WINDOW;
-    }
-
-    type
-
-       attr_t = chtype;
-       ldat = record
-            text : ^chtype;
-            firstchar : smallint;
-            lastchar : smallint;
-            oldindex : smallint;
-         end;
-
-       _win_st = record
-            _cury : smallint;
-            _curx : smallint;
-            _maxy : smallint;
-            _maxx : smallint;
-            _begy : smallint;
-            _begx : smallint;
-            _flags : smallint;
-            _attrs : attr_t;
-            _bkgd : chtype;
-            _notimeout : bool;
-            _clear : bool;
-            _leaveok : bool;
-            _scroll : bool;
-            _idlok : bool;
-            _idcok : bool;
-            _immed : bool;
-            _sync : bool;
-            _use_keypad : bool;
-            _delay : longint;
-            _line : ^ldat;
-            _regtop : smallint;
-            _regbottom : smallint;
-            _parx : longint;
-            _pary : longint;
-            _parent : ^WINDOW;
-            _pad : record
-                 _pad_y : smallint;
-                 _pad_x : smallint;
-                 _pad_top : smallint;
-                 _pad_left : smallint;
-                 _pad_bottom : smallint;
-                 _pad_right : smallint;
-              end;
-            _yoffset : smallint;
-         end;
-        WINDOW = _win_st;
-        PWINDOW = ^WINDOW;
-       SCREEN=WINDOW;
-       PSCREEN = PWINDOW;
+{$IFNDEF darwin}
+   acs_map : tacs_map cvar; external;
+{$ELSE darwin}
+   acs_map : tacs_map external libncurses name 'acs_map';
+{$ENDIF darwin}
+
+
+//function NCURSES_ACS(c : Longint) : Longint;
+(* VT100 symbols begin here  *)
+function ACS_ULCORNER : chtype; inline; { upper left corner }
+function ACS_LLCORNER : chtype; inline; { lower left corner }
+function ACS_URCORNER : chtype; inline; { upper right corner }
+function ACS_LRCORNER : chtype; inline; { lower right corner }
+function ACS_LTEE     : chtype; inline; { tee pointing right }
+function ACS_RTEE     : chtype; inline; { tee pointing left }
+function ACS_BTEE     : chtype; inline; { tee pointing up }
+function ACS_TTEE     : chtype; inline; { tee pointing down }
+function ACS_HLINE    : chtype; inline; { horizontal line }
+function ACS_VLINE    : chtype; inline; { vertical line }
+function ACS_PLUS     : chtype; inline; { large plus or crossover }
+function ACS_S1       : chtype; inline; { scan line 1 }
+function ACS_S9       : chtype; inline; { scan line 9 }
+function ACS_DIAMOND  : chtype; inline; { diamond }
+function ACS_CKBOARD  : chtype; inline; { checker board (stipple) }
+function ACS_DEGREE   : chtype; inline; { degree symbol }
+function ACS_PLMINUS  : chtype; inline; { plus/minus }
+function ACS_BULLET   : chtype; inline; { bullet }
+(* Teletype 5410v1 symbols begin here *)
+function ACS_LARROW   : chtype; inline; { arrow pointing left }
+function ACS_RARROW   : chtype; inline; { arrow pointing right }
+function ACS_DARROW   : chtype; inline; { arrow pointing down }
+function ACS_UARROW   : chtype; inline; { arrow pointing up }
+function ACS_BOARD    : chtype; inline; { board of squares }
+function ACS_LANTERN  : chtype; inline; { lantern symbol }
+function ACS_BLOCK    : chtype; inline; { solid square block }
+(*
+ * These aren't documented, but a lot of System Vs have them anyway
+ * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
+ * The ACS_names may not match AT&T's, our source didn't know them.
+ *)
+function ACS_S3       : chtype; inline; { scan line 3 }
+function ACS_S7       : chtype; inline; { scan line 7 }
+function ACS_LEQUAL   : chtype; inline; { less/equal }
+function ACS_GEQUAL   : chtype; inline; { greater/equal }
+function ACS_PI       : chtype; inline; { Pi }
+function ACS_NEQUAL   : chtype; inline; { not equal }
+function ACS_STERLING : chtype; inline; { UK pound sign }
 
-      var
-{$ifndef darwin}
-       stdscr  : PWINDOW; cvar; external;
-       curscr  : PWINDOW; cvar; external;
-       newscr  : PWINDOW; cvar; external;
-       LINES   : longint; cvar; external;
-       COLS    : longint; cvar; external;
-       TABSIZE : longint; cvar; external;
-       ESCDELAY: longint; cvar; external;
-{$else darwin}
-       stdscr  : PWINDOW; external libncurses name 'stdscr';
-       curscr  : PWINDOW; external libncurses name 'curscr';
-       newscr  : PWINDOW; external libncurses name 'newscr';
-       LINES   : longint; external libncurses name 'LINES';
-       COLS    : longint; external libncurses name 'COLS';
-       TABSIZE : longint; external libncurses name 'TABSIZE';
-       ESCDELAY: longint; external libncurses name 'ESCDELAY';
-{$endif darwin}
-
-    function define_key(_para1:pchar; _para2:longint):longint; cdecl;external libncurses;
-    function keyok(_para1:longint; _para2:bool):longint; cdecl;external libncurses;
-    function resizeterm(_para1:longint; _para2:longint):longint; cdecl;external libncurses;
-    function use_default_colors:longint; cdecl;external libncurses;
-    function wresize(_para1:pWINDOW; _para2:longint; _para3:longint):longint; cdecl;external libncurses;
-    {
-    extern char ttytype[];
-    }
-    function baudrate:longint; cdecl;external libncurses;
-    function beep:longint; cdecl;external libncurses;
-    function can_change_color:bool; cdecl;external libncurses;
-    function cbreak:longint; cdecl;external libncurses;
-    function clearok(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-    function color_content(_para1:longint; _para2:plongint; _para3:plongint; _para4:plongint):longint; cdecl;external libncurses;
-
-    function copywin(_para1:pWINDOW; _para2:pWINDOW; _para3:longint; _para4:longint; _para5:longint;
-               _para6:longint; _para7:longint; _para8:longint; _para9:longint):longint;cdecl;external libncurses;
-    function curs_set(_para1:longint):longint; cdecl;external libncurses;
-    function def_prog_mode:longint; cdecl;external libncurses;
-    function def_shell_mode:longint; cdecl;external libncurses;
-    function delay_output(_para1:longint):longint; cdecl;external libncurses;
-    procedure delscreen(_para1:pSCREEN);cdecl;external libncurses;
-    function delwin(_para1:pWINDOW):longint; cdecl;external libncurses;
-
-    function doupdate:longint; cdecl;external libncurses;
-
-    function echo:longint; cdecl;external libncurses;
-    function endwin:longint; cdecl;external libncurses;
-    function erasechar:char; cdecl;external libncurses;
-    procedure filter;cdecl;external libncurses;
-    function flash:longint; cdecl;external libncurses;
-    function flushinp:longint; cdecl;external libncurses;
-
-    function halfdelay(_para1:longint):longint; cdecl;external libncurses;
-    function has_colors:bool; cdecl;external libncurses;
-    function has_ic:longint; cdecl;external libncurses;
-    function has_il:longint; cdecl;external libncurses;
-    procedure idcok(_para1:pWINDOW; _para2:bool);cdecl;external libncurses;
-    function idlok(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-    procedure immedok(_para1:pWINDOW; _para2:bool);cdecl;external libncurses;
-
-    function init_color(_para1:longint; _para2:longint; _para3:longint; _para4:longint):longint; cdecl;external libncurses;
-    function init_pair(_para1:longint; _para2:longint; _para3:longint):longint; cdecl;external libncurses;
-    function intrflush(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-    function isendwin:longint; cdecl;external libncurses;
-    function is_linetouched(_para1:pWINDOW; _para2:longint):longint; cdecl;external libncurses;
-    function is_wintouched(_para1:pWINDOW):longint; cdecl;external libncurses;
-
-
-    function keypad(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-    function killchar:char; cdecl;external libncurses;
-    function leaveok(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-
-    function meta(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-    function mvcur(_para1:longint; _para2:longint; _para3:longint; _para4:longint):longint; cdecl;external libncurses;
-    function mvderwin(_para1:pWINDOW; _para2:longint; _para3:longint):longint; cdecl;external libncurses;
-    function mvprintw(_para1:longint;_para2:longint;_para3:pchar;_para4:array of const):longint; cdecl;external libncurses;
-    {
-    extern int mvscanw(int,int,const char  ,...)
-                GCC_SCANFLIKE(3,4);
-    }
-    function mvwin(_para1:pWINDOW; _para2:longint; _para3:longint):longint; cdecl;external libncurses;
-    function mvwprintw(_para1:pWINDOW;_para2,_para3:longint;_para4:pchar;_para5:array of const):longint; cdecl;external libncurses;
-    {
-    extern int mvwprintw(WINDOW ,int,int,const char  ,...)
-                GCC_PRINTFLIKE(4,5);
-    extern int mvwscanw(WINDOW  ,int,int,const char  ,...)
-                GCC_SCANFLIKE(4,5);
-    }
-    function napms(_para1:longint):longint; cdecl;external libncurses;
-
-    function nl:longint; cdecl;external libncurses;
-    function nocbreak:longint; cdecl;external libncurses;
-    function nodelay(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-    function noecho:longint; cdecl;external libncurses;
-    function nonl:longint; cdecl;external libncurses;
-    function noqiflush:longint; cdecl;external libncurses;
-    function noraw:longint; cdecl;external libncurses;
-    function notimeout(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-
-    function overlay(_para1:pWINDOW; _para2:pWINDOW):longint; cdecl;external libncurses;
-
-    function overwrite(_para1:pWINDOW; _para2:pWINDOW):longint; cdecl;external libncurses;
-    function pair_content(_para1:longint; _para2:plongint; _para3:plongint):longint; cdecl;external libncurses;
-
-    function pechochar(_para1:pWINDOW; _para2:chtype):longint; cdecl;external libncurses;
-    function pnoutrefresh(_para1:pWINDOW; _para2:longint; _para3:longint; _para4:longint; _para5:longint;
-               _para6:longint; _para7:longint):longint;cdecl;external libncurses;
-    function prefresh(_para1:pWINDOW; _para2:longint; _para3:longint; _para4:longint; _para5:longint;
-               _para6:longint; _para7:longint):longint;cdecl;external libncurses;
-    {
-    extern int printw(const char  ,...)
-                GCC_PRINTFLIKE(1,2);
-    }
-    function putp(_para1:pchar):longint; cdecl;external libncurses;
-    function putwin(_para1:pWINDOW; _para2:pFILE):longint; cdecl;external libncurses;
-    function qiflush:longint; cdecl;external libncurses;
-    function raw:longint; cdecl;external libncurses;
-    function resetty:longint; cdecl;external libncurses;
-    function reset_prog_mode:longint; cdecl;external libncurses;
-    function reset_shell_mode:longint; cdecl;external libncurses;
+(*
+ * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
+ * is the right, b is the bottom, and l is the left.  t, r, b, and l might
+ * be B (blank), S (single), D (double), or T (thick).  The subset defined
+ * here only uses B and S.
+ *)
+
+{$IFDEF FPC_OBJFPC}
+property ACS_BSSB : chtype read ACS_ULCORNER;
+property ACS_SSBB : chtype read ACS_LLCORNER;
+property ACS_BBSS : chtype read ACS_URCORNER;
+property ACS_SBBS : chtype read ACS_LRCORNER;
+property ACS_SBSS : chtype read ACS_RTEE;
+property ACS_SSSB : chtype read ACS_LTEE;
+property ACS_SSBS : chtype read ACS_BTEE;
+property ACS_BSSS : chtype read ACS_TTEE;
+property ACS_BSBS : chtype read ACS_HLINE;
+property ACS_SBSB : chtype read ACS_VLINE;
+property ACS_SSSS : chtype read ACS_PLUS;
+{$ENDIF FPC_OBJFPC}
+
+const
+   ERR = -(1);
+   OK = 0;
+   _SUBWIN     = $01; { is this a sub-window? }
+   _ENDLINE   = $02;  { is the window flush right? }
+   _FULLWIN   = $04;  { is the window full-screen? }
+   _SCROLLWIN = $08;  { bottom edge is at screen bottom? }
+   _ISPAD     = $10;  { is this window a pad? }
+   _HASMOVED  = $20;  { has cursor moved since last refresh? }
+   _WRAPPED   = $40;  { cursor was just wrappped }
+   _NOCHANGE  = -(1);
 {
-    function ripoffline(_para1:longint; init:function (_para1:pWINDOW; _para2:longint):longint):longint; cdecl;external libncurses;
+  this value is used in the firstchar and lastchar fields to mark
+  unchanged lines
 }
-    function savetty:longint; cdecl;external libncurses;
-    {
-    extern int scanw(const char  ,...)
-                GCC_SCANFLIKE(1,2);
-    }
-    function scr_dump(_para1:pchar):longint; cdecl;external libncurses;
-
-    function scr_init(_para1:pchar):longint; cdecl;external libncurses;
-    function scrollok(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-
-    function scr_restore(_para1:pchar):longint; cdecl;external libncurses;
-    function scr_set(_para1:pchar):longint; cdecl;external libncurses;
-
-    function slk_attroff(_para1:attr_t):longint; cdecl;external libncurses;
-    function slk_attron(_para1:attr_t):longint; cdecl;external libncurses;
-    function slk_attrset(_para1:attr_t):longint; cdecl;external libncurses;
-    function slk_attr:attr_t; cdecl;external libncurses;
-    function slk_clear:longint; cdecl;external libncurses;
-    function slk_init(_para1:longint):longint; cdecl;external libncurses;
-
-    function slk_noutrefresh:longint; cdecl;external libncurses;
-    function slk_refresh:longint; cdecl;external libncurses;
-    function slk_restore:longint; cdecl;external libncurses;
-
-    function slk_set(_para1:longint; _para2:pchar; _para3:longint):longint; cdecl;external libncurses;
-    function slk_touch:longint; cdecl;external libncurses;
-    function start_color:longint; cdecl;external libncurses;
-
-    function syncok(_para1:pWINDOW; _para2:bool):longint; cdecl;external libncurses;
-    function termattrs:chtype; cdecl;external libncurses;
-
-    function tigetflag(_para1:pchar):longint; cdecl;external libncurses;
-
-    function tigetnum(_para1:pchar):longint; cdecl;external libncurses;
-
-    function derwin (_para1:pWINDOW; _para2:longint; _para3:longint; _para4:longint; _para5:longint):PWINDOW; cdecl;external libncurses;
-    function dupwin (_para1:pWINDOW):PWINDOW; cdecl;external libncurses;
-    function getwin (_para1:pFILE):PWINDOW; cdecl;external libncurses;
-    function initscr :PWINDOW; cdecl;external libncurses;
-    function keyname  (_para1:longint):pchar; cdecl;external libncurses;
-    function longname :pchar; cdecl;external libncurses;
-    function newpad (_para1:longint; _para2:longint):PWINDOW; cdecl;external libncurses;
-    function newterm (_para1:pchar; _para2:pFILE; _para3:pFILE):PSCREEN; cdecl;external libncurses;
-    function newwin  (_para1:longint; _para2:longint; _para3:longint; _para4:longint):PWINDOW; cdecl;external libncurses;
-    function set_term (_para1:pSCREEN):PSCREEN; cdecl;external libncurses;
-    function slk_label (_para1:longint):pchar; cdecl;external libncurses;
-    function subpad (_para1:pWINDOW; _para2:longint; _para3:longint; _para4:longint; _para5:longint):PWINDOW; cdecl;external libncurses;
-    function subwin (_para1:pWINDOW; _para2:longint; _para3:longint; _para4:longint; _para5:longint):PWINDOW; cdecl;external libncurses;
-    function termname :pchar; cdecl;external libncurses;
-    function tigetstr (_para1:pchar):pchar; cdecl;external libncurses;
-    function typeahead(_para1:longint):longint; cdecl;external libncurses;
-    function ungetch(_para1:longint):longint; cdecl;external libncurses;
-    procedure use_env(_para1:bool);cdecl;external libncurses;
-    function vidattr(_para1:chtype):longint; cdecl;external libncurses;
+   _NEWINDEX  = -(1);
+
+   CCHARW_MAX = 5;
+
+
+type
+   pattr_t = ^attr_t;
+   attr_t = chtype;     { ...must be at least as wide as chtype  }
+   pcchar_t  = ^cchar_t;
+
+   cchar_t = record
+     attr : attr_t;
+     chars : array[0..CCHARW_MAX - 1] of wchar_t;
+{$IFDEF NCURSES_EXT_COLORS}
+     ext_color : Longint;  { color pair, must be more than 16-bits }
+{$ENDIF NCURSES_EXT_COLORS}
+   end;
+
+   ldat = record
+     text : pcchar_t;             { text of the line }
+     firstchar : Smallint;        { first changed character in the line }
+     lastchar : Smallint;         { last changed character in the line }
+     oldindex : Smallint;         { index of the line at last update }
+   end;
+
+  PWINDOW = ^TWINDOW;
+
+   _win_st = record
+     _cury, _curx : Smallint;     { current cursor position  }
+{ window location and size  }
+     _maxy, _maxx : Smallint;     { maximums of x and y, NOT window size  }
+     _begy, _begx : Smallint;     { screen coords of upper-left-hand corner  }
+     _flags : Smallint;           { window state flags  }
+{ attribute tracking  }
+     _attrs : attr_t;             { current attribute for non-space character }
+     _bkgd : chtype;              { current background char/attribute pair  }
+{ option values set by user  }
+     _notimeout : Bool;           { no time out on function-key entry?  }
+     _clear : Bool;               { consider all data in the window invalid?  }
+     _leaveok : Bool;             { OK to not reset cursor on exit?  }
+     _scroll : Bool;              { OK to scroll this window?  }
+     _idlok : Bool;               { OK to use insert/delete line?  }
+     _idcok : Bool;               { OK to use insert/delete char?  }
+     _immed : Bool;               { window in immed mode? (not yet used)  }
+     _sync : Bool;                { window in sync mode?  }
+     _use_keypad : Bool;          { process function keys into KEY_ symbols?  }
+     _delay : Longint;            { 0 = nodelay, <0 = blocking, >0 = delay  }
+     _line : ^ldat;               { the actual line data  }
+{ global screen state  }
+     _regtop : Smallint;          { top line of scrolling region  }
+     _regbottom : Smallint;       { bottom line of scrolling region  }
+{ these are used only if this is a sub-window  }
+     _parx : Longint;             { x coordinate of this window in parent  }
+     _pary : Longint;             { y coordinate of this window in parent  }
+     _parent : PWINDOW;           { pointer to parent if a sub-window  }
+{ these are used only if this is a pad  }
+     _pad : record
+        _pad_y : Smallint;
+        _pad_x : Smallint;
+        _pad_top : Smallint;
+        _pad_left : Smallint;
+        _pad_bottom : Smallint;
+        _pad_right : Smallint;
+     end;
+        _yoffset : Smallint;     { real begy is _begy + _yoffset  }
+        _bkgrnd : cchar_t;       { current background char/attribute pair  }
+{$IFDEF NCURSES_EXT_COLORS}
+     _color : Longint;           { current color-pair for non-space character }
+{$ENDIF NCURSES_EXT_COLORS}
+     end;
+
+   TWINDOW = _win_st;
+   TSCREEN = TWINDOW;
+   PSCREEN = ^TSCREEN;
+
+      var
+{$IFNDEF darwin}
+       stdscr  : PWINDOW cvar; external;
+       curscr  : PWINDOW cvar; external;
+       newscr  : PWINDOW cvar; external;
+       LINES   : Longint cvar; external;
+       COLS    : Longint cvar; external;
+       TABSIZE : Longint cvar; external;
+       ESCDELAY: Longint cvar; external;  { ESC expire time in milliseconds  }
+{$ELSE darwin}
+       stdscr  : PWINDOW external libncurses name 'stdscr';
+       curscr  : PWINDOW external libncurses name 'curscr';
+       newscr  : PWINDOW external libncurses name 'newscr';
+       LINES   : Longint external libncurses name 'LINES';
+       COLS    : Longint external libncurses name 'COLS';
+       TABSIZE : Longint external libncurses name 'TABSIZE';
+       ESCDELAY: Longint external libncurses name 'ESCDELAY';
+{$ENDIF darwin}
+
+
+(*
+ * These functions are extensions - not in XSI Curses.
+ *)
+
+function is_term_resized(_para1:Longint; _para2:Longint):Bool;cdecl;external libncurses;
+function keybound(_para1:Longint; _para2:Longint):PChar;cdecl;external  libncurses;
+function curses_version:PChar;cdecl;external  libncurses;
+function assume_default_colors(_para1:Longint; _para2:Longint):Longint; cdecl;external libncurses;
+function define_key(_para1:PChar; _para2:Longint):Longint; cdecl;external libncurses;
+function key_defined(_para1:PChar):Longint; cdecl;external libncurses;
+function keyok(_para1:Longint; _para2:Bool):Longint; cdecl;external libncurses;
+function resize_term(_para1:Longint; _para2:Longint):Longint; cdecl;external libncurses;
+function resizeterm(_para1:Longint; _para2:Longint):Longint; cdecl;external libncurses;
+function use_default_colors:Longint;cdecl;external libncurses;
+function use_extended_names(_para1:Bool):Longint; cdecl;external libncurses;
+function use_legacy_coding(_para1:Longint):Longint; cdecl;external libncurses;
+function wresize(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
+procedure nofilter;cdecl;external  libncurses;
+
+(*
+ * Function prototypes.  This is the complete XSI Curses list of required
+ * functions.
+ *)
+function baudrate:Longint; cdecl;external libncurses;
+function beep:Longint; cdecl;external libncurses;
+function can_change_color:Bool;cdecl;external libncurses;
+function cbreak:Longint; cdecl;external libncurses;
+//function color_content(_para1:Smallint; _para2:PSmallint; _para3:PSmallint; _para4:PSmallInt):Longint; cdecl;external libncurses;
+function color_content(color: NC_FPC_COLOR; r, g, b: PSmallint):Longint; cdecl;external libncurses;
+function copywin(_para1:PWINDOW; _para2:PWINDOW; _para3:Longint; _para4:Longint; _para5:Longint;
+           _para6:Longint; _para7:Longint; _para8:Longint; _para9:Longint):Longint; cdecl;external libncurses;
+function curs_set(_para1:Longint):Longint; cdecl;external libncurses;
+function def_prog_mode:Longint; cdecl;external libncurses;
+function def_shell_mode:Longint; cdecl;external libncurses;
+function delay_output(_para1:Longint):Longint; cdecl;external libncurses;
+procedure delscreen(_para1:PSCREEN);cdecl;external libncurses;
+function delwin(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function derwin(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint):PWINDOW;cdecl;external libncurses;
+function doupdate:Longint; cdecl;external libncurses;
+function dupwin(_para1:PWINDOW):PWINDOW;cdecl;external libncurses;
+function echo:Longint; cdecl;external libncurses;
+function endwin:Longint; cdecl;external libncurses;
+function erasechar:PChar;cdecl;external libncurses;
+procedure filter;cdecl;external libncurses;
+function flash:Longint; cdecl;external libncurses;
+function flushinp:Longint; cdecl;external libncurses;
+function getwin(_para1:PFILE):PWINDOW;cdecl;external libncurses;
+function halfdelay(_para1:Longint):Longint; cdecl;external libncurses;
+function has_colors:Bool;cdecl;external libncurses;
+function has_ic:Bool;cdecl;external libncurses;
+function has_il:Bool;cdecl;external libncurses;
+procedure idcok(_para1:PWINDOW; _para2:Bool);cdecl;external libncurses;
+function idlok(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+procedure immedok(_para1:PWINDOW; _para2:Bool);cdecl;external libncurses;
+function initscr:PWINDOW;cdecl;external libncurses;
+//function init_color(_para1:Smallint; _para2:Smallint; _para3:Smallint; _para4:Smallint):Longint; cdecl;external libncurses;
+function init_color(color: NC_FPC_COLOR; r, g, b: Smallint):Longint; cdecl;external libncurses;
+//function init_pair(_para1:Smallint; _para2:Smallint; _para3:Smallint):Longint; cdecl;external libncurses;
+function init_pair(pair: Smallint; f, b: NC_FPC_COLOR):Longint; cdecl;external libncurses; overload;
+function intrflush(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+function isendwin:Bool;cdecl;external libncurses;
+function is_linetouched(_para1:PWINDOW; _para2:Longint):Bool;cdecl;external libncurses;
+function is_wintouched(_para1:PWINDOW):Bool;cdecl;external libncurses;
+function keyname(_para1:Longint):PChar;cdecl;external libncurses;
+function keypad(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+function killchar:PChar;cdecl;external libncurses;
+function leaveok(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+function longname:PChar;cdecl;external libncurses;
+function meta(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+function mvcur(_para1:Longint; _para2:Longint; _para3:Longint; _para4:Longint):Longint; cdecl;external libncurses;
+function mvderwin(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
+function mvwin(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
+function napms(_para1:Longint):Longint; cdecl;external libncurses;
+function newpad(_para1:Longint; _para2:Longint):PWINDOW;cdecl;external libncurses;
+function newterm(_para1:PChar; _para2:PFILE; _para3:PFILE):PSCREEN;cdecl;external libncurses;
+function newwin(_para1:Longint; _para2:Longint; _para3:Longint; _para4:Longint):PWINDOW;cdecl;external libncurses;
+function nl:Longint; cdecl;external libncurses;
+function nocbreak:Longint; cdecl;external libncurses;
+function nodelay(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+function noecho:Longint; cdecl;external libncurses;
+function nonl:Longint; cdecl;external libncurses;
+procedure noqiflush;cdecl;external libncurses;
+function noraw:Longint; cdecl;external libncurses;
+function notimeout(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+function overlay(_para1:PWINDOW; _para2:PWINDOW):Longint; cdecl;external libncurses;
+function overwrite(_para1:PWINDOW; _para2:PWINDOW):Longint; cdecl;external libncurses;
+//function pair_content(_para1:Smallint; _para2:PSmallint; _para3:PSmallInt):Longint; cdecl;external libncurses;
+function pair_content(pair: Smallint; f, b: pNC_FPC_COLOR):Longint; cdecl;external libncurses;
+function pechochar(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
+function pnoutrefresh(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint;
+           _para6:Longint; _para7:Longint):Longint; cdecl;external libncurses;
+function prefresh(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint;
+           _para6:Longint; _para7:Longint):Longint; cdecl;external libncurses;
+function putwin(_para1:PWINDOW; _para2:PFILE):Longint; cdecl;external libncurses;
+procedure qiflush;cdecl;external libncurses;
+function raw:Longint; cdecl;external libncurses;
+function resetty:Longint; cdecl;external libncurses;
+function reset_prog_mode:Longint; cdecl;external libncurses;
+function reset_shell_mode:Longint; cdecl;external libncurses;
+{function ripoffline(_para1:Longint; _para2:function (_para1:PWINDOW; _para2:Longint):Longint):Longint; cdecl;external libncurses;}//   ->???
+function savetty:Longint; cdecl;external libncurses;
+function scr_dump(_para1:PChar):Longint; cdecl;external libncurses;
+function scr_init(_para1:PChar):Longint; cdecl;external libncurses;
+function scrollok(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+function scr_restore(_para1:PChar):Longint; cdecl;external libncurses;
+function scr_set(_para1:PChar):Longint; cdecl;external libncurses;
+function set_term(_para1:PSCREEN):PSCREEN;cdecl;external libncurses;
+function slk_attroff(_para1:chtype):Longint; cdecl;external libncurses;
+
+function slk_attron(_para1:chtype):Longint; cdecl;external libncurses;
+
+function slk_attrset(_para1:chtype):Longint; cdecl;external libncurses;
+function slk_attr:attr_t;cdecl;external libncurses;
+function slk_attr_set(_para1:attr_t; _para2:Smallint; _para3:Pointer):Longint; cdecl;external libncurses;
+function slk_clear:Longint; cdecl;external libncurses;
+function slk_color(_para1:Smallint):Longint; cdecl;external libncurses;
+function slk_init(_para1:Longint):Longint; cdecl;external libncurses;
+function slk_label(_para1:Longint):PChar;cdecl;external libncurses;
+function slk_noutrefresh:Longint; cdecl;external libncurses;
+function slk_refresh:Longint; cdecl;external libncurses;
+function slk_restore:Longint; cdecl;external libncurses;
+function slk_set(_para1:Longint; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
+function slk_touch:Longint; cdecl;external libncurses;
+function start_color:Longint; cdecl;external libncurses;
+function subpad(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint):PWINDOW;cdecl;external libncurses;
+function subwin(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint; _para5:Longint):PWINDOW;cdecl;external libncurses;
+function syncok(_para1:PWINDOW; _para2:Bool):Longint; cdecl;external libncurses;
+function termattrs:chtype;cdecl;external libncurses;
+function termname:PChar;cdecl;external libncurses;
+function typeahead(_para1:Longint):Longint; cdecl;external libncurses;
+function ungetch(_para1:Longint):Longint; cdecl;external libncurses;
+procedure use_env(_para1:Bool);cdecl;external libncurses;
+function vidattr(_para1:chtype):Longint; cdecl;external libncurses;
+function waddch(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
+function waddchnstr(_para1:PWINDOW; _para2:Pchtype; _para3:Longint):Longint; cdecl;external libncurses;
+function waddnstr(_para1:PWINDOW; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
+function wattr_on(_para1:PWINDOW; _para2:attr_t; _para3:Pointer):Longint; cdecl;external libncurses;
+function wattr_off(_para1:PWINDOW; _para2:attr_t; _para3:Pointer):Longint; cdecl;external libncurses;
+function wbkgd(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
+procedure wbkgdset(_para1:PWINDOW; _para2:chtype);cdecl;external libncurses;
+function wborder(_para1:PWINDOW; _para2:chtype; _para3:chtype; _para4:chtype; _para5:chtype; 
+           _para6:chtype; _para7:chtype; _para8:chtype; _para9:chtype):Longint; cdecl;external libncurses;
+function wchgat(_para1:PWINDOW; _para2:Longint; _para3:attr_t; _para4:Smallint; _para5:Pointer):Longint; cdecl;external libncurses;
+function wclear(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function wclrtobot(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function wclrtoeol(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function wcolor_set(_para1:PWINDOW; _para2:Smallint; _para3:Pointer):Longint; cdecl;external libncurses;
+procedure wcursyncup(_para1:PWINDOW);cdecl;external libncurses;
+function wdelch(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function wechochar(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
+function werase(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function wgetch(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function wgetnstr(_para1:PWINDOW; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
+function whline(_para1:PWINDOW; _para2:chtype; _para3:Longint):Longint; cdecl;external libncurses;
+function winch(_para1:PWINDOW):chtype;cdecl;external libncurses;
+function winchnstr(_para1:PWINDOW; _para2:Pchtype; _para3:Longint):Longint; cdecl;external libncurses;
+function winnstr(_para1:PWINDOW; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
+function winsch(_para1:PWINDOW; _para2:chtype):Longint; cdecl;external libncurses;
+function winsdelln(_para1:PWINDOW; _para2:Longint):Longint; cdecl;external libncurses;
+function winsnstr(_para1:PWINDOW; _para2:PChar; _para3:Longint):Longint; cdecl;external libncurses;
+{ realised as inline function }
+//function wmove(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
+function wnoutrefresh(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function wredrawln(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
+function wrefresh(_para1:PWINDOW):Longint; cdecl;external libncurses;
+function wscrl(_para1:PWINDOW; _para2:Longint):Longint; cdecl;external libncurses;
+function wsetscrreg(_para1:PWINDOW; _para2:Longint; _para3:Longint):Longint; cdecl;external libncurses;
+procedure wsyncdown(_para1:PWINDOW);cdecl;external libncurses;
+procedure wsyncup(_para1:PWINDOW);cdecl;external libncurses;
+procedure wtimeout(_para1:PWINDOW; _para2:Longint);cdecl;external libncurses;
+function wtouchln(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:Longint):Longint; cdecl;external libncurses;
+function wvline(_para1:PWINDOW; _para2:chtype; _para3:Longint):Longint; cdecl;external libncurses;
+
+
+(*
+ * These are also declared in <ncursesw/term.h>:
+ *)
+
+function tigetflag(_para1:PChar):Longint; cdecl;external libncurses;
+function tigetnum(_para1:PChar):Longint; cdecl;external libncurses;
+function tigetstr(_para1:PChar):PChar;cdecl;external libncurses;
+function putp(_para1:PChar):Longint; cdecl;external libncurses;
+
+
+var
+{$IFNDEF darwin}
+   ttytype : array of PChar cvar; external;  { needed for backward compatibility  }
+{$ELSE darwin}
+   ttytype : array of PChar external libncurses  name 'ttytype';
+{$ENDIF darwin}
+
+
+
+(*
+ * Function prototypes for wide-character operations.
+ *)
+{function vid_puts(_para1:attr_t; _para2:Smallint; _para3:pointer; _para4:function (_para1:cint):cint):longint; cdecl;external libncurses;
+function vidputs(_para1:chtype; _para2:function (_para1:Longint):Longint):Longint; cdecl;external libncurses;}
+type TPutc = function(arg:Longint):Longint; cdecl;
+function vid_puts(attrs:attr_t; pair:Smallint; opts:Pointer; _putc:TPutc):Longint; cdecl;external libncurses;
+function vidputs(attrs:chtype; _putc:TPutc):Longint; cdecl;external libncurses;
+
+function erasewchar(_para1:Pwchar_t):Longint; cdecl;external libncurses;
+function getcchar(_para1:Pcchar_t; _para2:Pwchar_t; _para3:Pattr_t; _para4:PSmallInt; _para5:Pointer):Longint; cdecl;external libncurses;
+function key_name(_para1:wchar_t):PChar;cdecl;external libncurses;
+function killwchar(_para1:Pwchar_t):Longint; cdecl;external libncurses;
+function pecho_wchar(_para1:PWINDOW; _para2:Pcchar_t):Longint; cdecl;external libncurses;
+function setcchar(_para1:Pcchar_t; _para2:Pwchar_t; _para3:attr_t; _para4:Smallint; _para5:Pointer):Longint; cdecl;external libncurses;
+function slk_wset(_para1:Longint; _para2:Pwchar_t; _para3:Longint):Longint; cdecl;external libncurses;
+function term_attrs:attr_t;cdecl;external  libncurses;
+function unget_wch(_para1:wchar_t):longint; cdecl;external libncurses;
+function vid_attr(_para1:attr_t; _para2:Smallint; _para3:pointer):longint; cdecl;external libncurses;
+function wadd_wch(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
+function wadd_wchnstr(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
+function waddnwstr(_para1:PWINDOW; _para2:Pwchar_t; _para3:Longint):longint; cdecl;external libncurses;
+function wbkgrnd(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
+procedure wbkgrndset(_para1:PWINDOW; _para2:Pcchar_t);cdecl;external  libncurses;
+function wborder_set(_para1:PWINDOW; _para2:Pcchar_t; _para3:Pcchar_t; _para4:Pcchar_t; _para5:Pcchar_t; 
+           _para6:Pcchar_t; _para7:Pcchar_t; _para8:Pcchar_t; _para9:Pcchar_t):longint; cdecl;external libncurses;
+function wecho_wchar(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
+function wget_wch(_para1:PWINDOW; _para2:PLongint):longint; cdecl;external libncurses;
+function wgetbkgrnd(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
+function wgetn_wstr(_para1:PWINDOW; _para2:PLongint; _para3:Longint):longint; cdecl;external libncurses;
+function whline_set(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
+function win_wch(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
+function win_wchnstr(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
+function winnwstr(_para1:PWINDOW; _para2:Pwchar_t; _para3:Longint):longint; cdecl;external libncurses;
+function wins_nwstr(_para1:PWINDOW; _para2:Pwchar_t; _para3:Longint):longint; cdecl;external libncurses;
+function wins_wch(_para1:PWINDOW; _para2:Pcchar_t):longint; cdecl;external libncurses;
+function winwstr(_para1:PWINDOW; _para2:Pwchar_t):longint; cdecl;external libncurses;
+function wunctrl(_para1:Pcchar_t):Pwchar_t;cdecl;external libncurses;
+function wvline_set(_para1:PWINDOW; _para2:Pcchar_t; _para3:Longint):longint; cdecl;external libncurses;
+
+
+
+const
+   A_NORMAL = 0;
+   A_ATTRIBUTES = (not 0) shl 8;
+   A_CHARTEXT=(1 shl (0 + 8)) - 1;
+   A_COLOR=((1 shl 8) - 1) shl 8;
+   A_STANDOUT = 1 shl (8 + 8);
+   A_UNDERLINE = 1 shl (9 + 8);
+   A_REVERSE = 1 shl (10 + 8);
+   A_BLINK = 1 shl (11 + 8);
+   A_DIM = 1 shl (12 + 8);
+   A_BOLD = 1 shl (13 + 8);
+   A_ALTCHARSET = 1 shl (14 + 8);
+   A_INVIS = 1 shl (15 + 8);
+   A_PROTECT = 1 shl (16 + 8);
+   A_HORIZONTAL = 1 shl (17 + 8);
+   A_LEFT = 1 shl (18 + 8);
+   A_LOW = 1 shl (19 + 8);
+   A_RIGHT = 1 shl (20 + 8);
+   A_TOP = 1 shl (21 + 8);
+   A_VERTICAL = 1 shl (22 + 8);
+
+const
+   WA_ATTRIBUTES = A_ATTRIBUTES;
+   WA_NORMAL = A_NORMAL;
+   WA_STANDOUT = A_STANDOUT;
+   WA_UNDERLINE = A_UNDERLINE;
+   WA_REVERSE = A_REVERSE;
+   WA_BLINK = A_BLINK;
+   WA_DIM = A_DIM;
+   WA_BOLD = A_BOLD;
+   WA_ALTCHARSET = A_ALTCHARSET;
+   WA_INVIS = A_INVIS;
+   WA_PROTECT = A_PROTECT;
+   WA_HORIZONTAL = A_HORIZONTAL;
+   WA_LEFT = A_LEFT;
+   WA_LOW = A_LOW;
+   WA_RIGHT = A_RIGHT;
+   WA_TOP = A_TOP;
+   WA_VERTICAL = A_VERTICAL;
+
+
+
+
+
+function COLOR_PAIR(n: longint): longint; inline;
+function PAIR_NUMBER(attr: attr_t): longint; inline;
+function color_set(color_pair_number: Smallint; opts: Pointer): longint; inline;
+
+
+
+(*  pseudo functions  *)
+
+function wgetstr(win: PWINDOW; s: PChar): Longint;
+function getnstr(s: PChar;n: Longint): Longint; inline;
+function setterm(term: PChar): Longint; inline;
+function fixterm: Longint; inline;
+function resetterm: Longint; inline;
+function saveterm: Longint; inline;
+function crmode: Longint; inline;
+function nocrmode: Longint; inline;
+procedure getyx   (win: PWINDOW; var y,x); inline;
+procedure getbegyx(win: PWINDOW; var y,x); inline;
+procedure getmaxyx(win: PWINDOW; var y,x); inline;
+procedure getparyx(win: PWINDOW; var y,x); inline;
+procedure getsyx  (var y,x); inline;
+procedure setsyx  (y,x: Smallint); inline;
+function getattrs(win: PWINDOW): attr_t; inline;
+function getcurx(win: PWINDOW): Smallint; inline;
+function getcury(win: PWINDOW): Smallint; inline;
+function getbegx(win: PWINDOW): Smallint; inline;
+function getbegy(win: PWINDOW): Smallint; inline;
+function getmaxx(win: PWINDOW): Smallint; inline;
+function getmaxy(win: PWINDOW): Smallint; inline;
+function getparx(win: PWINDOW): Smallint; inline;
+function getpary(win: PWINDOW): Smallint; inline;
+function wstandout(win: PWINDOW): Longint; inline;
+function wstandend(win: PWINDOW): Longint; inline;
+function wattr_set(win:PWINDOW; attrs:attr_t; pair:Smallint; opts:Pointer):Longint; inline;
+//function wattr_get(win: PWINDOW): longint;// original fpc ncurses?
+function wattr_get(win:PWINDOW; attrs:Pattr_t; pair:PSmallint; opts:Pointer):longint; inline;
+function wattron(win:PWINDOW; attrs: attr_t): Longint; inline;
+function wattroff(win:PWINDOW; attrs: attr_t): Longint; inline;
+function wattrset(win: PWINDOW; attrs: attr_t): longint; inline;
+function scroll(win: PWINDOW): longint; inline;
+function touchwin(win: PWINDOW): longint; inline;
+function touchline(win: PWINDOW;s,c: longint): longint; inline;
+function untouchwin(win: PWINDOW): longint; inline;
+function box(win:PWINDOW; v,h :chtype):Longint; inline;
+function border(ls,rs,ts,bs,tl,tr,bl,br: chtype): longint; inline;
+function hline(ch:chtype; n:longint): longint; inline;
+function vline(ch:chtype; n:longint): longint; inline;
+function winstr(win: PWINDOW;s: PChar): longint; inline;
+function winchstr(win: PWINDOW; chstr: pchtype): longint; inline;
+function winsstr(win: PWINDOW;s: PChar): longint; inline;
+function redrawwin(win: PWINDOW): longint; inline;
+function waddstr(win: PWINDOW;st: PChar): longint; inline;
+function waddchstr(win: PWINDOW; chstr: pchtype): longint; inline;
 {
-    function vidputs(_para1:chtype; _para2:function (_para1:longint):longint):longint; cdecl;external libncurses;
+   pseudo functions for standard screen
 }
+function addch(ch: chtype): longint; inline;
+function addchnstr(chstr: pchtype; n: longint): longint; inline;
+function addchstr(chstr: pchtype): longint; inline;
+function addnstr(str: PChar;n: longint): longint; inline;
+function addstr(str: PChar): longint; inline;
+function attroff(attrs: attr_t): longint; inline;
+function attron(attrs: attr_t): longint; inline;
+function attrset(attrs: attr_t): longint; inline;
+function bkgd(ch: chtype): longint; inline;
+procedure bkgdset(ch: chtype); inline;
+function clear: longint; inline;
+function clrtobot: longint; inline;
+function clrtoeol: longint; inline;
+function delch: longint; inline;
+function deleteln: longint; inline;
+function echochar(ch: chtype): longint; inline;
+function erase: longint; inline;
+function getch: longint; inline;
+function getstr(str: PChar): longint; inline;
+function inch: chtype; inline;
+function inchnstr(chstr: pchtype;n: longint): longint; inline;
+function inchstr(chstr: pchtype): longint; inline;
+function innstr(str: PChar;n: longint): longint; inline;
+function insch(ch: chtype): longint; inline;
+function insdelln(n: longint): longint; inline;
+function insertln: longint; inline;
+function insnstr(str: PChar;n: longint): longint; inline;
+function insstr(str: PChar): longint; inline;
+function instr(str: PChar): longint; inline;
+function move(y,x: Smallint): longint; inline;
+function refresh: longint; inline;
+function scrl(n: longint): longint; inline;
+function setscrreg(t,b: longint): longint; inline;
+function standend: longint; inline;
+function standout: longint; inline;
+procedure timeout(delay: longint); inline;
+function wdeleteln(win: PWINDOW): longint; inline;
+function winsertln(win: PWINDOW): longint; inline;
+
 {
-    function vwprintw(_para1:pWINDOW; _para2:pchar; _para3:va_list):longint; cdecl;external libncurses;
-    function vwscanw(_para1:pWINDOW; _para2:pchar; _para3:va_list):longint; cdecl;external libncurses;
-}
-    function waddch(_para1:pWINDOW; _para2:chtype):longint; cdecl;external libncurses;
-    function waddchnstr(_para1:pWINDOW; _para2:pchtype; _para3:longint):longint; cdecl;external libncurses;
-    function waddnstr(_para1:pWINDOW; _para2:pchar; _para3:longint):longint; cdecl;external libncurses;
-    function wattr_on(_para1:pWINDOW; _para2:attr_t):longint; cdecl;external libncurses;
-    function wattr_off(_para1:pWINDOW; _para2:attr_t):longint; cdecl;external libncurses;
-    function wattr_set(win : pwindow; at : longint) : longint; cdecl;external libncurses;
-    function wattron(win : pwindow;at : longint) : longint; cdecl;external libncurses;
-    function wattroff(win : pwindow;at : longint) : longint; cdecl;external libncurses;
-    function wattrset(win : pwindow;at : longint) : longint; cdecl;external libncurses;
-    function wbkgd(_para1:pWINDOW; _para2:chtype):longint; cdecl;external libncurses;
-    procedure wbkgdset(_para1:pWINDOW; _para2:chtype);cdecl;external libncurses;
-    function wborder(_para1:pWINDOW; _para2:chtype; _para3:chtype; _para4:chtype; _para5:chtype;
-               _para6:chtype; _para7:chtype; _para8:chtype; _para9:chtype):longint;cdecl;external libncurses;
-    function wchgat(_para1:pWINDOW; _para2:longint; _para3:attr_t; _para4:longint; _para5:pointer):longint; cdecl;external libncurses;
-    function wclear(_para1:pWINDOW):longint; cdecl;external libncurses;
-    function wclrtobot(_para1:pWINDOW):longint; cdecl;external libncurses;
-    function wclrtoeol(_para1:pWINDOW):longint; cdecl;external libncurses;
-    procedure wcursyncup(_para1:pWINDOW);cdecl;external libncurses;
-    function wdelch(_para1:pWINDOW):longint; cdecl;external libncurses;
-    function wechochar(_para1:pWINDOW; _para2:chtype):longint; cdecl;external libncurses;
-    function werase(_para1:pWINDOW):longint; cdecl;external libncurses;
-    function wgetch(_para1:pWINDOW):longint; cdecl;external libncurses;
-    function wgetnstr(_para1:pWINDOW; _para2:pchar; _para3:longint):longint; cdecl;external libncurses;
-    function whline(_para1:pWINDOW; _para2:chtype; _para3:longint):longint; cdecl;external libncurses;
-    function winch (win : PWindow) : longint; cdecl;external libncurses;
-    function winchnstr(_para1:pWINDOW; _para2:pchtype; _para3:longint):longint; cdecl;external libncurses;
-    function winnstr(_para1:pWINDOW; _para2:pchar; _para3:longint):longint; cdecl;external libncurses;
-    function winsch(_para1:pWINDOW; _para2:chtype):longint; cdecl;external libncurses;
-    function winsdelln(_para1:pWINDOW; _para2:longint):longint; cdecl;external libncurses;
-    function winsnstr(_para1:pWINDOW; _para2:pchar; _para3:longint):longint; cdecl;external libncurses;
-    function wmove(_para1:pWINDOW; _para2:longint; _para3:longint):longint; cdecl;external libncurses;
-    function wnoutrefresh(_para1:pWINDOW):longint; cdecl;external libncurses;
-    {
-    extern int wprintw(WINDOW  ,const char  ,...)
-                GCC_PRINTFLIKE(2,3);
-    }
-    function wredrawln(_para1:pWINDOW; _para2:longint; _para3:longint):longint; cdecl;external libncurses;
-    function wrefresh(_para1:pWINDOW):longint; cdecl;external libncurses;
-    {
-    extern int wscanw(WINDOW  ,const char  ,...)
-                GCC_SCANFLIKE(2,3);
-    }
-    function wscrl(_para1:pWINDOW; _para2:longint):longint; cdecl;external libncurses;
-    function wsetscrreg(_para1:pWINDOW; _para2:longint; _para3:longint):longint; cdecl;external libncurses;
-    procedure wsyncdown(_para1:pWINDOW);cdecl;external libncurses;
-    procedure wsyncup(_para1:pWINDOW);cdecl;external libncurses;
-    function wtimeout(_para1:pWINDOW; _para2:longint):longint; cdecl;external libncurses;
-    function wtouchln(_para1:pWINDOW; _para2:longint; _para3:longint; _para4:longint):longint; cdecl;external libncurses;
-    function wvline(_para1:pWINDOW; _para2:chtype; _para3:longint):longint; cdecl;external libncurses;
-    function mvwchgat(_para1:pWINDOW; _para2:longint; _para3:longint;
-                      _para4:longint; _para5:longint; _para6:longint;
-                      _para7:longint):longint;cdecl;external libncurses;
-    function PAIR_NUMBER(_para1:longint):longint;cdecl;external libncurses;
-
-    const
-           A_NORMAL = 0;
-           A_ATTRIBUTES = (not 0) shl 8;
-           A_CHARTEXT=(1 shl (0 + 8)) - 1;
-           A_COLOR=((1 shl 8) - 1) shl 8;
-           A_STANDOUT = 1 shl (8 + 8);
-           A_UNDERLINE = 1 shl (9 + 8);
-           A_REVERSE = 1 shl (10 + 8);
-           A_BLINK = 1 shl (11 + 8);
-           A_DIM = 1 shl (12 + 8);
-           A_BOLD = 1 shl (13 + 8);
-           A_ALTCHARSET = 1 shl (14 + 8);
-           A_INVIS = 1 shl (15 + 8);
-           A_PROTECT = 1 shl (16 + 8);
-           A_HORIZONTAL = 1 shl (17 + 8);
-           A_LEFT = 1 shl (18 + 8);
-           A_LOW = 1 shl (19 + 8);
-           A_RIGHT = 1 shl (20 + 8);
-           A_TOP = 1 shl (21 + 8);
-           A_VERTICAL = 1 shl (22 + 8);
-     function color_pair(n : longint): longint;
+   mv functions
+ }
+
+function mvwaddch(win: PWINDOW;y,x: Smallint; ch: chtype): longint; inline;
+function mvwaddchnstr(win: PWINDOW;y,x: Smallint; chstr: pchtype; n: longint): longint; inline;
+function mvwaddchstr(win: PWINDOW;y,x: Smallint; chstr: pchtype): longint; inline;
+function mvwaddnstr(win: PWINDOW;y,x: Smallint; str: PChar; n: longint): longint; inline;
+function mvwaddstr(win: PWINDOW;y,x: Smallint; str: PChar): longint; inline;
+function mvwdelch(win: PWINDOW; y,x: Smallint): longint;
+function mvwchgat(win: PWINDOW;y, x: Smallint; n: Longint;attr: attr_t;
+                            color: Smallint; opts: Pointer): longint; inline;
+function mvwgetch(win: PWINDOW; y,x: Smallint): longint; inline;
+function mvwgetnstr(win: PWINDOW; y,x: Smallint; str: PChar; n: longint): longint; inline;
+function mvwgetstr(win: PWINDOW; y,x: Smallint; str: PChar): longint; inline;
+function mvwhline(win: PWINDOW; y,x: Smallint; ch: chtype; n: longint): longint; inline;
+function mvwinch(win: PWINDOW;y,x: Smallint): chtype; inline;
+function mvwinchnstr(win: PWINDOW;y,x: Smallint;chstr: pchtype; n: longint): longint; inline;
+function mvwinchstr(win: PWINDOW;y,x: Smallint;chstr: pchtype): longint; inline;
+function mvwinnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint; inline;
+function mvwinsch(win: PWINDOW;y,x: Smallint;ch: chtype): longint; inline;
+function mvwinsnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint; inline;
+function mvwinsstr(win: PWINDOW;y,x: Smallint;str: PChar): longint; inline;
+function mvwinstr(win: PWINDOW;y,x: Smallint;str: PChar): longint; inline;
+function mvwvline(win: PWINDOW;y,x: Smallint;ch: chtype;n: longint): longint; inline;
+function mvaddch(y,x: Smallint; ch: chtype): longint; inline;
+function mvaddchnstr(y,x: Smallint; chstr: pchtype;n: longint): longint; inline;
+function mvaddchstr(y,x: Smallint; chstr: pchtype): longint; inline;
+function mvaddnstr(y,x: Smallint; str: PChar;n: longint): longint; inline;
+function mvaddstr(y,x: Smallint; str: PChar): longint; inline;
+function mvdelch(y,x: Smallint): longint; inline;
+function mvgetch(y,x: Smallint): longint; inline;
+function mvgetnstr(y,x: Smallint; str: PChar;n: longint): longint; inline;
+function mvgetstr(y,x: Smallint; str: PChar): longint; inline;
+function mvhline(y,x: Smallint;ch: chtype;n: longint): longint; inline;
+function mvinch(y,x: Smallint): chtype; inline;
+function mvinchnstr(y,x: Smallint; chstr: pchtype;n: longint): longint; inline;
+function mvinchstr(y,x: Smallint; chstr: pchtype): longint; inline;
+function mvinnstr(y,x: Smallint; str: PChar;n: longint): longint; inline;
+function mvinsch(y,x: Smallint;ch: chtype): longint; inline;
+function mvinsnstr(y,x: Smallint; str: PChar;n: longint): longint; inline;
+function mvinsstr(y,x: Smallint; str: PChar): longint; inline;
+function mvinstr(y,x: Smallint; str: PChar): longint; inline;
+function mvvline(y,x: Smallint; ch:chtype; n:longint): longint; inline;
+function attr_get(attrs:Pattr_t; pair:PSmallint; opts:Pointer): longint; inline;
+function attr_off(attrs:attr_t; opts:Pointer): longint; inline;
+function attr_on(attrs:attr_t; opts:Pointer): longint; inline;
+function attr_set(attrs:attr_t; pair:Smallint; opts:Pointer): longint; inline;
+function chgat(n: Longint;attr: attr_t;color: Smallint; opts: Pointer): longint; inline;
+{not present in fpc ncurses}
+function mvchgat(y, x: Smallint; n: Longint;attr: attr_t;color: Smallint; opts: Pointer):Longint; inline;
+function getbkgd(win: PWINDOW): chtype; inline;
+function slk_attr_off(attrs: attr_t; opts: Pointer) : longint; inline;
+function slk_attr_on(attrs: attr_t; opts: Pointer): longint; inline;
+
+
+
+
+
+(*
+ * Pseudo-character tokens outside ASCII range.  The curses wgetch() function
+ * will return any given one of these only if the corresponding k- capability
+ * is defined in your terminal's terminfo entry.
+ *
+ * Some keys (KEY_A1, etc) are arranged like this:
+ *  a1     up    a3
+ *  left   b2    right
+ *  c1     down  c3
+ *
+ * A few key codes do not depend upon the terminfo entry.
+ *)
+
+const
+   KEY_CODE_YES = 256;  { A wchar_t contains a key code    &0400 }
+   KEY_MIN = 257;       { Minimum curses key    &0401 }
+   KEY_BREAK = 257;     { Break key (unreliable)   &0401 }
+   KEY_SRESET = 344;    { Soft (partial) reset (unreliable)    &0530 }
+   KEY_RESET = 345;     { Reset or hard reset (unreliable)    &0531 }
+   KEY_DOWN = 258;      { down-arrow key    &0402 }
+   KEY_UP = 259;        { up-arrow key    &0403 }
+   KEY_LEFT = 260;      { left-arrow key    &0404 }
+   KEY_RIGHT = 261;     { right-arrow key    &0405 }
+   KEY_HOME = 262;      { home key    &0406 }
+   KEY_BACKSPACE = 263; { backspace key    &0407 }
+   KEY_F0 = 264;        { Function keys.  Space for 64    &0410 }
+
+{ Manually Added KEY_F1 .. KEY_F12 }
+
+   KEY_F1 = KEY_F0 + 1;
+   KEY_F2 = KEY_F0 + 2;
+   KEY_F3 = KEY_F0 + 3;
+   KEY_F4 = KEY_F0 + 4;
+   KEY_F5 = KEY_F0 + 5;
+   KEY_F6 = KEY_F0 + 6;
+   KEY_F7 = KEY_F0 + 7;
+   KEY_F8 = KEY_F0 + 8;
+   KEY_F9 = KEY_F0 + 9;
+   KEY_F10 = KEY_F0 + 10;
+   KEY_F11 = KEY_F0 + 11;
+   KEY_F12 = KEY_F0 + 12;
+
+
+function KEY_F(n : Byte) : chtype; inline;
+
+const
+   KEY_DL = 328;        { delete-line key    &0510 }
+   KEY_IL = 329;        { insert-line key    &0511 }
+   KEY_DC = 330;        { delete-character key    &0512 }
+   KEY_IC = 331;        { insert-character key    &0513 }
+   KEY_EIC = 332;       { sent by rmir or smir in insert mode    &0514 }
+   KEY_CLEAR = 333;     { clear-screen or erase key    &0515 }
+   KEY_EOS = 334;       { clear-to-end-of-screen key    &0516 }
+   KEY_EOL = 335;       { clear-to-end-of-line key    &0517 }
+   KEY_SF = 336;        { scroll-forward key    &0520 }
+   KEY_SR = 337;        { scroll-backward key    &0521 }
+   KEY_NPAGE = 338;     { next-page key    &0522 }
+   KEY_PPAGE = 339;     { previous-page key    &0523 }
+   KEY_STAB = 340;      { set-tab key    &0524 }
+   KEY_CTAB = 341;      { clear-tab key    &0525 }
+   KEY_CATAB = 342;     { clear-all-tabs key    &0526 }
+   KEY_ENTER = 343;     { enter/send key    &0527 }
+   KEY_PRINT = 346;     { print key    &0532 }
+   KEY_LL = 347;        { lower-left key (home down)    &0533 }
+   KEY_A1 = 348;        { upper left of keypad    &0534 }
+   KEY_A3 = 349;        { upper right of keypad    &0535 }
+   KEY_B2 = 350;        { center of keypad    &0536 }
+   KEY_C1 = 351;        { lower left of keypad    &0537 }
+   KEY_C3 = 352;        { lower right of keypad    &0540 }
+   KEY_BTAB = 353;      { back-tab key    &0541 }
+   KEY_BEG = 354;       { begin key    &0542 }
+   KEY_CANCEL = 355;    { cancel key    &0543 }
+   KEY_CLOSE = 356;     { close key    &0544 }
+   KEY_COMMAND = 357;   { command key   &0545  }
+   KEY_COPY = 358;      { copy key    &0546 }
+   KEY_CREATE = 359;    { create key    &0547 }
+   KEY_END = 360;       { end key    &0550 }
+   KEY_EXIT = 361;      { exit key    &0551 }
+   KEY_FIND = 362;      { find key    &0552 }
+   KEY_HELP = 363;      { help key    &0553 }
+   KEY_MARK = 364;      { mark key    &0554 }
+   KEY_MESSAGE = 365;   { message key    &0555 }
+   KEY_MOVE = 366;      { move key    &0556 }
+   KEY_NEXT = 367;      { next key    &0557 }
+   KEY_OPEN = 368;      { open key    &0560 }
+   KEY_OPTIONS = 369;   { options key    &0561 }
+   KEY_PREVIOUS = 370;  { previous key    &0562 }
+   KEY_REDO = 371;      { redo key    &0563 }
+   KEY_REFERENCE = 372; { reference key    &0564 }
+   KEY_REFRESH = 373;   { refresh key    &0565 }
+   KEY_REPLACE = 374;   { replace key    &0566 }
+   KEY_RESTART = 375;   { restart key    &0567 }
+   KEY_RESUME = 376;    { resume key    &0570 }
+   KEY_SAVE = 377;      { save key    &0571 }
+   KEY_SBEG = 378;      { shifted begin key    &0572 }
+   KEY_SCANCEL = 379;   { shifted cancel key    &0573 }
+   KEY_SCOMMAND = 380;  { shifted command key    &0574 }
+   KEY_SCOPY = 381;     { shifted copy key    &0575 }
+   KEY_SCREATE = 382;   { shifted create key    &0576 }
+   KEY_SDC = 383;       { shifted delete-character key    &0577 }
+   KEY_SDL = 384;       { shifted delete-line key    &0600 }
+   KEY_SELECT = 385;    { select key    &0601 }
+   KEY_SEND = 386;      { shifted end key    &0602 }
+   KEY_SEOL = 387;      { shifted clear-to-end-of-line key    &0603 }
+   KEY_SEXIT = 388;     { shifted exit key    &0604 }
+   KEY_SFIND = 389;     { shifted find key    &0605 }
+   KEY_SHELP = 390;     { shifted help key    &0606 }
+   KEY_SHOME = 391;     { shifted home key    &0607 }
+   KEY_SIC = 392;       { shifted insert-character key    &0610 }
+   KEY_SLEFT = 393;     { shifted left-arrow key    &0611 }
+   KEY_SMESSAGE = 394;  { shifted message key    &0612 }
+   KEY_SMOVE = 395;     { shifted move key    &0613 }
+   KEY_SNEXT = 396;     { shifted next key    &0614 }
+   KEY_SOPTIONS = 397;  { shifted options key    &0615 }
+   KEY_SPREVIOUS = 398; { shifted previous key    &0616 }
+   KEY_SPRINT = 399;    { shifted print key   &0617 }
+   KEY_SREDO = 400;     { shifted redo key    &0620 }
+   KEY_SREPLACE = 401;  { shifted replace key    &0621 }
+   KEY_SRIGHT = 402;    { shifted right-arrow key    &0622 }
+   KEY_SRSUME = 403;    { shifted resume key    &0623 }
+   KEY_SSAVE = 404;     { shifted save key    &0624 }
+   KEY_SSUSPEND = 405;  { shifted suspend key    &0625 }
+   KEY_SUNDO = 406;     { shifted undo key    &0626 }
+   KEY_SUSPEND = 407;   { suspend key    &0627 }
+   KEY_UNDO = 408;      { undo key     &0630}
+   KEY_MOUSE = 409;     { Mouse event has occurred    &0631 }
+   KEY_RESIZE = 410;    { Terminal resize event    &0632 }
+   KEY_EVENT = 411;     { We were interrupted by an event    &0633 }
+   KEY_MAX = 511;       { Maximum key value is 0633    &0777 }
+
+
+type
+   //tnc_wacs= array [char] of cchar_t;
+   tnc_wacs= array of cchar_t;
+   pnc_wacs = ^tacs_map;
+
+var
+{$IFNDEF darwin}
+   //_nc_wacs : pcchar_t cvar; external;
+   _nc_wacs : tnc_wacs cvar; external;
+{$ELSE darwin}
+   //_nc_wacs : pcchar_t external libncurses name '_nc_wacs';
+   _nc_wacs : tnc_wacs external libncurses name '_nc_wacs';
+{$ENDIF darwin}
+
+function NCURSES_WACS(c: chtype): cchar_t; inline;
+
+function WACS_BSSB: cchar_t; inline;
+function WACS_SSBB: cchar_t; inline;
+function WACS_BBSS: cchar_t; inline;
+function WACS_SBBS: cchar_t; inline;
+function WACS_SBSS: cchar_t; inline;
+function WACS_SSSB: cchar_t; inline;
+function WACS_SSBS: cchar_t; inline;
+function WACS_BSSS: cchar_t; inline;
+function WACS_BSBS: cchar_t; inline;
+function WACS_SBSB: cchar_t; inline;
+function WACS_SSSS: cchar_t; inline;
+function WACS_S1: cchar_t; inline;
+function WACS_S9: cchar_t; inline;
+function WACS_DIAMOND: cchar_t; inline;
+function WACS_CKBOARD: cchar_t; inline;
+function WACS_DEGREE: cchar_t; inline;
+function WACS_PLMINUS: cchar_t; inline;
+function WACS_BULLET: cchar_t; inline;
+function WACS_LARROW: cchar_t; inline;
+function WACS_RARROW: cchar_t; inline;
+function WACS_DARROW: cchar_t; inline;
+function WACS_UARROW: cchar_t; inline;
+function WACS_BOARD: cchar_t; inline;
+function WACS_LANTERN: cchar_t; inline;
+function WACS_BLOCK: cchar_t; inline;
+function WACS_S3: cchar_t; inline;
+function WACS_S7: cchar_t; inline;
+function WACS_LEQUAL: cchar_t; inline;
+function WACS_GEQUAL: cchar_t; inline;
+function WACS_PI: cchar_t; inline;
+function WACS_NEQUAL: cchar_t; inline;
+function WACS_STERLING: cchar_t; inline;
+
+{$IFDEF FPC_OBJFPC}
+property WACS_ULCORNER : cchar_t read WACS_BSSB;
+property WACS_LLCORNER : cchar_t read WACS_SSBB;
+property WACS_URCORNER : cchar_t read WACS_BBSS;
+property WACS_LRCORNER : cchar_t read WACS_SBBS;
+property WACS_RTEE : cchar_t read WACS_SBSS;
+property WACS_LTEE : cchar_t read WACS_SSSB;
+property WACS_BTEE : cchar_t read WACS_SSBS;
+property WACS_TTEE : cchar_t read WACS_BSSS;
+property WACS_HLINE : cchar_t read WACS_BSBS;
+property WACS_VLINE : cchar_t read WACS_SBSB;
+property WACS_PLUS : cchar_t read WACS_SSSS;
+{$ENDIF FPC_OBJFPC}
+
+
+(* mouse interface *)
+
+
+
+
+(*  event masks  *)
+
+const
+   BUTTON1_RELEASED       = 1;
+   BUTTON1_PRESSED        = 2;
+   BUTTON1_CLICKED        = 4;
+   BUTTON1_DOUBLE_CLICKED = 8;
+   BUTTON1_TRIPLE_CLICKED = 16;
+
+   BUTTON2_RELEASED       = 1 shl 6;
+   BUTTON2_PRESSED        = 2 shl 6;
+   BUTTON2_CLICKED        = 4 shl 6;
+   BUTTON2_DOUBLE_CLICKED = 8 shl 6;
+   BUTTON2_TRIPLE_CLICKED = 16 shl 6;
+
+   BUTTON3_RELEASED       = 1 shl (2 * 6);
+   BUTTON3_PRESSED        = 2 shl (2 * 6);
+   BUTTON3_CLICKED        = 4 shl (2 * 6);
+   BUTTON3_DOUBLE_CLICKED = 8 shl (2 * 6);
+   BUTTON3_TRIPLE_CLICKED = 16 shl (2 * 6);
+
+   BUTTON4_RELEASED       = 1 shl (3 * 6);
+   BUTTON4_PRESSED        = 2 shl (3 * 6);
+   BUTTON4_CLICKED        = 4 shl (3 * 6);
+   BUTTON4_DOUBLE_CLICKED = 8 shl (3 * 6);
+   BUTTON4_TRIPLE_CLICKED = 16 shl (3 * 6);
+
+   BUTTON1_RESERVED_EVENT = 32;
+   BUTTON2_RESERVED_EVENT = 32 shl 6;
+   BUTTON3_RESERVED_EVENT = 32 shl (2 * 6);
+   BUTTON4_RESERVED_EVENT = 32 shl (3 * 6);
+
+   BUTTON_CTRL            = 1 shl (4 * 6);
+   BUTTON_SHIFT           = 2 shl (4 * 6);
+   BUTTON_ALT             = 4 shl (4 * 6);
+   REPORT_MOUSE_POSITION  = 8 shl (4 * 6);
+
+   ALL_MOUSE_EVENTS       = REPORT_MOUSE_POSITION - 1;
+
+
+
+(* macros to extract single event-bits from masks *)
+
+function BUTTON_RELEASE(e,x: longint): longint; inline;
+function BUTTON_PRESS(e,x: longint): longint; inline;
+function BUTTON_CLICK(e,x: longint): longint; inline;
+function BUTTON_DOUBLE_CLICK(e,x: longint): longint; inline;
+function BUTTON_TRIPLE_CLICK(e,x: longint): longint; inline;
+function BUTTON_RESERVED_EVENT(e,x: longint): longint; inline;
+function mouse_trafo(pY,pX: PLongint; to_screen: Bool): Bool; inline;
+
+
+
+type
+   PMEVENT = ^MEVENT;
+   MEVENT = record
+   id : Smallint;        { ID to distinguish multiple devices }
+   x, y, z : Longint;    { event coordinates (character-cell) }
+   bstate : mmask_t;     { button state bits }
+end;
+
+
+function getmouse(_para1:PMEVENT):longint; cdecl;external libncurses;
+function ungetmouse(_para1:PMEVENT):longint; cdecl;external libncurses;
+function mousemask(_para1:mmask_t; _para2:Pmmask_t):mmask_t;cdecl;external;
+function wenclose(_para1:PWINDOW; _para2:Longint; _para3:Longint):Bool;cdecl;external;
+function mouseinterval(_para1:Longint):longint; cdecl;external libncurses;
+function wmouse_trafo(_para1:PWINDOW; _para2:PLongint; _para3:PLongint; _para4:Bool):Bool;cdecl;external;
+
+
+
 {
-           PAIR_NUMBER = (a(@(A_COLOR))) shr 8;
+ wide-character (enhanced) functionality
 }
 
-    {
-       pseudo functions
-     }
-    function wgetstr(w : pwindow;s : pchar) : longint;
-    function getnstr(s : pchar;n : longint) : longint;
-    function setterm(term : longint) : longint;
-    function fixterm : longint;
-    function resetterm : longint;
-    function saveterm : longint;
-    function crmode : longint;
-    function nocrmode : longint;
-    procedure getyx   (win : pwindow; var y,x : longint);
-    procedure getbegyx(win : pwindow; var y,x : longint);
-    procedure getmaxyx(win : pwindow; var y,x : longint);
-    procedure getparyx(win : pwindow; var y,x : longint);
-    procedure getsyx  (var y,x : longint);
-    procedure setsyx (y,x : longint);
-    function getattrs(win : pwindow) : longint;
-    function getcurx(win : pwindow) : longint;
-    function getcury(win : pwindow) : longint;
-    function getbegx(win : pwindow) : longint;
-    function getbegy(win : pwindow) : longint;
-    function getmaxx(win : pwindow) : longint;
-    function getmaxy(win : pwindow) : longint;
-    function getparx(win : pwindow) : longint;
-    function getpary(win : pwindow) : longint;
-    function wstandout(win : pwindow) : longint;
-    function wstandend(win : pwindow) : longint;
-{kjw, 08/24/2000, changed to cdecl; external
-    function wattr_set(win : pwindow; at : longint) : longint;
-    function wattron(win : pwindow;at : longint) : longint;
-    function wattroff(win : pwindow;at : longint) : longint;
-    function wattrset(win : pwindow;at : longint) : longint;
-}
-    function scroll(win : pwindow) : longint;
-    function touchwin(win : pwindow) : longint;
-    function touchline(win : pwindow;s,c : longint) : longint;
-    function untouchwin(win : pwindow) : longint;
-    function box(win : pwindow;v,h : longint) : longint;
-    function border(ls,rs,ts,bs,tl,tr,bl,br : longint) : longint;
-    function hline(ch,n : longint) : longint;
-    function vline(ch,n : longint) : longint;
-    function winstr(w : pwindow;s : pchar) : longint;
-    function winchstr(w : pwindow;s : pchar) : longint;
-    function winsstr(w : pwindow;s : pchar) : longint;
-    function redrawwin(w : pwindow) : longint;
-    function waddstr(win : pwindow;st : pchar) : longint;
-    function waddchstr(win : pwindow;st : pchar) : longint;
-    {
-       pseudo functions for standard screen
-     }
-    function addch(ch : longint) : longint;
-    function addchnstr(st : pchar;n : longint) : longint;
-    function addchstr(st : pchar) : longint;
-    function addnstr(st : pchar;n : longint) : longint;
-    function addstr(st : pchar) : longint;
-    function attroff(at : longint) : longint;
-    function attron(at : longint) : longint;
-    function attrset(at : longint) : longint;
-    function bkgd(ch : longint) : longint;
-    procedure bkgdset(ch : longint);
-    function clear : longint;
-    function clrtobot : longint;
-    function clrtoeol : longint;
-    function delch : longint;
-    function deleteln : longint;
-    function echochar(c : longint) : longint;
-    function erase : longint;
-    function getch : longint;
-    function getstr(st : pchar) : longint;
-    function inch : longint;
-    function inchnstr(s : pchar;n : longint) : longint;
-    function inchstr(s : pchar) : longint;
-    function innstr(s : pchar;n : longint) : longint;
-    function insch(c : longint) : longint;
-    function insdelln(n : longint) : longint;
-    function insertln : longint;
-    function insnstr(s : pchar;n : longint) : longint;
-    function insstr(s : pchar) : longint;
-    function instr(s : pchar) : longint;
-    function move(y,x : longint) : longint;
-    function refresh : longint;
-    function scrl(n : longint) : longint;
-    function setscrreg(t,b : longint) : longint;
-    function standend : longint;
-    function standout : longint;
-    function timeout(delay : longint) : longint;
-    function wdeleteln(win : pwindow) : longint;
-    function winsertln(win : pwindow) : longint;
-    {
-       mv functions
-     }
-    function mvwaddch(win : pwindow;y,x : longint; ch : chtype) : longint;
-    function mvwaddchnstr(win : pwindow;y,x : longint;st : pchar;n : longint) : longint;
-    function mvwaddchstr(win : pwindow;y,x : longint;st : pchar) : longint;
-    function mvwaddnstr(win : pwindow;y,x : longint;st : pchar;n : longint) : longint;
-    function mvwaddstr(win : pwindow;y,x : longint;st : pchar) : longint;
-    function mvwdelch(win : pwindow;y,x : longint) : longint;
-    function mvwgetch(win : pwindow;y,x : longint) : longint;
-    function mvwgetnstr(win : pwindow;y,x : longint;st : pchar;n: longint) : longint;
-    function mvwgetstr(win : pwindow;y,x : longint;st: pchar) : longint;
-    function mvwhline(win : pwindow;y,x : longint;c : chtype;n : longint) : longint;
-    function mvwinch(win : pwindow;y,x : longint) : longint;
-    function mvwinchnstr(win : pwindow;y,x : longint;s : pchar; n : longint) : longint;
-    function mvwinchstr(win : pwindow;y,x : longint;s : pchar) : longint;
-    function mvwinnstr(win : pwindow;y,x : longint;s : pchar;n : longint) : longint;
-    function mvwinsch(win : pwindow;y,x : longint;c : chtype) : longint;
-    function mvwinsnstr(win : pwindow;y,x : longint;s : pchar;n : longint) : longint;
-    function mvwinsstr(win : pwindow;y,x : longint;s : pchar) : longint;
-    function mvwinstr(win : pwindow;y,x : longint;s : pchar) : longint;
-    function mvwvline(win : pwindow;y,x : longint;c : chtype;n : longint) : longint;
-    function mvaddch(y,x,ch : longint) : longint;
-    function mvaddchnstr(y,x : longint; st: pchar;n : longint) : longint;
-    function mvaddchstr(y,x : longint; st : pchar) : longint;
-    function mvaddnstr(y,x : longint; st : pchar;n : longint) : longint;
-    function mvaddstr(y,x : longint; st : pchar) : longint;
-    function mvdelch(y,x : longint) : longint;
-    function mvgetch(y,x : longint) : longint;
-    function mvgetnstr(y,x : longint; st : pchar;n : longint) : longint;
-    function mvgetstr(y,x : longint; st : pchar) : longint;
-    function mvhline(y,x : longint;c : chtype;n : longint) : longint;
-    function mvinch(y,x : longint) : longint;
-    function mvinchnstr(y,x : longint; s : pchar;n : longint) : longint;
-    function mvinchstr(y,x : longint; s : pchar) : longint;
-    function mvinnstr(y,x : longint; s : pchar;n : longint) : longint;
-    function mvinsch(y,x: longint;c : chtype) : longint;
-    function mvinsnstr(y,x : longint; s : pchar;n : longint) : longint;
-    function mvinsstr(y,x : longint; s : pchar) : longint;
-    function mvinstr(y,x : longint; s : pchar) : longint;
-    function mvvline(y,x,c,n : longint) : longint;
-    function attr_get : longint;
-    function attr_off(a : longint) : longint;
-    function attr_on(a : longint) : longint;
-    function attr_set(a : longint) : longint;
-    function chgat(n,a,c,o : longint) : longint;
-    function getbkgd(win : pwindow) : longint;
-    function slk_attr_off(a : longint) : longint;
-    function slk_attr_on(a : longint) : longint;
-    function slk_attr_set(a : longint) : longint;
-    function vid_attr(a : longint) : longint;
-    function wattr_get(win : pwindow) : longint;
-    {
-       Pseudo-character tokens outside ASCII range.  The curses wgetch() function
-       will return any given one of these only if the corresponding k- capability
-       is defined in your terminal's terminfo entry.
-     }
-    const                       {octal}
-       KEY_CODE_YES = 256;      {0400}
-       KEY_MIN = 257;           {0401}
-       KEY_BREAK = 257;         {0401}
-       KEY_DOWN = 258;          {0402}
-       KEY_UP = 259;            {0403}
-       KEY_LEFT = 260;          {0404}
-       KEY_RIGHT = 261;         {0405}
-       KEY_HOME = 262;          {0406}
-       KEY_BACKSPACE = 263;     {0407}
-       KEY_F0 = 264;            {0410}
-
-    function KEY_F(n : longint) : longint;
-
-    const
-       KEY_DL = 328;            {0510}
-       KEY_IL = 329;            {0511}
-       KEY_DC = 330;            {0512}
-       KEY_IC = 331;            {0513}
-       KEY_EIC = 332;           {0514}
-       KEY_CLEAR = 333;         {0515}
-       KEY_EOS = 334;           {0516}
-       KEY_EOL = 335;           {0517}
-       KEY_SF = 336;            {0520}
-       KEY_SR = 337;            {0521}
-       KEY_NPAGE = 338;         {0522}
-       KEY_PPAGE = 339;         {0523}
-       KEY_STAB = 340;          {0524}
-       KEY_CTAB = 341;          {0525}
-       KEY_CATAB = 342;         {0526}
-       KEY_ENTER = 343;         {0527}
-       KEY_SRESET = 344;        {0530}
-       KEY_RESET = 345;         {0531}
-       KEY_PRINT = 346;         {0532}
-       KEY_LL = 347;            {0533}
-       KEY_A1 = 348;            {0534}
-       KEY_A3 = 349;            {0535}
-       KEY_B2 = 350;            {0536}
-       KEY_C1 = 351;            {0537}
-       KEY_C3 = 352;            {0540}
-       KEY_BTAB = 353;          {0541}
-       KEY_BEG = 354;           {0542}
-       KEY_CANCEL = 355;        {0543}
-       KEY_CLOSE = 356;         {0544}
-       KEY_COMMAND = 357;       {0545}
-       KEY_COPY = 358;          {0546}
-       KEY_CREATE = 359;        {0547}
-       KEY_END = 360;           {0550}
-       KEY_EXIT = 361;          {0551}
-       KEY_FIND = 362;          {0552}
-       KEY_HELP = 363;          {0553}
-       KEY_MARK = 364;          {0554}
-       KEY_MESSAGE = 365;       {0555}
-       KEY_MOVE = 366;          {0556}
-       KEY_NEXT = 367;          {0557}
-       KEY_OPEN = 368;          {0560}
-       KEY_OPTIONS = 369;       {0561}
-       KEY_PREVIOUS = 370;      {0562}
-       KEY_REDO = 371;          {0563}
-       KEY_REFERENCE = 372;     {0564}
-       KEY_REFRESH = 373;       {0565}
-       KEY_REPLACE = 374;       {0566}
-       KEY_RESTART = 375;       {0567}
-       KEY_RESUME = 376;        {0570}
-       KEY_SAVE = 377;          {0571}
-       KEY_SBEG = 378;          {0572}
-       KEY_SCANCEL = 379;       {0573}
-       KEY_SCOMMAND = 380;      {0574}
-       KEY_SCOPY = 381;         {0575}
-       KEY_SCREATE = 382;       {0576}
-       KEY_SDC = 383;           {0577}
-       KEY_SDL = 384;           {0600}
-       KEY_SELECT = 385;        {0601}
-       KEY_SEND = 386;          {0602}
-       KEY_SEOL = 387;          {0603}
-       KEY_SEXIT = 388;         {0604}
-       KEY_SFIND = 389;         {0605}
-       KEY_SHELP = 390;         {0606}
-       KEY_SHOME = 391;         {0607}
-       KEY_SIC = 392;           {0610}
-       KEY_SLEFT = 393;         {0611}
-       KEY_SMESSAGE = 394;      {0612}
-       KEY_SMOVE = 395;         {0613}
-       KEY_SNEXT = 396;         {0614}
-       KEY_SOPTIONS = 397;      {0615}
-       KEY_SPREVIOUS = 398;     {0616}
-       KEY_SPRINT = 399;        {0617}
-       KEY_SREDO = 400;         {0620}
-       KEY_SREPLACE = 401;      {0621}
-       KEY_SRIGHT = 402;        {0622}
-       KEY_SRSUME = 403;        {0623}
-       KEY_SSAVE = 404;         {0624}
-       KEY_SSUSPEND = 405;      {0625}
-       KEY_SUNDO = 406;         {0626}
-       KEY_SUSPEND = 407;       {0627}
-       KEY_UNDO = 408;          {0630}
-       KEY_MOUSE = 409;         {0631}
-       KEY_RESIZE = 410;        {0632}
-       KEY_MAX = 511;           {0777}
-
-    function mcprint(_para1:pchar; _para2:longint):longint;cdecl;external libncurses;
-    function has_key(_para1:longint):longint;cdecl;external libncurses;
+function add_wch(wch: pcchar_t): longint; inline;
+function add_wchnstr(wchstr: pcchar_t; n: longint): longint; inline;
+function add_wchstr(wchstr: pcchar_t): longint; inline;
+function addnwstr(wchstr: pwchar_t; n : longint) : longint; inline;
+function addwstr(wchstr: pwchar_t): longint; inline;
+function bkgrnd(wch: pcchar_t): longint; inline;
+procedure bkgrndset(wch: pcchar_t); inline;
+function border_set(ls,rs,ts,bs,tl,tr,bl,br: pcchar_t): longint; inline;
+function box_set(win: PWINDOW; verch,horch: pcchar_t): longint; inline;
+function echo_wchar(wch: Pcchar_t): longint; inline;
+function get_wch(wch: Plongint): longint; inline;
+function get_wstr(wstr: PLongint): longint; inline;
+function getbkgrnd(wch: pcchar_t): longint; inline;
+function getn_wstr(wstr: PLongint; n: longint): longint; inline;
+function hline_set(wch: pcchar_t; n: longint): longint; inline;
+function in_wch(wch: pcchar_t) : longint; inline;
+function in_wchnstr(wchstr: pcchar_t; n: longint): longint; inline;
+function in_wchstr(wchstr: pcchar_t): longint; inline;
+function innwstr(wstr: pwchar_t; n: longint): longint; inline;
+function ins_nwstr(wstr: pwchar_t; n: longint): longint; inline;
+function ins_wch(wch: pcchar_t): longint; inline;
+function ins_wstr(wstr: pwchar_t): longint; inline;
+function inwstr(wstr: pwchar_t): longint; inline;
+function vline_set(wch: pcchar_t; n: longint): longint; inline;
+function wadd_wchstr(win: PWINDOW; wchstr: pcchar_t): longint; inline;
+function waddwstr(win: PWINDOW; wstr :pwchar_t): longint; inline;
+function wget_wstr(win: PWINDOW; wstr: PLongint): longint; inline;
+function win_wchstr(win: PWINDOW; wchstr: pcchar_t): longint; inline;
+function wins_wstr(win: PWINDOW; wstr: pwchar_t): longint; inline;
+function mvadd_wch(y,x: Smallint;  wch: pcchar_t): longint; inline;
+function mvadd_wchnstr(y,x: Smallint; wchstr: pcchar_t; n: longint): longint; inline;
+function mvadd_wchstr(y,x: Smallint; wchstr: pcchar_t): longint; inline;
+function mvaddnwstr(y,x: Smallint; wstr: pwchar_t; n: longint): longint; inline;
+function mvaddwstr(y,x: Smallint; wstr: pwchar_t): longint; inline;
+function mvget_wch(y,x: Smallint; wch: Plongint): longint; inline;
+function mvget_wstr(y,x: Smallint; wstr: Plongint): longint; inline;
+function mvgetn_wstr(y,x: Smallint; wstr: Plongint; n: longint): longint; inline;
+function mvhline_set(y,x: Smallint; wch: pcchar_t; n: longint): longint; inline;
+function mvin_wch(y,x: Smallint; wch: pcchar_t) : longint; inline;
+function mvin_wchnstr(y,x: Smallint; wchstr: pcchar_t; n: longint): longint; inline;
+function mvin_wchstr(y,x: Smallint; wchstr: pcchar_t): longint; inline;
+function mvinnwstr(y,x: Smallint; wstr: pwchar_t; n : longint): longint; inline;
+function mvins_nwstr(y,x: Smallint; wstr: pwchar_t; n : longint): longint; inline;
+function mvins_wch(y,x: Smallint; wch: pcchar_t): longint; inline;
+function mvins_wstr(y,x: Smallint; wstr: pwchar_t): longint; inline;
+function mvinwstr(y,x: Smallint; wstr: pwchar_t): longint; inline;
+function mvvline_set(y,x: Smallint; wch: pcchar_t; n : longint): longint; inline;
+function mvwadd_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint; inline;
+function mvwadd_wchnstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t; n: longint): longint; inline;
+function mvwadd_wchstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t): longint; inline;
+function mvwaddnwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n: longint): longint; inline;
+function mvwaddwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t): longint; inline;
+function mvwget_wch(win: PWINDOW; y,x: Smallint; wch: Plongint): longint; inline;
+function mvwget_wstr(win: PWINDOW; y,x: Smallint; wstr: Plongint): longint; inline;
+function mvwgetn_wstr(win: PWINDOW; y,x: Smallint; wstr: Plongint; n: longint): longint; inline;
+function mvwhline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint): longint; inline;
+function mvwin_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint; inline;
+function mvwin_wchnstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t; n: longint): longint; inline;
+function mvwin_wchstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t): longint; inline;
+function mvwinnwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n : longint): longint; inline;
+function mvwins_nwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n: longint): longint; inline;
+function mvwins_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint; inline;
+function mvwins_wstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint; inline;
+function mvwinwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint; inline;
+function mvwvline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint) : longint; inline;
+
+
+function wmove(win: PWINDOW; y,x: Smallint): Longint; inline;
+
+(* C varargs  procedures*)
+
+function tparm(_para1:PChar):PChar;cdecl; varargs; external libncurses; overload;
+function mvprintw(_para1:Longint; _para2:Longint; _para3:PChar):Longint; cdecl; varargs; external libncurses; overload;
+function mvscanw(_para1:Longint; _para2:Longint; _para3:PChar):Longint; cdecl; varargs;external libncurses; overload;
+function mvwprintw(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:PChar):Longint; cdecl; varargs; external libncurses; overload;
+function mvwscanw(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:PChar):Longint; cdecl; varargs; external libncurses; overload;
+function scanw(_para1:PChar):Longint; cdecl; varargs; external libncurses; overload;
+function wprintw(_para1:PWINDOW; _para2:PChar):Longint; cdecl; varargs; external libncurses; overload;
+function wscanw(_para1:PWINDOW; _para2:PChar):Longint; cdecl; varargs; external libncurses; overload;
+function printw(_para1:PChar):Longint; cdecl; varargs; external libncurses; overload;
+{function vwprintw(_para1:PWINDOW; _para2:PChar; _para3:va_list):Longint; cdecl;external libncurses;
+function vw_printw(_para1:PWINDOW; _para2:PChar; _para3:va_list):Longint; cdecl;external libncurses;
+function vwscanw(_para1:PWINDOW; _para2:PChar; _para3:va_list):Longint; cdecl;external libncurses;
+function vw_scanw(_para1:PWINDOW; _para2:PChar; _para3:va_list):Longint; cdecl;external libncurses;}
+
+{$IF DEFINED(FPC_OBJFPC) OR DEFINED(FPC_DELPHI)}
+{function tparm(_para1:PChar; args:array of const):PChar;cdecl;external libncurses; overload;
+function mvprintw(_para1:Longint; _para2:Longint; _para3:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
+function mvscanw(_para1:Longint; _para2:Longint; _para3:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
+function mvwprintw(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
+function mvwscanw(_para1:PWINDOW; _para2:Longint; _para3:Longint; _para4:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
+function scanw(_para1:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
+function wprintw(_para1:PWINDOW; _para2:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
+function wscanw(_para1:PWINDOW; _para2:PChar; args:array of const):Longint; cdecl;external libncurses; overload;
+function printw(_para1:PChar; args:array of const):Longint; cdecl;external libncurses; overload;}
+
+{$ENDIF}
+
+
+implementation
+
+function ACS_ULCORNER : chtype;
+begin
+  ACS_ULCORNER:=acs_map['l'];
+end;
+
+function ACS_LLCORNER : chtype;
+begin
+  ACS_LLCORNER:=acs_map['m'];
+end;
+
+function ACS_URCORNER : chtype;
+begin
+  ACS_URCORNER:=acs_map['k'];
+end;
+
+function ACS_LRCORNER : chtype;
+begin
+  ACS_LRCORNER:=acs_map['j'];
+end;
+
+function ACS_LTEE : chtype;
+begin
+  ACS_LTEE:=acs_map['t'];
+end;
+
+function ACS_RTEE : chtype;
+begin
+  ACS_RTEE:=acs_map['u'];
+end;
+
+function ACS_BTEE : chtype;
+begin
+  ACS_BTEE:=acs_map['v'];
+end;
+
+function ACS_TTEE : chtype;
+begin
+  ACS_TTEE:=acs_map['w'];
+end;
+
+function ACS_HLINE : chtype;
+begin
+  ACS_HLINE:=acs_map['q'];
+end;
+
+function ACS_VLINE : chtype;
+begin
+  ACS_VLINE:=acs_map['x'];
+end;
+
+function ACS_PLUS : chtype;
+begin
+  ACS_PLUS:=acs_map['n'];
+end;
+
+function ACS_S1      : chtype;
+begin
+  ACS_S1    :=acs_map['o'];
+end;
+
+function ACS_S9      : chtype;
+begin
+  ACS_S9    :=acs_map['s'];
+end;
+
+function ACS_DIAMOND : chtype;
+begin
+  ACS_DIAMOND:=acs_map['`'];
+end;
+
+function ACS_CKBOARD : chtype;
+begin
+  ACS_CKBOARD:=acs_map['a'];
+end;
+
+function ACS_DEGREE : chtype;
+begin
+  ACS_DEGREE:=acs_map['f'];
+end;
+
+function ACS_PLMINUS : chtype;
+begin
+  ACS_PLMINUS:=acs_map['g'];
+end;
+
+function ACS_BULLET : chtype;
+begin
+  ACS_BULLET:=acs_map['~'];
+end;
+
+function ACS_LARROW : chtype;
+begin
+  ACS_LARROW:=acs_map[','];
+end;
+
+function ACS_RARROW : chtype;
+begin
+  ACS_RARROW:=acs_map['+'];
+end;
+
+function ACS_DARROW : chtype;
+begin
+  ACS_DARROW:=acs_map['.'];
+end;
+
+function ACS_UARROW : chtype;
+begin
+  ACS_UARROW:=acs_map['-'];
+end;
+
+function ACS_BOARD : chtype;
+begin
+  ACS_BOARD:=acs_map['h'];
+end;
+
+function ACS_LANTERN : chtype;
+begin
+  ACS_LANTERN:=acs_map['i'];
+end;
+
+function ACS_BLOCK : chtype;
+begin
+  ACS_BLOCK:=acs_map['0'];
+end;
+
+function ACS_S3      : chtype;
+begin
+  ACS_S3    :=acs_map['p'];
+end;
+
+function ACS_S7      : chtype;
+begin
+  ACS_S7    :=acs_map['r'];
+end;
+
+function ACS_LEQUAL : chtype;
+begin
+  ACS_LEQUAL:=acs_map['y'];
+end;
+
+function ACS_GEQUAL : chtype;
+begin
+  ACS_GEQUAL:=acs_map['z'];
+end;
+
+function ACS_PI      : chtype;
+begin
+  ACS_PI    :=acs_map['{'];
+end;
+
+function ACS_NEQUAL : chtype;
+begin
+  ACS_NEQUAL:=acs_map['|'];
+end;
+
+function ACS_STERLING : chtype;
+begin
+  ACS_STERLING:=acs_map['}'];
+end;
+
+
+
+function COLOR_PAIR(n : longint): longint;
+begin
+  COLOR_PAIR:=n shl 8;
+end;
+
+function PAIR_NUMBER(attr: attr_t) : longint;
+begin
+  PAIR_NUMBER := (attr AND A_COLOR) shr 8
+//#define PAIR_NUMBER(a)  (NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
+end;
+
+function color_set(color_pair_number: Smallint; opts: Pointer): longint; inline;
+begin
+  color_set:=wcolor_set(stdscr,color_pair_number,opts);
+end;
+
+(*  pseudo functions  *)
+
+function wgetstr(win: PWINDOW; s: PChar): Longint;
+begin
+  wgetstr := wgetnstr(win, s, -1);
+end;
+
+function getnstr(s: PChar;n: Longint): Longint;
+begin
+  getnstr := wgetnstr(stdscr,s,n);
+end;
+
+{
+  setupterm are declared in <ncursesw/term.h>:
+  int setupterm(char *term, int fildes, int *errret);
+}
+function setupterm(term:PChar; fildes:Longint; errret:Plongint):Longint; cdecl;external libncurses;
+
+function setterm(term: PChar): Longint;
+begin
+  setterm:=setupterm(term,1,plongint(0));
+end;
+
+function fixterm: Longint;
+begin
+  fixterm:=reset_prog_mode;
+end;
+
+function resetterm: Longint;
+begin
+  resetterm:=reset_shell_mode;
+end;
+
+function saveterm: Longint;
+begin
+  saveterm:=def_prog_mode;
+end;
+
+function crmode: Longint;
+begin
+  crmode:=cbreak;
+end;
+
+function nocrmode: Longint;
+begin
+  nocrmode:=nocbreak;
+end;
+
+
+
+
+procedure getyx(win: PWINDOW; var y,x);
+begin
+   if win<>nil then
+   begin
+      Smallint(y) :=win^._cury; Smallint(x) :=win^._curx
+   end
+   else
+   begin
+      Smallint(y) :=ERR; Smallint(x) :=ERR
+   end
+end;
+
+procedure getbegyx(win: PWINDOW; var y,x);
+begin
+   if win<>nil then
+   begin
+      Smallint(y) :=win^._begy; Smallint(x) :=win^._begx
+   end
+   else
+   begin
+      Smallint(y) :=ERR; Smallint(x) :=ERR
+   end
+end;
+
+procedure getmaxyx(win: PWINDOW; var y,x);
+begin
+   if win<>nil then
+   begin
+     Smallint(y) :=win^._maxy+1; Smallint(x) :=win^._maxx+1
+   end
+   else
+   begin
+      Smallint(y) :=ERR; Smallint(x) :=ERR
+   end
+end;
+
+procedure getparyx(win: PWINDOW; var y,x);
+begin
+{#define getparyx(win,y,x) (y = getpary(win), x = getparx(win))}
+  if win<>nil then
+   begin
+     Smallint(y) :=win^._pary; Smallint(x) :=win^._parx
+   end
+   else
+   begin
+      Smallint(y) :=ERR; Smallint(x) :=ERR
+   end
+end;
+
+
+
+
+procedure getsyx(var y,x);
+begin
+(*
+C macros:
+#define getsyx(y,x) do { if(newscr->_leaveok) (y)=(x)=-1; \
+       else getyx(newscr,(y),(x)); \
+        } while(0)
+*)
+{$IFNDEF USE_FPC_BYTEBOOL}
+   if newscr^._leaveok = NC_FPC_TRUE then
+{$ELSE USE_FPC_BYTEBOOL}
+   if newscr^._leaveok then
+{$ENDIF USE_FPC_BYTEBOOL}
+   begin
+      Smallint(y) := -1; Smallint(x) := -1
+   end
+   else
+   begin
+      Smallint(y) := newscr^._cury; Smallint(x) := newscr^._curx
+   end
+end;
+
+procedure setsyx(y,x: Smallint);
+begin
+(*
+C macros:
+#define setsyx(y,x) do { if((y)==-1 && (x)==-1) newscr->_leaveok=TRUE; \
+       else {newscr->_leaveok=FALSE;wmove(newscr,(y),(x));} \
+        } while(0)
+*)
+   if (x OR y >=0)AND(x<=newscr^._maxx)AND(y<=newscr^._maxy) then
+   begin
+      newscr^._curx := x;
+      newscr^._cury := y;
+      newscr^._flags := newscr^._flags AND not _WRAPPED;
+      newscr^._flags := newscr^._flags OR _HASMOVED;
+      newscr^._leaveok := NC_FPC_FALSE;
+   end
+   else if (x OR y = -1) then
+      newscr^._leaveok := NC_FPC_TRUE
+
+  //stdscr^._cury := y; //fpc ncurses original
+  //stdscr^._curx := x;
+end;
+
+function getattrs(win: PWINDOW): attr_t;
+begin
+  if win<>nil then
+    getattrs:=win^._attrs
+  else
+    getattrs:=A_NORMAL;
+end;
+
+function getcurx(win: PWINDOW): Smallint;
+begin
+  if win<>nil then
+    getcurx:=win^._curx
+  else
+    getcurx:=ERR;
+end;
+
+function getcury(win: PWINDOW): Smallint;
+begin
+  if win<>nil then
+    getcury:=win^._cury
+  else
+    getcury:=ERR;
+end;
+
+function getbegx(win: PWINDOW): Smallint;
+begin
+  if win<>nil then
+    getbegx:=win^._begx
+  else
+    getbegx:=ERR;
+end;
+
+function getbegy(win: PWINDOW): Smallint;
+begin
+  if win<>nil then
+    getbegy:=win^._begy
+  else
+    getbegy:=ERR;
+end;
+
+function getmaxx(win: PWINDOW): Smallint;
+begin
+  if win<>nil then
+    getmaxx:=(win^._maxx) + 1
+  else
+    getmaxx:=ERR;
+end;
+
+function getmaxy(win: PWINDOW): Smallint;
+begin
+  if win<>nil then
+    getmaxy:=(win^._maxy) + 1
+  else
+    getmaxy:=ERR;
+end;
+
+function getparx(win: PWINDOW): Smallint;
+begin
+  if win<>nil then
+    getparx:=win^._parx
+  else
+    getparx:=ERR;
+end;
+
+function getpary(win: PWINDOW): Smallint;
+begin
+  if win<>nil then
+    getpary:=win^._pary
+  else
+    getpary:=ERR;
+end;
+
+function wstandout(win: PWINDOW): Longint;
+begin
+  wstandout:=wattrset(win,A_STANDOUT);
+end;
+
+function wstandend(win: PWINDOW): Longint;
+begin
+  wstandend:=wattrset(win,A_NORMAL);
+end;
+
+function wattr_set(win: PWINDOW; attrs: attr_t; pair: Smallint; opts: Pointer): Longint;
+begin
+{ The parameter opts is reserved for future use, applications must supply a null pointer. }
+{
+ C macros
+#define wattr_set(win,a,p,opts)   ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
+}
+  win^._attrs := (attrs AND not A_COLOR) OR COLOR_PAIR(pair);
+  wattr_set := OK
+end;
+
+function wattr_get(win:PWINDOW; attrs:Pattr_t; pair:PSmallint; opts:Pointer):longint;
+begin
+{
+ C macros
+#define wattr_get(win,a,p,opts)   ((void)((a) != 0 && (*(a) = (win)->_attrs)), \
+           (void)((p) != 0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
+           OK)
+}
+    attrs^ := win^._attrs;
+    pair^ := PAIR_NUMBER(win^._attrs);
+    wattr_get := OK
+end;
+
+function wattron(win:PWINDOW; attrs: attr_t): Longint;
+begin
+  wattron:=wattr_on(win, attrs, nil);
+end;
+
+function wattroff(win:PWINDOW; attrs: attr_t): longint;
+begin
+  wattroff:=wattr_off(win, attrs, nil);
+end;
+
+function wattrset(win: PWINDOW; attrs: attr_t): longint;
+begin
+  win^._attrs := attrs;
+  wattrset := OK
+end;
+
+function scroll(win: PWINDOW): longint;
+begin
+  scroll:=wscrl(win,1);
+end;
+
+function touchwin(win: PWINDOW): longint;
+begin
+  touchwin:=wtouchln(win,0,getmaxy(win),1);
+end;
+
+function touchline(win: PWINDOW;s,c: longint): longint;
+begin
+  touchline:=wtouchln(win,s,c,1);
+end;
+
+function untouchwin(win: PWINDOW): longint;
+begin
+  untouchwin:=wtouchln(win,0,getmaxy(win),0);
+end;
+
+function box(win:PWINDOW; v,h :chtype):Longint;
+begin
+  box:=wborder(win,v,v,h,h,0,0,0,0);
+end;
+
+function border(ls,rs,ts,bs,tl,tr,bl,br: chtype): longint;
+begin
+  border:=wborder(stdscr,ls,rs,ts,bs,tl,tr,bl,br);
+end;
+
+function hline(ch:chtype; n:longint): longint;
+begin
+  hline:=whline(stdscr,ch,n);
+end;
+
+function vline(ch:chtype; n:longint): longint;
+begin
+  vline:=wvline(stdscr,ch,n);
+end;
+
+
+function winstr(win: PWINDOW;s: PChar): longint;
+begin
+  winstr:=winnstr(win,s,-(1));
+end;
+
+function winchstr(win: PWINDOW; chstr: pchtype): longint;
+begin
+  winchstr:=winchnstr(win,chstr,-(1));
+end;
+
+function winsstr(win: PWINDOW;s: PChar): longint;
+begin
+  winsstr:=winsnstr(win,s,-(1));
+end;
+
+function redrawwin(win: PWINDOW): longint;
+begin
+  redrawwin:=wredrawln(win,0,(win^._maxy)+1);
+end;
+
+function waddstr(win: PWINDOW;st: PChar): longint;
+begin
+  waddstr:=waddnstr(win,st,-(1));
+end;
+
+function waddchstr(win: PWINDOW; chstr: pchtype): longint;
+begin
+  waddchstr:=waddchnstr(win,chstr,-(1));
+end;
+
+{
+   pseudo functions for standard screen
+}
+function addch(ch: chtype): longint;
+begin
+  addch:=waddch(stdscr,ch);
+end;
+
+function addchnstr(chstr: pchtype; n: longint): longint;
+begin
+  addchnstr:=waddchnstr(stdscr,chstr,n);
+end;
+
+function addchstr(chstr: pchtype): longint;
+begin
+  addchstr:=waddchstr(stdscr,chstr);
+end;
+
+function addnstr(str: PChar;n: longint): longint;
+begin
+  addnstr:=waddnstr(stdscr,str,n);
+end;
+
+function addstr(str: PChar): longint;
+begin
+  addstr:=waddnstr(stdscr,str,-(1));
+end;
+
+function attroff(attrs: attr_t): longint;
+begin
+  attroff:=wattroff(stdscr,attrs);
+end;
+
+function attron(attrs: attr_t): longint;
+begin
+  attron:=wattron(stdscr,attrs);
+end;
+
+function attrset(attrs: attr_t): longint;
+begin
+  //attrset:=wattrset(stdscr,attrs);
+  stdscr^._attrs := attrs;
+  attrset := OK
+end;
+
+function bkgd(ch: chtype): longint;
+begin
+  bkgd:=wbkgd(stdscr,ch);
+end;
+
+procedure bkgdset(ch: chtype);
+begin
+  wbkgdset(stdscr,ch);
+end;
+
+function clear: longint;
+begin
+  clear:=wclear(stdscr);
+end;
+
+function clrtobot: longint;
+begin
+  clrtobot:=wclrtobot(stdscr);
+end;
+
+function clrtoeol: longint;
+begin
+  clrtoeol:=wclrtoeol(stdscr);
+end;
+
+function delch: longint;
+begin
+  delch:=wdelch(stdscr);
+end;
+
+function deleteln: longint;
+begin
+  deleteln:=winsdelln(stdscr,-(1));
+end;
+
+function echochar(ch: chtype): longint;
+begin
+  echochar:=wechochar(stdscr,ch);
+end;
+
+function erase: longint;
+begin
+  erase:=werase(stdscr);
+end;
+
+function getch: longint;
+begin
+  getch:=wgetch(stdscr);
+end;
+
+function getstr(str: PChar): longint;
+begin
+  getstr:=wgetstr(stdscr,str);
+end;
+
+function inch: chtype;
+begin
+  inch:=winch(stdscr);
+end;
+
+function inchnstr(chstr: pchtype;n: longint): longint;
+begin
+  inchnstr:=winchnstr(stdscr,chstr ,n);
+end;
+
+function inchstr(chstr: pchtype): longint;
+begin
+  inchstr:=winchstr(stdscr,chstr);
+end;
+
+function innstr(str: PChar;n: longint): longint;
+begin
+  innstr:=winnstr(stdscr,str,n);
+end;
+
+function insch(ch: chtype): longint;
+begin
+  insch:=winsch(stdscr,ch);
+end;
+
+function insdelln(n: longint): longint;
+begin
+  insdelln:=winsdelln(stdscr,n);
+end;
+
+function insertln: longint;
+begin
+  insertln:=winsdelln(stdscr,1);
+end;
+
+function insnstr(str: PChar;n: longint): longint;
+begin
+  insnstr:=winsnstr(stdscr,str,n);
+end;
 
-implementation
+function insstr(str: PChar): longint;
+begin
+  insstr:=winsstr(stdscr,str);
+end;
 
-function wgetstr(w : pwindow;s : pchar) : longint;
+function instr(str: PChar): longint;
 begin
-  wgetstr:=wgetnstr(w,s,-(1));
+  instr:=winstr(stdscr,str);
 end;
 
-function getnstr(s : pchar;n : longint) : longint;
+function move(y,x: Smallint): longint;
 begin
-  getnstr:=wgetnstr(stdscr,s,n);
+  if (x OR y >=0)AND(x<=stdscr^._maxx)AND(y<=stdscr^._maxy) then
+  begin
+    stdscr^._curx := x;
+    stdscr^._cury := y;
+    stdscr^._flags := stdscr^._flags AND not _WRAPPED;
+    stdscr^._flags := stdscr^._flags OR _HASMOVED;
+    move := OK
+  end
+  else
+    move := ERR
 end;
 
-function setterm(term : longint) : longint;
+function refresh: longint;
 begin
-  {
-  setterm:=setupterm(term,1,plongint(0));
-  }
-  setterm:=0;
+   refresh:=wrefresh(stdscr);
 end;
 
-function fixterm : longint;
+function scrl(n: longint): longint;
 begin
-  fixterm:=reset_prog_mode;
+   scrl:=wscrl(stdscr,n);
 end;
 
-function resetterm : longint;
+function setscrreg(t,b: longint): longint;
 begin
-  resetterm:=reset_shell_mode;
+   setscrreg:=wsetscrreg(stdscr,t,b);
 end;
 
-function saveterm : longint;
+function standend: longint;
 begin
-  saveterm:=def_prog_mode;
+   standend:=wstandend(stdscr);
 end;
 
-function crmode : longint;
+function standout: longint;
 begin
-  crmode:=cbreak;
+   standout:=wstandout(stdscr);
 end;
 
-function nocrmode : longint;
+procedure timeout(delay: longint);
 begin
-  nocrmode:=nocbreak;
+  wtimeout(stdscr,delay);
 end;
 
-procedure getsyx(var y,x : longint);
+function wdeleteln(win: PWINDOW): longint;
 begin
-  getyx(stdscr,y,x);
+   wdeleteln:=winsdelln(win,-(1));
 end;
 
-function getattrs(win : pwindow) : longint;
-var
-  if_local1 : longint;
+function winsertln(win: PWINDOW): longint;
 begin
-  if win<>nil then
-    if_local1:=win^._attrs
-  else
-    if_local1:=A_NORMAL;
-  getattrs:=if_local1;
+   winsertln:=winsdelln(win,1);
 end;
 
-function getcurx(win : pwindow) : longint;
-var
-  if_local1 : longint;
+{
+   mv functions
+ }
+function mvwaddch(win: PWINDOW;y,x: Smallint; ch: chtype): longint;
 begin
-  if win<>nil then
-    if_local1:=win^._curx
+  if wmove(win,y,x) = ERR then
+    mvwaddch := ERR
   else
-    if_local1:=ERR;
-  getcurx:=if_local1;
+    mvwaddch := waddch(win,ch)
 end;
 
-function getcury(win : pwindow) : longint;
-var
-  if_local1 : longint;
+function mvwaddchnstr(win: PWINDOW;y,x: Smallint;chstr: pchtype;n: longint): longint;
 begin
-  if win<>Nil then
-    if_local1:=win^._cury
+  if wmove(win,y,x) = ERR then
+    mvwaddchnstr := ERR
   else
-    if_local1:=ERR;
-  getcury:=if_local1;
+    mvwaddchnstr := waddchnstr(win,chstr,n);
 end;
-function getbegx(win : pwindow) : longint;
-var
-  if_local1 : longint;
 
+function mvwaddchstr(win: PWINDOW;y,x: Smallint;chstr: pchtype): longint;
 begin
-  if win<>Nil then
-    if_local1:=win^._begx
+  if wmove(win,y,x) = ERR then
+     mvwaddchstr := ERR
   else
-    if_local1:=ERR;
-  getbegx:=if_local1;
+     mvwaddchstr := waddchnstr(win,chstr,-(1))
 end;
 
-function getbegy(win : pwindow) : longint;
-var
-  if_local1 : longint;
+function mvwaddnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint;
 begin
-  if win<>Nil then
-    if_local1:=win^._begy
+  if wmove(win,y,x) = ERR then
+     mvwaddnstr := ERR
   else
-    if_local1:=ERR;
-  getbegy:=if_local1;
+     mvwaddnstr := waddnstr(win,str,n);
 end;
 
-function getmaxx(win : pwindow) : longint;
-var
-  if_local1 : longint;
+function mvwaddstr(win: PWINDOW;y,x: Smallint;str: PChar): longint;
 begin
-  if win<>Nil then
-    if_local1:=(win^._maxx) + 1
+  if wmove(win,y,x) = ERR then
+     mvwaddstr := ERR
   else
-    if_local1:=ERR;
-  getmaxx:=if_local1;
+     mvwaddstr := waddnstr(win,str,-(1));
 end;
 
-function getmaxy(win : pwindow) : longint;
-var
-  if_local1 : longint;
+function mvwdelch(win: PWINDOW;y,x: Smallint): longint;
 begin
-  if win<>Nil then
-    if_local1:=(win^._maxy) + 1
+  if wmove(win,y,x) = ERR then
+     mvwdelch := ERR
   else
-    if_local1:=ERR;
-  getmaxy:=if_local1;
+     mvwdelch :=wdelch(win);
 end;
 
-function getparx(win : pwindow) : longint;
-var
-  if_local1 : longint;
+function mvwchgat(win: PWINDOW;y, x: Smallint; n: Longint;attr: attr_t;
+                            color: Smallint; opts: Pointer): longint;
 begin
-  if win<>Nil then
-    if_local1:=win^._parx
+  if wmove(win,y,x) = ERR then
+    mvwchgat := ERR
   else
-    if_local1:=ERR;
-  getparx:=if_local1;
+    mvwchgat := wchgat(win,n,attr,color,opts);
 end;
 
-function getpary(win : pwindow) : longint;
-var
-  if_local1 : longint;
+function mvwgetch(win: PWINDOW;y,x: Smallint): longint;
 begin
-  if win<>Nil then
-    if_local1:=win^._pary
+  if wmove(win,y,x) = ERR then
+    mvwgetch := ERR
   else
-    if_local1:=ERR;
-  getpary:=if_local1;
+    mvwgetch := wgetch(win);
 end;
 
-function wstandout(win : pwindow) : longint;
+function mvwgetnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint;
 begin
-  wstandout:=wattr_set(win,A_STANDOUT);
+  if wmove(win,y,x) = ERR then
+    mvwgetnstr := ERR
+  else
+    mvwgetnstr := wgetnstr(win,str,n);
 end;
 
-function wstandend(win : pwindow) : longint;
+function mvwgetstr(win: PWINDOW;y,x: Smallint;str: PChar): longint;
 begin
-  wstandend:=wattr_set(win,A_NORMAL);
+  if wmove(win,y,x) = ERR then
+    mvwgetstr := ERR
+  else
+    mvwgetstr := wgetstr(win,str);
 end;
 
-(*
-function wattron(win : pwindow;at : longint) : longint;
+function mvwhline(win: PWINDOW;y,x: Smallint;ch: chtype;n: longint): longint;
 begin
-  wattron:=wattr_on(win,at);
+  if wmove(win,y,x) = ERR then
+    mvwhline := ERR
+  else
+    mvwhline := whline(win,ch,n);
 end;
 
-function wattroff(win : pwindow;at : longint) : longint;
+function mvwinch(win: PWINDOW;y,x: Smallint): chtype;
 begin
-  wattroff:=wattr_off(win,at);
+  if wmove(win,y,x) = ERR then
+    mvwinch := chtype(ERR)
+  else
+    mvwinch := winch(win);
 end;
 
-function wattrset(win : pwindow;at : longint) : longint;
+function mvwinchnstr(win: PWINDOW;y,x: Smallint;chstr: pchtype; n: longint): longint;
 begin
-  wattrset:=wattr_set(win,at);
+  if wmove(win,y,x) = ERR then
+    mvwinchnstr := ERR
+  else
+    mvwinchnstr := winchnstr(win,chstr,n);
 end;
-*)
-function scroll(win : pwindow) : longint;
+
+function mvwinchstr(win: PWINDOW;y,x: Smallint;chstr: pchtype): longint;
 begin
-  scroll:=wscrl(win,1);
+  if wmove(win,y,x) = ERR then
+    mvwinchstr := ERR
+  else
+    mvwinchstr := winchnstr(win,chstr,-(1));
 end;
 
-function touchwin(win : pwindow) : longint;
+function mvwinnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint;
 begin
-  touchwin:=wtouchln(win,0,getmaxy(win),1);
+  if wmove(win,y,x) = ERR then
+    mvwinnstr := ERR
+  else
+    mvwinnstr := winnstr(win,str,n);
 end;
 
-function touchline(win : pwindow;s,c : longint) : longint;
+function mvwinsch(win: PWINDOW;y,x: Smallint;ch: chtype): longint;
 begin
-  touchline:=wtouchln(win,s,c,1);
+  if wmove(win,y,x) = ERR then
+    mvwinsch := ERR
+  else
+    mvwinsch := winsch(win,ch);
 end;
 
-function untouchwin(win : pwindow) : longint;
+function mvwinsnstr(win: PWINDOW;y,x: Smallint;str: PChar;n: longint): longint;
 begin
-  untouchwin:=wtouchln(win,0,getmaxy(win),0);
+  if wmove(win,y,x) = ERR then
+    mvwinsnstr := ERR
+  else
+    mvwinsnstr := winsnstr(win,str,n);
 end;
 
-function box(win : pwindow;v,h : longint) : longint;
+function mvwinsstr(win: PWINDOW;y,x: Smallint;str: PChar): longint;
 begin
-  box:=wborder(win,v,v,h,h,0,0,0,0);
+  if wmove(win,y,x) = ERR then
+    mvwinsstr := ERR
+  else
+    mvwinsstr := winsnstr(win,str,-(1));
 end;
 
-function border(ls,rs,ts,bs,tl,tr,bl,br : longint) : longint;
+function mvwinstr(win: PWINDOW;y,x: Smallint;str: PChar): longint;
 begin
-  border:=wborder(stdscr,ls,rs,ts,bs,tl,tr,bl,br);
+  if wmove(win,y,x) = ERR then
+    mvwinstr := ERR
+  else
+    mvwinstr := winnstr(win,str,-(1));
 end;
 
-function hline(ch,n : longint) : longint;
+function mvwvline(win: PWINDOW;y,x: Smallint;ch: chtype;n: longint): longint;
 begin
-  hline:=whline(stdscr,ch,n);
+  if wmove(win,y,x) = ERR then
+    mvwvline := ERR
+  else
+    mvwvline := wvline(win,ch,n);
 end;
 
-function vline(ch,n : longint) : longint;
+function mvaddch(y,x: Smallint; ch: chtype): longint;
 begin
-  vline:=wvline(stdscr,ch,n);
+  if move(y,x) = ERR then
+    mvaddch := ERR
+  else
+    mvaddch := waddch(stdscr,ch)
 end;
 
-function winstr(w : pwindow;s : pchar) : longint;
+function mvaddchnstr(y,x: Smallint; chstr: pchtype;n: longint): longint;
 begin
-  winstr:=winnstr(w,s,-(1));
+  if move(y,x) = ERR then
+    mvaddchnstr := ERR
+  else
+    mvaddchnstr := waddchnstr(stdscr,chstr,n);
 end;
 
-function winchstr(w : pwindow;s : pchar) : longint;
+function mvaddchstr(y,x: Smallint; chstr: pchtype): longint;
 begin
-  winchstr:=winchnstr(w,s,-1);
+  if move(y,x) = ERR then
+    mvaddchstr := ERR
+  else
+    mvaddchstr := waddchnstr(stdscr,chstr,-(1));
 end;
 
-function winsstr(w : pwindow;s : pchar) : longint;
+function mvaddnstr(y,x: Smallint; str: PChar;n: longint): longint;
 begin
-  winsstr:=winsnstr(w,s,-(1));
+  if move(y,x) = ERR then
+    mvaddnstr := ERR
+  else
+    mvaddnstr := waddnstr(stdscr,str,n);
 end;
 
-function redrawwin(w : pwindow) : longint;
+function mvaddstr(y,x: Smallint; str: PChar): longint;
 begin
-  redrawwin:=wredrawln(w,0,(w^._maxy) + 1);
+  if move(y,x) = ERR then
+    mvaddstr := ERR
+  else
+    mvaddstr := waddnstr(stdscr,str,-(1));
 end;
 
-function waddstr(win : pwindow;st : pchar) : longint;
+function mvdelch(y,x: Smallint): longint;
 begin
-  waddstr:=waddnstr(win,st,-1);
+  if move(y,x) = ERR then
+    mvdelch := ERR
+  else
+    mvdelch := wdelch(stdscr);
 end;
 
-function waddchstr(win : pwindow;st : pchar) : longint;
+function mvgetch(y,x: Smallint): longint;
 begin
-  waddchstr:=waddchnstr(win,st,-1);
+  if move(y,x) = ERR then
+    mvgetch := ERR
+  else
+    mvgetch := wgetch(stdscr);
 end;
 
-function addch(ch : longint) : longint;
+function mvgetnstr(y,x: Smallint; str: PChar;n: longint): longint;
 begin
-  addch:=waddch(stdscr,ch);
+  if move(y,x) = ERR then
+    mvgetnstr := ERR
+  else
+    mvgetnstr := wgetnstr(stdscr,str,n);
 end;
 
-function addchnstr(st : pchar;n : longint) : longint;
+function mvgetstr(y,x: Smallint; str: PChar): longint;
 begin
-  addchnstr:=waddchnstr(stdscr,st,n);
+  if move(y,x) = ERR then
+    mvgetstr := ERR
+  else
+    mvgetstr := wgetnstr(stdscr,str,-(1));
 end;
 
-function addchstr(st : pchar) : longint;
+function mvhline(y,x: Smallint;ch: chtype;n: longint): longint;
 begin
-  addchstr:=waddchstr(stdscr,st);
+  if move(y,x) = ERR then
+    mvhline := ERR
+  else
+    mvhline := whline(stdscr,ch,n);
 end;
 
-function addnstr(st : pchar;n : longint) : longint;
+function mvinch(y,x: Smallint): chtype;
 begin
-  addnstr:=waddnstr(stdscr,st,n);
+  if move(y,x) = ERR then
+    mvinch := chtype(ERR)
+  else
+    mvinch := winch(stdscr);
 end;
 
-function addstr(st : pchar) : longint;
+function mvinchnstr(y,x: Smallint; chstr: pchtype;n: longint): longint;
 begin
-  addstr:=waddnstr(stdscr,st,-1);
+  if move(y,x) = ERR then
+    mvinchnstr := ERR
+  else
+    mvinchnstr := winchnstr(stdscr,chstr,n);
 end;
 
-function attroff(at : longint) : longint;
+function mvinchstr(y,x: Smallint; chstr: pchtype): longint;
 begin
-  attroff:=wattroff(stdscr,at);
+  if move(y,x) = ERR then
+    mvinchstr := ERR
+  else
+    mvinchstr := winchnstr(stdscr,chstr,-(1));
 end;
 
-function attron(at : longint) : longint;
+function mvinnstr(y,x: Smallint; str: PChar;n: longint): longint;
 begin
-  attron:=wattron(stdscr,at);
+  if move(y,x) = ERR then
+    mvinnstr := ERR
+  else
+    mvinnstr := winnstr(stdscr,str,n);
 end;
 
-function attrset(at : longint) : longint;
+function mvinsch(y,x: Smallint;ch: chtype): longint;
 begin
-  attrset:=wattrset(stdscr,at);
+  if move(y,x) = ERR then
+    mvinsch := ERR
+  else
+    mvinsch := winsch(stdscr,ch);
 end;
 
-function bkgd(ch : longint) : longint;
+function mvinsnstr(y,x: Smallint; str: PChar;n: longint): longint;
 begin
-  bkgd:=wbkgd(stdscr,ch);
+  if move(y,x) = ERR then
+    mvinsnstr := ERR
+  else
+    mvinsnstr := winsnstr(stdscr,str,n);
 end;
 
-procedure bkgdset(ch : longint);
+function mvinsstr(y,x: Smallint; str: PChar): longint;
 begin
-  wbkgdset(stdscr,ch);
+  if move(y,x) = ERR then
+    mvinsstr := ERR
+  else
+    mvinsstr := winsstr(stdscr,str);
 end;
 
-function clear : longint;
+function mvinstr(y,x: Smallint; str: PChar): longint;
 begin
-  clear:=wclear(stdscr);
+  if move(y,x) = ERR then
+    mvinstr := ERR
+  else
+    mvinstr := winstr(stdscr,str);
 end;
 
-function clrtobot : longint;
+function mvvline(y,x: Smallint; ch:chtype; n:longint): longint;
 begin
-  clrtobot:=wclrtobot(stdscr);
+  if move(y,x) = ERR then
+    mvvline := ERR
+  else
+    mvvline := wvline(stdscr,ch,n);
 end;
 
-function clrtoeol : longint;
+function attr_get(attrs:Pattr_t; pair:PSmallint; opts:Pointer): longint;
 begin
-  clrtoeol:=wclrtoeol(stdscr);
+  attr_get := wattr_get(stdscr,attrs,pair,opts);
 end;
 
-function delch : longint;
+function attr_off(attrs:attr_t; opts:Pointer): longint;
 begin
-  delch:=wdelch(stdscr);
+  attr_off := wattr_off(stdscr,attrs,opts);
 end;
 
-function deleteln : longint;
+function attr_on(attrs:attr_t; opts:Pointer): longint;
 begin
-  deleteln:=winsdelln(stdscr,-1);
+  attr_on := wattr_on(stdscr,attrs,opts);
 end;
 
-function echochar(c : longint) : longint;
+function attr_set(attrs:attr_t; pair:Smallint; opts:Pointer): longint;
 begin
-  echochar:=wechochar(stdscr,c);
+  attr_set := wattr_set(stdscr,attrs,pair,opts);
 end;
 
-function erase : longint;
+function chgat(n: Longint;attr: attr_t;color: Smallint; opts: Pointer): longint;
 begin
-  erase:=werase(stdscr);
+  chgat := wchgat(stdscr,n,attr,color,opts);
 end;
 
-function getch : longint;
+function mvchgat(y, x: Smallint; n: Longint;attr: attr_t;color: Smallint; opts: Pointer):Longint;
 begin
-  getch:=wgetch(stdscr);
+  if move(y,x) = ERR then
+    mvchgat := ERR
+  else
+    mvchgat := wchgat(stdscr,n,attr,color,opts);
 end;
 
-function getstr(st : pchar) : longint;
+function getbkgd(win: PWINDOW): chtype;
 begin
-  getstr:=wgetstr(stdscr,st);
+  getbkgd := win^._bkgd;
 end;
 
-function inch : longint;
+function slk_attr_off(attrs: attr_t; opts: Pointer) : longint;
 begin
-  inch:=winch(stdscr);
+  slk_attr_off := slk_attroff(attrs);
 end;
 
-function inchnstr(s : pchar;n : longint) : longint;
+function slk_attr_on(attrs: attr_t; opts: Pointer): longint;
 begin
-  inchnstr:=winchnstr(stdscr,s,n);
+  slk_attr_on := slk_attron(attrs);
 end;
 
-function inchstr(s : pchar) : longint;
+
+
+
+function KEY_F(n : Byte) : chtype;
 begin
-  inchstr:=winchstr(stdscr,s);
+  KEY_F := KEY_F0 + n;
 end;
 
-function innstr(s : pchar;n : longint) : longint;
+
+
+function NCURSES_WACS(c: chtype): cchar_t;
 begin
-  innstr:=winnstr(stdscr,s,n);
+  NCURSES_WACS := _nc_wacs[c];
 end;
 
-function insch(c : longint) : longint;
+function WACS_BSSB: cchar_t;
 begin
-  insch:=winsch(stdscr,c);
+  WACS_BSSB := _nc_wacs[chtype('l')];
 end;
 
-function insdelln(n : longint) : longint;
+function WACS_SSBB: cchar_t;
 begin
-  insdelln:=winsdelln(stdscr,n);
+  WACS_SSBB:= _nc_wacs[chtype('m')];
 end;
 
-function insertln : longint;
+function WACS_BBSS: cchar_t;
 begin
-  insertln:=winsdelln(stdscr,1);
+  WACS_BBSS:= _nc_wacs[chtype('k')];
 end;
 
-function insnstr(s : pchar;n : longint) : longint;
+function WACS_SBBS: cchar_t;
 begin
-  insnstr:=winsnstr(stdscr,s,n);
+  WACS_SBBS:= _nc_wacs[chtype('j')];
 end;
 
-function insstr(s : pchar) : longint;
+function WACS_SBSS: cchar_t;
 begin
-  insstr:=winsstr(stdscr,s);
+  WACS_SBSS:= _nc_wacs[chtype('u')];
 end;
 
-function instr(s : pchar) : longint;
+function WACS_SSSB: cchar_t;
 begin
-  instr:=winstr(stdscr,s);
+  WACS_SSSB:= _nc_wacs[chtype('t')];
 end;
 
-function move(y,x : longint) : longint;
+function WACS_SSBS: cchar_t;
 begin
-  move:=wmove(stdscr,y,x);
+  WACS_SSBS:= _nc_wacs[chtype('v')];
 end;
 
-function refresh : longint;
+function WACS_BSSS: cchar_t;
 begin
-  refresh:=wrefresh(stdscr);
+  WACS_BSSS:= _nc_wacs[chtype('w')];
 end;
 
-function scrl(n : longint) : longint;
+function WACS_BSBS: cchar_t;
 begin
-  scrl:=wscrl(stdscr,n);
+  WACS_BSBS:= _nc_wacs[chtype('q')];
 end;
 
-function setscrreg(t,b : longint) : longint;
+function WACS_SBSB: cchar_t;
 begin
-  setscrreg:=wsetscrreg(stdscr,t,b);
+  WACS_SBSB:= _nc_wacs[chtype('x')];
 end;
 
-function standend : longint;
+function WACS_SSSS: cchar_t;
 begin
-  standend:=wstandend(stdscr);
+  WACS_SSSS:= _nc_wacs[chtype('n')];
 end;
 
-function standout : longint;
+function WACS_S1: cchar_t;
 begin
-  standout:=wstandout(stdscr);
+  WACS_S1:= _nc_wacs[chtype('o')];
 end;
 
-function timeout(delay : longint) : longint;
+function WACS_S9: cchar_t;
 begin
-  timeout:=wtimeout(stdscr,delay);
+  WACS_S9:= _nc_wacs[chtype('s')];
 end;
 
-function wdeleteln(win : pwindow) : longint;
+function WACS_DIAMOND: cchar_t;
 begin
-  wdeleteln:=winsdelln(win,-1);
+  WACS_DIAMOND:= _nc_wacs[chtype('`')];
 end;
 
-function winsertln(win : pwindow) : longint;
+function WACS_CKBOARD: cchar_t;
 begin
-  winsertln:=winsdelln(win,1);
+  WACS_CKBOARD:= _nc_wacs[chtype('a')];
 end;
 
-function mvaddch(y,x,ch : longint) : longint;
+function WACS_DEGREE: cchar_t;
 begin
-  mvaddch:=mvwaddch(stdscr,y,x,ch);
+  WACS_DEGREE:= _nc_wacs[chtype('f')];
 end;
 
-function mvaddchnstr(y,x: longint;st : pchar;n : longint) : longint;
+function WACS_PLMINUS: cchar_t;
 begin
-  mvaddchnstr:=mvwaddchnstr(stdscr,y,x,st,n);
+  WACS_PLMINUS:= _nc_wacs[chtype('g')];
 end;
 
-function mvaddchstr(y,x : longint;st : pchar) : longint;
+function WACS_BULLET: cchar_t;
 begin
-  mvaddchstr:=mvwaddchstr(stdscr,y,x,st);
+  WACS_BULLET:= _nc_wacs[chtype('~')];
 end;
 
-function mvaddnstr(y,x: longint;st : pchar; n : longint) : longint;
+function WACS_LARROW: cchar_t;
 begin
-  mvaddnstr:=mvwaddnstr(stdscr,y,x,st,n);
+  WACS_LARROW:= _nc_wacs[chtype(',')];
 end;
 
-function mvaddstr(y,x : longint;st : pchar) : longint;
+function WACS_RARROW: cchar_t;
 begin
-  mvaddstr:=mvwaddstr(stdscr,y,x,st);
+  WACS_RARROW:= _nc_wacs[chtype('+')];
 end;
 
-function mvdelch(y,x : longint) : longint;
+function WACS_DARROW: cchar_t;
 begin
-  mvdelch:=mvwdelch(stdscr,y,x);
+  WACS_DARROW:= _nc_wacs[chtype('.')];
 end;
 
-function mvgetch(y,x : longint) : longint;
+function WACS_UARROW: cchar_t;
 begin
-  mvgetch:=mvwgetch(stdscr,y,x);
+  WACS_UARROW:= _nc_wacs[chtype('-')];
 end;
 
-function mvgetnstr(y,x : longint;st : pchar;n : longint) : longint;
+function WACS_BOARD: cchar_t;
 begin
-  mvgetnstr:=mvwgetnstr(stdscr,y,x,st,n);
+  WACS_BOARD:= _nc_wacs[chtype('h')];
 end;
 
-function mvgetstr(y,x: longint;st : pchar) : longint;
+function WACS_LANTERN: cchar_t;
 begin
-  mvgetstr:=mvwgetstr(stdscr,y,x,st);
+  WACS_LANTERN:= _nc_wacs[chtype('i')];
 end;
 
-function mvhline(y,x : longint;c : chtype;n : longint) : longint;
+function WACS_BLOCK: cchar_t;
 begin
-  mvhline:=mvwhline(stdscr,y,x,c,n);
+  WACS_BLOCK:= _nc_wacs[chtype('0')];
 end;
 
-function mvinch(y,x : longint) : longint;
+function WACS_S3: cchar_t;
 begin
-  mvinch:=mvwinch(stdscr,y,x);
+  WACS_S3:= _nc_wacs[chtype('p')];
 end;
 
-function mvinchnstr(y,x : longint;s : pchar;n : longint) : longint;
+function WACS_S7: cchar_t;
 begin
-  mvinchnstr:=mvwinchnstr(stdscr,y,x,s,n);
+  WACS_S7:= _nc_wacs[chtype('r')];
 end;
 
-function mvinchstr(y,x : longint;s : pchar) : longint;
+function WACS_LEQUAL: cchar_t;
 begin
-  mvinchstr:=mvwinchstr(stdscr,y,x,s);
+  WACS_LEQUAL:= _nc_wacs[chtype('y')];
 end;
 
-function mvinnstr(y,x : longint;s : pchar;n : longint) : longint;
+function WACS_GEQUAL: cchar_t;
 begin
-  mvinnstr:=mvwinnstr(stdscr,y,x,s,n);
+  WACS_GEQUAL:= _nc_wacs[chtype('z')];
 end;
 
-function mvinsch(y,x: longint;c : chtype) : longint;
+function WACS_PI: cchar_t;
 begin
-  mvinsch:=mvwinsch(stdscr,y,x,c);
+  WACS_PI:= _nc_wacs[chtype('{')];
 end;
 
-function mvinsnstr(y,x : longint;s : pchar;n : longint) : longint;
+function WACS_NEQUAL: cchar_t;
 begin
-  mvinsnstr:=mvwinsnstr(stdscr,y,x,s,n);
+  WACS_NEQUAL:= _nc_wacs[chtype('|')];
 end;
 
-function mvinsstr(y,x : longint;s : pchar) : longint;
+function WACS_STERLING: cchar_t;
 begin
-  mvinsstr:=mvwinsstr(stdscr,y,x,s);
+  WACS_STERLING:= _nc_wacs[chtype('}')];
 end;
 
-function mvinstr(y,x : longint;s : pchar) : longint;
+
+
+
+function add_wch(wch: pcchar_t): longint;
 begin
-  mvinstr:=mvwinstr(stdscr,y,x,s);
+   add_wch:=wadd_wch(stdscr,wch);
 end;
 
-function mvvline(y,x,c,n : longint) : longint;
+function add_wchnstr(wchstr: pcchar_t; n: longint): longint;
 begin
-  mvvline:=mvwvline(stdscr,y,x,c,n);
+   add_wchnstr:=wadd_wchnstr(stdscr,wchstr,n);
 end;
 
-function attr_get : longint;
+function add_wchstr(wchstr: pcchar_t): longint;
 begin
-  attr_get:=wattr_get(stdscr);
+   add_wchstr:=wadd_wchstr(stdscr,wchstr);
 end;
 
-function attr_off(a : longint) : longint;
+function addnwstr(wchstr: pwchar_t; n : longint) : longint;
 begin
-  attr_off:=wattr_off(stdscr,a);
+   addnwstr:=waddnwstr(stdscr,wchstr,n);
 end;
 
-function attr_on(a : longint) : longint;
+function addwstr(wchstr: pwchar_t): longint;
 begin
-  attr_on:=wattr_on(stdscr,a);
+   addwstr:=waddnwstr(stdscr,wchstr,-(1));
 end;
 
-function attr_set(a : longint) : longint;
+function bkgrnd(wch: pcchar_t): longint;
 begin
-  attr_set:=wattr_set(stdscr,a);
+   bkgrnd:=wbkgrnd(stdscr,wch);
 end;
 
-function chgat(n,a,c,o : longint) : longint;
+procedure bkgrndset(wch: pcchar_t);
 begin
- chgat:=wchgat(stdscr,n,a,c,pointer(ptrint(o)));
+   wbkgrndset(stdscr,wch);
 end;
 
-function getbkgd(win : pwindow) : longint;
+function border_set(ls,rs,ts,bs,tl,tr,bl,br: pcchar_t) : longint;
 begin
-  getbkgd:=win^._bkgd;
+   border_set:=wborder_set(stdscr,ls,rs,ts,bs,tl,tr,bl,br);
 end;
 
-function mvchgat(y,x,n,a,c,o : longint) : longint;
+function box_set(win: PWINDOW; verch,horch: pcchar_t) : longint;
 begin
-  mvchgat:=mvwchgat(stdscr,y,x,n,a,c,o);
+   //box_set:=wborder_set(win,verch,verch,horch,horch,0,0,0,0);
+   box_set:=wborder_set(win,verch,verch,horch,horch,nil,nil,nil,nil);
 end;
 
-function slk_attr_off(a : longint) : longint;
+function echo_wchar(wch: Pcchar_t): longint;
 begin
-  slk_attr_off:=slk_attroff(a);
+   echo_wchar:=wecho_wchar(stdscr,wch);
 end;
 
-function slk_attr_on(a : longint) : longint;
+function get_wch(wch: Plongint): longint;
 begin
-  slk_attr_on:=slk_attron(a);
+   get_wch:=wget_wch(stdscr,wch);
 end;
 
-function slk_attr_set(a : longint) : longint;
+function get_wstr(wstr: PLongint): longint;
 begin
-  slk_attr_set:=slk_attrset(a);
+   get_wstr:=wget_wstr(stdscr,wstr);
 end;
 
-function vid_attr(a : longint) : longint;
+
+
+
+function getbkgrnd(wch: pcchar_t): longint;
 begin
-  vid_attr:=vidattr(a);
+   getbkgrnd := wgetbkgrnd(stdscr,wch);
 end;
 
-function wattr_get(win : pwindow) : longint;
+function getn_wstr(wstr: PLongint; n: longint): longint;
 begin
-  wattr_get:=win^._attrs;
+   getn_wstr := wgetn_wstr(stdscr,wstr,n);
 end;
 
-function KEY_F(n : longint) : longint;
+function hline_set(wch: pcchar_t; n: longint): longint;
 begin
-  KEY_F:=KEY_F0 + n;
+   hline_set := whline_set(stdscr,wch,n);
 end;
 
-procedure getyx(win : pwindow; var y,x : longint);
+function in_wch(wch: pcchar_t) : longint;
 begin
-  X:=ERR;
-  Y:=ERR;
-  if Win<>Nil then
-   begin
-     Y:=win^._cury;
-     X:=Win^._curx;
-   end;
+   in_wch := win_wch(stdscr,wch);
 end;
 
-procedure getbegyx(win : pwindow; var y,x : longint);
+function in_wchnstr(wchstr: pcchar_t; n: longint): longint;
 begin
-  X:=ERR;
-  Y:=ERR;
-  if Win<>Nil then
-   begin
-     Y:=win^._begy;
-     X:=Win^._begx;
-   end;
+   in_wchnstr := win_wchnstr(stdscr,wchstr,n);
 end;
 
-procedure getmaxyx(win : pwindow; var y,x : longint);
+function in_wchstr(wchstr: pcchar_t) : longint;
 begin
-  X:=ERR;
-  Y:=ERR;
-  if Win<>Nil then
-   begin
-     Y:=win^._maxy+1;
-     X:=Win^._maxx+1;
-   end;
+   in_wchstr := win_wchstr(stdscr,wchstr);
 end;
 
-procedure getparyx(win : pwindow; var y,x : longint);
+function innwstr(wstr: pwchar_t; n : longint) : longint;
 begin
-  X:=ERR;
-  Y:=ERR;
-  if Win<>Nil then
-   begin
-     Y:=win^._pary;
-     X:=Win^._parx;
-   end;
+   innwstr:=winnwstr(stdscr,wstr,n);
 end;
-(* kjw, 08/23/2000, external in v4.2
-function winch (win : PWindow) : longint;
+
+function ins_nwstr(wstr: pwchar_t; n: longint): longint;
 begin
-  if win<>nil then
-   winch:=win^._line[win^._cury].text[Win^ ._curx]
-  else
-   winch:=0;
+   ins_nwstr:=wins_nwstr(stdscr,wstr,n);
 end;
 
-function wattr_set(win : pwindow; at : longint) : longint;
+function ins_wch(wch: pcchar_t): longint;
 begin
-  If win<>nil then
-   begin
-     win^._attrs := at;
-     wattr_set:=at;
-   end
-  else
-   wattr_set:=0;
+   ins_wch:=wins_wch(stdscr,wch);
 end;
-*)
-procedure setsyx (y,x : longint);
+
+function ins_wstr(wstr: pwchar_t): longint;
 begin
-  stdscr^._cury := y;
-  stdscr^._curx := x;
+   ins_wstr:=wins_wstr(stdscr,wstr);
 end;
 
-function  mvwaddch(win : pwindow;y,x : longint; ch : chtype) : longint;
+function inwstr(wstr: pwchar_t): longint;
 begin
-  if wmove(win,y,x) = ERR then
-   exit(ERR)
-  else
-   exit(waddch(win,ch))
+   inwstr:=winwstr(stdscr,wstr);
 end;
 
-function  mvwaddchnstr(win : pwindow;y,x : longint;st : pchar;n : longint) : longint;
+function vline_set(wch: pcchar_t; n: longint): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
-  else
-   exit(waddchnstr(win,st,n))
+   vline_set:=wvline_set(stdscr,wch,n);
 end;
 
-function  mvwaddchstr(win : pwindow;y,x : longint;st : pchar) : longint;
+function wadd_wchstr(win: PWINDOW; wchstr: pcchar_t): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
-  else
-   exit(waddchnstr(win,st,-1))
+   wadd_wchstr:=wadd_wchnstr(win,wchstr,-(1));
 end;
 
-function  mvwaddnstr(win : pwindow;y,x : longint;st : pchar;n : longint) : longint;
+function waddwstr(win: PWINDOW; wstr: pwchar_t): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
-  else
-   exit(waddnstr(win,st,n))
+   waddwstr:=waddnwstr(win,wstr,-(1));
 end;
 
-function  mvwaddstr(win : pwindow;y,x : longint;st : pchar) : longint;
+function wget_wstr(win: PWINDOW; wstr: PLongint): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
-  else
-   exit(waddnstr(win,st,-1))
+   wget_wstr:=wgetn_wstr(win,wstr,-(1));
 end;
 
-function  mvwdelch(win : pwindow;y,x : longint) : longint;
+function win_wchstr(win: PWINDOW; wchstr: pcchar_t): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
-  else
-   exit(wdelch(win))
+   win_wchstr:=win_wchnstr(win,wchstr,-(1));
 end;
 
-function  mvwgetch(win : pwindow;y,x : longint) : longint;
+function wins_wstr(win: PWINDOW; wstr: pwchar_t) : longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
-  else
-   exit(wgetch(win))
+   wins_wstr:=wins_nwstr(win,wstr,-(1));
 end;
 
-function  mvwgetnstr(win : pwindow;y,x : longint;st : pchar;n: longint) : longint;
+function mvadd_wch(y,x: Smallint;  wch: pcchar_t): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvadd_wch := ERR
   else
-   exit(wgetnstr(win,st,n))
+    mvadd_wch := wadd_wch(stdscr,wch);
 end;
 
-function  mvwgetstr(win : pwindow;y,x : longint;st: pchar) : longint;
+function mvadd_wchnstr(y,x: Smallint; wchstr: pcchar_t; n: longint): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvadd_wchnstr := ERR
   else
-   exit(wgetstr(win,st))
+    mvadd_wchnstr := wadd_wchnstr(stdscr,wchstr,n);
 end;
 
-function  mvwhline(win : pwindow;y,x : longint;c : chtype;n : longint) : longint;
+function mvadd_wchstr(y,x: Smallint; wchstr: pcchar_t): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvadd_wchstr := ERR
   else
-   exit(whline(win,c,n))
+    mvadd_wchstr := wadd_wchnstr(stdscr,wchstr,-(1));
 end;
 
-function  mvwinch(win : pwindow;y,x : longint) : longint;
+function mvaddnwstr(y,x: Smallint; wstr: pwchar_t; n: longint): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvaddnwstr := ERR
   else
-   exit(winch(win))
+    mvaddnwstr := waddnwstr(stdscr,wstr,n);
 end;
 
-function  mvwinchnstr(win : pwindow;y,x : longint;s : pchar; n : longint) : longint;
+function mvaddwstr(y,x: Smallint; wstr: pwchar_t) : longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvaddwstr := ERR
   else
-   exit(winchnstr(win,s,n))
+    mvaddwstr := waddnwstr(stdscr,wstr,-(1));
 end;
 
-function  mvwinchstr(win : pwindow;y,x : longint;s : pchar) : longint;
+function mvget_wch(y,x: Smallint; wch: Plongint) : longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvget_wch := ERR
   else
-   exit(winchstr(win,s))
+    mvget_wch := wget_wch(stdscr,wch);
 end;
 
-function  mvwinnstr(win : pwindow;y,x : longint;s : pchar;n : longint) : longint;
+
+function mvget_wstr(y,x: Smallint; wstr: Plongint): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvget_wstr := ERR
   else
-   exit(winnstr(win,s,n))
+    mvget_wstr := wgetn_wstr(stdscr,wstr,-(1));
 end;
 
-function  mvwinsch(win : pwindow;y,x : longint;c : chtype) : longint;
+function mvgetn_wstr(y,x: Smallint; wstr: Plongint; n: longint): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvgetn_wstr := ERR
   else
-   exit(winsch(win,c))
+    mvgetn_wstr := wgetn_wstr(stdscr,wstr,n);
 end;
 
-function  mvwinsnstr(win : pwindow;y,x : longint;s : pchar;n : longint) : longint;
+
+function mvhline_set(y,x: Smallint; wch: pcchar_t; n: longint): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvhline_set := ERR
   else
-   exit(winsnstr(win,s,n))
+    mvhline_set := whline_set(stdscr,wch,n);
 end;
 
-function  mvwinsstr(win : pwindow;y,x : longint;s : pchar) : longint;
+function mvin_wch(y,x: Smallint; wch: pcchar_t) : longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvin_wch := ERR
   else
-   exit(winsstr(win,s))
+    mvin_wch := win_wch(stdscr,wch);
 end;
 
-function  mvwinstr(win : pwindow;y,x : longint;s : pchar) : longint;
+function mvin_wchnstr(y,x: Smallint; wchstr: pcchar_t; n: longint): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvin_wchnstr := ERR
   else
-   exit(winstr(win,s))
+    mvin_wchnstr := win_wchnstr(stdscr,wchstr,n);
 end;
 
-function  mvwvline(win : pwindow;y,x : longint;c : chtype;n : longint) : longint;
+function mvin_wchstr(y,x: Smallint; wchstr: pcchar_t): longint;
 begin
-  if wmove (win,y,x)=ERR then
-   exit(ERR)
+  if move(y,x) = ERR then
+    mvin_wchstr := ERR
   else
-   exit(wvline(win,c,n))
+    mvin_wchstr := win_wchnstr(stdscr,wchstr,-(1));
 end;
 
-function color_pair(n : longint): longint;
+function mvinnwstr(y,x: Smallint; wstr: pwchar_t; n : longint): longint;
 begin
-  color_pair:=n shl 8;
+  if move(y,x) = ERR then
+    mvinnwstr := ERR
+  else
+    mvinnwstr := winnwstr(stdscr,wstr,n);
 end;
 
-function ACS_ULCORNER : chtype;
+function mvins_nwstr(y,x: Smallint; wstr: pwchar_t; n : longint): longint;
 begin
-  ACS_ULCORNER:=acs_map['l'];
+  if move(y,x) = ERR then
+    mvins_nwstr := ERR
+  else
+    mvins_nwstr := wins_nwstr(stdscr,wstr,n);
 end;
 
-function ACS_LLCORNER : chtype;
+function mvins_wch(y,x: Smallint; wch: pcchar_t): longint;
 begin
-  ACS_LLCORNER:=acs_map['m'];
+  if move(y,x) = ERR then
+    mvins_wch := ERR
+  else
+    mvins_wch := wins_wch(stdscr,wch);
 end;
 
-function ACS_URCORNER : chtype;
+function mvins_wstr(y,x: Smallint; wstr: pwchar_t): longint;
 begin
-  ACS_URCORNER:=acs_map['k'];
+  if move(y,x) = ERR then
+    mvins_wstr := ERR
+  else
+    mvins_wstr := wins_nwstr(stdscr,wstr,-(1));
 end;
 
-function ACS_LRCORNER : chtype;
+function mvinwstr(y,x: Smallint; wstr: pwchar_t): longint;
 begin
-  ACS_LRCORNER:=acs_map['j'];
+  if move(y,x) = ERR then
+    mvinwstr := ERR
+  else
+    mvinwstr := winwstr(stdscr,wstr);
 end;
 
-function ACS_LTEE : chtype;
+function mvvline_set(y,x: Smallint; wch: pcchar_t; n : longint) : longint;
 begin
-  ACS_LTEE:=acs_map['t'];
+  if move(y,x) = ERR then
+    mvvline_set := ERR
+  else
+    mvvline_set := wvline_set(stdscr,wch,n);
 end;
 
-function ACS_RTEE : chtype;
+function mvwadd_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint;
 begin
-  ACS_RTEE:=acs_map['u'];
+  if wmove(win,y,x) = ERR then
+    mvwadd_wch := ERR
+  else
+    mvwadd_wch := wadd_wch(win,wch);
 end;
 
-function ACS_BTEE : chtype;
+function mvwadd_wchnstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t; n: longint): longint;
 begin
-  ACS_BTEE:=acs_map['v'];
+  if wmove(win,y,x) = ERR then
+    mvwadd_wchnstr := ERR
+  else
+    mvwadd_wchnstr := wadd_wchnstr(win,wchstr,n);
 end;
 
-function ACS_TTEE : chtype;
+function mvwadd_wchstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t): longint;
 begin
-  ACS_TTEE:=acs_map['w'];
+  if wmove(win,y,x) = ERR then
+    mvwadd_wchstr := ERR
+  else
+    mvwadd_wchstr := wadd_wchnstr(win,wchstr,-(1));
 end;
 
-function ACS_HLINE : chtype;
+function mvwaddnwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n: longint): longint;
 begin
-  ACS_HLINE:=acs_map['q'];
+  if wmove(win,y,x) = ERR then
+    mvwaddnwstr := ERR
+  else
+    mvwaddnwstr := waddnwstr(win,wstr,n);
 end;
 
-function ACS_VLINE : chtype;
+function mvwaddwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t): longint;
 begin
-  ACS_VLINE:=acs_map['x'];
+  if wmove(win,y,x) = ERR then
+    mvwaddwstr := ERR
+  else
+    mvwaddwstr := waddnwstr(win,wstr,-(1));
 end;
 
-function ACS_PLUS : chtype;
+function mvwget_wch(win: PWINDOW; y,x: Smallint; wch: Plongint): longint;
 begin
-  ACS_PLUS:=acs_map['n'];
+  if wmove(win,y,x) = ERR then
+    mvwget_wch := ERR
+  else
+    mvwget_wch := wget_wch(win,wch);
 end;
 
-function ACS_S1      : chtype;
+function mvwget_wstr(win: PWINDOW; y,x: Smallint; wstr: Plongint): longint;
 begin
-  ACS_S1    :=acs_map['o'];
+  if wmove(win,y,x) = ERR then
+    mvwget_wstr := ERR
+  else
+    mvwget_wstr := wgetn_wstr(win,wstr,-(1));
 end;
 
-function ACS_S9      : chtype;
+function mvwgetn_wstr(win: PWINDOW; y,x: Smallint; wstr: Plongint; n: longint): longint;
 begin
-  ACS_S9    :=acs_map['s'];
+  if wmove(win,y,x) = ERR then
+    mvwgetn_wstr := ERR
+  else
+    mvwgetn_wstr := wgetn_wstr(win,wstr,n);
 end;
 
-function ACS_DIAMOND : chtype;
+function mvwhline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint): longint;
 begin
-  ACS_DIAMOND:=acs_map['`'];
+  if wmove(win,y,x) = ERR then
+    mvwhline_set := ERR
+  else
+    mvwhline_set := whline_set(win,wch,n);
 end;
 
-function ACS_CKBOARD : chtype;
+function mvwin_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint;
 begin
-  ACS_CKBOARD:=acs_map['a'];
+  if wmove(win,y,x) = ERR then
+    mvwin_wch := ERR
+  else
+    mvwin_wch := win_wch(win,wch);
 end;
 
-function ACS_DEGREE : chtype;
+function mvwin_wchnstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t; n: longint): longint;
 begin
-  ACS_DEGREE:=acs_map['f'];
+  if wmove(win,y,x) = ERR then
+    mvwin_wchnstr := ERR
+  else
+    mvwin_wchnstr := win_wchnstr(win,wchstr,n);
 end;
 
-function ACS_PLMINUS : chtype;
+function mvwin_wchstr(win: PWINDOW; y,x: Smallint; wchstr: pcchar_t): longint;
 begin
-  ACS_PLMINUS:=acs_map['g'];
+  if wmove(win,y,x) = ERR then
+    mvwin_wchstr := ERR
+  else
+    mvwin_wchstr := win_wchstr(win,wchstr);
 end;
 
-function ACS_BULLET : chtype;
+function mvwinnwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n : longint): longint;
 begin
-  ACS_BULLET:=acs_map['~'];
+  if wmove(win,y,x) = ERR then
+    mvwinnwstr := ERR
+  else
+    mvwinnwstr := winnwstr(win,wstr,n);
 end;
 
-function ACS_LARROW : chtype;
+function mvwins_nwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t; n: longint): longint;
 begin
-  ACS_LARROW:=acs_map[','];
+  if wmove(win,y,x) = ERR then
+    mvwins_nwstr := ERR
+  else
+    mvwins_nwstr := wins_nwstr(win,wstr,n);
 end;
 
-function ACS_RARROW : chtype;
+function mvwins_wch(win: PWINDOW; y,x: Smallint; wch: pcchar_t): longint;
 begin
-  ACS_RARROW:=acs_map['+'];
+  if wmove(win,y,x) = ERR then
+    mvwins_wch := ERR
+  else
+    mvwins_wch := wins_wch(win,wch);
 end;
 
-function ACS_DARROW : chtype;
+function mvwins_wstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint;
 begin
-  ACS_DARROW:=acs_map['.'];
+  if wmove(win,y,x) = ERR then
+    mvwins_wstr := ERR
+  else
+    mvwins_wstr := wins_wstr(win,wstr);
 end;
 
-function ACS_UARROW : chtype;
+function mvwinwstr(win: PWINDOW; y,x: Smallint; wstr: pwchar_t) : longint;
 begin
-  ACS_UARROW:=acs_map['-'];
+  if wmove(win,y,x) = ERR then
+    mvwinwstr := ERR
+  else
+    mvwinwstr := winwstr(stdscr,wstr);
 end;
 
-function ACS_BOARD : chtype;
+function mvwvline_set(win: PWINDOW; y,x: Smallint; wch: pcchar_t; n: longint) : longint;
 begin
-  ACS_BOARD:=acs_map['h'];
+  if wmove(win,y,x) = ERR then
+    mvwvline_set := ERR
+  else
+    mvwvline_set := wvline_set(win,wch,n);
 end;
 
-function ACS_LANTERN : chtype;
-begin
-  ACS_LANTERN:=acs_map['i'];
-end;
 
-function ACS_BLOCK : chtype;
+
+
+
+
+
+function wmove(win: PWINDOW; y,x: Smallint): Longint;
 begin
-  ACS_BLOCK:=acs_map['0'];
+  //if (win!=nil)AND(x>=0)AND(x<=win^._maxx)AND(y>=0)AND(y<=win^._maxy) then
+  if (x OR y >=0)AND(x<=win^._maxx)AND(y<=win^._maxy) then
+  begin
+    win^._curx := x;
+    win^._cury := y;
+    win^._flags := win^._flags AND not _WRAPPED;
+    win^._flags := win^._flags OR _HASMOVED;
+    wmove := OK
+  end
+  else
+    wmove := ERR
 end;
 
-function ACS_S3      : chtype;
+
+(* macros to extract single event-bits from masks *)
+
+function BUTTON_RELEASE(e,x: longint): longint;
+{ #define BUTTON_RELEASE(e, x)    ((e) & (001 << (6 * ((x) - 1)))) }
 begin
-  ACS_S3    :=acs_map['p'];
+   BUTTON_RELEASE:=e AND (001 shl (6*(x-1)));
 end;
 
-function ACS_S7      : chtype;
+function BUTTON_PRESS(e,x: longint): longint;
+{ #define BUTTON_PRESS(e, x)    ((e) & (002 << (6 * ((x) - 1)))) }
 begin
-  ACS_S7    :=acs_map['r'];
+   BUTTON_PRESS:=e AND (002 shl (6*(x-1)));
 end;
 
-function ACS_LEQUAL : chtype;
+function BUTTON_CLICK(e,x: longint): longint;
+//#define BUTTON_CLICK(e, x)    ((e) & (004 << (6 * ((x) - 1))))
 begin
-  ACS_LEQUAL:=acs_map['y'];
+   BUTTON_CLICK:=e AND (004 shl (6*(x-1)));
 end;
 
-function ACS_GEQUAL : chtype;
+function BUTTON_DOUBLE_CLICK(e,x: longint): longint;
+//#define BUTTON_DOUBLE_CLICK(e, x) ((e) & (010 << (6 * ((x) - 1))))
 begin
-  ACS_GEQUAL:=acs_map['z'];
+   BUTTON_DOUBLE_CLICK:=e AND (8 shl (6*(x-1)));
 end;
 
-function ACS_PI      : chtype;
+function BUTTON_TRIPLE_CLICK(e,x: longint): longint;
+//#define BUTTON_TRIPLE_CLICK(e, x) ((e) & (020 << (6 * ((x) - 1))))
 begin
-  ACS_PI    :=acs_map['{'];
+   BUTTON_TRIPLE_CLICK:=e AND (16 shl (6*(x-1)));
 end;
 
-function ACS_NEQUAL : chtype;
+function BUTTON_RESERVED_EVENT(e,x: longint): longint;
+//#define BUTTON_RESERVED_EVENT(e, x) ((e) & (040 << (6 * ((x) - 1))))
 begin
-  ACS_NEQUAL:=acs_map['|'];
+   BUTTON_RESERVED_EVENT:=e AND (32 shl (6*(x-1)));
 end;
 
-function ACS_STERLING : chtype;
+
+function mouse_trafo(pY,pX: PLongint; to_screen: Bool): Bool;
 begin
-  ACS_STERLING:=acs_map['}'];
+   mouse_trafo:=wmouse_trafo(stdscr,pY,pX,to_screen);
 end;
 
-end.
+
+end.

+ 14 - 12
packages/ncurses/src/ocrt.pp

@@ -287,7 +287,7 @@ Const
 
 Type
    {*** structures to save a screen via nGrabScreen ***}
-   pnOneRow = pchar;
+   pnOneRow = pchtype;
    { a buffer for a max of 256 chtype items accessed via pchar }
    tnOneRow = array [0..1023] of char;
    { a one way linked list of screen rows }
@@ -355,7 +355,7 @@ Type
       Procedure ClrChMap(idx : integer);
    End;
 
-   pwin = ^Window;
+   pwin = PWindow;
 
    pnWindow = ^tnWindow;
    tnWindow = Object
@@ -651,7 +651,7 @@ Begin
    Else Begin
       wn := win;
       wbkgd(win,COLOR_PAIR(nSetColorPair(wincolor)));
-      If nisbold(wincolor) then wattr_on(win,A_BOLD);
+      If nisbold(wincolor) then wattr_on(win,A_BOLD,nil);
       scrollok(win,bool(true));
       intrflush(win,bool(false));
       keypad(win,bool(true));
@@ -819,7 +819,7 @@ Begin
             att := A_BOLD
          Else
             att := A_NORMAL;
-         mvwchgat(win,0,hx,len,att,cp,0);
+         mvwchgat(win,0,hx,len,att,cp,Nil);
       End;
    End;
 End;
@@ -828,7 +828,8 @@ End;
 Procedure tnWindow.SetColor(att : integer);
 Begin
    wbkgd(wn,COLOR_PAIR(nSetColorPair(att)));
-   If nisbold(att) then wattr_set(wn,A_BOLD);
+   If nisbold(att) then 
+     wattr_set(wn,A_BOLD,0,Nil);
    wincolor := att;
    If visible Then wrefresh(wn);
 End;
@@ -857,10 +858,11 @@ Var
    x,y,
    mx,my,
    atts : longint;
+   
 Begin
    wbkgd(win,COLOR_PAIR(nSetColorPair(att)));
-   atts := wattr_get(win);
-   If nisbold(att) then wattr_on(win,atts or A_BOLD);
+   atts := wattr_get(win,nil,Nil,nil);
+   If nisbold(att) then wattr_on(win,atts or A_BOLD,Nil);
    box(win,ACS_VLINE,ACS_HLINE);
    framecolor := att;
    If framecolor = -1 Then framecolor := wincolor;
@@ -874,7 +876,7 @@ Begin
          subp := new_panel(sub);
          hide_panel(subp);
          wbkgd(sub,COLOR_PAIR(nSetColorPair(wincolor)));
-         If nisbold(wincolor) then wattr_on(sub,A_BOLD);
+         If nisbold(wincolor) then wattr_on(sub,A_BOLD,Nil);
          scrollok(sub,bool(true));
          intrflush(sub,bool(false));
          keypad(sub,bool(true));
@@ -1563,7 +1565,7 @@ Begin
       att := A_BOLD or A_ALTCHARSET
    Else
       att := A_NORMAL or A_ALTCHARSET;
-   mvwchgat(win,y-1,x-1,1,att,cp,0);
+   mvwchgat(win,y-1,x-1,1,att,cp,Nil);
    { return cursor to saved position }
    wmove(win,yy,xx);
    If doRefresh Then wrefresh(win);
@@ -1614,7 +1616,7 @@ Begin
    End;
    wbkgd(sub,COLOR_PAIR(nSetColorPair(Attrib)));
    If nisbold(Attrib) then
-      wattr_on(sub,A_BOLD);
+      wattr_on(sub,A_BOLD,Nil);
    mvwaddstr(sub,0,0,StrPCopy(ps,s));
    { highlight the embedded control characters substitutes }
    If ctrl Then Begin
@@ -2586,10 +2588,10 @@ Var
    c : longint;
    { array of char/attr values, 4 bytes each, max 256 }
    buf : array[0..1023] of char;
-   p : pchar;
+   p : pchtype;
 Begin
    s := '';
-   p := nReadScrStr(win,x,y,n,buf);
+   p := nReadScrStr(win,x,y,n,@buf);
    If p <> nil Then Begin
       idx := 0;
       For i := 1 to n Do Begin

+ 45 - 57
packages/ncurses/src/panel.pp

@@ -1,64 +1,52 @@
-unit panel;
-{---------------------------------------------------------------------------
-                                 CncWare
-----------------------------------------------------------------------------
-  Filename..: panel.pp
-  Programmer: Ken J. Wright
-  Date......: 12/08/1999
-
-  Purpose - Link to the Linux 'panel' library for ncurses windowing
-            functions. The panel library handles overlapping windows,
-            whereas, native ncurses windowing is only tiled.
 
--------------------------------< Revisions >---------------------------------
- Revision|   Date   | Prog| Description
------------------------------------------------------------------------------
- 1.00    | 12/08/99 | kjw | Initial release.
------------------------------------------------------------------------------
-}
+unit panel;
 interface
-uses ncurses;
-
-{$PACKRECORDS 4}
-{$linklib panel}
-
-  const
-    libpanel = 'panel';
-
-  type
 
-     pPANEL = ^_PANEL;
-
-     _PANEL = record
-          win : ^WINDOW;
-          wstarty : longint;
-          wendy : longint;
-          wstartx : longint;
-          wendx : longint;
-          below : ppanel;
-          above : ppanel;
-          user : longint; { NCURSES_CONST void  user; }
-          obscure : pointer;
-       end;
-
-  function panel_window(_para1:pPANEL):pWINDOW;cdecl;external libpanel;
-  procedure update_panels;cdecl;external libpanel;
-  function hide_panel(_para1:pPANEL):longint;cdecl;external libpanel;
-  function show_panel(_para1:pPANEL):longint;cdecl;external libpanel;
-  function del_panel(_para1:pPANEL):longint;cdecl;external libpanel;
-  function top_panel(_para1:pPANEL):longint;cdecl;external libpanel;
-  function bottom_panel(_para1:pPANEL):longint;cdecl;external libpanel;
-  function new_panel(_para1:pWINDOW):pPANEL;cdecl;external libpanel;
-  function panel_above(_para1:pPANEL):pPANEL;cdecl;external libpanel;
-  function panel_below(_para1:pPANEL):pPANEL;cdecl;external libpanel;
-
-  { extern  int set_panel_userptr(PANEL  , NCURSES_CONST void  );  }
-  { extern  NCURSES_CONST void  panel_userptr(const PANEL  );  }
-
-  function move_panel(_para1:pPANEL; _para2:longint; _para3:longint):longint;cdecl;external libpanel;
-  function replace_panel(_para1:pPANEL; _para2:pWINDOW):longint;cdecl;external libpanel;
-  function panel_hidden(_para1:pPANEL):longint;cdecl;external libpanel;
+uses
+  ncurses;
+
+
+{$PACKRECORDS C}
+{$linklib panelw}
+
+const
+   libpanel = 'panelw';
+
+(* Const before type ignored *)
+type
+   PPANEL  = ^TPANEL;
+   TPANEL = record
+        win : PWINDOW;
+        below : PPANEL;
+        above : PPANEL;
+        user : Pointer;
+     end;
+
+(* Const before type ignored *)
+
+function panel_window(_para1:PPANEL):PWINDOW; cdecl;external libpanel;
+procedure update_panels; cdecl;external libpanel;
+function hide_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
+function show_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
+function del_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
+function top_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
+function bottom_panel(_para1:PPANEL):Longint; cdecl;external libpanel;
+function new_panel(_para1:PWINDOW):PPANEL; cdecl;external libpanel;
+(* Const before type ignored *)
+function panel_above(_para1:PPANEL):PPANEL; cdecl;external libpanel;
+(* Const before type ignored *)
+function panel_below(_para1:PPANEL):PPANEL; cdecl;external libpanel;
+(* Const before type ignored *)
+function set_panel_userptr(_para1:PPANEL; _para2:pointer):Longint; cdecl;external libpanel;
+(* Const before type ignored *)
+(* Const before type ignored *)
+function panel_userptr(_para1:PPANEL):pointer; cdecl;external libpanel;
+function move_panel(_para1:PPANEL; _para2:Longint; _para3:Longint):Longint; cdecl;external libpanel;
+function replace_panel(_para1:PPANEL; _para2:PWINDOW):Longint; cdecl;external libpanel;
+(* Const before type ignored *)
+function panel_hidden(_para1:PPANEL):Longint; cdecl;external libpanel;
 
 implementation
 
+
 end.

+ 36 - 0
packages/ncurses/tests/cotest.pp

@@ -0,0 +1,36 @@
+program const_test;
+
+uses
+  ncurses;
+
+begin
+   //writeln('NCURSES_TRIPLE_CLICKED', NCURSES_TRIPLE_CLICKED);
+   writeln('BUTTON1_RELEASED ', BUTTON1_RELEASED);
+   writeln('BUTTON1_PRESSED ', BUTTON1_PRESSED);
+   writeln('BUTTON1_CLICKED ', BUTTON1_CLICKED);
+   writeln('BUTTON1_DOUBLE_CLICKED ', BUTTON1_DOUBLE_CLICKED);
+   writeln('BUTTON1_TRIPLE_CLICKED ', BUTTON1_TRIPLE_CLICKED);
+
+
+
+   writeln('BUTTON2_RELEASED', BUTTON2_RELEASED);
+   writeln('BUTTON2_PRESSED', BUTTON2_PRESSED);
+   writeln('BUTTON2_CLICKED', BUTTON2_CLICKED);
+   writeln('BUTTON2_DOUBLE_CLICKED', BUTTON2_DOUBLE_CLICKED);
+   writeln('BUTTON2_TRIPLE_CLICKED', BUTTON2_TRIPLE_CLICKED);
+
+   writeln('BUTTON3_RELEASED', BUTTON3_RELEASED);
+   writeln('BUTTON3_PRESSED', BUTTON3_PRESSED);
+   writeln('BUTTON3_CLICKED', BUTTON3_CLICKED);
+   writeln('BUTTON3_DOUBLE_CLICKED', BUTTON3_DOUBLE_CLICKED);
+   writeln('BUTTON3_TRIPLE_CLICKED', BUTTON3_TRIPLE_CLICKED);
+
+   writeln('BUTTON4_RELEASED', BUTTON4_RELEASED);
+   writeln('BUTTON4_PRESSED', BUTTON4_PRESSED);
+   writeln('BUTTON4_CLICKED', BUTTON4_CLICKED);
+   writeln('BUTTON4_DOUBLE_CLICKED', BUTTON4_DOUBLE_CLICKED);
+   writeln('BUTTON4_TRIPLE_CLICKED', BUTTON4_TRIPLE_CLICKED);
+
+
+   //writeln('ALL_MOUSE_EVENTS', ALL_MOUSE_EVENTS);
+end.

+ 80 - 0
packages/ncurses/tests/t1form.pp

@@ -0,0 +1,80 @@
+program form_basic;
+{
+  Example 25. Forms Basics
+  from ncurses howto
+}
+{$MODE OBJFPC}
+
+uses
+  ncurses, form;
+
+var
+  field: array[0..2] of PFIELD;
+  my_form: PFORM;
+  ch: Longint;
+begin
+
+try
+  (* Initialize curses *)
+   initscr();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+
+  (* Initialize the fields *)
+   field[0] := new_field(1, 10, 4, 18, 0, 0);
+   field[1] := new_field(1, 10, 6, 18, 0, 0);
+   field[2] := nil;
+
+  (* Set field options *)
+    set_field_back(field[0], A_UNDERLINE);  { Print a line for the option }
+    field_opts_off(field[0], O_AUTOSKIP);   { Don't go to next field when this }
+                                            { Field is filled up           }
+    set_field_back(field[1], A_UNDERLINE);
+    field_opts_off(field[1], O_AUTOSKIP);
+
+  (* Create the form and post it *)
+    my_form := new_form(field);
+    post_form(my_form);
+    refresh();
+
+    mvprintw(4, 10, 'Value 1:');
+    mvprintw(6, 10, 'Value 2:');
+    refresh();
+
+  (* Loop through to get user requests *)
+    ch := getch();
+    while ch <> KEY_F(1) do
+    begin
+      case ch of
+        KEY_DOWN:
+    (* Go to next field *)
+        begin
+          form_driver(my_form, REQ_NEXT_FIELD);
+            { Go to the end of the present buffer
+              Leaves nicely at the last character }
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_UP:
+    (* Go to previous field *)
+        begin
+          form_driver(my_form, REQ_PREV_FIELD);
+          form_driver(my_form, REQ_END_LINE);
+        end;
+      else
+          { If this is a normal character, it gets
+            Printed }
+        form_driver(my_form, ch);
+      end;
+      ch := getch();
+    end
+  finally
+  (* Un post form and free the memory *)
+    unpost_form(my_form);
+    free_form(my_form);
+    free_field(field[0]);
+    free_field(field[1]);
+
+    endwin();
+  end;
+end.

+ 64 - 0
packages/ncurses/tests/t1menu.pp

@@ -0,0 +1,64 @@
+program Menu_Basics;
+{
+  Example 18. Menu Basics
+  from ncurses howto
+}
+{$MODE OBJFPC}
+
+uses
+  ncurses, menu;
+
+const
+  choices: array[0..4] of PChar  =
+                      (
+                        'Choice 1',
+                        'Choice 2',
+                        'Choice 3',
+                        'Choice 4',
+                        'Exit'
+                      );
+
+
+var
+  my_items: ppITEM;
+  my_menu: pMENU;
+  c, n_choices, i: Longint;
+  cur_item: pITEM;
+begin
+  try
+    initscr();
+    cbreak();
+    noecho();
+    keypad(stdscr, TRUE);
+
+    n_choices := 5;
+    GetMem(my_items, (n_choices+1)*sizeof(pITEM));
+
+    for i := 0 to n_choices - 1 do
+      my_items[i] := new_item(choices[i], choices[i]);
+    my_items[n_choices] := nil;
+
+    my_menu := new_menu(my_items);
+    mvprintw(LINES - 2, 0, 'F1 to Exit');
+    post_menu(my_menu);
+    refresh();
+
+    c := getch();
+    while c <> KEY_F(1) do
+    begin
+      case c of
+        KEY_DOWN: menu_driver(my_menu, REQ_DOWN_ITEM);
+        KEY_UP: menu_driver(my_menu, REQ_UP_ITEM);
+      else
+      end;
+      c := getch();
+    end
+
+  finally
+    free_item(my_items[0]);
+    free_item(my_items[1]);
+    free_menu(my_menu);
+    FreeMem(my_items, (n_choices+1)*sizeof(pITEM));
+    endwin();
+  end;
+end.

+ 186 - 0
packages/ncurses/tests/t2form.pp

@@ -0,0 +1,186 @@
+program form_test_2;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, form, libc;
+
+
+var
+  my_bg: NC_FPC_COLOR = COLOR_BLACK;
+
+  field: array[0..5] of PFIELD;
+  my_form: PFORM;
+  i, ch: Longint;
+begin
+
+try
+  setlocale(LC_ALL, ''); { Tested with Russian UTF-8 locale }
+
+  (* Initialize curses *)
+   initscr();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+
+  (* Initialize colors *)
+   if has_colors() then
+   begin
+     start_color();
+     if (use_default_colors() = OK) then
+       my_bg := -1
+     else
+       my_bg := COLOR_BLACK;
+
+     init_pair(1, COLOR_YELLOW, my_bg);
+     init_pair(2, COLOR_MAGENTA, my_bg);
+     init_pair(3, COLOR_WHITE, my_bg);
+     init_pair(4, COLOR_WHITE, COLOR_BLUE);
+     init_pair(5, COLOR_WHITE, COLOR_GREEN);
+     init_pair(6, COLOR_YELLOW, COLOR_GREEN);
+     init_pair(7, COLOR_BLACK, COLOR_CYAN);
+   end;
+
+  (* Initialize the fields *)
+    for i := 0 to 3 do
+    begin
+      field[i] := new_field(1, 30, 2 + i * 2, 10, 0, 0);
+      field_opts_off(field[i], O_AUTOSKIP);
+    end;
+
+   field[4] := new_field(7, 30, 2, 42, 0, 0);
+   field[5] := nil;
+
+  (* Set field options *)
+    set_field_fore(field[0], COLOR_PAIR(2));
+    set_field_back(field[0], A_UNDERLINE OR COLOR_PAIR(3));
+
+    set_field_fore(field[1], COLOR_PAIR(1));
+    set_field_back(field[1], A_UNDERLINE OR COLOR_PAIR(1));
+    field_opts_off(field[1], O_ACTIVE);
+
+    set_field_fore(field[2], COLOR_PAIR(4));
+    set_field_back(field[2], A_UNDERLINE OR COLOR_PAIR(4));
+    field_opts_off(field[2], O_PUBLIC);
+
+    set_field_fore(field[3], COLOR_PAIR(5));
+    set_field_back(field[3], A_UNDERLINE OR COLOR_PAIR(5));
+    field_opts_off(field[3], O_STATIC);
+
+    set_field_fore(field[4], COLOR_PAIR(7));
+    set_field_back(field[4], COLOR_PAIR(7));
+
+  (* Create the form and post it *)
+    my_form := new_form(field);
+    post_form(my_form);
+
+  (* Center Justification *)
+    set_field_just(field[0], JUSTIFY_CENTER);
+    set_field_buffer(field[0], 0, 'This is a static Field');
+
+    set_field_just(field[1], JUSTIFY_CENTER);
+    set_field_buffer(field[1], 0, 'This is a inactive Field');
+
+  (* Set focus to the blue field *)
+    set_current_field(my_form, field[0]);
+
+    for i := 0 to 3 do
+      mvprintw(2 + i * 2, 2, 'Value %d:', i + 1);
+    mvaddstr(LINES - 2, 0, 'F1 to Exit');
+    refresh();
+
+  (* Loop through to get user requests *)
+    ch := getch();
+    while (ch <> KEY_F(1)) AND (ch <> 27) do
+    begin
+      case ch of
+        9:   { TAB }
+        begin
+          if form_driver(my_form, REQ_NEXT_WORD) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_NEXT_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        end;
+        KEY_NPAGE:
+    (* Go to next field *)
+        begin
+          form_driver(my_form, REQ_VALIDATION);
+          form_driver(my_form, REQ_NEXT_FIELD);
+            { Go to the end of the present buffer
+              Leaves nicely at the last character }
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_PPAGE:
+    (* Go to previous field *)
+        begin
+          form_driver(my_form, REQ_VALIDATION);
+          form_driver(my_form, REQ_PREV_FIELD);
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_DOWN:
+          if form_driver(my_form, REQ_DOWN_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_DOWN_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        KEY_UP:
+          if form_driver(my_form, REQ_UP_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_UP_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        KEY_LEFT:
+          if form_driver(my_form, REQ_LEFT_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_LEFT_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        KEY_RIGHT:
+          if form_driver(my_form, REQ_RIGHT_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_RIGHT_FIELD);
+          end;
+        KEY_BACKSPACE: form_driver(my_form, REQ_DEL_PREV);
+        10: { ENTER }
+          begin
+            form_driver(my_form, 10);
+            if form_driver(my_form, REQ_NEXT_LINE) <> E_OK then
+            begin
+              form_driver(my_form, REQ_VALIDATION);
+              form_driver(my_form, REQ_NEXT_FIELD);
+              form_driver(my_form, REQ_END_LINE);
+            end;
+          end;
+      else
+          { If this is a normal character, it gets
+            Printed }
+        form_driver(my_form, ch);
+      end;
+      ch := getch();
+    end;
+
+  refresh();
+
+  finally
+    unpost_form(my_form);
+    free_form(my_form);
+    endwin();
+
+    for i := 0 to 4 do
+    begin
+      if field_status(field[i]) then
+      begin
+        writeln;
+        writeln('Value ', i,':');
+        writeln(field_buffer(field[i], 0));
+      end;
+      free_field(field[i]);
+    end
+  end;
+end.

+ 438 - 0
packages/ncurses/tests/t2menu.pp

@@ -0,0 +1,438 @@
+{$MODE OBJFPC}
+program Menu_Example;
+
+
+uses
+  ncurses, menu, panel, sysutils;
+
+
+function st_middle(scrlen, itemlen: Smallint): Smallint; inline;
+begin
+  st_middle := (scrlen - itemlen) div 2;
+end;
+
+procedure print_in_middle(win: PWINDOW; starty, startx: Smallint;
+                          width: Longint; pair: NC_FPC_COLOR;
+                          const fmt: AnsiString; args: array of const);
+var
+  tstr: AnsiString;
+  my, mx: Smallint;
+begin
+  FmtStr(tstr, fmt, args);
+  getmaxyx(win, my, mx);
+  mx -= startx;
+
+  if (width > length(tstr)) OR  (width < 2) then
+    width := length(tstr);
+
+  if width > mx then
+    width := mx;
+
+  wattron(win,pair);
+  mvwaddnstr(win,starty,startx + st_middle(mx,width),PChar(tstr),width);
+  wattroff(win,pair);
+end;
+
+
+type
+  PMinfo = ^TMinfo;
+  TMinfo = record
+    n, d: PChar;
+  end;
+
+
+type
+  TSubmenu = class
+  private
+    _win: PWINDOW;
+    _pan: PPANEL;
+    _items: ppITEM;
+    _exit, _sitem: pITEM;
+    _menu: pMENU;
+  public
+    function doevent: chtype;
+    constructor create(szy,szx,nch: Smallint; choices: PMinfo;
+                        pair: NC_FPC_COLOR;const name: AnsiString);
+    destructor destroy; override;
+    property menu: pMENU read _menu;
+    property items: ppITEM read _items;
+    property sitem: pITEM read _sitem write _sitem ;
+    property win: PWINDOW read _win;
+    property pan: PPANEL read _pan;
+  end;
+
+function TSubmenu.doevent: chtype;
+
+function doenter(var ch: chtype): Boolean;
+begin
+        if current_item(_menu) = _exit then
+        begin
+          doenter := false;
+          ch := -1
+        end
+        else
+        if current_item(_menu) = sitem then
+        begin
+          doenter := false;
+          ch := 10
+        end
+        else
+          doenter := true;
+end;
+
+var
+  ch: chtype = 0;
+  doiter: Boolean = true;
+begin
+  while doiter do
+  begin
+    ch := wgetch(_win);
+    case ch of
+      KEY_DOWN:    menu_driver(_menu, REQ_DOWN_ITEM);
+      KEY_UP:      menu_driver(_menu, REQ_UP_ITEM);
+      KEY_LEFT:    menu_driver(_menu, REQ_LEFT_ITEM);
+      KEY_RIGHT:   menu_driver(_menu, REQ_RIGHT_ITEM);
+      KEY_NPAGE:   menu_driver(_menu, REQ_SCR_DPAGE);
+      KEY_PPAGE:   menu_driver(_menu, REQ_SCR_UPAGE);
+      chtype(' '): menu_driver(_menu, REQ_TOGGLE_ITEM);
+      10: doiter := doenter(ch);             (* Enter *)
+    else
+      if menu_driver(_menu, ch) <> E_OK then
+      begin
+        doiter := false;
+        if (ch <> chtype('q')) AND  (ch <> KEY_F(10)) then
+          ch := -1;                    (* Close menu *)
+      end
+      else
+        if (ch = KEY_MOUSE) then
+          doiter := doenter(ch);
+    end;
+  end;
+  update_panels();
+  doupdate();
+  doevent := ch;
+end;
+
+constructor TSubmenu.create(szy,szx,nch: Smallint; choices: PMinfo;
+                             pair: NC_FPC_COLOR;const name: AnsiString);
+var
+  i: Longint = 0;
+  sy,sx: Smallint;
+  //mrows,mcols: Longint;
+begin
+  GetMem(_items, (nch+1)*sizeof(pITEM));
+  for i := 0 to nch - 1 do
+    _items[i] := new_item(choices[i].n, choices[i].d);
+  _items[nch] := nil;
+  _exit := _items[i];
+  sitem := nil;
+
+  _menu := new_menu(_items);
+
+  //scale_menu(_menu, @mrows, @mcols);
+  _win := newwin(szy,szx,st_middle(LINES,szy),st_middle(COLS,szx));
+  //_win := newwin(mrows + 2, mcols + 2, st_middle(LINES,mrows+2),st_middle(COLS,mcols+2));
+  _pan := new_panel(_win);
+
+  keypad(_win, TRUE);
+  box(_win, ACS_VLINE, ACS_HLINE);
+
+  wbkgd(_win, COLOR_PAIR(pair));
+  set_menu_back(_menu, COLOR_PAIR(pair));
+
+  print_in_middle(_win,0,0,szx-2,pair,name,[]);
+
+  set_menu_win(_menu, _win);
+  set_menu_sub(_menu, derwin(_win, szy-2, szx-2, 1, 1));
+  //set_menu_sub(_menu, derwin(_win, mrows, mcols, 1, 1));
+  set_menu_mark(_menu, '-');
+end;
+
+destructor TSubmenu.destroy;
+var
+  i: Longint = 0;
+begin
+  unpost_menu(_menu);
+  free_menu(_menu);
+  while _items[i] <> nil do
+  begin
+    free_item(_items[i]); Inc(i);
+  end;
+  FreeMem(_items, (i+1)*sizeof(pITEM));
+
+  del_panel(_pan);
+  delwin(_win);
+  update_panels();
+  doupdate();
+end;
+
+
+type
+  Tmainptr = function: chtype;
+
+const
+  EXIT_PROGRAM = KEY_MAX + 100;
+
+function confirm_menu: chtype;
+const
+  choices: array[0..2] of TMinfo =
+                       (
+                         (n:'    Yes    ';d:nil),
+                         (n:'I dont know';d:nil),
+                         (n:'    No     ';d:nil)
+                       );
+var
+  smenu: TSubmenu;
+  i: Longint;
+begin
+  smenu := TSubmenu.create(3, 41,3,choices,5,'Do you really want to quit?');
+
+  menu_opts_off(smenu.menu, O_SHOWDESC);
+  set_menu_format(smenu.menu, 1, 3);
+  post_menu(smenu.menu);
+
+  smenu.sitem := smenu.items[0];
+
+  confirm_menu := smenu.doevent;
+
+  if (confirm_menu = 10) OR (confirm_menu = chtype('q')) OR (confirm_menu = KEY_F(10)) then
+    confirm_menu := EXIT_PROGRAM
+  else
+    confirm_menu := -1;
+  smenu.destroy;
+end;
+
+
+(* Scrolling Menus example *)
+
+function scroll_menu: chtype;
+const
+  choices: array[0..9] of TMinfo =
+                    (
+                      (n: '1_'; d: 'Choice'),
+                      (n: '2_'; d: 'Choice'),
+                      (n: '3_'; d: 'Choice'),
+                      (n: '4_'; d: 'Choice'),
+                      (n: '5_'; d: 'Choice'),
+                      (n: '6_'; d: 'Choice'),
+                      (n: '7_'; d: 'Choice'),
+                      (n: '8_'; d: 'Choice'),
+                      (n: '9_'; d: 'Choice'),
+                      (n: '..'; d: 'Close')
+                    );
+var
+  smenu: TSubmenu;
+  i: Longint;
+begin
+  mvaddstr(LINES - 3, COLS - 30, '"PAGEUP" "PAGEDOWN" - scroll');
+  refresh();
+  smenu := TSubmenu.create(8, 13,10,choices,6,'Scrolling');
+
+  set_menu_format(smenu.menu, 6, 1);
+  post_menu(smenu.menu);
+
+  scroll_menu := smenu.doevent;
+  smenu.destroy;
+  mvaddstr(LINES - 3, COLS - 30, '                            ');
+  refresh();
+end;
+
+
+(* Milt Columnar Menus Example *)
+
+function multicol_menu: chtype;
+const
+  choices: array[0..24] of TMinfo =
+  (
+    (n:'1_';d:nil),(n:'2_';d:nil),(n:'3_';d:nil),(n:'4_';d:nil),(n:'5_';d:nil),
+    (n:'6_';d:nil),(n:'7_';d:nil),(n:'8_';d:nil),(n:'9_';d:nil),(n:'10';d:nil),
+    (n:'11';d:nil),(n:'12';d:nil),(n:'13';d:nil),(n:'14';d:nil),(n:'15';d:nil),
+    (n:'16';d:nil),(n:'17';d:nil),(n:'18';d:nil),(n:'19';d:nil),(n:'20';d:nil),
+    (n:'21';d:nil),(n:'22';d:nil),(n:'23';d:nil),(n:'24';d:nil),(n:'..';d:nil)
+  );
+var
+  smenu: TSubmenu;
+  i: Longint;
+begin
+  smenu := TSubmenu.create(7, 22,25,choices,5,'Multicol');
+
+(* Set menu option not to show the description *)
+  menu_opts_off(smenu.menu, O_SHOWDESC);
+  set_menu_format(smenu.menu, 5, 5);
+  post_menu(smenu.menu);
+
+  multicol_menu := smenu.doevent;
+  smenu.destroy;
+end;
+
+
+(* Multi Valued Menus example *)
+
+function multival_menu: chtype;
+const
+  choices: array[0..5] of TMinfo =
+                    (
+                      (n: '1_'; d: 'Choice'),
+                      (n: '2_'; d: 'Choice'),
+                      (n: '3_'; d: 'Choice'),
+                      (n: '4_'; d: 'Choice'),
+                      (n: '5_'; d: 'Choice'),
+                      (n: '..'; d: 'Close')
+                    );
+var
+  smenu: TSubmenu;
+  i: Longint;
+begin
+  mvaddstr(LINES - 3, COLS - 30, '"SPACE" - toggle choice');
+  refresh();
+  smenu := TSubmenu.create(8, 13,6,choices,7,'Multival');
+
+  menu_opts_off(smenu.menu, O_ONEVALUE);
+  post_menu(smenu.menu);
+
+  multival_menu := smenu.doevent;
+  smenu.destroy;
+  mvaddstr(LINES - 3, COLS - 30, '                       ');
+  refresh();
+end;
+
+
+const
+  n_choices = 4;
+  choices: array[0..3] of TMinfo =
+                    (
+                      (n: '1_'; d: 'Scrolling Menus'),
+                      (n: '2_'; d: 'Multi Columnar Menus'),
+                      (n: '3_'; d: 'Multi Valued Menus'),
+                      (n: '..'; d: 'Exit')
+                    );
+
+var
+  main_menu_win: PWINDOW;
+  main_menu_panel: PPANEL;
+
+function mgetch: chtype;
+begin
+  mgetch :=   wgetch(main_menu_win);
+end;
+
+var
+  my_bg: NC_FPC_COLOR = COLOR_BLACK;
+
+  main_items: ppITEM;
+  cur_item: pITEM;
+  main_menu: pMENU;
+  ptr: Tmainptr = @mgetch;
+
+  ch: chtype = -1;
+  i: Longint;
+  tstr: AnsiString;
+begin
+  try
+  (* Initialize curses *)
+    initscr();
+    noecho();
+    cbreak();
+    keypad(stdscr, TRUE);
+    curs_set(0);
+    clear();
+    mousemask(ALL_MOUSE_EVENTS, nil);
+
+    if has_colors() then
+    begin
+      start_color();
+      if (use_default_colors() = OK) then
+        my_bg := -1
+      else
+        my_bg := COLOR_BLACK;
+
+      init_pair(1, COLOR_YELLOW, my_bg);
+      init_pair(2, COLOR_RED, my_bg);
+      init_pair(3, COLOR_MAGENTA, my_bg);
+      init_pair(4, COLOR_CYAN, my_bg);
+      init_pair(5, COLOR_WHITE, COLOR_RED);
+      init_pair(6, COLOR_WHITE, COLOR_BLUE);
+      init_pair(7, COLOR_WHITE, COLOR_GREEN);
+    end;
+
+    main_menu_win := newwin(8, 40, st_middle(LINES, 8) - 2, st_middle(COLS, 40) - 10);
+    main_menu_panel := new_panel(main_menu_win);
+    keypad(main_menu_win, TRUE);
+
+  (* Create items *)
+    GetMem(main_items, (n_choices+1)*sizeof(pITEM));
+    for i := 0 to n_choices-1 do
+      main_items[i] := new_item(choices[i].n, choices[i].d);
+    main_items[n_choices] := nil;
+
+  (* Set the user pointers *)
+     set_item_userptr(main_items[0], @scroll_menu);
+     set_item_userptr(main_items[1], @multicol_menu);
+     set_item_userptr(main_items[2], @multival_menu);
+     set_item_userptr(main_items[3], @confirm_menu);
+
+  (* Crate menu *)
+     main_menu := new_menu(main_items);
+
+   (* Set main window and sub window *)
+     set_menu_win(main_menu, main_menu_win);
+     set_menu_sub(main_menu, derwin(main_menu_win, 4, 38, 3, 1));
+
+   (* Set menu mark to the string "=>" *)
+     set_menu_mark(main_menu, '=>');
+
+   (* Print a border around the main window and print a title *)
+     box(main_menu_win, 0, 0);
+     wbkgd(main_menu_win, COLOR_PAIR(6));
+     set_menu_back(main_menu, COLOR_PAIR(6));
+
+     print_in_middle(main_menu_win, 1, 0, 40, COLOR_PAIR(6), 'Main Menu', []);
+     mvwaddch(main_menu_win, 2, 0, ACS_LTEE);
+     mvwhline(main_menu_win, 2, 1, ACS_HLINE, 38);
+     mvwaddch(main_menu_win, 2, 39, ACS_RTEE);
+     attron(COLOR_PAIR(4));
+     mvaddstr(LINES - 1, COLS - 30, 'Press "F10" or "q" to exit  ');
+     attroff(COLOR_PAIR(4));
+     refresh();
+
+   (* Post the menu *)
+     post_menu(main_menu);
+     wrefresh(main_menu_win);
+
+     while ch <> EXIT_PROGRAM do
+     begin
+       case ch of
+         KEY_DOWN: menu_driver(main_menu, REQ_DOWN_ITEM);
+         KEY_UP: menu_driver(main_menu, REQ_UP_ITEM);
+         -1: ptr := @mgetch;              (* Restore ptr *)
+         10:                              (* Enter *)
+         begin
+           cur_item := current_item(main_menu);     (* get current item *)
+           ptr := Tmainptr(item_userptr(cur_item)); (* set ptr to current item *)
+         end;
+       else
+       (* Process mouse and others events *)
+         if (menu_driver(main_menu, ch) = E_OK) AND (ch = KEY_MOUSE) then
+         begin
+           cur_item := current_item(main_menu);
+           ptr := Tmainptr(item_userptr(cur_item));
+         end;
+       end;
+       ch := ptr(); (* Call ptr function *)
+
+       if (ch = chtype('q')) OR  (ch = KEY_F(10)) then
+         ch := confirm_menu();
+     end;
+
+  finally
+    unpost_menu(main_menu);
+    free_menu(main_menu);
+    for i := 0 to n_choices - 1 do
+      free_item(main_items[i]);
+    FreeMem(main_items, (n_choices+1)*sizeof(pITEM));
+    del_panel(main_menu_panel);
+    delwin(main_menu_win);
+    curs_set(1);
+    endwin();
+  end;
+end.

+ 238 - 0
packages/ncurses/tests/t3form.pp

@@ -0,0 +1,238 @@
+program form_test_3;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, form, libc;
+
+
+
+function st_middle(scrlen, itemlen: Smallint): Smallint; inline;
+begin
+  st_middle := (scrlen - itemlen) div 2;
+end;
+
+
+procedure draw;
+
+function randomchar: chtype;
+var
+  ch: Char = #0;
+begin
+  while not (ch in ['0'..'9','A'..'Z','a'..'z']) do
+    ch := Char(Random(123));
+  randomchar := chtype(ch);
+end;
+
+function randompair: longint;
+var
+  pair: longint = 0;
+begin
+  while not (pair in [1..5]) do
+    pair := Random(6);
+  randompair := pair;
+end;
+
+var
+  y, x:  Smallint;
+begin
+  for y := 0 to LINES - 1 do
+    for x := 0 to COLS - 1 do
+      mvaddch(y, x, randomchar OR COLOR_PAIR(randompair));
+end;
+
+const
+  enumval: array[0..2] of PChar = ('one', 'two', 'three');
+  desc: array[0..5] of PChar =
+              (
+                'TYPE_ALPHA    Char data, a min width 8',
+                'TYPE_ENUM      one, two, three',
+                'TYPE_INTEGER     -300 .. 300',
+                'TYPE_NUMERIC    -30.0 .. 30.0',
+                'TYPE_REGEXP ^http://.+\.(ru|net|com)\s*$',
+                'TYPE_IPV4     An IP Version 4 address.'
+              );
+var
+  my_bg: NC_FPC_COLOR = COLOR_BLACK;
+  form_win: PWINDOW;
+
+  pair: Smallint;
+  field: array[0..6] of PFIELD;
+  my_form: PFORM;
+  i, frows, fcols, ch: Longint;
+begin
+
+try
+  setlocale(LC_ALL, '');
+
+  (* Initialize curses *)
+   initscr();
+   cbreak();
+   noecho();
+   keypad(stdscr, TRUE);
+
+  (* Initialize colors *)
+   if has_colors() then
+   begin
+     start_color();
+     if (use_default_colors() = OK) then
+       my_bg := -1
+     else
+       my_bg := COLOR_BLACK;
+
+     init_pair(1, COLOR_YELLOW, my_bg);
+     init_pair(2, COLOR_MAGENTA, my_bg);
+     init_pair(3, COLOR_WHITE, my_bg);
+     init_pair(4, COLOR_CYAN, my_bg);
+     init_pair(5, COLOR_GREEN, my_bg);
+     init_pair(6, COLOR_WHITE, COLOR_BLUE);
+     init_pair(7, COLOR_BLACK, COLOR_CYAN);
+   end;
+
+
+   for i := 0 to 5 do
+   begin
+     field[i] := new_field(1, 30, 2 + i * 3, 10, 0, 0);
+     field_opts_off(field[i], O_AUTOSKIP);
+     if i AND 1 = 0 then
+       pair := 7
+     else
+       pair := 6;
+     set_field_fore(field[i], COLOR_PAIR(pair));
+     set_field_back(field[i], A_UNDERLINE OR COLOR_PAIR(pair));
+     //set_field_pad(field[i],chtype(' '));
+   end;
+   draw;
+   refresh();
+
+   field[6] := nil;
+
+   set_field_type(field[0],TYPE_ALPHA,8);
+   set_field_type(field[1],TYPE_ENUM,PPChar(enumval),0,0);
+   set_field_type(field[2],TYPE_INTEGER,3,-300,300);
+   set_field_type(field[3],TYPE_NUMERIC,8,-30.0,30.0);
+   set_field_type(field[4],TYPE_REGEXP,'^http://.+\.(ru|net|com)\s*$');
+   set_field_type(field[5],TYPE_IPV4);
+
+
+   my_form := new_form(field);
+
+(* Calculate the area required for the form *)
+   scale_form(my_form, @frows, @fcols);
+
+(* Create the window to be associated with the form *)
+   //form_win := newwin(rows + 4, cols + 4, 4, 4);
+   form_win := newwin(frows + 4, fcols + 4, st_middle(LINES,frows+4), st_middle(COLS,fcols+4));
+   keypad(form_win, TRUE);
+
+(* Set main window and sub window *)
+   set_form_win(my_form, form_win);
+   set_form_sub(my_form, derwin(form_win, frows, fcols, 2, 2));
+
+(* Print a border around the main window and print a title *)
+   box(form_win, 0, 0);
+   //print_in_middle(my_form_win, 1, 0, cols + 4, "My Form", COLOR_PAIR(1));
+
+   post_form(my_form);
+   wrefresh(form_win);
+
+   for i := 0 to 5 do
+     mvwaddstr(form_win, 3 + i * 3, 1,desc[i]);
+   wrefresh(form_win);
+
+   //set_field_buffer(field[0], 0, 'Test Field');
+   //refresh();
+
+  (* Loop through to get user requests *)
+    ch := wgetch(form_win);
+    while (ch <> KEY_F(1)) AND (ch <> 27) do
+    begin
+      case ch of
+        9:   { TAB }
+        begin
+          if form_driver(my_form, REQ_NEXT_WORD) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_NEXT_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        end;
+        KEY_NPAGE:
+    (* Go to next field *)
+        begin
+          form_driver(my_form, REQ_VALIDATION);
+          form_driver(my_form, REQ_NEXT_FIELD);
+            { Go to the end of the present buffer
+              Leaves nicely at the last character }
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_PPAGE:
+    (* Go to previous field *)
+        begin
+          form_driver(my_form, REQ_VALIDATION);
+          form_driver(my_form, REQ_PREV_FIELD);
+          form_driver(my_form, REQ_END_LINE);
+        end;
+        KEY_DOWN:
+          if form_driver(my_form, REQ_DOWN_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_DOWN_FIELD);
+          end;
+        KEY_UP:
+          if form_driver(my_form, REQ_UP_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_UP_FIELD);
+          end;
+        KEY_LEFT:
+          if form_driver(my_form, REQ_LEFT_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_LEFT_FIELD);
+            form_driver(my_form, REQ_END_LINE);
+          end;
+        KEY_RIGHT:
+          if form_driver(my_form, REQ_RIGHT_CHAR) <> E_OK then
+          begin
+            form_driver(my_form, REQ_VALIDATION);
+            form_driver(my_form, REQ_RIGHT_FIELD);
+          end;
+        KEY_BACKSPACE: form_driver(my_form, REQ_DEL_PREV);
+        10: { ENTER }
+          begin
+            form_driver(my_form, 10);
+            if form_driver(my_form, REQ_NEXT_LINE) <> E_OK then
+            begin
+              form_driver(my_form, REQ_VALIDATION);
+              form_driver(my_form, REQ_NEXT_FIELD);
+              form_driver(my_form, REQ_END_LINE);
+            end;
+          end;
+      else
+          { If this is a normal character, it gets
+            Printed }
+        form_driver(my_form, ch);
+      end;
+      ch := wgetch(form_win);
+    end;
+
+  finally
+
+    unpost_form(my_form);
+    free_form(my_form);
+    delwin(form_win);
+    endwin();
+
+    for i := 0 to 5 do
+    begin
+      if field_status(field[i]) then
+      begin
+        writeln;
+        writeln('Value ', i,':');
+        writeln(field_buffer(field[i], 0));
+      end;
+      free_field(field[i]);
+    end
+  end;
+end.

+ 67 - 0
packages/ncurses/tests/tbackground.pp

@@ -0,0 +1,67 @@
+
+uses
+   ncurses;
+
+var
+    f, b: Smallint;
+begin
+
+ initscr();
+ cbreak();
+ noecho();
+
+ if (has_colors()) then
+  begin
+	start_color();
+
+	pair_content(0, @f, @b);
+  printw(PChar('pair 0 contains (%d,%d)'#10), f, b);
+	getch();
+
+	printw('Initializing pair 1 to red/black'#10);
+	init_pair(1, COLOR_RED, COLOR_BLACK);
+	bkgdset(chtype(' ') OR COLOR_PAIR(1));
+	printw('RED/BLACK'#10);
+	getch();
+
+	printw('Initializing pair 2 to white/blue'#10);
+	init_pair(2, COLOR_WHITE, COLOR_BLUE);
+	bkgdset(chtype(' ') OR COLOR_PAIR(2));
+	printw('WHITE/BLUE'#10);
+	getch();
+
+	printw('Resetting colors to pair 0'#10);
+	bkgdset(chtype(' ') OR COLOR_PAIR(0));
+	printw('Default Colors'#10);
+	getch();
+
+	printw('Resetting colors to pair 1'#10);
+	bkgdset(chtype(' ') OR COLOR_PAIR(1));
+	printw('RED/BLACK'#10);
+	getch();
+
+	printw('Setting screen to pair 0'#10);
+	bkgd(chtype(' ') OR COLOR_PAIR(0));
+	getch();
+
+	printw('Setting screen to pair 1'#10);
+	bkgd(chtype(' ') OR COLOR_PAIR(1));
+	getch();
+
+	printw('Setting screen to pair 2'#10);
+	bkgd(chtype(' ') OR COLOR_PAIR(2));
+	getch();
+
+	printw('Setting screen to pair 0'#10);
+	bkgd(chtype(' ') OR COLOR_PAIR(0));
+	getch();
+
+ end
+ else
+ begin
+	printw('This demo requires a color terminal'#10);
+
+	getch();
+    end;
+    endwin();
+end.

+ 269 - 0
packages/ncurses/tests/tclock.pp

@@ -0,0 +1,269 @@
+program tclock;
+{$MODE OBJFPC}
+
+uses
+  libc, ncurses, sysutils;
+
+const
+  ASPECT = 2.2;
+  _2PI = 2.0 * PI;
+
+function sign(_x: Integer): Integer;
+begin
+  if _x < 0 then
+    sign := -1
+  else
+    sign := 1
+end;
+
+function A2X(angle,radius: Double): Integer; inline;
+begin
+  A2X := round(ASPECT * radius * sin(angle))
+end;
+
+function A2Y(angle,radius: Double): Integer; inline;
+begin
+  A2Y := round(radius * cos(angle))
+end;
+
+type
+  PRchar = ^TRchar;
+  TRchar = record
+    ry,rx: Smallint;
+    rch: chtype;
+  end;
+
+procedure restore( rest: PRchar );
+var
+  i: Longint = 0;
+begin
+  while rest[i].rch <> 0 do
+  begin
+    with rest[i] do
+      mvaddch(ry, rx, rch);
+    Inc(i);
+  end;
+  freemem(rest)
+end;
+
+(* Draw a diagonal(arbitrary) line using Bresenham's alogrithm. *)
+procedure dline(from_y, from_x, end_y,  end_x: Smallint; ch: chtype; var rest: PRchar);
+var
+  dx, dy: Smallint;
+  ax, ay: Smallint;
+  sx, sy: Smallint;
+  x, y, d, i: Smallint;
+begin
+  dx := end_x - from_x;
+  dy := end_y - from_y;
+
+  ax := abs(dx * 2);
+  ay := abs(dy * 2);
+
+  sx := sign(dx);
+  sy := sign(dy);
+
+  x := from_x;
+  y := from_y;
+
+  i := 0;
+  if (ax > ay) then
+  begin
+    getmem(rest, sizeof(TRchar)*(abs(dx)+3));
+    d := ay - (ax DIV 2);
+
+    while true do
+    begin
+      move(y, x);
+      with rest[i] do
+      begin
+        rch := inch;
+        ry := y;
+        rx := x;
+        Inc(i)
+      end;
+      addch(ch);
+      if (x = end_x) then
+      begin
+        rest[i].rch := 0;
+        exit;
+      end;
+
+      if (d >= 0) then
+      begin
+        y += sy;
+        d -= ax;
+      end;
+      x += sx;
+      d += ay;
+    end
+  end
+  else
+  begin
+    getmem(rest, sizeof(TRchar)*(abs(dy)+3));
+    d := ax - (ay DIV 2);
+
+    while true do
+    begin
+      move(y, x);
+      with rest[i] do
+      begin
+        rch := inch;
+        ry := y;
+        rx := x;
+        Inc(i)
+      end;
+      addch(ch);
+      if (y = end_y) then
+      begin
+        rest[i].rch := 0;
+        exit;
+      end;
+
+      if (d >= 0) then
+      begin
+        x += sx;
+        d -= ay;
+      end;
+      y += sy;
+      d += ax;
+    end
+  end
+end;
+
+
+var
+  cx, cy: Integer;
+  cr, sradius, mradius, hradius: Double;
+
+
+procedure clockinit;
+const
+  title1 = 'Free pascal';
+  title2 = 'ncurses clock';
+  title3 = 'Press F10 or q to exit';
+var
+  i: Integer;
+  vstr, tstr: AnsiString;
+  angle: Double;
+begin
+  cx := (COLS - 1) DIV 2;
+  cy := LINES DIV 2;
+  if (cx / ASPECT < cy) then
+  cr := cx / ASPECT
+    else
+  cr := cy;
+
+  sradius := (8 * cr) / 9;
+  mradius := (3 * cr) / 4;
+  hradius := cr / 2;
+
+
+  for i := 1 to 24 do
+  begin
+    angle := i * _2PI / 24.0;
+
+
+    if (i MOD 2) = 0 then
+    begin
+      Str (i DIV 2, tstr);
+      attron(A_BOLD OR COLOR_PAIR(5));
+      mvaddstr(cy - A2Y(angle, sradius), cx + A2X(angle, sradius), @tstr[1]);
+      attroff(A_BOLD OR COLOR_PAIR(5));
+    end
+    else
+    begin
+      attron(COLOR_PAIR(1));
+      mvaddch(cy - A2Y(angle, sradius), cx + A2X(angle, sradius), chtype('.'));
+      attroff(COLOR_PAIR(1));
+    end
+  end;
+
+      vstr := curses_version;
+
+  attron(A_DIM OR COLOR_PAIR(2));
+  mvhline(cy , cx - round(sradius * ASPECT) + 1, ACS_HLINE,  round(sradius * ASPECT) * 2 - 1);
+  mvvline(cy - round(sradius) + 1, cx , ACS_VLINE,  round(sradius) * 2 - 1);
+  attroff(A_DIM OR COLOR_PAIR(1));
+  attron(COLOR_PAIR(3));
+  mvaddstr(cy - 5, cx - Length(title1) DIV 2, title1);
+  mvaddstr(cy - 4, cx - Length(title2) DIV 2, title2);
+  mvaddstr(cy - 3, cx - Length(vstr) DIV 2, PChar(vstr));
+  attroff(COLOR_PAIR(3));
+  attron(A_UNDERLINE);
+  mvaddstr(cy + 2, cx - Length(title3) DIV 2, title3);
+  attroff(A_UNDERLINE);
+end;
+
+
+var
+  angle: Double;
+  ch: chtype;
+  Hour, Min, Sec, Msec: Word;
+  Hrest, Mrest, Srest: PRchar;
+  timestr: AnsiString;
+  my_bg: NC_FPC_COLOR = COLOR_BLACK;
+begin
+  setlocale(LC_ALL, '');
+
+  try
+    initscr();
+    noecho();
+    cbreak();
+
+    halfdelay(10);
+    keypad(stdscr, TRUE);
+    curs_set(0);
+
+    if (has_colors()) then
+    begin
+      start_color();
+      if (use_default_colors() = OK) then
+        my_bg := -1;
+
+      init_pair(1, COLOR_YELLOW, my_bg);
+      init_pair(2, COLOR_RED, my_bg);
+      init_pair(3, COLOR_GREEN, my_bg);
+      init_pair(4, COLOR_CYAN, my_bg);
+      init_pair(5, COLOR_YELLOW, COLOR_BLACK) ;
+    end;
+
+    clockinit;
+    repeat
+      if (ch = KEY_RESIZE) then
+      begin
+        flash();
+        erase();
+        wrefresh(curscr);
+        clockinit;
+      end;
+
+      decodeTime(Time, Hour, Min, Sec, Msec);
+      Hour := Hour MOD 12;
+
+      timestr := DateTimeToStr(Now);
+      mvaddstr(cy + round(sradius) - 4, cx - Length(timestr) DIV 2, PChar(timestr));
+
+      angle := Hour * _2PI / 12;
+      dline(cy, cx, cy - A2Y(angle, hradius), cx + A2X(angle, hradius), chtype('*'),Hrest);
+
+      angle := Min * _2PI / 60;
+      dline(cy, cx, cy - A2Y(angle, mradius), cx + A2X(angle, mradius), chtype('*'),Mrest);
+
+      angle := Sec * _2PI / 60;
+      dline(cy, cx, cy - A2Y(angle, sradius), cx + A2X(angle, sradius), chtype('.'),Srest);
+
+      wsyncup(stdscr);
+      refresh;
+      ch := getch();
+
+      restore(Srest);
+      restore(Mrest);
+      restore(Hrest);
+
+    until (ch = chtype('q')) OR (ch = KEY_F(10));
+  finally
+    curs_set(1);
+    endwin();
+  end;
+end.

+ 39 - 0
packages/ncurses/tests/tevent.pp

@@ -0,0 +1,39 @@
+program test_event;
+
+{$MODE OBJFPC}
+
+uses
+  ncurses, sysutils;
+
+
+var
+  ch: chtype;
+begin
+  try
+    initscr();
+    noecho();
+    clear();
+    cbreak();
+    keypad(stdscr, TRUE);
+    mousemask(1, nil);
+
+    mvaddstr(1, 1,'press F10 or q to exit');
+    mvaddstr(2, 1,'press 1 to cbreak mode');
+    mvaddstr(3, 1,'press 2 to raw mode');
+    mvaddstr(4, 1,'press 3 to halfdelay(10) mode');
+    repeat
+      ch := getch;
+      mvaddstr(LINES - 1, 1,'                                ');
+      case ch of
+        ERR: mvaddstr(LINES - 1, 1,'timeout: 1 sec');
+        chtype('1'): cbreak();
+        chtype('2'): raw();
+        chtype('3'): halfdelay(10);
+      else
+        mvaddstr(LINES - 1, 1,PChar(Format('name:%-14s code:%d', [ keyname(ch), ch ] )));
+      end;
+    until (ch = chtype('q')) OR (ch = KEY_F(10));
+  finally
+    endwin();
+  end;
+end.

+ 144 - 0
packages/ncurses/tests/tmouse.pp

@@ -0,0 +1,144 @@
+program mouse_test;
+{$MODE OBJFPC}
+{$COPERATORS ON}
+
+
+uses
+  ncurses, panel, sysutils;
+
+procedure draw;
+
+function randomchar: chtype;
+var
+  ch: Char = #0;
+begin
+  while not (ch in ['0'..'9','A'..'Z','a'..'z']) do
+    ch := Char(Random(123));
+  randomchar := chtype(ch);
+end;
+
+function randompair: longint;
+var
+  pair: longint = 0;
+begin
+  while not (pair in [1..5]) do
+    pair := Random(6);
+  randompair := pair;
+end;
+
+var
+  y, x:  Smallint;
+begin
+  for y := 0 to 2 do
+    for x := 0 to COLS - 7 do
+      mvaddch(y, x, randomchar OR COLOR_PAIR(randompair));
+  attron(A_BOLD OR COLOR_PAIR(7));
+  mvaddstr(0, COLS - 6, '      ');
+  mvaddstr(1, COLS - 6, ' QUIT ');
+  mvaddstr(2, COLS - 6, '      ');
+  attroff(A_BOLD OR COLOR_PAIR(7));
+  for y := 3 to LINES - 1 do
+    for x := 0 to COLS - 1 do
+      mvaddch(y, x, randomchar OR COLOR_PAIR(randompair));
+end;
+
+
+var
+  win: PWINDOW;
+  pan: PPANEL;
+  str: AnsiString;
+function doevent: chtype;
+var
+  event: MEVENT;
+begin
+  getmouse(@event);
+  if (event.y > 2) OR (event.x < COLS - 6) then
+  begin
+    mvwaddstr(win, 1, 1, '                  ');
+    str := Format('y := %D, x := %D', [event.y, event.x]);
+    mvwaddstr(win, 1, 2, PChar(str));
+    wattron(win,A_BOLD);
+    mvwaddch(win, 3, 9, mvinch(event.y,event.x ));
+    wattroff(win,A_BOLD);
+    halfdelay(12);
+
+    show_panel(pan);
+
+    if event.bstate AND  BUTTON1_RELEASED<> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON1_RELEASED')
+    else if event.bstate AND BUTTON2_RELEASED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON2_RELEASED')
+    else if event.bstate AND BUTTON3_RELEASED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON3_RELEASED')
+    else if event.bstate AND BUTTON1_PRESSED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON1_PRESSED ')
+    else if event.bstate AND BUTTON2_PRESSED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON2_PRESSED ')
+    else if event.bstate AND BUTTON3_PRESSED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON3_PRESSED ')
+    else if event.bstate AND BUTTON1_CLICKED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON1_CLICKED ')
+    else if event.bstate AND BUTTON2_CLICKED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON2_CLICKED ')
+    else if event.bstate AND BUTTON3_CLICKED <> 0 then
+      mvwaddstr(win, 5, 2,'BUTTON3_CLICKED ');
+
+    doevent := wgetch(win);
+    cbreak();
+    hide_panel(pan);
+  end
+  else
+    doevent := chtype('q')
+end;
+
+var
+  ch: chtype;
+  my_bg: NC_FPC_COLOR = COLOR_BLACK;
+begin
+  try
+    initscr();
+    noecho();
+    clear();
+    cbreak();
+    keypad(stdscr, TRUE);
+    curs_set(0);
+    mousemask(ALL_MOUSE_EVENTS, nil);
+
+    if (has_colors()) then
+    begin
+      start_color();
+      if (use_default_colors() = OK) then
+        my_bg := -1
+      else
+        my_bg := COLOR_BLACK;
+
+      init_pair(1, COLOR_YELLOW, my_bg);
+      init_pair(2, COLOR_RED, my_bg);
+      init_pair(3, COLOR_MAGENTA, my_bg);
+      init_pair(4, COLOR_CYAN, my_bg);
+      init_pair(5, COLOR_GREEN, my_bg);
+      init_pair(6, COLOR_WHITE, COLOR_BLUE);
+      init_pair(7, COLOR_WHITE, COLOR_RED);
+    end;
+
+    win:= newwin(7, 20, (LINES - 7) DIV 2 , (COLS - 20) DIV 2);
+    pan := new_panel(win);
+    box(win, ACS_VLINE, ACS_HLINE);
+    wbkgd(win, COLOR_PAIR(6));
+
+    draw;
+    repeat
+      if ch = KEY_MOUSE then
+        ch := doevent
+      else
+        ch := getch();
+    until  (ch = chtype('q')) OR (ch = KEY_F(10));
+
+  finally
+    del_panel(pan);
+    delwin(win);
+    curs_set(1);
+    endwin();
+  end;
+end.
+

+ 49 - 0
packages/ncurses/tests/tnlshello.pp

@@ -0,0 +1,49 @@
+{
+  rstconv -i tnlshello.rst -o tnlshello_ru_UTF8.pot
+  msgfmt tnlshello_ru_UTF8.pot
+  mv messages.mo ru
+}
+
+program nlshello;
+{$mode objfpc}
+
+uses
+  gettext, libc, ncurses;
+
+resourcestring
+  hello_world = 'Hello world!';
+  press_key = 'Press any key to continue!';
+
+
+var
+  win : pWINDOW;
+begin
+  setlocale(LC_ALL, '');
+
+  try
+    initscr();
+    start_color;
+    noecho;
+    win:= newwin ( 10, COLS - 20, 5, 10);
+
+    init_pair(1,COLOR_WHITE,COLOR_BLUE);
+    init_pair(2,COLOR_RED,COLOR_BLUE);
+    wbkgd(win, COLOR_PAIR(1));
+    erase;
+    refresh;
+
+    box(win, ACS_VLINE, ACS_HLINE);
+    wrefresh(win);
+    mvwaddstr(win,1,3, curses_version);
+
+    TranslateResourcestrings('%s/messages.mo');
+    wattron(win,A_BLINK OR A_BOLD OR COLOR_PAIR(2));
+    mvwaddstr(win,3,3, PChar(hello_world));
+    wattroff(win,A_BLINK OR A_BOLD OR COLOR_PAIR(2));
+    mvwaddstr(win,5,3, PChar(press_key));
+    wrefresh(win);
+    getch();
+  finally
+    endwin();
+  end;
+end.