1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
/* c_bind.h
*
* Copyright (c) 1994-1996, Marko Macek
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
#ifndef C_BIND_H
#define C_BIND_H
#include "c_mode.h" // EM_MENUS
#include "console.h"
#include "e_regex.h"
#include "o_model.h"
#define ABBREV_HASH 16
class EMode;
class EEventMap;
class EKeyMap;
class EKey;
class EAbbrev;
class EView;
class EColorize;
struct KeySel {
TKeyCode Mask;
TKeyCode Key;
};
class EMode {
public:
EMode *fNext;
char *fName;
char *MatchName;
char *MatchLine;
RxNode *MatchNameRx;
RxNode *MatchLineRx;
EBufferFlags Flags;
EEventMap *fEventMap;
EMode *fParent;
#ifdef CONFIG_SYNTAX_HILIT
EColorize *fColorize;
#endif
char filename[256];
EMode(EMode *aMode, EEventMap *Map, const char *aName);
~EMode();
#ifdef CONFIG_ABBREV
EAbbrev *FindAbbrev(const char *string);
#endif
};
class EKeyMap {
public:
EKeyMap *fParent;
EKey *fKeys;
EKeyMap();
~EKeyMap();
void AddKey(EKey *aKey);
EKey *FindKey(TKeyCode aKey);
};
class EEventMap {
public:
EEventMap *Next;
EEventMap *Parent;
char *Name;
EKeyMap *KeyMap;
char *Menu[EM_MENUS]; // main + local
EAbbrev *abbrev[ABBREV_HASH];
EEventMap(const char *AName, EEventMap *AParent);
~EEventMap();
void SetMenu(int which, const char *What);
char *GetMenu(int which);
#ifdef CONFIG_ABBREV
int AddAbbrev(EAbbrev *ab);
#endif
};
enum CommandType_e {
CT_COMMAND,
CT_NUMBER,
CT_STRING,
CT_VARIABLE,
CT_CONCAT /* concatenate strings */
};
struct CommandType {
CommandType_e type;
short repeat;
short ign;
union {
long num;
char *string;
} u;
};
struct ExMacro {
char *Name;
unsigned Count;
CommandType *cmds;
};
class EKey {
public:
KeySel fKey;
int Cmd;
EKeyMap *fKeyMap;
EKey *fNext;
EKey(const char *aKey);
EKey(const char *aKey, EKeyMap *aKeyMap);
~EKey();
};
#ifdef CONFIG_ABBREV
class EAbbrev {
public:
EAbbrev *next;
int Cmd;
char *Match;
char *Replace;
EAbbrev(const char *aMatch, const char *aReplace);
EAbbrev(const char *aMatch, int aCmd);
~EAbbrev();
};
#endif
class ExState { // state of macro execution
public:
int Macro;
int Pos;
int GetStrParam(EView *view, char *str, size_t buflen);
int GetIntParam(EView *view, int *value);
};
extern EMode *Modes;
extern EEventMap *EventMaps;
extern int CMacros;
extern ExMacro *Macros;
int GetCharFromEvent(TEvent &E, char *Ch);
const char *GetCommandName(int Command);
EMode *FindMode(const char *Name);
EEventMap *FindEventMap(const char *Name);
EEventMap *FindActiveMap(EMode *Mode);
EMode *GetModeForName(const char *FileName);
int CmdNum(const char *Cmd);
void ExecKey(EKey *Key);
EKey *SetKey(EEventMap *aMap, const char *Key);
int GetKeyName(char *Key, size_t KeySize, KeySel &ks);
int NewCommand(const char *Name);
int RunCommand(int Command);
int AddCommand(int no, int cmd, int count, int ign);
int AddString(int no, const char *Command);
int AddNumber(int no, long number);
int AddVariable(int no, int number);
int AddConcat(int no);
int HashStr(const char *str, int maxim);
void SetWordChars(char *w, const char *s);
#endif // C_BIND_H
|