Lugaru's Epsilon
Programmer's
Editor 14.04

Context:
Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      . . .
      Operating System Primitives
         System Primitives
         Window System Primitives
         Timing
         Calling Windows DLLs
         Running a Process
      Control Primitives
         . . .
         Buffer-specific Variables
         Bytecode Files
         Starting and Finishing
         EEL Debugging and Profiling
         Help Subroutines
      Input Primitives
         Keys
         The Mouse
         Window Events
         . . .
         Binding Primitives
      . . .

Previous   Up    Next
Bytecode Files  Primitives and EEL Subroutines   EEL Debugging and Profiling


Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Control Primitives >

Starting and Finishing

do_save_state(char *file)
int save_state(char *file)

The do_save_state( ) subroutine writes the current state to the specified file. It aborts with an error message if it encounters a problem. It uses the save_state( ) primitive to actually write the state. The primitive returns 0 if the information was written successfully, or an error code if there was a problem (as with file_write( )). Both change the extension to ".sta" before using the supplied name.

The state includes all commands, subroutines, keyboard macros, and variables. It does not include buffers or windows. Since a state file can only be read while Epsilon is starting (when there are no buffers or windows), only the default value of each buffer-specific or window-specific variable is saved in a state file.

Pointer variables will have a value of zero when the state file is loaded again. Epsilon does not save the object that is pointed to. Spot variables and structures or unions containing pointers or spots are also zeroed, but other types of variables are retrieved unchanged (but see the description of the zeroed keyword in Global Definitions).

short argc;
char *argv[ ];

When Epsilon starts, it examines the arguments on its command line, and modifies its behavior if it recognizes certain special flags. But first it adds in the contents of the configuration variable EPSILON, if this exists, putting this before any actual command line parameters.

Epsilon looks for certain special flags, interprets them and removes them from the command line. It then passes the remainder of the command line to the EEL startup code in cmdline.e. That code interprets any remaining flags and files on the command line. You can add new flags to Epsilon by modifying cmdline.e. See Epsilon Command Line Flags for the meaning of each of Epsilon's flags.

Epsilon interprets and removes these flags from the command line:

 -k  Keyboard options  -m  Memory control
 -s  Load from state file  -w  Directory options
 -b  Load from bytecode file  -v  Video options

Some of these settings are visible to an EEL program through variables. See the load-from-state variable for the -b flag, the state_file variable for the -s flag, the want-cols and want-lines variables for the -vc and -vl flags, and the directory-flags variable for the -w flag.

All other flags, as well as any specified files, are interpreted by the EEL functions in cmdline.e. They read the command line from the argc and argv variables, already broken down into words. The argc variable contains the number of words in the command line. The argv variable contains the words themselves. The first word on the command line, argv[0], is always the name of Epsilon's executable file, so that if argc is 2, there was one argument and it is in argv[1].

char *original_argv(int n)

The original_argv( ) primitive lets EEL code access Epsilon's original command line arguments, including those interpreted internally and not passed along to EEL code in the argv array, and excluding those added by any EPSILON configuration variable. Calling original_argv(1) returns the first command line argument, original_argv(2) the second, and so forth. A null return value indicates there are no more arguments. Calling original_argv(0) returns the full path of Epsilon's executable.

when_restoring()        /* cmdline.e */
early_init()            /* cmdline.e */
middle_init()           /* cmdline.e */
start_up()              /* cmdline.e */
user char *version;
apply_defaults()

Epsilon calls the EEL subroutine when_restoring( ) if it exists after loading a state file. Unlike when_loading( ), this subroutine is not removed after it executes. The standard version of when_restoring( ) sets up variables and modes, and interprets the command line. It calls several EEL subroutines at various points in the process. Each does nothing by default, but you can conveniently customize Epsilon by redefining them. (See The Name Table to make sure your extension doesn't interfere with other extensions.)

The when_restoring( ) function calls early_init( ) just before interpreting flags, and middle_init( ) just after. It then loads files (from the command line, or a saved session), displays Epsilon's version number, and calls the start_up( ) subroutine. (The version variable contains a string with the current version of Epsilon, such as "9.0".) Finally, Epsilon executes any -l and -r switches.

The when_restoring( ) subroutine calls the apply_defaults( ) primitive before it calls early_init( ). This primitive sets the values of window-specific and buffer-specific variables in the current buffer and window to their default values.

char state_file[ ];
user char load_from_state;

The state_file primitive contains the name of the state file Epsilon was loaded from, or "" if it was loaded only using bytecode files with the -b flag. The load_from_state variable will be set to 1 if Epsilon loaded its functions from a state file at startup, or 0 if it loaded only from bytecode files.

after_loading()

After Epsilon calls the when_restoring( ) subroutine, it finishes its internal initialization by checking for the existence of certain variables and functions that must be defined if Epsilon is to run. Until this is done, Epsilon can't perform a variety of operations such as getting a key from the keyboard, displaying buffers, and searching. The after_loading( ) primitive tells Epsilon to finish initializing now. The variables and functions listed in the table must be defined when you call after_loading( ).

when_idle()
when_displaying()
when_repeating()
getkey()
on_modify()
prepare_windows()
build_mode()
fix_cursor()
load_from_path()
color_class standard_color;
color_class standard_mono;
user int see_delay;
user short beep_duration;
user short beep_frequency;
user char mention_delay;
char _display_characters[ ];
user buffer int undo_size;
buffer short *mode_keys;
user buffer short tab_size;
user buffer short case_fold;
buffer char *_display_class;
char *_echo_display_class;
user window int display_column;
window char _highlight_control;
window char _window_flags;
char use_process_current_directory;

finish_up()
user char leave_blank;

When Epsilon is about to exit, it calls the subroutine finish_up( ), if it exists. (See The Name Table to make sure your extension doesn't interfere with other extensions that may also define finish_up( ).) Epsilon normally redisplays each mode line one last time just before exiting, so any buffers that it saved just before exiting will not still be marked unsaved on the screen. However, if the leave_blank primitive is nonzero, it skips this step.



Previous   Up    Next
Bytecode Files  Primitives and EEL Subroutines   EEL Debugging and Profiling


Lugaru Epsilon Programmer's Editor 14.04 manual. Copyright (C) 1984, 2021 by Lugaru Software Ltd. All rights reserved.