/************************************************************************ * "Epsilon", "EEL" and "Lugaru" are trademarks of Lugaru Software, Ltd. * * * * Copyright (C) 1988, 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" char in_swedish_mode = 0; /* 1=swedish mode, 2=sis mode */ short orig_keytran[NUMKEYS]; /* copy of original values */ short swe_keytran[NUMKEYS]; buffer char *word_pattern; char normal_word[] = "[a-zA-Z0-9_]+"; /* values for word_pattern */ char swe_word[] = "[a-zA-Z0-9_]+"; char sis_word[] = "[]%\\}{%|a-zA-Z0-9_]+"; char def_char_class[256]; /* default case translation & typing */ char def_case_map[256]; char sis_cclass[256]; /* case translation for sis mode */ char sis_cmap[256]; char def_class[256]; /* default display class */ char sis_disp_class[256]; /* display class arrays for sis & swe modes */ char swe_disp_class[256]; init_word_pattern() /* set word-pattern to normal-word */ { /* in all buffers */ char *orig = bufname, *s; word_pattern.default = normal_word; s = buffer_list(1); do { bufname = s; word_pattern = normal_word; } while (s = buffer_list(0)); bufname = orig; } when_loading() { int i; char *from, *to; for (i = 0; i < NUMKEYS; i++) swe_keytran[i] = orig_keytran[i] = keytran[i]; from = "@^&*()_-+=\\|<>?/}~`{\":'[;]"; to = "\"&/()=?+`'<>;:_-^*@"; for (; *from; from++, to++) swe_keytran[*from] = *to; from = "@^&*()_-+=\\|<>?/}~`{\":'[;]"; for (; *from; from++) orig_keytran[*from] = *from; for (i = 0; i < 256; i++) sis_disp_class[i] = swe_disp_class[i] = def_class[i]; from = "[\\]{|}"; to = ""; for (; *from; from++, to++) { swe_disp_class[*from] = def_class[*from] = BNORMAL; sis_disp_class[*from] = *to; } from = ""; for (; *from; from++) { sis_disp_class[*from] = def_class[*from] = BMC; swe_disp_class[*from] = BNORMAL; reg_tab[*from] = (short) normal_character; } for (i = 0; i < 256; i++) sis_cmap[i] = i; for (i = 'A'; i <= ']'; i++) { sis_cclass[i] = C_UPPER; sis_cclass[i + 32] = C_LOWER; sis_cmap[i] = i + 32; sis_cmap[i + 32] = i; } init_word_pattern(); } start_up() /* after loading state file */ { init_word_pattern(); } command swedish_mode() on reg_tab[FALT(2)] { to_swedish_mode(1); } command SIS_mode() on reg_tab[FALT(4)] { to_swedish_mode(2); } to_swedish_mode(val) { in_swedish_mode = (in_swedish_mode == val) ? 0 : val; char_class = def_char_class; case_map = def_case_map; display_class = def_class; keytran = orig_keytran; word_pattern = normal_word; switch (in_swedish_mode) { case 1: word_pattern = swe_word; display_class = swe_disp_class; keytran = swe_keytran; break; case 2: word_pattern = sis_word; display_class = sis_disp_class; char_class = sis_cclass; case_map = sis_cmap; break; } build_first = 1; make_mode(); } make_mode() { strcpy(mode, major_mode); if (in_swedish_mode == 1) strcat(mode, " Swedish"); else if (in_swedish_mode == 2) strcat(mode, " SIS"); if (fill_mode) strcat(mode, " Fill"); if (over_mode) strcat(mode, " Over"); if (!strip_returns) strcat(mode, " NoTrans"); if (len_def_mac) strcat(mode, " Def"); } /* Repeat commands from format.e and tags.e here to pick up new definition of word_pattern as a buffer-specific variable. */ /* position point after the next word */ command forward_word() on reg_tab[ALT('f')], reg_tab[NUMCTRL(NUMDIGIT(6))] { if (iter < 0) { iter = -iter; backward_word(); } while (iter-- > 0) re_search(1, word_pattern); } /* position point before the previous word */ command backward_word() on reg_tab[ALT('b')], reg_tab[NUMCTRL(NUMDIGIT(4))] { if (iter < 0) { iter = -iter; forward_word(); } while (iter-- > 0) re_search(-1, word_pattern); } char *trans_temp; /* name of temporary buffer */ command transpose_words() on reg_tab[ALT('t')] { int first, second; trans_temp = temp_buf(); re_search(1, word_pattern); re_search(-1, word_pattern); re_search(-1, word_pattern); first = point; re_search(1, word_pattern); save_away(first, point); re_search(1, word_pattern); second = point; grab_back(); point = second; re_search(-1, word_pattern); save_away(point, second); point = first; grab_back(); delete_buffer(trans_temp); iter = 0; } command pluck_tag() on cx_tab[','] { /* read a function name at point & go there via tags */ char tag[80]; init_tags(); iter = 0; point--; re_search(1, word_pattern); re_search(-1, word_pattern); grab(point, matchstart, tag); go_tag(tag); }