# $Id: fimrc 242 2009-04-18 21:09:59Z dezperado $
# Contents of the default 'fimrc' file, hardcoded in the fim executable.
# Read the documentation 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 begining with a pound (#) are ignored by fim.

#autocmd "Prev" ""  "echo 'PREV'" ;
#autocmd "Prev" "1"  "echo 'PREV1'" ;
#autocmd "Prev" "2"  "echo 'PREV2'" ;
#autocmd "Next" ""  "echo 'NEXT'" ;
#quit;
#info;
#next;
#autocmd;
#bind 29 "scale_factor_increase";
#bind 31 "scale_factor_decrease";
#bind 29 "scale_factor_grow";
#bind 31 "scale_factor_shrink";

# 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 of these variables influence Fim's behaviour (in the sense these are 'internal')
_display_status=0;
_max_cached_images=5;
_max_cached_memory=80000000;	# not yet functional
_max_iterated_commands=100;
_want_prefetch=1;
autowidth=1;
ignorecase=1;
ascale="1.0";
console_offset=0;
_save_fim_history=1;
_load_fim_history=1;

# useful aliases
alias "toggleautoflip" "autoflip=1-autoflip;";
alias "toggleflip" "i:flipped=1-i:flipped;";
alias "flip" "toggleflip;redisplay;";
alias "fliponce" "flip;toggleflip;";
alias "toggleautomirror" "automirror=1-automirror;";
alias "togglemirror" "i:mirrored=1-i:mirrored;";
alias "mirror" "togglemirror;redisplay;";
alias "mirroronce" "mirror;togglemirror;";
alias "q" "quit;";

# default bindings (binding is dynamical, so you can rebind keys even during program's execution)
bind 'f' "flip;";
bind 'F' "fliponce;";
bind 'm' "mirror;";
bind 'M' "mirroronce;";
bind 'q' "quit";
bind 'Esc' "quit";
#bind 'f' "file";
bind 'n' "next_picture;";
#bind 'h' "help";
bind 'C-h' "help";
bind 'x' "echo";
bind 'e' "echo";
bind 'p' "prev;display;";
bind 'P' "pop";
bind 's' "sort";
bind 'C-s' "swap;redisplay;";
bind 'S' "toggleDisplayStatus";
#bind 'R' "reload";
#bind 'R' "redisplay";
#bind 'r' "rotate90";
bind 'R' "rotate10";
bind 'r' "rotate10_ccw;display;";
#bind 'C-d' "display";
bind '+' "magnify";
#bind 'C-+' "angle=angle+10.0;display;";
bind 'a' "auto_scale;";
bind 'Tab' "toggleVerbosity";
bind 'C-v' "toggleKeyVerbosity";
#bind 'C-k' "toggleKeyVerbosity";
bind 'v' "toggleDisplayStatus";
bind 'A' "A";
bind 'C-m' "mark";

# Note : on many consoles C-j is by default equivalent to Enter.. so this could not work :)
bind 'Enter' "mark;next";
bind '-' "reduce";
bind "Up" "panup";
bind 'k' "panup";
bind "Right" "panright";
bind 'l' "panright";
bind "Down" "pandown";
bind 'j' "pandown";
bind "Left" "panleft";
bind 'h' "panleft";
bind ' ' "scrolldown";
bind 't' "top_align;";
bind "PageUp" "prev_picture;";
bind "PageDown" "next_picture;";
bind 'i' "info";
bind 'P' "f=`files`/2;prev  --f";
bind 'N' "f=`files`/2;next  --f";

bind 'C-g' "system 'fbgrab fim.png'";
bind 'C-r' "start_recording;";
bind 'Q' "stop_recording";
bind 'D' "dump_record_buffer;";
bind 'E' "execute_record_buffer;";
bind 'C-e' "execute_record_buffer;";
#bind 'C-x' "execute_record_buffer;";
bind 'X' "execute_record_buffer;";
bind '.' "repeat_last;";

#reload;
#_display_status=1;
#display;
alias 'A' "'autotop=1-autotop;'";
alias "toggleVerbosity" "_display_console=1-_display_console;i:fresh=1;redisplay;";

# key echo
alias "toggleKeyVerbosity" "_verbose_keys=1-_verbose_keys;redisplay;";

v:auto_scale_v=1;
_verbose_keys=0;
_display_busy=1;
_display_status=1;
#_verbose_keys=1;

# autocommands are essential to Fim's automated behaviour
#autocmd "Next"     "" "echo 'rendering next image..'";
#autocmd "Prev"     "" "echo 'rendering prev image..'";
#autocmd "PostDisplay" "" "echo '\\nthis is a file\\n'";
#autocmd "PostGoto"   "" "set_interactive_mode;";
autocmd "PostGoto" "" "reload;";
autocmd "PostNext" "" "reload;";
autocmd "PostPrev" "" "reload;";
#autocmd "PostDisplay"   "" "i:fresh=1" ;
#autocmd "PreWindow"   "" "";
autocmd "PostWindow"   "" "display;";
autocmd "PreRedisplay"   "" "i:_will_display=1;";
autocmd "PreRedisplay"   ".*/fbps-.*" "if(i:fresh){i:fresh=0;auto_width_scale;i:fresh=0;}";
autocmd "PreRedisplay"   "" "if(autowidth*i:fresh){i:fresh=0;auto_width_scale;i:fresh=0;}";
autocmd "PreRedisplay"   "" "if(v:auto_scale_v *i:fresh){i:fresh=0;auto_scale       ;i:fresh=0;}";
autocmd "PreRedisplay"   "" "if(auto_width_v *i:fresh){i:fresh=0;auto_scale_width ;i:fresh=0;}";
autocmd "PreRedisplay"   "" "if(auto_height_v*i:fresh){i:fresh=0;auto_scale_height;i:fresh=0;}";
autocmd "PostRedisplay" ""   "i:_will_display=0;";


