Subversion Repositories Kolibri OS

Rev

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

Rev 7041 Rev 7043
1
//Calypte 0.3 - Leency
1
//Calypte 0.35 - Leency
2
//Calypte 0.15 - Punk Joker
2
//Calypte 0.15 - Punk Joker
3
 
3
 
4
#define MEMSIZE 1024*80
4
#define MEMSIZE 1024*100
5
 
5
 
6
#ifndef AUTOBUILD
6
#ifndef AUTOBUILD
7
	#include "lang.h--"
7
	#include "lang.h--"
8
#endif
8
#endif
9
 
9
 
10
 
10
 
11
//===================================================//
11
//===================================================//
12
//                                                   //
12
//                                                   //
13
//                       LIB                         //
13
//                       LIB                         //
14
//                                                   //
14
//                                                   //
15
//===================================================//
15
//===================================================//
16
 
16
 
17
#include "../lib/kolibri.h" 
17
#include "../lib/kolibri.h" 
18
#include "../lib/file_system.h"
18
#include "../lib/file_system.h"
19
#include "../lib/gui.h"
19
#include "../lib/gui.h"
20
#include "../lib/list_box.h"
20
#include "../lib/list_box.h"
21
#include "../lib/menu.h"
21
#include "../lib/menu.h"
-
 
22
//#include "../lib/collection.h"
-
 
23
 
22
 
24
 
-
 
25
#include "../lib/obj/iconv.h"
23
#include "../lib/obj/iconv.h"
26
#include "../lib/obj/box_lib.h"
24
//#include "../lib/obj/box_lib.h" //TO CHECK: boxlib doesn't work well with opendial
27
#include "../lib/obj/libio_lib.h" //TO CHECK: why opendial is a peace of shit!
25
#include "../lib/obj/proc_lib.h"
-
 
26
#include "../lib/obj/libio_lib.h"
28
#include "../lib/obj/proc_lib.h"
27
 
29
 
28
#include "../lib/patterns/simple_open_dialog.h"
30
#include "../lib/patterns/simple_open_dialog.h"
-
 
31
 
29
 
32
 
30
char default_dir[] = "/rd/1";
33
char default_dir[] = "/rd/1";
31
od_filter filter2 = { "TXT",0};
34
od_filter filter2 = { "TXT",0};
32
 
35
 
33
//===================================================//
36
//===================================================//
34
//                                                   //
37
//                                                   //
35
//                       DATA                        //
38
//                       DATA                        //
36
//                                                   //
39
//                                                   //
37
//===================================================//
40
//===================================================//
38
 
41
 
39
/*=========  MENU  ==========*/
42
/*=========  MENU  ==========*/
40
?define MENU1 "File"
43
?define MENU1 "File"
41
?define MENU2 "Encoding"
44
?define MENU2 "Encoding"
42
?define MENU3 "Reopen"
45
?define MENU3 "Reopen"
43
 
46
 
44
char menu_file_list[] =
47
char menu_file_list[] =
45
"Open
48
"Open
46
Close
49
Close
47
Properties
50
Properties
48
Exit";
51
Exit";
49
 
52
 
50
char menu_encoding_list[] =
53
char menu_encoding_list[] =
51
"UTF-8
54
"UTF-8
52
KOI8-RU
55
KOI8-RU
53
CP1251
56
CP1251
54
CP1252
57
CP1252
55
ISO8859-5
58
ISO8859-5
56
CP866";
59
CP866";
57
 
60
 
58
char menu_reopen_list[] =
61
char menu_reopen_list[] =
59
"Tinypad
62
"Tinypad
60
TextEdit
63
TextEdit
61
TextRead
64
TextRead
62
WebView
65
WebView
63
FB2Read
66
FB2Read
64
HexView";
67
HexView";
65
 
68
 
