diff --git a/.github/workflows/build_aaa_ansi.yml b/.github/workflows/build_aaa_ansi.yml new file mode 100644 index 0000000..9b3e1b8 --- /dev/null +++ b/.github/workflows/build_aaa_ansi.yml @@ -0,0 +1,17 @@ +name: aaa_ansi + +on: + push: + branches: [ main, master ] + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + uses: ./.github/workflows/build.yml + with: + crate: aaa_ansi diff --git a/.gitignore b/.gitignore index 0b566a3..50df3b3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ alire.lock bin lib obj -**/tests/config/ +**/config/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b1d6282 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,43 @@ +This repo hosts several nested Alire crates (aaa_base, aaa_texts, +aaa_ansi, ...), each buildable/testable independently with `alr` from +its own directory. + +To build and test everything at once, run from the repo root: + + alr -C dev test + +This uses the `dev` crate (see dev/alire.toml), which aggregates all +the other crates' test suites via `[[test]]` entries. + +## Crate layout + +- Directory name and Alire crate `name` can differ: `aaa_base/` + hosts the crate named `aaa` (root package `AAA`, in + aaa_base/src/aaa.ads). Other crates depend on it as `aaa`, pinned + to `../aaa_base` (or `../../aaa_base` from a `tests/` subdir). +- Nested crates that add children to the shared `AAA` root package + (aaa_texts, aaa_ansi) each need: `aaa = "~0.3.0"` in + `[[depends-on]]`, a pin to `../aaa_base`, `with "aaa.gpr";` in + their own `.gpr`, and the same `aaa` pin repeated in + `tests/alire.toml`. +- `AAA.ANSI` (aaa_ansi crate) is the low-level ANSI escape-sequence + builder (ported from ~/prog/ansi-ada, package `AnsiAda` -> + `AAA.ANSI`), Pure, no external deps. `AAA.ANSI.Tools` (aaa_texts + crate) is a different, unrelated package: display-width + measurement (`Length`/`Count_Extra`) built on `Umwi`. Don't + conflate the two when grepping for "ANSI". + +## Alire manifest gotchas + +- A bare `[pins.foo]` table in `alire.toml` without a preceding + `[[pins]]` array-of-tables header makes `alr` fail with + `field pins: expected a TOML_ARRAY but got a TOML_TABLE`. Either + write pins inline right after `[[pins]]` + (`foo = { path = "../foo" }`) or put an empty `[[pins]]` line + before any `[pins.foo]` subtables (see aaa_texts/alire.toml). +- If `alr test` in a crate's `tests/` dir errors with an Alire + "bug box" (`No release visited in round 3`), the generated + `tests/config/*_config.gpr` is likely stale/missing (e.g. after + editing `[[depends-on]]`). Fix by running `alr build` (or + `alr update`) directly inside that `tests/` directory to + regenerate config, then retry `alr test` from wherever. diff --git a/aaa_ansi/.gitignore b/aaa_ansi/.gitignore new file mode 100644 index 0000000..2a8a28f --- /dev/null +++ b/aaa_ansi/.gitignore @@ -0,0 +1,10 @@ +/alire/ +/bin/ +/config/ +/lib/ +/obj/ + +*.a +*.ali +*.o +*.so diff --git a/aaa_ansi/aaa_ansi.gpr b/aaa_ansi/aaa_ansi.gpr new file mode 100644 index 0000000..1f2ac90 --- /dev/null +++ b/aaa_ansi/aaa_ansi.gpr @@ -0,0 +1,31 @@ +with "config/aaa_ansi_config.gpr"; +with "aaa.gpr"; +project Aaa_Ansi is + + for Library_Name use "Aaa_Ansi"; + for Library_Version use + Project'Library_Name & ".so." & Aaa_Ansi_Config.Crate_Version; + + for Source_Dirs use ("src/", "config/"); + for Object_Dir use "obj/" & Aaa_Ansi_Config.Build_Profile; + for Create_Missing_Dirs use "True"; + for Library_Dir use "lib"; + + type Library_Type_Type is ("relocatable", "static", "static-pic"); + Library_Type : Library_Type_Type := + external ("AAA_ANSI_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static")); + for Library_Kind use Library_Type; + + package Compiler is + for Default_Switches ("Ada") use Aaa_Ansi_Config.Ada_Compiler_Switches; + end Compiler; + + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; + + package Install is + for Artifacts (".") use ("share"); + end Install; + +end Aaa_Ansi; diff --git a/aaa_ansi/alire.toml b/aaa_ansi/alire.toml new file mode 100644 index 0000000..470f432 --- /dev/null +++ b/aaa_ansi/alire.toml @@ -0,0 +1,19 @@ +name = "aaa_ansi" +description = "ANSI escape sequences" +version = "0.1.0-dev" + +authors = ["Alejandro R. Mosteo"] +maintainers = ["Alejandro R. Mosteo "] +maintainers-logins = ["mosteo"] +licenses = "MIT" +website = "" +tags = ["ansi", "terminal", "escape"] + +[test] +runner = "alire" + +[[depends-on]] +aaa = "~0.3.0" + +[[pins]] +aaa = { path = "../aaa_base" } diff --git a/aaa_ansi/src/aaa-ansi.ads b/aaa_ansi/src/aaa-ansi.ads new file mode 100644 index 0000000..6bc556a --- /dev/null +++ b/aaa_ansi/src/aaa-ansi.ads @@ -0,0 +1,402 @@ +package AAA.ANSI with Pure is + + Reset_All : constant String; + -- Resets the device to its original state. This may include (if + -- applicable): reset graphic rendition, clear tabulation stops, reset + -- to default font, and more. + + type States is (Off, On); + + function Scrub (Sequence : String) return String; + -- Remove all ANSI formatting from a string; + + function Shorten (Sequence : String) return String is (Sequence); + -- Some consecutive commands can be combined, resulting in a shorter + -- string. Currently does nothing, but included for future optimization. + + ----------- + -- COLOR -- + ----------- + + type Colors is + (Default, -- Implementation defined according to ANSI + + Black, + Red, + Green, + Yellow, + Blue, + Magenta, + Cyan, + Grey, + + -- Note: these light variants might not work in older terminals. In + -- general, the bold + [light] color combination will result in the + -- same bright color + Light_Black, + Light_Red, + Light_Green, + Light_Yellow, + Light_Blue, + Light_Magenta, + Light_Cyan, + Light_Grey); + + Reset : constant String; + -- Back to defaults. Applies to colors & styles. + + function Foreground (Color : Colors) return String; + function Background (Color : Colors) return String; + -- Basic palette, 8/16 colors + + subtype Palette_RGB is Natural range 0 .. 5; + -- Used for the 256-palette colors. Actual colors in this index-mode + -- palette can slightly vary from terminal to terminal. + + function Palette_Fg (R, G, B : Palette_RGB) return String; + function Palette_Bg (R, G, B : Palette_RGB) return String; + + subtype Greyscale is Natural range 0 .. 23; + -- Drawn from the same palette mode. 0 is black, 23 is white + + function Foreground (Level : Greyscale) return String; + function Background (Level : Greyscale) return String; + + subtype True_RGB is Natural range 0 .. 255; + -- Modern terminals support true 24-bit RGB color + + function Foreground (R, G, B : True_RGB) return String; + function Background (R, G, B : True_RGB) return String; + + Default_Foreground : constant String; + Default_Background : constant String; + + function Color_Wrap (Text : String; + Foreground : String := ""; + Background : String := "") + return String; + -- Wraps text between opening color and closing Defaults. See the combo + -- color+styles below. + + ------------ + -- STYLES -- + ------------ + + type Styles is + (Default, -- equivalent to Default_Foreground/Background + Bright, -- aka Bold + Dim, -- aka Faint + Italic, + Underline, + Blink, + Rapid_Blink, -- ansi.sys only + Invert, -- swaps fg/bg, aka reverse video + Conceal, -- aka hide + Strike, -- aka crossed-out + Fraktur, -- rarely supported, gothic style + Double_Underline); + + function Style (Style : Styles; Active : States := On) return String; + -- Apply/Remove a style + + function Style_Wrap (Text : String; + Style : Styles) return String; + -- Wraps Text in the given style between On/Off sequences + + function Wrap (Text : String; + Style : Styles; + Foreground : String := ""; + Background : String := "") + return String; + + ------------ + -- CURSOR -- + ------------ + + -- Cursor movement. No effect if at edge of screen. + + function Back (Cells : Positive := 1) return String; + function Down (Lines : Positive := 1) return String; + function Forward (Cells : Positive := 1) return String; + function Up (Lines : Positive := 1) return String; + + function Next (Lines : Positive := 1) return String; + function Previous (Lines : Positive := 1) return String; + -- Move to the beginning of the next/prev lines. Not in ansi.sys + + function Horizontal (Column : Positive := 1) return String; + -- Move to a certain absolute column. Not in ansy.sys + + function Position (Row, Column : Positive := 1) return String; + -- 1, 1 is top-left + + Store : constant String; + -- Store cursor position. Private SCO extension, may work in current vts + Restore : constant String; + -- Restore cursor position to the previously stored one + + Hide : constant String; + Show : constant String; + -- DECTCEM private extension, may work in current vts + + -------------- + -- CLEARING -- + -------------- + + Clear_Screen : constant String; + Clear_Screen_And_Buffer : constant String; + -- Clear also the backscroll buffer + + Clear_To_Beginning_Of_Screen : constant String; + Clear_To_End_Of_Screen : constant String; + -- From the cursor position + + Clear_Line : constant String; + -- Does not change cursor position (neither the two following). + + Clear_To_Beginning_Of_Line : constant String; + Clear_To_End_Of_Line : constant String; + + function Scroll_Up (Lines : Positive) return String; + -- Adds lines at bottom + function Scroll_Down (Lines : Positive) return String; + -- Adds lines at top + +private + + ESC : constant Character := ASCII.ESC; + CSI : constant String := ESC & '['; + + Reset_All : constant String := ESC & "c"; + + -- Helpers for the many int-to-str conversions + + function Tail (S : String) return String is + (S (S'First + 1 .. S'Last)); + + function Img (I : Natural) return String is + (Tail (I'Img)); + + ------------ + -- COLORS -- + ------------ + + Reset : constant String := CSI & "0m"; + -- Back to defaults. Applies to colors & styles. + + function Foreground (Color : Colors) return String is + (CSI + & (case Color is + when Default => "39", + when Black => "30", + when Red => "31", + when Green => "32", + when Yellow => "33", + when Blue => "34", + when Magenta => "35", + when Cyan => "36", + when Grey => "37", + when Light_Black => "90", + when Light_Red => "91", + when Light_Green => "92", + when Light_Yellow => "93", + when Light_Blue => "94", + when Light_Magenta => "95", + when Light_Cyan => "96", + when Light_Grey => "97") + & "m"); + function Background (Color : Colors) return String is + (CSI + & (case Color is + when Default => "49", + when Black => "40", + when Red => "41", + when Green => "42", + when Yellow => "43", + when Blue => "44", + when Magenta => "45", + when Cyan => "46", + when Grey => "47", + when Light_Black => "100", + when Light_Red => "101", + when Light_Green => "102", + when Light_Yellow => "103", + when Light_Blue => "104", + when Light_Magenta => "105", + when Light_Cyan => "106", + when Light_Grey => "107") + & "m"); + + function Bit8 (R, G, B : Palette_RGB) return String is + (Img (16 + 36 * R + 6 * G + B)); + + Fg : constant String := "38"; + Bg : constant String := "48"; + + function Palette_Fg (R, G, B : Palette_RGB) return String is + (CSI & Fg & ";5;" & Bit8 (R, G, B) & "m"); + function Palette_Bg (R, G, B : Palette_RGB) return String is + (CSI & Bg & ";5;" & Bit8 (R, G, B) & "m"); + + function Foreground (Level : Greyscale) return String is + (CSI & Fg & ";5;" & Img (232 + Level) & "m"); + function Background (Level : Greyscale) return String is + (CSI & Bg & ";5;" & Img (232 + Level) & "m"); + + function Foreground (R, G, B : True_RGB) return String is + (CSI & Fg & ";2;" & Img (R) & ";" & Img (G) & ";" & Img (B) & "m"); + function Background (R, G, B : True_RGB) return String is + (CSI & Bg & ";2;" & Img (R) & ";" & Img (G) & ";" & Img (B) & "m"); + + Default_Foreground : constant String := CSI & "39m"; + Default_Background : constant String := CSI & "49m"; + + function Color_Wrap (Text : String; + Foreground : String := ""; + Background : String := "") + return String is + ((if Foreground /= "" then Foreground else "") + & (if Background /= "" then Background else "") + & Text + & (if Background /= "" then Default_Background else "") + & (if Foreground /= "" then Default_Foreground else "")); + + ------------ + -- STYLES -- + ------------ + + function Style (Style : Styles; Active : States := On) return String is + (CSI + & (case Active is + when On => + (case Style is + when Default => "39", + when Bright => "1", + when Dim => "2", + when Italic => "3", + when Underline => "4", + when Blink => "5", + when Rapid_Blink => "6", + when Invert => "7", + when Conceal => "8", + when Strike => "9", + when Fraktur => "20", + when Double_Underline => "21" + ), + when Off => + (case Style is + when Default => "49", + when Bright => "22", + when Dim => "22", + when Italic => "23", + when Underline => "24", + when Blink => "25", + when Rapid_Blink => "25", + when Invert => "27", + when Conceal => "28", + when Strike => "29", + when Fraktur => "23", + when Double_Underline => "24" + )) + & "m"); + + function Style_Wrap (Text : String; + Style : Styles) return String is + (AAA.ANSI.Style (Style, On) + & Text + & AAA.ANSI.Style (Style, Off)); + + function Wrap (Text : String; + Style : Styles; + Foreground : String := ""; + Background : String := "") + return String is + (Style_Wrap (Style => Style, + Text => Color_Wrap (Text => Text, + Foreground => Foreground, + Background => Background))); + + ------------ + -- CURSOR -- + ------------ + + function Cursor (N : Positive; Code : Character) return String is + (CSI & Img (N) & Code) with Inline_Always; + -- For common Cursor sequences + + function Back (Cells : Positive := 1) return String is + (Cursor (Cells, 'D')); + function Down (Lines : Positive := 1) return String is + (Cursor (Lines, 'B')); + function Forward (Cells : Positive := 1) return String is + (Cursor (Cells, 'C')); + function Up (Lines : Positive := 1) return String is + (Cursor (Lines, 'A')); + + function Next (Lines : Positive := 1) return String is + (Cursor (Lines, 'E')); + function Previous (Lines : Positive := 1) return String is + (Cursor (Lines, 'F')); + + function Horizontal (Column : Positive := 1) return String is + (Cursor (Column, 'G')); + + function Position (Row, Column : Positive := 1) return String is + (CSI & Img (Row) & ";" & Img (Column) & "H"); + + Store : constant String := CSI & "s"; + Restore : constant String := CSI & "u"; + + Hide : constant String := CSI & "?25l"; + Show : constant String := CSI & "?25h"; + + -------------- + -- CLEARING -- + -------------- + + Clear_Screen : constant String := CSI & "2J"; + Clear_Screen_And_Buffer : constant String := CSI & "3J"; + + Clear_To_Beginning_Of_Screen : constant String := CSI & "2J"; + Clear_To_End_Of_Screen : constant String := CSI & "0J"; + + Clear_Line : constant String := CSI & "2K"; + + Clear_To_Beginning_Of_Line : constant String := CSI & "1K"; + Clear_To_End_Of_Line : constant String := CSI & "0K"; + + function Scroll_Up (Lines : Positive) return String is + (CSI & Img (Lines) & "S"); + function Scroll_Down (Lines : Positive) return String is + (CSI & Img (Lines) & "T"); + + ----------- + -- Scrub -- + ----------- + + function Scrub (Clean : String; + Dirty : String; + Cleaning : Boolean := False) + return String + is (if Dirty = "" + then Clean + else + (if Cleaning and then Dirty (Dirty'First) /= 'm' then + Scrub (Clean, Dirty (Dirty'First + 1 .. Dirty'Last), True) + elsif Cleaning and then Dirty (Dirty'First) = 'm' then + Scrub (Clean, Dirty (Dirty'First + 1 .. Dirty'Last), False) + elsif not Cleaning and then Dirty (Dirty'First) = ESC then + Scrub (Clean, Dirty (Dirty'First + 1 .. Dirty'Last), True) + elsif not Cleaning and then Dirty (Dirty'First) /= ESC then + Scrub (Clean & Dirty (Dirty'First), + Dirty (Dirty'First + 1 .. Dirty'Last), False) + else + raise Program_Error with "Unexpected state while scrubbing with " + & "clean=" & Clean + & " dirty=" & Dirty + & " cleaning=" & Cleaning'Image)); + + function Scrub (Sequence : String) return String + is (Scrub ("", Sequence)); + +end AAA.ANSI; diff --git a/aaa_ansi/tests/.gitignore b/aaa_ansi/tests/.gitignore new file mode 100644 index 0000000..2a8a28f --- /dev/null +++ b/aaa_ansi/tests/.gitignore @@ -0,0 +1,10 @@ +/alire/ +/bin/ +/config/ +/lib/ +/obj/ + +*.a +*.ali +*.o +*.so diff --git a/aaa_ansi/tests/aaa_ansi_tests.gpr b/aaa_ansi/tests/aaa_ansi_tests.gpr new file mode 100644 index 0000000..46fa288 --- /dev/null +++ b/aaa_ansi/tests/aaa_ansi_tests.gpr @@ -0,0 +1,19 @@ +with "config/aaa_ansi_tests_config.gpr"; +with "config/aaa_ansi_tests_list_config.gpr"; + +project Aaa_Ansi_Tests is + for Source_Dirs use ("src/**", "common/", "config/"); + for Object_Dir use "obj/" & Aaa_Ansi_Tests_Config.Build_Profile; + for Create_Missing_Dirs use "True"; + for Exec_Dir use "bin"; + for Main use Aaa_Ansi_Tests_List_Config.Test_Files; + + package Compiler is + for Default_Switches ("Ada") use + Aaa_Ansi_Tests_Config.Ada_Compiler_Switches; + end Compiler; + + package Binder is + for Switches ("Ada") use ("-Es"); -- Symbolic traceback + end Binder; +end Aaa_Ansi_Tests; diff --git a/aaa_ansi/tests/alire.toml b/aaa_ansi/tests/alire.toml new file mode 100644 index 0000000..b97bb16 --- /dev/null +++ b/aaa_ansi/tests/alire.toml @@ -0,0 +1,14 @@ +name = "aaa_ansi_tests" +description = "Tests for the built-in Alire test runner" +version = "0.0.0-test" + +[[depends-on]] +aaa_ansi = "*" + +[[pins]] +aaa = { path = '../../aaa_base' } +aaa_ansi = { path = ".." } + +[build-profiles] +aaa_ansi = "validation" +aaa_ansi_tests = "validation" diff --git a/aaa_ansi/tests/common/aaa_ansi_tests.ads b/aaa_ansi/tests/common/aaa_ansi_tests.ads new file mode 100644 index 0000000..c6ba440 --- /dev/null +++ b/aaa_ansi/tests/common/aaa_ansi_tests.ads @@ -0,0 +1,12 @@ +pragma Warnings (Off); +with Ada.Assertions; use Ada.Assertions; +-- Make Assert visible to children +pragma Warnings (On); + +pragma Ignore_Pragma (Alire_Test); +-- Alire configures tests through this pragma. This clause silences warnings +-- by GNAT about it. The pragma has no impact on GNAT compilation. + +package Aaa_Ansi_Tests is + +end Aaa_Ansi_Tests; diff --git a/aaa_ansi/tests/src/aaa_ansi_tests-assertions_enabled.adb b/aaa_ansi/tests/src/aaa_ansi_tests-assertions_enabled.adb new file mode 100644 index 0000000..f6b36f0 --- /dev/null +++ b/aaa_ansi/tests/src/aaa_ansi_tests-assertions_enabled.adb @@ -0,0 +1,10 @@ +procedure Aaa_Ansi_Tests.Assertions_Enabled is +begin + begin + pragma Assert (False, "Should raise"); + exception + when others => + return; -- properly raised + end; + raise Program_Error with "Assertion did not raise"; +end Aaa_Ansi_Tests.Assertions_Enabled; diff --git a/aaa_base/config/aaa_config.ads b/aaa_base/config/aaa_config.ads deleted file mode 100644 index cc77070..0000000 --- a/aaa_base/config/aaa_config.ads +++ /dev/null @@ -1,20 +0,0 @@ --- Configuration for aaa generated by Alire -pragma Restrictions (No_Elaboration_Code); -pragma Style_Checks (Off); - -package Aaa_Config is - pragma Pure; - - Crate_Version : constant String := "0.3.0-dev"; - Crate_Name : constant String := "aaa"; - - Alire_Host_OS : constant String := "linux"; - - Alire_Host_Arch : constant String := "x86_64"; - - Alire_Host_Distro : constant String := "suse"; - - type Build_Profile_Kind is (release, validation, development); - Build_Profile : constant Build_Profile_Kind := development; - -end Aaa_Config; diff --git a/aaa_base/config/aaa_config.gpr b/aaa_base/config/aaa_config.gpr deleted file mode 100644 index c6a04d4..0000000 --- a/aaa_base/config/aaa_config.gpr +++ /dev/null @@ -1,27 +0,0 @@ --- Configuration for aaa generated by Alire -abstract project Aaa_Config is - Crate_Version := "0.3.0-dev"; - Crate_Name := "aaa"; - - Alire_Host_OS := "linux"; - - Alire_Host_Arch := "x86_64"; - - Alire_Host_Distro := "suse"; - Ada_Compiler_Switches := External_As_List ("ADAFLAGS", " "); - Ada_Compiler_Switches := Ada_Compiler_Switches & - ( - "-Og" -- Optimize for debug - ,"-ffunction-sections" -- Separate ELF section for each function - ,"-fdata-sections" -- Separate ELF section for each variable - ,"-g" -- Generate debug info - ,"-gnatwa" -- Enable all warnings - ,"-gnatw.X" -- Disable warnings for No_Exception_Propagation - ,"-gnatVa" -- All validity checks - ,"-gnatW8" -- UTF-8 encoding for wide characters - ); - - type Build_Profile_Kind is ("release", "validation", "development"); - Build_Profile : Build_Profile_Kind := "development"; - -end Aaa_Config; diff --git a/aaa_base/config/aaa_config.h b/aaa_base/config/aaa_config.h deleted file mode 100644 index 522eacd..0000000 --- a/aaa_base/config/aaa_config.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Configuration for aaa generated by Alire */ -#ifndef AAA_CONFIG_H -#define AAA_CONFIG_H - -#define CRATE_VERSION "0.3.0-dev" -#define CRATE_NAME "aaa" - -#define ALIRE_HOST_OS "linux" - -#define ALIRE_HOST_ARCH "x86_64" - -#define ALIRE_HOST_DISTRO "suse" - -#define BUILD_PROFILE_RELEASE 1 -#define BUILD_PROFILE_VALIDATION 2 -#define BUILD_PROFILE_DEVELOPMENT 3 - -#define BUILD_PROFILE 3 - -#endif diff --git a/aaa_texts/aaa_texts.gpr b/aaa_texts/aaa_texts.gpr index 6cb867a..1562eeb 100644 --- a/aaa_texts/aaa_texts.gpr +++ b/aaa_texts/aaa_texts.gpr @@ -1,5 +1,6 @@ with "config/aaa_texts_config.gpr"; with "aaa.gpr"; +with "aaa_ansi.gpr"; with "lml.gpr"; project Aaa_Texts is diff --git a/aaa_texts/alire.toml b/aaa_texts/alire.toml index 4a9cd1b..fce6721 100644 --- a/aaa_texts/alire.toml +++ b/aaa_texts/alire.toml @@ -1,6 +1,7 @@ name = "aaa_texts" description = "Utilities to deal with enriched human texts (ANSI, Unicode)" -version = "0.3.0" +version = "0.4.0" +# 0.4.0: Renamed AAA.ANSI to AAA.ANSI.Tools authors = ["Alejandro R. Mosteo"] maintainers = ["Alejandro R. Mosteo "] @@ -10,16 +11,19 @@ website = "https://github.com/mosteo/aaa" tags = ["unicode", "ansi", "console", "terminal", "tables"] [[depends-on]] -aaa = "~0.3.0" -ansiada = "^1.1.0" -lml = "~0.2.0" -umwi = "~0.1.0" +aaa = "~0.3.0" +aaa_ansi = "~0.1.0" +lml = "~0.2.0" +umwi = "~0.1.0" [[pins]] [pins.aaa] path = "../aaa_base" +[pins.aaa_ansi] +path = "../aaa_ansi" + [pins.lml] url = "https://github.com/mosteo/lml_ada.git" commit = "6e775b785f795af21bb6d8cb870b59f549dae159" diff --git a/aaa_texts/src/aaa-ansi.adb b/aaa_texts/src/aaa-ansi-tools.adb similarity index 95% rename from aaa_texts/src/aaa-ansi.adb rename to aaa_texts/src/aaa-ansi-tools.adb index 55ad875..ae1e923 100644 --- a/aaa_texts/src/aaa-ansi.adb +++ b/aaa_texts/src/aaa-ansi-tools.adb @@ -3,7 +3,7 @@ with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with Umwi; -package body AAA.ANSI is +package body AAA.ANSI.Tools is package Chars renames Ada.Characters.Wide_Wide_Latin_1; @@ -48,4 +48,4 @@ package body AAA.ANSI is function Length (Text : UTF.UTF_String) return Natural is (Length (UTF.Wide_Wide_Strings.Decode (Text))); -end AAA.ANSI; +end AAA.ANSI.Tools; diff --git a/aaa_texts/src/aaa-ansi.ads b/aaa_texts/src/aaa-ansi-tools.ads similarity index 90% rename from aaa_texts/src/aaa-ansi.ads rename to aaa_texts/src/aaa-ansi-tools.ads index 28f9fd0..c8455de 100644 --- a/aaa_texts/src/aaa-ansi.ads +++ b/aaa_texts/src/aaa-ansi-tools.ads @@ -1,6 +1,6 @@ with Ada.Strings.UTF_Encoding; -package AAA.ANSI with Preelaborate is +package AAA.ANSI.Tools with Preelaborate is package UTF renames Ada.Strings.UTF_Encoding; @@ -15,4 +15,4 @@ package AAA.ANSI with Preelaborate is function Length (Text : UTF.UTF_String) return Natural; -- Same, but expects latin-1 or UTF-8 encoding -end AAA.ANSI; +end AAA.ANSI.Tools; diff --git a/aaa_texts/src/aaa-table_io.adb b/aaa_texts/src/aaa-table_io.adb index 3cbc74c..6d49e20 100644 --- a/aaa_texts/src/aaa-table_io.adb +++ b/aaa_texts/src/aaa-table_io.adb @@ -1,11 +1,10 @@ -with AAA.ANSI; +with AAA.ANSI.Tools; with AAA.Strings; with Ada.Containers; with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with Ada.Strings.Wide_Wide_Unbounded; -with AnsiAda; with GNAT.IO; @@ -42,10 +41,11 @@ package body AAA.Table_IO is end if; if Natural (T.Max_Widths.Length) < T.Next_Column then - T.Max_Widths.Append (ANSI.Length (Cell)); + T.Max_Widths.Append (ANSI.Tools.Length (Cell)); else T.Max_Widths (T.Next_Column) := - Natural'Max (ANSI.Length (Cell), T.Max_Widths (T.Next_Column)); + Natural'Max (ANSI.Tools.Length (Cell), + T.Max_Widths (T.Next_Column)); end if; T.Rows (Natural (T.Rows.Length)).Append (Cell); @@ -128,7 +128,7 @@ package body AAA.Table_IO is -- Field length, as it's not included in Text'Length. Pad : constant Wide_Wide_String := - (1 .. ANSI.Count_Extra (Text) + (1 .. ANSI.Tools.Count_Extra (Text) + T.Max_Widths (Col) - Counts.Width => ' '); @@ -156,7 +156,7 @@ package body AAA.Table_IO is & "; l:" & Counts.Points'Image & "; f:" & Field'Length'Image & "; m:" & Natural'(T.Max_Widths (Col))'Image - & "; a:" & ANSI.Count_Extra (Text)'Image + & "; a:" & ANSI.Tools.Count_Extra (Text)'Image & "; t:'" & Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Encode (Text) & "'"); end if; @@ -269,12 +269,12 @@ package body AAA.Table_IO is Builder.Insert (LML.Decode - (Trim (AnsiAda.Scrub (LML.Encode (T.Headers (Col)))))); + (Trim (ANSI.Scrub (LML.Encode (T.Headers (Col)))))); Builder.Append (LML.Scalars.New_Text (LML.Decode (Trim - (AnsiAda.Scrub + (ANSI.Scrub (LML.Encode (T.Rows (Row) (Col))))))); end loop; diff --git a/aaa_texts/src/aaa-text_io.adb b/aaa_texts/src/aaa-text_io.adb index 6a381f2..bb80a07 100644 --- a/aaa_texts/src/aaa-text_io.adb +++ b/aaa_texts/src/aaa-text_io.adb @@ -1,4 +1,4 @@ -with AAA.ANSI; +with AAA.ANSI.Tools; with AAA.Debug; with AAA.Filesystem; @@ -57,7 +57,7 @@ package body AAA.Text_IO is ---------- function Used return Natural - is (ANSI.Length (To_String (Line))); + is (ANSI.Tools.Length (To_String (Line))); PPos : constant Integer := Pos; -- Initial Pos, to check we had some progress @@ -78,7 +78,7 @@ package body AAA.Text_IO is end if; -- Eat words until line is complete - while Used + ANSI.Length (Next_Word) - 1 <= Line_Width loop + while Used + ANSI.Tools.Length (Next_Word) - 1 <= Line_Width loop Put (Next_Word); Pos := Pos + Next_Word'Length; diff --git a/aaa_texts/tests/alire.toml b/aaa_texts/tests/alire.toml index 3cf21ea..b599925 100644 --- a/aaa_texts/tests/alire.toml +++ b/aaa_texts/tests/alire.toml @@ -7,6 +7,7 @@ aaa_texts = '*' [[pins]] aaa = { path = '../../aaa_base' } +aaa_ansi = { path = '../../aaa_ansi' } aaa_texts = { path = ".." } [build-profiles] diff --git a/aaa_texts/tests/config/aaa_texts_tests_config.ads b/aaa_texts/tests/config/aaa_texts_tests_config.ads deleted file mode 100644 index 2d3060e..0000000 --- a/aaa_texts/tests/config/aaa_texts_tests_config.ads +++ /dev/null @@ -1,20 +0,0 @@ --- Configuration for aaa_texts_tests generated by Alire -pragma Restrictions (No_Elaboration_Code); -pragma Style_Checks (Off); - -package Aaa_Texts_Tests_Config is - pragma Pure; - - Crate_Version : constant String := "0.0.0-test"; - Crate_Name : constant String := "aaa_texts_tests"; - - Alire_Host_OS : constant String := "linux"; - - Alire_Host_Arch : constant String := "x86_64"; - - Alire_Host_Distro : constant String := "ubuntu"; - - type Build_Profile_Kind is (release, validation, development); - Build_Profile : constant Build_Profile_Kind := validation; - -end Aaa_Texts_Tests_Config; diff --git a/aaa_texts/tests/config/aaa_texts_tests_config.gpr b/aaa_texts/tests/config/aaa_texts_tests_config.gpr deleted file mode 100644 index 4829245..0000000 --- a/aaa_texts/tests/config/aaa_texts_tests_config.gpr +++ /dev/null @@ -1,55 +0,0 @@ --- Configuration for aaa generated by Alire -with "umwi.gpr"; -abstract project Aaa_Config is - Crate_Version := "0.3.0-dev"; - Crate_Name := "aaa"; - - Alire_Host_OS := "linux"; - - Alire_Host_Arch := "x86_64"; - - Alire_Host_Distro := "ubuntu"; - Ada_Compiler_Switches := External_As_List ("ADAFLAGS", " "); - Ada_Compiler_Switches := Ada_Compiler_Switches & - ( - "-O3" -- Optimize for performance - ,"-gnatn" -- Enable inlining - ,"-ffunction-sections" -- Separate ELF section for each function - ,"-fdata-sections" -- Separate ELF section for each variable - ,"-g" -- Generate debug info - ,"-gnato" -- Enable numeric overflow checking - ,"-gnatwa" -- Enable all warnings - ,"-gnatw.X" -- Disable warnings for No_Exception_Propagation - ,"-gnatVa" -- All validity checks - ,"-gnatwe" -- Warnings as errors - ,"-gnata" -- Enable assertions and contracts - ,"-gnaty3" -- Specify indentation level of 3 - ,"-gnatya" -- Check attribute casing - ,"-gnatyA" -- Use of array index numbers in array attributes - ,"-gnatyB" -- Check Boolean operators - ,"-gnatyb" -- Blanks not allowed at statement end - ,"-gnatyc" -- Check comments - ,"-gnaty-d" -- Disable check no DOS line terminators present - ,"-gnatye" -- Check end/exit labels - ,"-gnatyf" -- No form feeds or vertical tabs - ,"-gnatyh" -- No horizontal tabs - ,"-gnatyi" -- Check if-then layout - ,"-gnatyI" -- check mode IN keywords - ,"-gnatyk" -- Check keyword casing - ,"-gnatyl" -- Check layout - ,"-gnatym" -- Check maximum line length - ,"-gnatyn" -- Check casing of entities in Standard - ,"-gnatyO" -- Check that overriding subprograms are explicitly marked as such - ,"-gnatyp" -- Check pragma casing - ,"-gnatyr" -- Check identifier references casing - ,"-gnatyS" -- Check no statements after THEN/ELSE - ,"-gnatyt" -- Check token spacing - ,"-gnatyu" -- Check unnecessary blank lines - ,"-gnatyx" -- Check extra parentheses - ,"-gnatW8" -- UTF-8 encoding for wide characters - ); - - type Build_Profile_Kind is ("release", "validation", "development"); - Build_Profile : Build_Profile_Kind := "validation"; - -end Aaa_Config; diff --git a/aaa_texts/tests/config/aaa_texts_tests_config.h b/aaa_texts/tests/config/aaa_texts_tests_config.h deleted file mode 100644 index 64b4677..0000000 --- a/aaa_texts/tests/config/aaa_texts_tests_config.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Configuration for aaa_texts_tests generated by Alire */ -#ifndef AAA_TEXTS_TESTS_CONFIG_H -#define AAA_TEXTS_TESTS_CONFIG_H - -#define CRATE_VERSION "0.0.0-test" -#define CRATE_NAME "aaa_texts_tests" - -#define ALIRE_HOST_OS "linux" - -#define ALIRE_HOST_ARCH "x86_64" - -#define ALIRE_HOST_DISTRO "ubuntu" - -#define BUILD_PROFILE_RELEASE 1 -#define BUILD_PROFILE_VALIDATION 2 -#define BUILD_PROFILE_DEVELOPMENT 3 - -#define BUILD_PROFILE 2 - -#endif diff --git a/aaa_texts/tests/config/aaa_texts_tests_list_config.gpr b/aaa_texts/tests/config/aaa_texts_tests_list_config.gpr deleted file mode 100644 index e0536a6..0000000 --- a/aaa_texts/tests/config/aaa_texts_tests_list_config.gpr +++ /dev/null @@ -1,5 +0,0 @@ -abstract project Aaa_Texts_Tests_List_Config is - Test_Files := ( - "aaa_texts_tests-example_test.adb" - ); -end Aaa_Texts_Tests_List_Config; diff --git a/dev/alire.toml b/dev/alire.toml index 95188f5..2b85c2b 100644 --- a/dev/alire.toml +++ b/dev/alire.toml @@ -18,14 +18,20 @@ executables = ["dev"] runner = "alire" directory = "../aaa_base/tests" +[[test]] +runner = "alire" +directory = "../aaa_ansi/tests" + [[test]] runner = "alire" directory = "../aaa_texts/tests" [[depends-on]] aaa_tests = "*" +aaa_ansi_tests = "*" aaa_texts_tests = "*" [[pins]] aaa_tests = { path = "../aaa_base/tests" } +aaa_ansi_tests = { path = "../aaa_ansi/tests" } aaa_texts_tests = { path = "../aaa_texts/tests" }