rayzor
diff src/screen.cc @ 15:be616b58df99
continued the renderer slightly
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 13 Apr 2014 09:54:36 +0300 |
parents | 70e332156d02 |
children | 79609d482762 |
line diff
1.1 --- a/src/screen.cc Sun Apr 13 08:06:21 2014 +0300 1.2 +++ b/src/screen.cc Sun Apr 13 09:54:36 2014 +0300 1.3 @@ -1,5 +1,35 @@ 1.4 +#include <stdlib.h> 1.5 #include <string.h> 1.6 #include "screen.h" 1.7 +#include "rbtree.h" 1.8 +#include "logger.h" 1.9 + 1.10 +MsgAtom message_atom(const char *str) 1.11 +{ 1.12 + static struct rbtree *atoms; 1.13 + static MsgAtom last_atom; 1.14 + struct rbnode *node; 1.15 + MsgAtom atom; 1.16 + 1.17 + if(!atoms) { 1.18 + if(!(atoms = rb_create(RB_KEY_STRING))) { 1.19 + printlog("fatal: message_atom failed to create symbol table\n"); 1.20 + abort(); 1.21 + } 1.22 + } 1.23 + 1.24 + if((node = rb_find(atoms, (void*)str))) { 1.25 + return *(MsgAtom*)&node->data; 1.26 + } 1.27 + 1.28 + atom = ++last_atom; 1.29 + if(rb_insert(atoms, (void*)str, (void*)atom) == -1) { 1.30 + printlog("message_atom failed to insert new atom\n"); 1.31 + --last_atom; 1.32 + return -1; 1.33 + } 1.34 + return atom; 1.35 +} 1.36 1.37 Screen::Screen() 1.38 { 1.39 @@ -47,3 +77,7 @@ 1.40 void Screen::handle_mmotion(int x, int y) 1.41 { 1.42 } 1.43 + 1.44 +void Screen::message(MsgAtom ma) 1.45 +{ 1.46 +}