66
enum {
69
enum {
67
	MENU_ID_FILE=10,
70
	MENU_ID_FILE=10,
68
	FILE_SUBMENU_ID_OPEN=10,
71
	FILE_SUBMENU_ID_OPEN=10,
69
	FILE_SUBMENU_ID_CLOSE,
72
	FILE_SUBMENU_ID_CLOSE,
70
	FILE_SUBMENU_ID_PROPERTIES,
73
	FILE_SUBMENU_ID_PROPERTIES,
71
	FILE_SUBMENU_ID_EXIT,
74
	FILE_SUBMENU_ID_EXIT,
72
 
75
 
73
	MENU_ID_ENCODING=20,
76
	MENU_ID_ENCODING=20,
74
 
77
 
75
	MENU_ID_REOPEN=30,
78
	MENU_ID_REOPEN=30,
76
	FILE_SUBMENU_ID_TINYPAD=30,
79
	FILE_SUBMENU_ID_TINYPAD=30,
77
	FILE_SUBMENU_ID_TEXTEDIT,
80
	FILE_SUBMENU_ID_TEXTEDIT,
78
	FILE_SUBMENU_ID_TEXTREAD,
81
	FILE_SUBMENU_ID_TEXTREAD,
79
	FILE_SUBMENU_ID_WEBVIEW,
82
	FILE_SUBMENU_ID_WEBVIEW,
80
	FILE_SUBMENU_ID_FB2READ,
83
	FILE_SUBMENU_ID_FB2READ,
81
	FILE_SUBMENU_ID_HEXVIEW
84
	FILE_SUBMENU_ID_HEXVIEW
82
};
85
};
83
 
86
 
84
int menu_file_x = 6;
87
int menu_file_x = 6;
85
int menu_encoding_x = NULL;
88
int menu_encoding_x = NULL;
86
int menu_reopen_x = NULL;
89
int menu_reopen_x = NULL;
87
/*======== MENU END ==========*/
90
/*======== MENU END ==========*/
88
 
91
 
89
#define TITLE "Calypte v0.3"
92
#define TITLE "Calypte v0.3"
90
char win_title[4096] = TITLE;
93
char win_title[4096] = TITLE;
91
 
94
 
92
#define TOPPANELH 23
95
#define TOPPANELH 23
93
#define BOTPANELH 10
96
#define BOTPANELH 10
94
#define WIN_W 750
97
#define WIN_W 750
95
#define WIN_H 550
98
#define WIN_H 550
-
 
99
#define SCROLL_SIZE 15
96
 
100
 
97
proc_info Form;
101
proc_info Form;
98
llist rows;
102
llist rows;
99
 
103
 
100
int encoding;
104
int encoding;
101
	
105
	
102
dword old_width,old_height;
106
dword old_width,old_height;
103
 
107
 
104
dword bufpointer;
108
dword bufpointer;
105
dword bufsize;
109
dword bufsize;
106
dword draw_sruct;
110
dword draw_sruct;
-
 
111
 
-
 
