rayzor

view src/screen.cc @ 21:8c4859442200

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 15 Apr 2014 20:52:05 +0300
parents be616b58df99
children
line source
1 #include <stdlib.h>
2 #include <string.h>
3 #include "screen.h"
4 #include "rbtree.h"
5 #include "logger.h"
7 MsgAtom message_atom(const char *str)
8 {
9 static struct rbtree *atoms;
10 static MsgAtom last_atom;
11 struct rbnode *node;
12 MsgAtom atom;
14 if(!atoms) {
15 if(!(atoms = rb_create(RB_KEY_STRING))) {
16 printlog("fatal: message_atom failed to create symbol table\n");
17 abort();
18 }
19 }
21 if((node = rb_find(atoms, (void*)str))) {
22 return *(MsgAtom*)&node->data;
23 }
25 atom = ++last_atom;
26 if(rb_insert(atoms, (void*)str, (void*)atom) == -1) {
27 printlog("message_atom failed to insert new atom\n");
28 --last_atom;
29 return -1;
30 }
31 return atom;
32 }
34 Screen::Screen()
35 {
36 name = 0;
37 }
39 Screen::~Screen()
40 {
41 delete [] name;
42 }
44 bool Screen::init()
45 {
46 return true;
47 }
49 void Screen::shutdown()
50 {
51 }
53 void Screen::set_name(const char *name)
54 {
55 delete [] this->name;
56 this->name = new char[strlen(name) + 1];
57 strcpy(this->name, name);
58 }
60 const char *Screen::get_name() const
61 {
62 return name ? name : "<unnamed>";
63 }
65 void Screen::update()
66 {
67 }
69 void Screen::handle_keyboard(int key, bool press)
70 {
71 }
73 void Screen::handle_mbutton(int bn, bool press, int x, int y)
74 {
75 }
77 void Screen::handle_mmotion(int x, int y)
78 {
79 }
81 void Screen::message(MsgAtom msg, ...)
82 {
83 }