Subversion Repositories Kolibri OS

Rev

Rev 5915 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5915 Rev 6050
1
#ifndef AUTOBUILD
1
#ifndef AUTOBUILD
2
	#include "lang.h--"
2
	#include "lang.h--"
3
#endif
3
#endif
4
 
4
 
5
#define MEMSIZE 0x100000
5
#define MEMSIZE 0x100000
6
#include "..\lib\kolibri.h" 
6
#include "..\lib\kolibri.h" 
7
#include "..\lib\strings.h" 
7
#include "..\lib\strings.h" 
8
#include "..\lib\mem.h" 
8
#include "..\lib\mem.h" 
9
#include "..\lib\file_system.h"
9
#include "..\lib\file_system.h"
10
#include "..\lib\dll.h"
10
#include "..\lib\dll.h"
11
#include "..\lib\gui.h"
11
#include "..\lib\gui.h"
12
#include "..\lib\obj\iconv.h"
12
#include "..\lib\obj\iconv.h"
13
#include "..\lib\obj\box_lib.h"
13
#include "..\lib\obj\box_lib.h"
14
#include "..\lib\obj\proc_lib.h"
14
#include "..\lib\obj\proc_lib.h"
15
#include "..\lib\obj\libio_lib.h"
15
#include "..\lib\obj\libio_lib.h"
16
//#include "..\lib\obj\wword.h"
16
//#include "..\lib\obj\wword.h"
17
 
17
 
18
#ifdef LANG_RUS
18
#ifdef LANG_RUS
19
	?define T_FILE "” ©«"
19
	?define T_FILE "” ©«"
20
	?define T_TYPE "’¨¯"
20
	?define T_TYPE "’¨¯"
21
	?define T_SIZE " §¬¥à"
21
	?define T_SIZE " §¬¥à"
22
 
22
 
23
	?define MENU1 "” ©«"
23
	?define MENU1 "” ©«"
24
	?define MENU1_SUBMENU1 "Žâªàëâì"
24
	?define MENU1_SUBMENU1 "Žâªàëâì"
25
	?define MENU1_SUBMENU2 "‡ ªàëâì"
25
	?define MENU1_SUBMENU2 "‡ ªàëâì"
26
	?define MENU1_SUBMENU3 "‘¢®©á⢠"
26
	?define MENU1_SUBMENU3 "‘¢®©á⢠"
27
	?define MENU1_SUBMENU4 "‚ë室"
27
	?define MENU1_SUBMENU4 "‚ë室"
28
 
28
 
29
	?define MENU2 "Š®¤¨à®¢ª "
29
	?define MENU2 "Š®¤¨à®¢ª "
30
	?define MENU2_SUBMENU1 "UTF-8"
30
	?define MENU2_SUBMENU1 "UTF-8"
31
	?define MENU2_SUBMENU2 "KOI8-RU"
31
	?define MENU2_SUBMENU2 "KOI8-RU"
32
	?define MENU2_SUBMENU3 "CP1251"
32
	?define MENU2_SUBMENU3 "CP1251"
33
	?define MENU2_SUBMENU4 "CP1252"
33
	?define MENU2_SUBMENU4 "CP1252"
34
	?define MENU2_SUBMENU5 "ISO8859-5"
34
	?define MENU2_SUBMENU5 "ISO8859-5"
35
	?define MENU2_SUBMENU6 "CP866"
35
	?define MENU2_SUBMENU6 "CP866"
36
 
36
 
37
	?define ERROR_LOAD_BOX_LIB "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ - box_lib.obj"
37
	?define ERROR_LOAD_BOX_LIB "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ - box_lib.obj"
38
	?define ERROR_LOAD_LIBIO "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ - libio.obj"
38
	?define ERROR_LOAD_LIBIO "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ - libio.obj"
39
	?define ERROR_LOAD_PROC_LIB "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ - proc_lib.obj"
39
	?define ERROR_LOAD_PROC_LIB "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ - proc_lib.obj"
40
#else
40
#else
41
	?define T_FILE "File"
41
	?define T_FILE "File"
42
	?define T_TYPE "Type"
42
	?define T_TYPE "Type"
43
	?define T_SIZE "Size"
43
	?define T_SIZE "Size"
44
	?define MENU1 "File"
