::edit:: this is a bit overcomplicated in my opinion! say the word if you want a simple/better explaination, tomorrow!
i'll give you the concept, and if i can get time i'll try and write a working code example
there are a few qustions!
followed by what the ~pseudo example will use
1. how many characters per line? 80
2. how many line to display at once? 4
3. how many refernce lines of text to store? 100
4. what key starts text input? Return/enter key
5. how to store them? a inked list will be the easiest method!
ok heres some ~psuedo code! keep in mind there are possibly better more efficient ways, this is just the basic idea!
this is a simple example that ignores system keys(capslock,shift,ect)
i'll use windows messages as the example since its easiest to use and easily converted! but it has one down fall it uses Virtual keycodes so its kind of a pain to get punctuations and certain other keys to work properly!
btw: if this is cryptic or you cant understand parts of it, or you just want a plain text explaination!!! LET ME KNOW!!!!! because i don't know what you know and if there are things i misexplained or your not ready for or you need a different explaination, there are other different methods!
// use const or define whichever you prefer
#define MAX_VIEWABLE_LINES 4
#define MAX_LINE_LENGTH 80
#define MAX_STORED_LINES 100
}Linked List Node;
ect. ect... end up with a linked list;
int Current_Line_Length = 0
int Current_Line_Count = -1;
bool newline = false; // new line signal
bool typing = false; // flag if user is currently typing or not
linked list input_text_head; // used as head stores no text;
linked list* currentlinkpos = input_text->next; // current link
currentlinkpos = new node; // allocate storage
// draw a simple cursor if we're typing
get the current text pos! // depends on what kind of text how to do this
DrawText(current x, current y,"_");
// draw all the lines of text
for(int i = 0, linked list c = input_text->nexy; i < MAX_VIEWABLE_LINES;i++, c = c->next)
//in wndproc function
// check if over the max lines count
if(Current_Line_Count >= MAX_STORED_LINES)
// remove the oldest link and make room for a new one
linked list t;
t = input_text->next->next;
input_text->next = t;
if(typing ) // i were typing
// if were on a new line or have reached max line length(newline)
// if so alocate a new link
if(newline || Current_Line_Length >= MAX_LINE_LENGTH-1)
newline = false;
currentlinkpos->text = new unsigned char[MAX_LINE_LENGTH];
currentlinkpos->next = new node;
// nul the line to prevent printing errors
Current_Line_Length = 0;
currentlinkpos = currentlinkpos->next; // updat current link pos
// check for a graphical character or space and add it to the string
if(isgraph(wParam) || wParam == VK_SPACE)
currentlinkpos->text[Current_Line_Length ] = wParam;
// check for return to start of a or end of a line of text!
if(wParam == VK_RETURN)
// if they're not typeing then it has to be a new line of text!
newline = true;
typing = !typing;
disable other input response
by the way im sorry for any errors! its 1 am so im not really sure of much, i just hope this can help!