Thank you!
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 MenuQuote1) 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.
(import "msvcrt.dll" "_getch")
(import "msvcrt.dll" "_kbhit")
(exec "chcp 65001")
(setq n 0)
(while (< n 7)
(if (= 1 (setq k (_kbhit) ))
(println (++ n) ":" k ":" (_getch) ":" (_kbhit))
(setq n 0)
)
)
)
1:1:13:0 <----------- ENTER, one catch, code 13, and kbhit returns 0
1:1:224:1 <----------- press UP: two codes: 224 and next 72
2:1:72:0
1:1:0:1 <----------- press F1: two codes: first 0, kbhit still returns 1
2:1:59:0 <-------------------------------- second: 59, after that kbhit returns 0
1:1:145:1 <----------- enter "ё": first code 209 was disappear, getch return second: 145
2:1:145:1 <----------- AND kbhit still returns 1:
3:1:145:1
4:1:145:1
5:1:145:1
6:1:145:1
7:1:145:1
1
> ё <----------- and ё somehow printed by default newlisp REPL
Solutions is: (import "kernel32.dll" "SetConsoleOutputCP")
(import "kernel32.dll" "GetConsoleOutputCP")
> (SetConsoleOutputCP 866) (GetConsoleOutputCP) (char 937)
1
866
"╬й" <----------- FAIL
> (SetConsoleOutputCP 65001) (GetConsoleOutputCP) (char 937)
1
65001
"Ω" <----------- SUCCESS
> (import "kernel32.dll" "GetConsoleCP")
GetConsoleCP@CB3855F0
> (GetConsoleCP)
866 <----------- this is INPUT codepage
> (GetConsoleOutputCP)
65001 <----------- this is OUTPUT codepage
>
More info herenewLISP v.10.7.5 64-bit on Windows IPv4/6 UTF-8 libffi, options: newlisp -h
> (crc32 (string (symbols)))
3617620833
> (prompt-event (fn () (string (args 0) ":" (crc32 (string (symbols))) " > ")))
$prompt-event
MAIN:1539437814 > (delete 'a)
true
MAIN:1539437814 > a
nil
MAIN:2595764761 > ## state change: 2595764761
MAIN:2595764761 > (ref "a" (map term (symbols)))
(49)
MAIN:2595764761 > ## sym a exists
MAIN:2595764761 > (delete 'a)
true
MAIN:1539437814 > ## we come back in 1539437814
MAIN:1539437814 > (ref "a" (map term (symbols)))
nil
MAIN:1539437814 > ## no sym a in MAIN
MAIN:1539437814 >
MAIN:1539437814 > a
nil
MAIN:2595764761 > ## sym a exist again but now we try to clean a context MAIN by reset
MAIN:2595764761 > ## newlisp manual: " reset restores the top-level variable environment using the saved variable environments on the stack. "
MAIN:2595764761 > (reset)
MAIN:2595764761 > (ref "a" (map term (symbols)))
(49)
MAIN:2595764761 > ## sym a exists
MAIN:2595764761 >
(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
>
> (read-key) (read-key)
0
59
- first call returns 0, second call returns 59. /* 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 */
}
(define (peek-pipe fd)
(letn (pos (seek fd)
size (seek fd -1))
(seek fd pos)
size
))
(xml-type-tags nil nil nil nil)
(xml-parse {<br/>} 31)
(apply xml-type-tags '(nil nil nil nil))
(xml-parse {<br/>} 31)
((define (sxml:parse xml-source d)
(xml-type-tags nil nil nil nil)
(xml-parse xml-source d)
)
{<br/>}
31
)
returns
((br))
, but:
((define (some-function xml-source)
(sxml:parse xml-source 31)
)
{<br/>}
)
returns
((sxml:br))
Bug?
(define (peek-pipe fd)
(letn (pos (seek fd)
size (seek fd -1))
(seek fd pos)
size
))
(define (read-pipe fd)
(letn (buf "")
(read fd buf (peek-pipe fd))
buf
))