# $LastChangedDate: 2015-02-12 12:12:43 +0100 (Thu, 12 Feb 2015) $
# Contents of the default 'fimrc' file, hardcoded in the fim executable.
# Read the documentation (man fimrc) to discover how to change this default hardcoded file and how to make your own.
# Note that usually a ~/.fimrc file is read after these options take effect, so you could reset all of this with ease.
# Lines beginning with a pound (#) are ignored by fim (they are treated as comments).
#
# Internal variables.
# Some of these variables influence Fim's behaviour (input variables), some are set by Fim (output variables).
# It is wise the input variables are set at the beginning of the file, so the bottom may issue commands correctly affected by them.
if(_debug_commands==''){_debug_commands=0;}
if(_command_expansion==''){_command_expansion=1;}
if(_display_status==''){_display_status=0;}
if(_max_cached_images==''){_max_cached_images=5;}
if(_max_cached_memory==''){_max_cached_memory=81920;}
if(_max_iterated_commands==''){_max_iterated_commands=100;}
if(_want_prefetch==''){_want_prefetch=1;}
if(_no_external_loader_programs==''){_no_external_loader_programs=0;}
if(_scale_style==''){_scale_style='b';}
if(_save_fim_history==''){_save_fim_history=1;}
if(_load_fim_history==''){_load_fim_history=1;}
if(_verbose_keys==''){_verbose_keys=0;}
if(_display_busy==''){_display_busy=1;}
if(_ignorecase==''){_ignorecase=1;}
if(_re_search_opts==''){_re_search_opts='bi';}
if(_console_offset==''){_console_offset=0;}
if(_console_key==''){_console_key=58;}
if(_display_as_binary==''){_display_as_binary=0;}
if(_push_checks==''){_push_checks=1;}
#if(_want_caption_status==''){_want_caption_status=0;}
if(_want_exif_orientation==''){_want_exif_orientation=1;}
if(ascale==''){ascale="1.0";}
if(_use_mipmaps==''){_use_mipmaps=1;}
#
# External variables (not used internally).
if(allow_round_scroll==''){allow_round_scroll=0;}
if(console_scroll_n==''){console_scroll_n=3;}
#
alias "toggleautoflip" "_autoflip=1-_autoflip;" "";
alias "toggleautonegate" "_autonegate=1-_autonegate;" "";
alias "toggleflip" "i:flipped=1-i:flipped;" "";
alias "flip" "toggleflip;redisplay;" "flip the current image along the horizontal axis";
alias "fliponce" "flip;toggleflip;" "";
alias "toggleautomirror" "_automirror=1-_automirror;" "";
alias "togglemirror" "i:mirrored=1-i:mirrored;" "";
alias "mirror" "togglemirror;redisplay;" "mirror the image along the vertical axis" "";
alias "mirroronce" "mirror;togglemirror;" "";
# Warning : binding to C-s, C-z and C-c won't make effect, as these
# codes are catched by the console driver and will have no effect in fim.
# Moreover, C-z will crash fim and C-c will terminate it.
# Some other combinations (e.g.:C-l) may have similar problems in your console.
bind 'f' "flip;";
bind 'F' "fliponce;";
bind 'm' "mirror;";
bind 'M' "mirroronce;";
bind 'q' "quit";
bind 'Esc' "quit";
#bind 'n' "next_file;";
#bind 'n' "next;";
bind 'C-h' "help";
#bind '?' "help"; # assigned to back-search
#bind '/' "help"; # assigned to forward-search
bind '=' "scale '100%'";
#bind 'p' "prev_file;";
bind 'Del' "list 'pop';reload;";
#bind 's' "list 'sort'";
bind 's' "scrollforward";
bind 'C-s' "swap;redisplay;";
bind 'S' "toggleDisplayStatus";
bind 'I' "toggleautonegate";
bind 'i' "negate;redisplay;";
bind 'g' "desaturate;redisplay;";
bind 'G' "toggleDesaturate;";
#bind 'R' "reload";
#bind 'R' "redisplay";
bind 'r' "rotate90;";
bind 'R' "rotate270;";
#bind 'R' "rotate10;display;";
#bind 'r' "rotate10_ccw;display;";
#bind 'r' "reload;";
#bind 'C-d' "display";
bind '+' "magnify";
#bind 'C-+' "angle=angle+10.0;display;";
bind 'a' "scale 'a';";
bind 'H' "scale 'H';";
bind 'Tab' "toggleVerbosity";
bind 'Menu' "toggleVerbosity";
#bind 'C-k' "_want_caption_status=1-_want_caption_status;status ' '";
bind 'v' "toggleDisplayStatus";
bind 'A' "A";
bind 'C-m' "list 'mark'";
bind 'u' "list 'unmark'";
bind 'Enter' "list 'mark';next";
bind '-' "reduce";
bind "Up" "pan_up";
bind 'k' "pan_up";
#bind 'C-k' "pan_up";
bind "Right" "pan_right";
bind 'l' "pan_right";
bind "Down" "pan_down";
bind 'j' "pan_down";
bind "Left" "pan_left";
bind 'h' "pan_left";
bind ' ' "scrolldown";
bind 't' "align 'top';";
bind 'C-g' "system 'fbgrab fim.png'";
bind 'C-r' "recording 'start';";
bind 'Q' "recording 'stop'";
bind 'D' "recording 'dump';";
bind 'E' "recording 'execute';";
bind 'C-e' "recording 'execute';";
bind 'C-x' "recording 'execute';";
bind '.' "recording 'repeat_last';";
alias "toggleVerbosity" "_display_console=1-_display_console;i:fresh=1;redisplay;" "";
alias "toggleKeyVerbosity" "_verbose_keys=1-_verbose_keys;redisplay;" "";
alias "toggleDesaturate" "_autodesaturate=1-_autodesaturate;redisplay;" "";
#
# autocommands are essential to Fim's automated behaviour
# examples:
#autocmd "PostInteractiveCommand" "fim.png" "echo '\\nmatched an interactive command on fim.png\\n';";
#autocmd "PostDisplay" ".*png" "echo 'this is a png file';";
#autocmd "PostDisplay" ".*jpg" "echo 'this is a jpg file';";
#autocmd "PostDisplay" ".*gif" "echo 'this is a gif file';";
#autocmd "PostDisplay" "" "echo '\\nthis is a file\\n'";
#autocmd "PostGoto"   "" "set_interactive_mode;";
autocmd "PostGoto" "" "reload;";
#autocmd "PostGoto" "" "load;";
#autocmd "PostDisplay"   "" "i:fresh=1" ;
#autocmd "PreWindow"   "" "";
autocmd "PostWindow"   "" "display;";
autocmd "PreRedisplay"   "" "i:_will_display=1;";
autocmd "PreRedisplay"   "" "if(_scale_style!='' && i:fresh){i:fresh=0;scale _scale_style ;i:fresh=0;}";
autocmd "PostRedisplay" ""   "i:_will_display=0;";
# Display device specific config
alias "aalib_fix_do" "{if(aascale==''){ascale='2.0';}else{ascale=aascale;} i:fresh=1;display;if(_TERM=~'screen'){echo 'screen+aalib?expect binding problems!'}}" "See aalib_fix.";
alias "aalib_fix" "if(_device_string=='aa'){aalib_fix_do;scale 'a';}" "When using the aalib (ASCII art) library we face a problem: glyph proportions are seldom square (as pixels are), and are tricky to detect; for this reason, we need to reshape the image with respect to the font ratio, but we have to make a guess in the scaling factor to compensate. If at runtime a better value is known for the terminal font height/with ratio, it may be fed in the 'aascale' variable for an accurate scaling.";
#alias "exif_fix" "i:_orientation=exif_orientation;exif_orientation='';i:mirrored=exif_mirrored;exif_mirrored='';i:flipped=exif_flipped;exif_flipped='';" "";
#autocmd "PostReload"   "" "aalib_fix;exif_fix;";
#autocmd "PostLoad"   "" "aalib_fix;exif_fix;";
autocmd "PostReload"   "" "aalib_fix;";
autocmd "PostLoad"   "" "aalib_fix;";
bind "F11" "if(_device_string=='sdl' && !_fullscreen){_old_sw=_screen_width;_old_sh=_screen_height;display 'reinit' 'MW0:0';_fullscreen=1;}else if(_device_string=='sdl' && _old_sw*_old_sh*_fullscreen){display 'reinit' 'rwm'._old_sw.':'._old_sh;_fullscreen=0;}";

