_debug_info =1;
autoload("php_mode","phpmode");
%   User Initialization file for the JED editor  -*- slang -*-
%   If a user does not have a startup file in the user's home directory,
%   JED will automatically load this from JED_LIBRARY.   Thus is is easier
%   for a system manager to make defaults for all users.

%   Do not edit this file directly.  Instead, copy it to your home 
%   directory (sys$login:jed.rc on VMS or $HOME/.jedrc on Unix) and edit
%   the resulting file.  

%   To uncomment a line, simply remove any leading '%' characters.

%   This file is divided into various sections.  The first section pertains
%   to keybindings (e.g., Wordstar, Emacs, EDT, etc...) and the following
%   sections pertain to user preferences such as default TAB sizes, line 
%   and column numbers on status line, colors, indentation style, etc...

if (BATCH == 0)
{
%----------------------------------------------------------------------
%  Keybindings  (not loaded for batch processes)
%  
%    Default bindings are Emacs-like with EDT emulation on Unix and VMS.
%    For the PC, only Emacs is enabled by default.  If you do not want EDT
%    bindings, simply coment out the appropriate line.   
%
%    For Wordstar like bindings, comment out EDT and Emacs lines and
%    uncomment Wordstar line.  A similar statement applies for BRIEF,
%    and for Borland IDE-like bindings.
%
   () = evalfile("emacs");           % Emacs-like bindings
%  () = evalfile("edt");             % EDT emulation
%  () = evalfile ("ide");            % Borland IDE (see also doc/ide-mode.txt)   
%  () = evalfile ("brief");          % Brief Keybindings (MSDOS only!!)
%  () = evalfile("wordstar");        % Wordstar (considered to be obsolete)
%  Note: For EDT emulation, jed386.exe requires that the GOLD.COM TSR 
%        be loaded.  This TSR is available from space.mit.edu:/pub/davis/jed.

% Some of the above emulations may set keys that conflict with access to
% the menubars.  For example, emacs uses ESC-f to move by words.  The 
% next line causes the keys to activate the menus.  Comment this out
% to preserve the emulation.
   enable_menu_keys ();

% If you use jed inside an XTerminal, you can use the mouse to access the 
% menus and move the cursor by uncommenting the next line:
%  enable_xmouse ();
   
% What should the Ctrl-H key do??  
%
%  setkey ("bol", "^H");              % causes ^H to go to beg of line (EDT)
%  setkey ("help_prefix", "^H");      % Uncomment to have Ctrl-H as help

#ifdef XWINDOWS
   % See xjed.txt for information regarding the delete key under X Windows.
   %    x_set_keysym (0xFFFF, 0, "\e[3~");
   %    setkey ("delete_char_cmd", "\e[3~");
#endif
   %  !!!!  ^S/^Q flow control problems !!!!
   %  if you experience problems with JED suddenly going into search mode
   %  for some reason then you are a victim of the emacs emulation's 
   %  binding of the ^S key to the search function.
   %  TO prevent this from happening, either find out how to 
   %  prevent unwanted ^S/^Q characters or uncomment the next line:
#ifdef UNIX   
   %enable_flow_control (1);
#endif
   
%----------------------------------------------------------------------
%
%   TAB key setting  -- by default, the tab key is bound to 'indent_line_cmd'.
%                       If you want a real tab inserted, uncomment next line.
%
%   setkey("self_insert_cmd", "^I");

%----------------------------------------------------------------------

%  Initial help screen --- comment out to disable.
%  Note that for the help to be valid, it must occur AFTER bindings are 
%  loaded.
   
% help();               % Pops up a help window

}  %Batch

%%%%%%%%%%%%%%%% top menu bar %%%%%%%%%%%%%%%

% To disable it, uncomment the next line.  Note that menus will still be
% available but the menubar will be hidden when not in use.
% enable_top_status_line (0);


