home *** CD-ROM | disk | FTP | other *** search
- #include "DeskLib:Core.h"
- #include "DeskLib:Error.h"
-
- #include "Handy.h"
- #define BUFFER_SIZE 31
-
- static char buffer[BUFFER_SIZE] [MAXLEN];
- static int last = 0; /* last entry in buffer */
- static int popPos = 0; /* last entry to be poped */
-
- int History_Push(char *string)
- {
- if(*string != NULL){
- register int index = 0;
- register int same = TRUE;
-
- while(string[index] >31 && index<BUFFER_SIZE){
- if ( (same &=(buffer[last][index] == string[index]) ) == FALSE)
- { /* if strings are different, copy string into buffer */
- index = 0;
- /* inc last modulus buf size */
- last = ++last % BUFFER_SIZE;
- while(string[index] > 31 && index<BUFFER_SIZE){
- buffer[last][index] = string[index];
- index++;
- }
- popPos = last;
- return(1);
- }
- index++;
- }
- popPos = last;
- return(2);
- }
- return(FALSE);
- }
-
- char* History_Backward(void)
- {
- popPos = --popPos % BUFFER_SIZE;
- return(&buffer[popPos][0]);
- }
-
- char* History_Forward(void)
- {
- popPos = ++popPos % BUFFER_SIZE;
- return(&buffer[popPos][0]);
- }
-
-