development release newLISP v. 9.1.10

Started by Lutz, July 27, 2007, 08:14:33 AM

Previous topic - Next topic

Lutz

- syntax highlighting in newLISP-GS editor

- misc. fixes and improvements in editor

- new functions in guiserver.lsp





files and changes notes: http://newlisp.org/downloads/development/">http://newlisp.org/downloads/development/



newLISP-GS documentation http://newlisp.org/guiserver/">http://newlisp.org/guiserver/



Lutz

cormullion

#1
Hey, Lutz - you've put in some key-event monitoring functions! Thanks!



I discovered that:


(gs:text-area 'TextArea 'key-action 0 0)

appears to work fine  - a 0 pixel square text area can have the focus and respond to key events... (Is it OK to do this?)

HPW

#2
The 'save settings' code for pos and size still seems not save the right values to restore the same pos/size on restart (on WIN classic GUI).



When I align the window on the left screen border and save settings I get a value 4. But when I restart I get a 4 pixel offset.

The top value is correct saved but it is the client area with 44 pixel.

But it is restored that way, so the window in on the top pixel of the screen.

Height and width seems also have some pixel different.



Is the syntax-highlighting configurable (file) or hard-coded?

The gs:xxxxx commands should get their own color-class.
Hans-Peter

Lutz

#3
about gs:key-event:



your work-around before having gs:key-event sounds a like good idea. When using gs:key-event, the same is true: you have to put the focus with gs:request-focus on the area for which gs:key-event is registered.



save settings of windows geometry:



I am still experimenting with this, and I am not sure, if this is the same on all platforms, it seems to retrieve client area coordinates but positions on screen coordinates. On Mac OS X, windows typically don't have left or right decoration, so the right/left pixel difference has escaped me so far. The top/bottom decorations, at least on Mac OS X, seem to be 44 pixels tall, and adjusting for it seems to work on Win32 too.





syntax highlighting:



at the moment the only way to customize is, to edit c:Program Filesnewlispnewlisp-edit.lsp or on OS X/Unix /usr/bin/newlisp-edit. The themes are currently configured in the three functions: viewtheme1-handler, viewtheme2-handler an viewtheme3-handler starting at line: 1226 with Theme1.



A future version will abstract the whole procedure and store all 10 color vectors required for all three themes in the settings file. May be, there will be a procedure to add and unlimited number of profiles, which will be added to the View menu on startup. The first 4 colors (background, foreground, caret and selection) are on, even if View/Syntax coloring is switched off. This way themes also influence non .lsp files, which are not syntax highlighted. I will probably also add a procedure for 'C' code highlighting, as this is the other language used frequently with newLISP for writing libraries.



If anybody has an interesting profile, than put it on the discussion board. Profiles look very different on different monitors and lightning conditions, so I recommend to try them on different machines if you have the possibility.



Last not least, I have not been able to find a nice fixed spaced font which is standard for all Win2k/XP/Vista. Which is why we have the current font, which does not look good. Perhaps some Windows Expert has a suggestion for an alternative font to use as the default.



Lutz

cormullion

#4
With the key-action handler you use in the docs, what do the codes mean?  I'm getting this for each key-press- the code and modifier just go up by one each time...



id:MAIN:TextArea type:97 key code:1 modifiers:1

id:MAIN:TextArea type:115 key code:2 modifiers:2

id:MAIN:TextArea type:100 key code:3 modifiers:3

id:MAIN:TextArea type:113 key code:4 modifiers:4

id:MAIN:TextArea type:56 key code:5 modifiers:5

id:MAIN:TextArea type:57 key code:6 modifiers:6

id:MAIN:TextArea type:48 key code:7 modifiers:7

id:MAIN:TextArea type:112 key code:8 modifiers:8

id:MAIN:TextArea type:111 key code:9 modifiers:9

id:MAIN:TextArea type:105 key code:10 modifiers:10



Also, the arrow keys don't seem to be working. Will investigate further...

Lutz

#5
For your purpose, intercepting arrow keys, the events on text-area or text-pane don't work, use the new gs:key-event instead, e.g. on a gs:panel. Here a summary what is transmitted in the events:





text-area event:



id - name of the widget

code - key code equals ASCII code for most keys (only text keys)

dot - position of text caret in the text

mark - extended (selection) position of caret



text-pane event



id - name of the widget

code - key code equals ASCII code for most keys (only text keys)

mods - keys pressed together with the previous, like shift

dot - position of text caret in the text

mark - extended (selection) position of caret

len - length of the text in the textarea

undo - undo enabled/disabled

redo - redo enabled/disabled



text-area and text-pane do not give you the arrow keys and all keys or key combinations already subscribed to with menu shortcuts.





key-event suitable for any widget:



id - name of the widget

type - "pressed" or "released"

code - code for all keys including arrows

mods - shift,ctrl,option,meta etc.



Lutz

cormullion

#6
Hi Lutz. Thanks - the key-events are now making sense and working well.



But in this example:


(if (= ostype "Win32")
    (load (string (env "PROGRAMFILES") "/newlisp/guiserver.lsp"))
    (load "/usr/share/newlisp/guiserver.lsp"))

(gs:init)
(gs:frame 'Screen 0 20 200 200)
(gs:canvas 'MyCanvas)
(gs:key-event 'MyCanvas 'key-action)
(gs:add-to 'Screen  'MyCanvas)
(gs:set-background 'Screen gs:black)

(gs:set-font 'MyCanvas "Sans Serif" 12 "plain")
(gs:set-visible 'Screen true)

(gs:draw-text 'Text (date) 30 30 '(.5 .5 .6))

(define (key-action id type code modifiers)
     (println (string "id:" id " type:" type " key code:" code " modifiers:" modifiers)))

(define (ticker)
(timer 'ticker 3))

; start timer the first time
(ticker)

(while (gs:check-event 10000)
(gs:request-focus 'MyCanvas) ; keep focus in canvas
(if (> (timer 'ticker) 3) ; timer has finished
(begin
(gs:draw-text 'Text (date) 30 30 '(.5 .5 .6))
(ticker))))


I'm trying to get a timer working independently of an event loop responding to key presses. What should I do to stop newLISP crashing?

Lutz

#7
Don't use the timer in an application receiving GS events. Do the timing in the event loop setting a variable to time-of-day and checking with time-of-day again. Resolving conflicts between the timer and GS event handling (which is doing timing with net-select) will take me some time to investigate.



Lutz

Lutz

#8
updated documentation for gs:text-field,  gs:text-area and gs:text-pane to include event parameter information:



http://newlisp.org/guiserver/">http://newlisp.org/guiserver/



Lutz

cormullion

#9
Quote from: "Lutz"Don't use the timer in an application receiving GS events. Do the timing in the event loop setting a variable to time-of-day and checking with time-of-day again. Resolving conflicts between the timer and GS event handling (which is doing timing with net-select) will take me some time to investigate


OK - no worries - I was tempted to do it that way anyway, since timers are a bit mysterious.



thanks again



PS - guiserver is getting addictive now... :-)