From d67826a8f4d2d0968f5500e8a943a1b4740a9053 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 9 Jun 2024 18:39:01 -0400 Subject: [PATCH] Character changes... --- source/core.adb | 8 ++++---- source/core.ads | 4 ++++ source/ui.adb | 10 +++++----- source/world.adb | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source/core.adb b/source/core.adb index 471d245..be8dc0a 100644 --- a/source/core.adb +++ b/source/core.adb @@ -171,7 +171,7 @@ package body core is function c_string (ada_string : string) return string is begin - return (ada_string & character'val (0)); + return (ada_string & terminator); end c_string; ------------------------------------------------------------------------------------------ @@ -183,7 +183,7 @@ package body core is for index in data'range loop width := width + 1; -- - if data (index) = character'val (10) then + if data (index) = line_feed then maximum_width := (if width > maximum_width then width - 1 else maximum_width); width := 0; end if; @@ -200,7 +200,7 @@ package body core is height : natural := 0; begin for index in data'range loop - if data (index) = character'val (10) then + if data (index) = line_feed then height := height + 1; end if; end loop; @@ -309,7 +309,7 @@ package body core is procedure import_text (data : in out string_box_data; file_path : in string) is begin - data.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)).all)) & character'val (0); + data.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)).all)) & terminator; end import_text; ------------------------------------------------------------------------------------------ diff --git a/source/core.ads b/source/core.ads index 671a3b8..cc14920 100644 --- a/source/core.ads +++ b/source/core.ads @@ -74,6 +74,10 @@ package core is ------------------------------------------------------------------------------------------ + terminator : constant character := character'val (0); + tabulator : constant character := character'val (9); + line_feed : constant character := character'val (10); + folder : constant string := "."; icon : constant natural := 32; diff --git a/source/ui.adb b/source/ui.adb index ba0680f..8ed89ab 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -580,11 +580,11 @@ package body ui is --~buffer := (core.bound (text.text)) (length .. length); --~offset.x := offset.x + width; --~-- - --~exit when buffer = character'val (0); + --~exit when buffer = core.terminator; --~-- --~case buffer is - --~when character'val (9) => offset.x := offset.x + 2 * width; - --~when character'val (10) => offset.y := offset.y + 1 * height; offset.x := x; + --~when core.tabulator => offset.x := offset.x + 2 * width; + --~when core.line_feed => offset.y := offset.y + 1 * height; offset.x := x; --~when ':' | ';' | '.' | ',' | '=' | '<' | '>' => --~ui.write (buffer & "", offset.x, offset.y, (63, 127, 255, 255), height, code => true); --~when '+' | '*' | '/' | '|' | '&' => @@ -611,7 +611,7 @@ package body ui is --~buffer := ada.strings.unbounded.element (text.text, length); --~ui.write (buffer & "", offset.x, offset.y, (127, 127, 127, 255), height, code => true); --~offset.x := offset.x + width; - --~exit when buffer = character'val (10); + --~exit when buffer = core.line_feed; --~end loop; --~core.decrement (length); --~else @@ -632,7 +632,7 @@ package body ui is --~loop --~buffer := ada.strings.unbounded.element (text.text, length + subset); --~exit when buffer = ' ' or buffer = '.' or buffer = '(' or buffer = ')' or buffer = ',' or buffer = ';' or buffer = ''' - --~or buffer = character'val (9) or buffer = character'val (10); + --~or buffer = core.tabulator or buffer = core.line_feed; --~word := word & ada.strings.unbounded.to_unbounded_string (buffer & ""); --~core.increment (subset); --~end loop; diff --git a/source/world.adb b/source/world.adb index 02a8c01..efe03ba 100644 --- a/source/world.adb +++ b/source/world.adb @@ -1074,8 +1074,8 @@ package body world is -- ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height, width - 2 * offset); -- - ui.draw_text (text => "Hiring fee:" & data.hiring_fee'image & character'val (10) & - "Weekly fee:" & data.weekly_fee'image & character'val (10) & + ui.draw_text (text => "Hiring fee:" & data.hiring_fee'image & core.line_feed & + "Weekly fee:" & data.weekly_fee'image & core.line_feed & "Battle fee:" & data.battle_fee'image, x => core.center_x (width) + offset, y => core.center_y (height) + offset + unit.view_height + core.base,