home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / LIB / SHELL.LF < prev    next >
Text File  |  1996-06-04  |  36KB  |  1,352 lines

  1. %    $Id: shell.lf,v 1.2 1994/12/09 00:23:39 duchier Exp $    
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. % Copyright 1992 Digital Equipment Corporation
  5. % All Rights Reserved
  6. %
  7. %                The LIFE Shell
  8. %
  9. %
  10. % An interactive user interface for LIFE offering command line editing,
  11. %   a history mechanism, and user rebinding of keys.
  12. %
  13. % Notice: This is quite an 'old' Life program. It means that features have    
  14. %         been added to the language since it was written, especially global  
  15. %         and persistent variables: most constant functions (reset using setq)
  16. %         could be changed to persistent terms, saving memory and time.       
  17. %                                                                             
  18. % Author: Kathleen Milsted
  19. %
  20. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  21.  
  22. %% This loads the parser, etc.
  23.  
  24. module("shell") ?
  25. expand_load(true) ?
  26. load ("loader", "shell_interface") ?  
  27.  
  28. public( shell,shell2,global_set_key,interrupt,quit)  ?
  29.  
  30. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  31. %
  32. %            Main Routines
  33. %
  34. % shell: this is the main program.
  35. %   After printing a welcome message, it initializes global setq variables,
  36. %   loads the user keymap file (".life-keymap") if it exists,
  37. %   and reads the history file (by default, ".life-history") if it exists.
  38. %   It then calls the main read-eval loop with level 0 of the interface.
  39. %
  40. % main_loop: this loop is executed for each level of the interface.
  41. %   It first resets the line to be empty with the prompt for that level,
  42. %   and resets the history pointer to the current line.
  43. %   After writing the prompt, it invokes raw mode so as to read
  44. %   keyboard characters without intervention  by the terminal driver.
  45. %   It then calls "read_line" to get either: notification of an X event
  46. %   or a (possibly empty) line terminated by a carriage return.
  47. %   It exits raw mode then calls "eval_line" to evaluate the line.
  48. %   The loop is then repeated.
  49. %
  50. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  51.  
  52.  
  53. shell :-
  54.     nl,
  55.     write
  56.     ("  Welcome to the LIFE Shell (Version 0 Thu Jan 28 1993)"),
  57.     nl, nl,
  58.     initialize_variables,
  59.     read_keymap_file,
  60.     read_history_file,
  61.     fail ;            %% to recover memory
  62.     shell2.
  63.  
  64. shell2 :-
  65.     trace (false, false),
  66.     main_loop (@(level => 0, vars => @, cp_stack => [])).
  67.  
  68.  
  69.  
  70. main_loop ( Level : @(level => N) ) :-
  71.     Line = @(left => [], right => [], prompt => Prompt:prompt(N)),
  72.     HistoryPtr = current_line_number,
  73.     write (Prompt),
  74.     cond (not(in_raw), begin_raw),
  75.     read_line (Line, HistoryPtr),
  76.     end_raw,
  77.     eval_line (Level),
  78.     main_loop (Level).
  79.  
  80.  
  81.  
  82. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  83. %
  84. %            Input Routines
  85. %
  86. % read_line: this loop reads keys and executes the function 
  87. %   bound to them. The loop terminates if either an X event occurs
  88. %   or a carriage return is read.
  89. %
  90. % get_key_or_xevent: this loop reads raw characters until a 
  91. %   an X event occurs or a complete key is made.
  92. %
  93. %
  94. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  95.  
  96.  
  97. read_line (Line, HistoryPtr) :-
  98.     %%  get a key or X event  %%
  99.     get_key_or_xevent (Key, XEvent),
  100.     (
  101.       %%  if an X event, flag it and return  %%
  102.       XEvent, setq (xeventflag, true), nl
  103.     ;
  104.       %%  if carriage return, save the line and return
  105.       return_key (Key), setq (current_line, line2revchars(Line)), nl
  106.     ;
  107.       %%  else, get the function bound to the key,  %%
  108.       %%  execute the function,               %%
  109.       %%  then repeat the loop                    %%
  110.       get_function_bound_to_key (Key, global_map, Function),
  111.       Function & @(Line, HistoryPtr, self => Key),
  112.       setq (line, Line), setq (history_ptr, HistoryPtr),
  113.       fail            %% to recover memory
  114.     ;
  115.       read_line (line, history_ptr)
  116.     ), !.
  117.  
  118. get_key_or_xevent (Key, XEvent) :-
  119.     %%  get a raw char or X event  %%
  120.     get_raw (Char, XEventFlag),
  121.     (
  122.       %%  if an X event, return  %%
  123.       XEventFlag, XEvent = true
  124.     ;
  125.       %%  if a prefix char, keep on reading %%
  126.       prefix_char (Char),
  127.       get_rest_of_key_or_xevent (Key, XEvent, prefix => [Char])
  128.     ;
  129.       %%  if a meta char, return ESC plus ordinary char
  130.       Char >= 128,
  131.       Key = [27, Char-128], XEvent = false
  132.     ;
  133.       %%  else, return the char
  134.       Key = Char, XEvent = false
  135.     ), !.
  136.  
  137.  
  138. get_rest_of_key_or_xevent (Key, XEvent, prefix => Prefix) :-
  139.     %%  get a raw char or X event  %%
  140.     get_raw (Char, XEventFlag),
  141.     (
  142.       %%  if an X event, return  %%
  143.       XEventFlag, XEvent = true
  144.     ;
  145.       %%  if the character plus the previous prefix  %%
  146.       %%  together form a prefix, keep on reading    %%
  147.       prefix_key (NewPrefix : [Char|Prefix]),
  148.       get_rest_of_key_or_xevent (Key, XEvent, prefix => NewPrefix)
  149.     ;
  150.       %%  else, return  %%
  151.       Key = reverse(NewPrefix), XEvent = false
  152.     ), !.
  153.  
  154.  
  155.  
  156.  
  157. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  158. %
  159. %            Action Routines
  160. %
  161. % eval_line: 
  162. %
  163. % parse_line: 
  164. %
  165. % sh_query:
  166. %
  167. % declaration:
  168. %
  169. % error:
  170. %
  171. % goto_previous_level:
  172. %
  173. % goto_top_level:
  174. %
  175. % backtrack: 
  176. %
  177. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  178.  
  179.  
  180. eval_line (Level) :-
  181.     %%  if the line is empty, go to the previous level          %%
  182.     %%  if the line is just a ".", go to the top level          %%
  183.     %%  if the line is just a ";", backtrack              %%
  184.     %%  otherwise, it's a proper line: add it to the history, %%
  185.     %%  increase the line number, and parse it.           %%
  186.     xeventflag :== false, !,
  187.     Line = current_line,
  188.     (
  189.       is_empty (Line), !,
  190.       goto_previous_level (Level)
  191.     ;
  192.       is_dot (Line), !,
  193.       goto_top_level (Level)
  194.     ;
  195.       is_semicolon (Line), !,
  196.       backtrack (Level)
  197.     ;
  198.       add_to_history (Line),
  199.       setq (current_line_number, current_line_number+1),
  200.       parse_line (Level, reverse(Line))
  201.     ).
  202.  
  203.  
  204. eval_line (Level : @(level => N)) :-
  205.     %%  an X event occurred: reset the X event flag,          %%
  206.     %%  reset the window flag if a new window was created,    %%
  207.     %%  increase the current level, and succeed.              %%
  208.     setq (xeventflag, false),
  209.     cond (window_flag, (reset_window_flag, N <- N + 1)),
  210.     nl, write("**** Yes"), nl,
  211.     print_vars (Level).
  212.  
  213.  
  214.  
  215.  
  216. parse_line (Level, Line) :-
  217.     CP1 = get_choice,
  218.     first_shell_parse (Line, NewVars, Exp, TypeOfExp, ExistVars),
  219.     TypeOfExp & @(Exp, CP1, NewVars, ExistVars, Level).    
  220.  
  221. parse_line (Level) :-
  222.     print_vars (Level).
  223.  
  224.  
  225.  
  226. sh_query (Query, CP1, NewVars, ExistVars,
  227.        Level : @(level => N, cp_stack => CPStack, vars => OldVars))
  228.     :-
  229.     retract ((shell_query :- @ )),
  230.     assert ((shell_query(NewVars, TraceStatus, StepStatus) :-
  231.                    trace (trace_status, step_status),
  232.                Query,
  233.                trace (TraceStatus, StepStatus),
  234.            trace (false, false))),
  235.     ( 
  236.     CPTemp = get_choice,
  237.         shell_query (OldVars, NewTraceStatus, NewStepStatus),
  238.         setq (trace_status, NewTraceStatus),
  239.         setq (step_status, NewStepStatus),    
  240.         ExistsCP = exists_choice (CPTemp, CP2:get_choice),
  241.         cond (WindowCreated:window_flag, reset_window_flag),
  242.         CopyCPStack = copy_pointer(CPStack), %% this is to avoid a bug in cond
  243.         cond (ExistVars or ExistsCP or WindowCreated,
  244.                (N <- N + 1,
  245.             CPStack <- [(CP1,CP2)|CopyCPStack]),
  246.            (set_choice(CP1),nl, write("**** Yes"), nl, fail) ),
  247.         nl, write("**** Yes"), nl,
  248.         print_vars (Level)
  249.     ;
  250.     trace (NewTraceStatus, NewStepStatus),
  251.     trace(false,false), 
  252.     setq (trace_status, NewTraceStatus),
  253.         setq (step_status, NewStepStatus),
  254.     fail
  255.     ).
  256.  
  257. sh_query (Query, CP1) :-
  258.     nl, write("**** No"), nl,
  259.     set_choice(CP1),
  260.     fail.
  261.  
  262.  
  263. declaration (Declaration, CP1) :-
  264.     (
  265.         term_xpand(Declaration,NewDefs),!,
  266.         (
  267.         cond( NewDefs :=< list,
  268.               maprel(assert, NewDefs),
  269.               assert(NewDefs)),
  270.         !, nl, write("**** Yes"), nl
  271.         ;
  272.         succeed
  273.         )
  274.         ;
  275.         nl, write("**** Error in term expansion "),
  276.         nl, write("**** No"), nl
  277.     ),
  278.     set_choice(CP1),
  279.     fail.
  280.  
  281.  
  282.  
  283. error (_, CP1) :-
  284.     write_parse_error,
  285.     set_choice(CP1),
  286.     fail.
  287.  
  288.  
  289.  
  290. goto_previous_level (@(level => 0)) :- !.
  291.     %%  if at the top level, do nothing  %%
  292.  
  293. goto_previous_level (@(cp_stack => [(CP1,_)|_])) :- 
  294.     %%  otherwise, abandon the current query and fail back  %%
  295.     %%  to the choice point before the query was parsed     %%
  296.     nl, write("**** No"), nl,
  297.     set_choice(CP1),
  298.     fail.
  299.  
  300.  
  301.  
  302. goto_top_level (@(level => 0)) :- !.
  303.     %%  if already at the top level, do nothing %%
  304.  
  305. goto_top_level (@(cp_stack => CPStack)) :-
  306.     %%  otherwise, fail back to the first choice point  %%
  307.     %%  in the user choice point stack                %%
  308.     (CP1,_) = last(CPStack),
  309.     set_choice(CP1),
  310.     fail.
  311.  
  312.  
  313.  
  314. backtrack (@(level => 0)) :- !.
  315.     %%  if at the top level, do nothing  %%
  316.  
  317. backtrack (@(cp_stack => [(_,CP2)|_])) :-
  318.     %%  otherwise, fail back to the most recent choice point  %%
  319.     %%  in the user choice point stack, that is, the choice   %%
  320.     %%  point after the last query was executed              %%
  321.     set_choice(CP2),
  322.     trace(trace_status,step_status),
  323.     fail.
  324.  
  325.  
  326.  
  327. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  328. %
  329. %            Editing Routines
  330. %
  331. % Inserting text:
  332. %    self_insert_command
  333. %
  334. % Changing the location of point:
  335. %    beginning_of_line, end_of_line,
  336. %    forward_char, backward_char,
  337. %    forward_word, backward_word,
  338. %    next_line, previous_line,        
  339. %    beginning_of_history, end_of_history,
  340. %    transpose_chars
  341. %
  342. % Erasing text:
  343. %    delete_backward_char, delete_char,
  344. %    kill_line, kill_entire_line,
  345. %    kill_word, backward_kill_word
  346. %
  347. % Miscellaneous:
  348. %    rewrite_line,
  349. %    describe_key_briefly,
  350. %    interrupt, quit,
  351. %    undefined_key, ignore_key, bad_key
  352. %
  353. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  354.  
  355.  
  356.  
  357. %%                                %%
  358. %%        Insert character at the point            %%
  359. %%                                %%
  360.  
  361. self_insert_command ( @(left => Left, right => Right), self => Key ) :-
  362.     put_chars ([Char:last(Key) | Right]),
  363.     backspace_over (Right),
  364.     Left <- [Char | copy_pointer(Left)].
  365.  
  366.  
  367.  
  368.  
  369. %%                                %%
  370. %%        Move to the beginning of the line        %%
  371. %%                                 %%
  372.  
  373. beginning_of_line ( @(left => []) ) :- !.
  374.  
  375. beginning_of_line ( @(left => Left, right => Right, prompt => Prompt) ) :-
  376.     carriage_return,
  377.     write (Prompt),
  378.     Right <- join (Left, copy_pointer(Right)), 
  379.     Left  <- [].
  380.  
  381.  
  382.  
  383. %%                                %%
  384. %%        Move to the end of the line            %%
  385. %%                                %%
  386.  
  387. end_of_line ( @(right => []) ) :- !.
  388.  
  389. end_of_line ( @(left  => Left, right => Right) ) :-
  390.     put_chars (Right),
  391.     Left  <- join (Right, copy_pointer(Left)),
  392.     Right <- [].
  393.  
  394.  
  395.  
  396. %%                                %%
  397. %%        Move forward one character            %%
  398. %%                                %%
  399.  
  400. forward_char ( @(right => []) ) :- !.
  401.  
  402. forward_char ( @(left  => Left, right => Right:[Char|NewRight]) ) :-
  403.     put_chars (Char),
  404.     Left  <- [Char | copy_pointer(Left)],
  405.     Right <- NewRight.
  406.  
  407.  
  408.  
  409. %%                                %%
  410. %%        Move backward one character            %%
  411. %%                                %%
  412.  
  413. backward_char ( @(left => []) ) :- !.
  414.  
  415. backward_char ( @(left  => Left:[Char|NewLeft], right => Right ) ) :-
  416.     backspace,
  417.     Left  <- NewLeft,
  418.     Right <- [Char | copy_pointer(Right)].
  419.  
  420.  
  421.  
  422. %%                                %%
  423. %%        Move forward one word                %%
  424. %%                                %%
  425.  
  426. forward_word ( @(right => []) ) :- !.
  427.  
  428. forward_word ( Line : @(left => Left, right => Right) ) :-
  429.     find_word_right (copy_pointer(Right), copy_pointer(Left), Line).
  430.  
  431.  
  432. find_word_right ([], Left, Line) :-
  433.     !, find_end_of_word ([], Left, Line).
  434.  
  435. find_word_right ([Char|Right], Left, Line) :-
  436.     alphanumeric (Char), !,
  437.     put_chars (Char),
  438.     find_end_of_word (Right, [Char|Left], Line). 
  439.  
  440. find_word_right ([Char|Right], Left, Line) :-
  441.     put_chars (Char),
  442.     find_word_right (Right, [Char|Left], Line).
  443.  
  444.  
  445. find_end_of_word ([Char|Right], Left, Line) :-
  446.     alphanumeric (Char), !,
  447.     put_chars (Char),
  448.     find_end_of_word (Right, [Char|Left], Line).
  449.  
  450. find_end_of_word (NewRight, NewLeft, @(left => Left, right => Right)) :-
  451.     Left  <- NewLeft,
  452.     Right <- NewRight.
  453.  
  454.  
  455.  
  456. %%                                %%
  457. %%        Move backward one word                %%
  458. %%                                %%
  459.  
  460. backward_word ( @(left => []) ) :- !.
  461.  
  462. backward_word ( Line : @(left => Left, right => Right) ) :-
  463.     find_word_left (copy_pointer(Left), copy_pointer(Right), Line).
  464.  
  465.  
  466. find_word_left ([], Right, Line) :-
  467.     !, find_start_of_word ([], Right, Line).
  468.  
  469. find_word_left ([Char|Left], Right, Line) :-
  470.     alphanumeric (Char), !,
  471.     backspace,
  472.     find_start_of_word (Left, [Char|Right], Line). 
  473.  
  474. find_word_left ([Char|Left], Right, Line) :-
  475.     backspace,
  476.     find_word_left (Left, [Char|Right], Line).
  477.  
  478.  
  479. find_start_of_word ([Char|Left], Right, Line) :-
  480.     alphanumeric (Char), !,
  481.     backspace,
  482.     find_start_of_word (Left, [Char|Right], Line).
  483.  
  484. find_start_of_word (NewLeft, NewRight, @(left => Left, right => Right)) :-
  485.     Left  <- NewLeft,
  486.     Right <- NewRight.
  487.  
  488.  
  489.  
  490. %%                                %%
  491. %%        Get the next line in the history list        %%
  492. %%                                %%
  493.  
  494. next_line (_, HistoryPtr) :-
  495.     HistoryPtr = current_line_number, !,
  496.     bell.
  497.  
  498. next_line ( Line : @(left => Left, right => Right), HistoryPtr ) :-
  499.     HistoryPtr + 1 = NewHistoryPtr:current_line_number, !,
  500.     clear_line (Line),
  501.     Left  <- [],
  502.     Right <- [],
  503.     HistoryPtr <- NewHistoryPtr.
  504.  
  505. next_line ( Line : @(left => Left, right => Right), HistoryPtr ) :-
  506.     NextLine = str2psi (strcon
  507.          ("line", int2str(NewHistoryPtr:(HistoryPtr+1)))),
  508.     ReversedChars = eval(NextLine),
  509.     clear_line (Line),
  510.     put_chars (reverse(ReversedChars)),
  511.     Left  <- ReversedChars,
  512.     Right <- [],
  513.     HistoryPtr <- NewHistoryPtr.
  514.  
  515.  
  516.  
  517. %%                                %%
  518. %%    Get the previous line in the history list        %%
  519. %%                                %%
  520.  
  521. previous_line (_, HistoryPtr) :-
  522.     HistoryPtr - 1  <  max (1, current_line_number - history_limit), !,
  523.     bell.
  524.  
  525. previous_line ( Line : @(left => Left, right => Right), HistoryPtr ) :-
  526.     PreviousLine = str2psi (strcon
  527.           ("line", int2str(NewHistoryPtr:(HistoryPtr-1)))),
  528.     ReversedChars = eval(PreviousLine),
  529.     clear_line (Line),
  530.     put_chars (reverse(ReversedChars)),
  531.     Left  <- ReversedChars,
  532.     Right <- [],
  533.     HistoryPtr <- NewHistoryPtr.
  534.  
  535.  
  536.  
  537. %%                                %%
  538. %%    Get the first line in the history list            %%
  539. %%                                %%
  540.  
  541. beginning_of_history :-
  542.     current_line_number = 1, !,
  543.     bell.
  544.  
  545. beginning_of_history ( Line : @(left => Left, right  => Right), HistoryPtr ) :-
  546.     NewHistoryPtr = max (1, current_line_number - history_limit), 
  547.     FirstLine = str2psi (strcon ("line", int2str(NewHistoryPtr))),
  548.     ReversedChars = eval(FirstLine),
  549.     clear_line (Line),
  550.     put_chars (reverse(ReversedChars)),
  551.     Left  <- ReversedChars,
  552.     Right <- [],
  553.     HistoryPtr <- NewHistoryPtr.
  554.  
  555.  
  556.  
  557. %%                                %%
  558. %%        Get the last line in the history list        %%
  559. %%                                %%
  560.  
  561. end_of_history :-
  562.     current_line_number = 1, !, bell.
  563.  
  564. end_of_history ( Line : @(left => Left, right  => Right, HistoryPtr) ) :-
  565.     LastLine = str2psi (strcon
  566.           ("line", int2str(NewHistoryPtr:current_line_number-1))),
  567.     ReversedChars = eval(LastLine),
  568.     clear_line (Line),
  569.     put_chars (reverse(ReversedChars)),
  570.     Left  <- ReversedChars,
  571.     Right <- [],
  572.     HistoryPtr <- NewHistoryPtr.
  573.  
  574.  
  575.  
  576. %%                                %%
  577. %%    Transpose the two characters before and at the point    %%
  578. %%                                %%
  579.  
  580. transpose_chars ( @(left => []) ) :-
  581.     !.
  582.  
  583. transpose_chars ( @(right => []) ) :-
  584.     !.
  585.  
  586. transpose_chars ( @(left  => Left : [Char1|NewLeft],
  587.                     right => Right : [Char2|NewRight]) ) :-
  588.     backspace,
  589.     put_chars (Char2),
  590.     put_chars (Char1),
  591.     Left  <- [ Char1, Char2 | NewLeft ],
  592.     Right <- NewRight.
  593.  
  594.  
  595.  
  596. %%                                %%
  597. %%        Delete the character before the point        %%
  598. %%                                %%
  599.  
  600. delete_backward_char ( @(left => []) ) :- !.
  601.  
  602. delete_backward_char ( @(left => Left:[_|NewLeft], right => Right) ) :-
  603.     backspace,
  604.     put_chars (Right),
  605.     space,
  606.     backspace,
  607.     backspace_over (Right),
  608.     Left  <- NewLeft.
  609.  
  610.  
  611.  
  612. %%                                %%
  613. %%        Delete the character at the point        %%
  614. %%                                %%
  615.  
  616. delete_char ( @(right => []) ) :- !.
  617.  
  618. delete_char ( @(right => Right:[_|NewRight]) ) :-
  619.     put_chars (NewRight),
  620.     space,
  621.     backspace,
  622.     backspace_over (NewRight),
  623.     Right <- NewRight.
  624.  
  625.  
  626.  
  627. %%                                %%
  628. %%        Kill to the end of the line            %%
  629. %%                                %%
  630.  
  631. kill_line ( @(right => []) ) :- !.
  632.  
  633. kill_line ( @(right => Right) ) :-
  634.     blank_out (Right),
  635.     backspace_over (Right),
  636.     Right <- [].
  637.  
  638.  
  639.  
  640. %%                                %%
  641. %%    Kill the entire line both before and after the point    %%
  642. %%                                %%
  643.  
  644. kill_entire_line ( @(left => [], right => []) ) :- !.
  645.  
  646. kill_entire_line ( Line : @(left => Left, right  => Right) ) :-
  647.     clear_line (Line),
  648.     Left  <- [],
  649.     Right <- [].
  650.  
  651.  
  652.  
  653. %%                                %%
  654. %%    Kill forward to the end of the next word        %%
  655. %%                                %%
  656.  
  657. kill_word ( @(right => []) ) :- !.
  658.  
  659. kill_word ( Line : @(right => Right) ) :-
  660.     kill_word_right (copy_pointer(Right), Line).
  661.  
  662.  
  663. kill_word_right ([], Line) :-
  664.     !, kill_to_end_of_word ([], Line).
  665.  
  666. kill_word_right ([Char|Right], Line) :-
  667.     alphanumeric (Char), !,
  668.     kill_to_end_of_word (Right, Line). 
  669.  
  670. kill_word_right ([_|Right], Line) :-
  671.     kill_word_right (Right, Line).
  672.  
  673.  
  674. kill_to_end_of_word ([Char|Right], Line) :-
  675.     alphanumeric (Char), !,
  676.     kill_to_end_of_word (Right, Line).
  677.  
  678. kill_to_end_of_word (NewRight, Line : @(right => Right)) :-
  679.     overwrite (Right, NewRight),
  680.     backspace_over (NewRight),
  681.     Right <- NewRight.
  682.  
  683.  
  684.  
  685. %%                                %%
  686. %%    Kill back to the beginning of the previous word        %%
  687. %%                                %%
  688.  
  689. backward_kill_word ( @(left => []) ) :- !.
  690.  
  691. backward_kill_word ( Line : @(left => Left, right => Right) ) :-
  692.     kill_word_left (copy_pointer(Left), copy_pointer(Right), Line).
  693.  
  694.  
  695. kill_word_left ([], OldRight, Line) :-
  696.     !, kill_to_start_of_word ([], OldRight, Line).
  697.  
  698. kill_word_left ([Char|Left], OldRight, Line) :-
  699.     alphanumeric (Char), !,
  700.     backspace,
  701.     kill_to_start_of_word (Left, [Char|OldRight], Line). 
  702.  
  703. kill_word_left ([Char|Left], OldRight, Line) :-
  704.     backspace,
  705.     kill_word_left (Left, [Char|OldRight], Line).
  706.  
  707.  
  708. kill_to_start_of_word ([Char|Left], OldRight, Line) :-
  709.     alphanumeric (Char), !,
  710.     backspace,
  711.     kill_to_start_of_word (Left, [Char|OldRight], Line).
  712.  
  713. kill_to_start_of_word (NewLeft, OldRight, @(left => Left, right => Right)) :-
  714.     overwrite (OldRight, Right),
  715.     backspace_over (Right),
  716.     Left <- NewLeft.
  717.  
  718.  
  719.  
  720. %%                                %%
  721. %%    Rewrite the line                    %%
  722. %%    (useful after unwelcome garbage collection messages!)    %%
  723. %%                                %%
  724.  
  725. rewrite_line ( @(left => Left, right => Right, prompt => Prompt) ) :-
  726.     carriage_return,
  727.     write (Prompt),
  728.     put_chars (join(Left,Right)),
  729.     backspace_over (Right).
  730.  
  731.  
  732.  
  733. %%                                %%
  734. %%    Give a brief description of the next key        %%
  735. %%                                %%
  736.  
  737. describe_key_briefly (Line) :-
  738.     get_key_or_xevent (Key, XEvent),
  739.     (
  740.       XEvent, nl, setq(xeventflag, true)
  741.     ;
  742.       get_function_bound_to_key (Key, global_map, Function),
  743.        (
  744.          Function = undefined_key,
  745.          undefined_key (Line, self => Key)
  746.        ;
  747.          Function = ignore_key,
  748.          nl, write (key2name(Key), " is ignored in line edit mode"), nl,
  749.          rewrite_line (Line)
  750.        ;
  751.          nl, write (key2name(Key), " runs the command ", Function), nl,
  752.          rewrite_line (Line)
  753.        )
  754.     ), !.
  755.  
  756.  
  757.  
  758. %%                                %%
  759. %%    Leave the shell and return to Wild_LIFE            %%
  760. %%                                %%
  761.  
  762. interrupt :- cond (in_raw, end_raw),
  763.     setq (aborthook, abort),
  764.     abort.
  765.  
  766.  
  767.  
  768. %%                                %%
  769. %%    Leave the shell and Wild_LIFE, after writing the history%%
  770. %%                                %%
  771.  
  772. quit :-    cond (in_raw, end_raw),
  773.     write_history,
  774.     halt.
  775.  
  776.  
  777.  
  778. %%                                %%
  779. %%    Output error message if undefined key has been typed    %%
  780. %%                                %%
  781.  
  782. undefined_key (Line, self => Key) :-
  783.         nl, write (key2name(Key), " is not defined"), nl, bell,
  784.         rewrite_line (Line).
  785.  
  786.  
  787.  
  788. %%                                %%
  789. %%    Ignore the character.                    %%
  790. %%    Write an error message                    %%
  791. %%                                %%
  792.  
  793. ignore_key.
  794.  
  795. bad_key (self => Key) :-
  796.     nl, write("Oops! Got a bad key ", Key), nl.
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  804. %
  805. %            Keymaps and key bindings
  806. %
  807. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  808.  
  809. read_keymap_file :-
  810.     keymap_flag = false,
  811.     exists_file (F:".life-keymap"), !,
  812.     load (F),
  813.     write ("**** Read keymap file .life-keymap"), nl,
  814.     setq (keymap_flag, true).
  815.  
  816. read_keymap_file.
  817.  
  818.  
  819.  
  820. is_keymap (global_map).
  821. is_keymap (esc_map).
  822. is_keymap (esclsb_map).
  823. is_keymap (help_map).
  824.  
  825.  
  826.  
  827. global_set_key (Keyname, Function) :-
  828.     define_key (global_map, Keyname, Function).
  829.  
  830. define_key (Keymap, Keyname, Function) :-
  831.     is_keymap (Keymap), !,
  832.     [Key | _] = name2asc (Keyname),
  833.     KeymapEntry = str2psi (strcon (psi2str(Keymap), int2str(Key))),
  834.     dynamic (KeymapEntry),
  835.     setq (KeymapEntry, Function).
  836.  
  837. define_key (Keymap) :-
  838.     nl, write (Keymap," is not a known keymap"), nl.
  839.  
  840.  
  841.  
  842. get_function_bound_to_key (Char:int, Map, Function) :-
  843.     KeymapEntry = str2psi (strcon (psi2str(Map), int2str(Char))),
  844.     Func = eval (KeymapEntry),
  845.     (
  846.       is_defined (Func), Function = Func
  847.     ;
  848.       Function = undefined_key 
  849.     ), !.
  850.  
  851. get_function_bound_to_key ([], _, undefined_key) :- !.
  852.  
  853. get_function_bound_to_key ([Char|Rest], Map, Function) :-
  854.     KeymapEntry = str2psi (strcon (psi2str(Map), int2str(Char))),
  855.     Func = eval (KeymapEntry),
  856.     (
  857.       is_keymap (Func), get_function_bound_to_key (Rest, Func, Function)
  858.     ;
  859.       is_defined (Func), Function = Func
  860.     ;
  861.       Function = undefined_key 
  862.     ), !.
  863.  
  864.  
  865.  
  866.  
  867. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  868. %
  869. %        The history file
  870. %
  871. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  872.  
  873. read_history_file :-
  874.     history_flag = false,
  875.     exists_file (File : history_file), !,
  876.     open_in (File, Stream),
  877.     read_history_lines,
  878.     close (Stream),
  879.     write ("**** Read history file ", File), nl,
  880.     setq (history_flag, true).
  881.  
  882. read_history_file.
  883.  
  884.  
  885. read_history_lines :-
  886.     get_nonempty_line ([], ReversedChars), !,
  887.     add_to_history (ReversedChars),
  888.     setq (current_line_number, current_line_number+1),
  889.     read_history_lines.
  890. read_history_lines.
  891.  
  892. get_nonempty_line (ReversedChars,L) :-
  893.     get (Char),
  894.     cond (is_eol_char (Char),
  895.           get_nonempty_line ([],L),
  896.           cond (is_white_char (Char),
  897.          get_nonempty_line ([Char|ReversedChars], L),
  898.                 get_line ([Char|ReversedChars], L)
  899.                )
  900.          ).
  901.  
  902. get_line (ReversedChars,L) :-
  903.     get (Char),
  904.     cond (is_eol_char (Char),
  905.           L = ReversedChars,
  906.           get_line ([Char|ReversedChars], L)).
  907.  
  908. add_to_history (ReversedChars) :-
  909.     CurrentLine = str2psi (strcon ("line", int2str(current_line_number))),
  910.     setq (CurrentLine, ReversedChars).
  911.  
  912.  
  913.  
  914. write_history :-
  915.     CurrentLine:current_line_number > 1, !,
  916.     open_out (File : history_file, Stream),
  917.     StartOfHistory = max (1, CurrentLine - history_limit),
  918.     write_history_lines (StartOfHistory, CurrentLine),
  919.     close (Stream),
  920.     setq (history_flag, true),
  921.     write ("**** Wrote history list to file ", File), nl.
  922. write_history.
  923.  
  924. write_history_lines (N,N) :- !.
  925. write_history_lines (M,N) :-
  926.     LineM = str2psi (strcon ("line", int2str(M))),
  927.     ReversedChars = eval(LineM),
  928.     write (revchars2str(ReversedChars)),
  929.     nl,
  930.     write_history_lines (M+1,N).
  931.  
  932.  
  933.  
  934.  
  935. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  936. %
  937. %    Initializing routines and global setq variables
  938. %
  939. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  940.  
  941.  
  942. dynamic (history_limit, history_file) ?
  943.  
  944. dynamic (history_flag, keymap_flag, current_line_number, current_line,
  945.          line, history_ptr) ?
  946.  
  947.  
  948. non_strict (not_set) ?
  949. not_set (X) -> not (is_function(X)).
  950.  
  951.  
  952. initialize_variables :-
  953.     cond (not_set(history_limit),       `setq (history_limit, 100)),
  954.     cond (not_set(history_file),        `setq (history_file, ".life-history")),
  955.     cond (not_set(history_flag),        `setq (history_flag,  false)),
  956.     cond (not_set(keymap_flag),         `setq (keymap_flag,   false)),
  957.     cond (not_set(current_line_number), `setq (current_line_number, 1)),
  958.     setq (xeventflag, false),
  959.     setq (line, @),
  960.     setq (history_ptr, 1),
  961.     setq (trace_status, false),
  962.     setq (step_status, false),
  963.     setq (aborthook, shell2).
  964.  
  965. dynamic (shell_query) ?
  966. shell_query.
  967.  
  968.  
  969.  
  970. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  971. %
  972. %            Auxiliary routines
  973. %
  974. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  975.  
  976.  
  977. %%                                %%
  978. %%        Tests on single ascii codes            %%
  979. %%                                %%
  980.  
  981. return_key (10) :- !.
  982. return_key (13).
  983.  
  984. is_eol_char (10)          -> true.
  985. is_eol_char (end_of_file) -> true.
  986. is_eol_char (_)          -> false.
  987.  
  988. is_white_char (9)  -> true.
  989. is_white_char (32) -> true.
  990. is_white_char (_)  -> false.
  991.  
  992. alphanumeric (X) :- X >= 48, X =< 57, !.
  993. alphanumeric (X) :- X >= 65, X =< 90, !.
  994. alphanumeric (X) :- X >= 97, X =< 122.
  995.  
  996. ctl_char (X)    :- X < 32.
  997. single_char (X) :- X < 127.
  998. meta_char (X)   :- X > 127.
  999.  
  1000. prefix_char (27) :- !.
  1001. prefix_char (8).
  1002.  
  1003.  
  1004.  
  1005. %%                                %%
  1006. %%        Tests on lists of ascii codes            %%
  1007. %%                                %%
  1008.  
  1009. is_empty ([])      -> true.
  1010. is_empty ([9 |Xs]) -> is_empty (Xs).
  1011. is_empty ([32|Xs]) -> is_empty (Xs).
  1012. is_empty (_)       -> false.
  1013.  
  1014. is_dot ([9 |Xs]) -> is_dot (Xs).
  1015. is_dot ([32|Xs]) -> is_dot (Xs).
  1016. is_dot ([46|Xs]) -> is_empty (Xs).
  1017. is_dot (_)     -> false.
  1018.  
  1019. is_semicolon ([9 |Xs]) -> is_semicolon (Xs).
  1020. is_semicolon ([32|Xs]) -> is_semicolon (Xs).
  1021. is_semicolon ([59|Xs]) -> is_empty (Xs).
  1022. is_semicolon (_)       -> false.
  1023.  
  1024. prefix_key ([91,27]).
  1025.  
  1026.  
  1027.  
  1028.  
  1029. %    Convert a line to a list of reversed ascii codes
  1030.  
  1031.  
  1032. line2revchars (Line : @(left => Left, right => Right)) ->
  1033.     join (Right,Left).
  1034.  
  1035.  
  1036.  
  1037. %    Convert a list of ascii codes to a string
  1038.  
  1039.  
  1040. revchars2str (ReversedChars)       -> rc2s (ReversedChars,"").
  1041. rc2s ([], String)           -> String.
  1042. rc2s ([Char|ReversedChars], String) ->
  1043.     rc2s (ReversedChars, strcon (chr(Char), String)).
  1044.  
  1045.  
  1046. %    Convert a list of ascii codes to their names as a 
  1047. %      single string
  1048.  
  1049. key2name (X:int)    -> asc2name(X).
  1050. key2name ([])       -> "".
  1051. key2name ([X])      -> asc2name(X).
  1052. key2name ([X|Rest]) -> strcon (strcon(asc2name(X), " "), key2name(Rest)).
  1053.  
  1054. asc2name (0)   -> "NUL".
  1055. asc2name (9)   -> "TAB".
  1056. asc2name (10)  -> "RET".
  1057. asc2name (13)  -> "RET".
  1058. asc2name (27)  -> "ESC".
  1059. asc2name (32)  -> "SPC".
  1060. asc2name (127) -> "DEL".
  1061. asc2name (X)   ->
  1062.     cond (X < 26,
  1063.         strcon ("C-", asc2name(X+96)),
  1064.         cond (X < 32,
  1065.             strcon ("C-", asc2name(X+64)),
  1066.             cond (X > 127,
  1067.                 strcon ("ESC ", asc2name(X-128)), chr(X)))).
  1068.  
  1069.  
  1070.  
  1071. %    Convert ascii code names to the corresponding codes
  1072.  
  1073. name2asc (Name) -> n2a (explode(Name)).
  1074.  
  1075. n2a ([])              -> [].
  1076. n2a (["\" | Rest])    -> bs_seq2asc(Rest).
  1077. n2a ([Letter | Rest]) -> [asc(Letter) | n2a(Rest)].
  1078.  
  1079. bs_seq2asc (["b" | Rest])         -> [8 | n2a(Rest)].
  1080. bs_seq2asc (["t" | Rest])         -> [9 | n2a(Rest)].
  1081. bs_seq2asc (["n" | Rest])         -> [10 | n2a(Rest)].
  1082. bs_seq2asc (["f" | Rest])         -> [12 | n2a(Rest)].
  1083. bs_seq2asc (["r" | Rest])         -> [13 | n2a(Rest)].
  1084. bs_seq2asc (["\" | Rest])      -> [92 | n2a(Rest)].
  1085. bs_seq2asc (["e" | Rest])         -> esc2asc(Rest).
  1086. bs_seq2asc (["C" | ["-" | Rest]]) -> ctl2asc(Rest).
  1087. bs_seq2asc (["M" | ["-" | Rest]]) -> meta2asc(Rest).
  1088. bs_seq2asc (Rest)          -> [92 | n2a(Rest)].
  1089.  
  1090. ctl2asc ([Letter | Rest]) ->
  1091.     cond (64 < A:asc(Letter) and A < 96,
  1092.         [A-64 | n2a(Rest)],
  1093.         cond (95 < A and A < 123,
  1094.             [A-96 | n2a(Rest)],
  1095.             n2a(Rest))).        
  1096.  
  1097.  
  1098.  
  1099.  
  1100. %    The prompt
  1101.  
  1102.  
  1103. prompt (0) -> ">> ".
  1104. prompt (N) -> strcon (strcon (dashes(N), int2str(N)), ">> ").
  1105.  
  1106. dashes (0) -> "".
  1107. dashes (N) -> strcon (dashes(N-1), "--").
  1108.  
  1109.  
  1110.  
  1111. %    Output routines
  1112.  
  1113.  
  1114. bell        :- put_raw (7).
  1115. backspace    :- put_raw (8).
  1116. carriage_return :- put_raw (13).
  1117. space        :- put_raw (32).
  1118.  
  1119.  
  1120. put_chars (X:int) :-
  1121.     !, cond (X =:= 9, put_raw (32), put_raw(X)).
  1122. put_chars ([]) :-
  1123.     !.
  1124. put_chars ([X|T]) :-
  1125.     cond (X =:= 9, put_raw (32), put_raw(X)),
  1126.     put_chars (T).
  1127.  
  1128.     
  1129. blank_out ([]) :- !.
  1130. blank_out ([_|T]) :-
  1131.     put_raw (32),
  1132.     blank_out (T).
  1133.  
  1134.  
  1135. backspace_over ([]) :- !.
  1136. backspace_over ([_|T]) :-
  1137.     put_raw (8),
  1138.     backspace_over (T).
  1139.  
  1140.  
  1141. clear_line ( @(left => Left, right => Right, prompt => Prompt) ) :-
  1142.     backspace_over (Left),
  1143.     blank_out (Left),
  1144.     blank_out (Right),
  1145.     carriage_return,
  1146.     write (Prompt).
  1147.  
  1148.  
  1149. overwrite ([],L) :-
  1150.     !, put_chars (L).
  1151. overwrite (L:[_|_],[]) :-
  1152.     !, blank_out (L), backspace_over (L).
  1153. overwrite ([_|T1],[H|T2]) :-
  1154.     put_chars (H), overwrite (T1,T2).
  1155.  
  1156.  
  1157.  
  1158. %    Miscellaneous
  1159.  
  1160.  
  1161. last (X:int) -> X.
  1162. last ([X])   -> X.
  1163. last ([_|L]) -> last(L).
  1164.  
  1165. join ([], Ys)     -> Ys.
  1166. join ([X|Xs], Ys) -> join (Xs, [X|Ys]).
  1167.  
  1168. non_strict (is_defined)?
  1169. is_defined (X) :- is_function(X) or is_predicate(X).
  1170.  
  1171. reverse ([])     -> [].
  1172. reverse (L:list) -> rev (L,acc => []).
  1173.  
  1174. rev ([],    acc => L:list) -> L.
  1175. rev ([H|T], acc => L:list) -> rev (T,acc => [H|L]).
  1176.  
  1177. explode (S:string) -> expl (S,strlen(S)).
  1178.  
  1179. expl ("",int) -> [].
  1180. expl (S,L)    -> [substr(S,1,1) | expl(substr(S,2,L1:(L-1)),L1)].
  1181.  
  1182.  
  1183.  
  1184. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1185. %
  1186. %            Default Key Bindings
  1187. %
  1188. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1189.  
  1190.  
  1191. global_map0    -> bad_key.            %% C-` (NUL)
  1192. global_map1    -> beginning_of_line.        %% C-a
  1193. global_map2    -> backward_char.        %% C-b
  1194. global_map3    -> ignore_key.            %% C-c
  1195. global_map4    -> delete_char.            %% C-d
  1196. global_map5    -> end_of_line.            %% C-e
  1197. global_map6    -> forward_char.        %% C-f
  1198. global_map7    -> undefined_key.        %% C-g
  1199. global_map8    -> help_map.            %% C-h
  1200. global_map9    -> self_insert_command.        %% C-i (TAB)
  1201. global_map10    -> eval_line.            %% C-j (LF)
  1202. global_map11    -> kill_line.            %% C-k
  1203. global_map12    -> rewrite_line.        %% C-l
  1204. global_map13    -> eval_line.            %% C-m (CR)
  1205. global_map14    -> next_line.            %% C-n
  1206. global_map15    -> undefined_key.        %% C-o
  1207. global_map16    -> previous_line.        %% C-p
  1208. global_map17    -> undefined_key.        %% C-q
  1209. global_map18    -> undefined_key.        %% C-r
  1210. global_map19    -> undefined_key.        %% C-s
  1211. global_map20    -> transpose_chars.        %% C-t
  1212. global_map21    -> undefined_key.        %% C-u
  1213. global_map22    -> undefined_key.        %% C-v
  1214. global_map23    -> kill_entire_line.        %% C-w
  1215. global_map24    -> undefined_key.        %% C-x
  1216. global_map25    -> undefined_key.        %% C-y
  1217. global_map26    -> undefined_key.        %% C-z
  1218. global_map27    -> esc_map.            %% C-[ (ESC)
  1219. global_map28    -> undefined_key.        %% C-\ (not caught)
  1220. global_map29    -> undefined_key.        %% C-]
  1221. global_map30    -> undefined_key.        %% C-^
  1222. global_map31    -> undefined_key.        %% C-_
  1223. global_map32    -> self_insert_command.        %% SPC
  1224. global_map33    -> self_insert_command.        %% !
  1225. global_map34    -> self_insert_command.        %% "
  1226. global_map35    -> self_insert_command.        %% #
  1227. global_map36    -> self_insert_command.        %% $
  1228. global_map37    -> self_insert_command.        %% %
  1229. global_map38    -> self_insert_command.        %% &
  1230. global_map39    -> self_insert_command.        %% '
  1231. global_map40    -> self_insert_command.        %% (
  1232. global_map41    -> self_insert_command.        %% )
  1233. global_map42    -> self_insert_command.        %% *
  1234. global_map43    -> self_insert_command.        %% +
  1235. global_map44    -> self_insert_command.        %% ,
  1236. global_map45    -> self_insert_command.        %% -
  1237. global_map46    -> self_insert_command.        %% .
  1238. global_map47    -> self_insert_command.        %% /
  1239. global_map48    -> self_insert_command.        %% 0
  1240. global_map49    -> self_insert_command.        %% 1
  1241. global_map50    -> self_insert_command.        %% 2
  1242. global_map51    -> self_insert_command.        %% 3
  1243. global_map52    -> self_insert_command.        %% 4
  1244. global_map53    -> self_insert_command.        %% 5
  1245. global_map54    -> self_insert_command.        %% 6
  1246. global_map55    -> self_insert_command.        %% 7
  1247. global_map56    -> self_insert_command.        %% 8
  1248. global_map57    -> self_insert_command.        %% 9
  1249. global_map58    -> self_insert_command.        %% :
  1250. global_map59    -> self_insert_command.        %% ;
  1251. global_map60    -> self_insert_command.        %% <
  1252. global_map61    -> self_insert_command.        %% =
  1253. global_map62    -> self_insert_command.        %% >
  1254. global_map63    -> self_insert_command.        %% ?
  1255. global_map64    -> self_insert_command.        %% @
  1256. global_map65     -> self_insert_command.        %% A
  1257. global_map66    -> self_insert_command.        %% B
  1258. global_map67    -> self_insert_command.        %% C
  1259. global_map68    -> self_insert_command.        %% D
  1260. global_map69    -> self_insert_command.        %% E
  1261. global_map70    -> self_insert_command.        %% F
  1262. global_map71    -> self_insert_command.        %% G
  1263. global_map72    -> self_insert_command.        %% H
  1264. global_map73    -> self_insert_command.        %% I
  1265. global_map74    -> self_insert_command.        %% J
  1266. global_map75    -> self_insert_command.        %% K
  1267. global_map76    -> self_insert_command.        %% L
  1268. global_map77    -> self_insert_command.        %% M
  1269. global_map78    -> self_insert_command.        %% N
  1270. global_map79    -> self_insert_command.        %% O
  1271. global_map80    -> self_insert_command.        %% P
  1272. global_map81    -> self_insert_command.        %% Q
  1273. global_map82    -> self_insert_command.        %% R
  1274. global_map83    -> self_insert_command.        %% S
  1275. global_map84    -> self_insert_command.        %% T
  1276. global_map85    -> self_insert_command.        %% U
  1277. global_map86    -> self_insert_command.        %% V
  1278. global_map87    -> self_insert_command.        %% W
  1279. global_map88    -> self_insert_command.        %% X
  1280. global_map89    -> self_insert_command.        %% Y
  1281. global_map90    -> self_insert_command.        %% Z
  1282. global_map91    -> self_insert_command.        %% [
  1283. global_map92    -> self_insert_command.        %% \
  1284. global_map93    -> self_insert_command.        %% ]
  1285. global_map94    -> self_insert_command.        %% ^
  1286. global_map95    -> self_insert_command.        %% _
  1287. global_map96    -> self_insert_command.        %% `
  1288. global_map97    -> self_insert_command.        %% a
  1289. global_map98    -> self_insert_command.        %% b
  1290. global_map99    -> self_insert_command.        %% c
  1291. global_map100    -> self_insert_command.        %% d
  1292. global_map101    -> self_insert_command.        %% e
  1293. global_map102    -> self_insert_command.        %% f
  1294. global_map103    -> self_insert_command.        %% g
  1295. global_map104    -> self_insert_command.        %% h
  1296. global_map105    -> self_insert_command.        %% i
  1297. global_map106    -> self_insert_command.        %% j
  1298. global_map107    -> self_insert_command.        %% k
  1299. global_map108    -> self_insert_command.        %% l
  1300. global_map109    -> self_insert_command.        %% m
  1301. global_map110    -> self_insert_command.        %% n
  1302. global_map111    -> self_insert_command.        %% o
  1303. global_map112    -> self_insert_command.        %% p
  1304. global_map113    -> self_insert_command.        %% q
  1305. global_map114    -> self_insert_command.        %% r
  1306. global_map115    -> self_insert_command.        %% s
  1307. global_map116    -> self_insert_command.        %% t
  1308. global_map117    -> self_insert_command.        %% u
  1309. global_map118    -> self_insert_command.        %% v
  1310. global_map119    -> self_insert_command.        %% w
  1311. global_map120    -> self_insert_command.        %% x
  1312. global_map121    -> self_insert_command.        %% y
  1313. global_map122    -> self_insert_command.        %% z
  1314. global_map123    -> self_insert_command.        %% {
  1315. global_map124    -> self_insert_command.        %% |
  1316. global_map125    -> self_insert_command.        %% }
  1317. global_map126    -> self_insert_command.        %% ~
  1318. global_map127    -> delete_backward_char.    %% DEL
  1319.  
  1320.  
  1321. esc_map60    -> beginning_of_history.    %% ESC <
  1322. esc_map62    -> end_of_history.        %% ESC >
  1323. esc_map66    -> backward_word.        %% ESC B
  1324. esc_map68    -> kill_word.            %% ESC D
  1325. esc_map70    -> forward_word.        %% ESC F
  1326. esc_map91    -> esclsb_map.            %% ESC [
  1327. esc_map98    -> backward_word.        %% ESC b
  1328. esc_map100    -> kill_word.            %% ESC d
  1329. esc_map102    -> forward_word.        %% ESC f
  1330. esc_map127    -> backward_kill_word.        %% ESC DEL
  1331.  
  1332.  
  1333. esclsb_map65    -> previous_line.        %% ESC [ A (up arrow)
  1334. esclsb_map66    -> next_line.            %% ESC [ B (down arrow)
  1335. esclsb_map67    -> forward_char.        %% ESC [ C (right arrow)
  1336. esclsb_map68    -> backward_char.        %% ESC [ D (left arrow)
  1337.  
  1338.  
  1339. help_map67    -> describe_key_briefly.
  1340. help_map99    -> describe_key_briefly.
  1341.  
  1342.  
  1343. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1344. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1345.  
  1346. %%% return to user module
  1347.  
  1348.  
  1349. module("user") ?
  1350. open("shell") ?
  1351. open("accumulators") ?
  1352.