Implementing Xyntax in Ada work in progress...

This commit is contained in:
Ognjen Milan Robovic 2024-05-13 04:03:27 -04:00
parent f8c75a8be5
commit 725296802c
4 changed files with 39 additions and 6 deletions

View File

@ -200,7 +200,7 @@ package body core is
function import_text (file_path : in string) return string_box_data is
this : string_box_data;
begin
this.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path))));
this.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)))) & character'val (0);
--
return this;
end import_text;
@ -352,7 +352,7 @@ package body core is
------------------------------------------------------------------------------------------
procedure idle_skip is begin null; end idle_skip;
procedure idle_skip is null;
procedure move_camera_up is begin core.camera.y := core.camera.y - 1; end move_camera_up;
procedure move_camera_down is begin core.camera.y := core.camera.y + 1; end move_camera_down;

View File

@ -202,16 +202,17 @@ begin
cursor_mode := 0;
xxx := import_text ("./source/material.ads");
xxx := import_text ("./source/attribute.ads");
main_menu_loop: loop
synchronize;
--
exit when signal_mode = signal_space or cursor_mode = 2;
--
ui.write (to_string (xxx.text), 0, 0, code => true);
--
main_menu;
--
--~ui.write (to_string (xxx.text), 0, 0, size => 11, code => true);
ui.write_ada_code (xxx, 0, 0);
end loop main_menu_loop;
cursor_mode := 0;

View File

@ -4,6 +4,9 @@
with core;
with ada.strings.unbounded;
use ada.strings.unbounded;
package body ui is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -270,7 +273,7 @@ package body ui is
procedure write (text : in string; x, y : in integer; tint : in core.colour := (others => 255); size : in natural := 0; code : in boolean := false) is
begin
core.write (text, x, y, tint, font (active).scale, (if code then monospace else font (active)));
core.write (text, x, y, tint, (if size = 0 then font (active).scale else size), (if code then monospace else font (active)));
end write;
------------------------------------------------------------------------------------------
@ -577,6 +580,33 @@ package body ui is
core.increment (structure_array (structure_count - 1).gui_n);
end add_structure_orient;
------------------------------------------------------------------------------------------
procedure write_ada_code (text : in core.string_box_data; x, y : in integer) is
buffer : character := ' ';
width : constant integer := 13;
height : constant integer := 11;
length : natural := 1;
offset : core.vector := (x, y);
begin
loop
buffer := ada.strings.unbounded.element (text.text, length);
--
exit when buffer = character'val (0);
--~exit when buffer = ';';
--
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 ':' => ui.write (buffer & "", offset.x, offset.y, ( 0, 255, 255, 255), height, code => true);
when others => ui.write (buffer & "", offset.x, offset.y, (255, 255, 255, 255), height, code => true);
end case;
--
offset.x := offset.x + width;
length := length + 1;
end loop;
end write_ada_code;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end ui;

View File

@ -85,6 +85,8 @@ package ui is
procedure add_structure_button (icon : in core.sprite; text : in core.short_string; description : in core.long_string := "");
procedure add_structure_orient;
procedure write_ada_code (text : in core.string_box_data; x, y : in integer);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end ui;