Rev 4414 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4414 | Rev 4415 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | #include "..\lib\list_box.h" |
- | |
2 | - | ||
Line 3... | Line 1... | ||
3 | 1 | int downloader_id; |
|
Line 4... | Line 2... | ||
4 | int downloader_id; |
2 | |
5 | 3 | dword |
|
Line 9... | Line 7... | ||
9 | blink; |
7 | |
Line 10... | Line 8... | ||
10 | 8 | char download_path[]="/rd/1/.download"; |
|
11 | char download_path[]="/rd/1/.download"; |
9 | char search_path[]="http://nigma.ru/index.php?s="; |
Line 12... | Line -... | ||
12 | char search_path[]="http://nigma.ru/index.php?s="; |
- | |
13 | - | ||
14 | struct lines{ |
- | |
Line 15... | Line 10... | ||
15 | int visible, all, first, column_max; |
10 | |
16 | }; |
11 | |
17 | 12 | struct TWebBrowser { |
|
18 | struct TWebBrowser { |
13 | llist list; //need #include "..\lib\list_box.h" |
19 | llist list; |
14 | void GetNewUrl(); |
20 | void GetNewUrl(); |
15 | void OpenPage(); |
21 | void OpenPage(); |
16 | void ReadHtml(byte); |
Line 71... | Line 66... | ||
71 | strcat(#header, #version); |
66 | line = 0; |
72 | line = 0; |
67 | return; |
73 | return; |
68 | } |
74 | } |
69 | |
Line 75... | Line 70... | ||
75 | 70 | if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor) |
|
76 | if (stroka >= 0) && (stroka - 2 < lines.visible) && (line) && (!anchor) |
71 | { |
77 | { |
72 | start_x = stolbec * 6 + list.x + magrin_left; |
78 | start_x = stolbec * 6 + list.x + magrin_left; |
73 | start_y = stroka * 10 + list.y + magrin_left; |
79 | start_y = stroka * 10 + list.y + magrin_left; |
74 | line_length = strlen(#line) * 6; |
Line 170... | Line 165... | ||
170 | BrowserHistory.AddUrl(); |
165 | strcpy(#header, #version); |
171 | strcpy(#header, #version); |
166 | pre_text =0; |
172 | pre_text =0; |
167 | if (!strcmp(get_URL_part(5),"http:"))) |
173 | if (!strcmp(get_URL_part(5),"http:"))) |
168 | { |
174 | { |
169 | KillProcess(downloader_id); |
175 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
170 | DeleteFile(#download_path); |
176 | DeleteFile(#download_path); |
171 | IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL; |
177 | IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=NULL; |
172 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
178 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
173 | IF (downloader_id<0) notify("Error running Downloader. Internet unavilable."); |
179 | //Browser Hack v2.0 |
- | |
180 | /* |
- | |
181 | pause(60); |
- | |
182 | if (GetProcessSlot(downloader_id)<>0) |
- | |
183 | { |
- | |
184 | debug("Browser Hack v2.0: Killing downloader and trying to run it one more!"); |
- | |
185 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
- | |
186 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
- | |
187 | } |
- | |
188 | */ |
- | |
189 | IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable."); |
174 | Draw_Window(); |
190 | Draw_Window(); |
175 | return; |
191 | return; |
176 | } |
192 | } |
177 | list.first = list.count =0; |
193 | lines.first = lines.all =0; |
178 | ReadHtml(_WIN); |
194 | ReadHtml(_WIN); |
179 | WB1.ShowPage(); |
195 | WB1.ShowPage(); |
180 | } |
196 | } |
181 | |
Line 235... | Line 220... | ||
235 | link_color = 0x0000FF; |
220 | bg_color = 0xFFFFFF; |
236 | bg_color = 0xFFFFFF; |
221 | DrawBufFill(); |
237 | DrawBufFill(); |
222 | strcpy(#page_links,"|"); |
238 | strcpy(#page_links,"|"); |
223 | strcpy(#header, #version); |
239 | strcpy(#header, #version); |
224 | stroka = -list.first; |
240 | stroka = -lines.first; |
225 | stolbec = 0; |
241 | stolbec = 0; |
226 | line = 0; |
242 | line = 0; |
227 | |
Line 243... | Line 228... | ||
243 | 228 | if (pre_text<>2) |
|
244 | if (pre_text<>2) |
229 | { |
Line 333... | Line 318... | ||
333 | strlwr(#tagparam); |
318 | |
Line 334... | Line 319... | ||
334 | 319 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ |
|
335 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ |
320 | if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); |
Line 336... | Line 321... | ||
336 | if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); |
321 | |
337 | 322 | if (stolbec + strlen(#line) > list.column_max) //============the same as NEXT_MARK |
|
338 | if (stolbec + strlen(#line) > lines.column_max) //============the same as NEXT_MARK |
323 | { |
339 | { |
324 | perenos_num = strrchr(#line, ' '); |
340 | perenos_num = strrchr(#line, ' '); |
325 | if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max; |
341 | if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max; |
326 | strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì |
342 | strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì |
327 | line[perenos_num] = 0x00; |
343 | line[perenos_num] = 0x00; |
328 | if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì... |
344 | if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì... |
329 | DrawPage(); |
345 | DrawPage(); |
330 | strcpy(#line, #temp); |
346 | strcpy(#line, #temp); |
331 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó |
347 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó |
332 | } |
Line 361... | Line 346... | ||
361 | if (line[strlen(#line)-1]==' ') break; //óáðàòü 2 ïðîáåëà ïîäðÿä |
346 | if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà |
362 | if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà |
347 | } |
363 | } |
348 | if (strlen(#line) |
364 | if (strlen(#line) |
349 | |
Line 365... | Line 350... | ||
365 | 350 | if (stolbec + strlen(#line) > list.column_max) |
|
366 | if (stolbec + strlen(#line) > lines.column_max) |
351 | { |
367 | { |
352 | NEXT_MARK: |
368 | NEXT_MARK: |
353 | perenos_num = strrchr(#line, ' '); |
369 | perenos_num = strrchr(#line, ' '); |
354 | if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max; |
370 | if (!perenos_num) && (strlen(#line)>lines.column_max) perenos_num=lines.column_max; |
355 | strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì |
371 | strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì |
356 | line[perenos_num] = 0x00; |
372 | line[perenos_num] = 0x00; |
357 | if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì... |
373 | if (stroka-1 > lines.visible) && (lines.first <>0) break 1; //óõîäèì... |
358 | DrawPage(); |
374 | DrawPage(); |
359 | strcpy(#line, #temp); |
375 | strcpy(#line, #temp); |
360 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó |
376 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó |
361 | } |
377 | } |
362 | } |
378 | } |
363 | } |
Line 379... | Line 364... | ||
379 | } |
364 | |
380 | 365 | DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä |
|
Line 381... | Line 366... | ||
381 | DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä |
366 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó |
382 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó |
367 | |
383 | 368 | if (list.visible * 10 + 25 <= list.h) |
|
384 | if (lines.visible * 10 + 25 <= list.h) |
369 | DrawBar(list.x, list.visible * 10 + list.y + 25, list.w, -list.visible * 10 + list.h - 25, bg_color); |
385 | DrawBar(list.x, lines.visible * 10 + list.y + 25, list.w, -lines.visible * 10 + list.h - 25, bg_color); |
370 | if (stroka * 10 + 5 <= list.h) |
386 | if (stroka * 10 + 5 <= list.h) |
371 | DrawBar(list.x, stroka * 10 + list.y + 5, list.w, -stroka * 10 + list.h - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà |
387 | DrawBar(list.x, stroka * 10 + list.y + 5, list.w, -stroka * 10 + list.h - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà |
372 | if (list.first == 0) list.count = stroka; |
388 | if (lines.first == 0) lines.all = stroka; |
373 | if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë |
389 | if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë |
374 | { |
390 | { |
375 | anchor=NULL; |
391 | anchor=NULL; |
376 | list.first=anchor_line_num; |
392 | lines.first=anchor_line_num; |
377 | ParseHTML(buf); |
393 | ParseHTML(buf); |
378 | } |
Line 430... | Line 415... | ||
430 | 415 | IF(!chTag("q")) chrcat(#line, '\"'); |
|
Line 431... | Line 416... | ||
431 | IF(!chTag("q")) chrcat(#line, '\"'); |
416 | |
432 | 417 | if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò |
|
433 | if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò |
418 | { |
434 | { |
419 | if (!strcmp(#anchor, #options)) anchor_line_num=list.first+stroka; |
Line 435... | Line 420... | ||
435 | if (!strcmp(#anchor, #options)) anchor_line_num=lines.first+stroka; |
420 | } |
436 | } |
421 | |
437 | 422 | if (!chTag("body")) |
|
Line 456... | Line 441... | ||
456 | if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò |
441 | |
Line 457... | Line 442... | ||
457 | 442 | do{ |
|
458 | do{ |
443 | if (!strcmp(#parametr, "href=")) |
459 | if (!strcmp(#parametr, "href=")) |
444 | { |
460 | { |
445 | if (stroka - 1 > list.visible) || (stroka < -2) return; |
Line 461... | Line 446... | ||
461 | if (stroka - 1 > lines.visible) || (stroka < -2) return; |
446 | |
462 | 447 | text_color_index++; |
|
Line 463... | Line 448... | ||
463 | text_color_index++; |
448 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
Line 471... | Line 456... | ||
471 | } |
456 | if (anchor) && (!strcmp(#parametr, "name=")) |
472 | if (anchor) && (!strcmp(#parametr, "name=")) |
457 | { |
473 | { |
458 | if (!strcmp(#anchor, #options)) |
474 | if (!strcmp(#anchor, #options)) |
459 | { |
475 | { |
460 | anchor_line_num=list.first+stroka; |
476 | anchor_line_num=lines.first+stroka; |
461 | } |
477 | } |
462 | } |
478 | } |
463 | } while(GetNextParam()); |
479 | } while(GetNextParam()); |
464 | } |
480 | } |
465 | else { |
481 | else { |
466 | link = 0; |
Line 576... | Line 561... | ||
576 | { |
561 | li_text = rez; |
577 | li_text = rez; |
562 | if (rez) |
578 | if (rez) |
563 | { |
579 | { |
564 | TextGoDown(left1, top1, width1); |
580 | TextGoDown(left1, top1, width1); |
565 | if (stroka > -1) && (stroka - 2 < list.visible) DrawBufBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555); |
581 | if (stroka > -1) && (stroka - 2 < lines.visible) DrawBufBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555); |
566 | } |
582 | } |
567 | return; |
583 | return; |
568 | } |
584 | } |
569 | if (!chTag("u")) || (!chTag("ins")) u_text = rez; |
585 | if (!chTag("u")) || (!chTag("ins")) u_text = rez; |
570 | if (!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
586 | if (!chTag("s")) || (!chTag("strike")) || (!chTag("del")) s_text = rez; |
571 | if (!chTag("ul")) || (!chTag("ol")) IF(!rez) |
Line 627... | Line 612... | ||
627 | 612 | ||
628 | 613 | ||
629 | 614 | void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå |
|
630 | void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå |
615 | { |
631 | { |
616 | scroll1.max_area = list.count; |
Line 632... | Line 617... | ||
632 | scroll1.max_area = lines.all; |
617 | scroll1.cur_area = list.visible; |
633 | scroll1.cur_area = lines.visible; |
618 | scroll1.position = list.first; |
634 | scroll1.position = lines.first; |
619 |