44
	?define MENU1 "File"
45
 
45
 
46
	?define MENU1_SUBMENU1 "Open"
46
	?define MENU1_SUBMENU1 "Open"
47
	?define MENU1_SUBMENU2 "Close"
47
	?define MENU1_SUBMENU2 "Close"
48
	?define MENU1_SUBMENU3 "Properties"
48
	?define MENU1_SUBMENU3 "Properties"
49
	?define MENU1_SUBMENU4 "Exit"
49
	?define MENU1_SUBMENU4 "Exit"
50
 
50
 
51
	?define MENU2 "Encoding"
51
	?define MENU2 "Encoding"
52
	?define MENU2_SUBMENU1 "UTF-8"
52
	?define MENU2_SUBMENU1 "UTF-8"
53
	?define MENU2_SUBMENU2 "KOI8-RU"
53
	?define MENU2_SUBMENU2 "KOI8-RU"
54
	?define MENU2_SUBMENU3 "CP1251"
54
	?define MENU2_SUBMENU3 "CP1251"
55
	?define MENU2_SUBMENU4 "CP1252"
55
	?define MENU2_SUBMENU4 "CP1252"
56
	?define MENU2_SUBMENU5 "ISO8859-5"
56
	?define MENU2_SUBMENU5 "ISO8859-5"
57
	?define MENU2_SUBMENU6 "CP866"
57
	?define MENU2_SUBMENU6 "CP866"
58
 
58
 
59
	?define ERROR_LOAD_BOX_LIB "Error while loading library - box_lib.obj"
59
	?define ERROR_LOAD_BOX_LIB "Error while loading library - box_lib.obj"
60
	?define ERROR_LOAD_LIBIO "Error while loading library - libio.obj"
60
	?define ERROR_LOAD_LIBIO "Error while loading library - libio.obj"
61
	?define ERROR_LOAD_PROC_LIB "Error while loading library - proc_lib.obj"
61
	?define ERROR_LOAD_PROC_LIB "Error while loading library - proc_lib.obj"
62
#endif
62
#endif
63
 
63
 
64
#ifdef LANG_RUS
64
#ifdef LANG_RUS
65
struct menu1_text_struct
65
struct menu1_text_struct
66
{
66
{
67
	char menu[5];
67
	char menu[5];
68
	char sub_menu1[8];
68
	char sub_menu1[8];
69
	char sub_menu2[8];
69
	char sub_menu2[8];
70
	//char sub_menu3[9];
70
	//char sub_menu3[9];
71
	char sub_menu4[6];
71
	char sub_menu4[6];
72
	byte end;
72
	byte end;
73
};
73
};
74
struct menu2_text_struct
74
struct menu2_text_struct
75
{
75
{
76
	char menu[10];
76
	char menu[10];
77
	char sub_menu1[6];
77
	char sub_menu1[6];
78
	char sub_menu2[8];
78
	char sub_menu2[8];
79
	char sub_menu3[7];
79
	char sub_menu3[7];
80
	char sub_menu4[7];
80
	char sub_menu4[7];
81
	char sub_menu5[10];
81
	char sub_menu5[10];
82
	char sub_menu6[6];
82
	char sub_menu6[6];
83
	byte end;
83
	byte end;
84
};
84
};
85
#else
85
#else
86
struct menu1_text_struct
86
struct menu1_text_struct
87
{
87
{
88
	char menu[5];
88
	char menu[5];
89
	char sub_menu1[5];
89
	char sub_menu1[5];
90
	char sub_menu2[6];
90
	char sub_menu2[6];
91
	//char sub_menu3[11];
91
	//char sub_menu3[11];
92
	char sub_menu4[5];
92
	char sub_menu4[5];
93
	byte end;
93
	byte end;
94
};
94
};
95
struct menu2_text_struct
95
struct menu2_text_struct
96
{
96
{
97
	char menu[9];
97
	char menu[9];
98
	char sub_menu1[6];
98
	char sub_menu1[6];
99
	char sub_menu2[8];
99
	char sub_menu2[8];
100
	char sub_menu3[7];
100
	char sub_menu3[7];
101
	char sub_menu4[7];
101
	char sub_menu4[7];
102
	char sub_menu5[10];
102
	char sub_menu5[10];
103
	char sub_menu6[6];
103
	char sub_menu6[6];
104
	byte end;
104
	byte end;
105
};
105
};
106
#endif
106
#endif
107
 
