Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - oofoe

#31
Quote from: "cormullion"Try doubling the slashes?


Feetfish! I thought I had tried that and it didn't work!



> (find "\d+" "3432" 0) $0
0
"3432"
> (find "\D+" "XC3432" 0) $0
0
"XC"


But it does work. Thanks Cormullion!
#32
Hi!



Having some trouble with regular expressions... It seems that d and D aren't working for me:



> (find "d+" "3432" 0) $0
nil
"433"
> (find "D+" "XC3432" 0) $0
nil
"433"
> (find "[0-9]+" "3432" 0) $0
0
"3432"


I'll limp along with "[0-9]" for now, but it would be nice to know what's going on with the others. According to the PCRE manpage, they should work.



Using newLISP v.10.4.5 on Win32 IPv4/6 libffi from the most recent installer, running on XP64.



Thanks!
#33
newLISP Graphics & Sound / All right, all fixed.
October 07, 2012, 12:26:03 PM
OK, seems the actual problem was that I hadn't set the font. Adding:


(gs:set-font 'main-canvas "Lucida Sans" 20 "plain")

Fixes it. I guess the Java stack trace comes from not having a specified type metric for whatever it is that does the collision detection to determine if you've clicked on a canvas item.



I guess it would be nice if some sensible default was set up so that exception wouldn't get triggered. If I have time for it, I might go digging around in the guiserver and see if I can come up with a patch.
#34
OK, found it. In my original code (not the small snippet I posted), I had this line:


(gs:draw-text 'T "Click to create a node..." 20 30 gs:white)

Commenting that out and tag return works. So, some problem with how I did the text. Have to go finish building a USB typewriter, so I'll investigate that more later, since it's a problem not to be able to do text too...
#35
Alright! Figured out the guiserver trace problem -- I had "Javaw" associated to %.jar files, not "Java". Javaw is not attached to a console, so it's GUI only. I was able to start my program directly from Java with:



Java -jar ..guiserver.jar 47011 program.lsp


Now I have tracing! So, I can now see what happens when I attempt to set the event handler for mouse-released:



-> mouse-released MAIN:main-canvas MAIN:canvas-clicking true
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at sun.font.FontDesignMetrics$MetricsKey.init(Unknown Source)
        at sun.font.FontDesignMetrics.getMetrics(Unknown Source)
        at sun.swing.SwingUtilities2.getFontMetrics(Unknown Source)
        at javax.swing.JComponent.getFontMetrics(Unknown Source)
        at TextShape.hasPoint(TextShape.java:86)
        at CanvasWidget$MyCanvas.getTagsFromPoint(CanvasWidget.java:675)
        at CanvasWidget$MyCanvas.mouseReleased(CanvasWidget.java:754)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$200(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)


This appears to be some sort of nasty with Java itself. Any ideas?



Thanks very much!
#36
OK, I figured that if the flag for tracing GUI calls wasn't working, I'd just recompile %guiserver.jar and force it to print out.



So, I dragged down the latest source and added a new line to %java/Dispatcher.exe:

if(guiserver.debug) System.out.println("-> " + command);
System.out.println("F> " + command); // F for forced... josh 2012-10-07


I recompiled and pointed Newlisp's %guiserver.lsp to my new %guiserver.jar. I figured this way, I'd be sure to see something. And I don't.



As long as I just want to draw pictures with no true/false flags I'm OK. Beyond that... I'm stumped.
#37
OK, some more data points about the problem:



 * Using NewLisp v.10.4.4

 * Using latest x86 Java from Oracle (jre7, platform 1.7, product 1.7.0_07)

 * The "true" flag is not working for other functions -- for instance, there's no feedback

    when I set "(gs:set-trace true)" or trace messages either.

 * Since I couldn't use gs:set-trace, I added this line above the set-trace net-send call:
   (println (string "set-trace System " flag "n"))
   It prints:
   set-trace System true
   Which should be right, right?



The button-demo.lsp program works, but doesn't output the trace messages, so I don't think it's just my program.



Thanks!
#38
Hi!



According to the documentation, specifying gs:mouse-released with a third argument of "true" will provide a list of tags whose member's bounding boxes intersect the mouse cursor position. However, this doesn't seem to actually work (see example code below). If the "true" argument is removed, then you will see little red circles where you click. Otherwise nada.



Any ideas what's wrong? Thanks in advance!



(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

(gs:init)

(gs:frame 'main  100 100  800 800  "Demo")
(gs:set-border-layout 'main)

(gs:canvas 'main-canvas)
(gs:set-background 'main-canvas gs:gray)
(gs:add-to 'main 'main-canvas "center")
(gs:set-visible 'main true)

;; This is the affected line:
(gs:mouse-released 'main-canvas 'canvas-clicking true)

(define (canvas-clicking x y)
  (println (args))
  (gs:draw-circle 'C x y 8 gs:red)
  (gs:update)
  )

(gs:listen)
#39
Whither newLISP? / Re: Compose for NewLISP?
January 29, 2012, 07:16:41 AM
Thanks for getting back to me!



I should have been more clear -- I was thinking of "compose" not in the computer science or mathematical sense, but rather as a REBOL-style compose operation where it takes a quoted list and looks up certain tagged symbols. It does look like "expand" is the closest match.



Thanks!
#40
Whither newLISP? / Compose for NewLISP?
January 27, 2012, 10:30:52 PM
Hi!



I realize that this is probably really easy and trivial...  However! I would like to define an associative list that uses pre-existing variables. Something like this:


(setq x 412)
(setq a '((name "Bob")
             (age    x)))


So that:


(lookup 'age a) -> 412

Of course this doesn't actually work because the "x" is quoted inside the quoted associative list, so it returns x the symbol instead of the value at associative list creation time. This will work, but it's ugly because you have to use different strategies to assemble the individual keys and values:


(setq a (list '(name "Bob")
                   (list 'age x)))


So... Is there any more elegant way to do it?



Thanks!
#41
newLISP Graphics & Sound / Hmm.
August 26, 2008, 07:45:25 AM
OK, I'm thinking I've asked the unanswerable... Guess it's time to crack open the guiserver source again...



Thanks for reading!
#42
newLISP Graphics & Sound / Drag and Drop?
August 25, 2008, 08:28:15 AM
Hi,



Is there an easy way to do simple inter-process drag and drop with the newLisp GUIserver on Windows? I would like to be able to drag and drop text snippets from other applications (like Outlook or Wordpad) onto a newLisp application, then have it process the text.



As a bonus, it would also be good to have it going in the other direction -- dragging and dropping from the newLisp program.



It does seem that drag and drop work on text fields, but I would like to extend it in a more general direction -- using an image as the drop pocket, for example.



Thanks!
#43
newLISP Graphics & Sound / Thanks!
April 25, 2008, 01:48:33 PM
I looked in the newlisp and the newlisp/guiserver/java directories for the makefile... Didn't occur to me to check between!



Thanks for pointing it out!



I'll see if I can get Windows to compile it, since I don't have a Mac available.



Jos'h
#44
newLISP Graphics & Sound / Compiling guiserver...
April 25, 2008, 01:31:23 PM
Hi,



How does one re-compile the guiserver? I'm would like to tweak how list-boxes work but I don't see anything for compiling and building the .jar in the Makefiles.



I would like to be able to recompile it on Windows.



I may well have overlooked something... Pointers to the obvious would be welcome.



Thank you,



Jos'h
#45
Anything else we might add? /
September 17, 2007, 03:34:37 PM
I'm not so fast and awesome as to provide a replacement for m4, but here's a start at a tokenizer. Doesn't handle quotes, but that's not far away:



; ch2.lsp
; jrlf 2007-09-17
; Convert C .h header files to NewLisp import statements.


(context 'importer)

(setq whitespace " trn"     ; Whitespace to ignore.
      break '("#" ";" "(" ")") ; Characters to tokenize on.
)


(define (nocomment text)
  "( text -- cleaned) Removes comments and newlines. A bit of a cheat."

  (replace "/\*.+?\*/" (replace "[n|r]+" text " " 0) "" 0)
)


(define (tokenize text)
  "( text -- (token...)) Break text up into tokens."
  ; XXX Doesn't deal with quotes properly yet.

  (letn ((found '())
         (hold "")
         (quoting nil)
         (cleaned (nocomment text))
         )

        (dotimes (x (length cleaned))
          (letn ((c (cleaned x)))
                (if (<= 0 (find c whitespace))
                      (begin
                       (if (not (null? hold))
                           (setq found (append found (list hold))
                                 hold "")))
                      (<= 0 (find c break))
                      (begin
                       (if (not (null? hold))
                           (setq found (append found (list hold))
                                 hold ""))
                       (setq found (append found (list c)))
                       )
                      (setq hold (string hold c))
                  )
            )
          )
        found
        )
)


(define (read filename namespace)
  "( filename namespace -- code) Create library import code."


  (tokenize (read-file filename))
)

(context MAIN)


(println (importer:read "SDL_image.h" 'IMG))
[/code]