%----------------------------------------------------------------------
% JED global variables  --- defaults shown
%
#ifdef VMS UNIX
USE_ANSI_COLORS = 1;   % if non-zero, JED will display colors on a color
                        % terminal (Unix and VMS only) See doc/color.txt 
                        % for more discussion and look below for setting
                        % the colors.
#endif
No_Backups = 1;         % If non-zero, backup files will not be created.
Startup_With_File = -1;  % if greater then zero, force JED to prompt for a file
                        %   if none is specified on the command line.  If 
                        %   negative, inhibit startup message.
DISPLAY_TIME    = 1;    % non-zero enables the time to be displayed on 
                        %  status line, zero disables it.  If this value
                        %  is -1, 24 hour time will be used.
HIGHLIGHT	= 1;	% non-zero for region highlighting
WANT_SYNTAX_HIGHLIGHT = 1;
                        % Highlight syntax in C, Fortran, and TeX modes.
                        % See section on colors
                        %  below for choosing how to highlight.  On Unix and 
                        %  VMS systems, USE_ANSI_COLORS must also be non-zero.
HORIZONTAL_PAN	= 20;	% if zero, no automatic panning.  If positive, only
                        % the current line is panned.  If negative, pan window.
#ifdef IBMPC_SYSTEM
  HORIZONTAL_PAN  = -1; % For msdos, panning window might be better:
#endif

#ifdef IBMPC_SYSTEM
  LINENUMBERS	= 2;	% A value of zero means do NOT display line number on
#else                   % status line line.  A value of 1, means to display
  LINENUMBERS	= 1;	% the linenumber. A value greater than 1 will also
#endif			% display column number information.  I recommend a 
			% value of 2 only at high baud rates

BLINK		= 1;	% if non zero, blink matching parenthesis
TAB_DEFAULT	= 8;	% Tab size  (also try edit_tab_stops)
WRAP		= 78;	% wrap column
ADD_NEWLINE	= 1;	% add newline to file when writing if one not present
IGNORE_BEEP	= 3;	% Beep terminal during error messages---
                        %  1 == sound only, 2 = visible bell only, 3 = both
_traceback	= 0;	% Non zero means dump traceback on S-Lang errors
WRAP_INDENTS	= 0;	% Non zero indents next line after wrapping current.
			%  Make this a 1 if you want indented text mode.
CASE_SEARCH	= 0;    % zero turns off case sensitivity for 
                        % search functions, non-zero turns it on
%KILL_LINE_FEATURE = 0;
			% If non-zero, kill line will kill through end of the 
			%  line if Point is at the beginning of the line. For
			%  emacs-like behavior, set this to zero.

%---------------------------------------------------------------------------
% C-mode variables:
%---------------------------------------------------------------------------
C_INDENT	= 2;	% amount of space to indent within block.
C_BRACE		= 0;	% amount of space to indent brace
C_BRA_NEWLINE   = 1;    % If non-zero, insert a newline first before inserting
                        % a '{'.  Many C programmers like this to be 0. A zero
			% value will force '{' to be on same line as insertion.
			% The jed source code uses 1 for this variable.

			% Note that in C mode, the keys '{' and '}' are bound
			% to the commands 'brace_bra_cmd' and 'brace_ket_cmd'
			% respectively.

C_Colon_Offset = 1;     % Controls the indentation of case statements.
C_CONTINUED_OFFSET = 2; % This variable controls the indentation of statements
                        % that are continued onto the next line.
%---------------------------------------------------------------------------
variable PHP_Preprocess_Indent = 1;
variable PHP_INDENT	= 2;	% amount of space to indent within block.
variable PHP_BRACE	= 0;	% amount of space to indent brace
variable PHP_BRA_NEWLINE = 1;	% If non-zero, insert a newline first before inserting 
	                        % a '{'.  Many C programmers like this to be 0. A zero
				% value will force '{' to be on same line as insertion.
				% The jed source code uses 1 for this variable.
