2 Commits
v1.1 ... v1.1.1

Author SHA1 Message Date
rexy712
e3586a9e93 Reverted 2a733a0. Fixes binary printing 2019-07-22 14:13:16 -07:00
rexy712
72891834c2 Updated Readme and added public repo to help output 2019-07-22 13:50:46 -07:00
2 changed files with 57 additions and 40 deletions

View File

@@ -1,31 +1,42 @@
# README
## About
roflcat is a C++ rewrite of [lolcat][1] which runs much faster and supports all the options of GNU cat. I am not going to support the animation options of lolcat (--animate, --duration, --speed) because there is no real purpose to them.
roflcat is a C++ rewrite of [lolcat][1] which runs much faster and supports all the options of GNU cat. I am not going to support the animation options of lolcat (--animate, --duration, --speed) because there is no real purpose to them.
Currently I can only confirm it runs on a linux system and I have no desire to expand to supporting anything else at this time.
To keep compatability with both GNU cat and lolcat, I wanted all command line options from both to either be implemented or ignored. However there are a few conflicts between the two, namely -s -t and -v. For these I will be implementing the GNU cat functionality.
Current version is 0.1a as of writing this, so if the version is much newer, remind me to update this readme :)
![alt text](https://i.postimg.cc/1tYmJzxd/roflcat-usage.png "Screenshot of --help output")
Current version is 1.1 as of writing this, so if the version is much newer, remind me to update this readme :)
![alt text](https://i.postimg.cc/0Qk6k34j/roflcat-usage.png "Screenshot of --help output")
## Dependencies
ncurses
cmake
## Building
There is no release right now. There is only the debug build which will produce an executable called 'tester'.
To build just run `make`.
```
mkdir build
cd build
cmake ..
make
```
## Installing
I would not recommend installing at this time. There is no install target in the makefile.
From within the build directory:
```
make install
```
## More Screenshots
Some test outputs on a file filled with laughing cat emojis
256 color:
256 color:
![alt text](https://i.postimg.cc/1tZC2k6r/roflcat-roflcats.png "roflcats in 256 color")
Truecolor (24 bit):
Truecolor (24 bit):
![alt text](https://i.postimg.cc/tJF2527m/roflcat-roflcats-truecolor.png "roflcats in truecolor")
16 color (type that will work in a tty):
16 color (type that will work in a tty):
![alt text](https://i.postimg.cc/LX99RbFj/roflcat-roflcats-16color.png "roflcats in 16 color")
[1]: https://github.com/busyloop/lolcat

View File

@@ -94,6 +94,7 @@ constexpr void print_usage(Printer&& p){
p.print(L'\n');
}
p.print(L"\nroflcat Copyright (C) 2019 rexy712\n");
p.print(L"Source code can be found at https://gitlab.com/rexy712/roflcat\n");
p.print(L"This program comes with ABSOLUTELY NO WARRANTY\n");
p.print(L"This is free software, and you are welcome to redistribute it\n");
p.print(L"under certain conditions; see the GNU GPLv3 for details.\n");
@@ -172,47 +173,52 @@ template<class Printer>
int real_print_files(const cmd_args& args){
int ret = 0;
Printer p(args);
if(args.treatbinary){ //binary files
for(size_t i = 0;i < args.filenames.size();++i){
if(!strcmp(args.filenames[i], "-")){ //stdin
do_stdin<char>(p, fgetc);
}else{ //everything besides stdin
FILE* fp = open_file(args.filenames[i], "rb");
if(!fp){
ret = 2;
continue;
}
for(size_t i = 0;i < args.filenames.size();++i){
if(!strcmp(args.filenames[i], "-")){ //stdin
if(args.treatbinary){
//Don't check if buf is empty because that's not how GNU cat handles Ctrl+D in middle of line
for(int in;(in = fgetc(stdin)) != WEOF;){
p.print(static_cast<char>(in));
if(in == L'\n') //Only reset on newline to save print overhead
p.reset();
}
}else{
for(wint_t in;(in = fgetwc(stdin)) != WEOF;){
p.print(static_cast<wchar_t>(in));
if(in == L'\n')
p.reset();
}
}
clearerr(stdin);
}else{ //everything besides stdin
FILE* fp = open_file(args.filenames[i], "r");
if(!fp){
ret = 2;
continue;
}
if(args.treatbinary){
if(args.nonprinting){
for(char in;(in = fgetc(fp)) != EOF;){
for(int in;(in = fgetc(fp)) != WEOF;){
char tmp[5];
nonprinting_notation(in, tmp);
p.print(tmp);
}
}else{
for(char in;(in = fgetc(fp)) != EOF;)
p.print(in);
for(int in;(in = fgetc(fp)) != WEOF;)
p.print(static_cast<char>(in));
}
p.reset();
fclose(fp);
}
}
}else{ //non binary files
for(size_t i = 0;i < args.filenames.size();++i){
if(!strcmp(args.filenames[i], "-")){
do_stdin<wchar_t>(p, fgetwc);
}else{
FILE* fp = open_file(args.filenames[i], "r");
if(!fp){
ret = 2;
continue;
}
for(wchar_t in;(in = fgetwc(fp)) != WEOF;){
p.print(in);
}
p.reset();
fclose(fp);
//set to wide character mode before anything
fwide(fp, 1);
for(wint_t in;(in = fgetwc(fp)) != WEOF;)
p.print(static_cast<wchar_t>(in));
}
p.reset();
fclose(fp);
}
}
p.reset();