autocmd "PostReload"  "" "i:fresh=1" ;
autocmd "PostScale"   "" "if(0==i:_will_display){i:fresh=1;display;}" ;
#autocmd "PostScale"   "" "{i:fresh=1;display;}" ;
autocmd "PostPan"     "" "{i:fresh=1;display;}" ;
autocmd "PostReload"   "" "if(i:fresh){redisplay;}";
autocmd "PostInteractiveCommand"   "" "if(i:fresh){display;i:fresh=0;}";
autocmd "PostInteractiveCommand"   "" "if(_want_prefetch){prefetch;}";
autocmd "PostInteractiveCommand"   "" "if(_display_console==0 && i:fresh){redisplay;i:fresh=0;}";

alias "next10" "i=0;while(i<10){i=i+1;next;display;sleep '1';};" "goes forward 10 images";
bind 'N' 'next10';
bind 'P' 'prev10';
bind 'C-n' "goto '+//'";
bind 'C-p' "goto '-//'";
bind 'C-b' "goto '-//'"; # Warning: C-b cannot be detected on many configurations.
bind 'W' "display 'resize';" "if supported, resizes the window to match the current image pixels size";
bind 'C-w' "scale '100%';display 'resize';" "if supported, scales the image to 100% and resizes the window to match its size (if fits)";
alias "endless_slideshow" "while(1){display;sleep '1';next;};" "performs an automated slideshow, endlessly";
alias "bookview"          "while(1){display;sleep '2';scrolldown;};" "";
alias "comicview"         "while(1){display;sleep '1';scrolldown;};" "";
alias "read"              "while(1){display;sleep '1';scrollforward;};" "";
alias "slowread"          "while(1){display;sleep '2';scrollforward;};" "";
alias "fastread"          "while(1){display;scrollforward;};" "";
alias "pornview"          "echo 'press any key repeatedly to terminate' ;endless_slideshow;" "";
#bind  "C-p" "pornview";
#bind  "C-b" "bookview";
autocmd "PreExecutionCycle" "/fbps-" "_display_busy=0;_display_status=0;" ;
autocmd "PreExecutionCycle" "" "i:fresh=1;reload;";
#autocmd "PreExecutionCycle" "" "redisplay;";
autocmd "PreExecutionCycle" "/fbps-.*ps001.png" "i:fresh=1;redisplay;";
#autocmd "PostInteractiveCommand" "" "i:fresh=0;";
#autocmd "PostInteractiveCommand" "" "prefetch;";
bind '*' "scale '100%'";
bind 'w' "scale 'w'";
bind '<' "rotate10_ccw;display;";
bind '>' "rotate10;display;";
bind '_' "_scale_style='';scale '100%';";
bind ',' "_display_console=1;echo _last_system_output;";
bind 'C-a' "if(_scale_style!='a'){_scale_style='a';scale 'a';}else{_scale_style='';scale '100%';}";
#bind 'h' "scale 'h'";
#
alias "pan_nw" "pan 'nw';" "pans the image to the upper left";
alias "pan_ne" "pan 'ne';" "pans the image to the upper right";
alias "pan_se" "pan 'se';" "pans the image to the lower left";
alias "pan_sw" "pan 'sw';" "pans the image to the lower right";
alias "pan_down" "pan 'down';" "pans the image down";
alias "pan_up" "pan 'up';" "pans the image up";
alias "pan_left" "pan 'left';" "pans the image left";
alias "pan_right" "pan 'right';" "pans the image right";
#
alias "diagonal_nw" "pan_nw;" "pans the image to the upper left";
alias "diagonal_ne" "pan_ne;" "pans the image to the upper right";
alias "diagonal_se" "pan_se;" "pans the image to the lower left";
alias "diagonal_sw" "pan_sw;" "pans the image to the lower right";
bind 'd' "diagonal_nw;";
bind 'D' "diagonal_se;";
bind 'x' "diagonal_ne;";
bind 'X' "diagonal_sw;";
alias "toggleDisplayStatus" "_display_status=1-_display_status;" "";
alias "toggleDisplayBusy" "_display_busy=1-_display_busy;" "";
alias "sort" "list 'sort'" "sorts the files list ordered";
#toggleVerbosity;
#bind 'f' "next;display;";
#bind 'b' "prev;display;";
bind 'o' "sort";
bind 'b' "prev;";
bind 'B' "toggleDisplayBusy";
alias "random_slideshow" "while(1){goto random;}" "performs a shuffled slideshow";
alias "rotate90_ccw" "i:_orientation=i:_orientation+3;i:fresh=1;i:fresh=1;redisplay;" "";
alias "rotate90_cw"  "i:_orientation=i:_orientation+1;i:fresh=1;i:fresh=1;redisplay;" "";
alias "rotate90" "rotate90_cw;display;" "";
alias "rotate270" "rotate90_ccw;display;" "";
alias "rotate10"     "rotate  '10';display;" "";
alias "rotate10_ccw" "rotate -10;display;" "";

