xighlight/example/example_ada.adb
2023-10-07 04:33:20 -04:00

46 lines
842 B
Ada

-- gnatmake -o example_ada example_ada.adb
with ada.text_io, ada.command_line;
use ada.text_io, ada.command_line;
procedure example_ada is
type colours is (RED, GREEN, YELLOW);
type structure is record
x : integer := -1;
y : natural := 1;
end record;
escape : constant character := character'val (27);
procedure put_colour (colour : colours) is
code : integer := colours'pos (colour) + 49;
begin
put (escape & "[0;3" & character'val (code) & "m");
end put_colour;
procedure put_cancel is
begin
put (escape & "[0m");
end put_cancel;
heyo : structure := (-103, 107);
begin
for colour in colours
loop
put_colour (colour);
put_line ("x = " & integer'image (heyo.x));
put_line ("y = " & natural'image (heyo.y));
heyo.x := heyo.x - 1;
heyo.y := heyo.y + 1;
put_cancel;
end loop;
end example_ada;