pax_global_header00006660000000000000000000000064143622724660014526gustar00rootroot0000000000000052 comment=184b60f30e6fb20d443d8912ed916cb9a576ed6c curses-1.0.11/000077500000000000000000000000001436227246600131125ustar00rootroot00000000000000curses-1.0.11/.github/000077500000000000000000000000001436227246600144525ustar00rootroot00000000000000curses-1.0.11/.github/workflows/000077500000000000000000000000001436227246600165075ustar00rootroot00000000000000curses-1.0.11/.github/workflows/workflow.yml000066400000000000000000000013171436227246600211060ustar00rootroot00000000000000name: build on Mac/Linux on: pull_request: push: schedule: # Prime the caches every Monday - cron: 0 1 * * MON jobs: build: strategy: fail-fast: false matrix: os: - macos-latest - ubuntu-latest # - windows-latest ocaml-compiler: - 4.12.0 runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v2 - name: Use OCaml ${{ matrix.ocaml-version }} uses: ocaml/setup-ocaml@v2 with: ocaml-version: ${{ matrix.ocaml-version }} - run: opam install . --deps-only --with-test - run: opam exec -- dune build - run: opam exec -- dune runtest curses-1.0.11/.gitignore000066400000000000000000000000341436227246600150770ustar00rootroot00000000000000*~ .merlin _build *.install curses-1.0.11/.ocamlformat000066400000000000000000000030331436227246600154160ustar00rootroot00000000000000profile=janestreet quiet=false max-iters=10 comment-check=true wrap-fun-args=false wrap-comments=false type-decl-indent=2 type-decl=sparse stritem-extension-indent=0 space-around-variants=true space-around-records=true space-around-lists=true space-around-arrays=true single-case=sparse sequence-style=terminator sequence-blank-line=compact parse-docstrings=false parens-tuple-patterns=multi-line-only parens-tuple=multi-line-only parens-ite=true ocp-indent-compat=true nested-match=wrap module-item-spacing=compact max-indent=68 match-indent-nested=never match-indent=0 margin=100 let-module=sparse let-binding-spacing=compact let-binding-indent=2 let-and=sparse leading-nested-match-parens=true infix-precedence=parens indicate-nested-or-patterns=unsafe-no indicate-multiline-delimiters=no indent-after-in=0 if-then-else=keyword-first function-indent-nested=never function-indent=2 field-space=loose extension-indent=2 exp-grouping=parens dock-collection-brackets=false doc-comments-tag-only=fit doc-comments-padding=1 doc-comments=before disambiguate-non-breaking-match=false disable=false cases-matching-exp-indent=normal cases-exp-indent=2 break-struct=force break-string-literals=auto break-sequences=true break-separators=after break-infix-before-func=true break-infix=fit-or-vertical break-fun-sig=fit-or-vertical break-fun-decl=fit-or-vertical break-collection-expressions=fit-or-vertical break-cases=fit-or-vertical break-before-in=fit-or-vertical assignment-operator=begin-line align-variants-decl=false align-constructors-decl=false align-cases=false curses-1.0.11/CHANGES.md000066400000000000000000000036451436227246600145140ustar00rootroot00000000000000unreleased ===== * Don't hard-code gcc, use cc instead. Thanks @atupone for PR #7 * Remove Windows builds from Github workflow, too difficult to diagnose right now; Mac and Linux remain * Add missing dependency on Unix #8 (Thanks @dra27) * Add a test bin * Fix up for OCaml 5.0.0. Thanks @rrbq for #9 * Make it possible to vendor this package. Thanks @gridbugs for #10 1.0.10 (2021-11-21) ===== * Updated to dune-lang 2.7, so that we don't have that generated .opam file bug anymore. * Fixed build on Arch Linux, issue #4 * Fixed discover.ml to more durably locate curses.h headers * Fixed build for Windows * Added Github Workflow for CI build on Mac/Windows/Linux (uses ocaml-setup) * Ran ocamlformat 1.0.9 (2021-10-12) ===== * Convert to dune. Thanks to Olaf Hering for doing most of this! * Dead code in tmk/ and other junk files removed. 1.0.8 (2021-09-21) ===== * Makefile still had VERSION = 1.0.4 the whole time. Fix it with a new release. 1.0.7 ===== * 1.0.6 (2020-02-22) ===== * Fix segfault bug in delscreen (thanks to Shang Tsung for the report!) 1.0.5 (2020-01-24) ===== * Move project to github.com/mbacarella/curses * Install *.cmx files to LIBDIR so that dune doesn't warn about projects that build against curses. 1.0.4 (2018-11-20) ===== * Update configure script for ncurses 6.1 (Paul Pelzl). * Use CFLAGS from ./configure. * Enable debugging for all builds. * Allow compilation against PDCurses on Windows. 1.0.3 (2008-11-17) ===== * get*yx now return coordinates in the right order (thanks Brian Campbell). * Fix possible segfault with get_ripoff (thanks Brian Campbell). * Indicate that we should link with the curses library (thanks Jeff Meister). 1.0.2 (2007-10-09) ===== * Started to add documentation in curses.mli. * Using OCamlMakefile for the makefile, now handles bytecode-only compilation. * Libraries are now named curses.cm(x)a. 1.0.1 (2007-08-25) ===== * Initial release. curses-1.0.11/COPYING000066400000000000000000000634761436227246600141650ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! curses-1.0.11/README.md000066400000000000000000000024241436227246600143730ustar00rootroot00000000000000![example workflow](https://github.com/mbacarella/curses/actions/workflows/workflow.yml/badge.svg) Bindings to curses/ncurses ==== Tools for building terminal-based user interfaces. Overview --- OCaml Curses is a project to provide curses / ncurses bindings for the Objective Caml language. It was formally known as Text Mode Kit (TMK), but the TMK part of the project is not supported anymore, and instead we are just concentrating on providing reliable OCaml curses bindings. The author of TMK and the original version of the bindings was Nicolas George. OCaml Curses is free software, under the terms of the GNU Lesser General Public License. Downloads --- You can try `opam install curses` If you're using a dune project, you can also git clone this repo into a sub-directory and simply list `curses` in a `libraries` stanza. Documentation --- You can [browse the documentation](https://www.nongnu.org/ocaml-tmk/doc/) generated by ocamldoc. Bug reports and contributions --- Report issues to this github project's issue tracker, or email me directly, michael.bacarella@gmail.com. Feel free to send me pull requests as well! History --- This is a fork of the now unmaintained ocaml-twk package at https://www.nongnu.org/ocaml-tmk/ See [CHANGES.md](CHANGES.md) for change history. curses-1.0.11/_curses.ml000066400000000000000000000117111436227246600151100ustar00rootroot00000000000000(*pp gcc -x c -E *) type window type screen type terminal type chtype = int type attr_t = int type err = bool #define quote(a) #a #define ML0(f,tr) \ external f : unit -> tr = quote(mlcurses_##f) #define ML1(f,tr,ta) \ external f : ta -> tr = quote(mlcurses_##f) #define ML2(f,tr,ta,tb) \ external f : ta -> tb -> tr = quote(mlcurses_##f) #define ML3(f,tr,ta,tb,tc) \ external f : ta -> tb -> tc -> tr = quote(mlcurses_##f) #define ML4(f,tr,ta,tb,tc,td) \ external f : ta -> tb -> tc -> td -> tr = quote(mlcurses_##f) #define ML5(f,tr,ta,tb,tc,td,te) \ external f : ta -> tb -> tc -> td -> te -> tr = quote(mlcurses_##f) #define ML6(f,tr,ta,tb,tc,td,te,tf) \ external f : ta -> tb -> tc -> td -> te -> tf -> tr \ = quote(mlcurses_##f##_bytecode) quote(mlcurses_##f##_native) #define ML7(f,tr,ta,tb,tc,td,te,tf,tg) \ external f : ta -> tb -> tc -> td -> te -> tf -> tg -> tr \ = quote(mlcurses_##f##_bytecode) quote(mlcurses_##f##_native) #define ML8(f,tr,ta,tb,tc,td,te,tf,tg,th) \ external f : ta -> tb -> tc -> td -> te -> tf -> tg -> th -> tr \ = quote(mlcurses_##f##_bytecode) quote(mlcurses_##f##_native) #define ML9(f,tr,ta,tb,tc,td,te,tf,tg,th,ti) \ external f : ta -> tb -> tc -> td -> te -> tf -> tg -> th -> ti -> tr \ = quote(mlcurses_##f##_bytecode) quote(mlcurses_##f##_native) #define ML0d(f,tr) ML0(f,tr) #define ML1d(f,tr,ta) ML1(f,tr,ta) #define ML2d(f,tr,ta,tb) ML2(f,tr,ta,tb) #define ML3d(f,tr,ta,tb,tc) ML3(f,tr,ta,tb,tc) #define ML4d(f,tr,ta,tb,tc,td) ML4(f,tr,ta,tb,tc,td) #define ML5d(f,tr,ta,tb,tc,td,te) ML5(f,tr,ta,tb,tc,td,te) #define ML6d(f,tr,ta,tb,tc,td,te,tf) ML6(f,tr,ta,tb,tc,td,te,tf) #define ML0_notimpl(f,tr) ML0(f,tr) #define ML1_notimpl(f,tr,ta) ML1(f,tr,ta) #define ML2_notimpl(f,tr,ta,tb) ML2(f,tr,ta,tb) #define BEG (* #define BEG0 BEG #define BEG1 BEG #define BEG2 BEG #define BEG3 BEG #define BEG4 BEG #define BEG5 BEG #define BEG6 BEG #define BEG7 BEG #define BEG8 BEG #define BEG9 BEG #define END *) module Acs = struct type acs = { ulcorner: chtype; llcorner: chtype; urcorner: chtype; lrcorner: chtype; ltee: chtype; rtee: chtype; btee: chtype; ttee: chtype; hline: chtype; vline: chtype; plus: chtype; s1: chtype; s9: chtype; diamond: chtype; ckboard: chtype; degree: chtype; plminus: chtype; bullet: chtype; larrow: chtype; rarrow: chtype; darrow: chtype; uarrow: chtype; board: chtype; lantern: chtype; block: chtype; s3: chtype; s7: chtype; lequal: chtype; gequal: chtype; pi: chtype; nequal: chtype; sterling: chtype } let bssb a = a.ulcorner let ssbb a = a.llcorner let bbss a = a.urcorner let sbbs a = a.lrcorner let sbss a = a.rtee let sssb a = a.ltee let ssbs a = a.btee let bsss a = a.ttee let bsbs a = a.hline let sbsb a = a.vline let ssss a = a.plus end #include "_functions.c" (* these two were written separately in ml_curses.c, * to permit proper threading behavior *) ML0(getch,int) ML1(wgetch,int,window) let null_window = null_window () let bool_terminfo_variables = Hashtbl.create 67 let num_terminfo_variables = Hashtbl.create 67 let str_terminfo_variables = Hashtbl.create 601 let () = let rec ins f h n = let (a, b, c) = f n in if a = "" then () else ( Hashtbl.add h c (a, b); ins f h (n + 1) ) in (* These functions do not exist on all curses implementations, * so if they throw Invalid_argument, just ignore it. *) try ins bool_terminfo_variable bool_terminfo_variables 0; ins num_terminfo_variable num_terminfo_variables 0; ins str_terminfo_variable str_terminfo_variables 0 with Invalid_argument _ -> () /* (* Bon, je vais recopier les constantes directement, parceque je n'ai * aucune idée de comment générer ça automatiquement proprement. Si ça ne * marche pas chez vous, il vous suffit de regarder l'include, et de * corriger à la main. Faites-le moi savoir, à tout hasard... *) */ module A = struct let normal = 0 let attributes = 0x7FFFFF00 let chartext = 0x000000FF let color = 0x0000FF00 let standout = 0x00010000 let underline = 0x00020000 let reverse = 0x00040000 let blink = 0x00080000 let dim = 0x00100000 let bold = 0x00200000 let altcharset = 0x00400000 let invis = 0x00800000 let protect = 0x01000000 let horizontal = 0x02000000 let left = 0x04000000 let low = 0x08000000 let right = 0x10000000 let top = 0x20000000 let vertical = 0x40000000 let combine = List.fold_left (lor) 0 let color_pair n = (n lsl 8) land color let pair_number a = (a land color) lsr 8 end (*/* Je sais, c'est moche, mais ça marche */*) module WA = A module Color = struct let black = 0 let red = 1 let green = 2 let yellow = 3 let blue = 4 let magenta = 5 let cyan = 6 let white = 7 end module Key = struct #include "_keys.ml" let f n = f0 + n end module Curses_config = struct #include "_config.ml" end curses-1.0.11/curses.mli000066400000000000000000000525261436227246600151330ustar00rootroot00000000000000(** * Bindings to the ncurses library. * * Beware, all coordinates are passed [y] first, then [x]. * * Functions whose name start with a "w" take as first argument the window the * function applies to. * Functions whose name start with "mv" take as first two arguments the * coordinates [y] and [x] of the point to move the cursor to. For example * [mvaddch y x ch] is the same as [move y x; addch ch]. *) (** Windows. *) type window (** Screens. *) type screen (** Terminals. *) type terminal (** Characters. Usual characters can be converted from/to [chtype] using * [char_of_int] and [int_of_char]. See also [get_acs_codes] for characters * useful for drawing and the [Key] module for special input characters. *) type chtype = int (** Attributes are [lor]ings of flags which are defined in the [A] module. *) type attr_t = int (** A return value. [false] means that an error occured. *) type err = bool (** {2 Initialization functions} *) (** Initialize the curses library. *) val initscr : unit -> window (** Restore the terminal (should be called before exiting). *) val endwin : unit -> unit (** Has [endwin] been called without any subsequent call to [werefresh]? *) val isendwin : unit -> bool (** Create a new terminal. *) val newterm : string -> Unix.file_descr -> Unix.file_descr -> screen (** Switch terminal. *) val set_term : screen -> unit (** Delete a screen. *) val delscreen : screen -> unit val stdscr : unit -> window (** {2 Cursor} *) (** Get the current cursor position. *) val getyx : window -> int * int val getparyx : window -> int * int val getbegyx : window -> int * int val getmaxyx : window -> int * int (** Move the cursor. *) val move : int -> int -> err val wmove : window -> int -> int -> err (** {2 Operations on characters} *) (** Predefined characters. *) module Acs : sig type acs = { ulcorner : chtype; (** Upper left-hand corner (+). *) llcorner : chtype; (** Lower left-hand corner (+). *) urcorner : chtype; (** Upper right-hand corner (+). *) lrcorner : chtype; (** Lower right-hand corner (+). *) ltee : chtype; (** Left tee (+). *) rtee : chtype; (** Tight tee (+). *) btee : chtype; ttee : chtype; hline : chtype; (** Horizontal line (-). *) vline : chtype; (** Vertical line (|). *) plus : chtype; (** Plus (+). *) s1 : chtype; (** Scan line 1 (-). *) s9 : chtype; (** Scan line 9 (_). *) diamond : chtype; (** Diamond (+). *) ckboard : chtype; degree : chtype; (** Degree symbol ('). *) plminus : chtype; (** Plus/minus (#). *) bullet : chtype; larrow : chtype; (** Arrow pointing left (<). *) rarrow : chtype; (** Arrow pointing right (>). *) darrow : chtype; uarrow : chtype; (** Arrow pointing up (^). *) board : chtype; lantern : chtype; block : chtype; (** Solid square block (#). *) s3 : chtype; (** Scan line 3 (-). *) s7 : chtype; (** Scan line 7 (-). *) lequal : chtype; (** Less-than-or-equal-to (<). *) gequal : chtype; (** Greater-or-equal-to (>). *) pi : chtype; (** Greek pi ( * ). *) nequal : chtype; (** Not-equal (!). *) sterling : chtype; (** Pound-Sterling symbol (f). *) } val bssb : acs -> chtype val ssbb : acs -> chtype val bbss : acs -> chtype val sbbs : acs -> chtype val sbss : acs -> chtype val sssb : acs -> chtype val ssbs : acs -> chtype val bsss : acs -> chtype val bsbs : acs -> chtype val sbsb : acs -> chtype val ssss : acs -> chtype end (** Get the predefined characters. *) val get_acs_codes : unit -> Acs.acs (** {3 Displaying characters} *) (** Add a character at the current position, then advance the cursor. *) val addch : chtype -> err val waddch : window -> chtype -> err val mvaddch : int -> int -> chtype -> err val mvwaddch : window -> int -> int -> chtype -> err (** [echochar ch] is equivalent to [addch ch] followed by [refresh ()]. *) val echochar : chtype -> err val wechochar : window -> chtype -> err (** Add a sequence of characters at the current position. See also [addstr]. *) val addchstr : chtype array -> err val waddchstr : window -> chtype array -> err val mvaddchstr : int -> int -> chtype array -> err val mvwaddchstr : window -> int -> int -> chtype array -> err val addchnstr : chtype array -> int -> int -> err val waddchnstr : window -> chtype array -> int -> int -> err val mvaddchnstr : int -> int -> chtype array -> int -> int -> err val mvwaddchnstr : window -> int -> int -> chtype array -> int -> int -> err (** Add a string at the current position. *) val addstr : string -> err val waddstr : window -> string -> err val mvaddstr : int -> int -> string -> err val mvwaddstr : window -> int -> int -> string -> err val addnstr : string -> int -> int -> err val waddnstr : window -> string -> int -> int -> err val mvaddnstr : int -> int -> string -> int -> int -> err val mvwaddnstr : window -> int -> int -> string -> int -> int -> err (** Insert a character before cursor. *) val insch : chtype -> err val winsch : window -> chtype -> err val mvinsch : int -> int -> chtype -> err val mvwinsch : window -> int -> int -> chtype -> err (** Insert a string before cursor. *) val insstr : string -> err val winsstr : window -> string -> err val mvinsstr : int -> int -> string -> err val mvwinsstr : window -> int -> int -> string -> err val insnstr : string -> int -> int -> err val winsnstr : window -> string -> int -> int -> err val mvinsnstr : int -> int -> string -> int -> int -> err val mvwinsnstr : window -> int -> int -> string -> int -> int -> err (** Delete a character. *) val delch : unit -> err val wdelch : window -> err val mvdelch : int -> int -> err val mvwdelch : window -> int -> int -> err (** {3 Attributes} *) (** Attributes. *) module A : sig (** Normal display (no highlight). *) val normal : int val attributes : int (** Bit-mask to extract a character. *) val chartext : int val color : int (** Best highlighting mode of the terminal. *) val standout : int (** Underlining. *) val underline : int (** Reverse video. *) val reverse : int (** Blinking. *) val blink : int (** Half bright. *) val dim : int (** Extra bright or bold. *) val bold : int (** Alternate character set. *) val altcharset : int (** Invisible or blank mode. *) val invis : int (** Protected mode. *) val protect : int val horizontal : int val left : int val low : int val right : int val top : int val vertical : int val combine : int list -> int (** Color-pair number [n]. *) val color_pair : int -> int (** Get the pair number associated with the [color_pair n] attribute. *) val pair_number : int -> int end (** New series of highlight attributes. *) module WA : sig (** Normal display (no highlight). *) val normal : int val attributes : int val chartext : int val color : int (** Best highlighting mode of the terminal. Same as [attron A.standout]. *) val standout : int (** Underlining. *) val underline : int (** Reverse video. *) val reverse : int (** Blinking. *) val blink : int (** Half bright. *) val dim : int (** Extra bright or bold. *) val bold : int (** Alternate character set. *) val altcharset : int val invis : int val protect : int val horizontal : int val left : int val low : int val right : int val top : int val vertical : int val combine : int list -> int val color_pair : int -> int val pair_number : int -> int end (** Turn off the attributes given in argument (see the [A] module). *) val attroff : int -> unit val wattroff : window -> int -> unit (** Turn on the attributes given in argument. *) val attron : int -> unit val wattron : window -> int -> unit (** Set the attributes. *) val attrset : int -> unit val wattrset : window -> int -> unit val standend : unit -> unit val wstandend : window -> unit val standout : unit -> unit val wstandout : window -> unit (** Turn off the attributes given in argument (see the [WA] module). *) val attr_off : attr_t -> unit val wattr_off : window -> attr_t -> unit val attr_on : attr_t -> unit val wattr_on : window -> attr_t -> unit val attr_set : attr_t -> int -> unit val wattr_set : window -> attr_t -> int -> unit (** [chgat n attr color] changes the attributes of [n] characters. *) val chgat : int -> attr_t -> int -> unit val wchgat : window -> int -> attr_t -> int -> unit val mvchgat : int -> int -> int -> attr_t -> int -> unit val mvwchgat : window -> int -> int -> int -> attr_t -> int -> unit (** Get the attributes of the caracter at current position. *) val inch : unit -> chtype val winch : window -> chtype val mvinch : int -> int -> chtype val mvwinch : window -> int -> int -> chtype (** Get the attributes of a sequence of characters. *) val inchstr : chtype array -> err val winchstr : window -> chtype array -> err val mvinchstr : int -> int -> chtype array -> err val mvwinchstr : window -> int -> int -> chtype array -> err val inchnstr : chtype array -> int -> int -> err val winchnstr : window -> chtype array -> int -> int -> err val mvinchnstr : int -> int -> chtype array -> int -> int -> err val mvwinchnstr : window -> int -> int -> chtype array -> int -> int -> err (** Get the attributes of a string. *) val instr : string -> err val winstr : window -> string -> err val mvinstr : int -> int -> string -> err val mvwinstr : window -> int -> int -> string -> err val innstr : string -> int -> int -> err val winnstr : window -> string -> int -> int -> err val mvinnstr : int -> int -> string -> int -> int -> err val mvwinnstr : window -> int -> int -> string -> int -> int -> err (** {3 Background} *) (** Set the background of the current character. *) val bkgdset : chtype -> unit val wbkgdset : window -> chtype -> unit (** Set the background of every character. *) val bkgd : chtype -> unit val wbkgd : window -> chtype -> unit (** Get the current background. *) val getbkgd : window -> chtype (** {3 Operations on lines} *) (** Delete a line. *) val deleteln : unit -> err val wdeleteln : window -> err (** [insdelln n] inserts [n] lines above the current line if [n] is positive or * deletes [-n] lines if [n] is negative. *) val insdelln : int -> err val winsdelln : window -> int -> err (** Insert a blank line above the current line. *) val insertln : unit -> err val winsertln : window -> err (** {3 Characters input} *) (** Special keys. *) module Key : sig val code_yes : int val min : int val break : int val down : int val up : int val left : int val right : int val home : int val backspace : int val f0 : int val dl : int val il : int val dc : int val ic : int val eic : int val clear : int val eos : int val eol : int val sf : int val sr : int val npage : int val ppage : int val stab : int val ctab : int val catab : int val enter : int val sreset : int val reset : int val print : int val ll : int val a1 : int val a3 : int val b2 : int val c1 : int val c3 : int val btab : int val beg : int val cancel : int val close : int val command : int val copy : int val create : int val end_ : int val exit : int val find : int val help : int val mark : int val message : int val move : int val next : int val open_ : int val options : int val previous : int val redo : int val reference : int val refresh : int val replace : int val restart : int val resume : int val save : int val sbeg : int val scancel : int val scommand : int val scopy : int val screate : int val sdc : int val sdl : int val select : int val send : int val seol : int val sexit : int val sfind : int val shelp : int val shome : int val sic : int val sleft : int val smessage : int val smove : int val snext : int val soptions : int val sprevious : int val sprint : int val sredo : int val sreplace : int val sright : int val srsume : int val ssave : int val ssuspend : int val sundo : int val suspend : int val undo : int val mouse : int val resize : int val max : int val f : int -> int end (** Read a character in a window. *) val getch : unit -> int val wgetch : window -> int val mvgetch : int -> int -> int val mvwgetch : window -> int -> int -> int val ungetch : int -> err (** Read a string in a window. *) val getstr : string -> err val wgetstr : window -> string -> err val mvgetstr : int -> int -> string -> err val mvwgetstr : window -> int -> int -> string -> err val getnstr : string -> int -> int -> err val wgetnstr : window -> string -> int -> int -> err val mvgetnstr : int -> int -> string -> int -> int -> err val mvwgetnstr : window -> int -> int -> string -> int -> int -> err (** {2 Windows} *) (** {3 Window manipulations} *) (** [newwin l c y x] create a new window with [l] lines, [c] columns. The upper * left-hand corner is at ([x],[y]). *) val newwin : int -> int -> int -> int -> window (** Delete a window. *) val delwin : window -> err (** Move a window. *) val mvwin : window -> int -> int -> err (** [subwin l c y x] create a subwindow with [l] lines and [c] columns at * screen-relative position ([x],[y]). *) val subwin : window -> int -> int -> int -> int -> window (** Same as [subwin] excepting that the position ([x],[y]) is relative to the * parent window. *) val derwin : window -> int -> int -> int -> int -> window (** Move a derived windw. *) val mvderwin : window -> int -> int -> err (** Duplicate a window. *) val dupwin : window -> window val wsyncup : window -> unit (** If [syncok] is called with [true] as second argument, [wsyncup] is called * automatically whenever there is a change in the window. *) val syncok : window -> bool -> err val wcursyncup : window -> unit val wsyncdown : window -> unit val winch_handler_on : unit -> unit val winch_handler_off : unit -> unit val get_size : unit -> int * int val get_size_fd : Unix.file_descr -> int * int val null_window : window (** {3 Refresh control} *) (** Refresh windows. *) val refresh : unit -> err val wrefresh : window -> err val wnoutrefresh : window -> err val doupdate : unit -> err val redrawwin : window -> err val wredrawln : window -> int -> int -> err val wresize : window -> int -> int -> err val resizeterm : int -> int -> err val scroll : window -> err val scrl : int -> err val wscrl : window -> int -> err val touchwin : window -> err val touchline : window -> int -> int -> err val untouchwin : window -> err val wtouchln : window -> int -> int -> bool -> err val is_linetouched : window -> int -> int val is_wintouched : window -> bool (** Clear a window. *) val erase : unit -> unit val werase : window -> unit val clear : unit -> unit val wclear : window -> unit val clrtobot : unit -> unit val wclrtobot : window -> unit val clrtoeol : unit -> unit val wclrtoeol : window -> unit (** {3 Overlapped windows} *) (** [overlay srcwin dstwin] overlays [srcwin] on top of [dstwin]. *) val overlay : window -> window -> err val overwrite : window -> window -> err val copywin : window -> window -> int -> int -> int -> int -> int -> int -> bool -> err (** {3 Decorations} *) (** Draw a box around the edges of a window. *) val border : chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> unit val wborder : window -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> unit (** Draw a box. *) val box : window -> chtype -> chtype -> unit (** Draw an horizontal line. *) val hline : chtype -> int -> unit val whline : window -> chtype -> int -> unit val mvhline : int -> int -> chtype -> int -> unit val mvwhline : window -> int -> int -> chtype -> int -> unit (** Draw a vertical line. *) val vline : chtype -> int -> unit val wvline : window -> chtype -> int -> unit val mvvline : int -> int -> chtype -> int -> unit val mvwvline : window -> int -> int -> chtype -> int -> unit (** {3 Pads} *) (** A pad is like a window except that it is not restricted by the screen size, * and is not necessarily associated with a particular part of the screen.*) (** Create a new pad. *) val newpad : int -> int -> window val subpad : window -> int -> int -> int -> int -> window val prefresh : window -> int -> int -> int -> int -> int -> int -> err val pnoutrefresh : window -> int -> int -> int -> int -> int -> int -> err val pechochar : window -> chtype -> err (** {2 Colors} *) (** Colors. *) module Color : sig val black : int val red : int val green : int val yellow : int val blue : int val magenta : int val cyan : int val white : int end val start_color : unit -> err val use_default_colors : unit -> err val init_pair : int -> int -> int -> err val init_color : int -> int -> int -> int -> err val has_colors : unit -> bool val can_change_color : unit -> bool val color_content : int -> int * int * int val pair_content : int -> int * int val colors : unit -> int val color_pairs : unit -> int (** {2 Input/output options} *) (** {3 Input options} *) (** Disable line buffering. *) val cbreak : unit -> err (** Similar to [cbreak] but with delay. *) val halfdelay : int -> err (** Enable line buffering (waits for characters until newline is typed). *) val nocbreak : unit -> err (** Don't echo typed characters. *) val echo : unit -> err (** Echo typed characters. *) val noecho : unit -> err val intrflush : window -> bool -> err val keypad : window -> bool -> err val meta : window -> bool -> err val nodelay : window -> bool -> err val raw : unit -> err val noraw : unit -> err val noqiflush : unit -> unit val qiflush : unit -> unit val notimeout : window -> bool -> err val timeout : int -> unit val wtimeout : window -> int -> unit val typeahead : Unix.file_descr -> err val notypeahead : unit -> err (** {3 Output options} *) (** If called with [true] as second argument, the next call to [wrefresh] with * this window will clear the streen completely and redraw the entire screen * from scratch. *) val clearok : window -> bool -> unit val idlok : window -> bool -> unit val idcok : window -> bool -> unit val immedok : window -> bool -> unit val leaveok : window -> bool -> unit val setscrreg : int -> int -> err val wsetscrreg : window -> int -> int -> err val scrollok : window -> bool -> unit val nl : unit -> unit val nonl : unit -> unit (** {2 Soft-label keys} *) (** Initialize soft labels. *) val slk_init : int -> err val slk_set : int -> string -> int -> err val slk_refresh : unit -> err val slk_noutrefresh : unit -> err val slk_label : int -> string val slk_clear : unit -> err val slk_restore : unit -> err val slk_touch : unit -> err val slk_attron : attr_t -> err val slk_attroff : attr_t -> err val slk_attrset : attr_t -> err (** {2 Mouse} *) (** Sets the mouse mask. *) val mousemask : int -> int * int (** {2 Misc} *) (** Ring a bell. *) val beep : unit -> err (** Flash the screen. *) val flash : unit -> err val unctrl : chtype -> string val keyname : int -> string val filter : unit -> unit val use_env : bool -> unit val putwin : window -> Unix.file_descr -> err val getwin : Unix.file_descr -> window val delay_output : int -> err val flushinp : unit -> unit (** {2 Screen manipulation} *) (** Dump the current screen to a file. *) val scr_dump : string -> err val scr_restore : string -> err val scr_init : string -> err val scr_set : string -> err (** {2 Terminal} *) (** Get the speed of a terminal (in bits per second). *) val baudrate : unit -> int (** Get user's current erase character. *) val erasechar : unit -> char (** Has the terminal insert- and delete-character capabilites? *) val has_ic : unit -> bool (** Has the terminal insert- and delete-line capabilites? *) val has_il : unit -> bool (** Get user's current line kill character. *) val killchar : unit -> char (** Get a description of the terminal. *) val longname : unit -> string val termattrs : unit -> attr_t val termname : unit -> string val tgetent : string -> bool val tgetflag : string -> bool val tgetnum : string -> int val tgetstr : string -> bool val tgoto : string -> int -> int -> string val setupterm : string -> Unix.file_descr -> err val setterm : string -> err val cur_term : unit -> terminal val set_curterm : terminal -> terminal val del_curterm : terminal -> err val restartterm : string -> Unix.file_descr -> err val putp : string -> err val vidattr : chtype -> err val mvcur : int -> int -> int -> int -> err val tigetflag : string -> bool val tigetnum : string -> int val tigetstr : string -> string val tputs : string -> int -> (char -> unit) -> err val vidputs : chtype -> (char -> unit) -> err val tparm : string -> int array -> string val bool_terminfo_variable : int -> string * string * string val num_terminfo_variable : int -> string * string * string val str_terminfo_variable : int -> string * string * string val bool_terminfo_variables : (string, string * string) Hashtbl.t val num_terminfo_variables : (string, string * string) Hashtbl.t val str_terminfo_variables : (string, string * string) Hashtbl.t (** {2 Low-level curses routines} *) (** Save the current terminal modes as the "program" state for use by the * [reser_prog_mod] and [reset_shell_mode] functions. *) val def_prog_mode : unit -> unit val def_shell_mode : unit -> unit val reset_prog_mode : unit -> unit val reset_shell_mode : unit -> unit val resetty : unit -> unit val savetty : unit -> unit val getsyx : unit -> int * int val setsyx : int -> int -> unit val curs_set : int -> err val napms : int -> unit val ripoffline : bool -> unit val get_ripoff : unit -> window * int (** {2 Configuration} *) module Curses_config : sig (** If [Curses] has been linked against a curses library with wide * character support, then [wide_ncurses] is [true]. *) val wide_ncurses : bool end curses-1.0.11/curses.opam000066400000000000000000000014241436227246600152750ustar00rootroot00000000000000# This file is generated by dune, edit dune-project instead opam-version: "2.0" synopsis: "Bindings to ncurses" description: "Tools for building terminal-based user interfaces" maintainer: ["Michael Bacarella "] authors: ["Nicolas George"] license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" homepage: "https://github.com/mbacarella/curses" bug-reports: "https://github.com/mbacarella/curses/issues" depends: [ "dune" {>= "2.7"} "conf-ncurses" "conf-pkg-config" "dune-configurator" "ocaml" {>= "4.02.0"} "odoc" {with-doc} ] build: [ ["dune" "subst"] {dev} [ "dune" "build" "-p" name "-j" jobs "@install" "@runtest" {with-test} "@doc" {with-doc} ] ] dev-repo: "git+https://github.com/mbacarella/curses.git" curses-1.0.11/discover.ml000066400000000000000000000024551436227246600152700ustar00rootroot00000000000000module C = Configurator.V1 let () = C.main ~name:"curses" (fun c -> let ml_file = "config.ml" in let ml_code = [ "let wide_ncurses = true" ] in C.Flags.write_lines ml_file ml_code; let stale_ncursesw : C.Pkg_config.package_conf = { libs = [ "-lncursesw" ]; cflags = [] } in let conf = match C.Pkg_config.get c with | None -> C.die "'pkg-config' missing" | Some pc -> (match C.Pkg_config.query pc ~package:"ncursesw" with | None -> stale_ncursesw | Some deps -> deps) in let config_h = match Sys.os_type with | "Unix" -> [ "#define CURSES_HEADER "; "#define CURSES_TERM_H "; "#define HAVE_TERMIOS_H 1"; "#define HAVE_SYS_IOCTL_H 1" ] | "Win32" | "Cygwin" -> [ "#define CURSES_HEADER "; "#define CURSES_TERM_H "; "#define HAVE_WINDOWS_H 1" ] | os -> failwith (Printf.sprintf "Sys.os_type: %s: unknown os type" os) in C.Flags.write_lines "_config.h" config_h; let extra_cflags = [ "-DHAVE_CONFIG_H" ] in C.Flags.write_sexp "c_flags.sexp" (List.append conf.cflags extra_cflags); C.Flags.write_sexp "c_library_flags.sexp" conf.libs) curses-1.0.11/dune000066400000000000000000000024311436227246600137700ustar00rootroot00000000000000(library (name curses) (public_name curses) (synopsis "OCaml bindings for ncursesw") (modules curses) (wrapped false) (foreign_stubs (language c) (names ml_curses) (flags (:include c_flags.sexp))) (libraries unix) (c_library_flags (:include c_library_flags.sexp))) (executable (name discover) (modules discover) (libraries dune.configurator)) (rule (copy functions.c _functions.c)) (rule (copy keys.ml _keys.ml)) (rule (copy config.ml _config.ml)) (rule (target ml_curses.h) (deps config.h) (action (with-stdout-to %{target} (echo "")))) (rule (copy _config.h config.h)) (rule (target curses.ml) (deps _curses.ml _config.ml _functions.c _keys.ml config.h) (action (chdir %{project_root} (with-stdout-to %{target} (system "%{cc} -x c -E _curses.ml"))))) (rule (targets c_flags.sexp c_library_flags.sexp config.ml _config.h) (deps (:discover discover.exe)) (action (run %{discover}))) ; 2021-10-13 mbac: test.ml isn't a real unit test, and it doesn't seem to ; run from the testing environment properly (because curses?) ; [dune exec ./test.exe] is fine though ;(test ; (name test) ; (modules test) ; (libraries curses) ; (action ; (run %{exe:test.exe}))) ; disable docstring warnings (env (dev (flags (:standard -w -50)))) curses-1.0.11/dune-project000066400000000000000000000007761436227246600154460ustar00rootroot00000000000000(lang dune 2.7) (name curses) (generate_opam_files true) (license "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception") (authors "Nicolas George") (maintainers "Michael Bacarella ") (homepage "https://github.com/mbacarella/curses") (source (github mbacarella/curses)) (package (name curses) (synopsis "Bindings to ncurses") (description "Tools for building terminal-based user interfaces") (depends conf-ncurses conf-pkg-config dune-configurator (ocaml (>= 4.02.0)))) curses-1.0.11/functions.c000066400000000000000000000475621436227246600153040ustar00rootroot00000000000000/* addch */ ML1(addch,err,chtype) ML2(waddch,err,window,chtype) ML3(mvaddch,err,int,int,chtype) ML4(mvwaddch,err,window,int,int,chtype) ML1(echochar,err,chtype) ML2(wechochar,err,window,chtype) /* addchstr */ #define copie(l,id,ar) int i,c=l,r; \ chtype *t=malloc((c+1)*sizeof(chtype)); \ if(t==NULL) caml_failwith("Out of memory"); \ for(i=0;i0); END ML1(tigetnum,int,string) ML1d(tigetstr,string,string) BEG1 char *s=tigetstr(a_string(aa)); if((s==NULL)||(s==(char * )-1)) caml_failwith("tigetstr"); CAMLreturn(caml_copy_string(s)); END ML3d(tputs,err,string,int,(char->unit)) BEG3 putc_function=ac; r_err(tputs(a_string(aa),a_int(ab),putc_callback)); END ML2d(vidputs,err,chtype,(char->unit)) BEG2 putc_function=ab; r_err(vidputs(a_chtype(aa),putc_callback)); END #ifdef PDCURSES /* RWMJ: PDCurses has a moronic definition of tparm where they * seem to be trying to implement varargs on their own. Prototype * a sensible definition instead, at the cost of a warning: */ static char *(*mlcurses_rpl_tparm) (const char *, ...) = (void *) tparm; #else #define mlcurses_rpl_tparm tparm #endif ML2d(tparm,string,string,int array) BEG2 int t[10],i,n=Wosize_val(ab); if(n>10) n=10; for(i=0;i #include #include #include #include #include #include /* For PDCurses we need to define the following so that global * variables are declared (in the header) with __dllspec(dllimport). */ #ifdef PDCURSES #define PDC_DLL_BUILD #undef CURSES_LIBRARY #endif #ifdef CURSES_HEADER #include CURSES_HEADER #else #include #endif #ifdef CURSES_TERM_H #include CURSES_TERM_H #else #include #endif #ifdef HAVE_WINDOWS_H #include #endif /* Du travail pour les esclaves de M$ */ #include #ifdef HAVE_TERMIOS_H #include #endif #ifdef HAVE_SYS_IOCTL_H #include #endif #define AWB(x) caml__dummy_##x=caml__dummy_##x; /* anti-warning bugware */ static value Val_window(WINDOW *w) { return caml_copy_nativeint((intnat) w); } static value Val_terminal(TERMINAL *t) { return caml_copy_nativeint((intnat) t); } static value Val_screen(SCREEN *s) { return caml_copy_nativeint((intnat) s); } #define Window_val(v) ((WINDOW *) Nativeint_val(v)) #define Terminal_val(v) ((TERMINAL *) Nativeint_val(v)) #define Screen_val(v) ((SCREEN *) Nativeint_val(v)) #define r_unit(f) f; CAMLreturn(Val_unit); #define r_window(f) CAMLreturn(Val_window(f)) #define r_terminal(f) CAMLreturn(Val_terminal(f)) #define r_err(f) CAMLreturn(Val_bool((f)!=ERR)) #define r_int(f) CAMLreturn(Val_int(f)) #define r_char(f) CAMLreturn(Val_int((f)&255)) #define r_chtype(f) CAMLreturn(Val_int(f)) #define r_attr_t(f) CAMLreturn(Val_int(f)) #define r_bool(f) CAMLreturn(Val_bool(f)) #define r_int_int(x,y) \ { CAMLlocal1(ret); AWB(ret); \ ret=caml_alloc_tuple(2); \ Store_field(ret,0,Val_int(x)); \ Store_field(ret,1,Val_int(y)); \ CAMLreturn(ret); } #define r_window_int(x,y) \ { CAMLlocal1(ret); AWB(ret); \ ret=caml_alloc_tuple(2); \ Store_field(ret,0,Val_window(x)); \ Store_field(ret,1,Val_int(y)); \ CAMLreturn(ret); } #define r_int_int_int(x,y,z) \ { CAMLlocal1(ret); AWB(ret); \ ret=caml_alloc_tuple(3); \ Store_field(ret,0,Val_int(x)); \ Store_field(ret,1,Val_int(y)); \ Store_field(ret,2,Val_int(z)); \ CAMLreturn(ret); } #define r_string(f) \ { const char *ret=f; \ if(ret==NULL) caml_failwith("Null pointer"); \ CAMLreturn(caml_copy_string(ret)); } #define a_window(a) Window_val(a) #define a_terminal(a) Terminal_val(a) #define a_screen(a) Screen_val(Field(a,2)) #define a_int(a) Int_val(a) #define a_bool(a) Bool_val(a) #define a_chtype(a) Int_val(a) #define a_attr_t(a) Int_val(a) #define a_string(a) Bytes_val(a) #define RA0 CAMLparam0(); #define RA1 CAMLparam1(aa); AWB(aa); #define RA2 CAMLparam2(aa,ab); AWB(aa); #define RA3 CAMLparam3(aa,ab,ac); AWB(aa); #define RA4 CAMLparam4(aa,ab,ac,ad); AWB(aa); #define RA5 CAMLparam5(aa,ab,ac,ad,ae); AWB(aa); #define RA6 CAMLparam5(aa,ab,ac,ad,ae); CAMLxparam1(af); AWB(aa); AWB(af); #define RA7 CAMLparam5(aa,ab,ac,ad,ae); CAMLxparam2(af,ag); AWB(aa); AWB(af); #define RA8 CAMLparam5(aa,ab,ac,ad,ae); CAMLxparam3(af,ag,ah); AWB(aa); AWB(af); #define RA9 CAMLparam5(aa,ab,ac,ad,ae); CAMLxparam4(af,ag,ah,ai); AWB(aa); AWB(af); #define ML0(f,tr) \ value mlcurses_##f(void) \ { RA0 r_##tr(f()); } #define ML1(f,tr,ta) \ value mlcurses_##f(value aa) \ { RA1 r_##tr(f(a_##ta(aa))); } #define ML2(f,tr,ta,tb) \ value mlcurses_##f(value aa,value ab) \ { RA2 r_##tr(f(a_##ta(aa),a_##tb(ab))); } #define ML3(f,tr,ta,tb,tc) \ value mlcurses_##f(value aa,value ab,value ac) \ { RA3 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac))); } #define ML4(f,tr,ta,tb,tc,td) \ value mlcurses_##f(value aa,value ab,value ac,value ad) \ { RA4 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac),a_##td(ad))); } #define ML5(f,tr,ta,tb,tc,td,te) \ value mlcurses_##f(value aa,value ab,value ac,value ad,value ae) \ { RA5 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac),a_##td(ad),a_##te(ae))); } #define ML7(f,tr,ta,tb,tc,td,te,tf,tg) \ value mlcurses_##f##_bytecode(value *a,int n) \ { RA0 r_##tr(f(a_##ta(a[0]),a_##tb(a[1]),a_##tc(a[2]),a_##td(a[3]), \ a_##te(a[4]),a_##tf(a[5]),a_##tg(a[6]))); } \ value mlcurses_##f##_native(value aa,value ab,value ac,value ad, \ value ae,value af,value ag) \ { RA7 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac),a_##td(ad), \ a_##te(ae),a_##tf(af),a_##tg(ag))); } #define ML8(f,tr,ta,tb,tc,td,te,tf,tg,th) \ value mlcurses_##f##_bytecode(value *a,int n) \ { RA0 r_##tr(f(a_##ta(a[0]),a_##tb(a[1]),a_##tc(a[2]),a_##td(a[3]), \ a_##te(a[4]),a_##tf(a[5]),a_##tg(a[6]),a_##th(a[7]))); } \ value mlcurses_##f##_native(value aa,value ab,value ac,value ad, \ value ae,value af,value ag,value ah) \ { RA8 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac),a_##td(ad), \ a_##te(ae),a_##tf(af),a_##tg(ag),a_##th(ah))); } #define ML9(f,tr,ta,tb,tc,td,te,tf,tg,th,ti) \ value mlcurses_##f##_bytecode(value *a,int n) \ { RA0 r_##tr(f(a_##ta(a[0]),a_##tb(a[1]),a_##tc(a[2]),a_##td(a[3]),a_##te(a[4]), \ a_##tf(a[5]),a_##tg(a[6]),a_##th(a[7]),a_##ti(a[8]))); } \ value mlcurses_##f##_native(value aa,value ab,value ac,value ad,value ae, \ value af,value ag,value ah,value ai) \ { RA9 r_##tr(f(a_##ta(aa),a_##tb(ab),a_##tc(ac),a_##td(ad),a_##te(ae), \ a_##tf(af),a_##tg(ag),a_##th(ah),a_##ti(ai))); } #define ML0d(f,tr) value mlcurses_##f(void) #define ML1d(f,tr,ta) value mlcurses_##f(value aa) #define ML2d(f,tr,ta,tb) value mlcurses_##f(value aa,value ab) #define ML3d(f,tr,ta,tb,tc) value mlcurses_##f(value aa,value ab,value ac) #define ML4d(f,tr,ta,tb,tc,td) value mlcurses_##f(value aa,value ab,\ value ac,value ad) #define ML5d(f,tr,ta,tb,tc,td,te) value mlcurses_##f(value aa,value ab,\ value ac,value ad,value ae) #define ML6d(f,tr,ta,tb,tc,td,te,tf) value mlcurses_##f##_native(value,value,\ value,value,value,value); \ value mlcurses_##f##_bytecode(value *a,int n) \ { return(mlcurses_##f##_native(a[0],a[1],a[2],a[3],a[4],a[5])); } \ value mlcurses_##f##_native(value aa,value ab,value ac,value ad,value ae,value af) #define BEG0 { RA0 { #define BEG1 { RA1 { #define BEG2 { RA2 { #define BEG3 { RA3 { #define BEG4 { RA4 { #define BEG5 { RA5 { #define BEG6 { RA6 { #define BEG7 { RA7 { #define BEG8 { RA8 { #define BEG9 { RA9 { #define END }} /* RWMJ: Not implemented functions raise Invalid_argument * ("function_name"). This can happen for example when we are not * linked to real ncurses, particularly on Windows. */ #define ML0_notimpl(f,tr) \ value mlcurses_##f(void) BEG0 caml_invalid_argument (#f); CAMLnoreturn; END #define ML1_notimpl(f,tr,ta) \ value mlcurses_##f(value aa) BEG1 caml_invalid_argument (#f); CAMLnoreturn; END #define ML2_notimpl(f,tr,ta,tb) \ value mlcurses_##f(value aa, value ab) BEG2 caml_invalid_argument (#f); CAMLnoreturn; END static WINDOW *ripoff_w[5]; static int ripoff_l[5]; static int ripoff_niv=0; static int ripoff_callback(WINDOW *w,int l) { if(ripoff_niv==5) return(0); ripoff_w[ripoff_niv]=w; ripoff_l[ripoff_niv]=l; ripoff_niv++; return(0); } value putc_function; static int putc_callback(int c) { CAMLparam0(); CAMLlocal1(ret); AWB(ret); ret=caml_callback_exn(putc_function,Val_int(c&255)); CAMLreturn(Is_exception_result(ret)?-1:0); } #ifndef WIN32 /* Du travail pour les esclaves de M$ */ static void winch_handler(int n) { signal(n,winch_handler); ungetch(KEY_RESIZE); } #endif #include "functions.c" #include "caml/signals.h" /* The following routines are special-cased to allow other threads to run * while getch() is blocking */ value mlcurses_getch(void) { CAMLparam0(); int ch; caml_enter_blocking_section(); ch = getch(); caml_leave_blocking_section(); CAMLreturn(Val_int(ch)); } value mlcurses_wgetch(value win) { CAMLparam1(win); int ch; WINDOW* w; caml__dummy_win = caml__dummy_win; w = Window_val(win); caml_enter_blocking_section(); ch = wgetch(w); caml_leave_blocking_section(); CAMLreturn(Val_int(ch)); } curses-1.0.11/test.ml000066400000000000000000000045131436227246600144260ustar00rootroot00000000000000open Curses let () = ripoffline true let w = initscr () let wd, ncol = get_ripoff () (*let () = assert (start_color ()) let () = assert (init_pair 1 Color.red Color.white)*) let () = assert (cbreak ()) let () = assert (noecho ()) let () = assert (intrflush w false) let () = assert (keypad w true) let () = for i = 0 to 10 do assert (mvaddch i (i * 2) (A.color_pair 1 + 111)) done let () = border 0 0 0 0 0 0 0 0 let () = wborder w 0 0 0 0 0 0 0 0 let () = assert (refresh ()) let c1, c2 = mousemask (-1) let () = assert (mvaddstr 3 1 "Bonjour") let () = assert (mvaddstr 4 2 (string_of_int c1)) let () = assert (mvaddstr 5 2 (string_of_int c2)) let t = Array.init 50 (fun x -> 64 + x) let () = assert (addchnstr t 10 3) let () = assert (mvaddnstr 8 40 "Bonjour" 1 3) let () = assert (mvinsstr 8 40 "toto ") let t = [| 0; 0; 0; 0 |] let () = assert (inchnstr t 0 3) let[@warning "-52"] () = try winch_handler_on () with | Invalid_argument "winch_handler_on" -> () let[@warning "-52"] () = try let kup = tigetstr "kcuu1" in assert (addstr kup) with | Failure "tigetstr" -> () let acs = get_acs_codes () let () = assert (addch acs.Acs.ulcorner) let i = getch () let nc, np, can = colors (), color_pairs (), can_change_color () let c1, c2 = pair_content 1 let l = ref [] let () = assert (tputs "totoping" 1 (fun c -> l := int_of_char c :: !l)) let tr, tc = get_size () let () = endwin () let () = Array.iter (fun x -> print_int x; print_newline ()) t let () = print_string "key="; print_int i; print_newline () let () = print_int tr; print_string " "; print_int tc; print_newline () let () = print_int nc; print_string " " let () = print_int np; print_string " " let () = print_string (if can then "oui" else "non"); print_newline () let () = print_int c1; print_string " " let () = print_int c2; print_newline () let () = print_int ncol; print_newline () let () = List.iter (fun x -> print_int x; print_string " ") !l; print_newline () (*let i = ref 0 let () = while let (a, b, c) = str_terminfo_variable !i in (a <> "") && (print_string (a ^ "\t" ^ b ^ "\t" ^ c); print_newline (); true) do i := !i + 1 done*) (*let () = Hashtbl.iter (fun a (b,c) -> print_string (a ^ "\t" ^ b ^ "\t" ^ c); print_newline ()) str_terminfo_variables*) curses-1.0.11/test/000077500000000000000000000000001436227246600140715ustar00rootroot00000000000000curses-1.0.11/test/dune000066400000000000000000000000561436227246600147500ustar00rootroot00000000000000(executable (name test) (libraries curses)) curses-1.0.11/test/test.ml000066400000000000000000000022771436227246600154120ustar00rootroot00000000000000type t = { wfoo : Curses.window; wbar : Curses.window; wbazzes : Curses.window; wsnoos : Curses.window } let init title = (* init *) let _window = Curses.initscr () in assert (Curses.start_color ()); (* set title *) Curses.attron Curses.A.bold; assert (Curses.addstr title); Curses.attroff Curses.A.bold; assert (Curses.refresh ()); (* create windows *) let wfoo = Curses.newwin 1 80 1 0 in let wbar = Curses.newwin 3 80 2 0 in let wbazzes = Curses.newwin 3 80 5 0 in let wsnoos = Curses.newwin 10 80 8 0 in let demo_window win str = Curses.box win 0 0; assert (Curses.waddstr win str); assert (Curses.wrefresh win) in demo_window wfoo "foos"; demo_window wbar "bars"; demo_window wbazzes "bazzes"; demo_window wsnoos "snoos"; let wsnoos_left = Curses.derwin wsnoos 6 38 2 2 in let wsnoos_right = Curses.derwin wsnoos 6 30 2 44 in demo_window wsnoos_left "left side\nfoobar\n"; assert (Curses.waddstr wsnoos_left "third\n"); assert (Curses.wrefresh wsnoos_left); demo_window wsnoos_right "right side"; { wfoo; wbar; wbazzes; wsnoos } let () = let _t = init "the title" in ignore (Curses.getch () : int); Curses.endwin (); ()