Subversion Repositories Kolibri OS

Rev

Rev 6746 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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