Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Improvements #82

Merged
merged 9 commits into from Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -32,6 +32,9 @@ Run the executable:
This will open the editor view. Move the cursor with the arrow keys, and type to
insert text. Switch between input modes with `<TAB>`, and exit with `<CTRL+C>`.

COLLASCII also offers a command line interface - run `./collascii --help` for
more information on the CLI and using COLLASCII itself.

To export your art, you can save it a file with `<CTRL+S>`, or copy it off of
the screen. Most terminals support some sort of block select, which makes this a
little easier.
Expand All @@ -42,6 +45,15 @@ For `gnome-terminal` on Ubuntu (and some others):
- `CTRL+SHIFT+C` to copy to your clipboard
- paste it wherever you want! (including within COLLASCII)

#### Server

The networking as a whole is slightly rougher around the edges than the rest of
this project, but you can build the server right now with
`make server.out`.

Run it with an optional file to load from:
`./server.out art.txt`

### Installing Dependencies

Building and using COLLASCII requires [the NCURSES library](https://invisible-island.net/ncurses/).
Expand Down
8 changes: 4 additions & 4 deletions src/Makefile
Expand Up @@ -2,7 +2,7 @@ CC=gcc
CFLAGS+=-Wall -std=gnu99

version = $(shell git describe --always --tags --dirty)
CFLAGS+="-DVERSION=version"
CFLAGS+="-DVERSION=\"$(version)\""

# add debug annotations, turn off optimizations, and #define DEBUG
# use in bash with `DEBUG=1 make <foo>`
Expand Down Expand Up @@ -30,8 +30,8 @@ endif
collascii: frontend.out
mv frontend.out collascii

frontend.out: LDLIBS +=-lncurses
frontend.out: cursor.o fe_modes.o canvas.o view.o network.o
frontend.out: LDLIBS +=-lncurses -lm
frontend.out: cursor.o fe_modes.o canvas.o view.o network.o lib/argtable3.o

server.out: LDLIBS +=-lpthread
server.out: canvas.o
Expand All @@ -57,7 +57,7 @@ test: $(patsubst %.c, .run-%.c, $(wildcard *_test.c))
# add flags for minunit libraries, works with `make test_foo` too
%_test: LDLIBS+=-lrt -lm
# require foo.c, foo_test, and minunit.h for foo_test
%_test: %.o %_test.c minunit.h
%_test: %.o %_test.c lib/minunit.h
$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@

clean:
Expand Down
29 changes: 1 addition & 28 deletions src/canvas_test.c
@@ -1,5 +1,5 @@
#include "canvas.h"
#include "minunit.h"
#include "lib/minunit.h"
#include "util.h"

static int cols = 2;
Expand Down Expand Up @@ -179,12 +179,6 @@ MU_TEST(test_canvas_cpy_p1p2) {

c4 = canvas_cpy_p1p2(c3, 1, 1, c3->num_rows - 1, c3->num_cols - 1);

printf("\nc3\n");
canvas_print(c3);

printf("\nc4\n");
canvas_print(c4);

mu_assert_int_eq(2, c4->num_cols);
mu_assert_int_eq(2, c4->num_rows);
mu_assert_int_eq(canvas_gcharyx(c3, 1, 1), canvas_gcharyx(c4, 0, 0));
Expand All @@ -196,12 +190,6 @@ MU_TEST(test_canvas_ldcanvasyx) {
int res = canvas_ldcanvasyx(c2, c1, 1, 1);
mu_assert_int_eq(1, res);

// printf("c1\n");
// canvas_print(c1);

// printf("c2\n");
// canvas_print(c2);

mu_assert(!canvas_eq(c1, c2), "Canvases should not be equal");

// check left column
Expand All @@ -224,12 +212,6 @@ MU_TEST(test_canvas_ldcanvasyxc) {
int res = canvas_ldcanvasyxc(c2, c1, 1, 1, '2');
mu_assert_int_eq(1, res);

// printf("c1\n");
// canvas_print(c1);

// printf("c2\n");
// canvas_print(c2);

mu_assert(!canvas_eq(c1, c2), "Canvases should not be equal");

// check left column
Expand All @@ -250,20 +232,11 @@ MU_TEST(test_canvas_trimc) {
canvas_fill(c2, ' ');
canvas_ldcanvasyx(c2, c1, 1, 1);

printf("\nc1\n");
canvas_print(c1);
printf("\nc2\n");
canvas_print(c2);

Canvas *c3 = canvas_trimc(c2, ' ', true, true, true, true);
printf("\nc3\n");
canvas_print(c3);
mu_assert_int_eq(1, c3->num_cols);
mu_assert_int_eq(2, c3->num_rows);

Canvas *c4 = canvas_cpy_p1p2(c2, 1, 1, c3->num_cols - 1, c3->num_rows - 1);
printf("\nc4\n");
canvas_print(c4);

canvas_free(c2);
canvas_free(c3);
Expand Down