Rev 4674 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4491 | leency | 1 | #include "..\TWB\links.h" |
4411 | leency | 2 | |
4540 | leency | 3 | dword bufpointer; |
4636 | leency | 4 | dword o_bufpointer; |
4540 | leency | 5 | dword bufsize; |
4411 | leency | 6 | |
4416 | leency | 7 | #define URL param |
8 | |||
4677 | leency | 9 | scroll_bar scroll_wv = { 15,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}; |
4416 | leency | 10 | |
4417 | leency | 11 | char header[2048]; |
4416 | leency | 12 | |
4411 | leency | 13 | struct TWebBrowser { |
4540 | leency | 14 | llist list; |
4475 | leency | 15 | DrawBufer DrawBuf; |
4411 | leency | 16 | void GetNewUrl(); |
4636 | leency | 17 | void Prepare(); |
4550 | leency | 18 | void Parse(); |
4650 | leency | 19 | void SetTextStyle(); |
4411 | leency | 20 | void DrawPage(); |
21 | void DrawScroller(); |
||
4650 | leency | 22 | void NewLine(); |
4486 | leency | 23 | }; |
24 | |||
4411 | leency | 25 | TWebBrowser WB1; |
26 | |||
4491 | leency | 27 | byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, |
4637 | leency | 28 | link, ignor_text, cur_encoding, text_align, t_html, t_body; |
4417 | leency | 29 | byte condition_text_active, condition_text_val, condition_href, condition_max; |
4411 | leency | 30 | |
4636 | leency | 31 | enum { _WIN, _DOS, _KOI, _UTF, _DEFAULT }; |
4475 | leency | 32 | |
4411 | leency | 33 | enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
34 | |||
4417 | leency | 35 | dword text_colors[300]; |
36 | dword text_color_index; |
||
4491 | leency | 37 | dword link_color_inactive; |
38 | dword link_color_active; |
||
4417 | leency | 39 | dword bg_color; |
4411 | leency | 40 | |
4417 | leency | 41 | int stroka; |
42 | int stolbec; |
||
43 | int tab_len; |
||
44 | int anchor_line_num; |
||
4636 | leency | 45 | |
4417 | leency | 46 | char line[500]; |
47 | char tag[100]; |
||
48 | char tagparam[10000]; |
||
49 | char parametr[1200]; |
||
50 | char options[4096]; |
||
51 | char anchor[256]; |
||
4411 | leency | 52 | |
4416 | leency | 53 | #include "..\TWB\history.h" |
4411 | leency | 54 | #include "..\TWB\colors.h" |
55 | #include "..\TWB\unicode_tags.h" |
||
56 | #include "..\TWB\img_cache.h" |
||
57 | #include "..\TWB\parce_tag.h" |
||
4636 | leency | 58 | #include "..\TWB\table.h" |
4411 | leency | 59 | |
4475 | leency | 60 | |
61 | |||
4411 | leency | 62 | //======================================================================= |
63 | |||
64 | |||
65 | void TWebBrowser::DrawPage() |
||
66 | { |
||
67 | int start_x, start_y, line_length, magrin_left=5; |
||
68 | |||
69 | if (!header) |
||
70 | { |
||
71 | strcpy(#header, #line); |
||
72 | strcat(#header, " -"); |
||
73 | strcat(#header, #version); |
||
74 | line = 0; |
||
75 | return; |
||
76 | } |
||
4637 | leency | 77 | if (t_html) && (!t_body) return; |
4411 | leency | 78 | |
4415 | leency | 79 | if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor) |
4411 | leency | 80 | { |
4414 | leency | 81 | start_x = stolbec * 6 + list.x + magrin_left; |
82 | start_y = stroka * 10 + list.y + magrin_left; |
||
4411 | leency | 83 | line_length = strlen(#line) * 6; |
84 | |||
4475 | leency | 85 | WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, buf_data); |
86 | IF (b_text) WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, buf_data); |
||
87 | IF (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); } |
||
88 | IF (s_text) DrawBuf.DrawBar(start_x, 4, line_length, 1, text_colors[text_color_index]); |
||
89 | IF (u_text) DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]); |
||
4411 | leency | 90 | IF (link) { |
4493 | leency | 91 | UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9); |
4475 | leency | 92 | DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]); |
4550 | leency | 93 | PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE); |
4411 | leency | 94 | } |
95 | stolbec += strlen(#line); |
||
96 | } |
||
97 | } |
||
98 | //======================================================================= |
||
99 | |||
100 | |||
101 | |||
102 | char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0}; |
||
103 | void TWebBrowser::GetNewUrl(){ |
||
104 | int i, len; |
||
4534 | leency | 105 | char newurl[4096]; |
4411 | leency | 106 | |
107 | for (i=0; ABSOLUTE_LINKS[i]; i++) |
||
108 | { |
||
109 | len=strlen(ABSOLUTE_LINKS[i]); |
||
110 | if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return; |
||
111 | } |
||
112 | |||
4534 | leency | 113 | IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); |
114 | strcpy(#newurl, BrowserHistory.CurrentUrl()); |
||
4411 | leency | 115 | |
116 | if (URL[0] == '/') |
||
117 | { |
||
4534 | leency | 118 | i = strchr(#newurl+8, '/'); |
4646 | leency | 119 | if (i>0) newurl[i+7]=0; |
4411 | leency | 120 | strcpy(#URL, #URL+1); |
121 | } |
||
122 | |||
123 | _CUT_ST_LEVEL_MARK: |
||
124 | |||
4534 | leency | 125 | if (newurl[strrchr(#newurl, '/')-2]<>'/') |
4411 | leency | 126 | { |
4534 | leency | 127 | newurl[strrchr(#newurl, '/')] = 0x00; |
4411 | leency | 128 | } |
129 | |||
4534 | leency | 130 | IF (!strncmp(#URL,"../",3)) |
4411 | leency | 131 | { |
132 | strcpy(#URL,#URL+3); |
||
4534 | leency | 133 | newurl[strrchr(#newurl, '/')-1] = 0x00; |
4411 | leency | 134 | goto _CUT_ST_LEVEL_MARK; |
135 | } |
||
136 | |||
4534 | leency | 137 | if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/"); |
4411 | leency | 138 | |
4534 | leency | 139 | strcat(#newurl, #URL); |
140 | strcpy(#URL, #newurl); |
||
4411 | leency | 141 | } |
142 | |||
4636 | leency | 143 | void BufEncode(int set_new_encoding) |
4411 | leency | 144 | { |
4646 | leency | 145 | int bufpointer_realsize; |
4636 | leency | 146 | cur_encoding = set_new_encoding; |
147 | if (o_bufpointer==0) |
||
4554 | leency | 148 | { |
4646 | leency | 149 | bufpointer_realsize = strlen(bufpointer); |
150 | if (bufpointer_realsize > bufsize) |
||
151 | { |
||
152 | debug("bufsize: "); |
||
153 | debugi(bufsize); |
||
154 | debug("bufpointer_realsize: "); |
||
155 | debugi(bufpointer_realsize); |
||
156 | bufsize = bufpointer_realsize; |
||
157 | } |
||
4636 | leency | 158 | o_bufpointer = malloc(bufsize); |
159 | strcpy(o_bufpointer, bufpointer); |
||
4554 | leency | 160 | } |
4411 | leency | 161 | else |
4554 | leency | 162 | { |
4636 | leency | 163 | strcpy(bufpointer, o_bufpointer); |
4554 | leency | 164 | } |
4636 | leency | 165 | if (set_new_encoding==_WIN) wintodos(bufpointer); |
166 | if (set_new_encoding==_UTF) utf8rutodos(bufpointer); |
||
167 | if (set_new_encoding==_KOI) koitodos(bufpointer); |
||
4411 | leency | 168 | } |
169 | |||
4636 | leency | 170 | void TWebBrowser::Prepare(dword bufpos, in_filesize){ |
171 | bufsize = in_filesize; |
||
172 | bufpointer = bufpos; |
||
173 | Parse(); |
||
4554 | leency | 174 | } |
175 | |||
176 | |||
4636 | leency | 177 | void TWebBrowser::Parse(){ |
4411 | leency | 178 | word bukva[2]; |
179 | int j, perenos_num; |
||
180 | byte ignor_param; |
||
181 | char temp[768]; |
||
4636 | leency | 182 | dword bufpos = bufpointer; |
4411 | leency | 183 | |
4637 | leency | 184 | b_text = i_text = u_text = s_text = blq_text = t_html = t_body = |
4417 | leency | 185 | li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = |
186 | condition_text_val = condition_text_active = 0; //обнуляем теги |
||
4475 | leency | 187 | condition_max = 255; |
4411 | leency | 188 | text_align = ALIGN_LEFT; |
4491 | leency | 189 | link_color_inactive = 0x0000FF; |
190 | link_color_active = 0xFF0000; |
||
4411 | leency | 191 | bg_color = 0xFFFFFF; |
4475 | leency | 192 | DrawBuf.Fill(bg_color); |
4504 | leency | 193 | PageLinks.Clear(); |
4411 | leency | 194 | strcpy(#header, #version); |
4415 | leency |