/* undo.h - include file for the undo package */

#ifndef _UNDO_H_
#define _UNDO_H_

#include <sys/types.h>
#include <sys/queue.h>
#include "str.h"


/* Undo record. */

typedef struct {
    int group;
    ssize_t loc;
    size_t len;
    ssize_t delta;
    str* s;
    size_t point, mark;
    bool modified;
    } undo_record;

undo_record* undo_record_create( void );
void undo_record_destroy( undo_record* ur );


/* Undo record stack. */

SLIST_HEAD( undo_stack_head, undo_stack_entry );
typedef struct undo_stack_head undo_stack;

undo_stack* undo_stack_create( void );
bool undo_stack_empty( undo_stack* us );
bool undo_stack_push( undo_stack* us, undo_record* ur );
undo_record* undo_stack_top( undo_stack* us );
undo_record* undo_stack_pop( undo_stack* us );
void undo_stack_clear( undo_stack* us );
void undo_stack_destroy( undo_stack* us );

#endif /* _UNDO_H_ */
