Rev 7516 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7516 | Rev 7768 | ||
---|---|---|---|
1 | #define MEMSIZE 4096*25 |
1 | #define MEMSIZE 4096*25 |
2 | 2 | ||
3 | //===================================================// |
3 | //===================================================// |
4 | // // |
4 | // // |
5 | // LIB // |
5 | // LIB // |
6 | // // |
6 | // // |
7 | //===================================================// |
7 | //===================================================// |
8 | 8 | ||
9 | #include "../lib/io.h" |
9 | #include "../lib/io.h" |
10 | #include "../lib/gui.h" |
10 | #include "../lib/gui.h" |
11 | #include "../lib/list_box.h" |
11 | #include "../lib/list_box.h" |
12 | #include "../lib/kfont.h" |
12 | #include "../lib/kfont.h" |
13 | 13 | ||
14 | #include "../lib/obj/box_lib.h" |
14 | #include "../lib/obj/box_lib.h" |
15 | #include "../lib/obj/libini.h" |
15 | #include "../lib/obj/libini.h" |
16 | #include "../lib/obj/libimg.h" |
16 | #include "../lib/obj/libimg.h" |
17 | #include "../lib/obj/iconv.h" |
17 | #include "../lib/obj/iconv.h" |
18 | #include "../lib/obj/proc_lib.h" |
18 | #include "../lib/obj/proc_lib.h" |
19 | 19 | ||
20 | #include "../lib/patterns/simple_open_dialog.h" |
20 | #include "../lib/patterns/simple_open_dialog.h" |
21 | 21 | ||
22 | //===================================================// |
22 | //===================================================// |
23 | // // |
23 | // // |
24 | // DATA // |
24 | // DATA // |
25 | // // |
25 | // // |
26 | //===================================================// |
26 | //===================================================// |
27 | 27 | ||
28 | #define TOOLBAR_H 34 |
28 | #define TOOLBAR_H 34 |
29 | #define TOOLBAR_ICON_WIDTH 26 |
29 | #define TOOLBAR_ICON_WIDTH 26 |
30 | #define TOOLBAR_ICON_HEIGHT 24 |
30 | #define TOOLBAR_ICON_HEIGHT 24 |
31 | 31 | ||
32 | #define DEFAULT_EDITOR "/sys/tinypad" |
32 | #define DEFAULT_EDITOR "/sys/tinypad" |
33 | 33 | ||
34 | #define INTRO_TEXT "This is a plain Text Reader.\nTry to open some text file." |
34 | #define INTRO_TEXT "This is a plain Text Reader.\nTry to open some text file." |
35 | #define VERSION "Text Reader v1.3" |
35 | #define VERSION "Text Reader v1.3" |
36 | #define ABOUT "Idea: Leency, punk_joker |
36 | #define ABOUT "Idea: Leency, punk_joker |
37 | Code: Leency, Veliant, KolibriOS Team |
37 | Code: Leency, Veliant, KolibriOS Team |
38 | 38 | ||
39 | Hotkeys: |
39 | Hotkeys: |
40 | Ctrl+O - open file |
40 | Ctrl+O - open file |
41 | Ctrl+I - show file properties |
41 | Ctrl+I - show file properties |
42 | Ctrl+Up - bigger font |
42 | Ctrl+Up - bigger font |
43 | Ctrl+Down - smaller font |
43 | Ctrl+Down - smaller font |
44 | Ctrl+Tab - select charset |
44 | Ctrl+Tab - select charset |
45 | Ctrl+E - reopen current file in another app |
45 | Ctrl+E - reopen current file in another app |
46 | 46 | ||
47 | Press any key..." |
47 | Press any key..." |
48 | 48 | ||
49 | dword color_schemes[] = { |
49 | dword color_schemes[] = { |
50 | 0xFFFfff, 0, |
50 | 0xFFFfff, 0, |
51 | 0xF0F0F0, 0, |
51 | 0xF0F0F0, 0, |
52 | 0xFDF6E3, 0x101A21, |
52 | 0xFDF6E3, 0x101A21, |
53 | 0xFCF0DA, 0x171501, |
53 | 0xFCF0DA, 0x171501, |
54 | 0xF0F0C7, 0, |
54 | 0xF0F0C7, 0, |
55 | 0x282C34, 0xABB2BF, |
55 | 0x282C34, 0xABB2BF, |
56 | 0x282923, 0xD8D8D2 |
56 | 0x282923, 0xD8D8D2 |
57 | }; |
57 | }; |
58 | 58 | ||
59 | char color_scheme_names[] = |
59 | char color_scheme_names[] = |
60 | "White & Black |
60 | "White & Black |
61 | Grey & Black RtfRead |
61 | Grey & Black RtfRead |
62 | Linen & Black Horst |
62 | Linen & Black Horst |
63 | Antique & Black Pocket |
63 | Antique & Black Pocket |
64 | Lemon & Black Fb2Read |
64 | Lemon & Black Fb2Read |
65 | DarkGrey & Grey Godot |
65 | DarkGrey & Grey Godot |
66 | DarkGrey & Grey Monokai"; |
66 | DarkGrey & Grey Monokai"; |
67 | 67 | ||
68 | char default_dir[] = "/rd/1"; |
68 | char default_dir[] = "/rd/1"; |
69 | od_filter filter2 = { 8, "TXT\0\0" }; |
69 | od_filter filter2 = { 8, "TXT\0\0" }; |
70 | 70 | ||
71 | scroll_bar scroll = { 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}; |
71 | scroll_bar scroll = { 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}; |
72 | llist list; |
72 | llist list; |
73 | 73 | ||
74 | proc_info Form; |
74 | proc_info Form; |
75 | char title[4196]; |
75 | char title[4196]; |
76 | 76 | ||
77 | bool help_opened = false; |
77 | bool help_opened = false; |
78 | int charsets_mx; |
78 | int charsets_mx; |
79 | int reopenin_mx; |
79 | int reopenin_mx; |
80 | int colscheme_mx; |
80 | int colscheme_mx; |
81 | 81 | ||
82 | int curcol_scheme; |
82 | int curcol_scheme; |
83 | 83 | ||
84 | enum { |
84 | enum { |
85 | OPEN_FILE, |
85 | OPEN_FILE, |
86 | MAGNIFY_MINUS, |
86 | MAGNIFY_MINUS, |
87 | MAGNIFY_PLUS, |
87 | MAGNIFY_PLUS, |
88 | CHANGE_ENCODING, |
88 | CHANGE_ENCODING, |
89 | RUN_EDIT, |
89 | RUN_EDIT, |
90 | SHOW_INFO, |
90 | SHOW_INFO, |
91 | SHOW_FILE_PROPERTIES, |
91 | SHOW_FILE_PROPERTIES, |
92 | COLOR_SCHEME |
92 | COLOR_SCHEME |
93 | }; |
93 | }; |
94 | 94 | ||
95 | int encoding; |
95 | int encoding; |
96 | 96 | ||
97 | dword bg_color; |
97 | dword bg_color; |
98 | dword text_color; |
98 | dword text_color; |
99 | 99 | ||
100 | //===================================================// |
100 | //===================================================// |
101 | // // |
101 | // // |
102 | // INTERNAL INCLUDES // |
102 | // INTERNAL INCLUDES // |
103 | // // |
103 | // // |
104 | //===================================================// |
104 | //===================================================// |
105 | 105 | ||
106 | #include "ini.h" |
106 | #include "ini.h" |
107 | #include "prepare_page.h" |
107 | #include "prepare_page.h" |
108 | 108 | ||
109 | //===================================================// |
109 | //===================================================// |
110 | // // |
110 | // // |
111 | // CODE // |
111 | // CODE // |
112 | // // |
112 | // // |
113 | //===================================================// |
113 | //===================================================// |
114 | 114 | ||
115 | void InitDlls() |
115 | void InitDlls() |
116 | { |
116 | { |
117 | load_dll(boxlib, #box_lib_init, 0); |
117 | load_dll(boxlib, #box_lib_init, 0); |
118 | load_dll(libio, #libio_init, 1); |
118 | load_dll(libio, #libio_init, 1); |
119 | load_dll(libimg, #libimg_init, 1); |
119 | load_dll(libimg, #libimg_init, 1); |
120 | load_dll(libini, #lib_init, 1); |
120 | load_dll(libini, #lib_init, 1); |
121 | load_dll(iconv_lib, #iconv_open, 0); |
121 | load_dll(iconv_lib, #iconv_open, 0); |
122 | load_dll(Proc_lib, #OpenDialog_init,0); |
122 | load_dll(Proc_lib, #OpenDialog_init,0); |
123 | } |
123 | } |
124 | 124 | ||
125 | void main() |
125 | void main() |
126 | { |
126 | { |
127 | InitDlls(); |
127 | InitDlls(); |
128 | OpenDialog_init stdcall (#o_dialog); |
128 | OpenDialog_init stdcall (#o_dialog); |
129 | if (param) strcpy(#openfile_path, #param); |
129 | if (param) strcpy(#openfile_path, #param); |
130 | LoadIniSettings(); |
130 | LoadIniSettings(); |
131 | EventSetColorScheme(curcol_scheme); |
131 | EventSetColorScheme(curcol_scheme); |
132 | kfont.init(DEFAULT_FONT); |
132 | kfont.init(DEFAULT_FONT); |
133 | Libimg_LoadImage(#skin, abspath("toolbar.png")); |
133 | Libimg_LoadImage(#skin, abspath("toolbar.png")); |
134 | OpenFile(#param); |
134 | OpenFile(#param); |
135 | list.no_selection = true; |
135 | list.no_selection = true; |
136 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
136 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
137 | loop() |
137 | loop() |
138 | { |
138 | { |
139 | switch(WaitEvent()) |
139 | switch(WaitEvent()) |
140 | { |
140 | { |
141 | case evMouse: |
141 | case evMouse: |
142 | HandleMouseEvent(); |
142 | HandleMouseEvent(); |
143 | break; |
143 | break; |
144 | case evKey: |
144 | case evKey: |
145 | HandleKeyEvent(); |
145 | HandleKeyEvent(); |
146 | break; |
146 | break; |
147 | case evButton: |
147 | case evButton: |
148 | HandleButtonEvent(); |
148 | HandleButtonEvent(); |
149 | break; |
149 | break; |
150 | case evReDraw: |
150 | case evReDraw: |
151 | EventMenuClick(); |
151 | EventMenuClick(); |
152 | draw_window(); |
152 | draw_window(); |
153 | } |
153 | } |
154 | } |
154 | } |
155 | } |
155 | } |
156 | 156 | ||
157 | //===================================================// |
157 | //===================================================// |
158 | // // |
158 | // // |
159 | // EVENTS // |
159 | // EVENTS // |
160 | // // |
160 | // // |
161 | //===================================================// |
161 | //===================================================// |
162 | 162 | ||
163 | void HandleButtonEvent() |
163 | void HandleButtonEvent() |
164 | { |
164 | { |
165 | 165 | ||
166 | byte btn = GetButtonID(); |
166 | byte btn = GetButtonID(); |
167 | if (btn==1) { |
167 | if (btn==1) { |
168 | SaveIniSettings(); |
168 | SaveIniSettings(); |
169 | ExitProcess(); |
169 | ExitProcess(); |
170 | } |
170 | } |
171 | btn-=10; |
171 | btn-=10; |
172 | switch(btn) |
172 | switch(btn) |
173 | { |
173 | { |
174 | case OPEN_FILE: |
174 | case OPEN_FILE: |
175 | EventOpenFile(); |
175 | EventOpenFile(); |
176 | break; |
176 | break; |
177 | case SHOW_FILE_PROPERTIES: |
177 | case SHOW_FILE_PROPERTIES: |
178 | EventShowFileProperties(); |
178 | EventShowFileProperties(); |
179 | break; |
179 | break; |
180 | case MAGNIFY_PLUS: |
180 | case MAGNIFY_PLUS: |
181 | EventMagnifyPlus(); |
181 | EventMagnifyPlus(); |
182 | break; |
182 | break; |
183 | case MAGNIFY_MINUS: |
183 | case MAGNIFY_MINUS: |
184 | EventMagnifyMinus(); |
184 | EventMagnifyMinus(); |
185 | break; |
185 | break; |
186 | case CHANGE_ENCODING: |
186 | case CHANGE_ENCODING: |
187 | EventShowEncodingList(); |
187 | EventShowEncodingList(); |
188 | break; |
188 | break; |
189 | case RUN_EDIT: |
189 | case RUN_EDIT: |
190 | EventShowReopenMenu(); |
190 | EventShowReopenMenu(); |
191 | break; |
191 | break; |
192 | case COLOR_SCHEME: |
192 | case COLOR_SCHEME: |
193 | EventShowColorSchemesList(); |
193 | EventShowColorSchemesList(); |
194 | break; |
194 | break; |
195 | case SHOW_INFO: |
195 | case SHOW_INFO: |
196 | EventShowInfo(); |
196 | EventShowInfo(); |
197 | break; |
197 | break; |
198 | } |
198 | } |
199 | } |
199 | } |
200 | 200 | ||
201 | 201 | ||
202 | void HandleKeyEvent() |
202 | void HandleKeyEvent() |
203 | { |
203 | { |
204 | if (help_opened) { |
204 | if (help_opened) { |
205 | help_opened = false; |
205 | help_opened = false; |
206 | DrawPage(); |
206 | DrawPage(); |
207 | return; |
207 | return; |
208 | } |
208 | } |
209 | GetKeys(); |
209 | GetKeys(); |
210 | if (key_scancode == SCAN_CODE_F1) { |
210 | if (key_scancode == SCAN_CODE_F1) { |
211 | EventShowInfo(); |
211 | EventShowInfo(); |
212 | return; |
212 | return; |
213 | } |
213 | } |
214 | if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) { |
214 | if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) { |
215 | switch (key_scancode) |
215 | switch (key_scancode) |
216 | { |
216 | { |
217 | case SCAN_CODE_KEY_O: |
217 | case SCAN_CODE_KEY_O: |
218 | EventOpenFile(); |
218 | EventOpenFile(); |
219 | break; |
219 | break; |
220 | case SCAN_CODE_KEY_I: |
220 | case SCAN_CODE_KEY_I: |
221 | EventShowFileProperties(); |
221 | EventShowFileProperties(); |
222 | break; |
222 | break; |
223 | case SCAN_CODE_UP: |
223 | case SCAN_CODE_UP: |
224 | EventMagnifyPlus(); |
224 | EventMagnifyPlus(); |
225 | break; |
225 | break; |
226 | case SCAN_CODE_DOWN: |
226 | case SCAN_CODE_DOWN: |
227 | EventMagnifyMinus(); |
227 | EventMagnifyMinus(); |
228 | break; |
228 | break; |
229 | case SCAN_CODE_KEY_E: |
229 | case SCAN_CODE_KEY_E: |
230 | EventShowReopenMenu(); |
230 | EventShowReopenMenu(); |
231 | break; |
231 | break; |
232 | case SCAN_CODE_TAB: |
232 | case SCAN_CODE_TAB: |
233 | EventChangeEncoding(); |
233 | EventChangeEncoding(); |
234 | break; |
234 | break; |
235 | } |
235 | } |
236 | return; |
236 | return; |
237 | } |
237 | } |
238 | if (list.ProcessKey(key_scancode)) |
238 | if (list.ProcessKey(key_scancode)) |
239 | DrawPage(); |
239 | DrawPage(); |
240 | } |
240 | } |
241 | 241 | ||
242 | 242 | ||
243 | void HandleMouseEvent() |
243 | void HandleMouseEvent() |
244 | { |
244 | { |
245 | mouse.get(); |
245 | mouse.get(); |
246 | list.wheel_size = 7; |
246 | list.wheel_size = 7; |
247 | if (list.MouseScroll(mouse.vert)) { |
247 | if (list.MouseScroll(mouse.vert)) { |
248 | DrawPage(); |
248 | DrawPage(); |
249 | return; |
249 | return; |
250 | } |
250 | } |
251 | scrollbar_v_mouse (#scroll); |
251 | scrollbar_v_mouse (#scroll); |
252 | if (list.first != scroll.position) { |
252 | if (list.first != scroll.position) { |
253 | list.first = scroll.position; |
253 | list.first = scroll.position; |
254 | DrawPage(); |
254 | DrawPage(); |
255 | } |
255 | } |
256 | } |
256 | } |
257 | 257 | ||
258 | /* ----------------------------------------------------- */ |
258 | /* ----------------------------------------------------- */ |
259 | 259 | ||
260 | void EventOpenFile() |
260 | void EventOpenFile() |
261 | { |
261 | { |
262 | OpenDialog_start stdcall (#o_dialog); |
262 | OpenDialog_start stdcall (#o_dialog); |
263 | if (o_dialog.status) { |
263 | if (o_dialog.status) { |
264 | OpenFile(#openfile_path); |
264 | OpenFile(#openfile_path); |
265 | PreparePage(); |
265 | PreparePage(); |
266 | } |
266 | } |
267 | } |
267 | } |
268 | 268 | ||
269 | void EventShowFileProperties() |
269 | void EventShowFileProperties() |
270 | { |
270 | { |
271 | char ss_param[4096]; |
271 | char ss_param[4096]; |
272 | if (!param) return; |
272 | if (!param) return; |
- | 273 | strcpy(#ss_param, "-p "); |
|
273 | sprintf(#ss_param, "-p %s", #param); |
274 | strcpy(#ss_param+3, #param); |
274 | RunProgram("/sys/File managers/Eolite", #ss_param); |
275 | RunProgram("/sys/File managers/Eolite", #ss_param); |
275 | } |
276 | } |
276 | 277 | ||
277 | void EventMagnifyPlus() |
278 | void EventMagnifyPlus() |
278 | { |
279 | { |
279 | kfont.size.pt++; |
280 | kfont.size.pt++; |
280 | if(!kfont.changeSIZE()) |
281 | if(!kfont.changeSIZE()) |
281 | kfont.size.pt--; |
282 | kfont.size.pt--; |
282 | else |
283 | else |
283 | PreparePage(); |
284 | PreparePage(); |
284 | } |
285 | } |
285 | 286 | ||
286 | void EventMagnifyMinus() |
287 | void EventMagnifyMinus() |
287 | { |
288 | { |
288 | kfont.size.pt--; |
289 | kfont.size.pt--; |
289 | if(!kfont.changeSIZE()) |
290 | if(!kfont.changeSIZE()) |
290 | kfont.size.pt++; |
291 | kfont.size.pt++; |
291 | else |
292 | else |
292 | PreparePage(); |
293 | PreparePage(); |
293 | } |
294 | } |
294 | 295 | ||
295 | void EventShowEncodingList() |
296 | void EventShowEncodingList() |
296 | { |
297 | { |
297 | menu.selected = encoding + 1; |
298 | menu.selected = encoding + 1; |
298 | menu.show(Form.left+5 + charsets_mx, Form.top+29+skin_height, 130, |
299 | menu.show(Form.left+5 + charsets_mx, Form.top+29+skin_height, 130, |
299 | "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10); |
300 | "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10); |
300 | } |
301 | } |
301 | 302 | ||
302 | void EventShowReopenMenu() |
303 | void EventShowReopenMenu() |
303 | { |
304 | { |
304 | menu.selected = 0; |
305 | menu.selected = 0; |
305 | menu.show(Form.left+5 + reopenin_mx, Form.top+29+skin_height, 130, |
306 | menu.show(Form.left+5 + reopenin_mx, Form.top+29+skin_height, 130, |
306 | "Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther", 20); |
307 | "Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther", 20); |
307 | } |
308 | } |
308 | 309 | ||
309 | void EventShowColorSchemesList() |
310 | void EventShowColorSchemesList() |
310 | { |
311 | { |
311 | menu.selected = curcol_scheme + 1; |
312 | menu.selected = curcol_scheme + 1; |
312 | menu.show(Form.left+5 + colscheme_mx, Form.top+29+skin_height, 175, #color_scheme_names, 30); |
313 | menu.show(Form.left+5 + colscheme_mx, Form.top+29+skin_height, 175, #color_scheme_names, 30); |
313 | } |
314 | } |
314 | 315 | ||
315 | void EventSetColorScheme(dword _setn) |
316 | void EventSetColorScheme(dword _setn) |
316 | { |
317 | { |
317 | curcol_scheme = _setn; |
318 | curcol_scheme = _setn; |
318 | bg_color = color_schemes[curcol_scheme*2]; |
319 | bg_color = color_schemes[curcol_scheme*2]; |
319 | text_color = color_schemes[curcol_scheme*2+1]; |
320 | text_color = color_schemes[curcol_scheme*2+1]; |
320 | } |
321 | } |
321 | 322 | ||
322 | void EventShowInfo() { |
323 | void EventShowInfo() { |
323 | help_opened = true; |
324 | help_opened = true; |
324 | DrawBar(list.x, list.y, list.w, list.h, 0xFFFfff); |
325 | DrawBar(list.x, list.y, list.w, list.h, 0xFFFfff); |
325 | WriteText(list.x + 10, list.y + 10, 10000001b, 0x555555, VERSION); |
326 | WriteText(list.x + 10, list.y + 10, 10000001b, 0x555555, VERSION); |
326 | WriteTextLines(list.x + 10, list.y+40, 10110000b, 0, ABOUT, 20); |
327 | WriteTextLines(list.x + 10, list.y+40, 10110000b, 0, ABOUT, 20); |
327 | } |
328 | } |
328 | 329 | ||
329 | void EventChangeEncoding(dword id) |
330 | void EventChangeEncoding(dword id) |
330 | { |
331 | { |
331 | encoding = id; |
332 | encoding = id; |
332 | OpenFile(#openfile_path); |
333 | OpenFile(#openfile_path); |
333 | PreparePage(); |
334 | PreparePage(); |
334 | draw_window(); |
335 | draw_window(); |
335 | } |
336 | } |
336 | 337 | ||
337 | void EventOpenFileInAnotherProgram(dword _app) |
338 | void EventOpenFileInAnotherProgram(dword _app) |
338 | { |
339 | { |
339 | RunProgram(_app, #param); |
340 | RunProgram(_app, #param); |
340 | } |
341 | } |
341 | 342 | ||
342 | void EventMenuClick() |
343 | void EventMenuClick() |
343 | { |
344 | { |
344 | byte open_param[4096]; |
345 | byte open_param[4096]; |
345 | switch(menu.cur_y) |
346 | switch(menu.cur_y) |
346 | { |
347 | { |
347 | //Encoding |
348 | //Encoding |
348 | case 10...15: |
349 | case 10...15: |
349 | EventChangeEncoding(menu.cur_y-10); |
350 | EventChangeEncoding(menu.cur_y-10); |
350 | break; |
351 | break; |
351 | //Reopen |
352 | //Reopen |
352 | case 20: |
353 | case 20: |
353 | EventOpenFileInAnotherProgram("/sys/tinypad"); |
354 | EventOpenFileInAnotherProgram("/sys/tinypad"); |
354 | break; |
355 | break; |
355 | case 21: |
356 | case 21: |
356 | EventOpenFileInAnotherProgram("/sys/develop/t_edit"); |
357 | EventOpenFileInAnotherProgram("/sys/develop/t_edit"); |
357 | break; |
358 | break; |
358 | case 22: |
359 | case 22: |
359 | EventOpenFileInAnotherProgram("/sys/network/webview"); |
360 | EventOpenFileInAnotherProgram("/sys/network/webview"); |
360 | break; |
361 | break; |
361 | case 23: |
362 | case 23: |
362 | EventOpenFileInAnotherProgram("/sys/fb2read"); |
363 | EventOpenFileInAnotherProgram("/sys/fb2read"); |
363 | break; |
364 | break; |
364 | case 24: |
365 | case 24: |
365 | EventOpenFileInAnotherProgram("/sys/develop/heed"); |
366 | EventOpenFileInAnotherProgram("/sys/develop/heed"); |
366 | break; |
367 | break; |
367 | case 25: |
368 | case 25: |
- | 369 | open_param[0]='~'; |
|
368 | sprintf(#open_param,"~%s",#param); |
370 | strcpy(#open_param+1,#param); |
369 | RunProgram("/sys/@open", #open_param); |
371 | RunProgram("/sys/@open", #open_param); |
370 | break; |
372 | break; |
371 | //ColorSchemes |
373 | //ColorSchemes |
372 | case 30...38: |
374 | case 30...38: |
373 | EventSetColorScheme(menu.cur_y-30); |
375 | EventSetColorScheme(menu.cur_y-30); |
374 | PreparePage(); |
376 | PreparePage(); |
375 | break; |
377 | break; |
376 | } |
378 | } |
377 | menu.cur_y = 0; |
379 | menu.cur_y = 0; |
378 | } |
380 | } |
379 | 381 | ||
380 | //===================================================// |
382 | //===================================================// |
381 | // // |
383 | // // |
382 | // DRAWS AND OTHER FUNCS // |
384 | // DRAWS AND OTHER FUNCS // |
383 | // // |
385 | // // |
384 | //===================================================// |
386 | //===================================================// |
385 | 387 | ||
386 | void OpenFile(dword f_path) |
388 | void OpenFile(dword f_path) |
387 | { |
389 | { |
388 | int tmp; |
390 | int tmp; |
389 | if (ESBYTE[f_path]) { |
391 | if (ESBYTE[f_path]) { |
390 | strcpy(#param, f_path); |
392 | strcpy(#param, f_path); |
391 | io.read(#param); |
393 | io.read(#param); |
392 | strcpy(#title, #param); |
394 | strcpy(#title, #param); |
393 | strcat(#title, " - Text Reader"); |
395 | strcat(#title, " - Text Reader"); |
394 | } |
396 | } |
395 | else { |
397 | else { |
396 | if (list.count) return; |
398 | if (list.count) return; |
397 | io.buffer_data = INTRO_TEXT; |
399 | io.buffer_data = INTRO_TEXT; |
398 | strcpy(#title, "Text Reader"); |
400 | strcpy(#title, "Text Reader"); |
399 | } |
401 | } |
400 | if (encoding!=CH_CP866) ChangeCharset(charsets[encoding], "CP866", io.buffer_data); |
402 | if (encoding!=CH_CP866) ChangeCharset(charsets[encoding], "CP866", io.buffer_data); |
401 | list.KeyHome(); |
403 | list.KeyHome(); |
402 | list.ClearList(); |
404 | list.ClearList(); |
403 | } |
405 | } |
404 | 406 | ||
405 | void draw_window() |
407 | void draw_window() |
406 | { |
408 | { |
407 | #define BUTTONS_GAP 6 |
409 | #define BUTTONS_GAP 6 |
408 | #define BLOCKS_GAP 15 |
410 | #define BLOCKS_GAP 15 |
409 | #define TOOLBAR_BUTTON_WIDTH 26 |
411 | #define TOOLBAR_BUTTON_WIDTH 26 |
410 | incn x; |
412 | incn x; |
411 | DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0); |
413 | DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0); |
412 | GetProcessInfo(#Form, SelfInfo); |
414 | GetProcessInfo(#Form, SelfInfo); |
413 | if (Form.status_window>2) return; |
415 | if (Form.status_window>2) return; |
414 | 416 | ||
415 | if (Form.width < 200) { MoveSize(OLD,OLD,200,OLD); return; } |
417 | if (Form.width < 200) { MoveSize(OLD,OLD,200,OLD); return; } |
416 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } |
418 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } |
417 | 419 | ||
418 | DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, 0xe1e1e1); |
420 | DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, 0xe1e1e1); |
419 | DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F); |
421 | DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, 0x7F7F7F); |
420 | 422 | ||
421 | x.n = 0; |
423 | x.n = 0; |
422 | DrawToolbarButton(OPEN_FILE, x.inc(8)); |
424 | DrawToolbarButton(OPEN_FILE, x.inc(8)); |
423 | DrawToolbarButton(SHOW_FILE_PROPERTIES, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP)); |
425 | DrawToolbarButton(SHOW_FILE_PROPERTIES, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP)); |
424 | 426 | ||
425 | DrawToolbarButton(MAGNIFY_MINUS, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); |
427 | DrawToolbarButton(MAGNIFY_MINUS, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); |
426 | DrawToolbarButton(MAGNIFY_PLUS, x.inc(TOOLBAR_BUTTON_WIDTH - 1)); |
428 | DrawToolbarButton(MAGNIFY_PLUS, x.inc(TOOLBAR_BUTTON_WIDTH - 1)); |
427 | DrawToolbarButton(COLOR_SCHEME, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP)); colscheme_mx = x.n; |
429 | DrawToolbarButton(COLOR_SCHEME, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP)); colscheme_mx = x.n; |
428 | 430 | ||
429 | DrawToolbarButton(CHANGE_ENCODING, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); charsets_mx = x.n; |
431 | DrawToolbarButton(CHANGE_ENCODING, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); charsets_mx = x.n; |
430 | DrawToolbarButton(RUN_EDIT, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); reopenin_mx = x.n; |
432 | DrawToolbarButton(RUN_EDIT, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); reopenin_mx = x.n; |
431 | DrawToolbarButton(SHOW_INFO, Form.cwidth - 34); |
433 | DrawToolbarButton(SHOW_INFO, Form.cwidth - 34); |
432 | 434 | ||
433 | if ((Form.cwidth-scroll.size_x-1 == list.w) && |
435 | if ((Form.cwidth-scroll.size_x-1 == list.w) && |
434 | (Form.cheight-TOOLBAR_H == list.h) && |
436 | (Form.cheight-TOOLBAR_H == list.h) && |
435 | (list.count) |
437 | (list.count) |
436 | ) |
438 | ) |
437 | { |
439 | { |
438 | DrawPage(); |
440 | DrawPage(); |
439 | } else { |
441 | } else { |
440 | PreparePage(); |
442 | PreparePage(); |
441 | } |
443 | } |
442 | 444 | ||
443 | DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col); |
445 | DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col); |
444 | } |
446 | } |
445 | 447 | ||
446 | void DrawPage() |
448 | void DrawPage() |
447 | { |
449 | { |
448 | kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w); |
450 | kfont.ShowBufferPart(list.x, list.y, list.w, list.h, list.first*list.item_h*list.w); |
449 | DrawScroller(); |
451 | DrawScroller(); |
450 | } |
452 | } |
451 | 453 | ||
452 | void DrawToolbarButton(char image_id, int x) |
454 | void DrawToolbarButton(char image_id, int x) |
453 | { |
455 | { |
454 | DefineButton(x+1, 6, TOOLBAR_ICON_WIDTH-2, TOOLBAR_ICON_HEIGHT-2, 10+image_id + BT_HIDE, 0); |
456 | DefineButton(x+1, 6, TOOLBAR_ICON_WIDTH-2, TOOLBAR_ICON_HEIGHT-2, 10+image_id + BT_HIDE, 0); |
455 | img_draw stdcall(skin.image, x, 5, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, TOOLBAR_ICON_WIDTH-1*image_id, 0); |
457 | img_draw stdcall(skin.image, x, 5, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, TOOLBAR_ICON_WIDTH-1*image_id, 0); |
456 | } |
458 | } |
457 | 459 | ||
458 | void DrawScroller() |
460 | void DrawScroller() |
459 | { |
461 | { |
460 | scroll.max_area = list.count; |
462 | scroll.max_area = list.count; |
461 | scroll.cur_area = list.visible; |
463 | scroll.cur_area = list.visible; |
462 | scroll.position = list.first; |
464 | scroll.position = list.first; |
463 | scroll.all_redraw = 0; |
465 | scroll.all_redraw = 0; |
464 | scroll.start_x = list.x + list.w; |
466 | scroll.start_x = list.x + list.w; |
465 | scroll.start_y = list.y; |
467 | scroll.start_y = list.y; |
466 | scroll.size_y = list.h; |
468 | scroll.size_y = list.h; |
467 | scrollbar_v_draw(#scroll); |
469 | scrollbar_v_draw(#scroll); |
468 | }>> |
470 | }>> |