aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-06-12 20:48:30 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-06-12 20:48:30 +0200
commit7756a11530d9338954922c1df8e57c66a89fbdea (patch)
tree1fc4f9f070de5b1882f5953713f27e02b66a81e5 /src/main.cpp
downloadascedit-7756a11530d9338954922c1df8e57c66a89fbdea.tar.gz
Initial commit
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..b6be560
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,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;
+}