Rev 7756 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7756 | Rev 7757 | ||
---|---|---|---|
Line 12... | Line 12... | ||
12 | // *.obj libraries |
12 | // *.obj libraries |
13 | #include "..\lib\obj\box_lib.h" |
13 | #include "..\lib\obj\box_lib.h" |
14 | #include "..\lib\obj\libio.h" |
14 | #include "..\lib\obj\libio.h" |
15 | #include "..\lib\obj\libimg.h" |
15 | #include "..\lib\obj\libimg.h" |
16 | #include "..\lib\obj\http.h" |
- | |
17 | #include "..\lib\obj\iconv.h" |
16 | #include "..\lib\obj\iconv.h" |
- | 17 | #include "..\lib\obj\proc_lib.h" |
|
Line 18... | Line 18... | ||
18 | 18 | ||
19 | #include "..\lib\patterns\history.h" |
19 | //useful patterns |
20 | #include "..\lib\patterns\http_downloader.h" |
- | |
21 | - | ||
Line 22... | Line 20... | ||
22 | _http http = {0, 0, 0, 0, 0, 0, 0}; |
20 | #include "..\lib\patterns\simple_open_dialog.h" |
23 | 21 | ||
Line 24... | Line 22... | ||
24 | char homepage[] = FROM "html\\homepage.htm""\0"; |
22 | char homepage[] = FROM "html\\homepage.htm""\0"; |
25 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
23 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
Line 26... | Line 24... | ||
26 | 24 | ||
Line 27... | Line 25... | ||
27 | char version[]="C-- Code View"; |
25 | char version[]="C-- Code View"; |
Line 28... | Line 26... | ||
28 | char accept_language[]= "Accept-Language: en\n"; |
26 | char accept_language[]= "Accept-Language: en\n"; |
Line 50... | Line 48... | ||
50 | }; |
48 | }; |
51 | 49 | ||
Line 52... | Line 50... | ||
52 | #define URL_SIZE 4000; |
50 | #define URL_SIZE 4000; |
53 | #include "..\TWB\TWB.c" |
51 | #include "..\TWB\TWB.c" |
54 | #include "show_src.h" |
52 | #include "highlight_c.h" |
- | 53 | ||
- | 54 | char default_dir[] = "/rd/1"; |
|
- | 55 | od_filter filter2 = { 16, "C\0H\0C--\0H--\0CPP\0\0" }; |
|
Line 55... | Line 56... | ||
55 | 56 | ||
56 | char URL[URL_SIZE+1]; |
57 | char current_path[URL_SIZE+1]; |
57 | char editURL[URL_SIZE+1]; |
58 | char edit_path[URL_SIZE+1]; |
58 | int mouse_twb; |
59 | int mouse_twb; |
Line 59... | Line 60... | ||
59 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#editURL,#mouse_twb,2,19,19}; |
60 | edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#edit_path,#mouse_twb,2,19,19}; |
Line 60... | Line 61... | ||
60 | 61 | ||
61 | #define SKIN_Y 24 |
62 | #define SKIN_Y 24 |
62 | - | ||
63 | void main() |
- | |
64 | { |
63 | |
65 | int i; |
64 | void LoadLibraries() |
66 | int id; |
65 | { |
67 | load_dll(boxlib, #box_lib_init,0); |
66 | load_dll(boxlib, #box_lib_init,0); |
- | 67 | load_dll(libio, #libio_init,1); |
|
- | 68 | load_dll(libimg, #libimg_init,1); |
|
- | 69 | load_dll(iconv_lib, #iconv_open,0); |
|
- | 70 | load_dll(Proc_lib, #OpenDialog_init,0); |
|
- | 71 | OpenDialog_init stdcall (#o_dialog); |
|
- | 72 | } |
|
- | 73 | ||
- | 74 | void main() |
|
68 | load_dll(libio, #libio_init,1); |
75 | { |
69 | load_dll(libimg, #libimg_init,1); |
76 | int i; |
70 | load_dll(iconv_lib, #iconv_open,0); |
77 | LoadLibraries(); |
71 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
78 | if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME); |
72 | WB1.list.SetFont(8, 14, 10011000b); |
79 | WB1.list.SetFont(8, 14, 10011000b); |
73 | WB1.list.no_selection = true; |
80 | WB1.list.no_selection = true; |
Line 87... | Line 94... | ||
87 | } |
94 | } |
88 | break; |
95 | break; |
89 | 96 | ||
Line 90... | Line 97... | ||
90 | case evButton: |
97 | case evButton: |
91 | id=GetButtonID(); |
- | |
92 | if (1==id) ExitProcess(); |
98 | if (GetButtonID()==1) ExitProcess(); |
93 | break; |
99 | break; |
Line 94... | Line 100... | ||
94 | 100 | ||
95 | case evKey: |
101 | case evKey: |
Line 96... | Line 102... | ||
96 | GetKeys(); |
102 | GetKeys(); |
97 | 103 | ||
98 | if (SCAN_CODE_F5 == key_scancode) { |
104 | if (SCAN_CODE_F5 == key_scancode) { |
99 | OpenPage(); |
105 | OpenPage(#current_path); |
100 | } |
106 | } |
- | 107 | if (SCAN_CODE_F3 == key_scancode) { |
|
- | 108 | RunProgram("/rd/1/tinypad", #current_path); |
|
- | 109 | } |
|
- | 110 | ||
101 | if (SCAN_CODE_F3 == key_scancode) { |
111 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
Line 102... | Line 112... | ||
102 | RunProgram("/rd/1/tinypad", #URL); |
112 | if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;} |
103 | } |
113 | } |
104 | 114 | ||
- | 115 | if (address_box.flags & 0b10) |
|
- | 116 | { |
|
105 | if (address_box.flags & 0b10) |
117 | if (key_ascii == ASCII_KEY_ENTER) { |
106 | { |
118 | OpenPage(#edit_path); |
107 | if (key_ascii == ASCII_KEY_ENTER) EventGoToPage(); |
119 | } |
108 | else { |
120 | else { |
109 | EAX = key_editbox; |
121 | EAX = key_editbox; |
Line 124... | Line 136... | ||
124 | GetProcessInfo(#Form, SelfInfo); |
136 | GetProcessInfo(#Form, SelfInfo); |
125 | if (Form.status_window>2) { DrawTitle(#header); break; } |
137 | if (Form.status_window>2) { DrawTitle(#header); break; } |
126 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
138 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
127 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
139 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
128 | Draw_Window(); |
140 | SetElementSizes(); |
- | 141 | draw_window(); |
|
129 | break; |
142 | break; |
130 | } |
143 | } |
131 | } |
144 | } |
132 | 145 | ||
Line 133... | Line 146... | ||
133 | void SetElementSizes() |
146 | void SetElementSizes() |
Line 142... | Line 155... | ||
142 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
155 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
143 | WB1.list.visible = WB1.list.h; |
156 | WB1.list.visible = WB1.list.h; |
144 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
157 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
145 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700); |
158 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700); |
146 | OpenPage(); |
159 | OpenPage(#current_path); |
147 | } |
160 | } |
148 | } |
161 | } |
149 | 162 | ||
Line 150... | Line 163... | ||
150 | void Draw_Window() |
163 | void draw_window() |
151 | { |
164 | { |
152 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
165 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
153 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
166 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
154 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
167 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
155 | SetElementSizes(); |
- | |
156 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,border_color); |
168 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,border_color); |
157 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
169 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
158 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
170 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
159 | DrawEditBoxWebView(); |
171 | DrawEditBoxWebView(); |
160 | if (!header) |
172 | if (!header) { |
161 | OpenPage(); |
173 | OpenPage(#current_path); |
162 | else { |
174 | } else { |
163 | WB1.DrawPage(); |
175 | WB1.DrawPage(); |
164 | DrawEditBoxWebView(); |
176 | DrawEditBoxWebView(); |
165 | } |
177 | } |
166 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
178 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
167 | } |
179 | } |
Line 168... | Line -... | ||
168 | - | ||
169 | void EventGoToPage() |
- | |
170 | { |
- | |
171 | if (!editURL[0]) { |
- | |
172 | strcpy(#URL, URL_SERVICE_HOME); |
- | |
173 | } |
- | |
174 | else |
- | |
175 | { |
- | |
176 | strcpy(#URL, #editURL); |
- | |
177 | } |
- | |
178 | OpenPage(); |
- | |
Line 179... | Line -... | ||
179 | } |
- | |
180 | 180 | ||
181 | 181 | ||
182 | void SetPageDefaults() |
- | |
183 | { |
- | |
184 | strncpy(#header, #version, sizeof(header)-1); |
- | |
185 | WB1.list.count = WB1.list.first = 0; |
- | |
186 | cur_encoding = CH_NULL; |
- | |
187 | } |
182 | void OpenPage(dword _path) |
188 | - | ||
189 | void OpenPage() |
- | |
190 | { |
183 | { |
191 | char getUrl[URL_SIZE+1]; |
- | |
192 | strcpy(#editURL, #URL); |
184 | dword buf, size; |
193 | history.add(#URL); |
- | |
194 | if (!strncmp(#URL,"CodeView:",8)) |
- | |
195 | { |
185 | strcpy(#current_path, _path); |
196 | SetPageDefaults(); |
- | |
197 | if (!strcmp(#URL, URL_SERVICE_HOME)) LoadInternalPage(#homepage, sizeof(homepage)); |
186 | if (streq(_path, URL_SERVICE_HOME)) { |
198 | DrawEditBoxWebView(); |
187 | LoadInternalPage(#homepage, sizeof(homepage)); |
199 | return; |
- | |
200 | } |
- | |
201 | else |
188 | return; |
202 | { |
- | |
203 | file_size stdcall (#URL); |
189 | } |
204 | bufsize = EBX; |
190 | file_size stdcall (_path); |
205 | if (bufsize) |
191 | if (EBX) |
206 | { |
192 | { |
207 | free(bufpointer); |
- | |
208 | bufpointer = malloc(bufsize); |
193 | size = EBX; |
209 | SetPageDefaults(); |
194 | buf = malloc(size); |
210 | ReadFile(0, bufsize, bufpointer, #URL); |
- | |
211 | ShowCodeSource(); |
195 | ReadFile(0, size, buf, _path); |
212 | LoadInternalPage(bufpointer, bufsize); |
196 | ShowCodeSource(); |
213 | } |
197 | free(buf); |
- | 198 | return; |
|
214 | ShowPage(); |
199 | } |
Line 215... | Line 200... | ||
215 | } |
200 | LoadInternalPage(NULL,NULL); |
216 | } |
201 | } |
217 | 202 | ||
218 | DrawEditBoxWebView() |
203 | DrawEditBoxWebView() |
219 | { |
204 | { |
220 | int skin_x_offset; |
205 | int skin_x_offset; |
221 | DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
206 | DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
222 | DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
207 | DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
223 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
208 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#edit_path); |
224 | address_box.offset = 0; |
209 | address_box.offset = 0; |
225 | edit_box_draw stdcall(#address_box); |
210 | edit_box_draw stdcall(#address_box); |
Line 226... | Line 211... | ||
226 | skin_x_offset = 51; |
211 | skin_x_offset = 51; |
227 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
- | |
228 | } |
- | |
229 | - | ||
230 | void LoadInternalPage(dword bufpos, in_filesize){ |
- | |
231 | bufsize = in_filesize; |
- | |
232 | bufpointer = bufpos; |
- | |
233 | ShowPage(); |
212 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, skin_x_offset, SKIN_Y); |
- | 213 | } |
|
- | 214 | ||
- | 215 | void LoadInternalPage(dword _bufpos, _bufsize) |
|
- | 216 | { |
|
- | 217 | if (bufpointer) free(bufpointer); |
|
- | 218 | ||
- | 219 | if (!_bufpos) || (!_bufsize) { |
|
234 | } |
220 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
- | 221 | return; |
|
- | 222 | } |
|
- | 223 | strcpy(#edit_path, #current_path); |
|
235 | 224 | DrawEditBoxWebView(); |
|
- | 225 | ||
- | 226 | bufpointer = _bufpos; |
|
- | 227 | bufsize = _bufsize; |
|
236 | void ShowPage() |
228 | bufpointer = malloc(bufsize); |
237 | { |
229 | strcpy(bufpointer, _bufpos); |
238 | DrawEditBoxWebView(); |
230 | |
Line -... | Line 231... | ||
- | 231 | WB1.list.first = 0; |
|
- | 232 | WB1.ParseHtml(); |
|
- | 233 | WB1.DrawPage(); |
|
- | 234 | } |
|
- | 235 | ||
- | 236 | void EventOpenDialog() |
|
- | 237 | { |
|
- | 238 | OpenDialog_start stdcall (#o_dialog); |
|
- | 239 | if (o_dialog.status) { |
|
239 | if (!bufsize) LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
240 | OpenPage(#openfile_path); |
240 | WB1.ParseHtml(); |
241 | } |
241 | WB1.DrawPage(); |
242 | } |
Line 242... | Line 243... | ||
242 | } |
243 |