-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.h
31 lines (24 loc) · 908 Bytes
/
edit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef edit_h
#define edit_h
#include "block.h"
#define OPERATION_DELETE 0
#define OPERATION_INSERT 1
#define OPERATION_EQUALS 2
/* Represents the edits we will need to make in the end for printing */
typedef struct edit edit;
struct edit {
int operation; // 0 - Delete, 1 - Insert, 2 - Equals
block *old_block; // First block
block *new_block; // Second block
int old_line; // Line associated with the old block
int new_line; // Line associated with the new block
char *(*text)(edit *e); // text associated with the edit
};
/* returns a newly allocated edit object */
edit *edit_make(int operation, block *old_block, block *new_block, int old_line,
int new_line);
/* Returns either old_line or new_line */
char *edit_text(edit *e);
/* Prints each individual edit */
void edit_print(edit *e);
#endif