5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "x86_keybscr.h"
26 #include "manes/manec.h"
27 #include "libs/delegate.h"
28 #include "libs/colors.h"
30 using namespace manes
;
31 using namespace resources
;
33 keybscr::keybscr() : x(17), y(0) {}
36 void keybscr::read(buffer
&data
) {
37 for (int i
= 0; i
< data
.get_size(); i
++)
41 void keybscr::write(const buffer
&data
) {
42 for (int i
= 0; i
< data
.get_size(); i
++) {
44 if (data
[i
] == '\n') {
45 if (y
< get_height() - 1)
50 } else if (data
[i
] == '\t') {
53 screen_print(data
[i
], foreground
| (background
<< 4), x
, y
);
58 if (x
/ get_width() > 0 && y
>= get_height() - 1)
60 y
= y
< get_height() ? y
: get_height() - 1;
66 void keybscr::set_ondatareceived(delegate
<void> event
) {
67 assert("keybscr: attempt to set null event handler", event
.null());
68 on_data_received
= event
;
71 void keybscr::received(const char key
) {
73 write(buffer::to_mem(key
));
79 void keybscr::register_type() {
80 manec::get()->register_type
<arch_keybscr
>("keybscr", "console");