Editra and kill processes

For the Compleat Fan
Locked
noiv
Posts: 2
Joined: Fri Sep 12, 2008 1:25 pm
Location: Cologne
Contact:

Editra and kill processes

Post by noiv »

I found 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 thread and gives some essential tips.

Many thanks.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

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
Posts: 65
Joined: Sat Sep 06, 2008 6:30 am

on folding and programming editors.

Post by unixtechie »

cormullion wrote: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
Posts: 2
Joined: Fri Sep 12, 2008 1:25 pm
Location: Cologne
Contact:

Post by noiv »

cormullion wrote: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:

Code: Select all

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
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

noiv wrote: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:

Code: Select all

;; 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) "\r\n"))
			(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...

Locked