112
scroll_bar scroll_v = { SCROLL_SIZE,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
-
 
113
scroll_bar scroll_h = { SCROLL_SIZE,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
-
 
114
 
-
 
115
//collection s;
107
 
116
 
108
//===================================================//
117
//===================================================//
109
//                                                   //
118
//                                                   //
110
//                       CODE                        //
119
//                       CODE                        //
111
//                                                   //
120
//                                                   //
112
//===================================================//
121
//===================================================//
113
 
122
 
114
void InitDlls()
123
void InitDlls()
115
{
124
{
116
	//load_dll(boxlib,    #box_lib_init,   0);
125
	load_dll(boxlib,    #box_lib_init,   0);
117
	load_dll(libio,     #libio_init,     1);
126
	load_dll(libio,     #libio_init,     1);
118
	load_dll(iconv_lib, #iconv_open,     0);
127
	load_dll(iconv_lib, #iconv_open,     0);
119
	load_dll(Proc_lib,  #OpenDialog_init,0);
128
	load_dll(Proc_lib,  #OpenDialog_init,0);
120
	OpenDialog_init stdcall (#o_dialog);
129
	OpenDialog_init stdcall (#o_dialog);
121
}
130
}
122
 
131
 
123
void main()
132
void main()
124
{   
133
{   
125
	int id;
134
	int id;
126
 
135
 
127
	InitDlls();
136
	InitDlls();
128
	
137
	
129
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
138
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
130
	loop()
139
	loop()
131
	{
140
	{
132
	  switch(WaitEvent())
141
	  switch(WaitEvent())
133
	  {
142
	  {
134
		case evMouse:
143
		case evMouse:
135
			mouse.get();
144
			mouse.get();
136
			rows.wheel_size = 3;
145
			rows.wheel_size = 3;
137
			if (rows.MouseScroll(mouse.vert)) {
146
			if (rows.MouseScroll(mouse.vert)) {
138
				DrawText();
147
				DrawText();
139
				break; 
148
				break; 
140
			}
149
			}
141
			break;
150
			break;
142
		
151
		
143
		case evButton:
152
		case evButton:
144
			id=GetButtonID();               
153
			id=GetButtonID();               
145
			if (id==1) ExitProcess();
154
			if (id==1) ExitProcess();
146
			if (id==MENU_ID_FILE) menu.show(
155
			if (id==MENU_ID_FILE) 
147
				Form.left+5 + menu_file_x, 
156
				EventShowMenu(menu_file_x, #menu_file_list, MENU_ID_FILE, NULL);
148
				Form.top+skin_height + TOPPANELH, 
-
 
149
				140, 
-
 
150
				#menu_file_list, 
-
 
151
				MENU_ID_FILE);
-
 
152
 
-
 
153
			if (id==MENU_ID_ENCODING) menu.show(
157
			if (id==MENU_ID_ENCODING) 
154
				Form.left+5 + menu_encoding_x, 
158
				EventShowMenu(menu_encoding_x, #menu_encoding_list, MENU_ID_ENCODING, encoding+1);
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(
159
			if (id==MENU_ID_REOPEN) 
161
				Form.left+5 + menu_reopen_x, 
160
				EventShowMenu(menu_reopen_x, #menu_reopen_list, MENU_ID_REOPEN, NULL);
162
				Form.top+skin_height + TOPPANELH, 
-
 
163
				120, 
-
 
164
				#menu_reopen_list, 
-
 
165
				MENU_ID_REOPEN);
-
 
166
			break;
161
			break;
167
		
162
		
168
		case evKey:
163
		case evKey:
169
			GetKeys();
164
			GetKeys();
170
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
165
			if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL)
171
			{
166
			{
172
				if (key_scancode == SCAN_CODE_KEY_O) EventOpenFile();
167
				if (key_scancode == SCAN_CODE_KEY_O) EventOpenFile();
173
				break;
168
				break;
174
			}
169
			}
175
			if (rows.ProcessKey(key_scancode)) DrawText();
170
			if (rows.ProcessKey(key_scancode)) DrawText();
176
			break;
171
			break;
177
		 
172
		 
178
		 case evReDraw:
173
		 case evReDraw:
179
			if (menu.list.cur_y) {
174
			if (menu.list.cur_y) {
180
				if (menu.list.cur_y == FILE_SUBMENU_ID_OPEN) EventOpenFile();
175
				if (menu.list.cur_y == FILE_SUBMENU_ID_OPEN) EventOpenFile();
181
				if (menu.list.cur_y == FILE_SUBMENU_ID_CLOSE) EventCloseFile();
176
				if (menu.list.cur_y == FILE_SUBMENU_ID_CLOSE) EventCloseFile();
182
				if (menu.list.cur_y == FILE_SUBMENU_ID_PROPERTIES) EventShowFileProperties();
177
				if (menu.list.cur_y == FILE_SUBMENU_ID_PROPERTIES) EventShowFileProperties();
183
				if (menu.list.cur_y == FILE_SUBMENU_ID_EXIT) ExitProcess();
178
				if (menu.list.cur_y == FILE_SUBMENU_ID_EXIT) ExitProcess();
184
 
179
 
185
				if (menu.list.cur_y > MENU_ID_ENCODING) && (menu.list.cur_y < MENU_ID_ENCODING + 10) 
180
				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);
181
					EventChangeEncoding(menu.list.cur_y - MENU_ID_ENCODING);
187
 
182
 
188
				if (menu.list.cur_y == FILE_SUBMENU_ID_TINYPAD) ReopenFileIn("/sys/tinypad");
183
				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");
184
				if (menu.list.cur_y == FILE_SUBMENU_ID_TEXTEDIT) ReopenFileIn("/sys/develop/t_edit");
190
				if (menu.list.cur_y == FILE_SUBMENU_ID_TEXTREAD) ReopenFileIn("/sys/txtread");
185
				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");
186
				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");
187
				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");
188
				if (menu.list.cur_y == FILE_SUBMENU_ID_HEXVIEW) ReopenFileIn("/sys/develop/heed");
194
				
189
				
195
 
190
 
196
				menu.list.cur_y = 0;
191
				menu.list.cur_y = 0;
197
			};
192
			};
198
			draw_window();
193
			draw_window();
199
			break;
194
			break;
200
	  }
195
	  }
201
   }
196
   }
202
}
197
}
203
 
198
 
-
 
199
void ReopenFileIn(dword _app)
-
 
200
{
-
 
201
	RunProgram(_app, #param);
-
 
202
}
-
 
203
 
204
void ReopenFileIn(dword app)
204
void EventShowMenu(dword _menu_item_x, _menu_list, _id, _selected)
205
{
205
{
-
 
206
	menu.selected = _selected;
-
 
207
	menu.show(
-
 
208
	Form.left+5 + _menu_item_x, 
-
 
209
	Form.top+skin_height + TOPPANELH, 
-
 
210
	140, 
-
 
211
	_menu_list, 
206
	RunProgram(app, #param);
212
	_id);	
207
}
213
}
208
 
214
 
209
void EventOpenFile()
215
void EventOpenFile()
210
{
216
{
211
	OpenDialog_start stdcall (#o_dialog);
217
	OpenDialog_start stdcall (#o_dialog);
-
 
218
	if (!o_dialog.status) return;
212
	OpenFile(#openfile_path);
219
	OpenFile(#openfile_path);
213
	Prepare();
220
	Prepare();
214
	draw_window();
221
	draw_window();
215
}
222
}
216
 
223
 
217
void EventCloseFile()
224
void EventCloseFile()
218
{
225
{
-
 
226
	if (!bufpointer) return;
219
	strcpy(#win_title, TITLE);
227
	strcpy(#win_title, TITLE);
220
	FreeBuf();
228
	FreeBuf();
221
	draw_window();	
229
	draw_window();	
222
}
230
}
223
 
231
 
224
void EventShowFileProperties()
232
void EventShowFileProperties()
225
{
233
{
226
char ss_param[4096];
234
char ss_param[4096];
227
	if (!bufpointer) return;
235
	if (!bufpointer) return;
228
	sprintf(#ss_param, "-p %s", #param);
236
	sprintf(#ss_param, "-p %s", #param);
229
	RunProgram("/sys/File managers/Eolite", #ss_param);
237
	RunProgram("/sys/File managers/Eolite", #ss_param);
230
}
238
}
231
 
239
 
232
void EventChangeEncoding(dword id)
240
void EventChangeEncoding(dword id)
233
{
241
{
234
	encoding = id;
242
	encoding = id;
235
	OpenFile(#openfile_path);
243
	OpenFile(#openfile_path);
236
	Prepare();
244
	Prepare();
237
	draw_window();
245
	draw_window();
238
}
246
}
239
 
247
 
240
int DrawMenuButton(dword x,y,id,text)
248
int DrawMenuButton(dword x,y,id,text)
241
{
249
{
242
	int textlen = strlen(text)*8;
250
	int textlen = strlen(text)*8;
243
	int padding = 12;
251
	int padding = 12;
244
	DefineHiddenButton(x, y, textlen+padding+padding, TOPPANELH-2, id);
252
	DefineHiddenButton(x, y, textlen+padding+padding, TOPPANELH-2, id);
245
	WriteText(x+padding,y+4, 0x90, MixColors(system.color.work, system.color.work_text, 70), text);
253
	WriteText(x+padding,y+4, 0x90, MixColors(system.color.work, system.color.work_text, 70), text);
246
	return textlen+padding+padding;
254
	return textlen+padding+padding;
247
}
255
}
248
 
256
 
249
void draw_window()
257
void draw_window()
250
{
258
{
251
	system.color.get();
259
	system.color.get();
252
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title,0);
260
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2,WIN_W,WIN_H,0x73,0xFFFFFF,#win_title,0);
253
	GetProcessInfo(#Form, SelfInfo);
261
	GetProcessInfo(#Form, SelfInfo);
254
	DrawBar(0, 0, Form.cwidth, TOPPANELH-1, system.color.work);
262
	DrawBar(0, 0, Form.cwidth, TOPPANELH-1, system.color.work);
255
	DrawBar(0, TOPPANELH-1, Form.cwidth, 1, system.color.work_dark);
263
	DrawBar(0, TOPPANELH-1, Form.cwidth, 1, system.color.work_dark);
256
	DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, system.color.work);
264
	DrawBar(0, Form.cheight-BOTPANELH, Form.cwidth, BOTPANELH, system.color.work);
257
	
265
	
258
	menu_encoding_x = menu_file_x + DrawMenuButton(menu_file_x, 0, MENU_ID_FILE, MENU1);
266
	menu_encoding_x = menu_file_x + DrawMenuButton(menu_file_x, 0, MENU_ID_FILE, MENU1);
259
	menu_reopen_x = menu_encoding_x + DrawMenuButton(menu_encoding_x, 0, MENU_ID_ENCODING, MENU2);
267
	menu_reopen_x = menu_encoding_x + DrawMenuButton(menu_encoding_x, 0, MENU_ID_ENCODING, MENU2);
260
	DrawMenuButton(menu_reopen_x, 0, MENU_ID_REOPEN, MENU3);
268
	DrawMenuButton(menu_reopen_x, 0, MENU_ID_REOPEN, MENU3);
261
 
269
 
262
	if (old_width!=Form.width) || (old_height!=Form.height)
270
	if (old_width!=Form.width) || (old_height!=Form.height)
263
	{
271
	{
264
		old_width = Form.width;
272
		old_width = Form.width;
265
		old_height = Form.height;
273
		old_height = Form.height;
266
		
274
		
267
		rows.no_selection = true;
275
		rows.no_selection = true;
268
		rows.SetFont(8, 14, 0x90);
276
		rows.SetFont(8, 14, 0x90);
269
		rows.SetSizes(0, TOPPANELH, Form.cwidth, Form.cheight - TOPPANELH - BOTPANELH, 20);
277
		rows.SetSizes(0, TOPPANELH, Form.cwidth - SCROLL_SIZE, Form.cheight - TOPPANELH - BOTPANELH, 20);
270
		rows.column_max = rows.w / rows.font_w;
278
		rows.column_max = rows.w / rows.font_w;
271
 
279
 
272
		if (bufpointer) Prepare();
280
		if (bufpointer) Prepare();
273
		rows.CheckDoesValuesOkey();
281
		rows.CheckDoesValuesOkey();
274
	}
282
	}
275
	if (bufpointer) 
283
	DrawRectangle(rows.x+rows.w-1, rows.y, SCROLL_SIZE, rows.h-1, 0xEEEeee);
276
	{
-
 
277
		DrawText();
284
	DrawText();
278
	}
285
}
279
	else DrawBar(0, TOPPANELH, Form.cwidth, Form.cheight-BOTPANELH-TOPPANELH, 0xFFFFFF);
-
 
280
}
-
 
281
 
286
 
282
void OpenFile(dword _path)
287
void OpenFile(dword _path)
283
{
288
{
284
	strcpy(#param, _path);
289
	strcpy(#param, _path);
285
	sprintf(#win_title, "%s - %s", TITLE, #param);
290
	sprintf(#win_title, "%s - %s", TITLE, #param);
286
	rows.KeyHome();
291
	rows.KeyHome();
287
	file_size stdcall (#param);
292
	file_size stdcall (#param);
288
	bufsize = EBX;
293
	bufsize = EBX;
289
	if (bufsize)
294
	if (bufsize)
290
	{
295
	{
291
		bufpointer = mem_Free(bufpointer);
296
		bufpointer = mem_Free(bufpointer);
292
		bufpointer = mem_Alloc(bufsize);
297
		bufpointer = mem_Alloc(bufsize);
293
		if (ReadFile(0, bufsize, bufpointer, #param) != 0) {
298
		if (ReadFile(0, bufsize, bufpointer, #param) != 0) {
294
			bufpointer = 0;
299
			bufpointer = 0;
295
			notify("'Error opening file'-E");
300
			notify("'Error opening file'-E");
296
		}
301
		}
297
	}
302
	}
298
	if (encoding!=CH_CP866) ChangeCharset(charsets[encoding], "CP866", bufpointer);
303
	if (encoding!=CH_CP866) ChangeCharset(charsets[encoding], "CP866", bufpointer);
299
}
304
}
300
 
305
 
301
void FreeBuf()
306
void FreeBuf()
302
{
307
{
303
	int i;
308
	int i;
-
 
309
	if (!bufpointer) return;
304
	for (i=0; i
310
	for (i=0; i
305
	{
311
	{
306
		mem_Free(DSDWORD[i*4+draw_sruct]);
312
		mem_Free(DSDWORD[i*4+draw_sruct]);
307
	}
313
	}
308
	draw_sruct = mem_Free(draw_sruct);
314
	draw_sruct = mem_Free(draw_sruct);
309
	bufpointer = mem_Free(bufpointer);
315
	bufpointer = mem_Free(bufpointer);
310
}
316
}
311
 
317
 
312
enum {
318
enum {
313
	PARSE_CALCULATE_ROWS_COUNT,
319
	PARSE_CALCULATE_ROWS_COUNT,
314
	PARSE_DRAW_PREPARE,
320
	PARSE_DRAW_PREPARE,
315
};
321
};
316
void Parse(int mode)
322
void Parse(int mode)
317
{
323
{
318
	int pos=0;
324
	int pos=0;
319
	int sub_pos=0;
325
	int sub_pos=0;
320
	int len_str = 0;
326
	int len_str = 0;
321
	bool do_eof = false;
327
	bool do_eof = false;
322
	word bukva[2];
328
	word bukva[2];
323
 
329
 
324
	while(1)
330
	while(1)
325
	{
331
	{
326
		while(1)
332
		while(1)
327
		{
333
		{
328
			bukva = DSBYTE[bufpointer+pos+len_str];
334
			bukva = DSBYTE[bufpointer+pos+len_str];
329
			if (bukva=='\0')
335
			if (bukva=='\0')
330
			{
336
			{
331
				do_eof = true;
337
				do_eof = true;
332
				break;
338
				break;
333
			}
339
			}
334
			if (bukva==0x0a) break;
340
			if (bukva==0x0a) break;
335
			else len_str++;
341
			else len_str++;
336
		}
342
		}
337
		if (len_str<=rows.column_max) 
343
		if (len_str<=rows.column_max) 
338
		{
344
		{
339
			if (mode==PARSE_DRAW_PREPARE)
345
			if (mode==PARSE_DRAW_PREPARE)
340
			{
346
			{
341
				ESDWORD[sub_pos*4+draw_sruct] = mem_Alloc(len_str+1);
347
				ESDWORD[sub_pos*4+draw_sruct] = mem_Alloc(len_str+1);
342
				strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, len_str); //-1 to do not show \n symbol				
348
				strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, len_str); //-1 to do not show \n symbol				
343
			}
349
			}
344
			pos += len_str+1;
350
			pos += len_str+1;
345
		}
351
		}
346
		else
352
		else
347
		{
353
		{
348
			if (mode==PARSE_DRAW_PREPARE)
354
			if (mode==PARSE_DRAW_PREPARE)
349
			{
355
			{
350
				ESDWORD[sub_pos*4+draw_sruct] = mem_Alloc(len_str+1);
356
				ESDWORD[sub_pos*4+draw_sruct] = mem_Alloc(len_str+1);
351
				strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, rows.column_max);					
357
				strlcpy(DSDWORD[sub_pos*4+draw_sruct], bufpointer+pos, rows.column_max);					
352
			}
358
			}
353
			pos += rows.column_max;
359
			pos += rows.column_max;
354
		}
360
		}
355
		sub_pos++;
361
		sub_pos++;
356
		if (mode==PARSE_CALCULATE_ROWS_COUNT) if (do_eof) break;
362
		if (mode==PARSE_CALCULATE_ROWS_COUNT) if (do_eof) break;
357
		if (mode==PARSE_DRAW_PREPARE) if (pos>=bufsize-1) break;
363
		if (mode==PARSE_DRAW_PREPARE) if (pos>=bufsize-1) break;
358
		len_str = 0;
364
		len_str = 0;
359
	}
365
	}
360
	if (mode == PARSE_CALCULATE_ROWS_COUNT)
366
	if (mode == PARSE_CALCULATE_ROWS_COUNT)
361
	{
367
	{
362
		rows.count = sub_pos;
368
		rows.count = sub_pos;
363
		draw_sruct = mem_Free(draw_sruct);
369
		draw_sruct = mem_Free(draw_sruct);
364
		draw_sruct = mem_Alloc(rows.count*4);
370
		draw_sruct = mem_Alloc(rows.count*4);
365
		Parse(PARSE_DRAW_PREPARE);
371
		Parse(PARSE_DRAW_PREPARE);
366
 
372
 
367
	}
373
	}
368
}
374
}
369
 
375
 
370
void Prepare()
376
void Prepare()
371
{
377
{
372
	Parse(PARSE_CALCULATE_ROWS_COUNT);
378
	Parse(PARSE_CALCULATE_ROWS_COUNT);
373
}
379
}
374
 
380
 
375
void DrawText()
381
void DrawText()
376
{
382
{
377
	int i, top;
383
	int i=0, top;
378
 
384
 
379
	if (rows.count
385
	if (rows.count
380
	else
386
	else
381
	{
387
	{
382
		if (rows.count-rows.first<=rows.visible) top = rows.count-rows.first-1;
388
		if (rows.count-rows.first<=rows.visible) top = rows.count-rows.first-1;
383
		else top = rows.visible;
389
		else top = rows.visible;
384
	}
390
	}
385
 
391
 
386
	for (i=0; i
392
	if (bufpointer) for (i=0; i
387
	{
393
	{
388
		DrawBar(0, i*rows.item_h+TOPPANELH, Form.cwidth, rows.item_h, 0xFFFFFF);
394
		DrawBar(0, i*rows.item_h+TOPPANELH, rows.w, rows.item_h, 0xFFFFFF);
389
		WriteText(2, i*rows.item_h+TOPPANELH, 0x90, 0x000000, DSDWORD[i+rows.first*4+draw_sruct]);
395
		WriteText(2, i*rows.item_h+TOPPANELH, 0x90, 0x000000, DSDWORD[i+rows.first*4+draw_sruct]);
390
	}
396
	}
391
	DrawBar(0, i*rows.item_h+rows.y, rows.w, -i*rows.item_h + rows.h, 0xFFFfff);
397
	DrawBar(0, i*rows.item_h+rows.y, rows.w, -i*rows.item_h + rows.h, 0xFFFfff);
-
 
398
	DrawVerticalScroll();
-
 
399
}
-
 
400
 
-
 
401
void DrawVerticalScroll()
-
 
402
{
-
 
403
	scroll_v.max_area = rows.count;
-
 
404
	scroll_v.cur_area = rows.visible;
-
 
405
	scroll_v.position = rows.first;
-
 
406
	scroll_v.start_y = rows.y;
-
 
407
	scroll_v.size_y = rows.h;
-
 
408
	scroll_v.start_x = rows.w + rows.x -1;
-
 
409
	scroll_v.all_redraw = 0;
-
 
410
	scrollbar_v_draw(#scroll_v);
392
}
411
}
393
 
412
 
394
stop:
413
stop: