home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-27 | 43.6 KB | 2,193 lines |
- # $Header: P:/source/ppee/macros/epsilon.pev 1.17 13 Jul 1990 19:31:12 skipr $
-
- ##############################################################################
- #
- # Sage Software - POLYTRON Division
- # 1700 NW 167th Place
- # Beaverton, OR 97006
- #
- # Copyright 1990, Sage Software, Inc.
- #
- # Permission is hereby granted for licensed users of Sage Professional
- # Editor and PolyAwk to copy and modify this source code for their own
- # personal use. These derivative works may be distributed only to other
- # licensed Sage Professional Editor and PolyAwk users. All other usage
- # is prohibited without express written permission from Sage Software.
- #
- ##############################################################################
-
- #### $Workfile: epsilon.pel $: Key bindings for Epsilon compatibility
-
- # local variables:
-
- local markx;
- local marky;
- local lastsearch;
- local epsacc = 0;
- local last_was_kill = FALSE;
- local keymac;
- local savedmacs;
- local killbuffers;
- local currentkill=0;
- local lastyankx1 = (-1);
- local lastyanky1 = (-1);
- local lastyankx2 = (-1);
- local lastyanky2 = (-1);
- local errfile;
- local makebuffer = 0;
- local eps_sta_file = 0;
- local eps_sta_name = "emeps.sta";
-
- local ctrlx_keymap;
- local epsilon_keymap = -1;
-
- # establish epsilon mode:
-
- global function epsilon()
- {
- local i;
- markx = 0;
- marky = 0;
-
- toggle_dialog(1);
-
- if (eps_read_state())
- return
-
- emulation_mode = "epsilon"
-
- # Enable the keymap. Subsequent mods to the keymap will persist
- # through the end of the session.
- # Only one-time initialization should follow this point.
-
- if( epsilon_keymap >= 0 ){
- current_keymap = epsilon_keymap
- return
- }
-
- for (i=0; i<6; i++)
- killbuffers[i] = create_buffer( "killbuffer" i,
- "", BUFFER_SYSTEM );
-
- ctrlx_keymap = current_keymap = create_keymap(empty_keymap);
-
- assign_key( "<Ctrl-B>", "eps_bufed" );
- assign_key( "<Ctrl-C>", "eps_exit" );
- assign_key( "<Ctrl-D>", "eps_kill_window" );
- assign_key( "<Ctrl-E>", "eps_push" );
- assign_key( "<Ctrl-F>", "eps_find_file" );
- assign_key( "<Ctrl-I>", "eps_indent_rigidly" );
- assign_key( "<Ctrl-M>", "eps_start_process" );
- assign_key( "<Ctrl-N>", "eps_next_error" );
- assign_key( "<Ctrl-O>", "eps_delete_blank_lines" );
- assign_key( "<Ctrl-S>", "eps_save_file" );
- assign_key( "<Ctrl-T>", "eps_transpose_lines" );
- assign_key( "<Ctrl-V>", "eps_visit_file" );
- assign_key( "<Ctrl-W>", "eps_write_file" );
- assign_key( "<Ctrl-X>", "eps_exchange_point_and_mark" );
- assign_key( "<Ctrl-Z>", "eps_exit" );
-
-
- assign_key( "<Ctrl-^>b", "eps_bufed" );
- assign_key( "<Ctrl-^>c", "eps_exit" );
- assign_key( "<Ctrl-^>d", "eps_kill_window" );
- assign_key( "<Ctrl-^>e", "eps_push" );
- assign_key( "<Ctrl-^>f", "eps_find_file" );
- assign_key( "<Ctrl-^>i", "eps_indent_rigidly" );
- assign_key( "<Ctrl-^>m", "eps_start_process" );
- assign_key( "<Ctrl-^>n", "eps_next_error" );
- assign_key( "<Ctrl-^>o", "eps_delete_blank_lines" );
- assign_key( "<Ctrl-^>s", "eps_save_file" );
- assign_key( "<Ctrl-^>t", "eps_transpose_lines" );
- assign_key( "<Ctrl-^>v", "eps_visit_file" );
- assign_key( "<Ctrl-^>w", "eps_write_file" );
- assign_key( "<Ctrl-^>x", "eps_exchange_point_and_mark" );
- assign_key( "<Ctrl-^>z", "eps_exit" );
-
-
- assign_key( "(", "eps_start_kbd_macro" );
- assign_key( ")", "eps_end_kbd_macro" );
- assign_key( "1", "eps_one_window" );
- assign_key( "2", "eps_split_window" );
- assign_key( "=", "eps_show_point" );
- assign_key( "b", "eps_bufed" );
- assign_key( "e", "eps_last_kbd_macro" );
- assign_key( "f", "eps_set_fill_column" );
- assign_key( "g", "eps_goto_line" );
- assign_key( "i", "eps_insert_file" );
- assign_key( "k", "eps_kill_buffer" );
- assign_key( "l", "eps_count_lines" );
- assign_key( "m", "eps_make" );
- assign_key( "n", "eps_next_window" );
- assign_key( "o", "eps_next_window" );
- assign_key( "p", "eps_previous_window" );
- assign_key( "r", "eps_redo" );
- assign_key( "u", "eps_undo" );
- assign_key( "w", "eps_write_region" );
-
- assign_key( "<Alt-B>", "eps_bufed" );
- assign_key( "<Alt-N>", "name_macro" );
-
- assign_key( "<Esc>b", "eps_bufed" );
- assign_key( "<Esc>n", "name_macro" );
-
-
- epsilon_keymap = current_keymap = create_keymap( empty_keymap );
-
- for (i=32; i<128; i++) {
- assign_key( int_to_key(i), "donormal" );
- }
-
- # Normal keys that do extra things
- assign_key( "]", "paren" );
- assign_key( "}", "paren" );
- assign_key( ")", "paren" );
-
- # Main keyboard special keys that do extra things
- assign_key( "#8", "eps_bksp" ); # <Bksp> or <Ctrl-H>
- assign_key( "<Enter>", "eps_insert_newline" );
- assign_key( "<Alt-\\>", "altbackslash" );
- assign_key( "<Alt-,>", "altcomma" );
- assign_key( "<Alt-.>", "altdot" );
- assign_key( "<Alt-/>", "altslash" );
- assign_key( "<Ctrl-Minus>", "ctrlminus" );
- assign_key( "<Alt-Bksp>", "altback" );
- assign_key( "<Keypad-Center>", "eps_scroll_window_middle" );
- assign_key( "<Ctrl-Up>", "eps_prev_sentence" );
- assign_key( "<Ctrl-Down>", "eps_next_sentence" );
- assign_key( "<Alt-[>", "eps_prev_paragraph" );
- assign_key( "<Alt-]>", "eps_next_paragraph" );
- assign_key( "<Ctrl-@>", "ctrl_at" );
-
- # alt keys (and ctrl-alt keys)
- assign_key( "<Alt-0>", "alt0" );
- assign_key( "<Alt-1>", "eps_acc 1" );
- assign_key( "<Alt-2>", "alt2" );
- assign_key( "<Alt-3>", "eps_acc 3" );
- assign_key( "<Alt-4>", "eps_acc 4" );
- assign_key( "<Alt-5>", "alt5" );
- assign_key( "<Alt-6>", "eps_acc 6" );
- assign_key( "<Alt-7>", "alt7" );
- assign_key( "<Alt-8>", "alt8" );
- assign_key( "<Alt-9>", "eps_acc 9" );
- assign_key( "<Alt-A>", "eps_prev_sentence" );
- assign_key( "<Alt-B>", "altb" );
- assign_key( "<Alt-C>", "altc" );
- assign_key( "<Alt-D>", "altd" );
- assign_key( "<Alt-E>", "eps_next_sentence" );
- assign_key( "<Alt-F>", "altf" );
- assign_key( "<Alt-H>", "mark_para" );
- assign_key( "<Alt-K>", "altk" );
- assign_key( "<Alt-L>", "altl" );
- assign_key( "<Alt-M>", "altm" );
- assign_key( "<Alt-Q>", "eps_wrap_paragraph" );
- assign_key( "<Alt-R>", "altr" );
- assign_key( "<Alt-S>", "alts" );
- assign_key( "<Alt-T>", "altt" );
- assign_key( "<Alt-U>", "altu" );
- assign_key( "<Alt-V>", "eps_page_up" );
- assign_key( "<Alt-W>", "altw" );
- assign_key( "<Alt-X>", "eps_invoke_function" );
- assign_key( "<Alt-Y>", "eps_yankpop" );
- assign_key( "<Alt-Z>", "eps_scroll_vertical_up" );
-
- # alt function keys
- assign_key( "<Alt-F5>", "eps_toggle_display" );
-
- # normal control keys
- assign_key( "<Ctrl-A>", "eps_goto_bol" );
- assign_key( "<Ctrl-B>", "eps_prev_char" );
- assign_key( "<Ctrl-D>", "eps_delete_chars" );
- assign_key( "<Ctrl-E>", "eps_goto_eol" );
- assign_key( "<Ctrl-F>", "eps_next_char" );
- assign_key( "<Ctrl-K>", "ctrlk" );
- assign_key( "<Ctrl-L>", "eps_scroll_window_middle" );
- assign_key( "<Ctrl-N>", "eps_down" );
- assign_key( "<Ctrl-O>", "eps_open_line" );
- assign_key( "<Ctrl-P>", "eps_up" );
- assign_key( "<Ctrl-Q>", "ctrlq" );
- assign_key( "<Ctrl-R>", "search_e" );
- assign_key( "<Ctrl-S>", "search_e" );
- assign_key( "<Ctrl-T>", "ctrlt" );
- assign_key( "<Ctrl-U>", "ctrlu" );
- assign_key( "<Ctrl-V>", "eps_page_down" );
- assign_key( "<Ctrl-W>", "ctrlw" );
- assign_key( "<Ctrl-X>", "ctrlx" );
- assign_key( "<Ctrl-Y>", "eps_insert_scrap" );
- assign_key( "<Ctrl-Z>", "eps_scroll_vertical_down" );
-
- # ctrl function keys
- assign_key( "<Ctrl-F3>", "eps_write_state" );
- assign_key( "<Ctrl-F5>", "eps_toggle_display" );
- assign_key( "<Ctrl-F8>", "showvar" );
-
- # ctrl cursor keys
- assign_key( "<Ctrl-End>", "eps_goto_buffer_bottom" );
- assign_key( "<Ctrl-Home>", "eps_goto_buffer_top" );
- assign_key( "<Ctrl-Left>", "goto_bow" );
- assign_key( "<Ctrl-Right>", "goto_eow" );
-
- # ctrl prefix equivalents
-
- assign_key( "<Ctrl-^>a", "eps_goto_bol" );
- assign_key( "<Ctrl-^>b", "eps_prev_char" );
- assign_key( "<Ctrl-^>d", "eps_delete_chars" );
- assign_key( "<Ctrl-^>e", "eps_goto_eol" );
- assign_key( "<Ctrl-^>f", "eps_next_char" );
- assign_key( "<Ctrl-^>k", "ctrlk" );
- assign_key( "<Ctrl-^>l", "eps_scroll_window_middle" );
- assign_key( "<Ctrl-^>n", "eps_down" );
- assign_key( "<Ctrl-^>o", "eps_open_line" );
- assign_key( "<Ctrl-^>p", "eps_up" );
- assign_key( "<Ctrl-^>q", "ctrlq" );
- assign_key( "<Ctrl-^>r", "search_e" );
- assign_key( "<Ctrl-^>s", "search_e" );
- assign_key( "<Ctrl-^>t", "ctrlt" );
- assign_key( "<Ctrl-^>u", "ctrlu" );
- assign_key( "<Ctrl-^>v", "eps_page_down" );
- assign_key( "<Ctrl-^>w", "ctrlw" );
- assign_key( "<Ctrl-^>x", "ctrlx" );
- assign_key( "<Ctrl-^>y", "eps_insert_scrap" );
- assign_key( "<Ctrl-^>z", "eps_scroll_vertical_down" );
- assign_key( "<Ctrl-^><Alt-\\>", "indent_region" );
- assign_key( "<Ctrl-^><Esc>\\\\", "indent_region" );
-
- # ctrl-prefix function keys
- assign_key( "<Ctrl-^><F3>", "eps_write_state" );
- assign_key( "<Ctrl-^><F5>", "eps_toggle_display" );
- assign_key( "<Ctrl-^><F8>", "showvar" );
-
- # ctrl-prefix cursor keys
- assign_key( "<Ctrl-^><End>", "eps_goto_buffer_bottom" );
- assign_key( "<Ctrl-^><Home>", "eps_goto_buffer_top" );
- assign_key( "<Ctrl-^><Left>", "goto_bow" );
- assign_key( "<Ctrl-^><Right>", "goto_eow" );
-
- # alt-prefix normal keys
- assign_key( "<Esc>%", "alt5" );
- assign_key( "<Esc>&", "alt7" );
- assign_key( "<Esc>)", "alt0" );
- assign_key( "<Esc>*", "alt8" );
- assign_key( "<Esc>,", "altcomma" );
- assign_key( "<Esc>.", "altdot" );
- assign_key( "<Esc>/", "altslash" );
- assign_key( "<Esc>0", "eps_acc 0" );
- assign_key( "<Esc>1", "eps_acc 1" );
- assign_key( "<Esc>2", "eps_acc 2" );
- assign_key( "<Esc>3", "eps_acc 3" );
- assign_key( "<Esc>4", "eps_acc 4" );
- assign_key( "<Esc>5", "eps_acc 5" );
- assign_key( "<Esc>6", "eps_acc 6" );
- assign_key( "<Esc>7", "eps_acc 7" );
- assign_key( "<Esc>8", "eps_acc 8" );
- assign_key( "<Esc>9", "eps_acc 9" );
- assign_key( "<Esc>>", "altdot" );
- assign_key( "<Esc>?", "altslash" );
- assign_key( "<Esc>@", "alt2" );
- assign_key( "<Esc>a", "eps_prev_sentence" );
- assign_key( "<Esc>b", "altb" );
- assign_key( "<Esc>c", "altc" );
- assign_key( "<Esc>d", "altd" );
- assign_key( "<Esc>e", "eps_next_sentence" );
- assign_key( "<Esc>f", "altf" );
- assign_key( "<Esc>h", "mark_para" );
- assign_key( "<Esc>k", "altk" );
- assign_key( "<Esc>l", "altl" );
- assign_key( "<Esc>m", "altm" );
- assign_key( "<Esc>q", "eps_wrap_paragraph" );
- assign_key( "<Esc>s", "alts" );
- assign_key( "<Esc>t", "altt" );
- assign_key( "<Esc>u", "altu" );
- assign_key( "<Esc>v", "eps_page_up" );
- assign_key( "<Esc>w", "altw" );
- assign_key( "<Esc>x", "eps_invoke_function" );
- assign_key( "<Esc>y", "eps_yankpop" );
- assign_key( "<Esc>z", "eps_scroll_vertical_up" );
- assign_key( "<Esc>[", "eps_prev_paragraph" );
- assign_key( "<Esc>\\\\", "altbackslash" );
- assign_key( "<Esc>\\<", "altcomma" );
- assign_key( "<Esc>]", "eps_next_paragraph" );
- assign_key( "<Esc>~", "eps_modified" );
-
- # alt-prefix function keys
- assign_key( "<Esc><F5>", "eps_toggle_display" );
-
- # alt-prefix command keys
- assign_key( "<Esc><Bksp>", "altback" );
- assign_key( "<Esc><Down>", "eps_prev_paragraph" );
- assign_key( "<Esc><Up>", "eps_prev_paragraph" );
-
- # normal function keys
- assign_key( "<F1>", "eps_help" );
- assign_key( "<F2>", "eps_invoke_function" );
- assign_key( "<F4>", "bind_to_key" );
- assign_key( "<F6>", "whatiskey" );
- assign_key( "<F7>", "eps_cd" );
- assign_key( "<F8>", "setvar" );
- assign_key( "<F9>", "eps_undo" );
- assign_key( "<F10>", "eps_redo" );
-
- # normal cursor keys
- assign_key( "<Home>", "eps_goto_window_top" );
- assign_key( "<End>", "eps_goto_window_bottom" );
- assign_key( "<Left>", "eps_prev_char" );
- assign_key( "<PgDn>", "eps_page_down" );
- assign_key( "<PgUp>", "eps_page_up" );
- assign_key( "<Right>", "eps_next_char" );
- assign_key( "<Up>", "eps_up" );
- assign_key( "<Down>", "eps_down" );
- assign_key( "<Ins>", "eps_toggle_insert_mode" );
- assign_key( "<Del>", "eps_delete_chars" );
- assign_key( "<Tab>", "eps_indent" );
-
- assign_mouse_buttons()
- }
-
- global function ctrlx()
- {
- local gotchar,t,i,j, w, fname;
-
- message("C-X ");
- push_keymap(ctrlx_keymap);
- }
-
-
- global function ctrlk()
- {
- local i, count, t, has_arg;
-
- t = last_was_kill;
- has_arg = epsacc;
- count = eps_num();
-
- drop_anchor();
- for (i=0; i<count; i++) {
- if (!goto_eol() || has_arg) next_char();
- }
- if (t) {
- eps_append_to_scrap();
- delete_chars();
- }
- else eps_delete_to_scrap();
- last_was_kill = TRUE;
- }
-
- global function altd()
- {
- local i, j, t;
-
- t = last_was_kill;
-
- drop_anchor();
-
- j = eps_num();
- for (i=0; i<j; i++) goto_eow();
- if (t) {
- eps_append_to_scrap();
- delete_chars();
- }
- else eps_delete_to_scrap();
- last_was_kill = TRUE;
- }
-
- local function massage_string(instr,direction)
- {
- local i,j, outstr;
-
- outstr = quote_regex(instr);
-
- if (direction) outstr = outstr "\\c"
- return outstr;
- }
-
- global function search_e()
- {
- local ESC = 27,
- BKSP = 8,
- CTRLR = 18,
- CTRLS = 19,
- CTRLG = 7,
- level = 0,
- char,
- ch,
- pattern = "",
- spattern = "",
- flags = SEARCH_MAXIMAL_MATCH+SEARCH_FORWARD\
- +SEARCH_IGNORE_CASE+SEARCH_REGEX,
- safe_y = current_line,
- safe_x = current_column,
- dokey = FALSE,
- direction = 1,
- search_name,
- key_to_do;
-
- eps_num();
- search_name[0] = "Reverse I-Search";
- search_name[1] = "I-Search";
-
- if (current_key == 4882) {
- direction = 0;
- flags = and(flags,not(SEARCH_FORWARD));
- }
- message(search_name[direction] " for:");
- save_position();
- while (TRUE) {
- ch = getchar();
- if (ch == 0) {
- getchar();
- dokey = TRUE;
- key_to_do = prev_key;
- break;
- }
- if (ch == ESC) break;
- else if (ch == CTRLG) {
- while (level) {
- restore_position(FALSE);
- level --;
- }
- restore_position(TRUE);
- save_position();
- break;
- }
- else if (ch == BKSP) {
- if (level) {
- restore_position(TRUE);
- level --;
- }
- pattern = substr( pattern, 0, length( pattern ) - 1)
- restore_position(TRUE);
- save_position();
- spattern = massage_string(pattern,direction);
- if (search(spattern,flags)) {
- message(search_name[direction] " for: %s",pattern);
- }
- else {
- message("Failing " search_name[direction] " for: %s",pattern);
- }
- }
- else if (ch == CTRLS) {
- if (pattern == "") pattern = lastsearch;
- direction = 1;
- flags = or(flags,SEARCH_FORWARD);
- save_position();
- spattern = massage_string(pattern,direction);
- if (search(spattern, flags)) {
- message(search_name[direction] " for: %s",pattern);
- level++;
- }
- else {
- message("Failing " search_name[direction] " for: %s",pattern);
- restore_position(TRUE);
- }
- safe_y = current_line;
- safe_x = current_column;
- }
- else if (ch == CTRLR) {
- if (pattern == "") pattern = lastsearch;
- direction = 0;
- flags = and(flags, not(SEARCH_FORWARD));
- save_position();
- spattern = massage_string(pattern,direction);
- if (search(spattern, flags+SEARCH_ADVANCE)) {
- message(search_name[direction] " for: %s",pattern);
- level++;
- }
- else {
- message("Failing " search_name[direction] " for: %s",pattern);
- restore_position(TRUE);
- }
- safe_y = current_line;
- safe_x = current_column;
- }
- else if (isprint(chr(ch))) {
- restore_position(TRUE);
- save_position();
- char = chr(ch);
- spattern = massage_string(pattern char,direction);
- if (search(spattern, flags)) {
- safe_y = current_line;
- safe_x = current_column;
- message(search_name[direction] " for: %s",pattern char);
- }
- else {
- current_line = safe_y;
- current_column = safe_x;
- message("Failing " search_name[direction] " for: %s",pattern char);
- }
- pattern = pattern char
- }
- else {
- dokey = TRUE;
- key_to_do = current_key;
- break;
- }
- display_update();
- }
- while (level) {
- restore_position(FALSE);
- level --;
- }
- restore_position(FALSE);
- lastsearch = pattern;
- message("");
- last_was_kill = FALSE;
- if (dokey) {
- execute_key_action(int_to_key(key_to_do));
- }
- }
-
- global function ctrl_at()
- {
- eps_num();
- message("Mark set");
- marky = current_line;
- markx = current_column;
- last_was_kill = FALSE;
- }
-
- global function altw()
- {
- if (and(keyboard_flags,4)) {
- last_was_kill = TRUE;
- return;
- }
-
- eps_num();
- save_position();
- drop_anchor();
- current_line = marky;
- current_column = markx;
- if (last_was_kill) {
- eps_append_to_scrap();
- }
- else {
- eps_copy_to_scrap();
- }
- raise_anchor();
- restore_position(TRUE);
- last_was_kill = TRUE;
- }
-
- global function ctrlw()
- {
- eps_num();
- drop_anchor();
- current_line = marky;
- current_column = markx;
- if (last_was_kill) {
- eps_append_to_scrap();
- delete_chars();
- }
- else {
- eps_delete_to_scrap();
- }
- last_was_kill = TRUE;
- }
-
- global function forward_level()
- {
- local target, match, found, level=1, i, j;
-
- j = eps_num();
- last_was_kill = FALSE;
-
- for (i=0; i<j; i++) {
- if (!search("[\\[\\{\\(]",SEARCH_FORWARD+SEARCH_REGEX))
- return FALSE;
- target = read_buffer(1);
- if (target == "[") match = "]";
- else if (target == "{") match = "}";
- else match = ")";
-
- while (TRUE) {
- if (!search("[\\" target "\\" match "]",
- SEARCH_FORWARD+SEARCH_REGEX+SEARCH_ADVANCE))
- return FALSE;
- found = read_buffer(1);
- if (found == target) level++;
- else level--;
- if (!level) {
- next_char();
- return TRUE;
- }
- }
- }
- }
-
- global function backward_level()
- {
- local target, match, found, level=1, i, j;
-
- j = eps_num();
- last_was_kill = FALSE;
-
- for (i=0; i<j; i++) {
- if (!search("[\\]\\}\\)]",SEARCH_REGEX))
- return FALSE;
- target = read_buffer(1);
- if (target == "]") match = "[";
- else if (target == "}") match = "{";
- else match = "(";
-
- while (TRUE) {
- if (!search("[\\" target "\\" match "]",
- SEARCH_REGEX+SEARCH_ADVANCE))
- return FALSE;
- found = read_buffer(1);
- if (found == target) level++;
- else level--;
- if (!level) {
- prev_char();
- return TRUE;
- }
- }
- }
- }
-
- global function goto_eow()
- {
- local i, j;
-
- j = eps_num();
- last_was_kill = FALSE;
-
- for (i=0; i<j; i++) {
- if (!search("[A-Za-z0-9_]+\\c",
- SEARCH_FORWARD+SEARCH_REGEX+SEARCH_MAXIMAL_MATCH)) {
- return FALSE;
- }
- }
- return TRUE;
- }
-
- global function altf()
- {
- local i, j;
-
- j = eps_num();
-
- for (i=0; i<j; i++) {
- if (and(keyboard_flags,4)) forward_level();
- else goto_eow();
- }
- last_was_kill = FALSE;
- }
-
- global function goto_bow()
- {
- local i,j;
-
- j = eps_num();
- last_was_kill = FALSE;
-
- for (i=0; i<j; i++) {
- if (!search("[A-Za-z0-9_]+",
- SEARCH_ADVANCE+SEARCH_REGEX+SEARCH_MAXIMAL_MATCH)) {
- return FALSE;
- }
- }
- return TRUE;
- }
-
-
- global function altb()
- {
- local i,j;
-
- j = eps_num();
-
- for (i=0; i<j; i++) {
- if (and(keyboard_flags,4)) backward_level();
- else goto_bow();
- }
- last_was_kill = FALSE;
- }
-
- global function altk()
- {
- local i, j, t;
-
- j = eps_num();
-
- if (and(keyboard_flags,4)) {
- for (i=0; i<j; i++) kill_forward_level();
- }
-
- else {
- drop_anchor();
- t = last_was_kill;
- for (i=0; i<j; i++)
- next_sentence();
- if (t) {
- eps_append_to_scrap();
- delete_chars();
- }
- else eps_delete_to_scrap();
- raise_anchor();
- }
- last_was_kill = TRUE;
- }
-
- global function kill_forward_level()
- {
- local i,j,t;
-
- j = eps_num();
- drop_anchor();
-
- t = last_was_kill;
-
- for (i=0; i<j; i++) {
- if (!forward_level()) {
- raise_anchor();
- return;
- }
- }
- if (t) {
- eps_append_to_scrap();
- delete_chars();
- }
- else {
- eps_delete_to_scrap();
- }
- raise_anchor();
- last_was_kill = TRUE;
- }
-
- global function ctrlq()
- {
- local i,j;
-
- message("Quote:");
-
- while(!getchar()) {
- beep();
- getchar();
- }
-
- j = eps_num();
-
- for (i=0; i<j; i++) insert_key(current_key);
- message("");
- last_was_kill = FALSE;
- }
-
- global function ctrlt()
- {
- local char, goleft;
-
- eps_num();
- last_was_kill = FALSE;
- if (current_line_length < 2) return;
-
- goleft = !left(1);
- char = read_buffer(1);
- delete_chars(1);
- right(1);
- insert_string(char);
- left(1);
- if (goleft) left(1);
- }
-
- global function ctrlminus()
- {
- eps_num();
- last_was_kill = FALSE;
- if (and(keyboard_flags,3)) help();
- }
-
- global function altback()
- {
- local i,j;
-
- save_position();
-
- j = eps_num();
-
- for (i=0; i<j; i++) {
- search("[A-Za-z0-9_]+",SEARCH_REGEX+SEARCH_MAXIMAL_MATCH);
- }
- drop_anchor();
- restore_position(TRUE);
- if (last_was_kill) {
- insert_scrap();
- eps_delete_to_scrap();
- }
- else eps_delete_to_scrap();
- last_was_kill = TRUE;
- }
-
- global function altc()
- {
- local i,j;
-
- drop_anchor();
-
- j = eps_num();
- for (i=0; i<j; i++) {
- goto_eow();
- }
- capitalize();
- raise_anchor();
- last_was_kill = FALSE;
- }
-
- global function altu()
- {
- local i,j;
-
- drop_anchor();
- j = eps_num();
- for (i=0; i<j; i++) {
- goto_eow();
- }
- upper();
- raise_anchor();
- last_was_kill = TRUE;
- }
-
- global function altl()
- {
- local i,j;
-
- drop_anchor();
-
- j = eps_num();
- for (i=0; i<j; i++) {
- goto_eow();
- }
- lower();
- raise_anchor();
- last_was_kill = FALSE;
- }
-
- global function alts()
- {
- local s,e,c;
- local ft;
-
- eps_num();
-
- if (and(keyboard_flags,4)) {
- toggle_search_regex(TRUE);
- search_forward();
- return;
- }
- goto_bol();
- if (!search("[^ \t]",SEARCH_FORWARD+SEARCH_REGEX)) return;
- s = current_column;
- goto_eol();
- search("[^ \t]",SEARCH_REGEX);
- e = current_column;
- c = 40-((s + e)/2);
- current_column = s;
- ft = first_tab_distance();
- indent_tabs(c/ft);
- indent_columns(c%ft);
- last_was_kill = FALSE;
- }
-
- global function altbackslash()
- {
- if (and(keyboard_flags,4)) {
- indent_region();
- return;
- }
-
- eps_num();
- while (read_buffer(1) ~ "[ \t]") delete_chars(1);
- left();
- while (read_buffer(1) ~ "[ \t]") {
- delete_chars(1);
- left();
- }
- last_was_kill = FALSE;
- }
-
- global function altcomma()
- {
- eps_num();
- if (and(keyboard_flags,3)) goto_buffer_top();
- else goto_window_top();
- last_was_kill = FALSE;
- }
-
- global function altdot()
- {
- eps_num();
- if (and(keyboard_flags,3)) goto_buffer_bottom();
- else goto_window_bottom();
- last_was_kill = FALSE;
- }
-
- global function altslash()
- {
- eps_num();
- if (and(keyboard_flags,3)) help();
- last_was_kill = FALSE;
- }
-
- global function alt2()
- {
- if (and(keyboard_flags,3)) {
- eps_num();
- ctrl_at();
- last_was_kill = FALSE;
- }
- else eps_acc(2);
- }
-
- global function show_matching()
- {
- eps_num();
- save_position();
- backward_level();
- display_update();
- play("______");
- restore_position(TRUE);
- last_was_kill = FALSE;
- }
-
- global function alt0()
- {
- if (and(keyboard_flags,3)) {
- eps_num();
- show_matching();
- last_was_kill = FALSE;
- }
- else eps_acc(0);
- }
-
- global function bind_to_key()
- {
- local key, comm;
-
- eps_num();
- comm = prompt_history("BIND", "Bind command:", "");
- if (comm != "") {
- message("To key:");
- if (!getchar()) getchar();
- if (comm in savedmacs) {
- assign_key(int_to_key(current_key),"replay "comm);
- }
- else
- assign_key(int_to_key(current_key),comm);
- }
- message("");
- last_was_kill = FALSE;
- }
-
- global function paren()
- {
- local i,j;
-
- j = eps_num();
-
- for (i=0; i<j; i++) {
- insert_key(current_key);
- show_matching();
- }
- last_was_kill = FALSE;
- }
-
- global function altt()
- {
- local s1,e1,s2,e2, save1, save2;
-
- eps_num();
- goto_eow();
- e1 = current_column;
- goto_bow();
- s1 = current_column;
- save1 = read_buffer(e1-s1);
-
- goto_bow();
-
- goto_eow();
- e2 = current_column;
- goto_bow();
- s2 = current_column;
- save2 = read_buffer(e2-s2);
-
- current_column = s1;
- delete_chars(e1-s1);
- insert_string(save2);
-
- current_column = s2;
- delete_chars(e2-s2);
- insert_string(save1);
- last_was_kill = FALSE;
- }
-
- global function cd()
- {
- eps_num();
- chdir(prompt_history("CHDIR", "Change directory to:",""));
- last_was_kill = FALSE;
- }
-
- global function mark_para()
- {
- local i,j;
-
- j = eps_num();
- prev_paragraph();
- ctrl_at();
- for (i=0; i<j; i++) {
- next_paragraph();
- }
- last_was_kill = FALSE;
- }
-
- global function alt5()
- {
- if (and(keyboard_flags,3)) {
- eps_num();
- sf_replace();
- last_was_kill = FALSE;
- }
- else eps_acc(5);
- }
-
- global function alt7()
- {
- if (and(keyboard_flags,3)) {
- eps_num();
- sf_replace();
- last_was_kill = FALSE;
- }
- else eps_acc(7);
- }
-
- global function alt8()
- {
- if (and(keyboard_flags,3)) {
- eps_num();
- sf_replace();
- last_was_kill = FALSE;
- }
- else eps_acc(8);
- }
-
- global function altm()
- {
- eps_num();
- goto_bol();
- search("[^ \t]|\\n", SEARCH_FORWARD+SEARCH_REGEX);
- last_was_kill = FALSE;
- }
-
- global function eps_delete_chars()
- {
- if (epsacc || last_was_kill) {
- drop_anchor();
- next_char(eps_num());
- if (last_was_kill) {
- eps_append_to_scrap();
- delete_chars();
- }
- else eps_delete_to_scrap();
- last_was_kill = TRUE;
- }
- else {
- delete_chars(eps_num());
- last_was_kill = FALSE;
- }
- }
-
- global function eps_down()
- {
- down(eps_num());
- last_was_kill = FALSE;
- }
-
- global function eps_insert_newline()
- {
- local i, j;
-
- j = eps_num();
- for (i = 0; i < j; i ++) {
- auto_indent_cr()
- }
- last_was_kill = FALSE;
- }
-
- global function eps_open_line()
- {
- save_position()
- eps_insert_newline()
- restore_position(1)
- }
-
- global function eps_insert_scrap()
- {
- local i, j;
-
- j = eps_num();
-
- lastyankx1 = current_column;
- lastyanky1 = current_line;
-
- for (i = 0; i < j; i ++) {
- insert_scrap()
- }
-
- lastyankx2 = current_column;
- lastyanky2 = current_line;
-
- last_was_kill = FALSE;
- }
-
- global function eps_next_char()
- {
- next_char(eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_next_paragraph()
- {
- next_paragraph(eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_next_sentence()
- {
- next_sentence(eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_page_down()
- {
- local i,j;
-
- j = eps_num();
-
- for (i=0; i<j; i++) page_down()
- last_was_kill = FALSE;
- }
-
- global function eps_page_up()
- {
- local i,j;
-
- j = eps_num();
-
- for (i=0; i<j; i++) page_up()
- last_was_kill = FALSE;
- }
-
- global function eps_prev_char()
- {
- prev_char(eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_prev_paragraph()
- {
- prev_paragraph(eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_prev_sentence()
- {
- prev_sentence(eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_scroll_vertical_up()
- {
- scroll_vertical(-eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_scroll_vertical_down()
- {
- scroll_vertical(eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_up()
- {
- up(eps_num())
- last_was_kill = FALSE;
- }
-
- global function eps_bksp()
- {
- local i,j;
-
- if (epsacc || last_was_kill) {
- save_position();
- prev_char(eps_num());
- drop_anchor()
- restore_position(TRUE);
- if (last_was_kill) {
- insert_scrap();
- }
- eps_delete_to_scrap();
- last_was_kill = TRUE;
- }
- else {
- j = eps_num();
- for (i=0; i<j; i++)
- backspace();
- last_was_kill = FALSE;
- }
- }
-
- global function eps_num()
- {
- local i;
-
- i = ((epsacc) ? epsacc : 1);
- epsacc = 0;
- if (last_message != " ")
- message(" ");
- return i;
- }
-
- global function ctrlu()
- {
- if (!epsacc) epsacc++;
- epsacc *= 4;
- message("Argument %d",epsacc);
- }
-
- global function eps_acc(n)
- {
- local ch;
-
- epsacc *= 10;
- epsacc += n;
- message("Argument %d",epsacc);
-
- ch = getkey();
- while (isdigit( chr(and(ch, 0x00FF)) )){
- n = and(ch, 0x00FF) - ord("0");
-
- epsacc *= 10;
- epsacc += n;
- message("Argument %d",epsacc);
-
- ch = getkey();
- }
- ungetkey( ch );
- }
-
- global function donormal()
- {
- local i, j;
-
- j = eps_num();
- for (i=0; i<j; i++) {
- insert_key(current_key);
- }
- last_was_kill = FALSE;
- }
-
- global function eps_cd()
- {
- eps_num();
- last_was_kill = FALSE;
- cd();
- }
-
- global function eps_help()
- {
- eps_num();
- last_was_kill = FALSE;
- help();
- }
-
- global function eps_invoke_function()
- {
- local comm;
-
- eps_num();
- last_was_kill = FALSE;
-
- comm = prompt_history("XMACRO","Command: ","");
-
- if (comm in savedmacs) {
- replay(comm);
- }
- else invoke_function(comm);
- }
-
- global function eps_redo()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
- eps_num();
- last_was_kill = FALSE;
- redo();
- }
-
- global function eps_scroll_window_middle()
- {
- eps_num();
- last_was_kill = FALSE;
- scroll_window_middle();
- }
-
- global function eps_toggle_insert_mode()
- {
- eps_num();
- last_was_kill = FALSE;
- toggle_insert_mode();
- }
-
- global function eps_undo()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- undo();
- }
-
- global function eps_goto_bol()
- {
- eps_num();
- last_was_kill = FALSE;
- goto_bol();
- }
-
- global function eps_goto_eol()
- {
- eps_num();
- last_was_kill = FALSE;
- goto_eol();
- }
-
- global function eps_goto_buffer_bottom()
- {
- eps_num();
- last_was_kill = FALSE;
- goto_buffer_bottom();
- }
-
- global function eps_goto_buffer_top()
- {
- eps_num();
- last_was_kill = FALSE;
- goto_buffer_top();
- }
-
- global function eps_goto_window_bottom()
- {
- eps_num();
- last_was_kill = FALSE;
- goto_window_bottom();
- }
-
- global function eps_goto_window_top()
- {
- eps_num();
- last_was_kill = FALSE;
- goto_window_top();
- }
-
- global function name_macro()
- {
- local s;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- if (keymac == "") return;
-
- s = prompt("Macro name:");
-
- if (s == "") return;
-
- savedmacs[s] = keymac;
-
- message("");
- }
-
- global function replay(comm)
- {
- local s;
-
- eps_num();
- last_was_kill = FALSE;
-
- s = savedmacs[comm];
- playback(substr(s, 1, length(s) -1));
- }
-
- global function eps_indent()
- {
- local ft;
- local start_column, column, new_column, line, i, j;
-
- last_was_kill = FALSE;
- j = eps_num();
-
- start_column = current_column;
- altm();
- if (current_column >= start_column) { #should we re_indent
- line = current_line;
- goto_bol();
- if (prev_char() && search("[^ \t\n]",SEARCH_REGEX)) {
- altm();
- column = current_column;
- ft = first_tab_distance();
- new_column = max(column,start_column+ft) - 1;
- current_line = line;
- goto_bol();
- altbackslash();
- indent_columns( new_column%ft );
- indent_tabs( new_column/ft );
- altm();
- }
- else {
- current_column = start_column;
- current_line = line;
- insert_string("\t");
- }
- }
- else {
- current_column = start_column;
- for (i=0; i<j; i++) insert_string("\t");
- }
- last_was_kill = FALSE;
- }
-
- global function whatiskey()
- {
- local key,binding;
-
- eps_num();
- last_was_kill = FALSE;
- message("What is key: ");
-
- if (!getchar()) {
- getchar();
- key = key_name(prev_key);
- }
- else {
- key = key_name(current_key);
- }
- binding = keymap_binding(key);
- if (binding == "") {
- message("Key " key " is not bound to any command");
- }
- else {
- message("Key " key " runs the command " binding);
- }
- }
-
- global function max(a,b)
- {
- return (a>b) ? a : b;
- }
-
- global function eps_toggle_display()
- {
- eps_num();
- last_was_kill = FALSE;
- toggle_display();
- }
-
- global function eps_wrap_paragraph()
- {
- eps_num();
- last_was_kill = FALSE;
- wrap_paragraph();
- }
-
- global function eps_yankpop()
- {
- local thisbuffer = current_buffer;
-
- eps_num();
- last_was_kill = FALSE;
-
- if (current_column != lastyankx2) return;
- if (current_line != lastyanky2) return;
-
- drop_anchor();
-
- current_column = lastyankx1;
- current_line = lastyanky1;
-
- delete_chars();
- raise_anchor();
-
- prevkillbuf();
-
- current_buffer = killbuffers[currentkill];
-
- goto_buffer_top();
- drop_anchor();
- goto_buffer_bottom();
- copy_to_scrap();
- raise_anchor();
-
- current_buffer = thisbuffer;
-
- lastyankx1 = current_column;
- lastyanky1 = current_line;
-
- insert_scrap();
-
- lastyankx2 = current_column;
- lastyanky2 = current_line;
- }
-
- global function eps_delete_to_scrap()
- {
- local thisbuffer;
-
- thisbuffer = current_buffer;
-
- delete_to_scrap();
-
- nextkillbuf();
-
- delete_buffer(killbuffers[currentkill]);
- killbuffers[currentkill] = create_buffer("killbuffer" currentkill,
- "", BUFFER_SYSTEM);
-
- current_buffer = killbuffers[currentkill];
- insert_scrap();
-
- current_buffer = thisbuffer;
- }
-
- global function eps_append_to_scrap()
- {
- local thisbuffer;
-
- thisbuffer = current_buffer;
-
- append_to_scrap();
-
- delete_buffer(killbuffers[currentkill]);
- killbuffers[currentkill] = create_buffer("killbuffer" currentkill,
- "", BUFFER_SYSTEM);
-
- current_buffer = killbuffers[currentkill];
- insert_scrap();
-
- current_buffer = thisbuffer;
- }
-
- global function eps_copy_to_scrap()
- {
- local thisbuffer;
-
- thisbuffer = current_buffer;
-
- copy_to_scrap();
-
- nextkillbuf();
-
- delete_buffer(killbuffers[currentkill]);
- killbuffers[currentkill] = create_buffer("killbuffer" currentkill,
- "", BUFFER_SYSTEM);
-
- current_buffer = killbuffers[currentkill];
- insert_scrap();
-
- current_buffer = thisbuffer;
- }
-
- global function nextkillbuf()
- {
- currentkill ++;
- currentkill %= 6;
- }
-
- global function prevkillbuf()
- {
- currentkill += 5;
- currentkill %= 6;
- }
-
- global function eps_modified()
- {
- eps_num();
- last_was_kill = FALSE;
-
- buffer_flags = xor(buffer_flags, BUFFER_MODIFIED);
-
- if (and(buffer_flags,BUFFER_MODIFIED)) {
- message("Buffer is marked changed");
- }
- else {
- message("Buffer is marked unchanged");
- }
- }
-
- global function altr()
- {
- eps_num();
-
- last_was_kill = FALSE;
-
- if (and(keyboard_flags,4)) {
- toggle_search_regex(TRUE);
- search_backward();
- }
- else beep();
- }
-
- global function showvar()
- {
- local showme;
-
- eps_num();
- last_was_kill = FALSE;
-
- showme = prompt_history("XMACRO","Show variable: ","");
- message(showme " == " execute_function(showme));
- }
-
- global function setvar()
- {
- local setme;
- local to;
-
- eps_num();
- last_was_kill = FALSE;
-
- setme = prompt_history("XMACRO","set variable: ","");
- to = prompt("to: ");
- message(setme " == " execute_function(setme"="to));
- }
-
- global function eps_copytofile()
- {
- local t;
-
- t = and(buffer_flags,BUFFER_MODIFIED);
-
- write_buffer(prompt_history("EDITFILE","Copy to file: ",""));
-
- buffer_flags = set_flag_bits(buffer_flags, BUFFER_MODIFIED, t);
- }
-
- global function eps_bufed()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- buffer_list();
- }
-
- global function eps_count_lines()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- message("%d lines, point on line %d",buffer_last_line,
- current_line);
- }
-
- global function eps_delete_blank_lines()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- goto_bol();
-
- save_position();
- while (up() && isblank(read_buffer())) {
- restore_position(FALSE);
- save_position();
- }
- restore_position(TRUE);
- drop_anchor();
-
- save_position();
- while (isblank(read_buffer()) && down()) {
- restore_position(FALSE);
- save_position();
- }
- restore_position(TRUE);
-
- delete_chars();
- }
-
- global function eps_end_kbd_macro()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- keymac=record(0);
- message("Done Recording");
- }
-
- global function eps_exchange_point_and_mark()
- {
- local t;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- t = markx;
- markx = current_column;
- current_column = t;
- t = marky;
- marky = current_line;
- current_line = t;
- }
-
- global function eps_exit()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- quit();
- }
-
- global function eps_find_file()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- edit_file(prompt_history("EDITFILE", "Find file: ", ""));
- message("");
- }
-
- global function eps_goto_line()
- {
- local t, j;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- t = epsacc;
- j = eps_num();
-
- last_was_kill = FALSE;
- goto_line(t ? j : atoi(prompt("Goto line:")));
- }
-
- global function eps_indent_rigidly()
- {
- local i, j, t;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- t = epsacc;
- j = eps_num();
-
- drop_anchor();
- current_column = markx;
- current_line = marky;
- indent_columns((t) ? j : first_tab_distance());
- raise_anchor();
-
- last_was_kill = FALSE;
- }
-
- global function eps_insert_file()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- markx = current_column;
- marky = current_line;
- read_file(prompt_history("EDITFILE","Insert file: ",""));
- }
-
- global function eps_kill_buffer()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- delete_buffer_key();
- }
-
- global function eps_kill_window()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- delete_window();
- }
-
- global function eps_last_kbd_macro()
- {
- local i, j;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- j = eps_num();
- last_was_kill = FALSE;
- for (i=0; i<j; i++) {
- playback(substr(keymac,1,length(keymac)-1));
- }
- }
-
- global function eps_make()
- {
- local status;
- local old_window = current_window, old_buffer = current_buffer;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- if (makebuffer) delete_buffer(makebuffer);
-
- if (buffers_modified && toupper(prompt("Save buffers?")) == "Y") {
- write_all_buffers();
- }
-
- errfile=create_temp_name();
- current_window =
- create_window(3,8,display_width-6,display_height-16,
- WINDOW_MENU0);
- window_cursor_x = 0;
- window_cursor_y = 0;
- display_update();
- status = dos_window("make >& "errfile);
- makebuffer = current_buffer =
- create_buffer("", errfile, BUFFER_SYSTEM + BUFFER_NO_UNDO);
- attach_window_buffer(current_window, current_buffer);
- goto_buffer_bottom();
- goto_eol();
- display_update();
- confirm( "Press <ENTER> to continue.", "" );
- goto_buffer_top();
- goto_bol();
- delete_window();
- current_buffer = old_buffer;
- if (old_window)
- current_window = old_window;
- display_redraw();
- unlink(errfile);
- message("make returns %d",status);
- }
-
- global function eps_next_error()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- goto_next_error( errorSrcName );
- }
-
- global function eps_next_window()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- next_window();
- }
-
- global function eps_one_window()
- {
- local w;
- local cw;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- restore_window();
- expand_window();
- cw = current_window;
- while (cw) {
- w = next_window();
- if (w == cw)
- break;
- delete_window();
- }
- if (cw)
- current_window = cw;
- }
-
- global function eps_previous_window()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- prev_window();
- }
-
- global function eps_push()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- system("p");
- }
-
- global function eps_save_file()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- write_buffer();
- message("File saved.");
- }
-
- global function eps_set_fill_column()
- {
- local t, j;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- t = epsacc;
- j = eps_num();
-
- last_was_kill = FALSE;
- wp_right_margin = (t) ? j : current_column;
- }
-
- global function eps_show_point()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- message("%d Characters, point at %d",buffer_size,
- buffer_offset);
- }
-
- global function eps_split_window()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- create_tiled_window();
- }
-
- global function eps_start_kbd_macro()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- record(1);
- message("Recording");
- }
-
- global function eps_start_process()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- system("");
- }
-
- global function eps_transpose_lines()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- up(1);
- goto_bol();
- drop_anchor();
- down(1);
- eps_delete_to_scrap();
- down(1);
- insert_scrap();
- raise_anchor();
- up(1);
- }
-
- global function eps_visit_file()
- {
- local name;
-
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- edit_file(prompt_history("EDITFILE","Visit file :",buffer_filename));
- if (and(buffer_flags,BUFFER_MODIFIED)) {
- if (toupper(prompt("Write changes to disk first?"))=="Y") {
- write_buffer();
- }
- else {
- name = buffer_filename;
- buffer_flags = xor(buffer_flags,BUFFER_MODIFIED);
- delete_buffer();
- edit_file(name);
- }
- }
- }
-
- global function eps_write_file()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
- write_buffer(prompt("Write to file: "));
- message("File written.");
- }
-
- global function eps_write_region()
- {
- if (current_keymap == ctrlx_keymap) pop_keymap();
-
- eps_num();
- last_was_kill = FALSE;
-
- save_position();
- drop_anchor();
- current_column = markx;
- current_line = marky;
- write_marked_block(prompt("Write region to file: "));
- raise_anchor();
- restore_position(TRUE);
- }
-
- local function isblank(s)
- {
- local i;
-
- if (s == "") return TRUE;
-
- for (i=1; i<=length(s); i++) {
- if (substr(s,i,1) !~ "[ \t]") return FALSE;
- }
-
- return TRUE;
- }
-
- global function indent_region()
- {
- local oldcurrent, swapt = FALSE;
-
- eps_num();
- last_was_kill = FALSE;
-
- if (current_line < marky) {
- eps_exchange_point_and_mark();
- swapt = TRUE;
- }
- save_position();
-
- oldcurrent = current_line;
-
- for (current_line=marky; current_line<=oldcurrent; current_line++) {
- goto_bol();
- eps_indent();
- }
- restore_position(TRUE);
-
- if (swapt) eps_exchange_point_and_mark();
- }
-
- global function eps_write_state()
- {
- local i;
-
- eps_num();
- last_was_kill = FALSE;
-
- eps_sta_file = fopen(eps_sta_name,1)
- if (!eps_sta_file) {
- message("Cannot open state file");
- return;
- }
-
- if (lastsearch != "")
- fprintf(eps_sta_file,"lastsearch="lastsearch"\n");
-
-
- if (keymac != "")
- fprintf(eps_sta_file,"keymac="keymac"\n");
- # !! this doesn't always work right
-
- for (i in savedmacs) {
- fprintf(eps_sta_file,"savedmacs["i"]="i"\n");
- # !! this also doesn't always work right
- }
- # !! fprintf(eps_sta_file,"push_keymap ctrlx_keymap\n");
- # !! save ctrlx keymap here as a set of assign_key commands
- # !! fprintf(eps_sta_file,"pop_keymap\n");
- # !! save normal keymap here as a set of assign_key commands
- fclose(eps_sta_file);
- message("State file written.");
- }
-
- global function eps_read_state()
- {
- local oldbuffer = current_buffer,cf,cmd;
-
- cf = create_buffer("",eps_sta_name, BUFFER_SYSTEM+BUFFER_NO_UNDO);
-
- # !! create the ctrlx keymap (should be put in when keymaps are saved)
- # !!
- # !! ctrlx_keymap=create_keymap(empty_keymap);
- # !!
-
- # !! create and activate the main keymap (should be put in when
- # !! keymaps are saved)
- # !!
- # !! push_keymap(create_keymap(empty_keymap));
-
- if (cf) {
- current_buffer = cf;
- goto_buffer_top();
- do {
- cmd = read_buffer();
- if (cmd) execute_function(cmd);
- next_line();
- } while (cmd);
- delete_buffer(cf);
- current_buffer = oldbuffer;
- }
- else return FALSE;
-
- return FALSE; # !! this should return true when the keymap stuff is
- # !! built. My problem is saving all the maps including
- # !! multiple keystroke sequences
- }
-
-
- local eps_tab_distance;
- local eps_tab_string;
-
- ## first_tab_distance()
- #
- # Determine the column where the first Tab in a row would be positioned.
- #
- global function first_tab_distance(){
-
- if (eps_tab_string != buffer_tabs) {
- eps_tab_string = buffer_tabs;
- buffer_flags = and(buffer_flags, not(BUFFER_REAL_SPACE_ONLY))
- save_position()
- goto_bol()
- goto_next_tab();
- eps_tab_distance = current_column - 1;
- restore_position(1);
- buffer_flags = or(buffer_flags, BUFFER_REAL_SPACE_ONLY)
- }
- return eps_tab_distance;
- }
-