imcat icon indicating copy to clipboard operation
imcat copied to clipboard

How to Run and Compile on Cygwin

Open E3V3A opened this issue 5 years ago • 2 comments

I've managed to compile this on Cygwin (under Win 8.1) using the following patch:

diff --git a/Makefile b/Makefile
index db49cec..f9a1bb7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
 imcat: imcat.c
-       cc -std=c99 -Wall -g -o imcat imcat.c -lm
+       x86_64-w64-mingw32-gcc -std=c99 -Wall -g -o imcat imcat.c -lm
+       #gcc -std=c99 -Wall -g -o imcat imcat.c -lm

 run: imcat
        ./imcat ~/Desktop/*.png
diff --git a/imcat.c b/imcat.c
index 635fbc0..7b681b1 100644
--- a/imcat.c
+++ b/imcat.c
@@ -21,6 +21,12 @@ static unsigned char termbg[3] = { 0,0,0 };

 #if defined(_WIN64)
 #      include <windows.h>
+
+#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+#define ENABLE_VIRTUAL_TERMINAL_PROCESSING  0x0004
+#endif
+
+
 static void get_terminal_size(void)
 {
        const HANDLE hStdout = GetStdHandle( STD_OUTPUT_HANDLE );

Yeah, you need MinGW for Cygwin.

The output works for a small and original PNG:

The Original:

tiger2_100_96

The Result (in Cygwin Bash):

mintty_2018-12-13_20-35-52

In ConEmu (PowerShell 5.1.1)

conemu64_2018-12-13_20-47-50


  • trying to output the png you included in ./image/*.png silently fails.
    (Please add real png for testing!)
  • Running this in PowerShell fails on most systems not using ConPty or newest ConHost.
    (I.e. on OS < Win10)
  • If your terminal window is smaller (in character count) than the image pixel count (in any direction) the image gets broken up.
  • Also works on ConEmu, but look very ugly!

E3V3A avatar Dec 13 '18 18:12 E3V3A