Google Answers Logo
View Question
 
Q: hiking in new mexico ( No Answer,   1 Comment )
Question  
Subject: hiking in new mexico
Category: Computers > Programming
Asked by: rejct-ga
List Price: $10.00
Posted: 04 Nov 2002 22:21 PST
Expires: 06 Nov 2002 11:23 PST
Question ID: 99050
all in C code
Command	Operation
F	Moves the editing cursor forward one character position
B	Moves the editing cursor backward one character position
J	Jumps to the beginning of the buffer (before the first character)
E	Moves the cursor to the end of the buffer (after the last character)
I	Inserts the characters xxx at the current cursor position
D	Deletes the character just after the current cursor position.

use the following type definition
for the nodes of this linked list:
typedef struct node{
   char ch;
   struct node *link;
}  node;

The data structure for the buffer must contain at least two fields:
one pointer where the buffer starts and
one pointer to indicate the current cursor position 

typedef struct bufferType{
   node *start;
   node *cursor;
   ...
} bufferType;

typedef bufferType *bufferT;


   function prototypes in program:
/* This function dynamically allocates enough memory for the
underlying representation of a buffer and initializes to represent an
empty buffer
*/
bufferT NewBuffer();

/* This function frees the storage associated with the buffer.
*/
void FreeBuffer(bufferT buffer);

/* These functions move the cursor forward or backward one character
respectively. If Move CursorForward is called at the end of the buffer
or MoveCursorBackward is called at the beginning, the function call
has no effect.
*/
void MoveCursorForward(bufferT buffer);
void MoveCursorBackward(bufferT buffer);

/* These functions move the cursor to the start or to the end of the
buffer, respectively
*/
void MoveCursorToStart(bufferT buffer);
void MoveCursorToEnd(bufferT buffer);

/* This function inserts the single character ch into the buffer at
the current cursor position. The cursor is positioned after the
inserted character, which allows for consecutive insertions.
*/
void InsertCharacter(bufferT buffer, char c);

/* This function deletes the character immediately after the cursor.
If cursor is already at the end the function has no effect.
*/
void DeleteCharacter(bufferT buffer);

/* This function displays the current contents of the buffer on the
screen (as a sequence of characters)
*/
void DisplayBuffer(bufferT buffer);

/* This function stores a copy of the next count characters somewhere
in the internal structure for the buffer.
*/
void CopyFromBuffer(bufferT buffer, int count);

/* This function inserts those saved characters back into the buffer
at the current cursor position
*/
void PasteIntoBuffer(bufferT buffer);

/* This function stores a copy of the next count characters somewhere
in the internal structure for the buffer and then deletes those count
characters from the buffer.
*/
void CutFromBuffer(bufferT buffer, int count);

Request for Question Clarification by scriptor-ga on 05 Nov 2002 05:32 PST
Dear reject,

That is a highly challenging, fascinating problem. Alas, the
connection with hiking in New Mexico remains a bit unclear.

Regards,
Scriptor

Clarification of Question by rejct-ga on 05 Nov 2002 07:43 PST
the subject line has nothing to do with the prog... the prog is
supposed to work like a simple word editor
Answer  
There is no answer at this time.

Comments  
Subject: Re: hiking in new mexico
From: mathtalk-ga on 05 Nov 2002 09:35 PST
 
If the question is whether I would program all those functions for ten
dollars, the answer is pretty easy.

If you are looking for comments on the design, the use of a singly
linked list structure for the buffer seems a little cramped.  Wouldn't
a doubly linked list be more useful?  Or a simple character array; or
is this a condition of the assignment, use singly linked lists in this
manner?

regards, mathtalk-ga

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy