Unix readline/editline?
J Arcane (2729) 8 posts |
I’m new to Risc OS, and a bit of a Lisp/Scheme fanatic (my current day job is in Clojure even), and since it seems all the Lisps available for Risc OS date before the 32-bit switch, I thought it might be a fun first project to get to work on writing one following the Build Your Own Lisp book (which doubles as a C tutorial, something I could use as well). I’ve hit a bit of a snag, however. In order to support proper line editing the book’s code makes use of the readline-compatible editline library on non-Windows platforms, but I’ve been unable to locate a build of editline or readline for Risc OS anywhere. I’ve tried building the GNU readline and Minix editline libs, but just running the configure scripts makes Wimp freak out. I can default back to the Windows code I suppose, and just make do with the awful input editing behavior for now, but it really seems like this should be out there somewhere or doable. Anyone know? |
Steve Pampling (1551) 7928 posts |
My first thought was to look on riscos.info to see if anything had been ported – but it seems not. However dibbling through the stuff on there will probably give you the pointers needed to attempt a port yourself.
Do bear in mind that RISC OS is not any kind of ****x variant so you need to sort out your own make file. |
J Arcane (2729) 8 posts |
Yeah, I suspected it wouldn’t be that simple, but I gave it a shot anyway. Alas, I’m fairly C-illiterate (part of the reason I wanted to work through this book), I know some of the very basics but I don’t even know Make yet. I see the GCCSDK is able to do cross-compiling stuff, but I’d imagine that would similarly take some makefile tweaks to work as well. Perhaps I’d be better off with something in Lua or BBC Basic for now. :) EDIT: Also, I just discovered that Nettle has it’s own line editor window, which is good enough really, so I can probably keep going and just use the Windows readline-less code in the book instead. |
Steve Pampling (1551) 7928 posts |
We could form a club.
Using the OS_Readline SWI? PRM’s are on the net if you don’t like heavy paper tomes. |
Steve Fryatt (216) 2045 posts |
That depends. If it’s just using libraries that have already been ported, and you have access to a Linux box, the GCCSDK Autobuilder is intended to allow this kind of thing to be built with no changes. Because it’s on Linux, it just runs the configure scripts and uses the cross-compiler where required.
Er, no. OS_ReadLine isn’t in the same league. Olly Betts’ LineEditor module, which ships with Zap, might be worth a look if it’s fully ARMv7 compliant now. |
Steve Pampling (1551) 7928 posts |
Not seen any problems, but then I’m just using it for command line recall and edit in a task window. @J Commands : |
J Arcane (2729) 8 posts |
I think for my purposes the line editor window in Nettle is a good enough work around to keep going with the C project. RiscLua doesn’t bother either, after all, though !Bash does appear to have readline enabled; I wonder if maybe there is a compiled form of it somewhere and I just haven’t found it yet. Anyone know what the C preprocessor variable for detecting Risc OS is? EDIT: found it, __riscos works just fine. |
Ronald May (387) 407 posts |
!Bash does appear to have readline enabled History and improved editting keys work if you have the dot files in place. You need to use StrongEd with a few changes to the taskwindow mode file to let the arrow keys pass the ctrl key equivalents. I’m a bit out of touch with bash, as I’ve been working on dash, which doesn’t use libreadline, and so far I haven’t built it with the suggested libedit either. I’ve added a cat builtin so that it is used rather than worry about the OS cat(alogue) spoiling things. echo exec and printf are existing builtins which simplify the situation also. |
J Arcane (2729) 8 posts |
I’ve actually been using Nettle with an ANSI task running bash instead, as for some reason Zap crashes an awful lot when I use it for task windows. The line editor there is enough for me to get by for now, but I’ll have to remember that about StrongEd. I’ve been powering through the code today though, you can see what I’ve got up to so far here: https://github.com/jarcane/Risp |
Rick Murray (539) 13400 posts |
True, but then again the implementation in the current code is just fgets() from input, OS_ReadLine can do that… |
J Arcane (2729) 8 posts |
My next question is, how and why has my Ex command suddenly been hijacked, and how do I fix it? Now, instead of it printing my current directory, instead it leaps up to a 2-line section at the top of the task window and says ’Entering Ex mode. Type “visual” to go to Normal mode." Which does nothing. In fact, nothing seems to do anything once it does this, I have to close the Window and start another one. It didn’t use to do this, it only started a little while ago, and I’m not sure what even changed. Anyone know what this is? EDIT: I think I’ve found the problem: It’s Vim what does it. Somehow Vim hooks into Task Window. I installed it to try it out and now somehow it’s overriding commands in Task Window. :/ |
Ronald May (387) 407 posts |
It’s Vim what does it Well done on finding the variable at fault, that one kept me guessing for while. |
Fred Graute (114) 627 posts |
It looks like Vim sets up an alias for Ex. You can get at the original, unaliased, Ex by using: %Ex . |
Ronald May (387) 407 posts |
is just fgets() from input, OS_ReadLine can do that… Given that Olly Betts module works with the existing RISC OS clients (even the single tasking CLI) it would seem that one might only have to use OS_Readline or whatever !Edit or !Zap or !StrongED uses. |
Fred Graute (114) 627 posts |
Not sure if I can be of any help here, StrongED doesn’t use OS_ReadLine at all. The handling of TaskWindow input / output is all done via TaskWindow messages. The LineEditor module sits on ReadLineV so presumably works with anything that calls OS_ReadLine. The only thing to do if used from a TaskWindow is, as you’ve noticed, to make sure that the right keycodes are passed on to it. |
Ronald May (387) 407 posts |
StrongED doesn’t use OS_ReadLine at all Mmmm, I’m thinking the only criteria would be to get /any/ stdin through OSLib functions and equally to avoid the gcc header stdin functions, which inevitably use the termios/tty structure. |
J Arcane (2729) 8 posts |
After getting a bit fed up with with the book I was working with (I skipped ahead and discovered just how many subjects it skips entirely), I’ve been experimenting with some smaller Scheme compiler sources as possibly porting options. It turns out that Minischeme (the parent to TinyScheme) compiles quite happily with the SYSV option set, with only the minor tweak of having to change the init filename from “init.scm” to just “init”. TinyScheme itself, however, as well as one of the mini-CLs I tried, go looking for a dynamic linking library and fails (it looks for libdl, and doesn’t find it). I think I might be able to work around it though if I can make sense of the makefile options. TS is pretty configurable, though, and other than that snag compiles the rest of it without error, it just fails at the linking stage because it can’t find ld. |
Ronald May (387) 407 posts |
it just fails at the linking stage because it can’t find ld. You would find more people with technical answers on the gccsdk mailing list. I think that -ldl is one we dont have to use, have you tried just taking it out of the makefile/gcc command? |
J Arcane (2729) 8 posts |
A fair point. I should probably set up a subscription. And thanks for the tip about -static. Looks like I need to do some more reading. |
Ronald May (387) 407 posts |
thanks for the tip about -static When using -static with the native !GCC, I found that the /a version of the library needs to be in !GCC.arm-unknown-riscos.lib for the (eg.) -lm form to work. |
Ronald May (387) 407 posts |
I’ve actually been using Nettle with an ANSI task running bash instead Sorry about the delay, I have tried bash in !Nettle, and have found that for the readline line editing to work, The ansi window must be started with bash as the command, and not by opening the ansi task(window) first and then entering bash. Likewise for dash and it’s libedit2 version of readline. bash must have the HOME variable set in RISC OS before running, files /bashrc and /bash_history should be in that directory. /bashrc can be used to set some bash variables or alias’s, might not be needed always. |