/************************************************************************ * "Epsilon", "EEL" and "Lugaru" are trademarks of Lugaru Software, Ltd. * * * * Copyright (C) 1985, 1989 Lugaru Software Ltd. All rights reserved. * * * * Limited permission is hereby granted to reproduce and modify this * * copyrighted material provided that the resulting code is used only in * * conjunction with Lugaru products and that this notice is retained in * * any such reproduction or modification. * ************************************************************************/ #include "eel.h" #define COMMAND_MAX 100 /* longest remembered cmd */ short command_keys[COMMAND_MAX]; /* remember all chars in cmd */ short auto_save_counter; short auto_save_count = 500; char auto_save_prefix[80] = "\\autosave\\"; /* set key to next key, from macro or keyboard */ getkey() { if (ungot_key != -1) { /* check before calling */ wait_for_key(); return key; } else if (pushed_special_key != -1) { key = pushed_special_key; pushed_special_key = -1; } else { if (auto_save_counter++ > auto_save_count && !cmd_len) { auto_save_counter = 0; auto_save_buffers(); } wait_for_key(); if ((key_type == 3 || key_type == 2) && !now_quoting) { pushed_special_key = key; key = CTRL('Q'); } } if (cmd_len < COMMAND_MAX) command_keys[cmd_len] = key; if (len_def_mac) { def_text[len_def_mac++] = key; if (len_def_mac >= MAX_MACRO) { end_kbd_macro(); error( "Macro definition buffer full: keyboard macro defined"); } } return key; } auto_save_buffers() /* maybe save buffers */ { char *old = bufname, *s; s = buffer_list(1); do { bufname = s; if (*filename != '\0' && modified) auto_save_one(); } while (s = buffer_list(0)); bufname = old; } auto_save_one() { char name[80]; int err; strcpy(name, auto_save_prefix); strcat(name, get_tail(filename, 1)); if (err = file_write(name, strip_returns)) file_error(err, name, "couldn't autosave"); else say("%s autosaved.", name); modified = 1; }