Termux-Penti-PicoLisp

Terminals

xterm

fvwm

Termux

PentiKeyboard

Tmux

ssh

startTermux.mp4

The Penti Keyboard

pentiKeys.mp4

pentiArpeggio.mp4

F-Q

pentiRepeat.mp4

F-H

pentiHelp.mp4

Termux and Tmux

.profile

termux.mp4

Navigating Termux and Tmux Windows

.termux/termux.properties

shortcut.create-session = Ctrl + O shortcut.previous-session = Ctrl + P shortcut.next-session = Ctrl + N

Ctrl-O

Ctrl-P

Ctrl-N

navigateTermux.mp4

.profile

.tmux.conf

Ctrl-B + p

Ctrl-B + n

bind-key o new-window

set -g status-style "bg=yellow,fg=black"

Ctrl-B + s

bind-key s split-window -c '#{pane_current_path}'

navigateTmux.mp4

PicoLisp

picoLisp.mp4

Application Server

:~ ln -s /data/data/com.termux/files/usr/lib/picolisp/app

db/

:~ pil app/main.l @lib/too.l -main -go +

startApp.mp4

debugApp.mp4

*Top

modifyApp.mp4

PilBox

PilBox GUI

pilGui.mp4

repl

@lib/form.l

repl

repl.mp4

Android Toolbox

@lib/android.l

@lib/android.l

Notifications

notify

notify.mp4

notify

@lib/android.l