107
 
108
#define TITLE "Calypte v0.15"
108
#define TITLE "Calypte v0.15"
109
 
109
 
110
#define TOPPANELH 19
110
#define TOPPANELH 19
111
#define BOTPANELH 10
111
#define BOTPANELH 10
112
#define WIN_W 600
112
#define WIN_W 600
113
#define WIN_H 400
113
#define WIN_H 400
114
 
114
 
115
proc_info Form;
115
proc_info Form;
116
 
116
 
117
byte active_properties = 0;
117
byte active_properties = 0;
118
int encoding;
118
int encoding;
119
dword properties_window;
119
dword properties_window;
120
 
-
 
121
#include "include\gui.h"
120
 
122
#include "include\properties.h"
121
#include "include\properties.h"
123
 
122
 
124
struct filter
123
struct filter
125
{
124
{
126
	dword size;
125
	dword size;
127
	char ext1[4];
126
	char ext1[4];
128
	//char ext2[4];
127
	//char ext2[4];
129
	//char ext3[4];
128
	//char ext3[4];
130
	//char ext4[4];
129
	//char ext4[4];
131
	byte end;
130
	byte end;
132
};
131
};
133
 
132
 
134
filter filter2;
133
filter filter2;
135
menu1_text_struct menu1_text_area1;
134
menu1_text_struct menu1_text_area1;
136
menu2_text_struct menu2_text_area2;
135
menu2_text_struct menu2_text_area2;
137
 
136
 
138
char win_title[4096] = "Calypte v0.15";
137
char win_title[4096] = "Calypte v0.15";
139
 
138
 
140
int
139
int
141
	cur_row=0,
140
	cur_row=0,
142
	read=0,
141
	read=0,
143
	pos=0,
142
	pos=0,
144
	row_num=0,
143
	row_num=0,
145
	col_count=0,
144
	col_count=0,
146
	row_count=0;	
145
	row_count=0;	
147
	
146
	
148
dword old_width,old_height;
147
dword old_width,old_height;
149
 
148
 
150
proc_info pr_inf;
149
proc_info pr_inf;
151
char communication_area_name[] = "FFFFFFFF_open_dialog";
150
char communication_area_name[] = "FFFFFFFF_open_dialog";
152
byte plugin_path[4096];
151
byte plugin_path[4096];
153
char default_dir[] = "/rd/1";
152
char default_dir[] = "/rd/1";
154
char open_dialog_path[] = "/rd/1/File managers/opendial"; //opendial
153
char open_dialog_path[] = "/rd/1/File managers/opendial"; //opendial
155
byte openfile_path[2048];
154
byte openfile_path[2048];
156
byte filename_area[4096];
155
byte filename_area[4096];
157
 
156
 
