tiny_text_1.0.0_f072a0c3/src/tiny_text.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
--  Tiny Text
--  Copyright 2020 Jeremy Grosser
--  See LICENSE for details

with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with HAL.Bitmap; use HAL.Bitmap;
with HAL;

package Tiny_Text is
    Font_Width  : constant := 3;
    Font_Height : constant := 6;

    subtype Font_Character is HAL.UInt18;
	 type Font_Array is array (Character) of Font_Character;

	 Font_Data : constant Font_Array := (
      ' ' => 2#000_000_000_000_000_000#,
      '!' => 2#010_010_010_000_010_000#,
      '"' => 2#101_101_000_000_000_000#,
      '#' => 2#101_111_101_111_101_000#,
      '$' => 2#011_110_011_110_010_000#,
      '%' => 2#100_001_010_100_001_000#,
      '&' => 2#110_110_111_101_011_000#,
      ''' => 2#010_010_000_000_000_000#,
      '(' => 2#001_010_010_010_001_000#,
      ')' => 2#100_010_010_010_100_000#,
      '*' => 2#101_010_101_000_000_000#,
      '+' => 2#000_010_111_010_000_000#,
      ',' => 2#000_000_000_010_100_000#,
      '-' => 2#000_000_111_000_000_000#,
      '.' => 2#000_000_000_000_010_000#,
      '/' => 2#001_001_010_100_100_000#,
      '0' => 2#011_101_101_101_110_000#,
      '1' => 2#010_110_010_010_010_000#,
      '2' => 2#110_001_010_100_111_000#,
      '3' => 2#110_001_010_001_110_000#,
      '4' => 2#101_101_111_001_001_000#,
      '5' => 2#111_100_110_001_110_000#,
      '6' => 2#011_100_111_101_111_000#,
      '7' => 2#111_001_010_100_100_000#,
      '8' => 2#111_101_111_101_111_000#,
      '9' => 2#111_101_111_001_110_000#,
      ':' => 2#000_010_000_010_000_000#,
      ';' => 2#000_010_000_010_100_000#,
      '<' => 2#001_010_100_010_001_000#,
      '=' => 2#000_111_000_111_000_000#,
      '>' => 2#100_010_001_010_100_000#,
      '?' => 2#111_001_010_000_010_000#,
      '@' => 2#010_101_111_100_011_000#,
      'A' => 2#010_101_111_101_101_000#,
      'B' => 2#110_101_110_101_110_000#,
      'C' => 2#011_100_100_100_011_000#,
      'D' => 2#110_101_101_101_110_000#,
      'E' => 2#111_100_111_100_111_000#,
      'F' => 2#111_100_111_100_100_000#,
      'G' => 2#011_100_111_101_011_000#,
      'H' => 2#101_101_111_101_101_000#,
      'I' => 2#111_010_010_010_111_000#,
      'J' => 2#001_001_001_101_010_000#,
      'K' => 2#101_101_110_101_101_000#,
      'L' => 2#100_100_100_100_111_000#,
      'M' => 2#101_111_111_101_101_000#,
      'N' => 2#101_111_111_111_101_000#,
      'O' => 2#010_101_101_101_010_000#,
      'P' => 2#110_101_110_100_100_000#,
      'Q' => 2#010_101_101_111_011_000#,
      'R' => 2#110_101_111_110_101_000#,
      'S' => 2#011_100_010_001_110_000#,
      'T' => 2#111_010_010_010_010_000#,
      'U' => 2#101_101_101_101_011_000#,
      'V' => 2#101_101_101_010_010_000#,
      'W' => 2#101_101_111_111_101_000#,
      'X' => 2#101_101_010_101_101_000#,
      'Y' => 2#101_101_010_010_010_000#,
      'Z' => 2#111_001_010_100_111_000#,
      '[' => 2#111_100_100_100_111_000#,
      '\' => 2#000_100_010_001_000_000#,
      ']' => 2#111_001_001_001_111_000#,
      '^' => 2#010_101_000_000_000_000#,
      '_' => 2#000_000_000_000_111_000#,
      '`' => 2#100_010_000_000_000_000#,
      'a' => 2#000_110_011_101_111_000#,
      'b' => 2#100_110_101_101_110_000#,
      'c' => 2#000_011_100_100_011_000#,
      'd' => 2#001_011_101_101_011_000#,
      'e' => 2#000_011_101_110_011_000#,
      'f' => 2#001_010_111_010_010_000#,
      'g' => 2#000_011_101_111_001_010#,
      'h' => 2#100_110_101_101_101_000#,
      'i' => 2#010_000_010_010_010_000#,
      'j' => 2#001_000_001_001_101_010#,
      'k' => 2#100_101_110_110_101_000#,
      'l' => 2#110_010_010_010_111_000#,
      'm' => 2#000_111_111_111_101_000#,
      'n' => 2#000_110_101_101_101_000#,
      'o' => 2#000_010_101_101_010_000#,
      'p' => 2#000_110_101_101_110_100#,
      'q' => 2#000_011_101_101_011_001#,
      'r' => 2#000_011_100_100_100_000#,
      's' => 2#000_011_110_011_110_000#,
      't' => 2#010_111_010_010_011_000#,
      'u' => 2#000_101_101_101_011_000#,
      'v' => 2#000_101_101_111_010_000#,
      'w' => 2#000_101_111_111_111_000#,
      'x' => 2#000_101_010_010_101_000#,
      'y' => 2#000_101_101_011_001_010#,
      'z' => 2#000_111_011_110_111_000#,
      '{' => 2#011_010_100_010_011_000#,
      '|' => 2#010_010_000_010_010_000#,
      '}' => 2#110_010_001_010_110_000#,
      '~' => 2#011_110_000_000_000_000#,
      Degree_Sign => 2#010_101_010_000_000_000#,
      others => 2#111_101_101_101_111_000#);

    type Text_Buffer
       (Bitmap        : Any_Bitmap_Buffer;
        Width, Height : Natural) is tagged private;

    procedure Initialize
       (This : in out Text_Buffer);
    procedure Clear
       (This : in out Text_Buffer);
    procedure Advance
       (This : in out Text_Buffer);
    procedure New_Line
       (This : in out Text_Buffer);
    procedure Put
        (This       : in out Text_Buffer;
         Location   : in Point;
         Char       : in Character;
         Foreground : in Bitmap_Color;
         Background : in Bitmap_Color);
    procedure Put
       (This : in out Text_Buffer;
        Char : in Character);
    procedure Put
       (This : in out Text_Buffer;
        Str  : in String);
    procedure Put_Line
       (This : in out Text_Buffer;
        Str  : in String);

private
    type Text_Buffer
       (Bitmap        : Any_Bitmap_Buffer;
        Width, Height : Natural)
    is tagged record
       Default_Cursor : Point;
       Cursor : Point;
    end record;
end Tiny_Text;