# the aalib library has often problems with proportions, and this is a temporary fix
alias "aalib_fix_do" "{ascale='2.0';i:fresh=1;display;steps=5;if(_TERM=~'screen'){echo 'screen+aalib?expect binding problems!'}}";
alias "aalib_fix" "if(_device_driver=='aalib'){aalib_fix_do;auto_scale;}";
autocmd "PostReload"   "" "aalib_fix;";
autocmd "PostLoad"   "" "aalib_fix;";


autocmd "PostReload"  "" "i:fresh=1" ;
autocmd "PostScale"   "" "if(0==i:_will_display){i:fresh=1;display;}" ;
#autocmd "PostScale"   "" "{i:fresh=1;display;}" ;
autocmd "PostScale"   "" "_wd=i:_will_display;" ;
autocmd "PostPan"     "" "{i:fresh=1;display;}" ;
autocmd "PostReload"   "" "if(i:fresh){redisplay;}";
# FIXME : seems like the following automcd's can be commented
autocmd "PostInteractiveCommand"   "" "if(i:fresh){display;i:fresh=0;}";
autocmd "PostInteractiveCommand"   "" "if(_want_prefetch){prefetch;}";	# new : for smoother browsing of big images 
autocmd "PostInteractiveCommand"   "" "if(_display_console==0 && i:fresh){redisplay;i:fresh=0;}"; # a fixup

alias "next10" "i=0;while(i<10){i=i+1;next;display;sleep '1';};";
bind 'N' 'next10';
bind 'C-n' "regexp_goto_next";
alias "endless_slideshow" "while(1){display;sleep '1';next;};";
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;";
#extra..
bind 'w' "auto_width_scale";
bind 'h' "auto_height_scale";
alias "diagonal_nw" "pan_nw;";
alias "diagonal_ne" "pan_ne;";
alias "diagonal_se" "pan_se;";
alias "diagonal_sw" "pan_sw;";
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;";
#bind 'C-a' "auto_scale";
#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';";
####_display_status=1;
#push "media/fim.png";
#push "media/image.png";
#push "media/image.jpg";
#push "media/icon_smile.gif";
echo "WELCOME : to switch to the command line interface press ':' ";
alias "toggleAutoScale" "v:auto_scale_v=1-v:auto_scale_v;autowidth=0;reload;";
alias "toggleAutoWidth" "autowidth=1-autowidth;v:auto_scale_v=0;reload;";
bind 'C-w'   'toggleAutoWidth;';
bind 'C-a' "toggleAutoScale;";
bind 'C-c' "toggleAutoScale;";
#bind 'C-l' "clear;";	# temporarily off : FIXME
bind 'A'   "toggleAutoScale;";
#toggleVerbosity;
#bind 'f' "next;display;";
bind 'b' "prev;display;";
bind 'B' "toggleDisplayBusy";
alias "plisten" 'popen "nc -l -p 9999 "';
alias "wlisten" "while(1){sleep;plisten;}";
alias "random_slideshow" "while(1){goto random;}";
alias "rotate90_ccw" "i:orientation=i:orientation+1;i:fresh=1;i:i:fresh=1;redisplay;";
alias "rotate90_cw"  "i:orientation=i:orientation+3;i:fresh=1;i:i:fresh=1;redisplay;";
alias "rotate90" "rotate90_cw;display;";
alias "rotate10"     "rotate  '10';display;";
alias "rotate10_ccw" "rotate '-10';display;";

# window related aliases and commands
alias "wu" "window 'up'";
alias "wd" "window 'down'";
alias "wl" "window 'left'";
alias "wr" "window 'right'";
bind 'K' "wu";
# Note : on many consoles C-j is by default equivalent to Enter.. so this could not work :)
#bind 'C-j' "wd";
bind 'J' "wd";
bind 'H' "wl";
bind 'L' "wr";
alias "split" "window 'split'";
alias "vsplit" "window 'vsplit'";
alias "swap" "window 'swap'";
alias "ws " "window '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"';
# hmmmm we are out of combinations !

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;';
bind 'c' 'cache;';

alias 'widen'  'i:ascale=i:ascale*"1.1";*1.0;';
alias 'narrow' 'i:ascale=i:ascale/"1.1";*1.0;';
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 "musicplay"  "system 'mpc play'";
alias "musicpause" "system 'mpc pause'";

bind "Home" "0;";
bind "End" "$;";
bind "Backspace" "prev";

#This is a FIM initialization file. 
#Without one of these FIM is nothing.
#So feel free to modify it, but with caution! FIM is still alpha! 
