Recent posts

#51
newLISP and the O.S. / Re: Windows clipboard
Last post by Yael - November 05, 2023, 02:41:18 AM
I use a call to pasteclipboard.exe to read from the clipboard. Here, an example:

(set 'option (exec "pasteclipboard.exe"))
(set 'optid (parse (option 0)))
(when (= (join optid) "0") (myfunction))
.
.
.

To put something on the clipboard I call clip.exe (all of this under Windows OS)
#52
newLISP in the real world / Re: Reading keyboard input
Last post by IVShilov - October 26, 2023, 10:56:31 AM
Another bug on this way: timer and read-key can't used together
(setq c nil interval 0,001)
(define (output)
    (if c
        (begin
          (print (char c))
          (setq c nil)
          ))
    (timer 'output interval)
    )
(output)
In console:
      > (setq c 100)
      100
      > d

      > (setq c (read-key))
      13
      0 > ## a context "0" ???

      0 > (context)
      MAIN
      >
#53
newLISP in the real world / Re: Reading keyboard input
Last post by IVShilov - October 26, 2023, 10:44:47 AM
AutoHotKey? Can't even imagine this.

Enchanced REPL is like a emacs/readline but for one string:
 - autocompletion by TAB:
     - functions using (filter lambda? (symbols)) 
     - args using (type) and function definitions
 - swapping two elements in line by C-t|C-M-t
 - highlight substrings using xterm esc-sequences and ConEmu's interface
and so on.
For example, look at ipython.
#54
newLISP in the real world / Re: Reading keyboard input
Last post by cameyo - October 26, 2023, 07:37:53 AM
Sorry, I can't help you.
But what do you mean by "enhanced REPL"?
I use Notepad++ connected to a REPL via Autohotkey script.
Far more powerful than only REPL.
Thanks.
#55
newLISP in the real world / Re: Reading keyboard input
Last post by IVShilov - October 26, 2023, 06:18:38 AM
Yes, everything is fine with blocking form of read-key: it catch F1, UTF8 two-byte codes, and even CTRL-C (!) returs code 3.

Problems in non-blocking reading:
1) F1 (code 0 59) because 0 is default result of (read-key true) means "no key pressed", and IMHO it must return nil;
2) UTF8 non-onebyte char - leads to infinite loop and crash.
This two problems block for me creating enhanced REPL.
PS Does someone knew how to catch win32 keyboard events  like key-press|key-release ?
I have weak skills in FFI

#56
newLISP in the real world / Re: Reading keyboard input
Last post by cameyo - October 26, 2023, 04:28:10 AM
This works for me:

(define (keys)
  (local (k)
    (while (!= (setq k (read-key)) 13)
      (setq s (string k))
      (println s))))

(keys)
;-> 1   ; Ctrl-A
;-> 111 ; O
;-> 79  ; o
;-> 0
;-> 59  ; F1
;-> 0
;-> 60  ; F2
;-> 224
;-> 81  ; PageUp
;-> 224
;-> 72  ; Up
;-> 224
;-> 77  ; Right
;-> 224
;-> 80  ; Down
;-> 224
;-> 75  ; Left
#57
newLISP in the real world / Input "ё" crashes newlisp in n...
Last post by IVShilov - October 23, 2023, 01:04:58 AM
Also, UTF8 letter crash newlisp capturing keypress in non-blocking mode :

(while (!= 3 (print (read-key true))) (print ":" (read-key true) "|"))
0:0|0:0| ...
after input "ё" newlisp stuck and cmd window close.
#58
newLISP in the real world / Reading keyboard input
Last post by IVShilov - October 22, 2023, 07:29:32 AM
Hi.
[windows 10, newLISP v.10.7.5 64-bit on Windows IPv4/6 UTF-8 libffi]

Found, that non-blocking mode (read-key true) cannot get F1-F12 keycodes because return 0 when nothing pressed, when, for example, F1 key is (0 59):
> (read-key) (read-key)
0
59
- first call returns 0, second call returns 59. 

Under the hood read-key use kbhit() and getch():

/* thanks to Peter van Eerten for contributing this function */
/* included non-blocking ability 10.7.3, LM */

CELL * p_readKey(CELL * params)
{

#if defined(WINDOWS) || defined(OS2)
if(!isNil(evaluateExpression(params)) )
{
if(kbhit())
return(stuffInteger(getch()));
else
[b][u]return(stuffInteger(0));[/u][/b]
}
else
return(stuffInteger(getch()));
#else
...
 /* not Windows or OS2 */
}

As I understand in this place
 return(stuffInteger(0));
(read-key true) returns 0 when nothing has pressed.
I think it must returns nil in this case .

The questions:
1) Is it right place to change behavior and nil is right solution?
2) How to do it right, which C-code must be there and how to rebuild sources?
#59
newLISP and the O.S. / Windows clipboard
Last post by cameyo - October 09, 2023, 06:00:10 AM
Do you known a way to manage windows clipboard (cut, copy, paste)?
I have tried to use clipboard.dll with no luck.
Thanks.

cameyo
#60
newLISP newS / Re: newLISP Github?
Last post by iacore - August 07, 2023, 09:59:52 AM
I added to doc/CHANGES and to the release page.