-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor.h
41 lines (36 loc) · 945 Bytes
/
editor.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
32
33
34
35
36
37
38
39
40
41
#ifndef __EDIT__
#define __EDIT__
#include <ncurses.h>
#include <stdlib.h>
#include <string.h>
typedef struct line line;
typedef struct line {
int len;
char *c;
line *next;
} line;
typedef struct editor {
int cx, cy;
int height, width;
int num_rows;
int current_row;
int should_close;
int scroll_offset;
char *filename;
line *head;
} editor;
void init_editor(editor *editor);
void init_ncurses();
void end_ncurses();
void insert_char(editor *editor, int c);
void insert_new_line(editor *editor);
void print_rows(editor *editor);
void update_cursor_position(editor *editor, int key);
void delete_char(editor *editor);
line *get_current_line_position(editor *editor);
void save_file(editor *editor);
void load_file(editor *editor, const char *name);
void free_lines(line *head);
void scroll_rows(editor *editor);
void free_editor(editor *editor);
#endif