id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,blockedby,blocking,branch_state,votes 2977,Show images with img2txt helper (libcaca utility),szaszg,,"IMHO will be nice if mc can show images in quick view mode. It will be done if we convert images to ANSI color text files (with libcaca img2txt utility), and mcview can show ANSI colored text files. (and we fix mcview magic mode bug, see Ticket#2976) We can use sfs (1) and image.sh (2) to convert images to ANSI colored text. We can use nroff highliting mode (3) to show images. We should fix mcview magic mode bug (4). We should add a new hotkey to switch ""Format""/""Unformat"", because in quick view mode F9 do menu !PullDn (5) So i attach a patch: util.{h,c}: -a new compression type COMPRESS_IMG to handle sfs type image conversion (related to 1) -detect GIF, PNG, JPEG magic in get_compression_type() function (rel. 1) -new decompress extension '''/img''' in decompress_extension() function (rel. 1) sfs.ini: -new img ""decomress helper"" img2txt (rel .1) image.sh: -detect img2txt utility and use it for JPEG and other (*) images (rel .2) -print exif data (if any) after image to keep imege at top internal.h: -text wrap can broke images, so we defined a test (WRAP_MODE_DISABLED() and TEXT_WRAP_MODE()) to avoid text wrap when show ANSI colored text (rel. 3) -new enum (nroff_high_type) to select different highliting modes (e.g. ANSI :) -new member in view struct (nroff_high_type) to cache the result of highlite rule detection lib.c: -initialize nroff_high_type for views in mcview_toggle_magic_mode() function (rel. 3) display.c: -use mcview_display_ansi() if mcview in nroff_mode and file is ANSI colored (view->nroff_high_type) (rel. 3) mcviewer.c: -initialize nroff_high_type for new views in mcview_new() function (rel. 3) -fix mcview magic_mode bug in mcview_load() function (as in Ticket#2976) (rel. 4) move.c: -""if (view->text_wrap_mode)"" and similars changed to ""if (TEXT_WRAP_MODE(view))"" to avoid text wrap when show images (see note 1) (rel. 3) nroff.c: -check nroff_high_type (if not checked yet) and do ANSI colored display if needed (this is the optimal place to check) check result saved and later (if user play F9) display.c call directly the ANSI function... Makefile.am: -add ansi.c (rel. 3) ansi.c: -new function get_nroff_high_type() detect ANSI color escape sequences in the first 256 byte if file size less than 1M (avoid playing big files) (rel. 3) -new function mcview_display_ansi() to display ANSI colored text files (see note 2) (rel. 3) After make install i add ctrl-t to !NroffMode in mc.keymap, so now i can switch ""Format""/""Unformat"" mode on quick view panel. (rel. 5) ================================== So... 1. start up mc 2. switch quick view ctrl-x ctrl-q 3. browse an image (jpeg, gif, png) 4. switch to quick view (TAB) 5. press ctrl-t (should be set as i mentioned before) 6. 8-o 7. switch back to file list (TAB) 8. just browse your photos ;-) If you open an image in viewer F3, you can see the identify line the image and exif tags (jpeg only) Notes: 1. all other ""if (view->text_wrap_mode)"" and similars changed to ""if (TEXT_WRAP_MODE(view))"" in files 2. mcviewer_display_ansi() is similar to mciewer_display_text() but: -detects ANSI color sequences ''!^[#;#;#m'' when # is 0,1,5 or 30-37, or 40-47 -it uses a 128 byte length puffer, so color sequences larger than 128 byte not detected (there is no any reason to somebody use as long sequences) -if escape seq. not an ANSI color (e.g. cursor movement, etc...), or too large then displayed as in mciewer_display_text(). -it can use as many color pairs as the underlaying terminal(emulator) allow (usually 256), but mc allocate some color pair before. So in same cases (e.g. mc use ""underlined"" colors, and text file has 256 different color pair) this number may not enough and mcview show some ""default"" colored caracter instead of the ""real"" color. -it use a special escape sequence (!^[9999m), to detect the end-of-image and switch back to normal colors. (image.sh use this thing to show up exif data in normal colors)",enhancement,new,major,Future Releases,mcview,master,,,gotar@… egmont@… mooffie@…,,,no branch,