# $LastChangedDate: 2023-03-09 00:38:06 +0100 (Thu, 09 Mar 2023) $
# 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(_cache_control==''){_cache_control='m';}
if(_debug_commands==''){_debug_commands='';}
if(_command_expansion==''){_command_expansion=1;}
if(_display_status==''){_display_status=0;}
if(_max_cached_images==''){_max_cached_images=5;}
if(_min_cached_images==''){_min_cached_images=4;}
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_wm_caption_status==''){_want_wm_caption_status=0;}
if(_want_exif_orientation==''){_want_exif_orientation=1;}
if(ascale==''){ascale="1.0";}
if(_use_mipmaps==''){_use_mipmaps=1;}
if(_downscale_huge_at_load==''){_downscale_huge_at_load=1;}
if(_scroll_skip_page_fraction==''){_scroll_skip_page_fraction=0;}
if(_want_wm_mouse_ctrl==''){_want_wm_mouse_ctrl="'pP+a-=nN";}
#
# 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" "toggles flipped property on the current image";
alias "flip" "toggleflip;redisplay"        "flip the current image along the horizontal axis";
alias "fliponce" "flip;toggleflip"         "flip, but just for one display";
alias "toggleautomirror" "_automirror=1-_automirror" "";
alias "togglemirror" "i:mirrored=1-i:mirrored" "toggles mirrored property on the current image";
alias "mirror" "togglemirror;redisplay"         "mirror the image along the vertical axis" "";
alias "mirroronce" "mirror;togglemirror"        "mirror, but just for one display";
alias 'toggleLimitMarked' '__pre_limit_fileindex=_fileindex;_limit_mode=1-_limit_mode; if(_limit_mode==1){limit "!";} else { limit; } if(_filelistlen<1){_limit_mode=0;limit;goto __pre_limit_fileindex;} i:fresh=1;redisplay; ' "toggle between limiting file list to the marked files and the full list";
alias "unlimit" "limit" "calling limit with no arguments restores the original list";
# Warning : binding to C-s, C-z and C-c won't make effect, as these
# codes are get caught 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 'remove';reload";
#bind 's' "list 'sort'";
bind ' ' "scroll 'forward'";
###bind 'C-s' "swap;redisplay";
bind 'S' "toggleDisplayStatus";
bind 'I' "toggleautonegate";
bind 'i' "color 'negate';redisplay";
bind 'g' "color 'desaturate';redisplay";
###bind '[' "color 'colorblind'            ; redisplay";
###bind ']' "color 'colorblind' 'daltonize'; redisplay";
bind '[' 'font_reduce;redisplay';
bind ']' 'font_magnify;redisplay';
bind '|' 'toggle_font_auto_scale;redisplay';
bind '{' 'font "prev";redisplay';                                                                                                         
bind '}' 'font "next";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_wm_caption_status=1-_want_wm_caption_status;status ' '";
bind 'v' "toggleDisplayStatus";
bind 'A' "A";
bind 'C-m' "list 'mark'";
bind 'u'   "list 'unmark'";
####bind 'Enter' "list 'mark';next";
bind 'Enter' "list 'mark';goto _lastgotodirection";
bind '-' "reduce";
bind "Up" "pan_up";
bind 'k' "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 'j' "pan 'down+'";
bind "Left" "pan_left";
bind 'h' "pan_left";
####bind ' ' "scroll 'down'";
bind 't' "align 'top'";
bind 'C-g' "system 'fbgrab' 'fim_'._device_string.'.png'"; # grab a screenshot
#bind 'C-r' "recording 'start'";
bind 'C-r' "reload ''";
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'";
bind '`' "toggleLimitMarked";
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" "";
alias "idempotent_cmd" "goto ''";
#
# Autocommands 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" ""   "i:fresh=1;redisplay;";
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 "cacalib_fix_do" "{if(cacascale==''){ascale='1.18';}else{scale=cacascale;} i:fresh=1;display;if(_TERM=~'screen'){echo 'screen+cacalib?expect binding problems!'}}" "See cacalib_fix.";
alias "cacalib_fix" "getenv 'DISPLAY';if(_device_string=='caca' && ENV_DISPLAY==''){cacalib_fix_do;scale 'a';}" "When using the libcaca (Coloured 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 'cacascale' 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";
autocmd "PostReload"  "" "cacalib_fix";
autocmd "PostLoad"    "" "cacalib_fix";
alias "refresh" "desc 'reload';redisplay;" "reloads and displays image description";
bind "F5" "refresh";
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;}" "Toggles full screen. Will show mouse cursor in full screen.";

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>0){prefetch;}";
autocmd "PostInteractiveCommand"   "" "if(_display_console==0 && i:fresh){redisplay;i:fresh=0;}";
autocmd "PostInteractiveCommand"   "" "idempotent_cmd"; # Bug workaround: without it console scroll is broken.

