1with agar.core.types;
2with agar.gui.text;
3with agar.gui.widget.scrollbar;
4
5package agar.gui.widget.console is
6
7  use type c.unsigned;
8
9  type console_t;
10  type console_access_t is access all console_t;
11  pragma convention (c, console_access_t);
12
13  type line_t is record
14    text     : cs.chars_ptr;
15    len      : c.size_t;
16    surface  : c.int;
17    selected : c.int;
18    icon     : c.int;
19    font     : agar.gui.text.font_access_t;
20    color_fg : agar.core.types.uint32_t;
21    color_bg : agar.core.types.uint32_t;
22    ptr      : agar.core.types.void_ptr_t;
23    cons     : console_access_t;
24  end record;
25  type line_access_t is access all line_t;
26  pragma convention (c, line_t);
27  pragma convention (c, line_access_t);
28
29  type flags_t is new c.unsigned;
30  CONSOLE_HFILL  : constant flags_t := 16#01#;
31  CONSOLE_VFILL  : constant flags_t := 16#02#;
32  CONSOLE_EXPAND : constant flags_t := CONSOLE_HFILL or CONSOLE_VFILL;
33
34  type console_t is record
35    widget       : aliased widget_t;
36    flags        : flags_t;
37    padding      : c.int;
38    lineskip     : c.int;
39    lines        : line_access_t;
40    lines_number : c.unsigned;
41    row_offset   : c.unsigned;
42    color_bg     : agar.core.types.uint32_t;
43    scrollbar    : agar.gui.widget.scrollbar.scrollbar_access_t;
44    r            : agar.gui.rect.rect_t;
45  end record;
46  pragma convention (c, console_t);
47
48  -- API
49
50  function allocate
51    (parent : widget_access_t;
52     flags  : flags_t) return console_access_t;
53  pragma import (c, allocate);
54
55  procedure set_padding
56    (console : console_access_t;
57     padding : natural);
58  pragma inline (set_padding);
59
60  function message
61    (console : console_access_t;
62     text    : string) return line_access_t;
63  pragma inline (message);
64
65  function append_line
66    (console : console_access_t;
67     text    : string) return line_access_t;
68  pragma inline (append_line);
69
70  function widget (console : console_access_t) return widget_access_t;
71  pragma inline (widget);
72
73end agar.gui.widget.console;
74