From 62cbcd271283070848a0d924ba25a061a2dff2da Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 11 Oct 2011 15:08:14 +0200 Subject: applied debian erlang-slang_1.0-3 patch: some slang_drv updates most of this are useless whitespace changes, but slang_drv is updated and debian files are added --- README | 15 ++---- c_src/slang_drv.c | 132 ++++++++++++++++++++++------------------------ config/config.cache | 4 +- config/config.status | 28 +++++----- config/configure.in | 4 +- debian/README.Debian | 16 ++++++ debian/changelog | 21 ++++++++ debian/control | 16 ++++++ debian/copyright | 11 ++++ debian/dirs | 2 + debian/docs | 3 ++ debian/links | 1 + debian/rules | 85 ++++++++++++++++++++++++++++++ demo/ex1.erl | 2 +- demo/ex2.c | 5 +- demo/ex2.erl | 2 +- demo/ex3.c | 6 +-- demo/pager.erl | 112 +++++++++++++++++++-------------------- doc/cref.txt | 146 +++++++++++++++++++++++++-------------------------- doc/erlslang.txt | 14 ++--- include.mk | 2 +- slang.pub | 4 -- src/Makefile | 4 +- src/slang.erl | 28 +++++----- src/slang_int.hrl | 20 +++---- 25 files changed, 408 insertions(+), 275 deletions(-) create mode 100644 debian/README.Debian create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100644 debian/links create mode 100644 debian/rules diff --git a/README b/README index 5752879..adda637 100644 --- a/README +++ b/README @@ -1,9 +1,9 @@ -This is slang, an erlang interface to the amazing highly portable tty +This is slang, an erlang interface to the amazing highly portable tty interface that gave us such nice tty applications as mutt and slrn It's distributed as an erlang application (without a start mod) which makes -it possible to integrate into a larger buld environment. +it possible to integrate into a larger build environment. We use this at bluetail to have a terminal application onto our actual target machine. It can be used to to anything that's possible to di with the slang lib itself. @@ -17,16 +17,7 @@ demo: contains some various demos doc: well .. yes guess what config: contains configure scripts and stuff -To compile: +To compile: $ (cd config; ./configure) $ make - - - - - - - - - diff --git a/c_src/slang_drv.c b/c_src/slang_drv.c index f2e343b..3466433 100644 --- a/c_src/slang_drv.c +++ b/c_src/slang_drv.c @@ -1,8 +1,8 @@ #include -#include "driver.h" +#include "erl_driver.h" #include -#include +#include #if (SLANG_VERSION < 10400 ) @@ -183,10 +183,10 @@ - + static long sl_start(); static int sl_stop(), sl_read(); -static struct driver_entry sl_driver_entry; +static struct erl_drv_entry sl_erl_drv_entry; static int wait_for = 0; @@ -248,12 +248,12 @@ static long sl_start(long port, char *buf) } -static int sl_stop(int port) +static int sl_stop(ErlDrvPort port) { return 1; } -static int ret_int_int(int port, int i, int j) +static int ret_int_int(ErlDrvPort port, int i, int j) { char buf[9]; buf[0] = 1; @@ -264,7 +264,7 @@ static int ret_int_int(int port, int i, int j) } -static int ret_int(int port, int ret) +static int ret_int(ErlDrvPort port, int ret) { char buf[5]; buf[0] = 1; @@ -274,7 +274,7 @@ static int ret_int(int port, int ret) } -static int ret_string(int port, char *str) +static int ret_string(ErlDrvPort port, char *str) { str[-1] = 1; driver_output(port, str, 1+strlen(str)); @@ -282,7 +282,7 @@ static int ret_string(int port, char *str) } -static int sl_output(int port, char *buf, int len) +static int sl_output(ErlDrvPort port, char *buf, int len) { int x,y,z,v,w; char *str, *t1, *t2, *t3; @@ -310,7 +310,7 @@ static int sl_output(int port, char *buf, int len) ret = SLang_init_tty (abort_char,flow_ctl, opost); return ret_int(port, ret); } - + case SET_ABORT_FUNCTION: { SLang_set_abort_signal (NULL); return ret_int(port, 0); @@ -337,7 +337,7 @@ static int sl_output(int port, char *buf, int len) } case UNGETKEY: { unsigned char key = (unsigned char) *buf; - SLang_ungetkey (key); + SLang_ungetkey (key); return 0; } case RESET_TTY: { @@ -421,7 +421,7 @@ static int sl_output(int port, char *buf, int len) case esl_error: return ret_int(port, SLang_Error); case esl_version: - return ret_int(port, SLang_Version); + return ret_int(port, SLang_Version); case esl_backspace_moves : return ret_int(port, SLsmg_Backspace_Moves); case esl_display_eight_bit: @@ -430,13 +430,13 @@ static int sl_output(int port, char *buf, int len) return ret_int(port, -1); } } - + /*{{{ SLsmg Screen Management Functions */ - + case SMG_FILL_REGION: { x = get_int32(buf); buf+= 4; y = get_int32(buf); buf+= 4; @@ -445,49 +445,49 @@ static int sl_output(int port, char *buf, int len) ch = *buf; SLsmg_fill_region(x, y,z,v,ch); return 0; - } + } case SMG_SET_CHAR_SET: { x = get_int32(buf); buf+= 4; SLsmg_set_char_set(x); return 0; - } + } case SMG_SUSPEND_SMG: { return ret_int(port, SLsmg_suspend_smg()); - } + } case SMG_RESUME_SMG: { ret_int(port, SLsmg_resume_smg()); - } + } case SMG_ERASE_EOL: { SLsmg_erase_eol(); return 0; - } + } case SMG_GOTORC: { x = get_int32(buf); buf+= 4; y = get_int32(buf); buf+= 4; SLsmg_gotorc(x, y); return 0; - } + } case SMG_ERASE_EOS: { SLsmg_erase_eos(); return 0; - } + } case SMG_REVERSE_VIDEO: { SLsmg_reverse_video(); return 0; - } + } case SMG_SET_COLOR: { x = get_int32(buf); buf+= 4; SLsmg_set_color(x); return 0; - } + } case SMG_NORMAL_VIDEO: { SLsmg_normal_video(); return 0; - } + } case SMG_WRITE_STRING: { SLsmg_write_string(buf); return 0; - } + } case SMG_WRITE_CHAR: { ch = *buf; SLsmg_write_char(ch); @@ -503,21 +503,21 @@ static int sl_output(int port, char *buf, int len) w = get_int32(buf); buf+= 4; SLsmg_write_wrapped_string(t1, x,y,z,v,w); return 0; - } + } case SMG_CLS: { SLsmg_cls(); return 0; - } + } case SMG_REFRESH: { SLsmg_refresh(); return 0; - } + } case SMG_TOUCH_LINES: { x = get_int32(buf); buf+= 4; y = get_int32(buf); buf+= 4; SLsmg_touch_lines(x, y); return 0; - } + } case SMG_TOUCH_SCREEN: { #if (SLANG_VERSION < 10400 ) return ret_int(port, -1); @@ -525,24 +525,24 @@ static int sl_output(int port, char *buf, int len) SLsmg_touch_screen(); #endif return 0; - } + } case SMG_INIT_SMG: { return ret_int(port, SLsmg_init_smg()); - } + } case SMG_REINIT_SMG: { #if (SLANG_VERSION < 10400 ) return ret_int(port, -1); #else return ret_int(port, SLsmg_reinit_smg()); #endif - } + } case SMG_RESET_SMG: { SLsmg_reset_smg(); return 0; - } + } case SMG_CHAR_AT: { return ret_int(port, SLsmg_char_at()); - } + } case SMG_SET_SCREEN_START: { int *ip1, *ip2; *ip1 = get_int32(buf); buf+= 4; @@ -555,19 +555,19 @@ static int sl_output(int port, char *buf, int len) x = get_int32(buf); buf+= 4; SLsmg_draw_hline(x); return 0; - } + } case SMG_DRAW_VLINE: { x = get_int32(buf); buf+= 4; SLsmg_draw_vline(x); return 0; - } + } case SMG_DRAW_OBJECT: { x = get_int32(buf); buf+= 4; y = get_int32(buf); buf+= 4; x = get_int32(buf); buf+= 4; SLsmg_draw_object(x, y,z); return 0; - } + } case SMG_DRAW_BOX: { x = get_int32(buf); buf+= 4; y = get_int32(buf); buf+= 4; @@ -575,26 +575,26 @@ static int sl_output(int port, char *buf, int len) v = get_int32(buf); buf+= 4; SLsmg_draw_box(x, y,z,v); return 0; - } + } case SMG_GET_COLUMN: { return ret_int(port, SLsmg_get_column()); - } + } case SMG_GET_ROW: { return ret_int(port, SLsmg_get_row()); - } + } case SMG_FORWARD: { x = get_int32(buf); buf+= 4; SLsmg_forward(x); return 0; - } + } case SMG_WRITE_COLOR_CHARS: { SLsmg_Char_Type * sl; sl = decode_smg_char_type(&buf); x = get_int32(buf); buf+= 4; SLsmg_write_color_chars(sl, x); return 0; - } + } case SMG_READ_RAW: { x = get_int32(buf); buf+= 4; t1 = malloc((2*x) + 2 + 1); @@ -607,10 +607,10 @@ static int sl_output(int port, char *buf, int len) case SMG_WRITE_RAW: { SLsmg_Char_Type * sl; sl = decode_smg_char_type(&buf); - x = get_int32(buf); + x = get_int32(buf); y = SLsmg_write_raw(sl, x); return ret_int(port, y); - } + } case SMG_SET_COLOR_IN_REGION: { x = get_int32(buf); buf+= 4; y = get_int32(buf); buf+= 4; @@ -619,9 +619,7 @@ static int sl_output(int port, char *buf, int len) w = get_int32(buf); buf+= 4; SLsmg_set_color_in_region(x, y,z,v,w); return 0; - } - - + } @@ -718,7 +716,7 @@ static int sl_output(int port, char *buf, int len) } case TT_INIT_VIDEO: { ret = SLtt_init_video (); - return ret_int(port, ret); + return ret_int(port, ret); } case TT_RESET_VIDEO: { SLtt_reset_video (); @@ -734,25 +732,24 @@ static int sl_output(int port, char *buf, int len) } case TT_SET_CURSOR_VISIBILITY: { ret = SLtt_set_cursor_visibility (get_int32(buf)); - return ret_int(port, ret); + return ret_int(port, ret); } case TT_SET_MOUSE_MODE: { x = get_int32(buf); buf+=4; y = get_int32(buf); buf+=4; ret = SLtt_set_mouse_mode (x,y); - return ret_int(port, ret); + return ret_int(port, ret); } case TT_INITIALIZE: { ret =SLtt_initialize (buf); - return ret_int(port, ret); + return ret_int(port, ret); } case TT_ENABLE_CURSOR_KEYS: { SLtt_enable_cursor_keys(); return 0; } case TT_SET_TERM_VTXXX: { - return 0; } case TT_SET_COLOR_ESC: { @@ -800,11 +797,9 @@ static int sl_output(int port, char *buf, int len) return ret_string(port, str); } case TT_TIGETSTR: { - return 0; } case TT_TIGETNUM: { - return 0; } @@ -879,7 +874,7 @@ static int sl_output(int port, char *buf, int len) /* pending getkey request */ -sl_ready_input(int port, int fd) +sl_ready_input(ErlDrvPort port, int fd) { unsigned int key; driver_select(port, 0, DO_READ, 0); @@ -893,7 +888,7 @@ sl_ready_input(int port, int fd) return ret_int(port, key); } return 0; - } + } } @@ -902,20 +897,17 @@ sl_ready_input(int port, int fd) * Initialize and return a driver entry struct */ -struct driver_entry *driver_init(void *handle) +struct erl_drv_entry *driver_init(void *handle) { - sl_driver_entry.init = null_func; /* Not used */ - sl_driver_entry.start = sl_start; - sl_driver_entry.stop = sl_stop; - sl_driver_entry.output = sl_output; - sl_driver_entry.ready_input = sl_ready_input; - sl_driver_entry.ready_output = null_func; - sl_driver_entry.driver_name = "slang_drv"; - sl_driver_entry.finish = null_func; - sl_driver_entry.handle = handle; /* MUST set this!!! */ - return &sl_driver_entry; + sl_erl_drv_entry.init = NULL; /* Not used */ + sl_erl_drv_entry.start = sl_start; + sl_erl_drv_entry.stop = sl_stop; + sl_erl_drv_entry.output = sl_output; + sl_erl_drv_entry.ready_input = sl_ready_input; + sl_erl_drv_entry.ready_output = NULL; + sl_erl_drv_entry.driver_name = "slang_drv"; + sl_erl_drv_entry.finish = NULL; + sl_erl_drv_entry.handle = handle; /* MUST set this!!! */ + return &sl_erl_drv_entry; } - - - diff --git a/config/config.cache b/config/config.cache index 874acfe..3cc3b9c 100644 --- a/config/config.cache +++ b/config/config.cache @@ -12,5 +12,5 @@ # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # -ac_cv_path_ERL=${ac_cv_path_ERL=/usr/local/bin/erl} -ac_cv_path_ERLC=${ac_cv_path_ERLC=/usr/local/bin/erlc} +ac_cv_path_ERL=${ac_cv_path_ERL=/usr/bin/erl} +ac_cv_path_ERLC=${ac_cv_path_ERLC=/usr/bin/erlc} diff --git a/config/config.status b/config/config.status index f3da4fd..edfec51 100755 --- a/config/config.status +++ b/config/config.status @@ -2,7 +2,7 @@ # Generated automatically by configure. # Run this file to recreate the current configuration. # This directory was configured as follows, -# on host robin: +# on host kava: # # ./configure # @@ -39,7 +39,7 @@ s%@CFLAGS@%%g s%@CPPFLAGS@%%g s%@CXXFLAGS@%%g s%@FFLAGS@%%g -s%@DEFS@% -DCPU_VENDOR_OS=\"i686-pc-linux-gnu\" -DLINUX=1 %g +s%@DEFS@% -DCPU_VENDOR_OS=\"i586-pc-linux-gnu\" -DLINUX=1 %g s%@LDFLAGS@%%g s%@LIBS@%%g s%@exec_prefix@%${prefix}%g @@ -57,26 +57,26 @@ s%@includedir@%${prefix}/include%g s%@oldincludedir@%/usr/include%g s%@infodir@%${prefix}/info%g s%@mandir@%${prefix}/man%g -s%@host@%i686-pc-linux-gnu%g -s%@host_alias@%i686-pc-linux-gnu%g -s%@host_cpu@%i686%g +s%@host@%i586-pc-linux-gnu%g +s%@host_alias@%i586-pc-linux-gnu%g +s%@host_cpu@%i586%g s%@host_vendor@%pc%g s%@host_os@%linux-gnu%g -s%@target@%i686-pc-linux-gnu%g -s%@target_alias@%i686-pc-linux-gnu%g -s%@target_cpu@%i686%g +s%@target@%i586-pc-linux-gnu%g +s%@target_alias@%i586-pc-linux-gnu%g +s%@target_cpu@%i586%g s%@target_vendor@%pc%g s%@target_os@%linux-gnu%g -s%@build@%i686-pc-linux-gnu%g -s%@build_alias@%i686-pc-linux-gnu%g -s%@build_cpu@%i686%g +s%@build@%i586-pc-linux-gnu%g +s%@build_alias@%i586-pc-linux-gnu%g +s%@build_cpu@%i586%g s%@build_vendor@%pc%g s%@build_os@%linux-gnu%g s%@SLANG_INCLUDE@%/usr/include/slang%g s%@LD_SHARED@%ld -shared%g -s%@ERL@%/usr/local/bin/erl%g -s%@ERLC@%/usr/local/bin/erlc%g -s%@ERLDIR@%/usr/local/lib/erlang%g +s%@ERL@%/usr/bin/erl%g +s%@ERLC@%/usr/bin/erlc%g +s%@ERLDIR@%/usr/lib/erlang%g CEOF diff --git a/config/configure.in b/config/configure.in index 1c3ac53..bcf3280 100644 --- a/config/configure.in +++ b/config/configure.in @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl while debugging configure.in -dnl it's good to disable the cache +dnl it's good to disable the cache dnl define([AC_CACHE_LOAD], )dnl dnl define([AC_CACHE_SAVE], )dnl @@ -26,7 +26,7 @@ AC_ARG_WITH(slang-include, [ --with-slang-include=DIR installed slang library if test "x$SLANG_INCLUDE" = x; then SLANG_INCLUDE=/usr/include/slang fi - echo using $SLANG_INCLUDE + echo using $SLANG_INCLUDE ) AC_SUBST(SLANG_INCLUDE) diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..95fc141 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,16 @@ +erlang-slang for Debian +----------------------- + + +Known Problems: + +- The erlang repl doesn't seem to like erlang-slang mucking around with + the terminal much. A work around is to compile your erlang sources + using erlc and run them using erl -noshell -s Mod Fun + +- The documentation is not complete though usable. + + +------------------- + + -- Mark Ng , Sat, 7 Jul 2001 15:11:20 +1000 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..1048193 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,21 @@ +erlang-slang (1.0-3) unstable; urgency=low + + * Moved to Non-US : (closes: #133467) (closes: #133756) + + -- Mark Ng Thu, 14 Feb 2002 18:25:30 +1100 + +erlang-slang (1.0-2) unstable; urgency=low + + * Applied David N. Welton's patch : (closes: #121460) + - powerPC build. + - uses new erl_driver.h instead of driver.h interface. + + -- Mark Ng Mon, 7 Jan 2002 01:11:38 +1100 + +erlang-slang (1.0-1) unstable; urgency=low + + * Initial Release (closes: #101742) + + -- Mark Ng Sun, 28 Oct 2001 00:28:40 +1000 + + diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..1bf6cab --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: erlang-slang +Section: non-us/interpreters +Priority: optional +Maintainer: Mark Ng +Standards-Version: 3.5.6 +Build-Depends: debhelper (>> 3.0.0), slang1-dev (>= 1.4.4), erlang (>= 50), c-compiler, findutils, grep + +Package: erlang-slang +Architecture: any +Depends: ${shlibs:Depends}, erlang (>= 50) +Description: S-Lang interface for Erlang + This is an erlang interface to S-Lang the amazing highly portable tty + interface that gave us such nice tty applications as mutt and slrn + . + It's distributed as an erlang application (without a start mod) which makes + it possible to integrate into a larger build environment. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..d6f3c3a --- /dev/null +++ b/debian/copyright @@ -0,0 +1,11 @@ +This package was debianized by Mark Ng on +Sat, 7 Jul 2001 15:11:20 +1000. + +It was downloaded from http://www.erlang.org/contrib/slang-1.0.tgz + +Upstream Author(s): Claes Wikstrom + +Copyright: + + Same terms as slang itself. ie: GPL or Artistic License. + diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..a7c403e --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/lib/erlang/lib/slang-1.0/ + diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..f693f70 --- /dev/null +++ b/debian/docs @@ -0,0 +1,3 @@ +README +TODO +doc/erlslang.txt diff --git a/debian/links b/debian/links new file mode 100644 index 0000000..f29afb0 --- /dev/null +++ b/debian/links @@ -0,0 +1 @@ +/usr/lib/erlang/lib/slang-1.0/demo /usr/share/doc/erlang-slang/examples diff --git a/debian/rules b/debian/rules new file mode 100644 index 0000000..ffcb464 --- /dev/null +++ b/debian/rules @@ -0,0 +1,85 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +# This is the debhelper compatability version to use. +export DH_COMPAT=3 + +export ERLDIR=/usr/lib/erlang/ + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + make conf + + touch configure-stamp + +build: configure-stamp build-stamp +build-stamp: + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + # Add here commands to install the package into debian/erlang-slang. + # $(MAKE) install DESTDIR=$(CURDIR)/debian/erlang-slang + + + FILES=`find demo include ebin priv src slang.pub | grep -i -v -e cvs -e \.empty` ; \ + for f in $$FILES ; do if test -f $$f ; then \ + cp -P $$f $(CURDIR)/debian/erlang-slang/usr/lib/erlang/lib/slang-1.0 ; \ + fi ; done + + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + + dh_installdocs + + +# dh_undocumented + dh_installchangelogs + dh_link + dh_strip + dh_compress + dh_fixperms + dh_makeshlibs + dh_installdeb + dh_shlibdeps -- $(CURDIR)/debian/erlang-slang/usr/lib/erlang/lib/slang-1.0/priv/slang_drv.so + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure + + diff --git a/demo/ex1.erl b/demo/ex1.erl index a3e861a..8606ac9 100644 --- a/demo/ex1.erl +++ b/demo/ex1.erl @@ -1,7 +1,7 @@ %%%---------------------------------------------------------------------- %%% File : ex1.erl %%% Author : Claes Wikstrom -%%% Purpose : +%%% Purpose : %%% Created : 22 Nov 2000 by Claes Wikstrom %%%---------------------------------------------------------------------- diff --git a/demo/ex2.c b/demo/ex2.c index bbfa980..eef251e 100644 --- a/demo/ex2.c +++ b/demo/ex2.c @@ -5,7 +5,7 @@ int main () { int abort_char = 7; /* For MSDOS, use 34 as scan code */ unsigned int ch; - + if (-1 == SLang_init_tty (abort_char, 0, 1)) { fprintf (stderr, "Unable to initialize the terminal.\n"); @@ -14,7 +14,7 @@ int main () SLang_set_abort_signal (NULL); fflush (stdout); - + ch = SLang_getkey (); printf("<< %c >> %d ",ch, SLang_Error); @@ -22,7 +22,6 @@ int main () SLang_reset_tty (); return 0; } - diff --git a/demo/ex2.erl b/demo/ex2.erl index 613a3ec..06a118b 100644 --- a/demo/ex2.erl +++ b/demo/ex2.erl @@ -15,7 +15,7 @@ start() -> slang:kp_init(), slang:init_tty(7, 0, 1), slang:smg_init_smg (), - + draw_stuff2(), Key = slang:kp_getkey(), diff --git a/demo/ex3.c b/demo/ex3.c index 0e9c7ff..2ae848a 100644 --- a/demo/ex3.c +++ b/demo/ex3.c @@ -18,14 +18,14 @@ int main () SLkp_init (); SLang_init_tty (-1, 0, 0); SLsmg_init_smg (); - + stuff(); SLkp_getkey (); - + /* do stuff .... */ - + SLsmg_reset_smg (); SLang_reset_tty (); return 0; diff --git a/demo/pager.erl b/demo/pager.erl index 37f6a14..527d16c 100644 --- a/demo/pager.erl +++ b/demo/pager.erl @@ -1,7 +1,7 @@ %%%---------------------------------------------------------------------- %%% File : pager.erl %%% Author : Claes Wikstrom -%%% Purpose : +%%% Purpose : %%% Created : 1 Dec 2000 by Claes Wikstrom %%%---------------------------------------------------------------------- @@ -24,7 +24,7 @@ demolib_exit (Signal) -> slang:reset_tty (), slang:smg_reset_smg (), - + if Signal == 0 -> halt(); @@ -50,10 +50,10 @@ sigint_handler (Signal) -> % } exit_error_hook (Fmt, Args) -> - + slang:reset_tty (), slang:reset_smg (), - + io:format(Fmt, Args), io:nl(), halt(). @@ -62,27 +62,27 @@ exit_error_hook (Fmt, Args) -> demolib_init_terminal () -> - + %% SLang_Exit_Error_Hook = exit_error_hook - % It is wise to block the occurance of display related - %signals while we are - %initializing. + % It is wise to block the occurance of display related + %signals while we are + %initializing. %SLsig_block_signals (), - + slang:tt_get_terminfo (), - - %% SLkp_init assumes that SLtt_get_terminfo has been called. - + + %% SLkp_init assumes that SLtt_get_terminfo has been called. + case slang:kp_init() of -1 -> -1; Ret -> - + slang:init_tty (-1, 0, 1), %slang:tty_set_suspend_state (1), - + case slang:smg_init_smg () of -1 -> -1; @@ -94,12 +94,12 @@ demolib_init_terminal () -> main() -> File="tmp/test", - + int main (int argc, char **argv) -{ +{ if (argc == 2) { File_Name = argv[1]; @@ -107,36 +107,36 @@ int main (int argc, char **argv) else if ((argc != 1) || (1 == isatty (fileno(stdin)))) usage (argv[0]); - + if (-1 == read_file (File_Name)) { fprintf (stderr, "Unable to read %s\n", File_Name); return 1; } - + /* This sets up the terminal, signals, screen management routines, etc... */ if (-1 == demolib_init_terminal (1, 1)) { fprintf (stderr, "Unable to initialize terminal."); return 1; } - + #define APP_KEY_EOB 0x1001 #define APP_KEY_BOB 0x1002 - - /* Add a few application defined keysyms. 0x1000 and above are for + + /* Add a few application defined keysyms. 0x1000 and above are for * applications. */ (void) SLkp_define_keysym ("\033>", APP_KEY_EOB); (void) SLkp_define_keysym ("\033<", APP_KEY_BOB); - + main_loop (); /* should not return */ return 1; } - + /* The SLscroll routines will be used for pageup/down commands. They assume - * a linked list of lines. The first element of the structure MUST point to + * a linked list of lines. The first element of the structure MUST point to * the NEXT line, the second MUST point to the PREVIOUS line. */ typedef struct _File_Line_Type @@ -155,7 +155,7 @@ static SLscroll_Window_Type Line_Window; static void free_lines (void) { File_Line_Type *line, *next; - + line = File_Lines; while (line != NULL) { @@ -170,19 +170,19 @@ static void free_lines (void) static File_Line_Type *create_line (char *buf) { File_Line_Type *line; - + line = (File_Line_Type *) malloc (sizeof (File_Line_Type)); if (line == NULL) return NULL; - + memset ((char *) line, sizeof (File_Line_Type), 0); - + line->data = SLmake_string (buf); /* use a slang routine */ if (line->data == NULL) { free (line); return NULL; } - + return line; } @@ -193,45 +193,45 @@ static int read_file (char *file) char buf [1024]; File_Line_Type *line, *last_line; unsigned int num_lines; - - if (file == NULL) + + if (file == NULL) fp = stdin; else fp = fopen (file, "r"); - + if (fp == NULL) return -1; - + last_line = NULL; num_lines = 0; - + while (NULL != fgets (buf, sizeof(buf), fp)) { num_lines++; - + if (NULL == (line = create_line (buf))) { fprintf (stderr, "Out of memory."); free_lines (); return -1; } - + if (last_line == NULL) File_Lines = line; - else + else last_line->next = line; - + line->prev = last_line; line->next = NULL; - + last_line = line; } - + memset ((char *)&Line_Window, 0, sizeof (SLscroll_Window_Type)); - + Line_Window.current_line = (SLscroll_Type *) File_Lines; Line_Window.lines = (SLscroll_Type *) File_Lines; Line_Window.line_num = 1; Line_Window.num_lines = num_lines; - + return 0; } @@ -245,7 +245,7 @@ static void update_display (void) * the display while performing screen update. */ SLsig_block_signals (); - + Line_Window.nrows = nrows = SLtt_Screen_Rows - 1; /* Always make the current line equal to the top window line. */ @@ -253,17 +253,17 @@ static void update_display (void) Line_Window.current_line = Line_Window.top_window_line; SLscroll_find_top (&Line_Window); - + row = 0; line = (File_Line_Type *) Line_Window.top_window_line; - + SLsmg_normal_video (); - + while (row < Line_Window.nrows) { SLsmg_gotorc (row, 0); - - if (line != NULL) + + if (line != NULL) { SLsmg_write_string (line->data); line = line->next; @@ -271,13 +271,13 @@ static void update_display (void) SLsmg_erase_eol (); row++; } - + SLsmg_gotorc (row, 0); SLsmg_reverse_video (); SLsmg_printf ("%s", (File_Name == NULL) ? "" : File_Name); SLsmg_erase_eol (); SLsmg_refresh (); - + SLsig_unblock_signals (); } @@ -297,13 +297,13 @@ static void main_loop (void) case 'Q': demolib_exit (0); break; - + case SL_KEY_RIGHT: Screen_Start += 1; screen_start = Screen_Start; SLsmg_set_screen_start (NULL, &screen_start); break; - + case SL_KEY_LEFT: Screen_Start -= 1; if (Screen_Start < 0) Screen_Start = 0; @@ -315,13 +315,13 @@ static void main_loop (void) SLscroll_prev_n (&Line_Window, 1); Line_Window.top_window_line = Line_Window.current_line; break; - + case '\r': case SL_KEY_DOWN: SLscroll_next_n (&Line_Window, 1); Line_Window.top_window_line = Line_Window.current_line; break; - + case SL_KEY_NPAGE: case ' ': case 4: SLscroll_pagedown (&Line_Window); @@ -336,12 +336,12 @@ static void main_loop (void) while (-1 != SLscroll_pageup (&Line_Window)) ; break; - + case APP_KEY_EOB: while (-1 != SLscroll_pagedown (&Line_Window)) ; break; - + default: SLtt_beep (); } diff --git a/doc/cref.txt b/doc/cref.txt index 2871973..a01f106 100644 --- a/doc/cref.txt +++ b/doc/cref.txt @@ -14,7 +14,7 @@ SLsmg_fill_region DESCRIPTION - The `SLsmg_fill_region' function may be used to a + The `SLsmg_fill_region' function may be used to a rectangular region with the character `ch' in the current color. The rectangle's upper left corner is at row `r' and column `c', and spans `nr' rows and `nc' columns. The position @@ -78,10 +78,10 @@ SLsmg_suspend_smg `SLsmg_suspend_smg' can be used to suspend the state of the screen management facility during suspension of the program. Use of this function will reset the display back to its default state. The - funtion `SLsmg_resume_smg' should be called after suspension. - + funtion `SLsmg_resume_smg' should be called after suspension. + It returns zero upon success, or -1 upon error. - + This function is similar to `SLsmg_reset_smg' except that the state of the display prior to calling `SLsmg_suspend_smg' is saved. @@ -169,7 +169,7 @@ SLsmg_reverse_video void SLsmg_reverse_video (void); DESCRIPTION - This function is nothing more than `SLsmg_set_color(1)'. + This function is nothing more than `SLsmg_set_color(1)'. SEE ALSO SLsmg_set_color @@ -273,7 +273,7 @@ SLsmg_vprintf SLsmg_write_string SYNOPSIS - Write a character string on the display + Write a character string on the display USAGE void SLsmg_write_string (char *s) @@ -334,7 +334,7 @@ SLsmg_write_nchars `SLsmg_write_nchars' writes at most `n' characters from the string `s' to the display. If the length of `s' is less than `n', the whole length of the string will get written. - + This function differs from `SLsmg_write_nstring' in that `SLsmg_write_nstring' will pad the string to write exactly `n' characters. `SLsmg_write_nchars' does not perform any @@ -454,11 +454,11 @@ SLsmg_init_smg terminal's physical display in the proper state. It is up to the caller to make sure that the `SLtt' routines are initialized via `SLtt_get_terminfo' before calling `SLsmg_init_smg'. - + This function should also be called any time the size of the physical display has changed so that it can reallocate a new virtual display to match the physical display. - + It returns zero upon success, or -1 upon failure. SEE ALSO @@ -513,7 +513,7 @@ SLsmg_set_screen_start is `NULL', then the corresponding value will be set to `0'. Otherwise, the location specified by the pointers will be updated to reflect the old origin. - + See \tt{slang/demo/pager.c} for how this function may be used to scroll horizontally. @@ -569,9 +569,9 @@ SLsmg_draw_object object is really a character from the alternate character set and may be specified using one of the following constants: - SLSMG_HLINE_CHAR Horizontal line - SLSMG_VLINE_CHAR Vertical line - SLSMG_ULCORN_CHAR Upper left corner + SLSMG_HLINE_CHAR Horizontal line + SLSMG_VLINE_CHAR Vertical line + SLSMG_ULCORN_CHAR Upper left corner SLSMG_URCORN_CHAR Upper right corner SLSMG_LLCORN_CHAR Lower left corner SLSMG_LRCORN_CHAR Lower right corner @@ -814,7 +814,7 @@ SLclass_allocate_class that defines a new data type or class called `name'. If successful, a pointer to the class is returned, or upon failure the function returns `NULL'. - + This function does not automatically create the new data type. Callback functions must first be associated with the data type via functions such as `SLclass_set_push_function', and the the data @@ -844,22 +844,22 @@ SLclass_register_class The `SLclass_register_class' function is used to register a new class or data type with the interpreter. If successful, the function returns `0', or upon failure, it returns `-1'. - + The first parameter, `cl', must have been previously obtained via the `SLclass_allocate_class' function. - + The second parameter, `type' specifies the data type of the new class. It must be an unsigned character with value greater that `127'. The values in the range `0-127' are reserved for internal use by the library. - + The size that the data type represents in bytes is specified by the third parameter, `sizeof_type'. This value should not be confused with the sizeof the structure that represents the data type, unless the data type is of class `SLANG_CLASS_TYPE_VECTOR' or `SLANG_CLASS_TYPE_SCALAR'. For pointer objects, the value of this parameter is just `sizeof(void *)'. - + The final parameter specifies the class type of the data type. It must be one of the values: @@ -871,17 +871,17 @@ SLclass_register_class The `SLANG_CLASS_TYPE_SCALAR' indicates that the new data type is a scalar. Examples of scalars in `SLANG_INT_TYPE' and `SLANG_DOUBLE_TYPE'. - + Setting `class_type' to SLANG_CLASS_TYPE_VECTOR implies that the new data type is a vector, or a 1-d array of scalar types. An example of a data type of this class is the `SLANG_COMPLEX_TYPE', which represents complex numbers. - + `SLANG_CLASS_TYPE_PTR' specifies the data type is of a pointer type. Examples of data types of this class include `SLANG_STRING_TYPE' and `SLANG_ARRAY_TYPE'. Such types must provide for their own memory management. - + Data types of class `SLANG_CLASS_TYPE_MMT' are pointer types except that the memory management, i.e., creation and destruction of the type, is handled by the interpreter. Such a type is called a @@ -917,7 +917,7 @@ SLclass_set_string_function type, and the address of the object for which a string represetation is required. The callback function must return a _malloced_ string. - + Upon success, `SLclass_set_string_function' returns zero, or upon error it returns -1. @@ -928,12 +928,12 @@ SLclass_set_string_function char *string_and_int_callback (unsigned char type, VOID_STAR addr) { char buf[64]; - + switch (type) { case SLANG_STRING_TYPE: return SLmake_string (*(char **)addr); - + case SLANG_INTEGER_TYPE: sprintf (buf, "%d", *(int *)addr); return SLmake_string (buf); @@ -968,7 +968,7 @@ SLclass_set_destroy_function When called, `destroy_fun' will be passed two arguments: a unsigned char which represents the data type, and the address of the object to be destroyed. - + `SLclass_set_destroy_function' returns zero upon success, and -1 upon failure. @@ -1006,12 +1006,12 @@ SLclass_set_push_function `SLclass_set_push_function' is used to set the push callback for a new data type specified by `cl', which must have been previously obtained via `SLclass_allocate_class'. - + The parameter `push_fun' is a pointer to the push callback. It is required to take two arguments: an unsigned character representing the data type, and the address of the object to be pushed. It must return zero upon success, or -1 upon failure. - + `SLclass_set_push_function' returns zero upon success, or -1 upon failure. @@ -1045,14 +1045,14 @@ SLclass_set_pop_function `SLclass_set_pop_function' is used to set the callback for popping an object from the stack for a new data type specified by `cl', which must have been previously obtained via - `SLclass_allocate_class'. - + `SLclass_allocate_class'. + The parameter `pop_fun' is a pointer to the pop callback function, which is required to take two arguments: an unsigned character representing the data type, and the address of the object to be popped. It must return zero upon success, or -1 upon failure. - + `SLclass_set_pop_function' returns zero upon success, or -1 upon failure. @@ -1083,7 +1083,7 @@ SLclass_get_datatype_name data type specified by `type'. For example, if `type' is `SLANG_INT_TYPE', the string `"Integer_Type"' will be returned. - + This function returns a pointer that should not be modified or freed. SEE ALSO @@ -1223,8 +1223,8 @@ SLang_exit_error displays an error message using a `printf' type variable argument list. The default behavior to this function is to write the message to `stderr' and exit with the `exit' system - call. - + call. + If the the function pointer `SLang_Exit_Error_Hook' is non-NULL, the function to which it points will be called. This permits an application to perform whatever cleanup is necessary. @@ -1250,7 +1250,7 @@ SLang_init_slang applications that use the S-Lang interpreter. It initializes the interpreter, defines the built-in data types, and adds a set of core intrinsic functions. - + The function returns `0' upon success, or `-1' upon failure. SEE ALSO @@ -1341,7 +1341,7 @@ SLadd_intrin_fun_table parameter, `tbl' specifies the table to be added. The second parameter `pp_name', if non-NULL will be added to the list of preprocessor symbols. - + This function returns -1 upon failure or zero upon success. NOTES @@ -1367,7 +1367,7 @@ SLadd_intrin_var_table parameter, `tbl' specifies the table to be added. The second parameter `pp_name', if non-NULL will be added to the list of preprocessor symbols. - + This function returns -1 upon failure or zero upon success. NOTES @@ -1392,7 +1392,7 @@ SLang_load_file specified by `fn' and feeds it to the interpreter, line by line, for execution. If `fn' is `NULL', the function will take input from `stdin'. - + If no error occurs, it returns `0'; otherwise, it returns `-1', and sets `SLang_Error' accordingly. For example, if it fails to open the file, it will return `-1' with @@ -1427,7 +1427,7 @@ SLang_restart intact. Any time the stack is believed to be trashed, this routine should be called with a non-zero argument (e.g., if `setjmp'/`longjmp' is called). - + Calling `SLang_restart' does not reset the global variable `SLang_Error' to zero. It is up to the application to reset that variable to zero after calling `SLang_restart'. @@ -1436,7 +1436,7 @@ SLang_restart while (1) { - if (SLang_Error) + if (SLang_Error) { SLang_restart (1); SLang_Error = 0; @@ -1466,7 +1466,7 @@ SLang_byte_compile_file will have the name exmp{init.slc}. The meaning of the second parameter, `reserved', is reserved for future use. For now, set it to `0'. - + The function returns zero upon success, or `-1' upon error and sets SLang_Error accordingly. @@ -1487,7 +1487,7 @@ SLang_autoload `slang' function name `funct' with the file `filename' such that if `funct' has not already been defined when needed, it will be loaded from `filename'. - + `SLang_autoload' has no effect if `funct' has already been defined. Otherwise it declares `funct' as a user-defined S-Lang function. It returns `0' upon success, or `-1' upon error. @@ -1618,7 +1618,7 @@ SLang_pop_string The `SLpop_string' function pops a string from the stack and returns it as a malloced pointer via `strptr'. After the function returns, the integer pointed to by the second parameter - will be set to a non-zero value if `*strptr' should be freed via + will be set to a non-zero value if `*strptr' should be freed via `free' or `SLfree'. If successful, `SLpop_string' returns zero. However, if the top stack item is not of type `SLANG_STRING_TYPE', or the stack is empty, the function will @@ -1665,7 +1665,7 @@ SLang_pop_slstring `SLang_free_slstring' is the preferred function for popping strings. This is a result of the fact that the interpreter uses hashed strings as the native representation for string data. - + One must _never_ free a hashed string using `free' or `SLfree'. In addition, one must never make any attempt to modify a hashed string and doing so will result in memory @@ -2021,10 +2021,10 @@ SLexecute_function { double sum, x, y; SLang_Name_Type *nt; - + if (NULL == (nt = SLang_get_function (fname))) return -1; - + sum = 0; for (x = 0; x < 10.0; x += 0.1) { @@ -2036,7 +2036,7 @@ SLexecute_function return -1; if (-1 == SLang_pop_double (&y, NULL, NULL)) return -1; - + sum += y; } return sum; @@ -2260,7 +2260,7 @@ SLcalloc DESCRIPTION This function uses `calloc' to allocate memory for `num_elem' objects with each of size `elem_size' and returns - the result. In addition, the newly allocated memory is zeroed. + the result. In addition, the newly allocated memory is zeroed. Upon error it returns `NULL'; otherwise it returns a pointer to the allocated memory. One should use `SLfree' to free the memory after used. @@ -2304,8 +2304,8 @@ SLrealloc memory block specified by `ptr' to the new size `new_size'. If `ptr' is `NULL', the function call is equivalent to `SLmalloc(new_size)'. Similarly, if `new_size' is zero, - the function call is equivalent to `SLfree(ptr)'. - + the function call is equivalent to `SLfree(ptr)'. + If the function fails, or if `new_size' is zero, `NULL' is returned. Otherwise a pointer is returned to the (possibly moved) new block of memory. @@ -2330,8 +2330,8 @@ SLcurrent_time_string "Wed Dec 10 12:50:28 1997" However, unlike the `ctime' function, a newline character is not - present in the string. - + present in the string. + The returned value points to a statically allocated memory block which may get overwritten on subsequent function calls. @@ -2369,7 +2369,7 @@ SLang_pop_fileptr DESCRIPTION `SLang_pop_fileptr' pops a file pointer from the S-Lang run-time stack. It returns zero upon success, or -1 upon failure. - + A S-Lang file pointer (SLANG_FILEPTR_TYPE) is actually a memory managed object. For this reason, `SLang_pop_fileptr' also returns the memory managed object via the argument list. It is up @@ -2387,12 +2387,12 @@ SLang_pop_fileptr SLang_MMT_Type *mmt; FILE *fp; int status; - + if (-1 == SLang_pop_double (&d, NULL, NULL)) return -1; if (-1 == SLang_pop_fileptr (&mmt, &fp)) return -1; - + status = fwrite (&d, sizeof (double), 1, fp); SLang_free_mmt (mmt); return status; @@ -2403,7 +2403,7 @@ SLang_pop_fileptr define write_some_values () { variable fp, d; - + fp = fopen ("myfile.dat", "wb"); if (fp == NULL) error ("file failed to open"); @@ -2451,7 +2451,7 @@ SLadd_intrinsic_function to the function. The variable argument list following `nargs' must consists of `nargs' integers which specify the data type of each argument. - + The function returns zero upon success or -1 upon failure. EXAMPLE @@ -2464,7 +2464,7 @@ SLadd_intrinsic_function { msg_error ("Access denied."); return -1; - } + } return SLsystem (cmd); } @@ -2504,7 +2504,7 @@ SLadd_intrinsic_variable data type of the variable. If the fourth parameter, `rdonly', is non-zero, the variable will interpreted by the interpreter as read-only. - + If successful, `SLadd_intrinsic_variable' returns zero, otherwise it returns -1. @@ -2629,17 +2629,17 @@ SLang_init_tty input. If the first parameter `intr_ch' is in the range 0-255, it will be used as the interrupt character, e.g., under Unix this character will generate a `SIGINT' signal. Otherwise, if it is - `-1', the interrupt character will be left unchanged. - + `-1', the interrupt character will be left unchanged. + If the second parameter `no_flow_ctrl' is non-zero, flow control (`XON'/`XOFF') processing will be - enabled. - + enabled. + If the last parmeter `opost' is non-zero, output processing by the terminal will be enabled. If one intends to use this function in conjunction with the S-Lang screen management routines (`SLsmg'), this paramete shold be set to zero. - + `SLang_init_tty' returns zero upon success, or -1 upon error. NOTES @@ -2650,7 +2650,7 @@ SLang_init_tty and the generation of other signals via the keyboard is disabled. However, generation of the job control signal `SIGTSTP' is possible via the `SLtty_set_suspend_state' function. - + Under Unix, the integer variable `SLang_TT_Read_FD' is used to specify the input descriptor for the terminal. If `SLang_TT_Read_FD' represents a terminal device as determined @@ -2661,11 +2661,11 @@ SLang_init_tty used. So, if you prefer to use `stdin' for input, then set `SLang_TT_Read_FD' to `fileno(stdin)' _before_ calling `SLang_init_tty'. - + If the variable `SLang_TT_Baud_Rate' is zero when this function is called, the function will attempt to determine the baud rate by querying the terminal driver and set `SLang_TT_Baud_Rate' to - that value. + that value. SEE ALSO SLang_reset_tty, SLang_getkey, SLtty_set_suspend_state @@ -2700,7 +2700,7 @@ SLtty_set_suspend_state disable keyboard generation of the `SIGTSTP' job control signal. If `s' is non-zero, generation of this signal via the terminal interface will be enabled, otherwise it will be disabled. - + This function should only be called after the terminal driver has be initialized via `SLang_init_tty'. The `SLang_init_tty' always disables the generation of `SIGTSTP' via the keyboard. @@ -2997,7 +2997,7 @@ SLang_do_key specified by the `getkey' function pointer and uses the key sequence to return the appropriate entry in the keymap specified by `kml'. - + `SLang_do_key' returns `NULL' if the key sequence is not defined by the keymap, otherwise it returns a pointer to an object of type `SLang_Key_Type', which is defined in `slang.h' as @@ -3020,7 +3020,7 @@ SLang_do_key unsigned char str[SLANG_MAX_KEYMAP_KEY_SEQ + 1];/* key sequence */ } SLang_Key_Type; - + The `type' field specifies which field of the union `f' should be used. If `type' is `SLKEY_F_INTERPRET', then @@ -3091,8 +3091,8 @@ SLang_process_keystring 1). In addition, if the key sequence contains constructs such as `^(XX)', where `XX' represents a two-character termcap specifier, the termcap escape sequence will be looked up and - substituted. - + substituted. + Upon success, `SLang_process_keystring' returns a raw key-sequence whose first character represents the total length of the key-sequence, including the length specifier itself. It returns @@ -3179,12 +3179,12 @@ SLextract_list_element unsigned int nth; char **a; char buf[1024]; - + /* Determine the size of the array */ nth = 0; while (0 == SLextract_list_element (list, nth, delim, buf, sizeof(buf))) nth++; - + ap = (char **) SLmalloc ((nth + 1) * sizeof (char **)); nth = 0; while (0 == SLextract_list_element (list, nth, delim, buf, sizeof(buf))) diff --git a/doc/erlslang.txt b/doc/erlslang.txt index b647c96..db423ed 100644 --- a/doc/erlslang.txt +++ b/doc/erlslang.txt @@ -1,6 +1,6 @@ slang Library erlang Programmer's Guide, V1.0 Claes Wikstrom, klacke@bluetail.com - Adopted to erlang from the original + Adopted to erlang from the original document by John E. Davis, davis@space.mit.edu Thu Dec 14 00:05:42 CET 2000 @@ -155,7 +155,7 @@ develop sophisticated platform-independent software. In addition to providing the S-Lang extension language, the library provides facilities for screen management, keymaps, low-level terminal I/O, - etc. + etc. This document describes the slang API for erlang programmers. Slang itself is a progaming language in its own right and @@ -343,7 +343,7 @@ Example: - %% For MSDOS, use 34 as scan code + %% For MSDOS, use 34 as scan code case slang:init_tty(7,0,0) of -1 -> io:format("Failed to initialize tty ~n",[]), @@ -499,16 +499,16 @@ loop() -> io:format("\nPress any key. To quit, press Ctrl-G: ", []), case slang:input_pending (50) of %% 5secs - 0 -> + 0 -> io:format("waited toooo long ~n",[]), ok; _ -> Ch = slang:getkey(), case slang:getvar(error) of - ?USER_BREAK -> + ?USER_BREAK -> io:format("Ctrl-G pressed ~n",[]), - - + + { fputs ("Waited too long! Bye\n", stdout); break; diff --git a/include.mk b/include.mk index 9905e80..3a1bc5e 100644 --- a/include.mk +++ b/include.mk @@ -1,6 +1,6 @@ CC=gcc -ERLDIR=/usr/local/lib/erlang +ERLDIR=/usr/lib/erlang SLANG_INCLUDE=/usr/include/slang LD_SHARED=ld -shared diff --git a/slang.pub b/slang.pub index 2d3d4bd..94c7b81 100644 --- a/slang.pub +++ b/slang.pub @@ -5,7 +5,3 @@ {keywords, ["quack"]}. {needs, []}. {abstract,"This is a library which makes it possible to write terminal based aplications al'a vi/emacs/mutt/slrn in erlang."}. - - - - diff --git a/src/Makefile b/src/Makefile index b383c01..dc7fa4b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,12 +11,12 @@ include ../include.mk include ../vsn.mk ERLC_FLAGS+=-W $(DEBUG_FLAGS) -MODULES = slang +MODULES = slang TARGETS = $(MODULES:%=../ebin/%.beam) ../ebin/slang.app -all debug: $(TARGETS) +all debug: $(TARGETS) clean: rm -f $(TARGETS) ../ebin/slang.app: slang.app.src diff --git a/src/slang.erl b/src/slang.erl index eca5507..e90501a 100644 --- a/src/slang.erl +++ b/src/slang.erl @@ -17,13 +17,13 @@ stop_user() -> Flag=process_flag(trap_exit, true), {links, Lks0} = process_info(whereis(user),links), Lks = lists:delete(whereis(error_logger), Lks0), - + Hs = gen_event:which_handlers(error_logger), - + case lists:member(error_logger_tty_h, Hs) of true -> error_logger:delete_report_handler(error_logger_tty_h), - + supervisor:terminate_child(kernel_sup, user), lists:foreach(fun(Pid) -> @@ -56,8 +56,8 @@ wait_user(_) -> init_tty(AbortChar, FlowControl, Opost) -> P = gp(), - p_cmd(P, ?INIT_TTY, [{int, AbortChar}, - {int, FlowControl}, + p_cmd(P, ?INIT_TTY, [{int, AbortChar}, + {int, FlowControl}, {int, Opost}], int32). set_abort_signal(null) -> @@ -122,7 +122,7 @@ signal(Sig, Fun) -> smg_fill_region (R, C, Nr, Nc, Ch) -> P = gp(), p_cmd(P,?SMG_FILL_REGION, [{int,R}, {int, C}, - {int, Nr}, {int, Nc}, + {int, Nr}, {int, Nc}, {char, Ch}], void). smg_set_char_set (A) -> @@ -194,7 +194,7 @@ smg_write_nchars (S, N) -> smg_write_wrapped_string (S, R, C, Nr, Nc, Fill) -> P = gp(), p_cmd(P, ?SMG_WRITE_WRAPPED_STRING, [{string, S},{int, R}, {int, C}, - {int, Nr}, {int, Nc}, {int, Fill}], + {int, Nr}, {int, Nc}, {int, Fill}], void). smg_cls () -> @@ -324,7 +324,7 @@ p_cmd(P, Op, ArgList, Expect) -> end. rec_loop(P, Expect, Sig) -> - receive + receive {P, {data, [1 |What]}} -> {expect(What, Expect), Sig}; {P, {data, [0 , X1, X2, X3, X4]}} -> @@ -338,7 +338,7 @@ rec_loop(P, Expect, Sig) -> {'EXIT', P, Reason} -> exit(Reason) after 200 -> - P ! {self(), {command, [255]}}, % tick + P ! {self(), {command, [255]}}, % tick rec_loop(P, Expect, Sig) end. @@ -378,7 +378,7 @@ mk_args([{smg_char_type, Str} |Tail]) when list(Str) -> Len = 2 * length(Str), List = [?int32(Len) | lists:map(fun(I) -> ?int16(I) end, Str)] , [List| mk_args(Tail)]. - + open_slang_driver() -> erl_ddll:start(), @@ -628,17 +628,17 @@ debug(File, Line, Fmt, Args) -> Fd -> Fd end, - + Str = lists:flatten( io_lib:format("DEBUG ~s:~p, pid ~w: ~n", - [filename:basename(File), + [filename:basename(File), Line, self()])), - + case io:format(DFD, Str ++ Fmt ++ "~n", Args) of ok -> ok; _ -> io:format(DFD, "ERROR ~p:~p: Pid ~w: (bad format)~n~p,~p~n", [File, Line, self(), Fmt, Args]), - + ok end. diff --git a/src/slang_int.hrl b/src/slang_int.hrl index 0d47f7f..cdb21e9 100644 --- a/src/slang_int.hrl +++ b/src/slang_int.hrl @@ -1,7 +1,7 @@ %%%---------------------------------------------------------------------- %%% File : slang_int.hrl %%% Author : Claes Wikstrom -%%% Purpose : +%%% Purpose : %%% Created : 5 Dec 2000 by Claes Wikstrom %%%---------------------------------------------------------------------- @@ -138,17 +138,17 @@ -define(int24(X), [((X) bsr 16) band 16#ff, ((X) bsr 8) band 16#ff, (X) band 16#ff]). --define(int32(X), +-define(int32(X), [((X) bsr 24) band 16#ff, ((X) bsr 16) band 16#ff, ((X) bsr 8) band 16#ff, (X) band 16#ff]). %% Bytes to unsigned --define(u64(X7,X6,X5,X4,X3,X2,X1,X0), +-define(u64(X7,X6,X5,X4,X3,X2,X1,X0), ( ((X7) bsl 56) bor ((X6) bsl 48) bor ((X5) bsl 40) bor - ((X4) bsl 32) bor ((X3) bsl 24) bor ((X2) bsl 16) bor + ((X4) bsl 32) bor ((X3) bsl 24) bor ((X2) bsl 16) bor ((X1) bsl 8) bor (X0) )). --define(u32(X3,X2,X1,X0), +-define(u32(X3,X2,X1,X0), (((X3) bsl 24) bor ((X2) bsl 16) bor ((X1) bsl 8) bor (X0))). -define(u24(X2,X1,X0), @@ -156,20 +156,20 @@ -define(u16(X1,X0), (((X1) bsl 8) bor (X0))). - + -define(u8(X0), (X0)). %% Bytes to signed -define(i32(X3,X2,X1,X0), - (?u32(X3,X2,X1,X0) - + (?u32(X3,X2,X1,X0) - (if (X3) > 127 -> 16#100000000; true -> 0 end))). -define(i24(X2,X1,X0), - (?u24(X2,X1,X0) - + (?u24(X2,X1,X0) - (if (X2) > 127 -> 16#1000000; true -> 0 end))). - + -define(i16(X1,X0), - (?u16(X1,X0) - + (?u16(X1,X0) - (if (X1) > 127 -> 16#10000; true -> 0 end))). -define(i8(X0), -- cgit v1.2.3