-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.c
292 lines (274 loc) · 7.97 KB
/
setup.c
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/**
* @namespace biew
* @file setup.c
* @brief This file contains BIEW setup.
* @version -
* @remark this source file is part of Binary vIEW project (BIEW).
* The Binary vIEW (BIEW) is copyright (C) 1995 Nickols_K.
* All rights reserved. This software is redistributable under the
* licence given in the file "Licence.en" ("Licence.ru" in russian
* translation) distributed in the BIEW archive.
* @note Requires POSIX compatible development system
*
* @author Nickols_K
* @since 1999
* @note Development, fixes and improvements
**/
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include "beyehelp.h"
#include "colorset.h"
#include "setup.h"
#include "bconsole.h"
#include "beyeutil.h"
#include "libbeye/twin.h"
#include "libbeye/kbd_code.h"
extern char biew_help_name[];
extern char biew_skin_name[];
extern char biew_syntax_name[];
extern char biew_codepage[];
extern unsigned long biew_vioIniFlags;
extern unsigned long biew_twinIniFlags;
extern unsigned long biew_kbdFlags;
extern tBool iniSettingsAnywhere;
extern tBool fioUseMMF;
extern tBool iniPreserveTime;
extern tBool iniUseExtProgs;
#ifdef __QNX4__
extern int photon,bit7;
#endif
char * biewGetHelpName( void )
{
if(!biew_help_name[0])
{
strcpy(biew_help_name,__get_rc_dir("biew"));
strcat(biew_help_name,"biew.hlp");
}
return biew_help_name;
}
static char * __NEAR__ __FASTCALL__ biewGetColorSetName( void )
{
if(!biew_skin_name[0])
{
strcpy(biew_skin_name,__get_rc_dir("biew"));
strcat(biew_skin_name,"skn/" "standard.skn"); /* [dBorca] in skn/ subdir */
}
return biew_skin_name;
}
static char * __NEAR__ __FASTCALL__ biewGetSyntaxName( void )
{
if(!biew_syntax_name[0])
{
strcpy(biew_syntax_name,__get_rc_dir("biew"));
strcat(biew_syntax_name,"syntax/" "syntax.stx"); /* [dBorca] in syntax/ subdir */
}
return biew_syntax_name;
}
static const char * setuptxt[] =
{
"Help ",
"Consol",
"Color ",
"Mouse ",
"Bit ",
"Plugin",
"MMF ",
"Time ",
"ExtPrg",
"Escape"
};
static unsigned default_cp = 15;
static const char * cp_list[] =
{
"CP437 - original IBM PC Latin US",
"CP708 - Arabic language",
"CP737 - Greek language",
"CP775 - Baltic languages",
"CP850 - IBM PC MSDOS Latin-1",
"CP851 - IBM PC Greek-1",
"CP852 - Central European languages (Latin-2)",
"CP855 - Serbian language",
"CP857 - Turkish language",
"CP858 - Western European languages",
"CP860 - Portuguese language",
"CP861 - Icelandic language",
"CP862 - Hebrew language",
"CP863 - French language",
"CP865 - Nordic languages",
"CP866 - Cyrillic languages",
"CP869 - IBM PC Greek-2",
};
static tBool __FASTCALL__ select_codepage( void )
{
unsigned nModes;
int i;
nModes = sizeof(cp_list)/sizeof(char *);
i = SelBoxA(cp_list,nModes," Select single-byte codepage: ",default_cp);
if(i != -1)
{
unsigned len;
char *p;
default_cp = i;
p = strchr(cp_list[i],' ');
len = p-cp_list[i];
memcpy(biew_codepage,cp_list[i],len);
biew_codepage[len] = '\0';
return True;
}
return False;
}
static void drawSetupPrompt( void )
{
__drawSinglePrompt(setuptxt);
}
static void __NEAR__ __FASTCALL__ setup_paint( TWindow *twin )
{
TWindow *usd;
usd = twUsedWin();
twUseWin(twin);
twSetColorAttr(dialog_cset.group.active);
twGotoXY(2,9);
twPrintF(" [%c] - Direct console access "
,GetBool((biew_vioIniFlags & __TVIO_FLG_DIRECT_CONSOLE_ACCESS) == __TVIO_FLG_DIRECT_CONSOLE_ACCESS));
twGotoXY(2,10);
twPrintF(" [%c] - Mouse sensitivity "
,GetBool((biew_kbdFlags & KBD_NONSTOP_ON_MOUSE_PRESS) == KBD_NONSTOP_ON_MOUSE_PRESS));
twGotoXY(2,11);
twPrintF(" [%c] - Force mono "
,GetBool((biew_twinIniFlags & TWIF_FORCEMONO) == TWIF_FORCEMONO));
twGotoXY(2,12);
#ifdef __QNX4__
if(photon)
{
twSetColorAttr(dialog_cset.group.disabled);
twPrintF(" [%c] - Force 7-bit output "
,GetBool(bit7));
twSetColorAttr(dialog_cset.group.active);
}
else
#endif
twPrintF(" [%c] - Force 7-bit output "
,GetBool((biew_vioIniFlags & __TVIO_FLG_USE_7BIT) == __TVIO_FLG_USE_7BIT));
twGotoXY(32,9);
twPrintF(" [%c] - Apply plugin settings to all files "
,GetBool(iniSettingsAnywhere));
twGotoXY(32,10);
if(!__mmfIsWorkable()) twSetColorAttr(dialog_cset.group.disabled);
twPrintF(" [%c] - Use MMF "
,GetBool(fioUseMMF));
twSetColorAttr(dialog_cset.group.active);
twGotoXY(32,11);
twPrintF(" [%c] - Preserve timestamp "
,GetBool(iniPreserveTime));
twGotoXY(32,12);
twPrintF(" [%c] - Enable usage of external programs "
,GetBool(iniUseExtProgs));
twSetColorAttr(dialog_cset.main);
twGotoXY(50,7); twPutS(biew_codepage);
twUseWin(usd);
}
void Setup(void)
{
tAbsCoord x1,y1,x2,y2;
tRelCoord X1,Y1,X2,Y2;
int ret;
TWindow * wdlg,*ewnd[4];
char estr[3][FILENAME_MAX+1];
int active = 0;
strcpy(estr[0],biewGetHelpName());
strcpy(estr[1],biewGetColorSetName());
strcpy(estr[2],biewGetSyntaxName());
wdlg = CrtDlgWndnls(" Setup ",78,13);
twGetWinPos(wdlg,&x1,&y1,&x2,&y2);
X1 = x1;
Y1 = y1;
X2 = x2;
Y2 = y2;
X1 += 2;
X2 -= 1;
Y1 += 2;
Y2 = Y1;
ewnd[0] = CreateEditor(X1,Y1,X2,Y2,TWS_CURSORABLE | TWS_NLSOEM);
twShowWin(ewnd[0]);
twUseWin(ewnd[0]);
PostEvent(KE_ENTER);
xeditstring(estr[0],NULL,sizeof(estr[0]), NULL);
Y1 += 2;
Y2 = Y1;
ewnd[1] = CreateEditor(X1,Y1,X2,Y2,TWS_CURSORABLE | TWS_NLSOEM);
twShowWin(ewnd[1]);
twUseWin(ewnd[1]);
PostEvent(KE_ENTER);
xeditstring(estr[1],NULL,sizeof(estr[1]), NULL);
Y1 += 2;
Y2 = Y1;
ewnd[2] = CreateEditor(X1,Y1,X2,Y2,TWS_CURSORABLE | TWS_NLSOEM);
twShowWin(ewnd[2]);
twUseWin(ewnd[2]);
PostEvent(KE_ENTER);
xeditstring(estr[2],NULL,sizeof(estr[2]), NULL);
Y1 += 2;
Y2 = Y1;
ewnd[3] = WindowOpen(60,Y1,61,Y2,TWS_NLSOEM);
twUseWin(wdlg);
twGotoXY(2,1); twPutS("Enter help file name (including full path):");
twGotoXY(2,3); twPutS("Enter color skin name (including full path):");
twGotoXY(2,5); twPutS("Enter syntax name (including full path):");
twGotoXY(2,7); twPutS("Enter OEM codepage (for utf-based terminals):");
twSetFooterAttr(wdlg," [Enter] - Accept changes ",TW_TMODE_CENTER,dialog_cset.footer);
twinDrawFrameAttr(1,8,78,13,TW_UP3D_FRAME,dialog_cset.main);
setup_paint(wdlg);
active = 0;
twUseWin(ewnd[active]);
while(1)
{
if(active==3) {
if(select_codepage() == True) setup_paint(wdlg);
ret = KE_TAB;
}
else ret = xeditstring(estr[active],NULL,sizeof(estr[active]),drawSetupPrompt);
switch(ret)
{
case KE_F(10):
case KE_ESCAPE: ret = 0; goto exit;
case KE_ENTER: ret = 1; goto exit;
case KE_SHIFT_TAB:
case KE_TAB: active++;
if(active>3) active=0;
twUseWin(ewnd[active]);
continue;
case KE_F(1): hlpDisplay(5);
break;
case KE_F(2): biew_vioIniFlags ^= __TVIO_FLG_DIRECT_CONSOLE_ACCESS;
break;
case KE_F(3): biew_twinIniFlags ^= TWIF_FORCEMONO ;
break;
case KE_F(4): biew_kbdFlags ^= KBD_NONSTOP_ON_MOUSE_PRESS;
break;
case KE_F(5): biew_vioIniFlags ^= __TVIO_FLG_USE_7BIT;
break;
case KE_F(6): iniSettingsAnywhere = iniSettingsAnywhere ? False : True;
break;
case KE_F(7): if(__mmfIsWorkable()) fioUseMMF = fioUseMMF ? False : True;
break;
case KE_F(8): iniPreserveTime = iniPreserveTime ? False : True;
break;
case KE_F(9): iniUseExtProgs = iniUseExtProgs ? False : True;
break;
default: continue;
}
setup_paint(wdlg);
}
exit:
if(ret)
{
strcpy(biew_help_name,estr[0]);
strcpy(biew_skin_name,estr[1]);
strcpy(biew_syntax_name,estr[2]);
}
CloseWnd(ewnd[0]);
CloseWnd(ewnd[1]);
CloseWnd(ewnd[2]);
CloseWnd(wdlg);
}