rayzor

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