158
opendialog o_dialog = {0, #pr_inf, #communication_area_name, 0, #plugin_path, #default_dir, #open_dialog_path, #draw_window, 0, #openfile_path, #filename_area, #filter2, 420, 200, 320, 120};
157
opendialog o_dialog = {0, #pr_inf, #communication_area_name, 0, #plugin_path, #default_dir, #open_dialog_path, #draw_window, 0, #openfile_path, #filename_area, #filter2, 420, 200, 320, 120};
159
 
158
 
160
dword bufpointer;
159
dword bufpointer;
161
dword bufsize;
160
dword bufsize;
162
dword draw_sruct;
161
dword draw_sruct;
163
 
162
 
164
menu_data menudata1 = {0, 40, 2, 15, 2, #menu1_text_area1.menu, #menu1_text_area1.sub_menu1, #menu1_text_area1.end, 0, 0, 80, 2, 100, 18, 0xEEEEEE, 0xFF, 0xEEEEEE, 0, 0, 0, #Form, 0, 0, 0, 16, 0, 0, 0x00CC00, 0, 0xFFFFFF, 0, 8, 0, 0};
163
menu_data menudata1 = {0, 40, 2, 15, 2, #menu1_text_area1.menu, #menu1_text_area1.sub_menu1, #menu1_text_area1.end, 0, 0, 80, 2, 100, 18, 0xEEEEEE, 0xFF, 0xEEEEEE, 0, 0, 0, #Form, 0, 0, 0, 16, 0, 0, 0x00CC00, 0, 0xFFFFFF, 0, 8, 0, 0};
165
menu_data menudata2 = {0, 70, 44, 15, 2, #menu2_text_area2.menu, #menu2_text_area2.sub_menu1, #menu2_text_area2.end, 0, 0, 80, 44, 100, 18, 0xEEEEEE, 0xFF, 0xEEEEEE, 0, 0, 0, #Form, 0, 0, 0, 16, 0, 0, 0x00CC00, 0, 0xFFFFFF, 0, 8, 0, 0};
164
menu_data menudata2 = {0, 70, 44, 15, 2, #menu2_text_area2.menu, #menu2_text_area2.sub_menu1, #menu2_text_area2.end, 0, 0, 80, 44, 100, 18, 0xEEEEEE, 0xFF, 0xEEEEEE, 0, 0, 0, #Form, 0, 0, 0, 16, 0, 0, 0x00CC00, 0, 0xFFFFFF, 0, 8, 0, 0};
166
 
165
 
167
void main()
166
void main()
168
{   
167
{   
169
	int id;
168
	int id;
170
	
169
	
171
	strcpy(#filter2.ext1, "TXT");
170
	strcpy(#filter2.ext1, "TXT");
172
	//strcpy(#filter2.ext2, "ASM");
171
	//strcpy(#filter2.ext2, "ASM");
173
	//strcpy(#filter2.ext3, "INC\0");
172
	//strcpy(#filter2.ext3, "INC\0");
174
	//strcpy(#filter2.ext4, "\0");
173
	//strcpy(#filter2.ext4, "\0");
175
	filter2.size = 8;
174
	filter2.size = 8;
176
	filter2.end = 0;
175
	filter2.end = 0;
177
 
176
 
178
	strcpy(#menu1_text_area1.menu, MENU1);
177
	strcpy(#menu1_text_area1.menu, MENU1);
179
	strcpy(#menu1_text_area1.sub_menu1, MENU1_SUBMENU1);
178
	strcpy(#menu1_text_area1.sub_menu1, MENU1_SUBMENU1);
180
	strcpy(#menu1_text_area1.sub_menu2, MENU1_SUBMENU2);
179
	strcpy(#menu1_text_area1.sub_menu2, MENU1_SUBMENU2);
181
	//strcpy(#menu1_text_area1.sub_menu3, MENU1_SUBMENU3);
180
	//strcpy(#menu1_text_area1.sub_menu3, MENU1_SUBMENU3);
182
	strcpy(#menu1_text_area1.sub_menu4, MENU1_SUBMENU4);
181
	strcpy(#menu1_text_area1.sub_menu4, MENU1_SUBMENU4);
183
	menu1_text_area1.end = 0;
182
	menu1_text_area1.end = 0;
184
	
183
	
185
	strcpy(#menu2_text_area2.menu, MENU2);
184
	strcpy(#menu2_text_area2.menu, MENU2);
186
	strcpy(#menu2_text_area2.sub_menu1, MENU2_SUBMENU1);
185
	strcpy(#menu2_text_area2.sub_menu1, MENU2_SUBMENU1);
187
	strcpy(#menu2_text_area2.sub_menu2, MENU2_SUBMENU2);
186
	strcpy(#menu2_text_area2.sub_menu2, MENU2_SUBMENU2);
188
	strcpy(#menu2_text_area2.sub_menu3, MENU2_SUBMENU3);
187
	strcpy(#menu2_text_area2.sub_menu3, MENU2_SUBMENU3);
189
	strcpy(#menu2_text_area2.sub_menu4, MENU2_SUBMENU4);
188
	strcpy(#menu2_text_area2.sub_menu4, MENU2_SUBMENU4);
190
	strcpy(#menu2_text_area2.sub_menu5, MENU2_SUBMENU5);
189
	strcpy(#menu2_text_area2.sub_menu5, MENU2_SUBMENU5);
191
	strcpy(#menu2_text_area2.sub_menu6, MENU2_SUBMENU6);
190
	strcpy(#menu2_text_area2.sub_menu6, MENU2_SUBMENU6);
192
	menu2_text_area2.end = 0;
191
	menu2_text_area2.end = 0;
193
	
192
	
194
	//mem_Init();
193
	//mem_Init();
195
	load_dll(boxlib, #box_lib_init,0);
194
	load_dll(boxlib, #box_lib_init,0);
196
	load_dll(libio, #libio_init,1);
195
	load_dll(libio, #libio_init,1);
197
	load_dll(iconv_lib, #iconv_open,0);
196
	load_dll(iconv_lib, #iconv_open,0);
198
	load_dll(Proc_lib, #OpenDialog_init,0);
197
	load_dll(Proc_lib, #OpenDialog_init,0);
199
	OpenDialog_init stdcall (#o_dialog);
198
	OpenDialog_init stdcall (#o_dialog);
200
	
199
	
201
	SetEventMask(0x27);
200
	SetEventMask(0x27);
202
	loop()
201
	loop()
203
	{
202
	{
204
      switch(WaitEvent())
203
      switch(WaitEvent())
205
      {
204
      {
206
		case evMouse:
205
		case evMouse:
207
			menu_bar_mouse stdcall (#menudata1);
206
			menu_bar_mouse stdcall (#menudata1);
208
			menu_bar_mouse stdcall (#menudata2);
207
			menu_bar_mouse stdcall (#menudata2);
209
			if (menudata1.click==1)
208
			if (menudata1.click==1)
210
			{
209
			{
211
				switch(menudata1.cursor_out)
210
				switch(menudata1.cursor_out)
212
				{
211
				{
213
					case 1:
212
					case 1:
214
						OpenDialog_start stdcall (#o_dialog);
213
						OpenDialog_start stdcall (#o_dialog);
215
						OpenFile(#openfile_path);
214
						OpenFile(#openfile_path);
216
						Prepare();
215
						Prepare();
217
						draw_window();
216
						draw_window();
218
						break;
217
						break;
219
					case 2:
218
					case 2:
220
						read = 0;
219
						read = 0;
221
						strcpy(#win_title, TITLE);
220
						strcpy(#win_title, TITLE);
222
						FreeBuf();
221
						FreeBuf();
223
						draw_window();
222
						draw_window();
224
						break;
223
						break;
225
					case 3:
224
					case 3:
226
						if (!active_properties) 
225
						if (!active_properties) 
227
						{
226
						{
228
							SwitchToAnotherThread();
227
							SwitchToAnotherThread();
229
							properties_window = CreateThread(#properties_dialog, #properties_stak+4092);
228
							properties_window = CreateThread(#properties_dialog, #properties_stak+4092);
230
							break;
229
							break;
231
						}
230
						}
232
						else
231
						else
233
						{
232
						{
234
							ActivateWindow(GetProcessSlot(properties_window));
233
							ActivateWindow(GetProcessSlot(properties_window));
235
						}
234
						}
236
						break;
235
						break;
237
					case 4:
236
					case 4:
238
						ExitProcess();
237
						ExitProcess();
239
				}
238
				}
240
			}
239
			}
241
			if (menudata2.click==1)
240
			if (menudata2.click==1)
242
			{
241
			{
243
				encoding = menudata2.cursor_out - 1;
242
				encoding = menudata2.cursor_out - 1;
244
				OpenFile(#openfile_path);
243
				OpenFile(#openfile_path);
245
				Prepare();
244
				Prepare();
246
				draw_window();
245
				draw_window();
247
			}
246
			}
248
			break;
247
			break;
249
		
248
		
250
        case evButton:
249
        case evButton:
251
			id=GetButtonID();               
250
			id=GetButtonID();               
252
            if (id==1) || (id==10) ExitProcess();
251
            if (id==1) || (id==10) ExitProcess();
253
			break;
252
			break;
254
		
253
		
255
        case evKey:
254
        case evKey:
256
            GetKeys();
255
            GetKeys();
257
			if (TestBit(key_modifier, 2))
256
			if (TestBit(key_modifier, 2))
258
			{
257
			{
259
				switch(key_scancode)
258
				switch(key_scancode)
260
				{
259
				{
261
					case 024:  //Ctrl+O
260
					case 024:  //Ctrl+O
262
						OpenDialog_start stdcall (#o_dialog);
261
						OpenDialog_start stdcall (#o_dialog);
263
						OpenFile(#openfile_path);
262
						OpenFile(#openfile_path);
264
						Prepare();
263
						Prepare();
265
						draw_window();
264
						draw_window();
266
						break;
265
						break;
267
				}
266
				}
268
				break;
267
				break;
269
			}
268
			}
270
			switch (key_scancode)
269
			switch (key_scancode)
271
			{
270
			{
272
				if (Form.status_window>2) break;
271
				if (Form.status_window>2) break;
273
				case SCAN_CODE_HOME:
272
				case SCAN_CODE_HOME:
274
					cur_row = 0;
273
					cur_row = 0;
275
					DrawText();
274
					DrawText();
276
					break;
275
					break;
277
				case SCAN_CODE_END:
276
				case SCAN_CODE_END:
278
					cur_row = row_num - row_count - 1;
277
					cur_row = row_num - row_count - 1;
279
					DrawText();
278
					DrawText();
280
					break;
279
					break;
281
				case SCAN_CODE_UP:
280
				case SCAN_CODE_UP:
282
					if (!cur_row) break;
281
					if (!cur_row) break;
283
					else cur_row = cur_row-1;
282
					else cur_row = cur_row-1;
284
					DrawText();
283
					DrawText();
285
					break;
284
					break;
286
				case SCAN_CODE_DOWN:
285
				case SCAN_CODE_DOWN:
287
					if (cur_row+row_count>=row_num) break;
286
					if (cur_row+row_count>=row_num) break;
288
					cur_row = cur_row+1;
287
					cur_row = cur_row+1;
289
					DrawText();
288
					DrawText();
290
					break;
289
					break;
291
				case SCAN_CODE_PGUP:
290
				case SCAN_CODE_PGUP:
292
					if (!cur_row) break;
291
					if (!cur_row) break;
293
					if (cur_row
292
					if (cur_row
294
					else cur_row = cur_row-row_count;
293
					else cur_row = cur_row-row_count;
295
					DrawText();
294
					DrawText();
296
					break;
295
					break;
297
				case SCAN_CODE_PGDN:
296
				case SCAN_CODE_PGDN:
298
					if (cur_row+row_count>row_num) break;
297
					if (cur_row+row_count>row_num) break;
299
					cur_row = cur_row+row_count;
298
					cur_row = cur_row+row_count;
300
					DrawText();
299
					DrawText();
301
					break;
300
					break;
302
			}
301
			}
303
			break;
302
			break;
304
         
303
         
305
         case evReDraw:
304
         case evReDraw:
306
			draw_window();
305
			draw_window();
307
			break;
306
			break;
308
      }
307
      }
309
   }
308
   }
310
}
309
}
311
 
310
 
312
 
311
 
313
void draw_window()
312
void draw_window()
314
{
313
{
315
	system.color.get();
314
	system.color.get();
316
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title);
315
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title);
317
	GetProcessInfo(#Form, SelfInfo);
316
	GetProcessInfo(#Form, SelfInfo);
318
	DrawBar(0, 0, Form.cwidth, TOPPANELH, system.color.work);
317
	DrawBar(0, 0, Form.cwidth, TOPPANELH, system.color.work);
319
	DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, system.color.work);
318
	DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, system.color.work);
320
	
319
	
321
	menudata1.bckg_col = system.color.work;
320
	menudata1.bckg_col = system.color.work;
322
	menudata2.bckg_col = system.color.work;
321
	menudata2.bckg_col = system.color.work;
323
	menu_bar_draw stdcall (#menudata1);
322
	menu_bar_draw stdcall (#menudata1);
324
	menu_bar_draw stdcall (#menudata2);
323
	menu_bar_draw stdcall (#menudata2);
325
	
324
	
326
	if (old_width!=Form.width) || (old_height!=Form.height)
325
	if (old_width!=Form.width) || (old_height!=Form.height)
327
	{
326
	{
328
		old_width = Form.width;
327
		old_width = Form.width;
329
		old_height = Form.height;
328
		old_height = Form.height;
330
		
329
		
331
		col_count = Form.cwidth/6;
330
		col_count = Form.cwidth/6;
332
		row_count = Form.cheight-BOTPANELH-TOPPANELH-2;
331
		row_count = Form.cheight-BOTPANELH-TOPPANELH-2;
333
		row_count = row_count/10;
332
		row_count = row_count/10;
334
	
333
	
335
		if (read==1) Prepare();
334
		if (read==1) Prepare();
336
	}
335
	}
337
	if (read==1) 
336
	if (read==1) 
338
	{
337
	{
339
		DrawText();
338
		DrawText();
340
	}
339
	}
341
	else DrawBar(0, TOPPANELH, Form.cwidth, Form.cheight-BOTPANELH-TOPPANELH, 0xFFFFFF);
340
	else DrawBar(0, TOPPANELH, Form.cwidth, Form.cheight-BOTPANELH-TOPPANELH, 0xFFFFFF);
342
}
341
}
343
 
342
 
344
void OpenFile(dword path)
343
void OpenFile(dword path)
345
{
344
{
346
	strcpy(#win_title, TITLE);
345
	strcpy(#win_title, TITLE);
347
	strcat(#win_title, " - ");
346
	strcat(#win_title, " - ");
348
	strcat(#win_title, path);
347
	strcat(#win_title, path);
349
	file_size stdcall (path);
348
	file_size stdcall (path);
350
	bufsize = EBX;
349
	bufsize = EBX;
351
	if (bufsize)
350
	if (bufsize)
352
	{
351
	{
353
		mem_Free(bufpointer);
352
		mem_Free(bufpointer);
354
		bufpointer = mem_Alloc(bufsize);
353
		bufpointer = mem_Alloc(bufsize);
355
		ReadFile(0, bufsize, bufpointer, path);
354
		ReadFile(0, bufsize, bufpointer, path);
356
		read=1;
355
		read=1;
357
	}
356
	}
358
	if (encoding!=CH_CP866) ChangeCharset(charsets[encoding], "CP866", bufpointer);
357
	if (encoding!=CH_CP866) ChangeCharset(charsets[encoding], "CP866", bufpointer);
359
}
358
}
360
 
359
 
361
void FreeBuf()
360
void FreeBuf()
362
{
361
{
363
	int i;
362
	int i;
364
	for (i=0; i
363
	for (i=0; i
365
	{
364
	{
366
		mem_Free(DSDWORD[i*4+draw_sruct]);
365
		mem_Free(DSDWORD[i*4+draw_sruct]);
367
	}
366
	}
368
	mem_Free(draw_sruct);
367
	mem_Free(draw_sruct);
369
	mem_Free(bufpointer);
368
	mem_Free(bufpointer);
370
}
369
}
371
 
370
 
372
void Prepare()
371
void Prepare()
373
{
372
{
374
	int i, sub_pos;
373
	int i, sub_pos;
375
	int len_str = 0;
374
	int len_str = 0;
376
	byte do_eof = 0;
375
	byte do_eof = 0;
377
	word bukva[2];
376
	word bukva[2];
378
	dword address;
377
	dword address;
379
	row_num = 0;
378
	row_num = 0;
380
	while(1)
379
	while(1)
381
	{
380
	{
382
		while(1)
381
		while(1)
383
		{
382
		{
384
			bukva = DSBYTE[bufpointer+pos+len_str];
383
			bukva = DSBYTE[bufpointer+pos+len_str];
385
			if (bukva=='\0')
384
			if (bukva=='\0')
386
			{
385
			{
387
				do_eof = 1;
386
				do_eof = 1;
388
				break;
387
				break;
389
			}
388
			}
390
			if (bukva==0x0a) break;
389
			if (bukva==0x0a) break;
391
			else len_str++;
390
			else len_str++;
392
		}
391
		}
393
		if (len_str<=col_count)
392
		if (len_str<=col_count)
394
		{
393
		{
395
			pos=pos+len_str+1;
394
			pos=pos+len_str+1;
396
			row_num++;
395
			row_num++;
397
		}
396
		}
398
		else
397
		else
399
		{
398
		{
400
			pos=pos+col_count;
399
			pos=pos+col_count;
401
			row_num++;
400
			row_num++;
402
		}
401
		}
403
		len_str = 0;
402
		len_str = 0;
404
		if (do_eof) break;
403
		if (do_eof) break;
405
	}
404
	}
406
	mem_Free(draw_sruct);
405
	mem_Free(draw_sruct);
407
	draw_sruct = mem_Alloc(row_num*4);
406
	draw_sruct = mem_Alloc(row_num*4);
408
	pos=0;
407
	pos=0;
409
	sub_pos=0;
408
	sub_pos=0;
410
	len_str = 0;
409
	len_str = 0;
411
	do_eof = 0;
410
	do_eof = 0;
412
	while(1)
411
	while(1)
413
	{
412
	{
414
		while(1)
413
		while(1)
415
		{
414
		{
416
			bukva = DSBYTE[bufpointer+pos+len_str];
415
			bukva = DSBYTE[bufpointer+pos+len_str];
417
			if (bukva=='\0')
416
			if (bukva=='\0')
418
			{
417
			{
419
				do_eof = 1;
418
				do_eof = 1;
420
				break;
419
				break;
421
			}
420
			}
422
			if (bukva==0x0a) break;
421
			if (bukva==0x0a) break;
423
			else len_str++;
422
			else len_str++;
424
		}
423
		}
425
		if (len_str<=col_count)
424
		if (len_str<=col_count)
426
		{
425
		{
427
			address = mem_Alloc(len_str+1);
426
			address = mem_Alloc(len_str+1);
428
			ESDWORD[sub_pos*4+draw_sruct] = address;
427
			ESDWORD[sub_pos*4+draw_sruct] = address;
429
			strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, len_str);
428
			strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, len_str);
430
			pos=pos+len_str+1;
429
			pos=pos+len_str+1;
431
			sub_pos++;
430
			sub_pos++;
432
		}
431
		}
433
		else
432
		else
434
		{
433
		{
435
			address = mem_Alloc(len_str+1);
434
			address = mem_Alloc(len_str+1);
436
			ESDWORD[sub_pos*4+draw_sruct] = address;
435
			ESDWORD[sub_pos*4+draw_sruct] = address;
437
			strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, col_count);
436
			strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, col_count);
438
			pos=pos+col_count;
437
			pos=pos+col_count;
439
			sub_pos++;
438
			sub_pos++;
440
		}
439
		}
441
		len_str = 0;
440
		len_str = 0;
442
		if (pos>=bufsize-1) break;
441
		if (pos>=bufsize-1) break;
443
	}
442
	}
444
	pos=0;
443
	pos=0;
445
}
444
}
446
 
445
 
447
void DrawText()
446
void DrawText()
448
{
447
{
449
	int i, top, num_line;
448
	int i, top, num_line;
450
	if (row_num
449
	if (row_num
451
	else
450
	else
452
	{
451
	{
453
		if (row_num-cur_row<=row_count) top = row_num-cur_row-1;
452
		if (row_num-cur_row<=row_count) top = row_num-cur_row-1;
454
		else top = row_count;
453
		else top = row_count;
455
	}
454
	}
456
	DrawBar(0, TOPPANELH, Form.cwidth, 3, 0xFFFFFF);
455
	DrawBar(0, TOPPANELH, Form.cwidth, 3, 0xFFFFFF);
457
	for (i=0, num_line = cur_row; i
456
	for (i=0, num_line = cur_row; i
458
	{
457
	{
459
		DrawBar(0, i*10+TOPPANELH+3, Form.cwidth, 10, 0xFFFFFF);
458
		DrawBar(0, i*10+TOPPANELH+3, Form.cwidth, 10, 0xFFFFFF);
460
		WriteText(2, i*10+TOPPANELH+3, 0x80, 0x000000, DSDWORD[num_line*4+draw_sruct]);
459
		WriteText(2, i*10+TOPPANELH+3, 0x80, 0x000000, DSDWORD[num_line*4+draw_sruct]);
461
	}
460
	}
462
	DrawBar(0, i*10+TOPPANELH+3, Form.cwidth, -i*10-TOPPANELH-BOTPANELH+Form.cheight, 0xFFFFFF);
461
	DrawBar(0, i*10+TOPPANELH+3, Form.cwidth, -i*10-TOPPANELH-BOTPANELH+Form.cheight, 0xFFFFFF);
463
}
462
}
464
 
463
 
465
stop:
464
stop:
466
char properties_stak[4096];
465
char properties_stak[4096];
467
>
466
>
468
>
467
>