# window related aliases and commands
alias "wu" "window 'up'" "selects the window upwards the current";
alias "wd" "window 'down'" "selects the window under the current";
alias "wl" "window 'left'" "selects the window at left of the current";
alias "wr" "window 'right'" "selects the window at right of the current";
#bind 'K' "wu";
bind 'K' 'if(_display_console==0){echo i:_filename.": ".i:_comment;toggleVerbosity}else{toggleVerbosity;}';
# Note : on many consoles C-j is by default equivalent to Enter.. so this may not work :)
#bind 'C-j' "wd";
#bind 'J' "wd";
#bind 'H' "wl";
#bind 'L' "wr";
#alias "split" "window 'split'" "split the current window horizontally";
#alias "vsplit" "window 'vsplit'" "split the current window vertically";
#alias "swap" "window 'swap'" "swap the enclosing window subwindows";
#alias "ws " "window 'swap'" "see swap";
#bind 'T' "split;redisplay;";
##don't use C-s : it will be usually catched by the console driver, and fim won't get it!
##bind 'C-s' "split;";
#bind 'V' "vsplit;redisplay;";
#bind 'U' "swap;redisplay;";
#alias 'venlarge' 'window "venlarge"' "";
#alias 'henlarge' 'window "henlarge"' "";
#alias 'wnormalize' 'window "normalize"' "";
#alias 'wclose' 'window "close"' "";
#alias 'wc' 'window "close"' "closes the current window";
#bind  'C' "wc;redisplay;";

