-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline_Editor.h
56 lines (46 loc) · 1.47 KB
/
line_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include "buffer.h"
#include <stdbool.h>
/**
* Reads an entire line from stdin; stores the address of the buffer
* containing the text in the given 'lineptr' parameter
*
* SideEffect: The proccess from which this function is envoked is blocked
* (paused) until return; IE
*
*/
void get_line(char **lineptr);
/*Struct for cursor position*/
typedef struct pos {
int x;
int y;
} cPos;
// TODO make these coments shorter
// Todo rename struct to LineEditorInfo
/*This struct should contain infromation related to the line editor*/
typedef struct LineData {
struct termios oldt; // orignal terminal settings
ldBuffer * ldb; // character buffer that getLine() returns when enter is pressed
struct winsize ws; // For terminal window size information into the struct
// The start position that the cursor assumes with every
// new line; the cursor may not move any more left of this
// positoin
cPos initP;
int cursIdex;
int lineEndPos;
// The end position of the current line; cursor may not
// move past this position; increased when keys are typed;
// dec when delete pressed
cPos maxP;
// Current cursor position
cPos curP;
bool terminate; // used to ditect when to terminate the line editing proccess
} LineData;
/*
Line Editor stores the address of the buffer containing the inputed terminal text string once
enter has been pressed
*/
void ldGetLine(char ** lineptr);