S-Lang (language interpreter)
Jan 30, 2019 23:32:20 GMT 1
Post by alexfish on Jan 30, 2019 23:32:20 GMT 1
Hi All
Whilst looking for a better way to do a poor mans terminal >
I stumbled on S-lang:
Will Need libslang2-dev
possible find here the following files
have tested all in c but have done a quick demo in Bacon
if wanting to continue: best look at smgtest.c | also thinking in terms of Joes work on the RPI GPIO pins
Example of Embedding S-lang in Bacon
Have Fun
+
BR
Alex
Whilst looking for a better way to do a poor mans terminal >
I stumbled on S-lang:
The S-Lang library includes the following:
* Low level tty input routines for reading single characters at a time.
* Keymap routines for defining keys and manipulating multiple keymaps.
* A high-level key processing interface (SLkp) for
handling function and arrow keys.
* High level screen management routines for manipulating both
monochrome and color terminals. These routines are very
efficient. (SLsmg)
* Low level terminal-independent routines for manipulating the display
of a terminal. (SLtt)
* Routines for reading single line input with line editing and recall
capabilities. (SLrline)
* Searching functions: both ordinary searches and regular expression
searches. (SLsearch)
* An embedded stack-based language interpreter with a C-like syntax.
* Low level tty input routines for reading single characters at a time.
* Keymap routines for defining keys and manipulating multiple keymaps.
* A high-level key processing interface (SLkp) for
handling function and arrow keys.
* High level screen management routines for manipulating both
monochrome and color terminals. These routines are very
efficient. (SLsmg)
* Low level terminal-independent routines for manipulating the display
of a terminal. (SLtt)
* Routines for reading single line input with line editing and recall
capabilities. (SLrline)
* Searching functions: both ordinary searches and regular expression
searches. (SLsearch)
* An embedded stack-based language interpreter with a C-like syntax.
Will Need libslang2-dev
possible find here the following files
/usr/share/doc/libslang2-dev/examples/README
/usr/share/doc/libslang2-dev/examples/demolib.c
/usr/share/doc/libslang2-dev/examples/keypad.c
/usr/share/doc/libslang2-dev/examples/pager.c
/usr/share/doc/libslang2-dev/examples/smgtest.c
/usr/share/doc/libslang2-dev/examples/useropen.c
have tested all in c but have done a quick demo in Bacon
if wanting to continue: best look at smgtest.c | also thinking in terms of Joes work on the RPI GPIO pins
Example of Embedding S-lang in Bacon
PRAGMA LDFLAGS -lslang
PRAGMA INCLUDE <slang.h>
OPTION PARSE FALSE
LOCAL abort_char = 7 TYPE int
LOCAL ch TYPE unsigned char
IF (-1 == SLang_init_tty (abort_char, 0, 1)) THEN
PRINT "Unable to initialize the terminal"
END IF
' Disable Ctrl_
SLang_set_abort_signal (NULL);
WHILE (1) DO
PRINT "Press any key. To quit , press Ctlr-G"
' can increase or decrease input pending
IF (SLang_input_pending (50) == 0) THEN
PRINT "waited to long Bye"
BREAK
END IF
ch = SLang_getkey()
IF (SLang_get_error () == SL_UserBreak_Error) THEN
PRINT "Ctrl-G pressed! Bye"
BREAK
END IF
PRINT CHR$(ch)
WEND
SLang_reset_tty ();
Have Fun
+
BR
Alex