J
John N.
Hi All,
Here I have a linked list each containing a char and is double linked.
Then I have a pointer to an item in that list which is the current
insertion point.
In this funtion, the user hits the right
and left keys to move this insertion point (cursor)
Here is the problem:
But its not stable, the insertion point seems to skip an item
back, here and there. It could be the API Im using for the keyboard
input but Im not sure.
Thanks in advance for any help.
John
//a char structure, making a text string list
struct Word{
char *c;
struct Word *next,*back;
};
typedef struct Word Word;
Word *wrd;// a linked list of Word structures
Word *insert;// pointer to the current insertion point of *wrd
wrd = (allocate a list of Word structures)
insert = (pointer to an insertion point in the text in the *wrd list)
DoKey(insert,RIGHT_KEY);
/* etc */
void DoKey(struct Word *char_insert, int key){
switch(key){
case RIGHT_KEY:
if(char_insert->next!=NULL)
char_insert=char_insert->next;/* this is not fool proof,
any help? */
break;
case LEFT_KEY:
if(char_insert->back!=NULL)
char_insert=char_insert->back;/* this is not fool proof,
any help? */
break;
}
}
Here I have a linked list each containing a char and is double linked.
Then I have a pointer to an item in that list which is the current
insertion point.
In this funtion, the user hits the right
and left keys to move this insertion point (cursor)
Here is the problem:
But its not stable, the insertion point seems to skip an item
back, here and there. It could be the API Im using for the keyboard
input but Im not sure.
Thanks in advance for any help.
John
//a char structure, making a text string list
struct Word{
char *c;
struct Word *next,*back;
};
typedef struct Word Word;
Word *wrd;// a linked list of Word structures
Word *insert;// pointer to the current insertion point of *wrd
wrd = (allocate a list of Word structures)
insert = (pointer to an insertion point in the text in the *wrd list)
DoKey(insert,RIGHT_KEY);
/* etc */
void DoKey(struct Word *char_insert, int key){
switch(key){
case RIGHT_KEY:
if(char_insert->next!=NULL)
char_insert=char_insert->next;/* this is not fool proof,
any help? */
break;
case LEFT_KEY:
if(char_insert->back!=NULL)
char_insert=char_insert->back;/* this is not fool proof,
any help? */
break;
}
}