Updating a bunch of stuff.

This commit is contained in:
Kyle Isom 2020-02-11 22:47:57 -08:00
parent fe3694fe68
commit 688b44914d
12 changed files with 49 additions and 19 deletions

View File

@ -6,7 +6,6 @@ TESTS = tests/dirlist_test \
dist_noinst_DATA = LICENSE \
testdata \
README \
example/ \
autobuild.sh
test: check

View File

@ -2,8 +2,8 @@ AC_PREREQ([2.59])
AC_INIT([kst], [1.0.0], [kyle@imap.cc],
[libdirutils], [https://hg.sr.ht/~kisom/kst])
AM_INIT_AUTOMAKE([1.11 foreign subdir-objects])
AC_CONFIG_SRCDIR([docs/srm.1])
AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile test/Makefile])
AC_CONFIG_SRCDIR([doc/srm.1])
AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile tests/Makefile])
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB

View File

@ -91,6 +91,7 @@ erow_insert(int at, char *s, int len)
assert(editor->row != NULL);
if (at < editor->nrows) {
printf("%d, %d\n", at, editor->nrows);
memmove(&editor->row[at+1], &editor->row[at],
sizeof(struct erow) * (editor->nrows - at + 1));
}

View File

@ -40,6 +40,8 @@
void editor_set_status(const char *fmt, ...);
void display_refresh();
char *editor_prompt(char *, void (*cb)(char *, int16_t));
void init_editor();
void process_normal(int16_t c);
enum KeyPress {
@ -547,6 +549,24 @@ editor_find()
}
void
editor_openfile()
{
char *filename;
/* TODO(kyle): combine with dirutils for tab-completion */
filename = editor_prompt("Load file: %s", NULL);
if (filename == NULL) {
return;
}
free(editor->row);
init_editor();
open_file(filename);
}
void
move_cursor(int16_t c)
{
@ -667,10 +687,18 @@ process_kcommand(int16_t c)
case 'w':
exit(save_file());
case 'd':
while ((editor->row[editor->cury].size - editor->curx) > 0) {
process_normal(DEL_KEY);
}
break;
case CTRL_KEY('\\'):
/* sometimes it's nice to dump core */
disable_termraw();
abort();
case 'e':
case CTRL_KEY('e'):
editor_openfile();
break;
case 'f':
editor_find();
break;

View File

@ -2,9 +2,9 @@ CFLAGS := -pedantic -Wall -Werror -Wextra -O2 -std=c99 -g
lib_LIBRARIES := libdirutils.a libiniparser.a
nobase_include_HEADERS := kst/dirutils.h \
kst/iniparser.h \
dist_noinst_HEADERS := kst/dirlist.h
bin_PROGRAMS := srm
kst/iniparser.h
dist_noinst_HEADERS = kst/dirlist.h
bin_PROGRAMS = srm
## programs
@ -13,7 +13,7 @@ srm_SOURCES = srm.c
## libraries
libdirutils_a_SOURCES = dirutils.c dirlist.c dirwalk.c dirlist.h
libiniparser_a_SOURCES = iniparser.c

View File

@ -147,7 +147,7 @@ _rmdirs(const char *path)
char child[FILENAME_MAX + 1];
struct dirent *dp;
DIR *dirp;
int fail;
int fail = EXIT_FAILURE;
if (NULL == (dirp = opendir(path))) {
return EXIT_FAILURE;

View File

@ -21,9 +21,9 @@
#define __DIRUTILS_DIRLIST_H
#include <sys/queue.h>
#include <stdio.h>
#include <dirent.h>
#include "queue.h"
struct dirlst {

View File

@ -1,9 +0,0 @@
AM_LDFLAGS = -L/usr/local/include -lcunit -L../src/
AM_CFLAGS = -Wall -g -I/usr/local/include -I../src -O0
check_PROGRAMS = dirlist_test dirutils_test
dirlist_test_CFLAGS = $(AM_CFLAGS)
dirlist_test_SOURCES = dirlist_test.c
dirutils_test_CFLAGS = $(AM_CFLAGS)
dirutils_test_SOURCES = dirutils_test.c

9
tests/Makefile.am Normal file
View File

@ -0,0 +1,9 @@
AM_LDFLAGS = -L/usr/local/lib -lcunit
AM_CFLAGS = -Wall -g -I/usr/local/include -I../src -O0
check_PROGRAMS = dirlist_test dirutils_test iniparser-test
dirlist_test_SOURCES = dirlist_test.c ../src/dirlist.c
dirutils_test_SOURCES = dirutils_test.c ../src/dirlist.c ../src/dirutils.c
iniparser_test_SOURCES = iniparser_test.c ../src/iniparser.c

View File

@ -45,6 +45,7 @@ main(int argc, char *argv[])
argc--;
argv++;
iniparser_line_init(&line);
for (i = 0; i < argc; i++) {
printf("Processing %s\n", argv[i]);
ret = iniparser_open(argv[i], &file);
@ -92,5 +93,6 @@ exit:
iniparser_destroy();
}
return ret==0;
return ret!=0;
}