Rev 2696 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2696 | Rev 2739 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | //èäåÿ - ëåâûå ôàéëû îòêðûâàòü ñîîòâåòñòâóþùèìè ïðîãàìè |
1 | //èäåÿ - ëåâûå ôàéëû îòêðûâàòü ñîîòâåòñòâóþùèìè ïðîãàìè |
2 | //ol - öèôåðêè |
2 | //ol - öèôåðêè |
Line 3... | Line -... | ||
3 | - | ||
4 | //èç õòòï-ëîàä â ðåàäõòìë |
- | |
Line 5... | Line 3... | ||
5 | 3 | ||
Line 6... | Line 4... | ||
6 | 4 | ||
7 | int downloader_id; |
5 | int downloader_id; |
Line 13... | Line 11... | ||
13 | int i; |
11 | int i; |
Line 14... | Line 12... | ||
14 | 12 | ||
15 | char download_path[]="/rd/1/.download"; |
13 | char download_path[]="/rd/1/.download"; |
16 | //char search_path[]="http://nova.rambler.ru/search?words="; |
14 | //char search_path[]="http://nova.rambler.ru/search?words="; |
17 | char search_path[]="http://nigma.ru/index.php?s="; |
15 | char search_path[]="http://nigma.ru/index.php?s="; |
Line 18... | Line 16... | ||
18 | char version[]=" Text-based Browser 0.83"; |
16 | char version[]=" Text-based Browser 0.9"; |
19 | 17 | ||
20 | - | ||
21 | struct TWebBrowser { |
- | |
22 | int left, |
- | |
23 | top, |
18 | |
24 | width, |
19 | struct TWebBrowser { |
25 | height; |
20 | int left, top, width, height; |
26 | void DrawScroller(); |
21 | void DrawScroller(); |
27 | void ShowPage(); |
22 | void ShowPage(); |
Line 109... | Line 104... | ||
109 | case 021: //Ctrl+U |
104 | case 021: //Ctrl+U |
110 | ReadHtml(); |
105 | ReadHtml(); |
111 | utf8rutodos(buf); |
106 | utf8rutodos(buf); |
112 | break; |
107 | break; |
113 | case BACK: |
108 | case BACK: |
114 | BrowserHistory.GoBack(); |
109 | if (!BrowserHistory.GoBack()) return; |
115 | - | ||
116 | copystr(#URL, #editURL); |
- | |
117 | za_kadrom = count = 0; |
- | |
118 | if (!strcmp(get_URL_part(5),"http:"))) HttpLoad(); |
- | |
119 | ShowPage(#URL); |
110 | OpenPage(); |
120 | return; |
111 | return; |
121 | case FORWARD: |
112 | case FORWARD: |
122 | BrowserHistory.GoForward(); |
113 | if (!BrowserHistory.GoForward()) return; |
123 | - | ||
124 | copystr(#URL, #editURL); |
- | |
125 | za_kadrom = count = 0; |
- | |
126 | if (!strcmp(get_URL_part(5),"http:"))) HttpLoad(); |
- | |
127 | ShowPage(#URL); |
114 | OpenPage(); |
128 | return; |
115 | return; |
129 | case 054: //F5 |
116 | case 054: //F5 |
130 | IF(edit1.flags == 66) break; |
117 | IF(edit1.flags == 66) break; |
131 | case REFRESH: |
118 | case REFRESH: |
132 | if (GetProcessSlot(downloader_id)<>0) |
119 | if (GetProcessSlot(downloader_id)<>0) |
Line 154... | Line 141... | ||
154 | case HOME: |
141 | case HOME: |
155 | copystr("http://kolibri-os.narod.ru", #editURL); |
142 | copystr("http://kolibri-os.narod.ru", #editURL); |
156 | case GOTOURL: |
143 | case GOTOURL: |
157 | case 0x0D: //enter |
144 | case 0x0D: //enter |
158 | copystr(#editURL, #URL); |
145 | copystr(#editURL, #URL); |
159 | if (!strcmp(get_URL_part(5),"http:"))) HttpLoad(); |
- | |
160 | za_kadrom = count = 0; |
- | |
161 | ShowPage(#URL); |
146 | OpenPage(); |
162 | return; |
147 | return; |
163 | case 173: //ctrl+enter |
148 | case 173: //ctrl+enter |
164 | case SEARCHWEB: |
149 | case SEARCHWEB: |
165 | copystr(#search_path, #URL); |
150 | copystr(#search_path, #URL); |
166 | copystr(#editURL, #URL + strlen(#URL)); |
151 | copystr(#editURL, #URL + strlen(#URL)); |
167 | if (!strcmp(get_URL_part(5),"http:"))) HttpLoad(); |
- | |
168 | za_kadrom = count = 0; |
- | |
169 | ShowPage(#URL); |
152 | OpenPage(); |
170 | return; |
153 | return; |
Line 171... | Line 154... | ||
171 | 154 | ||
172 | case ID1: //ìîòàåì ââåðõ |
155 | case ID1: //ìîòàåì ââåðõ |
173 | IF(za_kadrom <= 0) return; |
156 | IF(za_kadrom <= 0) return; |
Line 199... | Line 182... | ||
199 | RETURN; |
182 | RETURN; |
200 | } |
183 | } |
201 | ParseHTML(buf, filesize); |
184 | ParseHTML(buf, filesize); |
202 | } |
185 | } |
Line -... | Line 186... | ||
- | 186 | ||
- | 187 | void OpenPage() |
|
- | 188 | { |
|
- | 189 | if (GetProcessSlot(downloader_id)<>0) PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
|
- | 190 | KillProcess(downloader_id); |
|
- | 191 | copystr(#URL, #editURL); |
|
- | 192 | za_kadrom = count = 0; |
|
- | 193 | if (!strcmp(get_URL_part(5),"http:"))) HttpLoad(); |
|
- | 194 | WB1.ShowPage(#URL); |
|
- | 195 | } |
|
203 | 196 | ||
204 | void GetNewUrl(){ |
197 | void GetNewUrl(){ |
Line 205... | Line 198... | ||
205 | IF (!strcmp(get_URL_part(2),"./")) copystr(#URL+2,#URL); //èãíîðèì :) |
198 | IF (!strcmp(get_URL_part(2),"./")) copystr(#URL+2,#URL); //èãíîðèì :) |
206 | 199 | ||
Line 236... | Line 229... | ||
236 | copystr(#version, #header); |
229 | copystr(#version, #header); |
237 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
230 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
238 | DeleteFile(#download_path); |
231 | DeleteFile(#download_path); |
239 | IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=''; |
232 | IF (URL[strlen(#URL)-1]=='/') URL[strlen(#URL)-1]=''; |
240 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
233 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
- | 234 | //ýòî ãåíèàëüíî è ýòî ïèçäåö!!! |
|
- | 235 | Pause(60); |
|
- | 236 | KillProcess(downloader_id); //óáèâàåì ñòàðûé ïðîöåññ |
|
- | 237 | downloader_id = RunProgram("/sys/network/downloader", #URL); |
|
- | 238 | // |
|
241 | IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable."); |
239 | IF (downloader_id<0) RunProgram("@notify", "Error running Downloader. Internet unavilable."); |
242 | Draw_Window(); |
240 | Draw_Window(); |
243 | } |
241 | } |
Line 273... | Line 271... | ||
273 | //LETS_LOAD |
271 | //LETS_LOAD |
274 | ReadHtml(); |
272 | ReadHtml(); |
Line 275... | Line 273... | ||
275 | 273 | ||
276 | if (!filesize) |
274 | if (!filesize) |
277 | { |
275 | { |
278 | DrawBar(left, top, width+2, height, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äîíèçó |
276 | DrawBar(left, top, width+4, height, 0xFFFFFF); //çàêðàøèâàåì âñ¸ äîíèçó |
279 | if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...", 0); |
277 | if (GetProcessSlot(downloader_id)<>0) WriteText(left + 10, top + 18, 0x80, 0, "Loading...", 0); |
280 | else |
278 | else |
281 | { |
279 | { |
282 | WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0); |
280 | WriteText(left + 10, top + 18, 0x80, 0, "Page not found. May be, URL contains some errors.", 0); |
Line 408... | Line 406... | ||
408 | { |
406 | { |
409 | bukva = unicode_chars[rez]; |
407 | bukva = unicode_chars[rez]; |
410 | GOTO DEFAULT_MARK; //îáðàáàòûâàåì áóêâó |
408 | GOTO DEFAULT_MARK; //îáðàáàòûâàåì áóêâó |
411 | } |
409 | } |
Line 412... | Line 410... | ||
412 | 410 | ||
413 | WriteDebug(#tag); //òýã íå íàéäåí - âûâîäèì íà äîñêó îòëàäêè |
411 | //WriteDebug(#tag); //òýã íå íàéäåí - âûâîäèì íà äîñêó îòëàäêè |
414 | copystr(#tag, #line + strlen(#line)); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò |
412 | copystr(#tag, #line + strlen(#line)); //âûâîäèì íà ýêðàí íåîáðàáîòàííûé òåã, òàê áðàóçåðû çà÷åì-òî äåëàþò |
415 | break; |
413 | break; |
416 | default: |
414 | default: |
417 | DEFAULT_MARK: |
415 | DEFAULT_MARK: |
Line 593... | Line 591... | ||
593 | return; |
591 | return; |
594 | } |
592 | } |
595 | ///////////////////////// |
593 | ///////////////////////// |
596 | if (!chTag("font")) |
594 | if (!chTag("font")) |
597 | { |
595 | { |
598 | IF(stroka < 0) || (stroka - 1 > max_kolvo_strok) return; |
596 | IF (stroka - 1 > max_kolvo_strok) return; |
599 | COL_MARK: |
597 | COL_MARK: |
600 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
598 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
601 | { |
599 | { |
602 | text_color_index++; |
600 | text_color_index++; |
603 | text_colors[text_color_index] = GetColor(#options); |
601 | text_colors[text_color_index] = GetColor(#options); |
Line 764... | Line 762... | ||
764 | return; |
762 | return; |
765 | } |
763 | } |
766 | } |
764 | } |
Line 767... | Line 765... | ||
767 | 765 | ||
- | 766 | ||
768 | 767 | void TextGoDown(int left1, top1, width1) |
|
769 | void TextGoDown(int left1, top1, width1) { |
768 | { |
770 | stroka++; |
769 | stroka++; |
771 | IF(blq_text == 1) stolbec = 8; |
770 | IF(blq_text == 1) stolbec = 8; |
772 | ELSE stolbec = 0; |
771 | ELSE stolbec = 0; |
773 | IF(li_text == 1) stolbec = li_tab * 5; |
772 | IF(li_text == 1) stolbec = li_tab * 5; |
Line 774... | Line 773... | ||
774 | IF(stroka >= 0) && (stroka - 2 < max_kolvo_strok) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
773 | IF(stroka >= 0) && (stroka - 2 < max_kolvo_strok) DrawBar(left1 - 5, top1 + 10, width1 + 5, 10, bg_color); |
775 | } |
774 | } |
- | 775 | ||
776 | 776 | ||
777 | - | ||
778 | //ñêðîëë |
777 | //ñêðîëë |
779 | void TWebBrowser::DrawScroller() { |
778 | void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå |
780 | dword on_y; |
779 | { |
781 | DrawBar(left + width - 15, top + 17, 1, height - 34, 0x94AECE); //ëèíèÿ ñëåâà îò ïðîêðóòêè |
780 | scroll1.max_area = count; |
782 | DrawFlatButton(left + width - 15, top + height - 17, 16, 16, ID2, 0xE4DFE1, "\x19"); |
781 | scroll1.cur_area = max_kolvo_strok; |
783 | DrawFlatButton(left + width - 15, top, 16, 16, ID1, 0xE4DFE1, "\x18"); |
782 | scroll1.position = za_kadrom; |
784 | 783 | ||
- | 784 | scroll1.all_redraw=1; |
|
Line 785... | Line -... | ||
785 | IF(count <= max_kolvo_strok) { |
- | |
786 | DrawBar(left + width - 14, top+17, 16, height - 34, 0xCED0D0); |
- | |
787 | return; |
785 | scroll1.start_x=Form.width-28; //left + width - 15 |
788 | } |
- | |
789 | 786 | scroll1.size_y=WB1.height; |
|
790 | scroll_size = height - 16 * max_kolvo_strok / count - 3; |
- | |
791 | IF(scroll_size < 10) scroll_size = 10; |
- | |
792 | IF(za_kadrom + max_kolvo_strok >= count) on_y = height - scroll_size + top - 17; |
- | |
793 | ELSE on_y = height - 32 * za_kadrom / count + top + 16; |
787 | |
794 | DrawFlatButton(left + width - 15, on_y, 16, scroll_size, 0, 0xE4DFE1, ""); //ïîëçóíîê |
788 | scrollbar_v_draw(#scroll1); |