-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXCode.pas
154 lines (139 loc) · 3.39 KB
/
XCode.pas
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
unit XCode;
interface
uses
Defines, Objects2, Streams, U_KeyMap
;
type
PXCoder = ^TXCoder;
{`2 ¡®â á ¯¥à¥ª®¤¨à®¢ª ¬¨ ¢ ¯à®á¬®âà¥, dbf ¨ â.¯.}
TXCoder = object(TObject)
XLatCP: TXLatCP;
KeyMap: TKeyMap;
{` KeyMap=kmXlat ¤«ï ª®¤¨à®¢ª¨, § £à㦥®© ¨§ xlt-ä ©« `}
MaxCodeTagLen: Byte;
{` Œ ªá¨¬ «ì ï ¤«¨ CodeTag. ¥ ¡®«¥¥ 8.`}
CodeTag: Str8;
{` Ž¡®§ 票¥ ª®¤¨à®¢ª¨ ¤«ï ¨¤¨ª 樨 ¢ à ¬ª¥.
â® ¨¬ï ¯à¥¤®¯à¥¤¥«ñ®© ª®¤¨à®¢ª¨ ¨«¨ ¨¬ï ä ©« § £à㦥®©
xlt-â ¡«¨æë ¡¥§ ¯ã⨠`}
constructor Init(AMaxCodeTagLen: Byte);
constructor Load(var S: TStream);
procedure Store(var S: TStream);
procedure UseToAscii;
{` áâநâì ¢áñ kmXlat ®á®¢ ¨¨ XLatCP[ToAscii]`}
procedure UseKeyMap;
{` áâநâì ¢áñ ⥪ãéãî KeyMap (kmAscii ¨«¨ ¡®«¥¥)`}
procedure LoadXlatTable;
procedure NextXLat;
{` ¥à¥ª«î票¥ ¯® ªàã£ã ¯à¥¤®¯à¥¤¥«ñëå ª®¤¨à®¢®ª `}
procedure FromHistory(fKeyMap: TKeyMap;
fToAscii: TXLat; fCodeTag: Str8);
procedure ToHistory(var fKeyMap: TKeyMap;
var fToAscii: TXLat; var fCodeTag: Str8);
end;
{`}
implementation
uses
Advance, Advance1, Lfn, DNStdDlg, DnApp, Commands, DnIni
;
constructor TXCoder.Init;
begin
inherited Init;
KeyMap := kmAscii;
UseKeyMap;
if (AMaxCodeTagLen > 8) then
AMaxCodeTagLen := 8;
MaxCodeTagLen := AMaxCodeTagLen;
end;
procedure TXCoder.Store;
begin
S.Write(KeyMap, SizeOf(KeyMap));
S.Write(MaxCodeTagLen, SizeOf(MaxCodeTagLen));
S.Write(CodeTag, SizeOf(CodeTag));
if KeyMap = kmXlat then
S.Write(XLatCP[ToAscii], SizeOf(TXLat));
end;
constructor TXCoder.Load;
var
FName: PString;
begin
S.Read(KeyMap, SizeOf(KeyMap));
S.Read(MaxCodeTagLen, SizeOf(MaxCodeTagLen));
S.Read(CodeTag, SizeOf(CodeTag));
if KeyMap <> kmXlat then
UseKeyMap
else
begin
S.Read(XLatCP[ToAscii], SizeOf(TXLat));
UseToAscii;
end;
end;
procedure TXCoder.UseToAscii;
begin
KeyMap := kmXlat;
AcceptToAscii(XLatCP);
end;
procedure TXCoder.UseKeyMap;
begin
XLatCP := KeyMapDescr[KeyMap].XLatCP^;
CodeTag := KeyMapDescr[KeyMap].Tag;
end;
procedure TXCoder.LoadXlatTable; {JO}
var
FN: String;
More: Boolean;
None: Boolean;
Dr: String;
Nm: String;
Xt: String;
label
SkipMenu;
begin
More := True;
None := KeyMap = kmXlat;
if SkipXLatMenu then
goto SkipMenu;
FN := GetFileNameMenu(SourceDir+'XLT\', '*.XLT', FN, True, More, None);
if None then
begin
UseKeyMap;
Exit;
end;
if More then
SkipMenu:
FN := GetFileNameDialog(SourceDir+'XLT\*.XLT',
GetString(dlSelectXLT),
GetString(dlOpenFileName),
fdOKButton+fdHelpButton,
hsOpenXLT);
if BuildCodeTable(FN, XLatCP) then
begin
lFSplit(FN, Dr, Nm, Xt);
CodeTag := Cut(Nm, MaxCodeTagLen);
KeyMap := kmXlat;
end;
end { LoadXlatTable }; {JO}
procedure TXCoder.NextXLat;
begin
KeyMap := RollKeyMap[KeyMap];
UseKeyMap;
end;
procedure TXCoder.FromHistory(fKeyMap: TKeyMap;
fToAscii: TXLat; fCodeTag: Str8);
begin
KeyMap := fKeyMap;
CodeTag := fCodeTag;
XLatCP[ToAscii] := fToAscii;
if KeyMap = kmXlat then
UseToAscii
else
UseKeyMap;
end;
procedure TXCoder.ToHistory(var fKeyMap: TKeyMap;
var fToAscii: TXLat; var fCodeTag: Str8);
begin
fKeyMap := KeyMap;
fCodeTag := CodeTag;
fToAscii := XLatCP[ToAscii];
end;
end.