refactor to move src and include

This commit is contained in:
Night Kaly 2024-07-01 03:11:07 +01:00
parent 23f1a2ab8a
commit 2e662a95c1
Signed by: night0721
GPG key ID: 957D67B8DB7A119B
7 changed files with 16 additions and 2 deletions

View file

@ -6,14 +6,16 @@ VERSION = 1.0
TARGET = vip
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1
# Flags
CFLAGS = -O3 -march=native -mtune=native -pipe -s -flto -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
SRC = vip.c term.c bar.c
SRC = src/*.c
INCLUDE = include
$(TARGET): $(SRC)
$(CC) $(SRC) -o $@ $(CFLAGS)
$(CC) $(SRC) -o $@ $(CFLAGS) -I$(INCLUDE)
dist:
mkdir -p $(TARGET)-$(VERSION)

View file

View file

View file

@ -139,6 +139,18 @@ void append_row(char *s, size_t len)
vip.rows++;
}
void row_insert_char(row *row, int at, int c)
{
if (at < 0 || at > row->size) {
at = row->size;
}
row->chars = realloc(row->chars, row->size + 2);
memmove(&row->chars[at + 1], &row->chars[at], row->size - at + 1);
row->size++;
row->chars[at] = c;
update_row(row);
}
void open_editor(char *filename)
{
free(vip.filename);