began user interface and made functional

This commit is contained in:
Noah Swerhun 2021-07-01 00:20:09 -05:00
parent 8d5478c6bb
commit 87b1a9d38d
9 changed files with 64 additions and 16 deletions

View file

@ -1,5 +1,5 @@
CC = gcc
CFLAGS = -Wall -Wextra -pedantic-errors -std=c99 -Wno-format
CFLAGS = -Wall -Wextra -pedantic-errors -std=c99 -Wno-format -lncurses
OUTFILE = cards
SRCDIR = src

BIN
cards

Binary file not shown.

View file

@ -1,5 +0,0 @@
the,quick
brown,fox
jumped,over
the,lazy
dog,foobar
1 the quick
2 brown fox
3 jumped over
4 the lazy
5 dog foobar

6
example.tsv Normal file
View file

@ -0,0 +1,6 @@
What is T-Mobile Home Internet? T-Mobile Home Internet is a new offering from T-Mobile, available to customers at certain addresses.
How much does the T-Mobile Home Internet plan cost? T-Mobile Home Internet is just $60 all in with AutoPay for customers who already have (or switch to) a tax included plan, or $60 with AutoPay plus taxes and fees for customers already on a tax exclusive wireless plan.
Is there a data cap on the T-Mobile Home Internet service? Nope! There are no data caps on our 5G Home Internet service.
What type of T-Mobile home internet speeds can I expect? We anticipate some T-Mobile Home Internet customers will see average download speeds in excess of 100 Mbps, and all eligible households will see average download speeds of 25 Mbps or more.
Can I purchase higher-speed service? No confusing charts with multiple speed options that do who-knows-what. Customers will get the max speed the network is able to offer at their home location.
Are there ways I cannot use T-Mobile Home Internet? You can use your Home Internet for all the homework, streaming, and video conferencing you need! But to ensure that our network is available for all customers, there are some restrictions on activities that can damage or disproportionately congest the network.
1 What is T-Mobile Home Internet? T-Mobile Home Internet is a new offering from T-Mobile, available to customers at certain addresses.
2 How much does the T-Mobile Home Internet plan cost? T-Mobile Home Internet is just $60 all in with AutoPay for customers who already have (or switch to) a tax included plan, or $60 with AutoPay plus taxes and fees for customers already on a tax exclusive wireless plan.
3 Is there a data cap on the T-Mobile Home Internet service? Nope! There are no data caps on our 5G Home Internet service.
4 What type of T-Mobile home internet speeds can I expect? We anticipate some T-Mobile Home Internet customers will see average download speeds in excess of 100 Mbps, and all eligible households will see average download speeds of 25 Mbps or more.
5 Can I purchase higher-speed service? No confusing charts with multiple speed options that do who-knows-what. Customers will get the max speed the network is able to offer at their home location.
6 Are there ways I cannot use T-Mobile Home Internet? You can use your Home Internet for all the homework, streaming, and video conferencing you need! But to ensure that our network is available for all customers, there are some restrictions on activities that can damage or disproportionately congest the network.

Binary file not shown.

Binary file not shown.

View file

@ -12,10 +12,10 @@ CARD new_card(char *o, char *r) {
return c;
}
CARD* card_parse_csv(char *f, size_t *ct) {
CARD* card_parse_csv(char *f, int *ct) {
FILE *fp;
char *l, *o, *r;
const char *delims = ",\0";
const char *delims = " \0";
CARD *ca;
if ((fp = fopen(f, "r")) == NULL)

View file

@ -8,6 +8,6 @@ typedef struct card_T {
CARD new_card(char *, char *);
CARD* card_parse_csv(char *, size_t *);
CARD* card_parse_csv(char *, int *);
#endif

View file

@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ncurses.h>
#include "include/main.h"
#include "include/card.h"
@ -9,9 +10,7 @@ void die(char *s) {
fprintf(stderr, "fatal: %s\n", s);
exit(1);
}
char *fgetl(FILE *stream) {
size_t s_sz = 1; // +1 for null byte
char *fgetl(FILE *stream) { size_t s_sz = 1; // +1 for null byte
char *s = NULL;
char c;
@ -38,15 +37,63 @@ char *strdup_(char *s) {
int main(int argc, char **argv) {
CARD *cards;
size_t cards_ct;
WINDOW *main_card;
int cards_ct, cc = 0, cf = 0, term_y, term_x;
char k = '\0';
if (argc < 1)
if (argc < 2)
die("filename required");
cards = card_parse_csv(argv[1], &cards_ct);
for (size_t i = 0; i < cards_ct; i++)
printf("o: `%s`, r: `%s`\n", cards[i].obverse, cards[i].reverse);
initscr();
noecho();
curs_set(0);
getmaxyx(stdscr, term_y, term_x);
main_card = newwin(term_y * .75,
term_x * .75,
(term_y * .5) - ((term_y * .75) * .5),
(term_x * .5) - ((term_x * .75) * .5));
refresh();
do {
switch (k) {
case 'j':
if (++cc > cards_ct - 1)
cc = 0;
cf = 0;
break;
case 'k':
if (--cc < 0)
cc = cards_ct - 1;
cf = 0;
break;
case ' ':
switch (cf) {
case 0: cf = 1; break;
case 1: cf = 0; break;
}
break;
case 'q':
endwin();
exit(0);
break;
}
wclear(main_card);
wrefresh(main_card);
box(main_card, 0, 0);
if (cf == 0) {
mvwprintw(main_card, 0, 10, " Card #%d/%d [front] \r", cc + 1, cards_ct);
mvwprintw(main_card, (term_y * .75) * .5, (term_x * .75) * .5, "%s\r", cards[cc].obverse);
} else {
mvwprintw(main_card, 0, 10, " Card #%d/%d [back] \r", cc + 1, cards_ct);
mvwprintw(main_card, (term_y * .75) * .5, (term_x * .75) * .5, "%s\r", cards[cc].reverse);
}
wrefresh(main_card);
} while ((k = getch()) != EOF);
/* for (size_t i = 0; i < cards_ct; i++) */
/* printf("o: `%s`, r: `%s`\n", cards[i].obverse, cards[i].reverse); */
return 0;
}