alias 'cache' 'echo _cache_status;' "displays cached images status";
#bind 'c' 'cache;';
bind 'c' 'align "center";';
alias 'widen'  'i:ascale=i:ascale*"1.1";*1.0;' "widen the current image";
alias 'narrow' 'i:ascale=i:ascale/"1.1";*1.0;' "narrow the current image";
alias 'contract' 'narrow';
bind  'y' "widen" "widens horizontally the image";
bind  'Y' "narrow" "shrinks horizontally the image";
#alias 'scu'   'scroll_console_up;'   "";
#alias 'scd'   'scroll_console_down;' "";
#alias 'console_scroll_up'   'if(_console_offset<_console_lines){_console_offset=_console_offset+1;}';
#alias 'console_scroll_down' 'if(_console_offset>0){_console_offset=_console_offset-1;}';
alias 'console_scroll_up' 'if(_console_offset<_console_lines+console_scroll_n-_rows){_console_offset=_console_offset+console_scroll_n;}';
alias 'console_scroll_down' 'if(allow_round_scroll || (_console_offset>=console_scroll_n)){_console_offset=_console_offset-console_scroll_n;}';
alias 'console_scroll_reset' '{_console_offset=0;}';
alias 'scu'   'console_scroll_up;'   "";
alias 'scd'   'console_scroll_down;' "";
alias 'scz'   'console_scroll_reset;' "";
alias 'center'   'align "center"';
alias 'left'   'align "left"';
alias 'right'  'align "right"';
alias 'top'   'align "top"';
alias 'bottom'   'align "bottom"';
bind "PageUp" "if(_display_console==0){prev;}else{scu;}";
bind "PageDown" "if(_display_console==0){next;}else{scd;}";
bind "Home" "0;";
bind "End" "$;";
bind "^" "0;";
bind "$" "$;";
bind "Backspace" "prev;";
bind "'" "goto _lastfileindex"; 
_display_status=1;
_want_caption_status="fim:%N@%p%%%L[%i/%l]";
_info_fmt_str="%p%% %wx%h%L %i/%l%P %F %T %c";
_display_status_fmt="%N%?EXIF_DateTimeOriginal?[%:EXIF_DateTimeOriginal:]?%?EXIF_ExposureTime?[%:EXIF_ExposureTime:]?%?EXIF_FNumber?[%:EXIF_FNumber:]?%?EXIF_ApertureValue?[%:EXIF_ApertureValue:]?%?EXIF_ISOSpeedRatings?[ISO%:EXIF_ISOSpeedRatings:]?:%k";
#_display_status_fmt="%N:%k"; #
#_use_exiftool=0;
echo "WELCOME : to switch to the command line interface press ':' ";
# Some more examples:
#alias "plisten" 'popen "nc -l -p 9999 "' "executes fim commands coming from port 9999 on this computer";
#alias "wlisten" "while(1){sleep;plisten;}" "listen to a pipe, endlessly";
#alias "musicplay"  "system 'mpc play'" "";
#alias "musicpause" "system 'mpc pause'" "";
#alias "rdjpgcom" 'system "rdjpgcom" i:_filename';
# offsetscan usage : need a mechanism for popping all images before.
#alias "offsetscan" "while(i:width<1){list 'push' offimage;_open_offset=_open_offset+1;reload;}";
#alias "offsetscan" "while(i:width<1){list 'push' '/home/dez/mostro.jpg';stdout _open_offset ;_open_offset=_open_offset+1;reload;}";
#alias "webcam" "pread 'vgrabbj -d /dev/video0';";
#alias "webcam_cycle" "while(1){webcam;reload;sleep 1;};";
#This is a FIM initialization file. 
#Without one of these FIM is nothing.
#So feel free to modify it, but with caution! 