variable PHP_Colon_Offset = 1;	% Controls the indentation of case statements.
variable PHP_CONTINUED_OFFSET = 2;% This variable controls the indentation of statements
				% that are continued onto the next line.
%---------------------------------------------------------------------------

#ifdef MSDOS XWINDOWS MSWINDOWS
% Alt-key handling.  Setting this variable controls how the
% Alt key is handled.  By default it is set to 27 (Ascii ESCAPE).  This means
% that any key pressed in conjunction with the alt key produces ESCAPE 
% followed by the key itself.  If ALT-X is pressed, an ESCAPE-X is generated.
% Set it to zero to turn off Alt key processing.  On XWindow systems, setting
% this to zero will cause the high bit to be set on the character.
% ALT_CHAR = 27;

#endif


%    Mute (dead or accent) keys 
%    Valid Mute keys are:
%      ^, ~, ', `, \d168 (ISO Diaeresis), \d180 (ISO Acute), and \".
%    This means pressing this key then the key you want to accent yields
%     the accented character.  If you do not know what this is, you do not
%     need them.  By default, they are turned off.

%mute_set_mute_keys (" ^ ~ ' ` \d168 \d180 \"  ");  % choose all or subset

META_CHAR	= -1;	% All chars with hi bit set will self insert

#ifdef IBMPC_SYSTEM
%  DISPLAY_EIGHT_BIT = 128;
#else
%  DISPLAY_EIGHT_BIT = 160; % Other systems assume ISO Latin 1
#endif

% Color Settings
% Look at jed/lib/color/README for a description of predefined color
% schemes.
set_color_scheme ("black4");
%set_color_scheme ("blue2");

#ifdef UNIX
%
%  Terminal type.  By default, on Unix termcap is used.  However, some
%  (if not all) termcaps do not include AL, DL strings for vtxxx terminals.
%
%  True blue vt100 terminals cannot insert and delete lines so the AL and DL
%  termcap entries are not appropriate for them.  However, almost no one
%  uses a true vt100 terminal anymore but they set their TERM variable to
%  vt100 just the same.  If you do not like the way your terminal scrolls,
%  and it is more than a vt100, either set your TERM variable appropriately
%  or add vt100 to the list below. 
%  

if (0)
{
   $1 = "vt102 vt200 vt220 vt300 vt320 vt420 xterms";
   if (is_substr($1, getenv("TERM"))) set_term_vtxxx(0);
}
#endif
  

%  Compiler interface --- uncomment one of the following:
% 
compile_parse_error_function = "gcc";           % GNU compiler
% compile_parse_error_function = "Ultrix_cc";     % cc on Ultrix
%compile_parse_error_function = "bcc";           % Borlands BCC
% compile_parse_error_function = "sun_acc";       % SunOS C++ and ACC
% compile_parse_error_function = "hp_cc";         % HPUX cc


() = evalfile ("comment");
%
%  Hooks:  read jed/doc/hooks.sl for more information
%
define dired_hook ()
{
   local_unsetkey ("^K");
   local_setkey ("dired_kill_line", "^K");
}

%define perl_mode_hook ()
%{
%}
%
%define php_mode_hook ()
%{
%}
%define py_mode_hook ()
%{
%}
%define sh_mode_hook ()
%{
%}
%
%define c_mode_hook ()
%{
%}

%define mail_hook ()
%{
%   % See lib/sendmail.sl for other options.
%   local_unsetkey ("^C");
%   local_setkey ("mail_send", "^C^C");   %emacs-like
%}
%
%define slang_mode_hook ()
%{
%}

%variable Tcl_Check_Syntax;
%define tcl_mode_hook ()
%{
%   Tcl_Check_Syntax = 0;
%}

() = evalfile("linux.sl");
%() = evalfile("mousex.sl");

%if(getenv("COLORTERM") == NULL)
%{
%  putenv("COLORTERM="+getenv("TERM"));
%}
%variable term;
%variable colorterm;

