commit 1a917de4e940a3949123845b485e852e2f8a40e0 Author: emilia Date: Thu Mar 19 21:40:57 2026 +0100 working on editor diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8276912 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build/ +obj/ +include/ + diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..1c87f24 --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +NAME := sl_editor + +CC := gcc + +#-static -fsanitize=thread +CFLAGS := -g -ggdb -fsanitize=address -fsanitize=undefined -Og -Wall -Wextra -Werror -std=c99 -pedantic + +LDFLAGS := + +LDLIBS := -lasan -lubsan -lpthread -lreadline -lncurses + +SRC_DIR := source + +OBJ_DIR := obj + +BUILD_DIR := build + +SRC := $(wildcard $(SRC_DIR)/*.c) + +OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) + +all: $(NAME) + +$(NAME): $(OBJ) | $(BUILD_DIR) + $(CC) $(OBJ) $(LDFLAGS) $(LDLIBS) -o $(BUILD_DIR)/$(NAME) + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c $(wildcard $(SRC_DIR)/*.h) + $(CC) $(CFLAGS) -c $< -o $@ + +$(OBJ_DIR): + mkdir $(OBJ_DIR) + +$(BUILD_DIR): + mkdir $(BUILD_DIR) + +$(OBJ): | $(OBJ_DIR) + +clean: + rm -f myshell + +fclean: clean + rm -rf $(OBJ_DIR) + +re: fclean all + +.PHONY: all clean fclean re $(NAME) + diff --git a/source/main.c b/source/main.c new file mode 100644 index 0000000..caab451 --- /dev/null +++ b/source/main.c @@ -0,0 +1,102 @@ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#define STB_DS_IMPLEMENTATION +#include "../include/stb_ds.h" + +int main(int ac, char** av, char** envp) { + (void)ac; + (void)av; + (void)envp; + + if (!setlocale(LC_ALL, "")) { + printf("Unable to set local attributes from environment\n"); + return (-1); + } + bool running = true; + WINDOW* editor = 0; + WINDOW* edit_tab = 0; + WINDOW* edit_ruler = 0; + WINDOW* term = 0; + WINDOW* document = 0; + WINDOW* doc_tab = 0; + WINDOW* doc_ruler = 0; + initscr(); + cbreak(); + noecho(); + noqiflush(); + keypad(stdscr, TRUE); + start_color(); + timeout(20); + //nodelay(stdscr, TRUE); + + printf("%ix%i\n", LINES, COLS); + //2line for tab + //1 colomn for middle sep + //1 line for terminput + //2 line for sep + + edit_tab = subwin(stdscr, 1, COLS / 2, 0, 0); + editor = subwin(stdscr, LINES - 4, COLS / 2, 2, 0); + edit_ruler = subwin(stdscr, 1, COLS / 2, 1, 0); + + doc_tab = subwin(stdscr, 1, COLS / 2, 0, COLS / 2); + document = subwin(stdscr, LINES - 7, COLS / 2, 2, COLS / 2); + doc_ruler = subwin(stdscr, 1, COLS / 2, LINES - 2, COLS / 2); + + term = subwin(stdscr, 3, COLS - COLS % 2, LINES - 3, 0); + + //terminfo(); + + rl_initialize(); + rl_inhibit_completion = true;//non zero = bypasscompletion + //now need to have all my "window" + int i = 0; + while (running) { + clear(); + wborder(editor, '|', '|', '-', '-', '-', '-', '-', '-'); + wborder(document, '|', '|', '-', '-', '-', '-', '-', '-'); + //box(editor, ACS_VLINE, ACS_HLINE); + //box(document, ACS_VLINE, ACS_HLINE); + box(term, ACS_VLINE, ACS_HLINE); + + + refresh(); + wrefresh(edit_tab); + wrefresh(editor); + wrefresh(edit_ruler); + wrefresh(doc_tab); + wrefresh(document); + wrefresh(doc_ruler); + wrefresh(term); + //move(); + int ch = getch(); + if (ch != ERR) { + //process + running = false; + } + i++; + } + endwin(); +/* free(editor); + free(edit_tab); + free(edit_ruler); + free(term); + free(document); + free(doc_tab); + free(doc_ruler); +*/ + printf("number of loop:%i\n", i); + return (0); +}