From 9f32667aafcf3760a4a073e657ccc793dd15935a Mon Sep 17 00:00:00 2001 From: Rod Kay Date: Tue, 16 Aug 2022 14:29:29 +1000 Subject: [PATCH] lace.text: Add an 'Element' function. --- 1-base/lace/source/text/lace-text.adb | 13 +++++++++++++ 1-base/lace/source/text/lace-text.ads | 3 +++ 2 files changed, 16 insertions(+) diff --git a/1-base/lace/source/text/lace-text.adb b/1-base/lace/source/text/lace-text.adb index 0c45ef3..e876bbe 100644 --- a/1-base/lace/source/text/lace-text.adb +++ b/1-base/lace/source/text/lace-text.adb @@ -155,6 +155,19 @@ is + function Element (Self : in Item; Index : in Positive) return Character + is + begin + if Index > Self.Length + then + raise Error with "Index" & Index'Image & " exceeds length of" & Self.Length'Image; + end if; + + return Self.Data (Index); + end Element; + + + procedure append (Self : in out Item; Extra : in String) is First : constant Positive := Self.Length + 1; diff --git a/1-base/lace/source/text/lace-text.ads b/1-base/lace/source/text/lace-text.ads index 7e69be4..19c97fa 100644 --- a/1-base/lace/source/text/lace-text.ads +++ b/1-base/lace/source/text/lace-text.ads @@ -124,6 +124,9 @@ is function mono_Spaced (Self : in Item) return Item; + function Element (Self : in Item; Index : in Positive) return Character; + + procedure append (Self : in out Item; Extra : in String); -- -- Raises an Error if capacity is exceeded.