pyjarrett / trendy_terminal Goto Github PK
View Code? Open in Web Editor NEWA Windows/Linux library for enabling terminal settings and driving character-by-character input.
License: Apache License 2.0
A Windows/Linux library for enabling terminal settings and driving character-by-character input.
License: Apache License 2.0
Debug_Get_Line
crashes if this is not set:
Trendy_Terminal.Set (Trendy_Terminal.Echo, False);
Trendy_Terminal.Set (Trendy_Terminal.Line_Input, False);
Trendy_Terminal.Set (Trendy_Terminal.Escape_Sequences, True);
raised CONSTRAINT_ERROR : bad input for 'Value: ""
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ad49812 at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ad49bbe at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ad47e76 at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ad47f54 at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ac4fa00 at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ac5071a at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ac2e1b8 at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ac2e7c6 at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ab9176b at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ab92560 at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ab91422 at ???
[D:\dev\ada\septum\bin\septum.exe]
0x7ff66ab9113b at ???
[C:\Windows\System32\KERNEL32.DLL]
0x7ff81b617032
[C:\Windows\SYSTEM32\ntdll.dll]
0x7ff81cb2264f
Well, I just have to try macOS!
Looking at trendy_terminal-linux.ads
, I think the treatment of c_lflag_t
and Local_Flags
is confusing if not wrong.
The representations of c_lflag_t
(which are mask values) look as thought they ought to be octal, not hex? (values 1, 2, 4, 10 ...) - but Local_Flags
is an array indexed by the position, not the representation, so that ECHO
is bit 3, as it should be (on Linux).
On macOS, things are different (order, missing values):
for c_lflag_t use
(
ECHOKE => 16#00000001#,
ECHOE => 16#00000002#,
ECHOK => 16#00000004#,
ECHO => 16#00000008#,
ECHONL => 16#00000010#,
ECHOPRT => 16#00000020#,
ECHOCTL => 16#00000040#,
ISIG => 16#00000080#,
ICANON => 16#00000100#,
ALTWERASE => 16#00000200#,
IEXTEN => 16#00000400#,
EXTPROC => 16#00000800#,
TOSTOP => 16#00400000#,
FLUSHO => 16#00800000#,
NOKERNINFO => 16#02000000#,
PENDIN => 16#20000000#,
NOFLSH => 16#80000000#
);
I know we don’t use the last 4, so we could use the current scheme, but I’ve seen a NOKERNINFO
in the wild. I’ve gone for e.g. in Set
case Setting is
when Platform.Echo =>
Std_Input.Settings.c_lflag :=
Std_Input.Settings.c_lflag and not Macos.ECHO'Enum_Rep;
if Enabled then
Std_Input.Settings.c_lflag :=
Std_Input.Settings.c_lflag or Macos.ECHO'Enum_Rep;
end if;
Anyway, I spent a long time before noticing that termios.h
says
typedef unsigned long tcflag_t;
typedef unsigned char cc_t;
typedef unsigned long speed_t;
and on macOS unsigned long
is 8 bytes, so the Ada has to be unsigned_long
:
NCCS : constant := 20;
type tcflag_t is new Interfaces.C.unsigned_long;
type cc_t is new Interfaces.C.unsigned_char;
type speed_t is new Interfaces.C.unsigned_long;
type cc_array is array (Natural range 0 .. NCCS - 1) of cc_t;
On macOS, I couldn't say
stdin : aliased FILE_Ptr;
stdout : aliased FILE_Ptr;
stderr : aliased FILE_Ptr;
pragma Import (C, stdin, "stdin");
pragma Import (C, stdout, "stdout");
pragma Import (C, stderr, "stderr");
because the symbol _stdin
(I think the underscore was there). After delving into the GNAT runtime, I came up with
function Gnat_Constant_Stdin return FILE_Ptr with
Import => True,
Convention => C,
External_Name => "__gnat_constant_stdin";
function Gnat_Constant_Stdout return FILE_Ptr with
Import => True,
Convention => C,
External_Name => "__gnat_constant_stdout";
function Gnat_Constant_Stderr return FILE_Ptr with
Import => True,
Convention => C,
External_Name => "__gnat_constant_stderr";
stdin : aliased FILE_Ptr := Gnat_Constant_Stdin;
stdout : aliased FILE_Ptr := Gnat_Constant_Stdout;
stderr : aliased FILE_Ptr := Gnat_Constant_Stderr;
(ugh)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.