home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / AP / JED / JED097-1.TAR / jed / src / intrin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  56.5 KB  |  1,252 lines

  1. /*
  2.  *  Copyright (c) 1992, 1994 John E. Davis  (davis@amy.tch.harvard.edu)
  3.  *  All Rights Reserved.
  4.  */
  5. #include <string.h>
  6.  
  7. #include "slang.h"
  8. #include "config.h"
  9. #include "buffer.h"
  10. #include "keymap.h"
  11. #include "file.h"
  12. #include "ins.h"
  13. #include "ledit.h"
  14. #include "screen.h"
  15. #include "window.h"
  16. #include "display.h"
  17. #include "search.h"
  18. #include "misc.h"
  19. #include "replace.h"
  20. #include "paste.h"
  21. #include "sysdep.h"
  22. #include "cmds.h"
  23. #include "text.h"
  24. #include "abbrev.h"
  25.  
  26. #if defined(__GO32__) || defined(__WATCOMC__)
  27. #define LANG_INTERRUPT i386_check_kbd
  28. extern void i386_check_kbd (void);
  29. #endif
  30.  
  31.  
  32. #if defined(msdos) || defined(__os2__)
  33. #include <process.h>
  34. #endif
  35.  
  36. extern char Jed_Root_Dir[256];
  37.  
  38. static void do_buffer_keystring (char *s)
  39. {
  40.    buffer_keystring (s, strlen(s));
  41. }
  42.  
  43. static void do_tt_write_string (char *s)
  44. {
  45.    if (Batch)
  46.      {
  47.     fputs (s, stdout);
  48.      }
  49.    else tt_write_string (s);
  50. }
  51.  
  52. #ifndef pc_system
  53. static void do_tt_set_term_vtxxx (int *i)
  54. {
  55.    tt_set_term_vtxxx (i);
  56. }
  57. #endif
  58.  
  59.  
  60. static int jed_getpid (void)
  61. {
  62.    return getpid ();
  63. }
  64.  
  65. static int map_color_object_to_number (char *what)
  66. {
  67.    int i;
  68.    
  69.    if (!strcmp("normal", what)) i = JNORMAL_COLOR;
  70.    else if (!strcmp("status", what)) i = JSTATUS_COLOR;
  71.    else if (!strcmp("region", what)) i = JREGION_COLOR;
  72.    else if (!strcmp("cursor", what)) i = JCURSOR_COLOR;
  73.    else if (!strcmp("operator", what)) i = JOP_COLOR;
  74.    else if (!strcmp("number", what)) i = JNUM_COLOR;
  75.    else if (!strcmp("string", what)) i = JSTR_COLOR;
  76.    else if (!strcmp("comment", what)) i = JCOM_COLOR;
  77.    else if (!strcmp("keyword", what)) i = JKEY_COLOR;
  78.    else if (!strncmp("delimiter", what, 5)) i = JDELIM_COLOR;
  79.    /* Oops!-- earlier version had delimiter spelled delimeter.  This is
  80.     * for backward compatability.
  81.     */
  82.    else if (!strcmp("preprocess", what)) i = JPREPROC_COLOR;
  83.    else if (!strcmp("menu", what)) i = JMENU_COLOR;
  84.    
  85.    else i = -1;
  86.    return i;
  87. }
  88.  
  89. static void enable_menu_bar (int *what)
  90. {
  91.    Window_Type *w;
  92.    
  93.    /* find the top window */
  94.    w = JWindow;
  95.    
  96.    while (w->top != Top_Window_Row) w = w->next;
  97.    if (*what) 
  98.      {
  99.     if (Top_Window_Row != 1) return;
  100.     if (w->rows < 3) 
  101.       {
  102.          /* window is too small --- fix it. */
  103.          one_window ();  w = JWindow;
  104.          if (w->rows < 3) return;
  105.       }
  106.     w->top = Top_Window_Row = 2;
  107.     w->rows -= 1;
  108.      }
  109.    else 
  110.      {
  111.     if (Top_Window_Row == 1) return;
  112.     w->top = Top_Window_Row = 1;
  113.     w->rows += 1;
  114.      }
  115.    touch_screen ();
  116. }
  117.  
  118.          
  119. static int rename_file (char *f1, char *f2)
  120. {
  121.    return rename (f1, f2);
  122. }
  123.  
  124.     
  125.    
  126. void set_term_colors(char *what, char *fg, char *bg)
  127. {
  128.    int i;
  129.    i = map_color_object_to_number (what);
  130.    tt_set_color (i, what, fg, bg);
  131. }
  132.  
  133. #ifndef pc_system
  134. void set_term_color_esc (char *what, char *esc)
  135. {
  136.    int i;
  137.    if (tt_set_color_esc == NULL) return;
  138.    
  139.    i = map_color_object_to_number (what);
  140.    tt_set_color_esc (i, esc);
  141. }
  142. #endif
  143.  
  144.  
  145. static void exit_error_cmd (char *msg, int *severity)
  146. {
  147.    exit_error (msg, *severity);
  148. }
  149.  
  150. void save_search_string(char *s)
  151. {
  152.    strncpy(Last_Search_Str, s, 131);
  153.    Last_Search_Str[131] = 0;
  154. }
  155.  
  156. int do_prefix_argument(int *n)
  157. {
  158.    int ret = *n;
  159.    if (Repeat_Factor != NULL)
  160.      {
  161.     ret = *Repeat_Factor;
  162.     Repeat_Factor = NULL;
  163.      }
  164.    return ret;
  165. }
  166.  
  167.  
  168.  
  169. static void bury_buffer(char *name)
  170. {
  171.    Buffer *b, *cp, *bp, *bn;
  172.    
  173.    if ((NULL == (b = find_buffer(name)))
  174.        || (b == CBuf)
  175.        || (CBuf == (bn = b->next))) return;
  176.    
  177.    cp = CBuf->prev;
  178.    bp = b->prev;
  179.    
  180.    CBuf->prev = b;               /* my definition of bury buffer */
  181.    b->next = CBuf;
  182.    b->flags |= BURIED_BUFFER;
  183.    bp->next = bn;
  184.    bn->prev = bp;
  185.    cp->next = b;
  186.    b->prev = cp;
  187. }
  188.  
  189.  
  190. static void set_buffer_hook (char *s, char *h)
  191. {
  192.    SLang_Name_Type *f;
  193.    
  194.    f = SLang_get_function (h);
  195.    
  196.    if (!strcmp("par_sep", s)) CBuf->par_sep = f;
  197.    else if (!strcmp("indent_hook", s)) CBuf->indent_hook = f;
  198.    else if (!strcmp("wrap_hook", s)) CBuf->wrap_hook = f;
  199. }
  200.    
  201.     
  202.  
  203. static SLang_Name_Type jed_intrinsics[] =
  204. {
  205.    MAKE_INTRINSIC(".setkey", set_key, VOID_TYPE, 2),
  206.    /*Prototype: Void setkey(String fun, String key);
  207.      'fun' is the function that 'key' is to be assigned.  'key' can contain
  208.      the '^' character which denotes that the following character is to be
  209.      interpreted as a control character, e.g.,
  210.      
  211.           setkey("bob", "^Kt");
  212.       
  213.      sets the key sequence 'Ctrl-K t' to the function 'bob' which moves the 
  214.      editing point to the beginning of the buffer.  Note that 'setkey' works 
  215.      on the "global" keymap.
  216.      See also: unsetkey, definekey. */
  217.  
  218.    MAKE_INTRINSIC(".push_mark", push_mark,VOID_TYPE, 0),
  219.    /*Prototype: Void push_mark();
  220.      This function marks the current Point as the beginning of a region.  
  221.      Other functions operate on the region defined by the Point and the Mark. 
  222.      See also: pop_mark, push_spot, markp, dupmark, check_region */
  223.    
  224.    MAKE_INTRINSIC(".bol", bol,VOID_TYPE, 0),
  225.    /*Prototype: Void bol();
  226.     * Moves Point to the beginning of the current line.
  227.     * See also: eol, bob, eob, bolp */
  228.  
  229.    MAKE_INTRINSIC(".setmode", set_mode_cmd, VOID_TYPE, 2),
  230.    /*Prototype:  Void setmode(String mode, Integer flags);
  231.     * Sets buffer mode flags and status line mode name.  'mode' is a string 
  232.     * which is displayed on the status line if the %m status line format 
  233.     * specifier is used. The second argument, 'flags' is an integer with 
  234.     * the possible values:
  235.  
  236.     *     0 : no mode. Very generic
  237.     *     1 : Wrap mode.  Lines are automatically wrapped at wrap column.
  238.     *     2 : C mode.
  239.     *     4 : Language mode.  Mode does not wrap but is useful for computer 
  240.     *         languages.
  241.     *     8 : S-Lang mode
  242.     *   0x10: Fortran mode highlighting
  243.     *   0x20: TeX mode highlighting
  244.     * See also: whatmode, getbuf_info, setbuf_info.  */
  245.         
  246.    MAKE_INTRINSIC(".insert", insert_string,VOID_TYPE, 1),
  247.    /*Prototype: Void insert(String str);
  248.     * Inserts string 'str' in buffer at the current Point.
  249.     * See also: del, insert_file, insbuf */
  250.    MAKE_INTRINSIC(".eol", eol,VOID_TYPE, 0),
  251.    /*Prototype Void eol();
  252.     * Moves Point to the end of the current line. 
  253.     * See also: eolp, bol, bob, eob */
  254.    MAKE_INTRINSIC(".setbuf", set_buffer, VOID_TYPE, 1),
  255.    /*Prototype: Void setbuf(String buf);
  256.     * Changes the default buffer to one named 'buf' for editing.  This change
  257.     * only lasts until top level of editor loop is reached at which point the
  258.     * the buffer associated with current window will be made the default.
  259.     * See also: sw2buf, pop2buf, whatbuf */
  260.    MAKE_INTRINSIC(".message", message, VOID_TYPE, 1),
  261.    /*Prototype: Void message(String msg);
  262.     * Displays the string 'msg' in the MiniBuffer at the bottom of the display.
  263.     * This does not immediately display the message.  In particular, subsequent
  264.     * calls to 'message' will overwrite the values of previous calls.  The 
  265.     * message is displayed when the screen is updated next.  For an immediate
  266.     * effect, use the function 'flush' instead.
  267.     * See also: flush, error, update */
  268.    
  269.    MAKE_INTRINSIC(".del_region", delete_region, VOID_TYPE, 0),
  270.    /*Prototype: Void del_region();
  271.     * Deletes the region specified by the Point and Mark.
  272.     * See also: push_mark, markp, check_region */
  273.    MAKE_INTRINSIC(".bufsubstr", buffer_substring, VOID_TYPE, 0),
  274.    /*Prototype: String bufsubstr();
  275.     * This function returns the region specified by the Point and Mark as 
  276.     * a String.  If the region crosses lines, the string will contain
  277.     * newline characters.
  278.     * See also: insbuf, push_mark */
  279.    MAKE_INTRINSIC(".right", forwchars,INT_TYPE, 1),
  280.    /*Prototype: Integer right(Integer n);
  281.     * This function moves the Point forward forward 'n' characters and returns
  282.     * the number actually moved.  The number returned will be smaller than 'n'
  283.     * if the end of the buffer is reached.
  284.     * See also: left, up, down, eol, eob */
  285.  
  286.    MAKE_INTRINSIC(".definekey", set_key_in_keymap, VOID_TYPE, 3),
  287.    /*Prototype: Void definekey(String f, String key, String kmap);
  288.     * This function is used for binding keys to functions in a specific keymap.
  289.     * Here 'f' is the function to be bound, 'key' is a sequence of keys and 
  290.     * 'kmap' is the name of the keymap to be used.  See 'setkey' for a 
  291.     * definition of 'keys'.  
  292.     See also: setkey, undefinekey, make_keymap, use_keymap */
  293.    MAKE_VARIABLE(".LAST_SEARCH", Last_Search_Str, STRING_TYPE, 1),
  294.    /*A readonly string variable containing the value of the last 
  295.     * interactively search for string.
  296.     * See also: save_search_string. */
  297. #ifndef pc_system
  298.    MAKE_VARIABLE(".USE_ANSI_COLORS", &tt_Use_Ansi_Colors, INTP_TYPE, 0),
  299. #endif
  300.    MAKE_VARIABLE(".Status_Line_String", Default_Status_Line, STRING_TYPE, 1),
  301.    /*A read-only String variable containing the format of the status line
  302.     * applied to newly created buffers.
  303.     See also: set_status_line */
  304.    MAKE_INTRINSIC(".save_search_string", save_search_string, VOID_TYPE, 1),
  305.    /*Prototype: Void save_search_string(String str);
  306.     * Sets the value of the read-only variable 'LAST_SEARCH' to 'str'. 
  307.     * See also: LAST_SEARCH */
  308.    MAKE_VARIABLE(".MINIBUFFER_ACTIVE", &MiniBuffer_Active, INT_TYPE, 1),
  309.    /*A read-only variable that is non-zero when the MiniBuffer is actively
  310.     * being used. */
  311.    MAKE_INTRINSIC(".left", backwchars,INT_TYPE, 1),
  312.    /*Prototype: Integer left(Integer n);
  313.     * Move Point backward 'n' characters returning number actually moved.  
  314.     * The number returned will be less than 'n' only if the top of the buffer 
  315.     * is reached. 
  316.     * See Also: right, up, down, bol, bob */
  317.    MAKE_INTRINSIC(".whatbuf", what_buffer, STRING_TYPE, 0),
  318.    /*Prototype: String what_buffer();
  319.     * Returns the name of the current buffer.
  320.     * See also: getbuf_info, bufferp */
  321.    MAKE_INTRINSIC(".error", msg_error, VOID_TYPE, 1),
  322.    /*Prototype: Void error(String msg);
  323.     * Signals an error condition and displays the string 'msg' at the bottom of
  324.     * the display.  The error can be caught by an ERROR_BLOCK and cleared with
  325.     * the '_clear_error' function.  Unless caught, the error will cause the 
  326.     * S-Lang stack to unwind to the top level.
  327.     * See also: _clear_error, message, flush */
  328.    MAKE_INTRINSIC(".getbuf_info", get_buffer_info,  VOID_TYPE, 0),
  329.    /*Prototype:  getbuf_info();
  330.     * This function returns 4 values to the stack.  The four value from the 
  331.     * top are:
  332.     *  Integer'flags'        % buffer flags
  333.     *  String 'buffer_name'  % name of buffer
  334.     *  String 'directory'    % directory associated with buffer
  335.     *  String 'file'         % name of file associated with buffer (if any).
  336.  
  337.     * The flags are encoded as: 
  338.     *   bit 0: buffer modified
  339.     *   bit 1: auto save mode
  340.     *   bit 2: file on disk modified
  341.     *   bit 3: read only bit
  342.     *   bit 4: overwrite mode
  343.     *   bit 5: undo enabled
  344.     *   bit 6: reserved
  345.     *   bit 7: just save instead of autosaving.  If bit 1 is set, 
  346.     *          this is ignored.
  347.  
  348.     * For example, 
  349.     *   (file,,,) = getbuf_info();
  350.     * returns the file associated with the buffer.
  351.     * See also: setbuf_info, whatbuf */
  352.    MAKE_INTRINSIC(".otherwindow", other_window, VOID_TYPE, 0),
  353.    /*Prototype: Void otherwindow();
  354.     * Switch to next window. 
  355.     * See also: nwindows, onewindow */
  356.    MAKE_INTRINSIC(".is_internal", is_internal, INT_TYPE, 1),
  357.    /*Prototype Integer is_internal(String f);
  358.     * Returns non-zero is function 'f' is defined as an internal function or
  359.     * returns zero if not.  Internal functions not immediately accessable from
  360.     * S-Lang; rather, they must be called using the 'call' function.
  361.     See also: call, is_defined.*/
  362.    MAKE_INTRINSIC(".setbuf_info", set_buffer_info,  VOID_TYPE, 4),
  363.    /*Prototype: Void setbuf_info(String file, String dir, String buf, Integer flags);
  364.     * Sets information of the current buffer.  Here 'file' is the name of the 
  365.     * file to be associated with the buffer; 'dir' is the directory to be 
  366.     * associated with the buffer; buf is the name to be assigned to the buffer,
  367.     * and flags describe the buffer attributes.  See 'getbuf_info' for a 
  368.     * discussion of 'flags'.  Note that the actual file associated with the
  369.     * buffer is located in directory 'dir' with the name 'file'.
  370.     * See also: getbuf_info */
  371.    MAKE_INTRINSIC(".up", prevline, INT_TYPE, 1),
  372.    /*Prototype: Integer up(Integer n);
  373.     * Move Point up 'n' lines returning number of lines actually moved.  The 
  374.     * number returned will be less than 'n' only if the top of the buffer is
  375.     * reached.
  376.     See also: down, left, right */
  377.    MAKE_INTRINSIC(".down", nextline,INT_TYPE, 1),
  378.    /*Prototype: Integer down(Integer n);
  379.     * Move Point down 'n' lines returning number of lines actually moved.  The 
  380.     * number returned will be less than 'n' only if the last line of the buffer
  381.     * has been reached.
  382.     See also: down, left, right */
  383.    MAKE_INTRINSIC(".call", call_cmd, VOID_TYPE, 1),
  384.    /*Prototype: Void call(String f);
  385.     * Execute internal function named 'f'.  An internal function is a function
  386.     * that cannot be directly accessed from S-Lang.
  387.     * See: is_internal. */
  388.    MAKE_INTRINSIC(".eob", eob,VOID_TYPE, 0),
  389.    /*Prototype: Void eob();
  390.     * Move Point to the end of the buffer.
  391.     * See also: eobp, bob, bol, eol */
  392.    MAKE_INTRINSIC(".unsetkey", unset_key, VOID_TYPE, 1),
  393.    /*Prototype: Void unsetkey(String key);
  394.     * Removes the defeinition of 'key' from the "global" keymap.  For example,
  395.     * by default, the "global" keymap binds the keys "^[[A", "^[[B", "^[[C", 
  396.     * and "^[[D" to the character movement functions.  Using 
  397.     * 'unsetkey("^[[A")' will remove the binding of "^[[A" from the global 
  398.     * keymap but the other three will remain.  However, 'unsetkey("^[[")' 
  399.     * will remove the definition of all the above keys.
  400.     * See also:  setkey, undefinekey */
  401.    MAKE_INTRINSIC(".bob", bob,VOID_TYPE, 0),
  402.    /*Prototype: Void eob();
  403.     * Move Point to the beginning of the buffer.
  404.     * See also: bobp, eob, bol, eol */
  405.    MAKE_INTRINSIC(".looking_at", looking_at, INT_TYPE, 1),
  406.    /*Prototype: Integer looking_at(String s);
  407.     * Returns non-zero if Point is positioned in he buffer such that the 
  408.     * characters immediately following it match 's' otherwise it returns 0.
  409.     * See also: ffind, fsearch, re_fsearch, bfind */
  410.    MAKE_INTRINSIC(".del", del,VOID_TYPE, 0),
  411.    /*Prototype: Void del();
  412.     * Delete character at point unless at the end of the buffer in which case
  413.     * nothing happens.
  414.     * See also: what_char, eobp, del_region */
  415.    MAKE_INTRINSIC(".markp", markp, INT_TYPE, 0),
  416.    /*Prototype: Void markp();
  417.     * Returns a non-zero value if a mark is set in the buffer otherwise it
  418.     * returns zero.  A mark usually denotes a region is defined.
  419.     * See also: push_mark, pop_mark, check_region, push_spot */
  420.    MAKE_INTRINSIC(".nwindows", num_windows,INT_TYPE, 0),
  421.    /*Prototype Integer nwindows();
  422.     * Return number of windows currently visible.
  423.     * See also: splitwindow, onewindow, window_size */
  424.    MAKE_INTRINSIC(".add_completion", add_to_completion, VOID_TYPE, 1),
  425.    /*Prototype Void add_completion(String f);
  426.     * Add S-Lang function with name 'f' to the list of function completions.
  427.     * See also: read_with_completion */
  428.    MAKE_INTRINSIC(".what_column", calculate_column,INT_TYPE, 0),
  429.    /*Prototype: Integer what_column();
  430.     * Returns the current column number of the Point expanding tabs, etc...
  431.     * The beginning of the line is at column 1.
  432.     * See: whatline, whatpos, goto_column */
  433.    MAKE_INTRINSIC(".eobp", eobp,INT_TYPE, 0),
  434.    /*Prototype: Integer eobp();
  435.     * Returns non-zero if the Point is positions at the beginning of the 
  436.     * buffer otherwise it returns zero.
  437.     * See also: eob, bolp, eolp */
  438.    MAKE_INTRINSIC(".fsearch", search_forward, INT_TYPE, 1),
  439.    /*Prototype: Integer fsearch(String str);
  440.     *  Search forward in buffer looking for string 'str'.  If not found, this
  441.     * functions returns zero.  However, if found, it returns non-zero and 
  442.     * moves the Point to the start of the match.  It respects the setting
  443.     * of the variable 'CASE_SEARCH'.
  444.     * See also: ffind, bsearch, bfind, re_fsearch, CASE_SEARCH */
  445.    
  446.    MAKE_INTRINSIC(".buffer_visible", jed_buffer_visible, INT_TYPE, 1),
  447.    /*Prototype: Integer buffer_visible(String buffer);
  448.     * Returns non-zero if 'buffer' is currently visible in a window or
  449.     * it returns zero if not. */
  450.      
  451.    MAKE_INTRINSIC(".exit_jed", exit_jed, VOID_TYPE, 0),
  452.    /*Prototype: Void exit_jed();
  453.     * Exits JED.  If any buffers are modified, the user is queried 
  454.     * about whether or not to save first.  Calls S-Lang hook "exit_hook"
  455.     * if defined.  If "exit_hook" is defined, it must either call 'quit_jed'
  456.     * or 'exit_jed' to really exit the editor.  If 'exit_jed' is called from
  457.     * 'exit_hook', 'exit_hook' will not be called again. */
  458.    MAKE_INTRINSIC(".set_color", set_term_colors, VOID_TYPE, 3),
  459.    /*Prototype: Void set_color(String object, String fg, String bg);
  460.     * This function sets the foreground and background colors of an 'object'
  461.     * to 'fg' and 'bg'.  The exact values of the strings 'fg' and 'bg' are 
  462.     * system dependent.  
  463.     * Valid object names are: 
  464.     *   "status", "normal", "region", and "cursor".
  465.     * In addition, if color syntax highlighting is enabled, the following object
  466.     * names are also meaningful:
  467.     *   "number", "delimeter", "keyword", "string", "comment", "operator",
  468.     *   "preprocess"
  469.     * See also: WANT_SYNTAX_HIGHLIGHT
  470.     */
  471. #ifndef pc_system
  472.    MAKE_INTRINSIC(".set_color_esc", set_term_color_esc, VOID_TYPE, 2),
  473.    /*Prototype: Void set_color_esc (String object, String esc_seq);
  474.     * This function may be used to associate an escape sequence with an 
  475.     * object.  The escape sequence will be set to the terminal prior to 
  476.     * sending the object.  It may be used on mono terminals to underline 
  477.     * objects, etc...
  478.     * See 'set_color' for a list of valid object names.
  479.     */
  480. #endif
  481.    MAKE_INTRINSIC(".extract_filename", extract_file, STRING_TYPE, 1),
  482.    /*Prototype: String extract_filename (String filespec);
  483.     * Separates the filename from the path of 'filespec'. 
  484.     * Example: (unix)
  485.     *    var = extract_filename ("/tmp/name");
  486.     * assigns a value of "name" to 'var'
  487.     */
  488.    MAKE_INTRINSIC(".trim", trim_whitespace,VOID_TYPE, 0),
  489.    /*Prototype: Void trim(); 
  490.     * Removes all whitespace around point.
  491.     * See also: skip_chars, skip_white
  492.     */
  493.    MAKE_INTRINSIC(".pop2buf", pop_to_buffer, VOID_TYPE, 1),
  494.    /*Prototype: Void pop2buf (String buf);
  495.     * Pop up a window containing a buffer named 'buf'. If 'buf' does not exist,
  496.     * it will be created. If 'buf' already exists in a window, the window containing
  497.     * 'buf' will be the active one.  This function will create a new window
  498.     * if necessary.
  499.     * See also: pop2buf_whatbuf, setbuf, sw2buf */
  500.    MAKE_INTRINSIC(".pop2buf_whatbuf", pop_to_buffer, STRING_TYPE, 1),
  501.    /*Prototype: String pop2buf_whatbuf (String buf);
  502.     * This function performs the same function as 'pop2buf' except that the 
  503.     * name of the buffer that 'buf' replaced in the window is returned.  This 
  504.     * allows one to replace the buffer in the window with the one previously
  505.     * there. 
  506.     * See also: pop2buf */
  507.    MAKE_VARIABLE(".DISPLAY_EIGHT_BIT", &Display_Eight_Bit, INT_TYPE, 0),
  508.    /* if non zero, pass chars with hi bit set to terminal as is,
  509.       otherwise prefix with a `~' and pass char with hi bit off. */
  510.    MAKE_VARIABLE(".JED_CSI", &JED_CSI, INT_TYPE, 0),
  511.    /* Control Sequence Introducer. --- reserved for future use */
  512.    MAKE_INTRINSIC(".copy_region", copy_region_cmd, VOID_TYPE, 1),
  513.    /*Prototype: Void copy_region (String buf);
  514.     * Copies a marked region in the current buffer to buffer 'buf'.
  515.     * See also: insbuf, bufsubstr */
  516.    MAKE_INTRINSIC(".insbuf", insert_buffer_name, VOID_TYPE, 1),
  517.    /*Prototype: Void insbuf (String buf);
  518.     * Insert buffer named 'buf' into the current buffer at Point.
  519.     * See also: copy_region */
  520.    MAKE_INTRINSIC(".bolp", bolp,INT_TYPE, 0),
  521.    /*Prototype: Integer bolp ();
  522.     * 'bolp' is used to test if the Point is at the beginning of a line.  It 
  523.     * returns non-zero if at the beginning of a line and 0 if not.
  524.     * See also: bol, eolp, bobp, eobp */
  525.    MAKE_INTRINSIC(".beep", beep, VOID_TYPE, 0),
  526.    /* Send beep to screen. */
  527.    MAKE_INTRINSIC(".onewindow", one_window,VOID_TYPE, 0),
  528.    /* make current window the only one. */
  529.    MAKE_INTRINSIC(".pop_spot", pop_spot,VOID_TYPE, 0),
  530.    /*Prototype: Void pop_spot ();
  531.     * This function is used after 'push_spot' to return to the location where
  532.     * 'push_spot' was called.
  533.     * See also: push_spot, pop_mark */
  534.    MAKE_INTRINSIC(".push_spot", push_spot,VOID_TYPE, 0),
  535.    /*Prototype: Void push_spot ();
  536.     * 'push_spot' pushes the location of the current buffer location onto a 
  537.     * stack.  This function does not set the mark.  Use push_mark for that purpose.
  538.     * The spot can be returned to using 'pop_spot'.
  539.     * See also: pop_spot, push_mark */
  540.    MAKE_INTRINSIC(".bsearch", search_backward, INT_TYPE, 1),
  541.    /*Prototype: Integer bsearch (String str);
  542.     * Searches backward from the current Point for 'str'.  If 'str' is found, 
  543.     * this function will return non-zero and the Point will be placed at the
  544.     * location of the match.  If a match is not found, zero will be returned and
  545.     * the Point will not change.
  546.     * See also: fsearch, bol_bsearch, re_bsearch */
  547.    MAKE_INTRINSIC(".sw2buf", switch_to_buffer_cmd, VOID_TYPE, 1),
  548.    /* Switch to BUFFER.  If BUFFER does not exist, one is created with name
  549.        BUFFER */
  550.    MAKE_INTRINSIC(".tt_send", do_tt_write_string, VOID_TYPE, 1),
  551.    /* send STRING to terminal with no interpretation */
  552.    MAKE_INTRINSIC(".eolp", eolp,INT_TYPE, 0),
  553.    /* Returns TRUE if Point is at the end of a line. */
  554.    MAKE_INTRINSIC(".what_keymap", what_keymap, STRING_TYPE, 0),
  555.    /* returns keymap name of current buffer */
  556.    MAKE_INTRINSIC(".find_file", find_file_in_window, INT_TYPE, 1),
  557.    /* finds FILE in current window returning non zero if file found.
  558.        See Also: read_file */
  559.    MAKE_INTRINSIC(".set_status_line", set_status_format, VOID_TYPE, 2),
  560.    /*  Usage:  set_status_line(String format, Integer flag);
  561.        If flag is non-zero, format applies to the global format string 
  562.        otherwise it applies to current buffer only.  
  563.        Format is a string that may contain the following format specifiers:
  564.          %b   buffer name
  565.      %f   file name
  566.      %v   JED version
  567.      %t   current time --- only used if variable DISPLAY_TIME is non-zero
  568.      %p   line number or percent string
  569.      %%   literal '%' character
  570.      %m   mode string
  571.      */
  572.    MAKE_INTRINSIC(".bury_buffer", bury_buffer, VOID_TYPE, 1),
  573.    /*Prototype: Void bury_buffer(String name);
  574.      Make buffer 'name' unlikley to appear in a window.  */
  575.    
  576.    MAKE_INTRINSIC(".dupmark", dup_mark, INT_TYPE, 0),
  577.    /*Prototype Integer dupmark ();
  578.      This function returns zero if the mark is not set or, if the mark is set,
  579.      a duplicate of it is pushed and 1 is returned. */
  580.    MAKE_INTRINSIC(".erase_buffer", erase_buffer, VOID_TYPE, 0),
  581.    /* erases all text from the current buffer.
  582.     See: delbuf */
  583.    MAKE_INTRINSIC(".window_info", window_size_intrinsic, INT_TYPE, 1),
  584.    /*Prototype Integer window_info(Integer item);
  585.      Returns information specified by 'item' about the current window.  Here
  586.      'item' is one of:
  587.      
  588.          'r'  : Number of rows
  589.          'w'  : width of window 
  590.      'c'  : starting column (from 1)
  591.      't'  : screen line of top line of window (from 1)
  592.     */
  593.    MAKE_VARIABLE(".whatline", &LineNum,INT_TYPE, 1),
  594.    /* returns current line number -- used to be a function. */
  595.    MAKE_VARIABLE(".BLINK", &Blink_Flag, INT_TYPE, 0),
  596.    MAKE_VARIABLE(".WRAP_INDENTS", &Indented_Text_Mode, INT_TYPE, 0),
  597.    /* If non-zero, after wrap, line is indented as previous line. */
  598.    MAKE_INTRINSIC(".goto_column", goto_column, VOID_TYPE, 1),
  599.    /* Move Point to COLUMN inserting spaces and tabs if necessary. */
  600.    MAKE_INTRINSIC(".goto_column_best_try", goto_column1, INT_TYPE, 1),
  601.    /*Prototype: Integer goto_column_best_try (Integer c);
  602.      This function is like goto_column except that it will not insert
  603.      spaces.  It returns the column number is did go to. */
  604.    /* Move Point to COLUMN inserting spaces and tabs if necessary. */
  605.    MAKE_VARIABLE(".TAB_DEFAULT", &User_Vars.tab, INT_TYPE, 0),
  606.    /* default tab setting applied to all newly created buffers.
  607.       See TAB. */
  608.    MAKE_INTRINSIC(".goto_line", goto_line,VOID_TYPE, 1),
  609.    /* move Point to LINE. */
  610.    MAKE_INTRINSIC(".file_status", file_status, INT_TYPE, 1),
  611.  /* returns integer desecribing FILE:
  612.         2 file is a directory
  613.         1 file exists
  614.         0 file does not exist.
  615.        -1 no access.
  616.        -2 path invalid
  617.        -3 unknown error
  618.    */
  619.    MAKE_VARIABLE(".C_INDENT", &User_Vars.c_indent, INT_TYPE, 0),
  620.    MAKE_INTRINSIC(".flush", flush_message, VOID_TYPE, 1),
  621.    /* Takes 1 string argument and immediately displays it as a message 
  622.       in the minibuffer.  It is exactly like the `message' function except
  623.       that its effect is immediate.
  624.       See: message, update */
  625.       
  626.       MAKE_VARIABLE(".IGNORE_BEEP", &tt_Ignore_Beep, INTP_TYPE, 0),
  627.       /* If 0, do not beep the terminal.  If 1 beep.  If 2 use visible bell
  628.        * only.  If 3 use both bells.
  629.        */
  630.    
  631.       MAKE_VARIABLE(".ADD_NEWLINE", &Require_Final_Newline, INT_TYPE, 0),
  632.    MAKE_VARIABLE(".LASTKEY", Jed_Key_Buffer, STRING_TYPE, 1),
  633.    /* buffer containing last keysequence.  Key sequences using the
  634.       null character will not be recorded accurately. */
  635.    MAKE_VARIABLE(".C_BRA_NEWLINE", &C_Bra_Newline, INT_TYPE, 0),
  636.    /* if non-zero, insert newline before inserting '{' in C mode */
  637.    MAKE_VARIABLE(".DISPLAY_TIME", &Display_Time, INT_TYPE, 0),
  638.    /* A non-zero value means to enable display of time whenever %t occurs
  639.       in the status line format. */
  640.    MAKE_VARIABLE(".WANT_EOB", &Want_Eob, INT_TYPE, 0),
  641.    /* Set this to non zero value if it is desired to have [EOB] mark
  642.        the end of the buffer. */
  643.    MAKE_INTRINSIC(".input_pending", input_pending, INT_TYPE, 1),
  644.    /* Only argument is amount of seconds/10 to wait for input.  0 returns
  645.       right away.  Returns TRUE if there is input waiting. */
  646.    MAKE_INTRINSIC(".insert_file",  insert_file, INT_TYPE, 1),
  647.    /* This returns <= 0 if file not found. */
  648.    MAKE_INTRINSIC(".keymap_p",  keymap_p, INT_TYPE, 1),
  649.    /* Returns TRUE if KEYMAP is defined. */
  650.    MAKE_VARIABLE(".WRAP", &User_Vars.wrap_column, INT_TYPE, 0),
  651.    MAKE_INTRINSIC(".what_char", what_char, INT_TYPE, 0),
  652.    /* returns ASCII value of character point is on. */
  653.    MAKE_INTRINSIC(".bfind", backward_search_line, INT_TYPE, 1),
  654.    /* returns TRUE if STRING found backward on current line */
  655.    MAKE_INTRINSIC(".pop_mark", pop_mark, VOID_TYPE, 1),
  656.    /* Pop last pushed mark off the mark stack. If argument is non zero, 
  657.        move point to position of mark first. */
  658.    MAKE_INTRINSIC(".read_mini", mini_read, VOID_TYPE, 3),
  659.    /* read from minibuffer with PROMPT and DEFAULT strings using STRING
  660.       to stuff the minibuffer.  Returns string to stack. */
  661.    MAKE_INTRINSIC(".recenter", recenter, VOID_TYPE, 1),
  662.    /* update window with current line on Nth line of window. 
  663.        If N is 0, recenter */
  664.    MAKE_INTRINSIC(".bufferp", bufferp, INT_TYPE, 1),
  665.    /* returns  TRUE if BUFFER exists */
  666.    MAKE_INTRINSIC(".get_key_function", get_key_function, VOID_TYPE, 0),
  667.    /* Returns current key binding.  If key has a binding, it also 
  668.       returns 0 if the function is S-Lang or non zero if it is internal. */
  669.    MAKE_INTRINSIC(".dump_bindings", dump_bindings, VOID_TYPE, 1),
  670.    /*Prototype: Void dump_bindings(String map);
  671.      Dumps a list of the keybindings for the keymap specified by 'map'.
  672.      */
  673.    /* Returns current key binding.  If key has a binding, it also 
  674.       returns 0 if the function is S-Lang or non zero if it is internal. */
  675.    MAKE_VARIABLE(".META_CHAR", &Meta_Char, INT_TYPE, 0),
  676.    /* When a character with the hi bit set is input, it gets mapped to
  677.       a two character sequence, The META_CHAR, followed by the
  678.       character with its hi bit off.  By default, META_CHAR is 27, the
  679.       escape character. */
  680.    MAKE_VARIABLE(".DEC_8BIT_HACK", &DEC_8Bit_Hack, INT_TYPE, 0),
  681.    /* If set, an character between 128 and 160 will be converted into a 
  682.       two character sequence: ESC and the character itself stripped of the
  683.       high bit + 64.
  684.     */
  685.    MAKE_INTRINSIC(".undefinekey", unset_key_in_keymap, VOID_TYPE, 2),
  686.    /* Undefines KEY from KEYMAP.
  687.    See: make_keymap. */
  688.    MAKE_INTRINSIC(".getpid", jed_getpid, INT_TYPE, 0),
  689.    /*Prototype: Integer getpid();
  690.      Returns pid of current process. */
  691.    
  692.    MAKE_INTRINSIC(".update", update_cmd, VOID_TYPE, 1),
  693.    /* Update display.  If argument it TRUE, force update otherwise 
  694.       update only if there is no input */
  695.    MAKE_INTRINSIC(".skip_white", skip_whitespace, VOID_TYPE, 0),
  696.    /* Skip past whitespace.  This does not cross lines.  
  697.     See: skip_chars */
  698.    MAKE_INTRINSIC(".skip_word_chars", skip_word_chars, VOID_TYPE, 0),
  699.    /* skip over all characters that constitute a word. */
  700.    MAKE_INTRINSIC(".skip_non_word_chars", skip_non_word_chars, VOID_TYPE, 0),
  701.    /* skip over all characters that do not constitute a word. */
  702.    MAKE_INTRINSIC(".bskip_word_chars", bskip_word_chars, VOID_TYPE, 0),
  703.    /* skip backwards over all characters that constitute a word. */
  704.    MAKE_INTRINSIC(".bskip_non_word_chars", bskip_non_word_chars, VOID_TYPE, 0),
  705.    /* skip backwards over all characters that do not constitute a word. */
  706.    MAKE_INTRINSIC(".which_key", which_key, INT_TYPE, 1),
  707.    /* returns NUMBER of keys that are bound to argument followed
  708.        by NUMBER keys.  Control Chars are expanded as 2 chars. */
  709.    MAKE_INTRINSIC(".whitespace", insert_whitespace,VOID_TYPE, 1),
  710.    /* inserts whitespace of length n using tabs and spaces.  If the global
  711.     variable  TAB is 0, only spaces are used. */
  712.    MAKE_VARIABLE(".C_BRACE", &User_Vars.c_brace, INT_TYPE, 0),
  713.    MAKE_INTRINSIC(".enlargewin", enlarge_window,VOID_TYPE, 0),
  714.    /* Makes the current window bigger by one line. */
  715.    MAKE_INTRINSIC(".splitwindow", split_window,VOID_TYPE, 0),
  716.    /* Splits current window in half making two. */
  717.    MAKE_INTRINSIC(".file_time_compare", file_time_cmp, INT_TYPE, 2),
  718.    /* compares the modification times of two files, FILE1 and FILE2.
  719.       returns positive, negative, or zero integer for FILE1 > FILE2,
  720.       FILE1 < FILE2, or FILE1 == FILE2, resp.  The operator '>' should
  721.       be read 'is more recent than'.   The convention adopted by the routine
  722.       is that if a file does not exist, it was modified at the beginning of
  723.       time. Thus, if 'f' exists, but 'g' does not, f g file_time_compare
  724.       will return 1. */
  725.    MAKE_INTRINSIC(".xform_region", transform_region, VOID_TYPE, 1),
  726.    /* Prototype: Void xform_region (Integer how);
  727.     * This function changes the characters in the region in a way specified 
  728.     * by the parameter 'how'.  This is an integer that can be any of of the
  729.     * following:
  730.     *     'u' upcase_region
  731.     *     'd' downcase_region
  732.     *     'c' Capitalize region
  733.     * Anything else will change case of region 
  734.     */
  735. #ifdef pc_system
  736. #if !defined(__GO32__) && !defined(__WATCOMC__)
  737.    MAKE_VARIABLE(".NUMLOCK_IS_GOLD", &NumLock_Is_Gold, INT_TYPE, 0),
  738. #endif
  739. #if !defined(__os2__) && !defined(__WATCOMC__) && !defined(__GO32__)
  740.    MAKE_VARIABLE(".CHEAP_VIDEO", &SLtt_Msdos_Cheap_Video, INTP_TYPE, 0),
  741.    /* non zero if snow appears on screen when updating it. */
  742. #endif
  743. #else
  744.    MAKE_VARIABLE(".OUTPUT_RATE", &tt_Baud_Rate, INTP_TYPE, 0),
  745.    /* Terminal baud rate */
  746. #endif
  747.  
  748.    MAKE_INTRINSIC(".skip_chars", skip_chars, VOID_TYPE, 1),
  749.    /*Prototype: Void skip_chars(String s);
  750.     * skip past all characters in string 's'.
  751.     * s is a string which contains ascii chars to skip, or a rang of ascii 
  752.     * chars.  So for example, "- \t0-9ai-o_" will skip the hyphen, space, tab
  753.     * numerals 0 to 9, letter a, letters i to o, and underscore.
  754.     * 
  755.     * If the first character of 's' is '^', then the compliment of the range 
  756.     * is skipped instead.  So for example,
  757.     * 
  758.     *     skip_chars("^A-Za-z");
  759.     * 
  760.     * skips ALL characters except the letters.  The backslash character may be
  761.     * used to escape ONLY the FIRST character in the string.  That is, "\\^"
  762.     * is to be used to skip over '^' characters.
  763.  
  764.     * See Also: bskip_chars, skip_white */
  765.    
  766.    MAKE_INTRINSIC(".bobp", bobp,INT_TYPE, 0),
  767.    /* TRUE if at beginning of buffer */
  768.    MAKE_INTRINSIC(".ffind", forward_search_line, INT_TYPE, 1),
  769.    /* Returns TRUE if STRING is found forward current line. If found, Point
  770.        is moved to string */
  771.    MAKE_INTRINSIC(".bol_fsearch", bol_fsearch, INT_TYPE, 1),
  772.    /* Search forward for string at beginning of line. Returns TRUE if found */
  773.    MAKE_INTRINSIC(".bol_bsearch", bol_bsearch, INT_TYPE, 1),
  774.    /* Search backward string at beginning of line. Returns TRUE if found */
  775.    
  776.    MAKE_INTRINSIC(".command_line_arg", command_line_argv, STRING_TYPE, 1),
  777.    /* Takes integer parameter N in the range: 0 <= N < MAIN_ARGC.
  778.     MAIN_ARGC is a global variable indicating the number of command line 
  779.     parameters.  This function returns the Nth parameter.
  780.     See Also the variable MAIN_ARGC */
  781.    
  782.    MAKE_VARIABLE(".MAIN_ARGC", &Main_Argc, INT_TYPE, 1),
  783.    /* MAIN_ARGC is a global variable indicating the number of command line 
  784.       parameters. 
  785.       See Also: command_line_arg */
  786.       
  787.    
  788.    MAKE_INTRINSIC(".set_file_translation", set_file_trans, VOID_TYPE, 1),
  789.    /* 1 open files in binary, 0 in text (default) */
  790.  
  791. #if defined (unix) || defined (__os2__)
  792. #ifndef __GO32__
  793.    MAKE_INTRINSIC(".pipe_region", pipe_region, INT_TYPE, 1),
  794.    /* pipes region to CMD returning number of lines written. */
  795.    MAKE_INTRINSIC(".shell_cmd", shell_command, VOID_TYPE, 1),
  796.    /* executes CMD in a subshell inserting output inter buffer at Point */
  797. #endif
  798. #endif
  799.    MAKE_INTRINSIC(".mkdir", make_directory, INT_TYPE, 1),
  800.    /* create a directory with NAME.  Returns TRUE if successful, 0 otherwise. */
  801.    MAKE_INTRINSIC(".rmdir", delete_directory, INT_TYPE, 1),
  802.    /* delete a directory with NAME.  Returns TRUE if successful, 0 otherwise. 
  803.       The directory must be empty for the operation to succeed. */
  804.    MAKE_INTRINSIC(".append_region_to_file", append_to_file, INT_TYPE, 1),
  805.    /*Prototype: Integer append_region_to_file (String file);
  806.     * Appends a marked region to 'file' returning number of lines written or -1
  807.     * on error.  This does NOT modify a buffer visiting the file; however,
  808.     * it does flag the buffer as being changed on disk. */
  809.    MAKE_INTRINSIC(".autosave", auto_save, VOID_TYPE, 0),
  810.    /* autosave current buffer if marked for autosave */
  811.    MAKE_INTRINSIC(".autosaveall", auto_save_all, VOID_TYPE, 0),
  812.    /* save all buffers marked for autosave */
  813.    
  814.    MAKE_INTRINSIC(".backward_paragraph", backward_paragraph, VOID_TYPE, 0),
  815.    /* move point past current paragraph.  Slang hook is_paragraph_seperator
  816.      is called (if defined) to determine if line is a paragraph seperator. */
  817.    MAKE_INTRINSIC(".blank_rect", blank_rectangle, VOID_TYPE, 0),
  818.    /* blanks out rectangle defined by point and mark */
  819.    MAKE_INTRINSIC(".bskip_chars", bskip_chars, VOID_TYPE, 1),
  820.    /* skip backward chars in STRING.  
  821.       See skip_chars for definition of STRING */
  822.    MAKE_INTRINSIC(".buffer_list", make_buffer_list,  VOID_TYPE, 0),
  823.    /* returns a  list of buffers to the stack.  The top element of the 
  824.     stack is the number of buffers */
  825.    MAKE_INTRINSIC(".check_region", check_region, VOID_TYPE, 1),
  826.    /* Signals Error if mark not set.  Exchanges point 
  827.     and mark to produce valid region.  A valid region is one with mark
  828.     earlier in the buffer than point.  Always call this if using a region
  829.     which requires point > mark.  Also, if argument is non-zero, spot is 
  830.     pushed. */
  831.    MAKE_INTRINSIC(".copy_rect", copy_rectangle, VOID_TYPE, 0),
  832.    /* save a copy of rectangle defined by point and mark in rectangle 
  833.      buffer */
  834.    MAKE_INTRINSIC(".define_word", define_word, VOID_TYPE, 1),
  835.    /* Only argument is a string which is an expression which defines 
  836.       a word.  Typically, it is a range of ascii values.  The default 
  837.       definition is: "a-z0-9"
  838.       To include a hyphen, make it the first character.  So for example,
  839.       "-i-n" defines a word to consist of letters 'i' to 'n'  and '-' */
  840.      
  841.    MAKE_INTRINSIC(".delbuf", kill_buffer_cmd, VOID_TYPE, 1),
  842.    /* deletes specified buffer name */
  843.    MAKE_INTRINSIC(".delete_file",  sys_delete_file, INT_TYPE, 1),
  844.    /* Deletes FILENAME.  Returns 1 if deletion was successful, otherwise
  845.     it returns 0. */
  846.    MAKE_INTRINSIC(".directory", expand_wildcards, INT_TYPE, 1),
  847.    /* returns number of files and list of files which match filename. 
  848.       On unix, this defaults to filename*.  It is primarily useful for
  849.       DOS and VMS to expand wilcard filenames */
  850.    MAKE_INTRINSIC(".evalbuffer", load_buffer, VOID_TYPE ,0),
  851.    /* evaluates a buffer as S-Lang code.  See: evalfile */
  852.    MAKE_INTRINSIC(".expand_filename", expand_filename, STRING_TYPE, 1),
  853.    /* expands filename to a canonical form */
  854.    MAKE_INTRINSIC(".filechgondsk", file_changed_on_disk, INT_TYPE, 1),
  855.    /* Returns true if FILE on disk is more recent than editor file */
  856.    MAKE_INTRINSIC(".forward_paragraph", forward_paragraph, VOID_TYPE, 0),
  857.    /* move point past current paragraph.  Slang hook is_paragraph_seperator
  858.      is called (if defined) to determine if line is a paragraph seperator. */
  859.    
  860.    MAKE_INTRINSIC(".get_doc_string", get_doc_string, INT_TYPE, 2),
  861.    /* read doc string for OBJECT from FILE.  Returns 1 and string
  862.        upon success or 0 on failure.  If OBJECT is a functiion, 
  863.        it must be prefixed with an 'F'.  If it is a variable, the prefix
  864.        character is a 'V'.  
  865.        Example: "Fget_doc_string" */
  866.    MAKE_INTRINSIC(".getkey", jed_getkey, INT_TYPE, 0),
  867.    /* Read a key from input stream returning ASCII value read. */
  868.    MAKE_INTRINSIC(".indent_line", indent_line, VOID_TYPE, 0),
  869.    /* Indent line according to current mode. */
  870.  
  871.    MAKE_INTRINSIC(".insert_rect", insert_rectangle, VOID_TYPE, 0),
  872.    /* insert contents of previously deleted rectangle at Point. */
  873.    MAKE_INTRINSIC(".kill_rect", kill_rectangle, VOID_TYPE, 0),
  874.    /* deletes rectangle defined  by point and mark.  The contents of 
  875.        the rectangle are saved in the rectangle buffer destroying previous
  876.        contents. */
  877.    MAKE_INTRINSIC(".make_keymap", create_keymap, VOID_TYPE, 1),
  878.    /* Creates a new keymap with name map.  The newly created keymap is an 
  879.     * exact copy of the global map "global".
  880.     * See: use_keymap, definekey, undefinekey */
  881.    MAKE_INTRINSIC(".map_input", map_character, VOID_TYPE, 2),
  882.    /* Used to remap input characters from the keyboard to a different 
  883.        character before JED interprets the character.  For example,
  884.      '8 127 map_input' will cause JED to think that the ^H (8) is the 
  885.       delete character (127).  Note that '8 127 map_input 127 8 map_input
  886.       effectively swaps the ^H and delete keys. */
  887.    MAKE_INTRINSIC(".narrow", narrow_to_region, VOID_TYPE, 0),
  888.    /* restrict editing to region of LINES defined by point and mark.  
  889.        Use 'widen' to remove the restriction. Be careful with this because
  890.        it currently does not remember a previous narrow. */
  891.    MAKE_INTRINSIC(".open_rect", open_rectangle, VOID_TYPE, 0),
  892.    /* insert a BLANK rectangle.  The rectangle  is defined by point and mark. */
  893.    
  894.    MAKE_INTRINSIC(".quit_jed", quit_jed, VOID_TYPE, 0),
  895.    /* Quit JED saving no buffers, just get out! */
  896.    
  897.    MAKE_INTRINSIC(".read_file", find_file_cmd, INT_TYPE, 1),
  898.    /*  read FILE into its own buffer  returning non zero if file exists.
  899.        see find_file to read a file into a window. */
  900.    MAKE_INTRINSIC(".read_with_completion", read_object_with_completion, VOID_TYPE, 4),
  901.    /* Takes 4 parameters:  PROMPT(string) DEFAULT(string) STUFF(string) 
  902.       and TYPE(integer).
  903.       TYPE must be one of:
  904.          'f'   file name
  905.      'b'   buffer name
  906.      'F'   function name
  907.      'V'   variable name.
  908.      
  909.      STUFF is a string which is stuffed into the buffer.
  910.      Using this function enables completion on the object.
  911.      */
  912.    MAKE_INTRINSIC(".replace", replace_cmd, VOID_TYPE, 2),
  913.    /*Prototype Void replace(String old, String new);
  914.      Replaces all occurances of 'old' with 'new' from current point to
  915.      the end of the buffer. The Point is returned to the initial location. */
  916.    MAKE_INTRINSIC(".set_abort_char", set_abort_char, VOID_TYPE, 1),
  917.    /* Change Abort character to CHAR.  The default is 7 which is ^G.
  918.       Using this function modifies ALL keymaps */
  919.    MAKE_INTRINSIC(".suspend", sys_spawn_cmd, VOID_TYPE, 0),
  920.    /* Suspend jed and return to calling process or spawn subprocess.
  921.      "suspend_hook" is called before suspension and "resume_hook" is called
  922.      after.  These are user defined S-Lang functions. */
  923.    MAKE_INTRINSIC(".time", get_time, STRING_TYPE, 0),
  924.    /* return current date and time string */
  925.    MAKE_INTRINSIC(".ungetkey", ungetkey, VOID_TYPE, 1),
  926.    /* push ASCII value of character on input stream */
  927.    MAKE_INTRINSIC(".buffer_keystring", do_buffer_keystring, VOID_TYPE, 1),
  928.    /*Prototype: Void buffer_keystring (String str);
  929.     * Append string 'str' to the end of the input stream to be read by JED's
  930.     * getkey routines.
  931.     * See also: ungetkey, getkey
  932.     */
  933.    MAKE_INTRINSIC(".use_keymap",  use_keymap, VOID_TYPE, 1),
  934.    /* Asscoiate KEYMAP with buffer. */
  935. #ifndef pc_system
  936.    MAKE_INTRINSIC(".w132", screen_w132, VOID_TYPE, 0),
  937.    MAKE_INTRINSIC(".w80", screen_w80, VOID_TYPE, 0),
  938. #endif
  939.    MAKE_INTRINSIC(".whatmode", what_mode, INT_TYPE, 0),
  940.    /* returns buffer mode string and mode flag.  See setmode for details. */
  941.    MAKE_INTRINSIC(".widen", widen, VOID_TYPE, 0),
  942.    /* Opposite of Narrow.  See narrow for additional information. */
  943.    MAKE_INTRINSIC(".window_line", window_line, INT_TYPE, 0),
  944.    /* returns number of line in window.  top line is 1. */
  945.    MAKE_INTRINSIC(".write_buffer", write_buffer_cmd, INT_TYPE, 1),
  946.    /* writes buffer to FILE. Returns number of lines written or signals
  947.        error on failure. */
  948.    MAKE_INTRINSIC(".write_region_to_file", write_region, INT_TYPE, 1),
  949.    /* Prototype: Integer write_region_to_file (String file);
  950.     * Write region to 'file'.  Returns number of lines written or signals
  951.     * error on failure. 
  952.     */
  953.       
  954.    MAKE_INTRINSIC(".count_chars", count_chars, VOID_TYPE, 0),
  955.    /* returns a string of form "char 37, point 2150 of 10067"
  956.       where 2150 is character number of Point and 10067 is the total.
  957.       37 is the ascii value of current character.
  958.       A string is returned instead of numbers because MSDOSints are only 
  959.       16 bits and S-Lang does not have long integer types.
  960.       */
  961.    MAKE_INTRINSIC(".get_yes_no", get_yes_no, INT_TYPE, 1),
  962.    /* Takes one argument-- a string that is used to get 
  963.       yes or no responce from user.  Returns 1 if yes, 0 if no. 
  964.       Also returns -1 if abort and signals error. */
  965.    MAKE_INTRINSIC(".rename_file", rename_file, INT_TYPE, 2),
  966.    /* rename file from OLD_NAME to NEW_NAME returning 0 if the 
  967.       operation succeeds, and a non-zero value if it fails. 
  968.       Both files must be on the same file system. */
  969.    MAKE_INTRINSIC(".change_default_dir", ch_dir, INT_TYPE, 1),
  970.    /*  Change default directory to new directory.  Returns 0 upon
  971.       success and -1 upon failure.  All relative path names are expanded
  972.       with respect to the new default directory. */
  973.    MAKE_INTRINSIC(".prefix_argument",  do_prefix_argument, INT_TYPE, 1),
  974.    /* Usage:  int prefix_argument(int default);
  975.          Returns value of prefix argument if there is one otherwise
  976.      returns 'default'. */
  977.    MAKE_INTRINSIC(".regexp_nth_match", regexp_nth_match, VOID_TYPE, 1),
  978.    MAKE_INTRINSIC(".replace_match", replace_match, INT_TYPE, 2),
  979.    /*Prototype: Integer replace_match(String s, Integer how);
  980.     * This function replaces text previously matched with `re_fsearch' or
  981.     * `re_bsearch' at the current editing point with string 's'.  If 'how' is
  982.     * zero, 's' is a specially formatted string of the form described below.
  983.     * If 'how' is non-zero, 's' is regarded as a simple string and is used
  984.     * literally.  If the replacement fails, this function returns zero
  985.     * otherwise, it returns non-zero.
  986.     */
  987.    MAKE_INTRINSIC(".re_fsearch", re_search_forward, INT_TYPE, 1),
  988.    /*Prototype: Integer re_fsearch(String pattern);
  989.     * Search forward for regular expression 'pattern'.  This function returns
  990.     * the 1 + length of the string  matched.  If no match is found, it returns 
  991.     * 0.
  992.     * 
  993.     * See also: fsearch, bol_fsearch, re_bsearch */
  994.    MAKE_INTRINSIC(".re_bsearch", re_search_backward, INT_TYPE, 1),
  995.    /*Prototype: Integer re_bsearch(String pattern);
  996.     * Search backward for regular expression 'pattern'.  This function returns
  997.     * the 1 + length of the string  matched.  If no match is found, it returns 
  998.     * 0.
  999.     * 
  1000.     * See also: bsearch, bol_bsearch, re_fsearch */
  1001.  
  1002.    MAKE_INTRINSIC(".set_buffer_hook", set_buffer_hook, VOID_TYPE, 2),
  1003.    /*Prototype: Void set_buffer_hook (String hook, String f);
  1004.     * Set current buffer hook 'hook' to function 'f'. 'f' is a user
  1005.     * defined S-Lang function.  Currently, name can be any one of:
  1006.     *   "par_sep"  -- returns zero if the current line does not
  1007.     *                 constitute the beginning or end of a paragraph.  
  1008.     *                 It returns non-zero otherwise.  The default value of 'hook' is 
  1009.     *                 'is_paragraph_separator'.
  1010.     *   "indent_hook" -- returns nothing.  It is called by the indent line
  1011.     *                 routines.
  1012.     *   "wrap_hook"   hook that is called after a line is wrapped.  Returns
  1013.     *                 nothing
  1014.     */
  1015.    MAKE_INTRINSIC(".insert_file_region", insert_file_region, INT_TYPE, 3),
  1016.    MAKE_INTRINSIC(".search_file", search_file, INT_TYPE, 3),
  1017.    /* search FILE for STRING returning TRUE if string found. */
  1018.    MAKE_INTRINSIC(".random", make_random_number, INT_TYPE, 2),
  1019.    /* Usage:  seed n random
  1020.       Returns a random number in the range 0 to n - 1.  If seed is 0, the 
  1021.       number generated depends on previous seed.  If seed is -1, a seed based 
  1022.       on current time and pid is used, otherwise, seed is used as a seed. */
  1023. #ifndef pc_system
  1024.    MAKE_INTRINSIC(".set_term_vtxxx", do_tt_set_term_vtxxx, VOID_TYPE, 1),
  1025.    /* Set terminal display appropriate for a vtxxx terminal.  This function 
  1026.     * takes a single integer parameter.  If non-zero, the terminal type is set 
  1027.     * for a vt100.  This means the terminal lacks the ability to insert/delete
  1028.     * lines and characters.  If the parameter is zero, the terminal is assumed
  1029.     * to be vt102 compatable.  Unless you are using a VERY old terminal or 
  1030.     * a primitive emulator, use zero as the parameter. */
  1031.     MAKE_VARIABLE(".TERM_CANNOT_INSERT", &tt_Term_Cannot_Insert, INTP_TYPE, 0),
  1032.    /* Set this variable to 1 in your jed startup file (jed.rc) if your 
  1033.     terminal is unable to insert (not vt102 compatable) */
  1034.    MAKE_VARIABLE(".TERM_CANNOT_SCROLL", &tt_Term_Cannot_Scroll, INTP_TYPE, 0),
  1035.    /* Set this variable to 1 in your jed startup file (jed.rc) if your 
  1036.     terminal is unable to scroll. */
  1037. #endif
  1038.    
  1039.    MAKE_VARIABLE(".BATCH", &Batch, INT_TYPE, 1),
  1040.    /* non-zero if JED is running in batch mode.  This variable
  1041.        is read only. */
  1042.    MAKE_VARIABLE(".TAB", &Buffer_Local.tab, INT_TYPE, 0),
  1043.    /* Tab setting for the current buffer. */
  1044.    MAKE_VARIABLE(".SELECTIVE_DISPLAY", &Buffer_Local.sd, INT_TYPE, 0),
  1045.    /* If negative, ^M (RET) makes rest of line invisible.  Hidden 
  1046.       text is indicated by '...'.  */
  1047.    MAKE_VARIABLE(".LAST_CHAR", &SLang_Last_Key_Char, INT_TYPE, 0),
  1048.    /* Last character entered from the keyboard */
  1049.    MAKE_VARIABLE(".MAX_HITS", &User_Vars.max_hits, INT_TYPE, 0),
  1050.    /* maximum number of 'hits' on a buffer before an autosave is performed. */
  1051.    MAKE_VARIABLE(".CASE_SEARCH", &Case_Sensitive, INT_TYPE, 0),
  1052.    /* if 1, searches are case sensitive.  If 0, they are not */
  1053.    MAKE_VARIABLE(".POINT", &Point, INT_TYPE, 0),
  1054.    MAKE_VARIABLE(".MESSAGE_BUFFER", Message_Buffer, STRING_TYPE, 1),
  1055.    /* Read only string indicating current message to be displayed or
  1056.       is displayed in the message buffer */
  1057.    MAKE_VARIABLE(".IGNORE_USER_ABORT", &Ignore_User_Abort, INT_TYPE, 0),
  1058.    /* If set to a non-zero value, the Abort Character will not trigger a
  1059.       S-Lang error.  When JED starts up, this value is set to 1 so that 
  1060.       the user cannot abort the loading of site.sl.  Later, it is set to 0 */
  1061.  
  1062.  
  1063.    MAKE_VARIABLE(".KILL_LINE_FEATURE", &Kill_Line_Feature, INT_TYPE, 0),
  1064.    /* If non-zero, kill_line will kill through end of line character if
  1065.     Point is at beginning of the line.  Otherwise, it will kill only until
  1066.     the end of the line.  By default, this feature is turned on. */
  1067.    MAKE_VARIABLE(".SCREEN_HEIGHT", &tt_Screen_Rows, INTP_TYPE, 1),
  1068.    /* number of rows on the screen. */
  1069.    MAKE_VARIABLE(".SCREEN_WIDTH", &tt_Screen_Cols, INTP_TYPE, 1),
  1070.    /* number of columns on the screen */
  1071.    MAKE_VARIABLE(".JED_LIBRARY", Jed_Library, STRING_TYPE, 1),
  1072.    /* Read only string variable indicating the directory where JED library
  1073.     files are kept.  This variable may be set using an environment variable */
  1074.    MAKE_VARIABLE(".JED_ROOT", Jed_Root_Dir, STRING_TYPE, 1),
  1075.    /* Read only string variable indicating JED's root directory.
  1076.       This variable may be set using an environment variable */
  1077.    MAKE_VARIABLE(".LINENUMBERS", &User_Prefers_Line_Numbers, INT_TYPE, 0),
  1078.    /* If set to 0, line numbers are not displayed on the screen. If set to 
  1079.       1, line numbers will be displayed.  If set to anything else, the 
  1080.       %c column format specifier will be parsed allowing the column number
  1081.       to be displayed on the screen. */
  1082. #ifdef pc_system
  1083.    MAKE_VARIABLE(".ALT_CHAR", &PC_Alt_Char, INT_TYPE, 0),
  1084.    /*  If this variable is non-zero, characters pressed in combination
  1085.      the ALT key will generate a two character sequence: the first character 
  1086.      is the value of the ALT_CHAR itself followed by the character pressed. 
  1087.      For example, if ALT-X is pressed and ALT_CHAR has a value of 27, the 
  1088.      characters ESCAPE X will be generated. */
  1089. #endif
  1090.  
  1091. #ifdef HAS_MOUSE
  1092.     MAKE_VARIABLE(".MOUSE_X", &JMouse.x, INT_TYPE, 1),
  1093.     MAKE_VARIABLE(".MOUSE_Y", &JMouse.y, INT_TYPE, 1),
  1094.     MAKE_VARIABLE(".MOUSE_DELTA_TIME", &JMouse.time, INT_TYPE, 1),
  1095.     MAKE_VARIABLE(".MOUSE_BUTTON", &JMouse.button, INT_TYPE, 1),
  1096.     MAKE_VARIABLE(".MOUSE_EVENT_TYPE", &JMouse.type, INT_TYPE, 1),
  1097.     /* Value is 1 if the event is a keypress and 0 if a release. */
  1098.     MAKE_VARIABLE(".MOUSE_STATE", &JMouse.state, INT_TYPE, 1),
  1099.     /* The state of the shift, control, and button keys BEFORE the event.
  1100.      * This is an integer with the following meaning for the bits:
  1101.      *       0: left button pressed
  1102.      *       1: middle button pressed
  1103.      *       2: right button pressed
  1104.      *       3: shift key pressed
  1105.      *       4: control key pressed */
  1106. #endif
  1107.  
  1108.    MAKE_VARIABLE(".HIGHLIGHT", &Wants_Attributes, INT_TYPE, 0),
  1109.    /* Set this variable non-zero to highlight marked regions */
  1110.    MAKE_VARIABLE(".HORIZONTAL_PAN", &Wants_HScroll, INT_TYPE, 0),
  1111.    /* If this variable is non-zero, the window pans with the Point.  Actually
  1112.     * if the value is less than zero, the entire window pans.  If the value is 
  1113.     * positive, only the current line will pan.  The absolute value of the 
  1114.     * number determines the panning increment.  */
  1115. #ifdef VMS
  1116.    MAKE_INTRINSIC(".vms_get_help", vms_get_help,VOID_TYPE, 2),
  1117.    MAKE_INTRINSIC(".vms_send_mail", vms_send_mail, INT_TYPE, 2),
  1118.    /* Takes 2 string arguments: TO and SUBJECT.  
  1119.     *  TO may be a comma separated list of names.  The buffer will be
  1120.     *  mailed to names on this list with SUBJECT.  This routine uses 
  1121.     *  callable VMS mail.
  1122.     */
  1123. #endif
  1124. #ifdef unix
  1125. #ifndef __GO32__
  1126.    MAKE_INTRINSIC(".enable_flow_control", enable_flow_control, VOID_TYPE, 1),
  1127.    /* If integer argument is non-zero, ^S/^Q flow control is enabled.  If
  1128.     * argument is 0, ^S/^Q processing by the terminal is disabled.  Emacs mode
  1129.     * sets this to 0 (flow control off). */
  1130. #endif
  1131. #endif
  1132.    MAKE_INTRINSIC(".core_dump", exit_error_cmd, VOID_TYPE, 2),
  1133.    /*Prototype: Void core_dump(String msg, Integer severity);
  1134.     * Exit editor sumping the state of some crucial variables. If severity is 1, 
  1135.     * dump core if possible.  Message msg is also displayed. */
  1136.    MAKE_INTRINSIC(".get_last_macro", get_last_macro, VOID_TYPE, 0),
  1137.    /* Prototype: String get_last_macro();
  1138.     * This function returns characters composing the last keyboard macro.  The
  1139.     * charactors that make up the macro are encoded as themselves except the
  1140.     * following characters:
  1141.     * 
  1142.     *     '\n'    ---->   \J
  1143.     *     null    ---->   \@
  1144.     *      \      ---->   \\
  1145.     *      '"'    ---->   \"
  1146.     */
  1147. #ifdef __os2__
  1148.       MAKE_INTRINSIC(".IsHPFSFileSystem", IsHPFSFileSystem, INT_TYPE, 1),
  1149.       /*Prototype: Integer IsHPFSFileSystem(String path);
  1150.         Returns TRUE if drive of 'path' (possibly the default drive) is HPFS. */
  1151. #endif
  1152. #ifdef pc_system
  1153.       MAKE_INTRINSIC(".msdos_fixup_dirspec", msdos_pinhead_fix_dir, STRING_TYPE, 1),
  1154.       /*Prototype: String msdos_fixup_dirspec (String dir);
  1155.        * The motivation behind this is that DOS does not like a trailing
  1156.        * backslash '\\' except if it is for the root dir.  This function makes
  1157.        * 'dir' conform to that */
  1158. #endif
  1159.    MAKE_VARIABLE(".C_COMMENT_HINT", &C_Comment_Hint, INT_TYPE, 1),
  1160.    MAKE_VARIABLE(".WANT_SYNTAX_HIGHLIGHT", &Wants_Syntax_Highlight, INT_TYPE, 0),
  1161.    MAKE_INTRINSIC(".set_top_status_line", define_top_screen_line, VOID_TYPE, 1),
  1162.    /*Prototype: String set_top_status_line (String str);
  1163.     * This functions sets the string to be displayed at the top of the 
  1164.     * display. It returns the value of the line that was previously 
  1165.     * displayed.
  1166.     * 
  1167.     * See also: enable_top_status_line
  1168.     */
  1169.    MAKE_INTRINSIC(".enable_top_status_line", enable_menu_bar, VOID_TYPE, 1),
  1170.    /*Prototype: Void enable_top_status_line (Integer x);
  1171.     * If x is non-zero, the top status line is enabled.  If x is zero, the
  1172.     * top status line is disabled and hidden.
  1173.     * See also: set_top_status_line
  1174.     */
  1175.    MAKE_VARIABLE(".TOP_WINDOW_ROW", &Top_Window_Row, INT_TYPE, 1),
  1176.    /* This read-only variable gives the value of the starting row of the top
  1177.     * window.  
  1178.     */
  1179.    MAKE_VARIABLE(".DEFINING_MACRO", &Defining_Keyboard_Macro, INT_TYPE, 1),
  1180.    MAKE_VARIABLE(".EXECUTING_MACRO", &Executing_Keyboard_Macro, INT_TYPE, 1),
  1181. #if 0
  1182.    MAKE_INTRINSIC(".matching", new_find_matching, INT_TYPE, 2),
  1183. #endif
  1184.    MAKE_INTRINSIC(".create_user_mark", create_user_mark, VOID_TYPE, 0),
  1185.    MAKE_INTRINSIC(".goto_user_mark", goto_user_mark, VOID_TYPE, 0),
  1186.    MAKE_INTRINSIC(".user_mark_buffer", user_mark_buffer, STRING_TYPE, 0),
  1187.  
  1188. #ifdef HAS_ABBREVS
  1189.  
  1190.    MAKE_INTRINSIC(".list_abbrev_tables", list_abbrev_tables, INT_TYPE, 0),
  1191.    /* Prototype: Integer list_abbrev_tables ();
  1192.     * This function returns the names of all currently defined 
  1193.     * abbreviation tables.  The top item on the stack will be the number of
  1194.     * tables followed by the names of the tables.
  1195.     */
  1196.    MAKE_INTRINSIC(".use_abbrev_table", use_abbrev_table, VOID_TYPE, 1),
  1197.    /* Prototype: Void use_abbrev_table (String table);
  1198.     * Use the abbreviation table named 'table' as the abbreviation table for 
  1199.     * the current buffer.  By default, the "Global" table is used.
  1200.     */
  1201.    MAKE_INTRINSIC(".create_abbrev_table", create_abbrev_table, VOID_TYPE, 2),
  1202.     /* Prototype: Void create_abbrev_table (String name, String word);
  1203.      * Create an abbreviation table with name 'name'.  The second parameter
  1204.      * 'word' is the list of characters used to represent a word for the 
  1205.      * table. If the empty string is passed for 'word', the characters that
  1206.      * currently constitute a word are used.
  1207.      */
  1208.    MAKE_INTRINSIC(".define_abbrev", define_abbrev, VOID_TYPE, 3),
  1209.    /* Prototype: Void define_abbrev (String tbl, String abbrv, String expans);
  1210.     * This function is used to define an abbreviation 'abbrv' that will be 
  1211.     * expanded to 'expans'.  The definition will be placed in the table with
  1212.     * name 'tbl'.
  1213.     */
  1214.    MAKE_INTRINSIC(".abbrev_table_p", abbrev_table_p, INT_TYPE, 1),
  1215.    /* Prototype: Integer abbrev_table_p (String name);
  1216.     * Returns non-zero if an abbreviation table with called 'name' exists. If
  1217.     * the table does not exist, it returns zero.
  1218.     */
  1219.    MAKE_INTRINSIC(".dump_abbrev_table", dump_abbrev_table, VOID_TYPE, 1),
  1220.    /* Prototype: Void dump_abbrev_table (String name);
  1221.     * This function inserts the contents of the abbreviation table called
  1222.     * 'name' into the current buffer.
  1223.     */
  1224.    MAKE_INTRINSIC(".what_abbrev_table", what_abbrev_table, VOID_TYPE, 0),
  1225.    /* Prototype: (String, String) what_abbrev_table ();
  1226.     * This functions returns both the name of the abbreviation table and the 
  1227.     * definition of the word for the table currently associated with the 
  1228.     * current buffer.  If none is defined it returns two empty strings.
  1229.     */
  1230.    MAKE_INTRINSIC(".delete_abbrev_table", delete_abbrev_table, VOID_TYPE, 1),
  1231.    /* Prototype: Void delete_abbrev_table (String name);
  1232.     * Delete the abbrev table specified by 'name'.
  1233.     */
  1234.  
  1235. #endif
  1236.    SLANG_END_TABLE
  1237. };
  1238.  
  1239. int init_jed_intrinsics()
  1240. {
  1241.    int ret;
  1242.    ret = SLang_add_table(jed_intrinsics, "Jed");
  1243. #ifdef pc_system
  1244.    
  1245.    /* overload default slang version of system */
  1246.    SLadd_name ("system", (long) sys_System, SLANG_INTRINSIC, SLANG_MAKE_ARGS(INT_TYPE, 1));
  1247. #endif
  1248.    return ret;
  1249. }
  1250.  
  1251.  
  1252.