So i thought about some kind of algorith that could go like this
read buffer if not 0 then add to list on the line, else if 0 read buffer again and see what key it is(something like enter, key down, esc .....) if the key is enter move to next line and that would be a second link list of line in the link list of column
My problem is big for me, so far im just trying to make the lines link lists work, then ill get into the columns linked lists(i have no idea on how to make a linked list of linked lists) but i have seen this in my dreams
Here is what i have so far for the link list of lines aka rows, any idea, comments, remarks. Would be greatly appresiated, i started this like 2 hours ago so its pretty much nothing
#include <iostream>
#include <conio.h>
#include "definitions.h"
using namespace std;
class Letter{
public:
char letter;
Letter *next;
Letter *prev;
};
class Wr{
protected:
Letter *start,*end;
public:
Wr(){start=NULL;};
bool read();
void add(char letter);
void show();
void lshow();
void remove();
};
void Wr::lshow(){
while(start!=NULL){
cout<<start->letter;
start=start->next;
}
}
void Wr::remove(){
Letter *temp;
end->letter=' ';
show();
temp=end;
end=temp->prev;
delete temp;
}
void Wr::add(char letter){
Letter *temp;
temp=new Letter;
temp->letter=letter;
temp->next=NULL;
temp->prev=NULL;
if(start==NULL)
start=end=temp;
else{
temp->prev=end;
end->next=temp;
end=temp;
}
}
void Wr::show(){
cout<<end->letter;
}
bool Wr::read(){
Letter *cur;
cur=end;
char let=_getch();
if(let!=0){
add(let);
}
else
if(let==0)
let=_getch();
if(let==KEY_RIGHT)
if(cur->next!=NULL)
cur=cur->next;
else
cur=cur;
else
if(let==KEY_LEFT)
if(cur->prev!=NULL)
cur=cur->prev;
else
cur=cur;
else
if(let==13)
cout<<endl;
else
if(let==27)
return false;
else
if(let==127)
remove();
return true;
}
int main(){
Wr r;
bool flag=true;
while(flag==true){
flag=r.read();
r.show();
}
cout<<endl;
r.lshow();
cin.ignore();
cin.get();
}
The definitions library is
#ifndef definitions_H_ #define definitions_H_ #define KEY_HOME 71 #define KEY_UP 72 #define KEY_PGUP 73 #define KEY_LEFT 75 #define KEY_CENTER 76 #define KEY_RIGHT 77 #define KEY_END 79 #define KEY_DOWN 80 #define KEY_PGDN 81 #define KEY_INSERT 82 #define KEY_DELETE 83 #define KEY_F1 59 #define KEY_F2 60 #define KEY_F3 61 #define KEY_F4 62 #define KEY_F5 63 #define KEY_F6 64 #define KEY_F7 65 #define KEY_F8 66 #define KEY_F9 67 #endif
Ok well im working on console to make the correspondant tests, but my IDE (Visual Studio 2008) wont let me use clrscr() to clean the console, im guessing ill need something else, so i cant do tests on remove and the move left and right functions.
Either way any comments would be great!

New Topic/Question
Reply




MultiQuote




|