added some terminal things, added debugging to buildfile
This commit is contained in:
16
main.c
16
main.c
@@ -2,6 +2,10 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define ZED_CAPACITY 1024
|
||||
|
||||
typedef struct {
|
||||
@@ -13,12 +17,24 @@ static Editor editor = {0};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (!isatty(0)) {
|
||||
fprintf(stderr, "Please run in the terminal!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: zed <input.txt>\n");
|
||||
fprintf(stderr, "ERROR: no input file was provided\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// stores the state of the terminal
|
||||
struct termios term;
|
||||
if (tcgetattr(0, &term)) {
|
||||
fprintf(stderr, "ERROR: could not save the state of the terminal\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *file_path = argv[1];
|
||||
FILE *f = fopen(file_path, "rb");
|
||||
if (f == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user