alias "next10" "i=0;while(i<10){i=i+1;next;display;sleep '1';}" "goes forward 10 images";
alias "prev10" "i=0;while(i<10){i=i+1;prev;display;sleep '1';}" "goes backward 10 images";
bind 'N' 'next10';
bind 'P' 'prev10';
bind 'C-n' "goto '+//'";
bind 'C-p' "goto '-//'";
bind 'C-b' "goto '-//'"; # Warning: many configurations cannot detect C-b.
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)";
bind 'C-w' "if(_scale_style!='w'){_scale_style='w';scale 'w';}else{_scale_style='';scale '100%';}" "scale to width";
alias "endless_slideshow" "while(1){display;sleep '1';next;}" "performs an automated slideshow, endlessly";
alias "bookview"          "while(1){display;sleep '2';scroll 'down';}" "";
alias "comicview"         "while(1){display;sleep '1';scroll 'down';}" "";
alias "read"              "while(1){display;sleep '1';scroll 'forward';}" "";
alias "slowread"          "while(1){display;sleep '2';scroll 'forward';}" "";
alias "fastread"          "while(1){display;scroll 'forward';}" "proceeds like in a book bug very fast";
alias "pornview"          "echo 'press any key repeatedly to terminate' ;endless_slideshow" "enters an 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";
## Example in imposing a file loader to an extension:
#autocmd "PreReload"    ".*mtx.gz" "_file_loader='MatrixMarket'";
#autocmd "PostReload"   ".*mtx.gz" "_file_loader=''";
###bind '*' "scale '100%'";
bind '*' "_display_console=0;toggleVerbosity;echo i:*";
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%';}" "scale to height";
####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" "if(_display_console==0){pan 'down';}else{scd;}" "pans the image down / scrolls console down";
alias "pan_up"   "if(_display_console==0){pan 'up'  ;}else{scu;}"   "pans the image up / scrolls console 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;redisplay" "";
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" "rotate 90 degrees counter clockwise";
alias "rotate90_cw"  "i:_orientation=i:_orientation+1;i:fresh=1;i:fresh=1;redisplay" "rotate 90 degrees clockwise";
alias "rotate180"  "i:_orientation=i:_orientation+2;i:fresh=1;i:fresh=1;redisplay" "rotate 180 degrees";
alias "rotate90" "rotate90_cw;display" "rotate 90 degrees clockwise";
alias "rotate270" "rotate90_ccw;display" "rotate 90 degrees counter clockwise";
alias "rotate10"     "rotate  '10';display" "rotate 10 degrees counter clockwise";
alias "rotate10_ccw" "rotate -10  ;display" "rotate 10 degrees clockwise";

#### 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;}';
bind 'C-k' 'crop' # still experimental
#### 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 caught 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" "widen horizontally the image";
bind  'Y' "narrow" "shrink 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;}' "scrolls up the virtual console";
alias 'console_scroll_down' 'if(allow_round_scroll || (_console_offset>=console_scroll_n)){_console_offset=_console_offset-console_scroll_n;}' "scrolls down the virtual console";
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"';
alias "font_magnify_auto" "if(_fbfont_as_screen_fraction>1){_fbfont_as_screen_fraction=_fbfont_as_screen_fraction-1;}else{_fbfont_as_screen_fraction=_screen_width/100+_screen_height/100;}" "";
alias "font_magnify_manual"      "_fbfont_magnify_factor=_fbfont_magnify_factor+1" "";
alias "font_reduce_auto"  "if(_fbfont_as_screen_fraction>1){_fbfont_as_screen_fraction=_fbfont_as_screen_fraction+1;}" "";
alias "font_reduce_manual"       "_fbfont_magnify_factor=_fbfont_magnify_factor-1" "";
alias "toggle_font_auto_scale" "if(_fbfont_as_screen_fraction<0){_fbfont_as_screen_fraction=0;echo 'Auto font scaling on.';}else{_fbfont_as_screen_fraction=-1;echo 'Auto font scaling off.';}" "toggles between manual and auto font scaling control";
alias 'next_file_dir_same'      "goto '+/s';" "go to next file in same dir";
alias 'next_file_dir_other'     "goto '+/S';" "go to next file in other dir";
alias 'next_file_dir_up'        "goto '+/u';" "go to next file up the dir hierarchy";
alias 'next_file_dir_down'      "goto '+/d';" "go to next file down the dir hierarchy";
alias 'next_file_same_basename' "goto '+/b';" "go to next file with same basename";
alias 'prev_file_dir_same'      "goto '-/s';" "go to prev file in same dir";
alias 'prev_file_dir_other'     "goto '-/S';" "go to prev file in other dir";
alias 'prev_file_dir_up'        "goto '-/u';" "go to prev file up the dir hierarchy";
alias 'prev_file_dir_down'      "goto '-/d';" "go to prev file down the dir hierarchy";
alias 'prev_file_same_basename' "goto '-/b';" "go to prev file with same basename";
#alias "font_magnify" "if(_fbfont_as_screen_fraction<0) {font_magnify_manual;}else{font_magnify_auto;}" "increase font size (either relative or absolute)";
#alias "font_reduce"  "if(_fbfont_as_screen_fraction<0) {font_reduce_manual;} else{font_reduce_auto;}"  "increase font size (either relative or absolute)";
alias "font_magnify" "_fbfont_as_screen_fraction=-1;font_magnify_manual" "increase absolute font size and set manual font control";
alias "font_reduce"  "_fbfont_as_screen_fraction=-1;font_reduce_manual"  "decrease absolute font size and set manual font control";
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"; # console code for C-h and Backspace is the same :-)
bind "'" "goto _lastfileindex"; 
bind '"' "scale 'shadow';i:fresh=1;redisplay;"; 
bind '(' "goto '^p'";
bind ')' "goto '$p'";
bind 'Z' "sleep 1";
_display_status=1; # lower status line
_want_wm_caption_status="fim:%N@%p%%%L[%i/%l]";
_info_fmt_str="%p%% %wx%h%L %i/%l%P %F %T %c"; # lower right line part
#_display_status_fmt="%N:%k"; #
_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"; # lower left line part
#_fbfont_as_screen_fraction=-1; # disable auto font scaling
echo "WELCOME: to switch to the command line interface press ':'";
# 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' 'blob.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 it FIM cannot work like it should.
# Feel free to modify it, but with caution!