$1=getenv("TERM");
if (getenv("TERM") == NULL) $1 = "";
$2=getenv("COLORTERM");
if ($2 == NULL) $2 = "";

if(string_match ($2, "^rxvt", 1))
{
  setkey("backward_delete_char",	"");
  setkey("beg_of_line",		"[^@");
  %setkey("delete_char_cmd",	"");
  setkey("delete_char_cmd",	"[3~");
  setkey("eol_cmd",		"[e");	
  setkey("beg_of_line",		"[1~");	
  setkey("toggle_overwrite",	"[2~");     %/* insert key */
  setkey("eol_cmd",		"[4~");	
  setkey("beg_of_line",		"[7~");
  setkey("eol_cmd",		"[8~");
  setkey("beg_of_buffer",	"[5^");
  setkey("end_of_buffer",	"[6^");
}
else if (string_match ($1, "^linux", 1))
{
  setkey("backward_delete_char",	"");
  %setkey("backward_delete_char_untabify",	"");	
  setkey("beg_of_line",		"[^@");
  %setkey("delete_char_cmd",	"");	
  setkey("eol_cmd",		"[e");	
  setkey("beg_of_line",		"[1~");	
  setkey("toggle_overwrite",	"[2~");     %/* insert key */
  setkey("delete_char_cmd",	"[3~");
  setkey("eol_cmd",		"[4~");	
  setkey("beg_of_line",		"[7~");
  setkey("eol_cmd",		"[8~");
}
else if(is_substr("rxvt", $2))
{
  setkey("backward_delete_char",	"");	
  setkey("beg_of_line",		"[^@");
  setkey("delete_char_cmd",	"[3~");	
  setkey("eol_cmd",		"[e");	
  setkey("beg_of_line",		"[1~");	
  setkey("toggle_overwrite",	"[2~");     %/* insert key */
  setkey("eol_cmd",		"[4~");	
  setkey("beg_of_line",		"[7~");
  setkey("eol_cmd",		"[8~");
  setkey("beg_of_buffer",	"[5^");
  setkey("end_of_buffer",	"[6^");
}
else if(is_substr("Eterm", $2))
{
  setkey("backward_delete_char",	"");	
  setkey("beg_of_line",		"[^@");
  setkey("delete_char_cmd",	"[3~");	
  setkey("eol_cmd",		"[e");	
  setkey("beg_of_line",		"[1~");	
  setkey("toggle_overwrite",	"[2~");     %/* insert key */
  setkey("eol_cmd",		"[4~");	
  setkey("beg_of_line",		"[7~");
  setkey("eol_cmd",		"[8~");
  setkey("beg_of_buffer",	"[5^");
  setkey("end_of_buffer",	"[6^");
  
}
else if(is_substr("xterm-color", $2))
{
  setkey("backward_delete_char",	"^?");	
  setkey("beg_of_line",		"[^@");
  setkey("delete_char_cmd",	"[3~");	
  setkey("eol_cmd",		"[e");	
  setkey("beg_of_line",		"[1~");	
  setkey("toggle_overwrite",	"[2~");     %/* insert key */
  setkey("eol_cmd",		"[4~");	
  setkey("beg_of_line",		"[7~");
  setkey("eol_cmd",		"[8~");
  setkey("beg_of_buffer",	"[5^");
  setkey("end_of_buffer",	"[6^");
}
else if(is_substr("xiterm", $2))
{
  setkey("backward_delete_char",	"^?");	
  setkey("beg_of_line",		"[^@");
  setkey("delete_char_cmd",	"[3~");	
  setkey("eol_cmd",		"[e");	
  setkey("beg_of_line",		"[1~");	
  setkey("toggle_overwrite",	"[2~");     %/* insert key */
  setkey("eol_cmd",		"[4~");	
  setkey("beg_of_line",		"[7~");
  setkey("eol_cmd",		"[8~");
  setkey("beg_of_buffer",	"[5^");
  setkey("end_of_buffer",	"[6^");
}
else
{
  setkey("backward_delete_char",	"");
  %setkey("backward_delete_char_untabify",	"");	
  setkey("beg_of_line",		"[^@");
  setkey("delete_char_cmd",	"");	
  setkey("eol_cmd",		"[e");	
  setkey("beg_of_line",		"[1~");	
  setkey("toggle_overwrite",	"[2~");     %/* insert key */
  setkey("delete_char_cmd",	"[3~");
  setkey("eol_cmd",		"[4~");	
  setkey("beg_of_line",		"[7~");
  setkey("eol_cmd",		"[8~");
  setkey("beg_of_buffer",	"[5^");
  setkey("end_of_buffer",	"[6^");
}

