summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-12-26 23:56:20 +0000
committerTim Redfern <tim@eclectronics.org>2012-12-26 23:56:20 +0000
commite4c9063867fe86dff4a89289332cef1a41410df8 (patch)
tree82b9c6599a49717c95afe75214ee75c0c232814b /src
parenta706381940821d7299e0d1eba7ab087a93e75d13 (diff)
OSX project
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.cpp2
-rwxr-xr-xsrc/testApp.cpp37
-rwxr-xr-xsrc/testApp.h14
3 files changed, 29 insertions, 24 deletions
diff --git a/src/main.cpp b/src/main.cpp
index ee028c0..c27c0e2 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,7 +6,7 @@
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(ofxFensterManager::get(),600,600, OF_WINDOW); // <-------- setup the GL context
+ ofSetupOpenGL(ofxFensterManager::get(),400,400, OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 5a18248..22c2897 100755
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -25,6 +25,10 @@ set box size - draw scrollbar & set scrollpoint - drag to scroll
insertion point/ selection - set with mouse -
get and set clipboard (ofxFensterManager.h)
+
+
+vector insert a problem performance wise?
+you need to use an iterator to insert into a vector anyway- may as well use a list
*/
@@ -33,14 +37,13 @@ editorWindow::~editorWindow(){
}
void editorWindow::setup(){
- ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 600, 600, OF_WINDOW);
+ ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 400, 400, OF_WINDOW);
win->setWindowTitle("editor");
win->addListener(this);
selected=false;
text.push_back(string(""));
}
void editorWindow::draw(){
-
for (int i=0;i<text.size();i++) {
ofDrawBitmapString(text[i],10,15+(i*12));
}
@@ -78,15 +81,19 @@ void editorWindow::draw(){
#define OF_KEY_INSERT
*/
void editorWindow::keyPressed(int key){
- printf("%i\n",key);
+ vector<string>::iterator i;
+ string t;
+ int l;
switch (key) {
case OF_KEY_RETURN:
- text.push_back(string(""));
- insertionPoint.row=text.size()-1;
+ for (i=text.begin(),l=0;l<=insertionPoint.row;i++,l++) {}
+ t=text[insertionPoint.row].substr(insertionPoint.column);
+ text[insertionPoint.row].erase(insertionPoint.column);
+ text.insert(i,t);
+ insertionPoint.row++;
insertionPoint.column=0;
break;
- case OF_KEY_LEFT:
- printf("left\n");
+ case 267: //OF_KEY_LEFT is wrong?
insertionPoint.column--;
if (insertionPoint.column<0) {
if (insertionPoint.row>0) {
@@ -96,15 +103,13 @@ void editorWindow::keyPressed(int key){
else insertionPoint.column=0;
}
break;
- case OF_KEY_UP:
- printf("up\n");
+ case 269: //OF_KEY_UP is wrong?
if (insertionPoint.row>0) {
insertionPoint.row--;
insertionPoint.column=min(insertionPoint.column,(int)text[insertionPoint.row].size());
}
break;
- case OF_KEY_RIGHT:
- printf("right\n");
+ case 268: //OF_KEY_RIGHT is wrong?
insertionPoint.column++;
if (insertionPoint.column>text[insertionPoint.row].size()) {
if (text.size()>insertionPoint.column) {
@@ -114,17 +119,17 @@ void editorWindow::keyPressed(int key){
else insertionPoint.column--;
}
break;
- case OF_KEY_DOWN:
- printf("down\n");
+ case 270: //OF_KEY_DOWN is wrong?
if (text.size()>insertionPoint.row) {
insertionPoint.row++;
insertionPoint.column=min(insertionPoint.column,(int)text[insertionPoint.row].size());
}
break;
default:
- char buf[2];
- sprintf(buf,"%c",key);
- text[insertionPoint.row]+=buf;
+ //char buf[2];
+ //sprintf(buf,"%c",key);
+ //text[insertionPoint.row]+=buf;
+ text[insertionPoint.row].insert(insertionPoint.column,1,(char)key);
insertionPoint.column++;
}
}
diff --git a/src/testApp.h b/src/testApp.h
index de24006..6c7ccf2 100755
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -3,9 +3,9 @@
#include "ofMain.h"
#include "ofxFensterManager.h"
-struct vecTexPt {
- vecTexPt(int r=0,int c=0) {row=r;column=c;};
- int row;
+struct texPt {
+ texPt(int r=0,int c=0) {row=r;column=c;};
+ int row;
int column;
};
@@ -40,10 +40,10 @@ class editorWindow: public ofxFensterListener{
void keyPressed(int key);
void keyReleased(int key);
private:
- vector<string> text;
- vecTexPt insertionPoint;
- vecTexPt selectionStart;
- vecTexPt selectionEnd;
+ vector<string> text;
+ texPt insertionPoint;
+ texPt selectionStart;
+ texPt selectionEnd;
bool selected;
};