aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: b6be5603319ba71e0d76a56d4ba555e6f38966ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <cObject.h>
#include <cObjectHandler.h>
#include <cRender.h>
#include <cInput.h>

#include "editor.h"
#include "colorpicker.h"

class status : public cObject
{
public:
	status(unsigned int width) { setSize(10,5); }
	~status() { destruct(); }
};

int main() {
	cRender render(' ', _COL_DEFAULT);
	cObjectHandler handler(&render, true, false);
	cInput input;
	render.render();

	editor edit({30,30});
	unsigned int edit_id = handler.createObject(&edit);

	colorpicker pick;
	unsigned int pick_id = handler.createObject(&pick);

	handler.moveObject(pick_id, {34, 0}, _MOVE_ABSOLUTE);

	render.setTargetFPS( 60 );

	while ( 1 ){
		sInputEvent ie = input.poll();
		if ( ie.type != _EVENT_NULL ) {
			if ( ie.type == _EVENT_KEY ) {
				switch ( ie.c ) {
					case 'A'://up
						edit.moveCursor({0,-1});
						break;
					case 'B'://down
						edit.moveCursor({0,1});
						break;
					case 'D'://Left
						edit.moveCursor({-1,0});
						break;
					case 'C'://Right
						edit.moveCursor({1,0});
						break;
				};//switch
			}//if
			else if ( ie.type == _EVENT_MOUSE ) {
				if ( ie.b == 0 )
					handler.clickEvent({ie.x, ie.y}, 0);
			}// if
			else if ( ie.type == _EVENT_CHAR )
			{
				switch ( ie.c )
				{
					case 'w':
						break;
					case 's':
						break;
					case 'g':
						render.enableDebugInfo(true);
						break;
					case 'G':
						render.enableDebugInfo(false);
						break;
					default:
						handler.charEvent( ie.c );
				};//switch
			}//if
			else if ( ie.type == _EVENT_TERM ) {
				return 0;
			}//if
		}//if

		handler.write();
		render.render();
	}
	
	return 0;
}