(de notify (Ttl Msg Id) (let B (java "android.support.v4.app.NotificationCompat$Builder" T CONTEXT) (java B 'setSmallIcon (java "de.software_lab.pilbox.R$drawable" "notify")) (java B 'setContentTitle Ttl) (java B 'setContentText Msg) (java B 'setAutoCancel T) (java B 'setLights `(hex "FFFFFF") 500 500) (java (java CONTEXT 'getSystemService "notification") # NotificationManager 'notify (or Id 0) (java B 'build) ) ) )

public void notify(String title, String msg, int id) { Notification.Builder b = new NotificationCompat.Builder(ctx); b.setSmallIcon(R.drawable.some_icon); b.setContentTitle(title); b.setContentText(msg); b.setAutoCancel(true); b.setLights(0xFFFFFF, 500, 500); NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE) manager.notify(id, b.build()); }

Reading the GPS position

gps

*LocMan

*LocLsn

gps.mp4

gps

@lib/android.l

(de gps () (unless *LocMan (setq *LocMan (java CONTEXT 'getSystemService "location") *LocLsn (java T "android.location.LocationListener") ) (def 'onLocationChanged *LocLsn '((Loc) (msg Loc " onLocationChanged") NIL ) ) (def 'onProviderDisabled *LocLsn '((Prov)) ) (def 'onProviderEnabled *LocLsn '((Prov)) ) (def 'onStatusChanged *LocLsn '((Prov Stat Extras)) ) (java *LocMan 'requestLocationUpdates "gps" '(L . 20000) (-3 . 100) *LocLsn) ) (when (java *LocMan 'isProviderEnabled "gps") (let? Loc (java *LocMan 'getLastKnownLocation "gps") (cons (+ (java Loc 'getLatitude) 90000000) (+ (java Loc 'getLongitude) 180000000) ) ) ) )

onLocationChanged

onProviderDisabled

onProviderEnabled

onStatusChanged

requestLocationUpdates

getLastKnownLocation

Taking Pictures

camera.mp4

(bar "Camera" (form NIL (<h3> "fh" "Camera") (form NIL (gui '(+Button) "Take Picture" '(android~takePicture (tmp "img") '((Intent) (setq *Picture (tmp "img")) (android~loadUrl (baseHRef) *SesId "app/camera.l") ) ) ) (----) (gui '(+Var +Img) '*Picture NIL NIL 400 400) ) ) )

@lib/android.l

(de takePicture (Dst Fun) (startActivityForResult Fun "android.media.action.IMAGE_CAPTURE" "output" (fileUri Dst) ) )

Dst

Intent

startActivityForResult

Rooted Devices

pilBox

rooted.mp4

:~ su -c 'exec bash --rcfile /data/data/de.software_lab.pilbox/files/abu'

.vimrc

pilBox

Since 2015 I do most of my software development on an Android tablet. I am a bit fed up with PCs and notebooks, as they are tedious to handle and have too many mechanical parts. A tablet is more convenient, it can be held in one hand, and usually survives if coffee is spilt over it.The obvious drawbacks of a tablet are a smaller screen size and the lack of a keyboard, but I can compensate these deficits mostly, and want to demonstrate this in the following.My preferred working style uses multiple terminal windows, some for editing with Vi, some running Bash, and some running PicoLisp. On a desktop these ares in anwindow manager.On Android I usewith the. Termux is an Android terminal emulator and Linux environment, and Penti is a chorded keyboard for Android.Termux can be found in stores like Google play or F-Droid.org.Termux windows I use theterminal multiplexer, both locally and on'd remote machines.Starting Termux automatically also starts a first Tmux window, here indicated by the yellow status line at the bottom:The white dotted circles are the Penti "keyboard". It is described and downloadable at https://software-lab.de/penti.html Penti has many advantages over the common type of virtual keyboards for touch screens, as it doesn't take up precious screen space, and supports all keys of a standard PC keyboard including punctuation and control characters, navigation and function keys etc., with just one or two touches. There are even "keys" for cut and paste, reset, restart and hide the whole keyboard, and direct numeric input forunicode character. The Japanese version also supports Kanji input.Penti distinguishes between "chords" (keys are pressed simultaneously) and "arpeggio" (keys are pressed one after the other).For example, pressing thumb and index finger together gives the letter "f", but pressing the thumb andthe index finger (while keeping the thumb down) means "shift", indicated by a large letter "S" above the circles.Pressing index finger and thumb in reverse order, gives a shift lock, and doing the same again releases the lock. Other arpeggio combinations result in punctuation, digits, control, alt and function keys.Special arpeggios are reserved for Backspace, Tab, Enter and Escape. And — for that matter — Ctrl-Z (suspend key), Ctrl-B (used a lot in Tmux) and Ctrl-Y.The sixth key in the middle is thekey. It repeats the last key that was typed, and does auto-repeat when pressed long enough. If pressed as arpeggio after the thumb, it repeats the one-before-last key.If the screen is pressed outside any circle, Penti is temporarily hidden and further touches go down to the underlying screen.(Function-Quit) closes Penti, it usually pops up again when any editable field on the screen is touched.Important to remember is the function key combinationfor "Help". It displays a help screen and is closed by any other key press.When the Bash in Termux starts up, it reads theinitiation file, which in turn checks whether it is the first instance, and if so, starts Tmux.Termux reads its initiation file. This defines three control key sequences for navigation:i.e.for "open new terminal",for "previous" andfor next terminal.Usually I have three Termux windows open, so I can get from any window to any other with a single keystroke ("previous" and "next" move cyclically).As we noted above, Tmux is started fromautomatically in the first Termux window. Tmux reads its configuration file. By default, Tmux navigates in a similar way, withfor "previous" andfor "next", so we add the definitionfor "open new window".The yellow status line at the bottom results fromI use colors on different machines.Withwe can split a Tmux window into two panes.When opening 3 Termux windows, each with 3 Tmux windows split into 2 panes each, we have 18 Bash terminal sessions open. Each of them can bewith maximally four keystrokes (e.g. Ctrl, N, Ctrl-B, n), and perhaps two additional keystrokes (Ctrl-B, j) toto the other pane. Hopefully, the colors in the status bar help not to get fully lost ;)PicoLisp is available as a Termux package:You can use it to develop and test normal PicoLisp applications.Let't take the "app/" demo that comes with the PicoLisp distribution.I don't want to clobber the installation directory, so I put a symbolic link into my Termux home directory:Then the demo application can be started (it will create adirectory in the current working directory):As always, connect your browser to the default port 8080, and run the application:The application can now be fully examined and debugged in the terminal. We can look at the object in the current form, and even edit it directly in the database or navigate to connected objects like the order's customer and positions/items:As a last example, let's modify the GUI while it is running. We edit the source of the current form (in theglobal variable), test it, and then open a "normal" editor in a split pane for a better overview and modify it again:A first brief description of the generic PilBox Android App appeared in https://www.mail-archive.com/picolisp@software-lab.de/msg07233.html . The tarball can be downloaded from https://software-lab.de/PilBox.tgz , and a more detailed description is in https://software-lab.de/PilBox/README This wiki also has an article at https://picolisp.com/wiki/?PilBox You can download the current APK from https://software-lab.de/pilBox.apk I don't want to repeat the descriptions here, so I just show some practical aspects of it usage.PilBox employs the standard PicoLisp GUI. In fact, the whole setup is identical, so that a normal PicoLisp application works right out of the box, including database and IPC. This is possible because the App starts up a normal PicoLisp Arm64 binary, and connects to it via the https://developer.android.com/reference/android/webkit/WebView.html component.The pre-packaged PilBox comes with a slightly modified "Phone GUI" demo from https://picolisp.com/wiki/?PhoneGUI . The single monolithic file was split into smaller fragments for better modularity, the start page modified, and some Android functionality was added.Going through some of the standard components:Tapping on the Logo always returns to the start page. When tapped a second time, however, it opens a REPL window (also in the standard GUI, thefunction in).Thecomponents also allows you to edit a source file directly in the App. Useful if you phone or tablet is not rooted. As an example, we edit and modify the very page where the REPL is shown, and insert a big "TEST !!!!" in the header.But PilBox can do much more than that. The big difference is that it has full access to the Android runtime system, allowing most things which are possible in a native App (as opposed to a plain browser-based WebApp).The demo App allows access to the Notification manager, GPS devices, camera and QR-Code scanner. The interface functions are all in, as included in the standard PicoLisp distribution.is an extension and improvement of the principles described in https://picolisp.com/wiki/?javaCode We can post an Android Notification directly from the REPL, with thefunction:Thefunction is defined inThis corresponds to the standard Java SDK code:As you see, it is a straight-forward translation.GPS can be read with thefunction. It uses Java objects like(Location Manager) and(Location Listener):Theis also defined inThe four methods of the LocationListener interface (and) are empty and currently unused. They could well be omitted. So what remains is just the creation of the LocationListener object, registering it with, and callingwhenever needed.The final two lines — offsetting the position with 90.0 and 180.0 — are necessary because the PicoLisp database wants to avoid negative coordinates in ' +UB ' trees.Taking a picture is easy:The GUI is justThe relevant function inistaking a destination file name inand a function accepting anfor handling the picture after it was taken. The workhorse for that is, a very powerful mechanism for finding and running another Activity (i.e. a Camera App).If you have rooted your device (recommended anyway for serious development work), then you don't have to bother with the REPL GUI.Instead, you can swich to theuser:The Termux command linepasses a small Bash source file ("abu" in my case), to set up some environment, aliases and other convenience stuff. I have also afile in thehome directory.In this way you can do virtuallywith the code. In principle you can replace it with a different App. The PilBox itself is completely generic. All modifications will remain until you re-install the app, so you should save and restore it appropriately.

https://picolisp.com/wiki/?termuxpentipicolisp