Skip to content

Commits on Source 6

_build/
/lambda-term-*.tar.gz
/setup.data
/setup.log
/setup.exe
/setup-dev.exe
/man/*.gz
/src/lTerm_config.h
*.swp
*.native
/lambda-term-api.docdir
*~
*.merlin
*.install
S src/
S src/widget_impl/
S examples/
B _build/src
B _build/src/widget_impl/
B _build/examples
PKG lwt
PKG lwt.unix
PKG lwt.react
PKG zed
EXT lwt
language: c
sudo: required
install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
script: bash -ex .travis-opam.sh
env:
- OCAML_VERSION=4.02
- OCAML_VERSION=4.03
- OCAML_VERSION=4.04
- OCAML_VERSION=4.05
- OCAML_VERSION=4.06
- OCAML_VERSION=4.07
os:
- linux
- osx
2.0.2 (2019-08-09)
------------------
LTerm\_history: catch and log `Zed_string.Invalid` exception
2.0.1 (2019-06-17)
------------------
* fix windows build (@db4, #72)
* expand zchar before writing to windows console (@kandu, #75)
2.0 (2019-05-17)
----------------
### Breaking
* LTerm\_draw: type `point` is redefined to use `Zed_char.t` as the essential element to support wide, combined glyph
* functions and methods: change parameter type from `UChar.t` or `Zed_utf8.t` to `Zed_char.t` or `Zed_string.t`
* LTerm\_text
* function `of_string` is renamed to `of_utf8`
* function `of_string_maybe_invalid` is renamed to `of_utf8_maybe_invalid`
* the new `of_string` function is of type `Zed_string.t -> t`
* the new `of_string_maybe_invalid` function is of type `Zed_string.t -> t`
### General
* depend on zed 2
* Lterm\_draw, LTerm\_widget, LTerm\_read\_line refactored to support wide, combined glyphs
* add name to dune-project (Hannes Mehnert, #70)
* port to dune (Jérémie Dimino, #69)
* README: Add Travis badge (Kevin Ji, #66)
* Add travis config (Anurag Soni, #65)
* opam: update homepage, bug-reports and dev-repo fields (Jérémie Dimino)
1.13 (2018-06-01)
-----------------
* Make lambda-term compatible with Lwt 4 and Camomile 1 (#63,
@ncihnegn)
1.12 (2017-11-05)
-----------------
* Fix: copy & pasting the terminal output doesn't adds many spaces
after the end of lines (#52, Deokhwan Kim, fixes diml/utop#186)
* -safe-string compatibility (#54)
1.11 (2017-04-04)
-----------------
* Add history-search-prev and history-search-next (#47, Fabian Hemmer)
* Allow frame widgets to be labeled (#36, Andrew Ray)
* Add an alignment setting to label widgets (#36, Andrew Ray)
* Add scrollbar widgets (#33, Andrew Ray)
* Improve the `lambda-term-inputrc.5` man page (#41, Léon van Velzen)
* Allow editor widgets to request a specific size and add a "double
editor" example (#42, Fabian Bonk)
* Add `^` to the list of characters recognized in inputrc files (#46,
github user zhenya1007)
* Switch the build to jbuilder
* Drop compatibility with 4.01
1.10.1 (2016-08-15)
-------------------
......
# Makefile
# --------
# Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org>
# Licence : BSD3
#
# Generic Makefile for oasis project
INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)
# Set to setup.exe for the release
SETUP := setup.exe
.PHONY: all
all:
dune build @install @examples/all
# Default rule
default: build
.PHONY: examples
examples:
dune build @examples/all
# Setup for the development version
setup-dev.exe: _oasis setup.ml
sed '/^#/D' setup.ml > setup_dev.ml
ocamlfind ocamlopt -o $@ -linkpkg -package ocamlbuild,oasis.dynrun setup_dev.ml || \
ocamlfind ocamlc -o $@ -linkpkg -package ocamlbuild,oasis.dynrun setup_dev.ml || true
rm -f setup_dev.*
.PHONY: asciiart
asciiart:
dune build examples/asciiart/asciiart.exe
# Setup for the release
setup.exe: setup.ml
ocamlopt.opt -o $@ $< || ocamlopt -o $@ $< || ocamlc -o $@ $<
rm -f setup.cmx setup.cmi setup.o setup.obj setup.cmo
.PHONY: install
install:
dune install $(INSTALL_ARGS)
build: $(SETUP) setup.data
./$(SETUP) -build $(BUILDFLAGS)
.PHONY: uninstall
uninstall:
dune uninstall $(INSTALL_ARGS)
doc: $(SETUP) setup.data build
./$(SETUP) -doc $(DOCFLAGS)
.PHONY: reinstall
reinstall:
$(MAKE) uninstall
$(MAKE) install
test: $(SETUP) setup.data build
./$(SETUP) -test $(TESTFLAGS)
.PHONY: test
test:
dune runtest
all: $(SETUP)
./$(SETUP) -all $(ALLFLAGS)
.PHONY: all-supported-ocaml-versions
all-supported-ocaml-versions:
dune build @install @examples/all @runtest --workspace dune-workspace.dev
install: $(SETUP) setup.data
ocamlfind remove lambda-term 2>/dev/null || true
./$(SETUP) -install $(INSTALLFLAGS)
uninstall: $(SETUP) setup.data
./$(SETUP) -uninstall $(UNINSTALLFLAGS)
reinstall: $(SETUP) setup.data
ocamlfind remove lambda-term 2>/dev/null || true
./$(SETUP) -reinstall $(REINSTALLFLAGS)
clean: $(SETUP)
./$(SETUP) -clean $(CLEANFLAGS)
distclean: $(SETUP)
./$(SETUP) -distclean $(DISTCLEANFLAGS)
configure: $(SETUP)
./$(SETUP) -configure $(CONFIGUREFLAGS)
setup.data: $(SETUP)
./$(SETUP) -configure $(CONFIGUREFLAGS)
.PHONY: default build doc test all install uninstall reinstall clean distclean configure
.PHONY: clean
clean:
dune clean
Lambda-Term
===========
[![Build Status](https://travis-ci.org/ocaml-community/lambda-term.svg?branch=master)](https://travis-ci.org/ocaml-community/lambda-term)
Lambda-Term is a cross-platform library for manipulating the
terminal. It provides an abstraction for keys, mouse events, colors,
as well as a set of widgets to write curses-like applications.
......@@ -13,42 +15,49 @@ a C library.
Lambda-Term integrates with zed to provide text edition facilities in
console applications.
Dependencies
------------
* [OCaml](http://caml.inria.fr/ocaml/) (>= 3.12)
* [findlib](http://projects.camlcity.org/projects/findlib.html)
* [react](http://erratique.ch/software/react)
* [lwt](http://ocsigen.org/lwt/) (>= 2.4.0) built with react support
* [Camomile](http://github.com/yoriyuki/Camomile) (>= 0.8)
* [zed](http://github.com/diml/zed) (>= 1.2)
For building the development version, you also need to install
[oasis](http://oasis.forge.ocamlcore.org/) (>= 0.3.0).
Installation
------------
To build and install Lambda-Term:
$ ./configure
$ make
$ make install
$ dune build
$ dune install
### Documentation and manual pages _(optional)_
Note that this will build Lambda-Term using the development build
profile which has strict compilation flags. If the build fails, try
passing `--profile=release` to `dune` or alternatively create a
`dune-workspace` file with the following contents:
(lang dune 1.1)
(profile release)
### HTML API Documentation _(optional)_
To build the documentation:
$ make doc
$ dune build @doc
It will then be installed by `make install`.
You can then consult it by openning
`_build/default/_doc/_html/index.html`.
### Tests _(optional)_
To build and execute tests:
$ ./configure --enable-tests
$ make test
$ dune runtest
### Examples _(optional)_
To build the examples:
$ dune build @examples
Binaries for the examples will be in `_build/default/examples`.
The `asciiart` example is not built by default as it as an additional
dependency on the `camlimages` library. To build it run:
$ dune build examples/asciiart/asciiart.exe
Terminal emulators compatibility
--------------------------------
......@@ -81,6 +90,19 @@ You can then send the result to jeremie@dimino.org, including:
* the contents of the `TERM` environment variable inside the terminal (`echo $TERM`),
* the output of `print_sequences.ml` with, for each line, the keystroke.
Key bindings
------------
Key bindings can be set in `~/.lambda-term-inputrc`. See
[lambda-term-inputrc](lambda-term-inputrc). Useful mappings:
```
# This allows zsh-like searching the history by pressing up/down
[read-line]
up: history-search-prev
down: history-search-next
```
Main modules
------------
......
# +-------------------------------------------------------------------+
# | Package parameters |
# +-------------------------------------------------------------------+
OASISFormat: 0.4
OCamlVersion: >= 3.12
Name: lambda-term
Version: 1.10.1
LicenseFile: LICENSE
License: BSD-3-CLAUSE
Authors: Jeremie Dimino
Maintainers: Jeremie Dimino <jeremie@dimino.org>
Homepage: http://lambda-term.forge.ocamlcore.org/
BuildTools: ocamlbuild
Plugins: DevFiles (0.4), META (0.4)
XDevFilesEnableMakefile: false
Synopsis: Terminal manipulation library for OCaml
Description:
Lambda-term is a cross-platform library for manipulating the
terminal. It provides an abstraction for keys, mouse events, colors,
as well as a set of widgets to write curses-like applications.
.
The main objective of lambda-term is to provide a higher level
functional interface to terminal manipulation than, for example,
ncurses, by providing a native OCaml interface instead of bindings to
a C library.
.
Lambda-term integrates with zed to provide text edition facilities in
console applications.
FilesAB: src/lTerm_config.h.ab
Flag examples
Description: build examples
Default: true
# +-------------------------------------------------------------------+
# | The library |
# +-------------------------------------------------------------------+
Library "lambda-term"
FindlibName: lambda-term
BuildDepends:
lwt (>= 2.4.0),
lwt.unix,
lwt.react,
zed (>= 1.2)
XMETADescription: Cross-platform library for terminal manipulation
Path: src
Install: true
Modules:
LTerm,
LTerm_key,
LTerm_event,
LTerm_unix,
LTerm_windows,
LTerm_style,
LTerm_geom,
LTerm_draw,
LTerm_mouse,
LTerm_widget,
LTerm_widget_callbacks,
LTerm_edit,
LTerm_read_line,
LTerm_text,
LTerm_ui,
LTerm_resources,
LTerm_inputrc,
LTerm_history
InternalModules:
LTerm_color_mappings,
LTerm_resource_lexer,
widget_impl/LTerm_widget_base_impl,
widget_impl/LTerm_buttons_impl,
widget_impl/LTerm_containers_impl,
widget_impl/LTerm_running_impl,
widget_impl/LTerm_toplevel_impl
CSources:
lTerm_config.h,
lTerm_term_stubs.c,
lTerm_unix_stubs.c,
lTerm_windows_stubs.c
CCOpt: -I$pkg_lwt
if system(openbsd)
CCOpt+: -I/usr/local/include
CCLib: -L/usr/local/lib -lcharset
# +-------------------------------------------------------------------+
# | Examples |
# +-------------------------------------------------------------------+
Executable events
Path: examples
Install: false
CompiledObject: best
MainIs: events.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable colors
Path: examples
Install: false
CompiledObject: best
MainIs: colors.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable colors_256
Path: examples
Install: false
CompiledObject: best
MainIs: colors_256.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable rgb
Path: examples
Install: false
CompiledObject: best
MainIs: rgb.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable move
Path: examples
Install: false
CompiledObject: best
MainIs: move.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable hello
Path: examples
Install: false
CompiledObject: best
MainIs: hello.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable clock
Path: examples
Install: false
CompiledObject: best
MainIs: clock.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable buttons
Path: examples
Install: false
CompiledObject: best
MainIs: buttons.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable focus
Path: examples
Install: false
CompiledObject: best
MainIs: focus.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable checkbuttons
Path: examples
Install: false
CompiledObject: best
MainIs: checkbuttons.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable radiobuttons
Path: examples
Install: false
CompiledObject: best
MainIs: radiobuttons.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable shell
Path: examples
Install: false
CompiledObject: best
MainIs: shell.ml
BuildDepends: lambda-term, str
Build$: flag(examples)
Executable repl
Path: examples
Install: false
CompiledObject: best
MainIs: repl.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable modal
Path: examples
Install: false
CompiledObject: best
MainIs: modal.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable "read-password"
Path: examples
Install: false
CompiledObject: best
MainIs: read_password.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable "read-yes-no"
Path: examples
Install: false
CompiledObject: best
MainIs: read_yes_no.ml
BuildDepends: lambda-term
Build$: flag(examples)
Executable "editor"
Path: examples
Install: false
CompiledObject: best
MainIs: editor.ml
BuildDepends: lambda-term
Build$: flag(examples)
# +-------------------------------------------------------------------+
# | Utils |
# +-------------------------------------------------------------------+
Executable "lambda-term-actions"
Path: tools
Install: true
CompiledObject: best
MainIs: lambda_term_actions.ml
BuildDepends: lambda-term
# +-------------------------------------------------------------------+
# | Tests |
# +-------------------------------------------------------------------+
Executable "history-stress-test"
Path: tests
Install: false
CompiledObject: best
MainIs: history_stress_test.ml
BuildDepends: lambda-term
Build$: flag(tests)
# +-------------------------------------------------------------------+
# | Doc |
# +-------------------------------------------------------------------+
Document "lambda-term-api"
Title: API reference for Lambda-Term
Type: ocamlbuild (0.4)
Install: true
InstallDir: $htmldir/api
DataFiles: style.css
BuildTools: ocamldoc
XOCamlbuildPath: ./
XOCamlbuildLibraries: lambda-term
# +-------------------------------------------------------------------+
# | Manual pages |
# +-------------------------------------------------------------------+
Document "lambda-term-actions-man"
Type: custom (0.4)
Title: Man page for lambda-term-actions
Install: true
BuildTools: gzip
XCustom: $gzip -c man/lambda-term-actions.1 > man/lambda-term-actions.1.gz
XCustomClean: $rm man/lambda-term-actions.1.gz
DataFiles: man/lambda-term-actions.1.gz
InstallDir: $mandir/man1
Document "lambda-term-inputrc-man"
Type: custom (0.4)
Title: Man page for ~/.lambda-term-inputrc
Install: true
BuildTools: gzip
XCustom: $gzip -c man/lambda-term-inputrc.5 > man/lambda-term-inputrc.5.gz
XCustomClean: $rm man/lambda-term-inputrc.5.gz
DataFiles: man/lambda-term-inputrc.5.gz
InstallDir: $mandir/man5
# +-------------------------------------------------------------------+
# | Configuration examples |
# +-------------------------------------------------------------------+
Document "lamda-term-inputrc"
Type: custom (0.4)
Title: lambda-term-inputrc example
XCustom: true
Install: true
DataFiles: lambda-term-inputrc
Document "lambda-termrc"
Type: custom (0.4)
Title: lambda-term resource file example
XCustom: true
Install: true
DataFiles: lambda-termrc
# +-------------------------------------------------------------------+
# | Misc |
# +-------------------------------------------------------------------+
SourceRepository head
Type: git
Location: https://github.com/diml/lambda-term.git
Browser: https://github.com/diml/lambda-term
true: bin_annot
<**/*.ml{,i}>: warn(-40)
# OASIS_START
# DO NOT EDIT (digest: f12ba400c7843bbf5596c40bead94720)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
true: annot, bin_annot
<**/.svn>: -traverse
<**/.svn>: not_hygienic
".bzr": -traverse
".bzr": not_hygienic
".hg": -traverse
".hg": not_hygienic
".git": -traverse
".git": not_hygienic
"_darcs": -traverse
"_darcs": not_hygienic
# Library lambda-term
"src/lambda-term.cmxs": use_lambda-term
<src/*.ml{,i,y}>: oasis_library_lambda_term_ccopt
<src/widget_impl/*.ml{,i,y}>: oasis_library_lambda_term_ccopt
"src/lTerm_term_stubs.c": oasis_library_lambda_term_ccopt
"src/lTerm_unix_stubs.c": oasis_library_lambda_term_ccopt
"src/lTerm_windows_stubs.c": oasis_library_lambda_term_ccopt
<src/lambda-term.{cma,cmxa}>: oasis_library_lambda_term_cclib
"src/liblambda-term_stubs.lib": oasis_library_lambda_term_cclib
"src/dlllambda-term_stubs.dll": oasis_library_lambda_term_cclib
"src/liblambda-term_stubs.a": oasis_library_lambda_term_cclib
"src/dlllambda-term_stubs.so": oasis_library_lambda_term_cclib
<src/lambda-term.{cma,cmxa}>: use_liblambda-term_stubs
<src/*.ml{,i,y}>: pkg_lwt
<src/*.ml{,i,y}>: pkg_lwt.react
<src/*.ml{,i,y}>: pkg_lwt.unix
<src/*.ml{,i,y}>: pkg_zed
<src/widget_impl/*.ml{,i,y}>: pkg_lwt
<src/widget_impl/*.ml{,i,y}>: pkg_lwt.react
<src/widget_impl/*.ml{,i,y}>: pkg_lwt.unix
<src/widget_impl/*.ml{,i,y}>: pkg_zed
"src/lTerm_term_stubs.c": pkg_lwt
"src/lTerm_term_stubs.c": pkg_lwt.react
"src/lTerm_term_stubs.c": pkg_lwt.unix
"src/lTerm_term_stubs.c": pkg_zed
"src/lTerm_unix_stubs.c": pkg_lwt
"src/lTerm_unix_stubs.c": pkg_lwt.react
"src/lTerm_unix_stubs.c": pkg_lwt.unix
"src/lTerm_unix_stubs.c": pkg_zed
"src/lTerm_windows_stubs.c": pkg_lwt
"src/lTerm_windows_stubs.c": pkg_lwt.react
"src/lTerm_windows_stubs.c": pkg_lwt.unix
"src/lTerm_windows_stubs.c": pkg_zed
# Executable events
<examples/events.{native,byte}>: pkg_lwt
<examples/events.{native,byte}>: pkg_lwt.react
<examples/events.{native,byte}>: pkg_lwt.unix
<examples/events.{native,byte}>: pkg_zed
<examples/events.{native,byte}>: use_lambda-term
# Executable colors
<examples/colors.{native,byte}>: pkg_lwt
<examples/colors.{native,byte}>: pkg_lwt.react
<examples/colors.{native,byte}>: pkg_lwt.unix
<examples/colors.{native,byte}>: pkg_zed
<examples/colors.{native,byte}>: use_lambda-term
# Executable colors_256
<examples/colors_256.{native,byte}>: pkg_lwt
<examples/colors_256.{native,byte}>: pkg_lwt.react
<examples/colors_256.{native,byte}>: pkg_lwt.unix
<examples/colors_256.{native,byte}>: pkg_zed
<examples/colors_256.{native,byte}>: use_lambda-term
# Executable rgb
<examples/rgb.{native,byte}>: pkg_lwt
<examples/rgb.{native,byte}>: pkg_lwt.react
<examples/rgb.{native,byte}>: pkg_lwt.unix
<examples/rgb.{native,byte}>: pkg_zed
<examples/rgb.{native,byte}>: use_lambda-term
# Executable move
<examples/move.{native,byte}>: pkg_lwt
<examples/move.{native,byte}>: pkg_lwt.react
<examples/move.{native,byte}>: pkg_lwt.unix
<examples/move.{native,byte}>: pkg_zed
<examples/move.{native,byte}>: use_lambda-term
# Executable hello
<examples/hello.{native,byte}>: pkg_lwt
<examples/hello.{native,byte}>: pkg_lwt.react
<examples/hello.{native,byte}>: pkg_lwt.unix
<examples/hello.{native,byte}>: pkg_zed
<examples/hello.{native,byte}>: use_lambda-term
# Executable clock
<examples/clock.{native,byte}>: pkg_lwt
<examples/clock.{native,byte}>: pkg_lwt.react
<examples/clock.{native,byte}>: pkg_lwt.unix
<examples/clock.{native,byte}>: pkg_zed
<examples/clock.{native,byte}>: use_lambda-term
# Executable buttons
<examples/buttons.{native,byte}>: pkg_lwt
<examples/buttons.{native,byte}>: pkg_lwt.react
<examples/buttons.{native,byte}>: pkg_lwt.unix
<examples/buttons.{native,byte}>: pkg_zed
<examples/buttons.{native,byte}>: use_lambda-term
# Executable focus
<examples/focus.{native,byte}>: pkg_lwt
<examples/focus.{native,byte}>: pkg_lwt.react
<examples/focus.{native,byte}>: pkg_lwt.unix
<examples/focus.{native,byte}>: pkg_zed
<examples/focus.{native,byte}>: use_lambda-term
# Executable checkbuttons
<examples/checkbuttons.{native,byte}>: pkg_lwt
<examples/checkbuttons.{native,byte}>: pkg_lwt.react
<examples/checkbuttons.{native,byte}>: pkg_lwt.unix
<examples/checkbuttons.{native,byte}>: pkg_zed
<examples/checkbuttons.{native,byte}>: use_lambda-term
# Executable radiobuttons
<examples/radiobuttons.{native,byte}>: pkg_lwt
<examples/radiobuttons.{native,byte}>: pkg_lwt.react
<examples/radiobuttons.{native,byte}>: pkg_lwt.unix
<examples/radiobuttons.{native,byte}>: pkg_zed
<examples/radiobuttons.{native,byte}>: use_lambda-term
# Executable shell
<examples/shell.{native,byte}>: pkg_lwt
<examples/shell.{native,byte}>: pkg_lwt.react
<examples/shell.{native,byte}>: pkg_lwt.unix
<examples/shell.{native,byte}>: pkg_str
<examples/shell.{native,byte}>: pkg_zed
<examples/shell.{native,byte}>: use_lambda-term
<examples/*.ml{,i,y}>: pkg_str
# Executable repl
<examples/repl.{native,byte}>: pkg_lwt
<examples/repl.{native,byte}>: pkg_lwt.react
<examples/repl.{native,byte}>: pkg_lwt.unix
<examples/repl.{native,byte}>: pkg_zed
<examples/repl.{native,byte}>: use_lambda-term
# Executable modal
<examples/modal.{native,byte}>: pkg_lwt
<examples/modal.{native,byte}>: pkg_lwt.react
<examples/modal.{native,byte}>: pkg_lwt.unix
<examples/modal.{native,byte}>: pkg_zed
<examples/modal.{native,byte}>: use_lambda-term
# Executable read-password
<examples/read_password.{native,byte}>: pkg_lwt
<examples/read_password.{native,byte}>: pkg_lwt.react
<examples/read_password.{native,byte}>: pkg_lwt.unix
<examples/read_password.{native,byte}>: pkg_zed
<examples/read_password.{native,byte}>: use_lambda-term
# Executable read-yes-no
<examples/read_yes_no.{native,byte}>: pkg_lwt
<examples/read_yes_no.{native,byte}>: pkg_lwt.react
<examples/read_yes_no.{native,byte}>: pkg_lwt.unix
<examples/read_yes_no.{native,byte}>: pkg_zed
<examples/read_yes_no.{native,byte}>: use_lambda-term
# Executable editor
<examples/editor.{native,byte}>: pkg_lwt
<examples/editor.{native,byte}>: pkg_lwt.react
<examples/editor.{native,byte}>: pkg_lwt.unix
<examples/editor.{native,byte}>: pkg_zed
<examples/editor.{native,byte}>: use_lambda-term
<examples/*.ml{,i,y}>: pkg_lwt
<examples/*.ml{,i,y}>: pkg_lwt.react
<examples/*.ml{,i,y}>: pkg_lwt.unix
<examples/*.ml{,i,y}>: pkg_zed
<examples/*.ml{,i,y}>: use_lambda-term
# Executable lambda-term-actions
<tools/lambda_term_actions.{native,byte}>: pkg_lwt
<tools/lambda_term_actions.{native,byte}>: pkg_lwt.react
<tools/lambda_term_actions.{native,byte}>: pkg_lwt.unix
<tools/lambda_term_actions.{native,byte}>: pkg_zed
<tools/lambda_term_actions.{native,byte}>: use_lambda-term
<tools/*.ml{,i,y}>: pkg_lwt
<tools/*.ml{,i,y}>: pkg_lwt.react
<tools/*.ml{,i,y}>: pkg_lwt.unix
<tools/*.ml{,i,y}>: pkg_zed
<tools/*.ml{,i,y}>: use_lambda-term
# Executable history-stress-test
<tests/history_stress_test.{native,byte}>: pkg_lwt
<tests/history_stress_test.{native,byte}>: pkg_lwt.react
<tests/history_stress_test.{native,byte}>: pkg_lwt.unix
<tests/history_stress_test.{native,byte}>: pkg_zed
<tests/history_stress_test.{native,byte}>: use_lambda-term
<tests/*.ml{,i,y}>: pkg_lwt
<tests/*.ml{,i,y}>: pkg_lwt.react
<tests/*.ml{,i,y}>: pkg_lwt.unix
<tests/*.ml{,i,y}>: pkg_zed
<tests/*.ml{,i,y}>: use_lambda-term
# OASIS_STOP
#!/bin/sh
# OASIS_START
# DO NOT EDIT (digest: dc86c2ad450f91ca10c931b6045d0499)
set -e
FST=true
for i in "$@"; do
if $FST; then
set --
FST=false
fi
case $i in
--*=*)
ARG=${i%%=*}
VAL=${i##*=}
set -- "$@" "$ARG" "$VAL"
;;
*)
set -- "$@" "$i"
;;
esac
done
ocaml setup.ml -configure "$@"
# OASIS_STOP
(install
(section share_root)
(files lambda-term-inputrc lambda-termrc))
(alias
(name examples)
(deps (alias examples/all)))
(lang dune 1.1)
(name lambda-term)
(lang dune 1.1)
;; This file is used by `make all-supported-ocaml-versions`
(context (opam (switch 4.02.3)))
(context (opam (switch 4.03.0)))
(context (opam (switch 4.04.2)))
(context (opam (switch 4.05.0)))
(context (opam (switch 4.06.1)))
(context (opam (switch 4.07.0)))
(*
* asciiart.ml
* -----------
* Copyright : (c) 2016, Andy Ray <andy.ray@ujamjar.com>
* Licence : BSD3
*
* This file is a part of Lambda-Term.
*)
(* ascii chars of increasing intensity *)
let palette = " .*:o&8#@"
(* grayscale conversion coefficients *)
let coefs = [| 0.229; 0.587; 0.114 |]
(* load image *)
let load file =
let img = OImages.load file [] in
match OImages.tag img with
| OImages.Index8 img
| OImages.Index16 img -> img#to_rgb24
| OImages.Rgb24 img -> img
| _ -> failwith "not supported"
(* images will be scaled down by averaging pixels in blocks of this size *)
let avg_cols = ref 5
let avg_rows = ref 10
let filename = ref "test.png"
let () = Arg.(parse [
"-cols", Set_int avg_cols, "num cols to average";
"-rows", Set_int avg_rows, "num rows to average";
] (fun s -> filename := s) "asciiart [options] filename")
(* scale image and convert to indices into palette *)
let indices img =
let rows = img#height in
let cols = img#width in
let avg = float_of_int (!avg_rows * !avg_cols) in
let luma r g b =
((float_of_int r *. coefs.(0)) +.
(float_of_int g *. coefs.(1)) +.
(float_of_int b *. coefs.(2)))
in
Array.init (rows / !avg_rows) (fun row ->
Array.init (cols / !avg_cols) (fun col ->
let sum = ref 0. in
for row=row * !avg_rows to ((row+1) * !avg_rows)-1 do
for col=col * !avg_cols to ((col+1) * !avg_cols)-1 do
let pel = img#get col row in
sum := !sum +. (luma pel.Images.r pel.Images.g pel.Images.b)
done
done;
let sum = !sum /. (256. *. avg) in
max 0 @@ min 8 (int_of_float (sum *. 9.))))
open Lwt
open LTerm_widget
open LTerm_geom
open CamomileLibrary
(* scrollable asciiart widget *)
class asciiart img = object(self)
inherit t "asciiart" as super
method! can_focus = true
(* scrollable interfaces *)
val vscroll = new scrollable
val hscroll = new scrollable
method vscroll = vscroll
method hscroll = hscroll
method document_size = {
rows = img#height / !avg_rows;
cols = img#width / !avg_cols;
}
initializer
vscroll#set_document_size self#document_size.rows;
hscroll#set_document_size self#document_size.cols
method! set_allocation r =
super#set_allocation r;
let size = size_of_rect r in
vscroll#set_page_size size.rows;
hscroll#set_page_size size.cols
val style =
LTerm_style.({ none with foreground=Some white;
background=Some black })
(* buffer the image - reconvert when the scale changes *)
val mutable stored_img : (int * int * (int array array)) option = None
method img =
match stored_img with
| Some(r, c, i) when r = !avg_rows && c = !avg_cols -> i
| _ -> stored_img <- Some(!avg_rows, !avg_cols, indices img); self#img
method! draw ctx _focused =
let { rows; cols } = LTerm_draw.size ctx in
let img = self#img in
for row=0 to rows-1 do
for col=0 to cols-1 do
LTerm_draw.draw_char ~style ctx row col @@
Zed_char.unsafe_of_char palette.[
try img.(row + vscroll#offset).(col + hscroll#offset) with _ -> 0
]
done
done
(* delta from center of screen *)
method private mouse_delta_event ev =
let open LTerm_mouse in
match ev with
| LTerm_event.Mouse m when m.button=Button1 && m.control=true ->
let alloc = self#allocation in
let size = size_of_rect alloc in
vscroll#set_offset
(vscroll#offset + m.LTerm_mouse.row - alloc.row1 - size.rows/2);
hscroll#set_offset
(hscroll#offset + m.LTerm_mouse.col - alloc.col1 - size.cols/2);
true
| _ -> false
(* adjust scale, which changes the document size *)
method private scale_event = function
| LTerm_event.Key{LTerm_key.code=LTerm_key.Char c;_} when c = UChar.of_char 'w' ->
avg_rows := max 1 (!avg_rows - 1);
vscroll#set_document_size self#document_size.rows;
self#queue_draw; true
| LTerm_event.Key{LTerm_key.code=LTerm_key.Char c;_} when c = UChar.of_char 's' ->
avg_rows := !avg_rows + 1;
vscroll#set_document_size self#document_size.rows;
self#queue_draw; true
| LTerm_event.Key{LTerm_key.code=LTerm_key.Char c;_} when c = UChar.of_char 'a' ->
avg_cols := max 1 (!avg_cols - 1);
hscroll#set_document_size self#document_size.cols;
self#queue_draw; true
| LTerm_event.Key{LTerm_key.code=LTerm_key.Char c;_} when c = UChar.of_char 'd' ->
avg_cols := !avg_cols + 1;
hscroll#set_document_size self#document_size.cols;
self#queue_draw; true
| _ -> false
(* page up/down *)
method page_event = function
| LTerm_event.Key{LTerm_key.code=LTerm_key.Next_page;_} ->
vscroll#set_offset @@ vscroll#page_next; self#queue_draw; true
| LTerm_event.Key{LTerm_key.code=LTerm_key.Prev_page;_} ->
vscroll#set_offset @@ vscroll#page_prev; self#queue_draw; true
| _ -> false
initializer
self#on_event (fun ev -> self#scale_event ev ||
self#page_event ev ||
self#mouse_delta_event ev)
end
(* place vertical and horizontal scroll bars around the picture *)
let with_scrollbar ?down widget =
let vbox = new vbox in
let hbox = new hbox in
(* make scroll bars roughly the same size *)
let vscroll = new vscrollbar ~width:3 widget#vscroll in
let hscroll = new hscrollbar ~height:2 widget#hscroll in
let spacing = new spacing ~rows:2 ~cols:3 () in
hbox#add widget;
hbox#add ~expand:false (new vline);
hbox#add ~expand:false vscroll;
vbox#add hbox;
vbox#add ~expand:false (new hline);
let hbox = new hbox in
hbox#add hscroll;
hbox#add ~expand:false (new vline);
hbox#add ~expand:false spacing;
vbox#add ~expand:false hbox;
(* moving focus *)
widget#set_focus { widget#focus with right = Some(vscroll :> t);
down = Some(hscroll :> t) };
vscroll#set_focus { vscroll#focus with down = Some(hscroll :> t) };
hscroll#set_focus { hscroll#focus with up = Some(vscroll :> t); down };
(* events *)
widget#on_event (fun ev -> vscroll#mouse_event ev && hscroll#mouse_event ev);
vscroll#on_event widget#page_event;
vbox
let main () =
let img = load !filename in
let waiter, wakener = wait () in
let exit = new button "exit" in
exit#on_click (wakeup wakener);
let vbox = with_scrollbar ~down:(exit :> t) (new asciiart img) in
vbox#add ~expand:false (new hline);
vbox#add ~expand:false exit;
let top = new frame in
top#set vbox;
top#on_event (function (* quit with escape key *)
| LTerm_event.Key{LTerm_key.code=LTerm_key.Escape;_} ->
wakeup wakener (); false
| _ -> false);
Lazy.force LTerm.stdout >>= fun term ->
LTerm.enable_mouse term >>= fun () ->
Lwt.finalize
(fun () -> run term top waiter)
(fun () -> LTerm.disable_mouse term)
let () = Lwt_main.run (main ())
(executable
(name asciiart)
(libraries lambda-term
camlimages.png
camlimages.jpeg))
......@@ -14,7 +14,10 @@ let main () =
let waiter, wakener = wait () in
let vbox = new vbox in
let button = new button "exit" in
let button = new button
~brackets:("[ ", " ]")
"exit退出"
in
let label = new label "_" in
button#on_click (wakeup wakener);
vbox#add button;
......@@ -23,7 +26,7 @@ let main () =
for i = 0 to 2 do
let hbox = new hbox in
let button i =
let button = new button ("button" ^ string_of_int i) in
let button = new button ("button按钮" ^ string_of_int i) in
button#on_click (fun () -> label#set_text (string_of_int i));
button
in
......@@ -38,6 +41,7 @@ let main () =
let frame = new frame in
frame#set vbox;
frame#set_label ~alignment:LTerm_geom.H_align_center "Button test按钮测试";
Lazy.force LTerm.stdout >>= fun term ->
LTerm.enable_mouse term >>= fun () ->
......
......@@ -14,8 +14,8 @@ let main () =
let waiter, wakener = wait () in
let vbox = new vbox in
let checked_label = (new label "") in
let create_button n = new checkbutton ("button" ^ (string_of_int n)) false in
let checked_label = new label "" in
let create_button n = new checkbutton ("button按钮" ^ (string_of_int n)) false in
let checkbuttons = Array.init 9 create_button in
let callback () =
let new_label = ref "" in
......@@ -26,7 +26,7 @@ let main () =
done;
checked_label#set_text !new_label
in
let button = new button "exit" in
let button = new button "exit退出" in
button#on_click (wakeup wakener);
vbox#add ~expand:false button;
vbox#add ~expand:false (new hline);
......
......@@ -7,7 +7,6 @@
* This file is a part of Lambda-Term.
*)
open Lwt_react
open Lwt
open LTerm_widget
......@@ -23,7 +22,7 @@ let main () =
let vbox = new vbox in
let clock = new label (get_time ()) in
let button = new button "exit" in
let button = new button "exit退出" in
vbox#add clock;
vbox#add button;
......
(*
* double_editor.ml
* ----------
* Copyright : (c) 2016, Fabian Bonk <fabian.bonk@bonkii.com>
* Licence : BSD3
*
* This file is a part of Lambda-Term.
*)
open LTerm_geom
let ( >>= ) = Lwt.( >>= )
(* helper functions *)
let make_key ?(ctrl = false) ?(meta = false) ?(shift = false) c =
let code =
match c with
| `Char c -> LTerm_key.Char (CamomileLibrary.UChar.of_char c)
| `Other key -> key in
{ LTerm_key.control = ctrl; meta; shift; code }
let frame widget =
let frame = new LTerm_widget.frame in
frame#set widget;
frame
let main () =
let waiter, wakener = Lwt.wait () in
let ctrl_c = [make_key ~ctrl:true @@ `Char 'c'] in
let tab = [make_key @@ `Other LTerm_key.Tab] in
let quit = [LTerm_edit.Custom (Lwt.wakeup wakener)] in
let vbox = new LTerm_widget.vbox in
let top_editor = new LTerm_edit.edit () in
let top_frame = frame top_editor in
(* make bottom editor a fixed 10 rows in size *)
let bottom_editor = new LTerm_edit.edit ~size:{ rows = 10; cols = 1 } () in
(* changed my mind: make it 5 rows smaller *)
bottom_editor#set_allocation
{ bottom_editor#allocation with row1 = bottom_editor#allocation.row1 - 5 };
let bottom_frame = frame bottom_editor in
vbox#add top_frame;
(* in versions before PR#42 this would either crash or make the bottom editor unusable *)
vbox#add ~expand:false bottom_frame;
(* exit on C-c *)
top_editor#bind ctrl_c quit;
bottom_editor#bind ctrl_c quit;
let send_key key =
LTerm_edit.Custom (fun () -> vbox#send_event @@ LTerm_event.Key (make_key key)) in
(* switch editors on Tab *)
top_editor#bind tab [send_key @@ `Other LTerm_key.Down];
bottom_editor#bind tab [send_key @@ `Other LTerm_key.Up];
let label = new LTerm_widget.label "Press Tab to switch between editors.\nPress C-c to exit." in
vbox#add ~expand:false label;
Lazy.force LTerm.stdout
>>= fun term ->
LTerm.enable_mouse term
>>= fun () ->
Lwt.finalize
(fun () -> LTerm_widget.run term ~save_state:false ~load_resources:false vbox waiter)
(fun () -> LTerm.disable_mouse term)
let () = Lwt_main.run (main ())
(executables
(names double_editor
events
colors
colors_256
rgb
move
hello
clock
buttons
focus
scroll
scroll_debug
checkbuttons
radiobuttons
shell
repl
modal
read_password
read_yes_no
editor)
(libraries lambda-term str)
(flags :standard -safe-string))
(alias
(name all)
(deps (glob_files *.exe)))
(alias
(name all.bc)
(deps (glob_files *.bc)))