Skip to content
This repository has been archived by the owner on Jul 21, 2018. It is now read-only.

Commit

Permalink
fixed reading from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-simon committed Aug 6, 2017
1 parent b2d7b3c commit 17e4d9f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Ansifilter ChangeLog

06.08.2017

ansifilter 2.8

-fixed reading from stdin (https://github.com/andre-simon/ansifilter/issues/8)

---

03.08.2017

ansifilter 2.7
Expand Down
9 changes: 5 additions & 4 deletions README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-------------------------------------------------------------------------------
--- ANSIFILTER MANUAL - Version 2.6 --------------------------- JULY 2017 ---
--- ANSIFILTER MANUAL - Version 2.8 ------------------------- AUGUST 2017 ---
-------------------------------------------------------------------------------

OSI Certified Open Source Software
Expand Down Expand Up @@ -60,9 +60,9 @@ Format options:
--wrap-no-numbers Omit line numbers of wrapped lines (assumes -l)

ANSI art options:
--art-cp437 Parse codepage 437 ANSI art (HTML, RTF output only)
--art-bin Parse BIN/XBIN ANSI art (HTML, RTF output only)
--art-tundra Parse Tundra ANSI art (HTML, RTF output only)
--art-cp437 Parse codepage 437 ANSI art (HTML, RTF output)
--art-bin Parse BIN/XBIN ANSI art (HTML output, no stdin)
--art-tundra Parse Tundra ANSI art (HTML output, no stdin)
--art-width Set ANSI art width (default 80)
--art-height Set ANSI art height (default 150)

Expand All @@ -76,6 +76,7 @@ ansifilter *.txt
tail -f server.log | ansifilter

Parsing XBIN files overrides --art-width, --art-height and --map options.
The ANSI art file formats BIN, XBIN and TND cannot be read from stdin.

The GUI version (ansifilter-gui) also accepts the first command line argument
as input file name.
Expand Down
Binary file modified man/ansifilter.1.gz
Binary file not shown.
9 changes: 6 additions & 3 deletions src/codegenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,9 +964,11 @@ void CodeGenerator::allocateTermBuffer(){
}

bool CodeGenerator::streamIsXBIN() {
if (in==&cin) return false;

bool isXBIN = false;
char head[5] = {0};
if (in!=&cin && in->read (head, sizeof head -1) ) {
if (in->read (head, sizeof head -1) ) {
isXBIN = string(head)=="XBIN";
}
in->clear();
Expand All @@ -976,13 +978,14 @@ bool CodeGenerator::streamIsXBIN() {


bool CodeGenerator::streamIsTundra() {
if (in==&cin) return false;

bool isTND = false;
char head[10] = {0};

if (in!=&cin && in->read (head, sizeof head -1) ) {
if (in->read (head, sizeof head -1) ) {
isTND = string(head)=="\x18TUNDRA24";
}

in->clear();
in->seekg (0, ios::beg);
return isTND;
Expand Down
7 changes: 4 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ void ANSIFilterApp::printHelp()
cout << " --wrap-no-numbers Omit line numbers of wrapped lines (assumes -l)\n";

cout << "\nANSI art options:\n";
cout << " --art-cp437 Parse codepage 437 ANSI art (HTML, RTF output only)\n";
cout << " --art-bin Parse BIN/XBIN ANSI art (HTML, RTF output only)\n";
cout << " --art-tundra Parse Tundra ANSI art (HTML, RTF output only)\n";
cout << " --art-cp437 Parse codepage 437 ANSI art (HTML and RTF output)\n";
cout << " --art-bin Parse BIN/XBIN ANSI art (HTML output, no stdin)\n";
cout << " --art-tundra Parse Tundra ANSI art (HTML output, no stdin)\n";
cout << " --art-width Set ANSI art width (default 80)\n";
cout << " --art-height Set ANSI art height (default 150)\n";

Expand All @@ -95,6 +95,7 @@ void ANSIFilterApp::printHelp()
cout << "ansifilter *.txt\n";
cout << "tail -f server.log | ansifilter\n\n";
cout << "Parsing XBIN files overrides --art-width, --art-height and --map options.\n";
cout << "The ANSI art file formats BIN, XBIN and TND cannot be read from stdin.\n";
cout << "\nPlease report bugs to " ANSIFILTER_EMAIL "\n";
cout << "For updates see " ANSIFILTER_URL "\n";
}
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ along with ANSIFilter. If not, see <http://www.gnu.org/licenses/>.
#ifndef VERSION_H
#define VERSION_H

#define ANSIFILTER_VERSION "2.7"
#define ANSIFILTER_VERSION "2.8"

#define ANSIFILTER_URL "http://www.andre-simon.de/"
#define ANSIFILTER_EMAIL "andre.simon1@gmx.de"
Expand Down

0 comments on commit 17e4d9f

Please sign in to comment.