setkey("insert(\"*\")",	"Oj");
setkey("insert(\"+\")",	"Ok");
setkey("insert(\".\")",	"On");
setkey("insert(\"-\")",	"Om");
setkey("newline",    	"OM");
setkey("insert(\"/\")",	"Oo");
setkey("insert(\"1\")",	"Oq");
setkey("insert(\"2\")",	"Or");
setkey("insert(\"3\")",	"Os");
setkey("insert(\"4\")",	"Ot");
setkey("insert(\"5\")",	"Ou");
setkey("insert(\"6\")",	"Ov");
setkey("insert(\"7\")",	"Ow");
setkey("insert(\"8\")",	"Ox");
setkey("insert(\"9\")",	"Oy");
setkey("insert(\"0\")",	"Op");
setkey("goto_line_cmd",	"g");
setkey("describe_bindings", "[24~");
setkey("execute_macro","[23~");
setkey("beg_of_line",	"[H");
setkey("eol_cmd",	"[F");
setkey("bdelete_word",	"\e[3~");
setkey("bdelete_word",	"\e");
setkey("skip_word",	"Oc");
setkey("bskip_word",	"Od");


%HTMLModeWraps = 1;
define delete_this_line ()
{
  bol (); push_mark (); eol (); down (1);
  del_region ();
}

setkey("delete_this_line",	"\eK");

define set_xterm_title ()
{
  variable file, dir, name,flags;
  if (is_substr("xterm", getenv("TERM")))
  {
    (file,dir,name,) = getbuf_info();
    if(strcmp(file,"") == 0)
    {
      tt_send(strncat("\[\033]0;jed   [",dir,file,"]\007\]",4));
    }
    else
    {
      tt_send(strncat("\[\033]0;jed   (",name,")\007\]",3));
    }
  }
}

unsetkey("[11^");
setkey("set_xterm_title",	"[11^");
unsetkey("^[11~");
setkey("select_menubar",	"[11~");

define reload_buffer ()
{
   variable file, dir, name,flags,buf,line,col;
   buf = whatbuf();
   (file,dir,name,) = getbuf_info();
   line=what_line();
   col=what_column();
   delbuf(buf);
   find_file(strcat(dir,file));
   goto_line(line);
   goto_column(col);
}
setkey("reload_buffer",	"[14~");
define wrap_text ()
{
   variable line,col;
   col=what_column();
   line=what_line();
   eol();
   if(what_column()>80) {
      goto_column(80);
      bsearch(" ");
      if(what_line()!=line) {
	 goto_line(line);
	 goto_column(col);
      }
      else {
	 call ("next_char_cmd");
	 insert ("\".");
	 call ("newline_and_indent");
	 insert ("\"");
      }
   }
   else {
      goto_line(line);
      goto_column(col);
   }
}
define wrap_array ()
{
   variable line,col;
   col=what_column();
   line=what_line();
   eol();
   if(what_column()>80) {
      goto_column(80);
      bsearch(",");
      if(what_line()!=line) {
	 goto_line(line);
	 goto_column(col);
      }
      else {
	 call ("next_char_cmd");
	 call ("newline_and_indent");
      }
   }
   else {
      goto_line(line);
      goto_column(col);
   }
}
setkey("wrap_text",	"[18~");
setkey("wrap_array",	"[31~");

