Editra and kill processes

Started by noiv, September 20, 2008, 04:52:52 AM

Previous topic - Next topic

noiv

I found http://editra.org/">Editra as editor quite convenient. The interface is easy to use, has all I need like syntax highlighting, code folding and project support. However, there seem to be a problem in doing remote control with newLisp and/or the guiserver. I've tried to help the developer with all what I can do (not that much).



What we like to achieve is having the console messages within the launcher and to start and stop newLisp scripts. It would be very kind if someone (eventually with some python knowhow) jumps in this http://editra.org/forum/viewtopic.php?p=610#610">thread and gives some essential tips.



Many thanks.

Lutz

#1
The editor in the Java based newLISP IDE does similar things, which may be some help to make it going on Editra.



The relevant file to look at is:



newlisp-9.4.5/guiserver/java/TextAreaWidget.java



the functions:



- runShell() which runs newLISP with a program, e.g: newlisp button-demo.lsp



- setupShell() establishes piped between the shell and the newLISP process std I/O



- destroyShell() destroys the newLISP process



I assume that in Editra the steps are basically similar. Perhaps looking at the Java code helps.

cormullion

#2
Editra looks good - trying it out.



You say it's good at highlighting newLISP syntax - does that require a download or something? There's nothing in the editor that says 'newLISP' rather than LISP...

unixtechie

#3
Quote from: "cormullion"Editra looks good - trying it out.


heh, there are literally HUNDREDS of programming editors.

I usually use "joe", it has familiar keystrokes and its colouring config file is easy to edit.



But specifically for folding I (after looking around a bit)  found "fte" (or "nfte"). It allows one to insert folding marks in the whole file according to a regular expression!

Less necessary for Lisp, probably, but I use it in longer scripts in procedural languages and like the ability to actually see in one glance the structure of the script.



To know where to fold the  editor puts some markers at the end of the lines after the comment delimit character for the given language.



FTE configuration is also not that difficult to figure out, so I did (somewhat roughly) colouring of NewLisp keywords and comments, and live happily.



As a unix guy I obviously use vi, but have never taken to emacs, strongly prefer those that can be run in an xterm window, and just ignore all kinds of IDE "integration", simply running make or my scripts in a separate window. I sort of fail to understand why that should be incorporated into an editor too.

noiv

#4
Quote from: "cormullion"highlighting newLISP syntax - does that require a download or something?


Yes - the latest source includes the newLisp Lexer. Despite any dependencies all you need is: svn checkout http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/Editra Editra
sudo python setup.py install

But, are there any more ideas in regard to the original problem?? Is there any other editor using shell out and abort?

cormullion

#5
Quote from: "noiv"But, are there any more ideas in regard to the original problem?? Is there any other editor using shell out and abort?


A bit over my head, all this low level stuff, but I'll throw out some random ideas. The newLISP-GS editor does this:


;; script-handler, saves current edit tab to a temporary file
;; and passes the file name as an argument to the script
;; scripts are registered in the settings file
;; scripts must exit or newlisp-edit will hang.
(define (script-handler id)
(letn ( (idx (int (10 id))) (S (config:currentScripts idx)))
(set 'currentScriptFile (S 1))
(if (file? currentScriptFile)
(begin
(set 'currentScriptMode (S 2))
(if (= currentScriptMode "selection")
(gs:get-selected-text currentEdit 'script-execute)
; else "content"
    (gs:get-text currentEdit 'script-execute))
)
(output-monitor (string ";--- could not find script " currentScriptFile " ---n"))
)
)
)

(define (script-execute id text)
(if (not text) (set 'text "===="))
(let (file (string $TEMP "/" (uuid)))
(if (= ostype "Win32")
(write-file file (replace "n" (base64-dec text) "rn"))
(write-file file (base64-dec text)))
(if (= ostype "Win32")
(catch (exec (string {newlisp.exe "} currentScriptFile {" } file " > " (string file "out"))) 'result)
(catch (exec (string "/usr/bin/newlisp " currentScriptFile " " file)) 'result)
)
(if (list? result)
(begin
(set 'result (if (= ostype "Win32")
(read-file (string file "out"))
  (join result "n")))
(if (= currentScriptMode "selection")
(paste-action result)
(if (= ostype "Win32")
(output-monitor result)
(output-monitor (string result "n")))
)
)
(output-monitor result)
)
(if (= ostype "Win32") (delete-file (string file "out")))
(delete-file file)
)
)


As it says, the script has to exit when it's finished, otherwise the editor stops.



Could the script be executed using spawn and sync? Then you could just send an abort to kill the processes.



Having written that, perhaps all this has to be written in the editor in question, in Python, rather than newLISP...