Henry Vermaak wrote:
On 18/11/11 13:06, Martin wrote:
Not done any console apps in a long time.
If I do:
var c: char;
read(c);
It will read individual files, but only after I pressed enter on my
terminal. What is needed to read the char immediately?
This is rather platform specific, since you have to set your terminal
into non-canonical mode. You should be able to use the functions in the
keyboard unit to do this in a cross platform way.
I wonder if I could ask a related question. With this code
ke := GetKeyEvent;
kr := TKeyRecord(ke);
Write('<', IntToHex(ke, 8), '>');
Write('<', IntToHex(kr.KeyCode, 4), ' ', IntToHex(kr.ShiftState,
2), ' ', IntToHex(kr.Flags, 2), '>');
WriteLn;
If I enter 1 1<cr> (three characters followed by enter) on x86
(little-endian, using 2.6.0) I get
<03000231><0231 00 03>
<03003920><3920 00 03>
<03000231><0231 00 03>
<0300240A><240A 00 03>
while on SPARC (big-endian, using 2.7.1) I get
<03000231><0300 02 31>
<03003920><0300 39 20>
<03000231><0300 02 31>
<0300240A><0300 24 0A>
Referring to
http://lazarus-ccr.sourceforge.net/docs/rtl/keyboard/tkeyrecord.html I
would have thought that this should have been sorted inside the keyboard
unit.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus