summaryrefslogtreecommitdiff
path: root/editor.h
blob: 578a91e76d2f3cf1d45a7c8317ccd5f97691f652 (plain)
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
#pragma once

#include <time.h>
#include "buffer.h"

struct editor_state {
	int cursor_x, cursor_y;
	int cursor_display_x;
	int row_offset;
	int col_offset;
	int screen_rows;
	int screen_cols;
	int row_count;
	struct editor_row* rows;
	int dirty;
	char* filename;
	char status_message[80];
	time_t status_message_time;
	struct editor_syntax* syntax;
};

void init_editor(struct editor_state* editor);

void editor_set_status_message(struct editor_state* editor, const char* format, ...);
void editor_refresh_screen(struct editor_state* editor);
char* editor_prompt(struct editor_state* editor, char* prompt, void (*callback)(struct editor_state*, char*, int));

void editor_insert_char(struct editor_state* editor, int c);
void editor_insert_newline(struct editor_state* editor);
void editor_delete_char(struct editor_state* editor);
void editor_find(struct editor_state* editor);
void editor_scroll(struct editor_state* editor);
void editor_draw_rows(struct editor_state* editor, struct append_buffer* buffer);
void editor_draw_status_bar(struct editor_state* editor, struct append_buffer* buffer);
void editor_draw_message_bar(struct editor_state* editor, struct append_buffer* buffer);