Recent posts

#71
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.
#72
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.
#73
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

#74
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
#75
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.
#76
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?
#77
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
#78
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.
#79
newLISP newS / Re: I'd like to offer to take ...
Last post by itistoday - August 07, 2023, 09:20:47 AM
Quote from: marchildmann on August 07, 2023, 07:51:56 AMThank you Greg for managing the new forums!
Just re-registered because my previous nickname "hilti" was taken.

Cheers
Marc

Welcome back @marchildmann!

FYI your previous username should still belong to you. Try resetting the password for that username. If you still have control over that email you should get an email letting your reset it.
#80
newLISP newS / Re: I'd like to offer to take ...
Last post by marchildmann - August 07, 2023, 07:51:56 AM
Thank you Greg for managing the new forums!
Just re-registered because my previous nickname "hilti" was taken.

Cheers
Marc