set_status_line("(Jed %v) EKT: %b   (%m%a%n%o)  %p,%c   %t",1);

setkey("indent_and_advance",	"[19~");
define indent_and_advance ()
{
   indent_line();
   call ("next_line_cmd");
}

static variable last_buffer="";
define swap_buffers()
{
   variable buf;
   if(last_buffer=="")
   {
      last_buffer=whatbuf();
      call ("switch_to_buffer");
   }
   else
   {
      buf=last_buffer;
      last_buffer=whatbuf();
      sw2buf(buf);
      %tt_send(buf+"--"+last_buffer);
   }
}
setkey("swap_buffers",	"[13~");

define switch2buffer()
{
   last_buffer=whatbuf();
   call ("switch_to_buffer");
   %tt_send("--last="+last_buffer);
}
setkey("switch2buffer",	"b");

enable_top_status_line(0);

static variable newline_mode="newline_and_indent";
define newline_switch()
{
  if(newline_mode=="newline")
  {
    newline_mode="newline_and_indent";
    set_status_line("(Jed %v) EKT: %b   (%m%a%n%o)  %p,%c   %t",1);
  }
  else
  {
    newline_mode="newline";
    set_status_line("(Jed %v) EKT: %b   (%m%a%n%o No indent)  %p,%c   %t",1);
  }
  setkey(newline_mode,"");
} 
setkey("newline_switch",		"");


() = evalfile("macro");
setkey("macro_save_macro",		"[15~");
setkey("macro_to_function",		"[15^");
setkey("macro_assign_macro_to_key",	"[28~");
setkey("execute_macro",			"[23~");

setkey("query_replace_match",			"");
setkey("re_search_forward",			"");
setkey("re_search_backward",			"");
setkey("scroll_up_in_place",			"Oa");
setkey("scroll_down_in_place",			"Ob");
setkey("shell",	"[11~");

setkey("del_region",	"");

autoload("php_mode","phpmode");
add_mode_for_extension("php","html");
add_mode_for_extension("php","htm");
add_mode_for_extension("html","shtml");
add_mode_for_extension("php","phtml");
add_mode_for_extension("php","php");
add_mode_for_extension("php","php3");
add_mode_for_extension("php","inc");

%add_mode_for_extension("slang","sl");

variable Jed_State_File = dircat (getenv ("HOME"), ".jedstate.sl");

% Startup hook that utilizes jedstate invoked as getjedstate
%define startup_hook ()
%{
  %!if (BATCH)                           % not evaluated for batch processes
    %{
      %$1 = Sprintf ("getjedstate \"%s\"", buffer_filename, 1);
      %() = system ($1);
%
      %if (file_status (Jed_State_File) == 1)    % if we have a .jedstate.sl file
        %{
          %() = evalfile (Jed_State_File);       % evaluate command
          %() = delete_file (Jed_State_File);    % - then delete source
        %}
    %}
%}

% Exit hook that utilizes jedstate invoked as setjedstate
%define exit_hook ()
%{
  %!if (BATCH)                           % not evaluated for batch processes
    %{
      %variable fname = buffer_filename ();
%
      %if (strlen (fname))               % only if we actually have a file name
        %{
          %variable line = what_line (); % active line
          %variable col = what_column ();% - and column
%
          %$1 = Sprintf ("setjedstate \"%s\" %d %d", fname, line, col, 3);
          %() = system ($1);             % do it
        %}
      %exit_jed ();
    %}
%}

define my_mode_hook (ext)
{
   variable file;
   (file,,,) = getbuf_info ();
   if (0 != strncmp (file, "pico.", 5)) return 0;
   WRAP = 74;
   text_mode ();
   return 1;
}
Mode_Hook_Pointer = &my_mode_hook;
