switching to config build sys
lunix is why we can't have nice things
This commit is contained in:
parent
8ed46b1087
commit
e999245c8e
85
ke/Makefile
85
ke/Makefile
|
@ -1,50 +1,57 @@
|
||||||
BIN := ke
|
|
||||||
OBJS := main.o
|
|
||||||
INSTROOT := $(HOME)
|
|
||||||
VERSION := 0.9.2
|
VERSION := 0.9.2
|
||||||
|
CC ?= gcc
|
||||||
|
TARGET := ke
|
||||||
|
OBJS := main.o
|
||||||
|
LIBS := -lefence
|
||||||
|
|
||||||
LDFLAGS :=
|
PREFIX ?= /usr/local
|
||||||
CFLAGS := -pedantic -Wall -Werror -Wextra -O2 -std=c99 -g
|
MANDIR ?= /usr/local/man
|
||||||
CFLAGS += -fno-builtin-memmove -DKE_VERSION="\"$(VERSION)\""
|
|
||||||
|
|
||||||
.PHONY: all
|
CFLAGS += -Wall -Wextra -pedantic -Wshadow -Werror -std=c99 -g
|
||||||
all: build
|
CFLAGS += -DKE_VERSION="\"$(TARGET) version $(VERSION)\""
|
||||||
|
CFLAGS += -D_DEFAULT_SOURCE -D_POSIX_SOURCE -D_XOPEN_SOURCE
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
build: $(BIN)
|
|
||||||
|
|
||||||
$(BIN): $(OBJS)
|
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS)
|
|
||||||
|
|
||||||
$(BIN).1.txt: $(BIN).1
|
|
||||||
mandoc -Tutf8 $(BIN).1 > $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(BIN) $(OBJS) *.core keypress
|
-rm -f .?*.* *.core *.o *.html tags $(TARGET) $(OBJS)
|
||||||
|
-rm -rf security
|
||||||
|
-rm -rf $(TARGET)-$(VERSION)
|
||||||
|
-rm -f $(TARGET)-$(VERSION).tgz
|
||||||
|
|
||||||
.PHONY: run
|
$(TARGET): $(OBJS)
|
||||||
run: $(BIN)
|
${CC} -o $(TARGET) ${CFLAGS} ${LDFLAGS} $(LIBS) $(OBJS)
|
||||||
reset
|
|
||||||
./$(BIN) hello.txt
|
|
||||||
|
|
||||||
keypress: keypress.c
|
install: $(TARGET)
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ keypress.c
|
install -m 0755 $(TARGET) $(PREFIX)/bin/$(TARGET)
|
||||||
|
install -m 0755 -d $(MANDIR)/man1
|
||||||
|
install -m 0444 $(TARGET).1 $(MANDIR)/man1/$(TARGET).1
|
||||||
|
|
||||||
.PHONY: install
|
uninstall:
|
||||||
install: $(BIN) $(BIN).1
|
-rm -f $(PREFIX)/bin/$(TARGET)
|
||||||
install -d $(INSTROOT)/bin/
|
-rm -f $(MANDIR)/man1/$(TARGET).1
|
||||||
install -d $(INSTROOT)/share/man/man1
|
|
||||||
install -C $(BIN) $(INSTROOT)/bin/
|
|
||||||
install -C $(BIN).1 $(INSTROOT)/share/man/man1/$(BIN).1
|
|
||||||
|
|
||||||
.PHONY: upload
|
lint:
|
||||||
upload: $(BIN).1.txt
|
-mkdir security
|
||||||
scp main.c p.kyleisom.net:/var/www/sites/p/ke/$(BIN)_$(VERSION).c.txt
|
-rats -w 3 $(TARGET).[ch] > security/rats.out
|
||||||
scp $(BIN).1.txt p.kyleisom.net:/var/www/sites/p/ke/$(BIN).1.txt
|
-lint -fhrs $(TARGET).c > security/lint.out
|
||||||
|
-splint +posixlib $(TARGET).[ch] > security/splint.out
|
||||||
|
|
||||||
.PHONY: cloc
|
dist: clean
|
||||||
cloc:
|
-mkdir $(TARGET)-$(VERSION)
|
||||||
cloc main.c
|
-cp * $(TARGET)-$(VERSION)
|
||||||
|
-cd $(TARGET)-$(VERSION) && make distclean && cd ..
|
||||||
|
-tar czf $(TARGET)-$(VERSION).tgz $(TARGET)-$(VERSION)
|
||||||
|
|
||||||
%.o: %.c
|
distclean: clean
|
||||||
|
-rm -f Makefile
|
||||||
|
|
||||||
|
htmldoc:
|
||||||
|
-mandoc -Thtml $(TARGET).1 > $(TARGET).1.html
|
||||||
|
|
||||||
|
tags:
|
||||||
|
ctags *.[ch]
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) -c ${CFLAGS} $?
|
||||||
|
|
||||||
|
.PHONY: clean all install lint uninstall dist distclean htmldoc tags
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
VERSION := 0.9.2
|
||||||
|
CC ?= gcc
|
||||||
|
TARGET := ke
|
||||||
|
OBJS := main.o
|
||||||
|
LIBS :=
|
||||||
|
|
||||||
|
PREFIX ?= $PREFIX
|
||||||
|
MANDIR ?= $MANDIR
|
||||||
|
|
||||||
|
CFLAGS += -Wall -Wextra -pedantic -Wshadow -Werror -std=c99 -g
|
||||||
|
CFLAGS += -DKE_VERSION="\"$(TARGET) version $(VERSION)\""
|
||||||
|
CFLAGS += OS_CFLAGS
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -f .?*.* *.core *.o *.html tags $(TARGET) $(OBJS)
|
||||||
|
-rm -rf security
|
||||||
|
-rm -rf $(TARGET)-$(VERSION)
|
||||||
|
-rm -f $(TARGET)-$(VERSION).tgz
|
||||||
|
|
||||||
|
$(TARGET): $(OBJS)
|
||||||
|
${CC} -o $(TARGET) ${CFLAGS} ${LDFLAGS} $(LIBS) $(OBJS)
|
||||||
|
|
||||||
|
install: $(TARGET)
|
||||||
|
install -m 0755 $(TARGET) $(PREFIX)/bin/$(TARGET)
|
||||||
|
install -m 0755 -d $(MANDIR)/man1
|
||||||
|
install -m 0444 $(TARGET).1 $(MANDIR)/man1/$(TARGET).1
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
-rm -f $(PREFIX)/bin/$(TARGET)
|
||||||
|
-rm -f $(MANDIR)/man1/$(TARGET).1
|
||||||
|
|
||||||
|
lint:
|
||||||
|
-mkdir security
|
||||||
|
-rats -w 3 $(TARGET).[ch] > security/rats.out
|
||||||
|
-lint -fhrs $(TARGET).c > security/lint.out
|
||||||
|
-splint +posixlib $(TARGET).[ch] > security/splint.out
|
||||||
|
|
||||||
|
dist: clean
|
||||||
|
-mkdir $(TARGET)-$(VERSION)
|
||||||
|
-cp * $(TARGET)-$(VERSION)
|
||||||
|
-cd $(TARGET)-$(VERSION) && make distclean && cd ..
|
||||||
|
-tar czf $(TARGET)-$(VERSION).tgz $(TARGET)-$(VERSION)
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
-rm -f Makefile
|
||||||
|
|
||||||
|
htmldoc:
|
||||||
|
-mandoc -Thtml $(TARGET).1 > $(TARGET).1.html
|
||||||
|
|
||||||
|
tags:
|
||||||
|
ctags *.[ch]
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) -c ${CFLAGS} $?
|
||||||
|
|
||||||
|
.PHONY: clean all install lint uninstall dist distclean htmldoc tags
|
43
ke/main.c
43
ke/main.c
|
@ -15,6 +15,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -77,44 +78,43 @@ void editor_set_status(const char *fmt, ...);
|
||||||
/* miscellaneous */
|
/* miscellaneous */
|
||||||
void die(const char *s);
|
void die(const char *s);
|
||||||
int get_winsz(int *rows, int *cols);
|
int get_winsz(int *rows, int *cols);
|
||||||
void goto_line();
|
void goto_line(void);
|
||||||
void delete_row(int at);
|
void delete_row(int at);
|
||||||
void row_append_row(struct erow *row, char *s, int len);
|
void row_append_row(struct erow *row, char *s, int len);
|
||||||
void row_insert_ch(struct erow *row, int at, int16_t c);
|
void row_insert_ch(struct erow *row, int at, int16_t c);
|
||||||
void row_delete_ch(struct erow *row, int at);
|
void row_delete_ch(struct erow *row, int at);
|
||||||
void insertch(int16_t c);
|
void insertch(int16_t c);
|
||||||
void deletech();
|
void deletech(void);
|
||||||
void open_file(const char *filename);
|
void open_file(const char *filename);
|
||||||
char *rows_to_buffer(int *buflen);
|
char *rows_to_buffer(int *buflen);
|
||||||
int save_file();
|
int save_file(void);
|
||||||
uint16_t is_arrow_key(int16_t c);
|
uint16_t is_arrow_key(int16_t c);
|
||||||
int16_t get_keypress();
|
int16_t get_keypress(void);
|
||||||
void display_refresh();
|
void display_refresh(void);
|
||||||
void editor_find_callback(char *query, int16_t c);
|
void editor_find_callback(char *query, int16_t c);
|
||||||
void editor_find();
|
void editor_find(void);
|
||||||
char *editor_prompt(char *, void (*cb)(char *, int16_t));
|
char *editor_prompt(char *, void (*cb)(char *, int16_t));
|
||||||
void editor_openfile();
|
void editor_openfile(void);
|
||||||
void move_cursor(int16_t c);
|
void move_cursor(int16_t c);
|
||||||
void newline();
|
void newline(void);
|
||||||
void process_kcommand(int16_t c);
|
void process_kcommand(int16_t c);
|
||||||
void process_normal(int16_t c);
|
void process_normal(int16_t c);
|
||||||
void process_escape(int16_t c);
|
void process_escape(int16_t c);
|
||||||
int process_keypress();
|
int process_keypress(void);
|
||||||
void enable_termraw();
|
void enable_termraw(void);
|
||||||
void display_clear(struct abuf *ab);
|
void display_clear(struct abuf *ab);
|
||||||
void disable_termraw();
|
void disable_termraw(void);
|
||||||
void setup_terminal();
|
void setup_terminal(void);
|
||||||
void draw_rows(struct abuf *ab);
|
void draw_rows(struct abuf *ab);
|
||||||
char status_mode_char();
|
char status_mode_char(void);
|
||||||
void draw_status_bar(struct abuf *ab);
|
void draw_status_bar(struct abuf *ab);
|
||||||
void draw_message_line(struct abuf *ab);
|
void draw_message_line(struct abuf *ab);
|
||||||
void scroll();
|
void scroll(void);
|
||||||
void display_refresh();
|
void display_refresh(void);
|
||||||
void editor_set_status(const char *fmt, ...);
|
void editor_set_status(const char *fmt, ...);
|
||||||
void loop();
|
void loop(void);
|
||||||
void init_editor();
|
void init_editor(void);
|
||||||
void process_normal(int16_t c);
|
void process_normal(int16_t c);
|
||||||
void disable_termraw();
|
|
||||||
|
|
||||||
|
|
||||||
enum KeyPress {
|
enum KeyPress {
|
||||||
|
@ -133,6 +133,10 @@ enum KeyPress {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* editor is the global editor state; it should be broken out
|
||||||
|
* to buffers and screen state, probably.
|
||||||
|
*/
|
||||||
struct editor_t {
|
struct editor_t {
|
||||||
struct termios entry_term;
|
struct termios entry_term;
|
||||||
int rows, cols;
|
int rows, cols;
|
||||||
|
@ -172,7 +176,6 @@ ab_free(struct abuf *buf)
|
||||||
buf->b = NULL;
|
buf->b = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char
|
char
|
||||||
nibble_to_hex(char c)
|
nibble_to_hex(char c)
|
||||||
{
|
{
|
||||||
|
@ -899,6 +902,8 @@ move_cursor(int16_t c)
|
||||||
while (--reps) {
|
while (--reps) {
|
||||||
move_cursor(c == PG_UP ? ARROW_UP : ARROW_DOWN);
|
move_cursor(c == PG_UP ? ARROW_UP : ARROW_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case HOME_KEY:
|
case HOME_KEY:
|
||||||
|
|
Loading…
Reference in New Issue