Rev 7921 | Rev 7941 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7921 | Rev 7924 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | Quark Code Edit v0.2 |
2 | Quark Code Edit v0.2 |
3 | Author: Kiril Lipatov aka Leency |
3 | Author: Kiril Lipatov aka Leency |
4 | Licence: GPLv2 |
4 | Licence: GPLv2 |
5 | 5 | ||
6 | The core components of this app are: |
6 | The core components of this app are: |
7 | 1. list: text grid with keyboard and mouse proceed |
7 | 1. list: text grid with keyboard and mouse events |
8 | 2. lines: the mas of pointers for each line start |
8 | 2. lines: the mas of pointers for each line start |
9 | 3. selection |
9 | 3. selection |
10 | */ |
10 | */ |
11 | 11 | ||
12 | #define MEMSIZE 1024*100 |
12 | #define MEMSIZE 1024*100 |
13 | 13 | ||
14 | //===================================================// |
14 | //===================================================// |
15 | // // |
15 | // // |
16 | // LIB // |
16 | // LIB // |
17 | // // |
17 | // // |
18 | //===================================================// |
18 | //===================================================// |
19 | 19 | ||
20 | #include "../lib/io.h" |
20 | #include "../lib/io.h" |
21 | #include "../lib/gui.h" |
21 | #include "../lib/gui.h" |
22 | #include "../lib/list_box.h" |
22 | #include "../lib/list_box.h" |
23 | #include "../lib/draw_buf.h" |
23 | #include "../lib/draw_buf.h" |
24 | #include "../lib/events.h" |
24 | #include "../lib/events.h" |
25 | #include "../lib/array.h" |
25 | #include "../lib/array.h" |
26 | #include "../lib/clipboard.h" |
26 | #include "../lib/clipboard.h" |
27 | #include "../lib/math.h" |
27 | #include "../lib/math.h" |
28 | 28 | ||
29 | #include "../lib/obj/box_lib.h" |
29 | #include "../lib/obj/box_lib.h" |
30 | #include "../lib/obj/libini.h" |
30 | #include "../lib/obj/libini.h" |
31 | #include "../lib/obj/libimg.h" |
31 | #include "../lib/obj/libimg.h" |
32 | #include "../lib/obj/iconv.h" |
32 | #include "../lib/obj/iconv.h" |
33 | #include "../lib/obj/proc_lib.h" |
33 | #include "../lib/obj/proc_lib.h" |
34 | 34 | ||
35 | #include "../lib/patterns/simple_open_dialog.h" |
35 | #include "../lib/patterns/simple_open_dialog.h" |
36 | #include "../lib/patterns/toolbar_button.h" |
36 | #include "../lib/patterns/toolbar_button.h" |
37 | 37 | ||
38 | //===================================================// |
38 | //===================================================// |
39 | // // |
39 | // // |
40 | // INTERNAL INCLUDES // |
40 | // INTERNAL INCLUDES // |
41 | // // |
41 | // // |
42 | //===================================================// |
42 | //===================================================// |
43 | 43 | ||
44 | proc_info Form; |
44 | proc_info Form; |
45 | llist list; |
45 | llist list; |
46 | 46 | ||
47 | #define TOOLBAR_H 38 |
47 | #define TOOLBAR_H 38 |
48 | #define TOOLBAR_ICON_WIDTH 24 |
48 | #define TOOLBAR_ICON_WIDTH 24 |
49 | #define TOOLBAR_ICON_HEIGHT 22 |
49 | #define TOOLBAR_ICON_HEIGHT 22 |
50 | #define STATUSBAR_H 15 |
50 | #define STATUSBAR_H 15 |
51 | #define TAB_H 20 |
51 | #define TAB_H 20 |
52 | 52 | ||
53 | int user_encoding; |
53 | int user_encoding; |
54 | int real_encoding = CH_CP866; |
54 | int real_encoding = CH_CP866; |
55 | int curcol_scheme; |
55 | int curcol_scheme; |
56 | int font_size; |
56 | int font_size; |
57 | 57 | ||
58 | #include "data.h" |
58 | #include "data.h" |
59 | 59 | ||
60 | #include "../txtread/search.h" |
60 | #include "../txtread/search.h" |
61 | #include "selection.h" |
61 | #include "selection.h" |
62 | #include "prepare_page.h" |
62 | #include "prepare_page.h" |
63 | 63 | ||
64 | //===================================================// |
64 | //===================================================// |
65 | // // |
65 | // // |
66 | // DATA // |
66 | // DATA // |
67 | // // |
67 | // // |
68 | //===================================================// |
68 | //===================================================// |
69 | 69 | ||
70 | scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee, |
70 | scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee, |
71 | 0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
71 | 0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
72 | 72 | ||
73 | char title[4196]; |
73 | char title[4196]; |
74 | 74 | ||
75 | bool help_opened = false; |
75 | bool help_opened = false; |
76 | 76 | ||
77 | int reopenin_mx, |
77 | int reopenin_mx, |
78 | theme_mx, |
78 | theme_mx, |
79 | burger_mx, |
79 | burger_mx, |
80 | search_mx; |
80 | search_mx; |
81 | 81 | ||
82 | enum { |
82 | enum { |
83 | CHANGE_CHARSET=12, |
83 | CHANGE_CHARSET=12, |
84 | REOPEN_IN_APP=1, |
84 | REOPEN_IN_APP=1, |
85 | COLOR_SCHEME=8, |
85 | COLOR_SCHEME=8, |
86 | RMB_MENU, |
86 | RMB_MENU, |
87 | BTN_FIND_NEXT, |
87 | BTN_FIND_NEXT, |
88 | BTN_FIND_CLOSE |
88 | BTN_FIND_CLOSE, |
- | 89 | BTN_CHANGE_CHARSET |
|
89 | }; |
90 | }; |
90 | 91 | ||
91 | dword menu_id; |
92 | dword menu_id; |
92 | 93 | ||
93 | EVENTS button; |
94 | EVENTS button; |
94 | EVENTS key; |
95 | EVENTS key; |
95 | 96 | ||
96 | //===================================================// |
97 | //===================================================// |
97 | // // |
98 | // // |
98 | // CODE // |
99 | // CODE // |
99 | // // |
100 | // // |
100 | //===================================================// |
101 | //===================================================// |
101 | 102 | ||
102 | void InitDlls() |
103 | void InitDlls() |
103 | { |
104 | { |
104 | load_dll(boxlib, #box_lib_init, 0); |
105 | load_dll(boxlib, #box_lib_init, 0); |
105 | load_dll(libio, #libio_init, 1); |
106 | load_dll(libio, #libio_init, 1); |
106 | load_dll(libimg, #libimg_init, 1); |
107 | load_dll(libimg, #libimg_init, 1); |
107 | load_dll(libini, #lib_init, 1); |
108 | load_dll(libini, #lib_init, 1); |
108 | load_dll(iconv_lib, #iconv_open, 0); |
109 | load_dll(iconv_lib, #iconv_open, 0); |
109 | load_dll(Proc_lib, #OpenDialog_init,0); |
110 | load_dll(Proc_lib, #OpenDialog_init,0); |
110 | OpenDialog_init stdcall (#o_dialog); |
111 | OpenDialog_init stdcall (#o_dialog); |
111 | } |
112 | } |
112 | 113 | ||
113 | void LoadFileFromDocPack() |
114 | void LoadFileFromDocPack() |
114 | { |
115 | { |
115 | dword bufsize = atoi(#param + 1) + 20; |
116 | dword bufsize = atoi(#param + 1) + 20; |
116 | dword bufpointer = malloc(bufsize); |
117 | dword bufpointer = malloc(bufsize); |
117 | dword filesize; |
- | |
118 | 118 | ||
119 | ESDWORD[bufpointer+0] = 0; |
119 | ESDWORD[bufpointer+0] = 0; |
120 | ESDWORD[bufpointer+4] = 8; |
120 | ESDWORD[bufpointer+4] = 8; |
121 | - | ||
122 | IpcSetArea(bufpointer, bufsize); |
121 | IpcSetArea(bufpointer, bufsize); |
123 | SetEventMask(EVM_IPC); |
- | |
- | 122 | ||
124 | 123 | SetEventMask(EVM_IPC); |
|
125 | if (@WaitEventTimeout(200) != evIPC) { |
124 | if (@WaitEventTimeout(200) != evIPC) { |
126 | notify("'IPC FAIL'E"); |
125 | notify("'IPC FAIL'E"); |
127 | return; |
126 | return; |
128 | } |
127 | } |
129 | 128 | ||
130 | io.buffer_data = malloc(ESDWORD[bufpointer+12]); |
129 | io.buffer_data = malloc(ESDWORD[bufpointer+12]); |
131 | strcpy(io.buffer_data, bufpointer + 16); |
130 | strcpy(io.buffer_data, bufpointer + 16); |
132 | } |
131 | } |
133 | 132 | ||
134 | void main() |
133 | void main() |
135 | { |
134 | { |
136 | InitDlls(); |
135 | InitDlls(); |
137 | LoadIniSettings(); |
136 | LoadIniSettings(); |
138 | EventSetColorScheme(curcol_scheme); |
137 | EventSetColorScheme(curcol_scheme); |
139 | if (param[0] == '*') { |
138 | if (param[0] == '*') { |
140 | LoadFileFromDocPack(); |
139 | LoadFileFromDocPack(); |
141 | param[0]='\0'; |
140 | param[0]='\0'; |
142 | sprintf(#title, "#DOCPACK - %s", #short_app_name); |
141 | sprintf(#title, "#DOCPACK - %s", #short_app_name); |
143 | } else { |
142 | } else { |
144 | if (streq(#param,"-new")) {Form.left+=40;Form.top+=40;} |
143 | if (streq(#param,"-new")) {Form.left+=40;Form.top+=40;} |
145 | LoadFile(#param); |
144 | LoadFile(#param); |
146 | } |
145 | } |
147 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
146 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
148 | loop() |
147 | loop() |
149 | { |
148 | { |
150 | switch(@WaitEventTimeout(400)) |
149 | switch(@WaitEventTimeout(400)) |
151 | { |
150 | { |
152 | case evMouse: |
151 | case evMouse: |
153 | HandleMouseEvent(); |
152 | HandleMouseEvent(); |
154 | break; |
153 | break; |
155 | case evKey: |
154 | case evKey: |
156 | HandleKeyEvent(); |
155 | HandleKeyEvent(); |
157 | break; |
156 | break; |
158 | case evButton: |
157 | case evButton: |
159 | HandleButtonEvent(); |
158 | HandleButtonEvent(); |
160 | break; |
159 | break; |
161 | case evReDraw: |
160 | case evReDraw: |
162 | if (CheckActiveProcess(Form.ID)) EventMenuClick(); |
161 | if (CheckActiveProcess(Form.ID)) EventMenuClick(); |
163 | draw_window(); |
162 | draw_window(); |
164 | break; |
163 | break; |
165 | default: |
164 | default: |
166 | DrawStatusBar(" "); //clean DrawStatusBar text with delay |
165 | DrawStatusBar(" "); //clean DrawStatusBar text with delay |
167 | } |
166 | } |
168 | } |
167 | } |
169 | } |
168 | } |
170 | 169 | ||
171 | //===================================================// |
170 | //===================================================// |
172 | // // |
171 | // // |
173 | // EVENT HANDLERS // |
172 | // EVENT HANDLERS // |
174 | // // |
173 | // // |
175 | //===================================================// |
174 | //===================================================// |
176 | 175 | ||
177 | void HandleButtonEvent() |
176 | void HandleButtonEvent() |
178 | { |
177 | { |
179 | int btn = GetButtonID(); |
178 | int btn = GetButtonID(); |
180 | if (btn==1) { |
179 | if (btn==1) { |
181 | SaveIniSettings(); |
180 | SaveIniSettings(); |
182 | ExitProcess(); |
181 | ExitProcess(); |
183 | } |
182 | } |
184 | button.press(btn); |
183 | button.press(btn); |
185 | switch(btn-10) |
184 | switch(btn-10) |
186 | { |
185 | { |
187 | case BTN_FIND_NEXT: |
186 | case BTN_FIND_NEXT: |
188 | EventSearchNext(); |
187 | EventSearchNext(); |
189 | break; |
188 | break; |
190 | case BTN_FIND_CLOSE: |
189 | case BTN_FIND_CLOSE: |
191 | search.hide(); |
190 | search.hide(); |
192 | break; |
191 | break; |
- | 192 | case BTN_CHANGE_CHARSET: |
|
- | 193 | EventShowCharsetsList(); |
|
- | 194 | break; |
|
193 | } |
195 | } |
194 | } |
196 | } |
195 | 197 | ||
196 | void HandleKeyEvent() |
198 | void HandleKeyEvent() |
197 | { |
199 | { |
198 | int new_y; |
200 | int new_y; |
199 | if (help_opened) { |
201 | if (help_opened) { |
200 | help_opened = false; |
202 | help_opened = false; |
201 | DrawPage(); |
203 | DrawPage(); |
202 | return; |
204 | return; |
203 | } |
205 | } |
204 | GetKeys(); |
206 | GetKeys(); |
205 | 207 | ||
206 | if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) { |
208 | if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) { |
207 | if (key.press(ECTRL + key_scancode)) return; |
209 | if (key.press(ECTRL + key_scancode)) return; |
208 | switch (key_scancode) |
210 | switch (key_scancode) |
209 | { |
211 | { |
210 | case SCAN_CODE_KEY_X: |
212 | case SCAN_CODE_KEY_X: |
211 | EventCut(); |
213 | EventCut(); |
212 | return; |
214 | return; |
213 | case SCAN_CODE_KEY_C: |
215 | case SCAN_CODE_KEY_C: |
214 | EventCopy(); |
216 | EventCopy(); |
215 | return; |
217 | return; |
216 | case SCAN_CODE_KEY_V: |
218 | case SCAN_CODE_KEY_V: |
217 | EventPaste(); |
219 | EventPaste(); |
218 | return; |
220 | return; |
219 | case SCAN_CODE_UP: |
221 | case SCAN_CODE_UP: |
220 | EventMagnifyPlus(); |
222 | EventMagnifyPlus(); |
221 | return; |
223 | return; |
222 | case SCAN_CODE_DOWN: |
224 | case SCAN_CODE_DOWN: |
223 | EventMagnifyMinus(); |
225 | EventMagnifyMinus(); |
224 | return; |
226 | return; |
225 | case SCAN_CODE_TAB: |
227 | case SCAN_CODE_TAB: |
226 | EventShowCharsetsList(); |
228 | EventShowCharsetsList(); |
227 | return; |
229 | return; |
228 | case SCAN_CODE_KEY_F: |
230 | case SCAN_CODE_KEY_F: |
229 | search.show(); |
231 | search.show(); |
230 | return; |
232 | return; |
231 | case SCAN_CODE_HOME: |
- | |
232 | list.KeyHome(); |
- | |
233 | list.KeyHomeHor(); |
- | |
234 | DrawPage(); |
- | |
235 | return; |
- | |
236 | case SCAN_CODE_END: |
- | |
237 | list.KeyEnd(); |
- | |
238 | list.column_max = strlen(lines.get(list.cur_y)); |
- | |
239 | list.KeyEndHor(); |
- | |
240 | DrawPage(); |
- | |
241 | return; |
- | |
242 | case SCAN_CODE_KEY_A: |
233 | case SCAN_CODE_KEY_A: |
243 | selection.select_all(); |
234 | selection.select_all(); |
244 | DrawPage(); |
235 | DrawPage(); |
245 | return; |
236 | return; |
246 | } |
237 | } |
247 | } |
238 | } |
248 | switch (key_scancode) |
239 | switch (key_scancode) |
249 | { |
240 | { |
250 | case SCAN_CODE_F1: |
241 | case SCAN_CODE_F1: |
251 | EventShowInfo(); |
242 | EventShowInfo(); |
252 | return; |
243 | return; |
253 | case SCAN_CODE_ESC: |
244 | case SCAN_CODE_ESC: |
254 | search.hide(); |
245 | search.hide(); |
255 | return; |
246 | return; |
256 | case SCAN_CODE_ENTER: |
247 | case SCAN_CODE_ENTER: |
257 | if (! search_box.flags & ed_focus) return; |
248 | if (! search_box.flags & ed_focus) return; |
258 | case SCAN_CODE_F3: |
249 | case SCAN_CODE_F3: |
259 | EventSearchNext(); |
250 | EventSearchNext(); |
260 | return; |
251 | return; |
261 | } |
252 | } |
262 | if (search.edit_key()) { |
253 | if (search.edit_key()) { |
263 | return; |
254 | return; |
- | 255 | } else { |
|
- | 256 | if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_start(); |
|
- | 257 | else selection.cancel(); |
|
264 | } else if (list.ProcessKey(key_scancode)) { |
258 | if (list.ProcessKey(key_scancode)) { |
- | 259 | if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_end(); |
|
265 | DrawPage(); |
260 | DrawPage(); |
- | 261 | } |
|
266 | return; |
262 | return; |
267 | } |
263 | } |
268 | EventInsertCharIntoText(); |
264 | //EventInsertCharIntoText(); |
269 | } |
265 | } |
270 | 266 | ||
271 | void HandleMouseEvent() |
267 | void HandleMouseEvent() |
272 | { |
268 | { |
273 | mouse.get(); |
269 | mouse.get(); |
274 | list.wheel_size = 7; |
270 | list.wheel_size = 7; |
275 | if (list.MouseScroll(mouse.vert)) { |
271 | if (list.MouseScroll(mouse.vert)) { |
276 | DrawPage(); |
272 | DrawPage(); |
277 | return; |
273 | return; |
278 | } |
274 | } |
279 | if (!scroll.delta2) && (list.MouseOver(mouse.x, mouse.y)) { |
275 | if (!scroll.delta2) && (list.MouseOver(mouse.x, mouse.y)) { |
280 | if (mouse.key&MOUSE_LEFT) { |
276 | if (mouse.key&MOUSE_LEFT) { |
281 | 277 | ||
282 | GetKeyModifier(); |
278 | GetKeyModifier(); |
283 | if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) { |
279 | if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) { |
284 | if (mouse.down) && (!selection.is_active()) selection.set_start(); |
280 | if (mouse.down) selection.set_start(); |
285 | list.ProcessMouse(mouse.x, mouse.y); |
281 | list.ProcessMouse(mouse.x, mouse.y); |
286 | if (mouse.up) selection.set_end(); |
282 | if (mouse.up) selection.set_end(); |
287 | DrawPage(); |
283 | DrawPage(); |
288 | return; |
284 | return; |
289 | } |
285 | } |
290 | 286 | ||
291 | list.ProcessMouse(mouse.x, mouse.y); |
287 | list.ProcessMouse(mouse.x, mouse.y); |
292 | if (mouse.down) { |
288 | if (mouse.down) { |
- | 289 | selection.cancel(); |
|
293 | selection.set_start(); |
290 | selection.set_start(); |
294 | } |
291 | } |
295 | selection.set_end(); |
292 | selection.set_end(); |
296 | DrawPage(); |
293 | DrawPage(); |
297 | } |
294 | } |
298 | if (mouse.key&MOUSE_RIGHT) && (mouse.up) { |
295 | if (mouse.key&MOUSE_RIGHT) && (mouse.up) { |
299 | EventShowRmbMenu(); |
296 | EventShowRmbMenu(); |
300 | } |
297 | } |
301 | return; |
298 | return; |
302 | } |
299 | } |
303 | scrollbar_v_mouse (#scroll); |
300 | scrollbar_v_mouse (#scroll); |
304 | if (list.first != scroll.position) { |
301 | if (list.first != scroll.position) { |
305 | list.first = scroll.position; |
302 | list.first = scroll.position; |
306 | DrawPage(); |
303 | DrawPage(); |
307 | } |
304 | } |
308 | search.edit_mouse(); |
305 | search.edit_mouse(); |
309 | } |
306 | } |
310 | 307 | ||
311 | //===================================================// |
308 | //===================================================// |
312 | // // |
309 | // // |
313 | // EVENTS // |
310 | // EVENTS // |
314 | // // |
311 | // // |
315 | //===================================================// |
312 | //===================================================// |
316 | 313 | ||
317 | bool EventSearchNext() |
314 | bool EventSearchNext() |
318 | { |
315 | { |
319 | int new_y = search.find_next(list.first, theme.bg); |
316 | int new_y = search.find_next(list.first, theme.bg); |
320 | if (new_y) { |
317 | if (new_y) { |
321 | list.first = new_y / list.item_h; |
318 | list.first = new_y / list.item_h; |
322 | list.CheckDoesValuesOkey(); |
319 | list.CheckDoesValuesOkey(); |
323 | DrawPage(); |
320 | DrawPage(); |
324 | } |
321 | } |
325 | } |
322 | } |
326 | 323 | ||
327 | void EventNewFile() |
324 | void EventNewFile() |
328 | { |
325 | { |
329 | RunProgram(#program_path, "-new"); |
326 | RunProgram(#program_path, "-new"); |
330 | } |
327 | } |
331 | 328 | ||
332 | void EventOpenDialog() |
329 | void EventOpenDialog() |
333 | { |
330 | { |
334 | OpenDialog_start stdcall (#o_dialog); |
331 | OpenDialog_start stdcall (#o_dialog); |
335 | if (o_dialog.status) { |
332 | if (o_dialog.status) { |
336 | LoadFile(#openfile_path); |
333 | LoadFile(#openfile_path); |
337 | ParseAndPaint(); |
334 | ParseAndPaint(); |
338 | } |
335 | } |
339 | } |
336 | } |
340 | 337 | ||
341 | void EventSave() |
338 | void EventSave() |
342 | { |
339 | { |
343 | int res; |
340 | int res; |
344 | char backy_param[4096]; |
341 | char backy_param[4096]; |
345 | if (io.buffer_data) { |
342 | if (io.buffer_data) { |
346 | io.dir.make("/tmp0/1/quark_backups"); |
343 | io.dir.make("/tmp0/1/quark_backups"); |
347 | sprintf(#backy_param, "%s -o /tmp0/1/quark_backups", #param); |
344 | sprintf(#backy_param, "%s -o /tmp0/1/quark_backups", #param); |
348 | io.run("/sys/develop/backy", #backy_param); |
345 | io.run("/sys/develop/backy", #backy_param); |
349 | if (! io.write(#param, io.buffer_data) ) { |
346 | if (! io.write(#param, io.buffer_data) ) { |
350 | notify(FILE_SAVED_WELL); |
347 | notify(FILE_SAVED_WELL); |
351 | } else { |
348 | } else { |
352 | notify(FILE_NOT_SAVED); |
349 | notify(FILE_NOT_SAVED); |
353 | } |
350 | } |
354 | } |
351 | } |
355 | } |
352 | } |
356 | 353 | ||
357 | void EventShowFileInfo() |
354 | void EventShowFileInfo() |
358 | { |
355 | { |
359 | char ss_param[4096]; |
356 | char ss_param[4096]; |
360 | if (!param) return; |
357 | if (!param) return; |
361 | strcpy(#ss_param, "-p "); |
358 | strcpy(#ss_param, "-p "); |
362 | strcpy(#ss_param+3, #param); |
359 | strcpy(#ss_param+3, #param); |
363 | RunProgram("/sys/File managers/Eolite", #ss_param); |
360 | RunProgram("/sys/File managers/Eolite", #ss_param); |
364 | } |
361 | } |
365 | 362 | ||
366 | void EventMagnifyMinus() |
363 | void EventMagnifyMinus() |
367 | { |
364 | { |
368 | SetSizes('S'); |
365 | SetSizes('S'); |
369 | ParseAndPaint(); |
366 | ParseAndPaint(); |
370 | } |
367 | } |
371 | 368 | ||
372 | void EventMagnifyPlus() |
369 | void EventMagnifyPlus() |
373 | { |
370 | { |
374 | SetSizes('M'); |
371 | SetSizes('M'); |
375 | ParseAndPaint(); |
372 | ParseAndPaint(); |
376 | } |
373 | } |
377 | 374 | ||
378 | void EventShowCharsetsList() |
375 | void EventShowCharsetsList() |
379 | { |
376 | { |
380 | menu_id = CHANGE_CHARSET; |
377 | menu_id = CHANGE_CHARSET; |
381 | open_lmenu(Form.left + Form.cwidth, Form.top + skin_height |
378 | open_lmenu(Form.left + Form.cwidth, Form.top + skin_height |
382 | + Form.cheight - 6, MENU_ALIGN_BOT_RIGHT, user_encoding+1, |
379 | + Form.cheight - 6, MENU_ALIGN_BOT_RIGHT, user_encoding+1, |
383 | "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866\nAUTO"); |
380 | "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866\nAUTO"); |
384 | } |
381 | } |
385 | 382 | ||
386 | void EventShowReopenMenu() |
383 | void EventShowReopenMenu() |
387 | { |
384 | { |
388 | menu_id = REOPEN_IN_APP; |
385 | menu_id = REOPEN_IN_APP; |
389 | open_lmenu(Form.left+5 + reopenin_mx, Form.top+29+skin_height, |
386 | open_lmenu(Form.left+5 + reopenin_mx + 23, Form.top+29+skin_height, |
390 | MENU_ALIGN_TOP_LEFT, NULL, |
387 | MENU_ALIGN_TOP_RIGHT, NULL, |
391 | "Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther"); |
388 | "Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther"); |
392 | } |
389 | } |
393 | 390 | ||
394 | void EventShowThemesList() |
391 | void EventShowThemesList() |
395 | { |
392 | { |
396 | menu_id = COLOR_SCHEME; |
393 | menu_id = COLOR_SCHEME; |
397 | open_lmenu(Form.left+2 + theme_mx + 26, |
394 | open_lmenu(Form.left+5 + theme_mx + 23, |
398 | Form.top+29+skin_height, MENU_ALIGN_TOP_RIGHT, |
395 | Form.top+29+skin_height, MENU_ALIGN_TOP_RIGHT, |
399 | curcol_scheme+1, #color_scheme_names); |
396 | curcol_scheme+1, #color_scheme_names); |
400 | } |
397 | } |
401 | 398 | ||
402 | void EventShowRmbMenu() |
399 | void EventShowRmbMenu() |
403 | { |
400 | { |
404 | menu_id = RMB_MENU; |
401 | menu_id = RMB_MENU; |
405 | open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, |
402 | open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y, |
406 | MENU_ALIGN_TOP_LEFT, NULL, #rmb_menu); |
403 | MENU_ALIGN_TOP_LEFT, NULL, #rmb_menu); |
407 | } |
404 | } |
408 | 405 | ||
409 | 406 | ||
410 | void EventSetColorScheme(dword _setn) |
407 | void EventSetColorScheme(dword _setn) |
411 | { |
408 | { |
412 | curcol_scheme = _setn; |
409 | curcol_scheme = _setn; |
413 | theme.bg = color_schemes[curcol_scheme*5]; |
410 | theme.bg = color_schemes[curcol_scheme*5]; |
414 | theme.text = color_schemes[curcol_scheme*5+1]; |
411 | theme.text = color_schemes[curcol_scheme*5+1]; |
415 | scroll.bckg_col = theme.bg; |
412 | scroll.bckg_col = theme.bg; |
416 | scroll.frnt_col = scroll.line_col = color_schemes[curcol_scheme*5+2]; |
413 | scroll.frnt_col = scroll.line_col = color_schemes[curcol_scheme*5+2]; |
417 | selection.color = color_schemes[curcol_scheme*5+3]; |
414 | selection.color = color_schemes[curcol_scheme*5+3]; |
418 | theme.cursor = color_schemes[curcol_scheme*5+4]; |
415 | theme.cursor = color_schemes[curcol_scheme*5+4]; |
419 | if (list.count) ParseAndPaint(); |
416 | if (list.count) ParseAndPaint(); |
420 | } |
417 | } |
421 | 418 | ||
422 | 419 | ||
423 | void EventShowInfo() { |
420 | void EventShowInfo() { |
424 | static dword shared_about; |
421 | static dword shared_about; |
425 | if (!shared_about) { |
422 | if (!shared_about) { |
426 | shared_about = memopen("QUARK_ABOUT", sizeof(about)+1, SHM_OPEN_ALWAYS + SHM_READ); |
423 | shared_about = memopen("QUARK_ABOUT", sizeof(about)+1, SHM_OPEN_ALWAYS + SHM_READ); |
427 | strcpy(shared_about, #about); |
424 | strcpy(shared_about, #about); |
428 | } |
425 | } |
429 | RunProgram("/sys/dialog", "-info 122 *QUARK_ABOUT"); |
426 | RunProgram("/sys/dialog", "-info 122 *QUARK_ABOUT"); |
430 | } |
427 | } |
431 | 428 | ||
432 | void EventChangeCharset(dword id) |
429 | void EventChangeCharset(dword id) |
433 | { |
430 | { |
434 | if (param[0]=='\0') return; |
431 | if (param[0]=='\0') return; |
435 | user_encoding = id; |
432 | user_encoding = id; |
436 | LoadFile(#openfile_path); |
433 | LoadFile(#openfile_path); |
437 | ParseAndPaint(); |
434 | ParseAndPaint(); |
438 | draw_window(); |
435 | draw_window(); |
439 | } |
436 | } |
440 | 437 | ||
441 | void EventOpenFileInOtherApp(dword _id) |
438 | void EventOpenFileInOtherApp(dword _id) |
442 | { |
439 | { |
443 | dword app; |
440 | dword app; |
444 | byte open_param[4096]; |
441 | byte open_param[4096]; |
445 | switch(_id) { |
442 | switch(_id) { |
446 | case 0: app = "/sys/tinypad"; break; |
443 | case 0: app = "/sys/tinypad"; break; |
447 | case 1: app = "/sys/develop/t_edit"; break; |
444 | case 1: app = "/sys/develop/t_edit"; break; |
448 | case 2: app = "/sys/network/webview"; break; |
445 | case 2: app = "/sys/network/webview"; break; |
449 | case 3: app = "/sys/fb2read"; break; |
446 | case 3: app = "/sys/fb2read"; break; |
450 | case 4: app = "/sys/develop/heed"; break; |
447 | case 4: app = "/sys/develop/heed"; break; |
451 | case 5: open_param[0]='~'; |
448 | case 5: open_param[0]='~'; |
452 | strcpy(#open_param+1,#param); |
449 | strcpy(#open_param+1,#param); |
453 | RunProgram("/sys/@open", #open_param); |
450 | RunProgram("/sys/@open", #open_param); |
454 | return; |
451 | return; |
455 | } |
452 | } |
456 | RunProgram(app, #param); |
453 | RunProgram(app, #param); |
457 | } |
454 | } |
458 | 455 | ||
459 | void EventMenuClick() |
456 | void EventMenuClick() |
460 | { |
457 | { |
461 | dword click_id = get_menu_click(); |
458 | dword click_id = get_menu_click(); |
462 | 459 | ||
463 | if (click_id) && (menu_id) switch(menu_id) |
460 | if (click_id) && (menu_id) switch(menu_id) |
464 | { |
461 | { |
465 | case CHANGE_CHARSET: EventChangeCharset(click_id-1); break; |
462 | case CHANGE_CHARSET: EventChangeCharset(click_id-1); break; |
466 | case REOPEN_IN_APP: EventOpenFileInOtherApp(click_id-1); break; |
463 | case REOPEN_IN_APP: EventOpenFileInOtherApp(click_id-1); break; |
467 | case COLOR_SCHEME: EventSetColorScheme(click_id-1); break; |
464 | case COLOR_SCHEME: EventSetColorScheme(click_id-1); break; |
468 | case RMB_MENU: EventRbmMenuClick(click_id-1); break; |
465 | case RMB_MENU: EventRbmMenuClick(click_id-1); break; |
469 | default: notify("'Error: wrong menu number'E"); |
466 | default: notify("'Error: wrong menu number'E"); |
470 | } |
467 | } |
471 | menu_id = NULL; |
468 | menu_id = NULL; |
472 | } |
469 | } |
473 | 470 | ||
474 | void EventClickSearch() |
471 | void EventClickSearch() |
475 | { |
472 | { |
476 | if (search.visible) { |
473 | if (search.visible) { |
477 | search.hide(); |
474 | search.hide(); |
478 | } else { |
475 | } else { |
479 | search.show(); |
476 | search.show(); |
480 | } |
477 | } |
481 | } |
478 | } |
482 | 479 | ||
483 | void EventInsertCharIntoText() |
480 | void EventInsertCharIntoText() |
484 | { |
481 | { |
485 | dword cursor_pos = lines.get(list.cur_y) + list.cur_x; |
482 | dword cursor_pos = lines.get(list.cur_y) + list.cur_x; |
486 | 483 | ||
487 | switch(key_scancode) |
484 | switch(key_scancode) |
488 | { |
485 | { |
489 | case SCAN_CODE_DOWN: |
486 | case SCAN_CODE_DOWN: |
490 | case SCAN_CODE_UP: |
487 | case SCAN_CODE_UP: |
491 | case SCAN_CODE_HOME: |
488 | case SCAN_CODE_HOME: |
492 | case SCAN_CODE_END: |
489 | case SCAN_CODE_END: |
493 | case SCAN_CODE_PGUP: |
490 | case SCAN_CODE_PGUP: |
494 | case SCAN_CODE_PGDN: |
491 | case SCAN_CODE_PGDN: |
495 | return; |
492 | return; |
496 | case SCAN_CODE_BS: |
493 | case SCAN_CODE_BS: |
497 | case SCAN_CODE_DEL: |
494 | case SCAN_CODE_DEL: |
498 | notify("'Not supported yet'A"); |
495 | notify("'Not supported yet'A"); |
499 | return; |
496 | return; |
500 | } |
497 | } |
501 | 498 | ||
502 | if (list.cur_x >= list.column_max) return; |
499 | if (list.cur_x >= list.column_max) return; |
503 | 500 | ||
504 | ESBYTE[cursor_pos] = key_ascii; |
501 | ESBYTE[cursor_pos] = key_ascii; |
505 | list.KeyRight(); |
502 | list.KeyRight(); |
506 | PaintVisible(); |
503 | PaintVisible(); |
507 | } |
504 | } |
508 | 505 | ||
509 | void EventOpenSysfuncs() |
506 | void EventOpenSysfuncs() |
510 | { |
507 | { |
511 | if (io.run("/sys/docpack", "f") <= 0) { |
508 | if (io.run("/sys/docpack", "f") <= 0) { |
512 | notify("'Can not open SysFunctions because\n/rd/1/docpack is not found!'E"); |
509 | notify("'Can not open SysFunctions because\n/rd/1/docpack is not found!'E"); |
513 | } |
510 | } |
514 | } |
511 | } |
515 | 512 | ||
516 | void EventOpenPipet() |
513 | void EventOpenPipet() |
517 | { |
514 | { |
518 | io.run("/sys/develop/pipet", NULL); |
515 | io.run("/sys/develop/pipet", NULL); |
519 | } |
516 | } |
520 | 517 | ||
521 | void EventRbmMenuClick(dword id) |
518 | void EventRbmMenuClick(dword id) |
522 | { |
519 | { |
523 | switch(id) { |
520 | switch(id) { |
524 | case 0: EventCut(); break; |
521 | case 0: EventCut(); break; |
525 | case 1: EventCopy(); break; |
522 | case 1: EventCopy(); break; |
526 | case 2: EventPaste(); break; |
523 | case 2: EventPaste(); break; |
527 | case 3: EventRevealInFolder(); break; |
524 | case 3: EventRevealInFolder(); break; |
528 | case 4: EventCopyFilePath(); break; |
525 | case 4: EventCopyFilePath(); break; |
529 | } |
526 | } |
530 | } |
527 | } |
531 | 528 | ||
532 | void EventCut() |
529 | void EventCut() |
533 | { |
530 | { |
534 | //selection.copy(); |
531 | //selection.copy(); |
535 | } |
532 | } |
536 | 533 | ||
537 | void EventCopy() |
534 | void EventCopy() |
538 | { |
535 | { |
539 | char copy_status_text[32]; |
536 | char copy_status_text[32]; |
540 | 537 | ||
541 | dword copy_buf; |
538 | dword copy_buf; |
542 | dword copy_len; |
539 | dword copy_len; |
543 | dword copy_start; |
540 | dword copy_start; |
544 | dword copy_end; |
541 | dword copy_end; |
545 | 542 | ||
546 | if (selection.is_active()) { |
543 | if (selection.is_active()) { |
547 | copy_start = selection.start_offset; |
544 | copy_start = selection.start_offset; |
548 | copy_end = selection.end_offset; |
545 | copy_end = selection.end_offset; |
549 | if (copy_start > copy_end) copy_start >< copy_end; |
546 | if (copy_start > copy_end) copy_start >< copy_end; |
550 | } else { |
547 | } else { |
551 | copy_start = lines.get(list.cur_y); |
548 | copy_start = lines.get(list.cur_y); |
552 | copy_end = lines.get(list.cur_y+1); |
549 | copy_end = lines.get(list.cur_y+1); |
553 | } |
550 | } |
554 | copy_len = copy_end - copy_start; |
551 | copy_len = copy_end - copy_start; |
555 | copy_buf = malloc(copy_len + 2); |
552 | copy_buf = malloc(copy_len + 2); |
556 | strncpy(copy_buf, copy_start, copy_len); |
553 | strncpy(copy_buf, copy_start, copy_len); |
557 | ESBYTE[copy_buf+copy_len] = '\0'; |
554 | ESBYTE[copy_buf+copy_len] = '\0'; |
558 | Clipboard__CopyText(copy_buf); |
555 | Clipboard__CopyText(copy_buf); |
559 | free(copy_buf); |
556 | free(copy_buf); |
560 | 557 | ||
561 | sprintf(#copy_status_text, #copied_chars, copy_len); |
558 | sprintf(#copy_status_text, #copied_chars, copy_len); |
562 | DrawStatusBar(#copy_status_text); |
559 | DrawStatusBar(#copy_status_text); |
563 | } |
560 | } |
564 | 561 | ||
565 | void EventPaste() |
562 | void EventPaste() |
566 | { |
563 | { |
567 | //selection.copy(); |
564 | //selection.copy(); |
568 | } |
565 | } |
569 | 566 | ||
570 | void EventRevealInFolder() |
567 | void EventRevealInFolder() |
571 | { |
568 | { |
572 | RunProgram("/sys/File managers/Eolite", #param); |
569 | RunProgram("/sys/File managers/Eolite", #param); |
573 | } |
570 | } |
574 | 571 | ||
575 | void EventCopyFilePath() |
572 | void EventCopyFilePath() |
576 | { |
573 | { |
577 | char copy_status_text[32]; |
574 | char copy_status_text[32]; |
578 | Clipboard__CopyText(#param); |
575 | Clipboard__CopyText(#param); |
579 | sprintf(#copy_status_text, #copied_chars, strlen(#param)); |
576 | sprintf(#copy_status_text, #copied_chars, strlen(#param)); |
580 | DrawStatusBar(#copy_status_text); |
577 | DrawStatusBar(#copy_status_text); |
581 | } |
578 | } |
582 | 579 | ||
583 | //===================================================// |
580 | //===================================================// |
584 | // // |
581 | // // |
585 | // DRAWS AND OTHER FUNCS // |
582 | // DRAWS AND OTHER FUNCS // |
586 | // // |
583 | // // |
587 | //===================================================// |
584 | //===================================================// |
588 | 585 | ||
589 | void EncodeToDos() |
586 | void EncodeToDos() |
590 | { |
587 | { |
591 | real_encoding = user_encoding; |
588 | real_encoding = user_encoding; |
592 | 589 | ||
593 | // Autodetecting charset |
590 | // Autodetecting charset |
594 | if (real_encoding == CH_AUTO) { |
591 | if (real_encoding == CH_AUTO) { |
595 | real_encoding = CH_CP866; |
592 | real_encoding = CH_CP866; |
596 | if (strstr(io.buffer_data, "\208\190")) real_encoding = CH_UTF8; |
593 | if (strstr(io.buffer_data, "\208\190")) real_encoding = CH_UTF8; |
597 | else { |
594 | else { |
598 | if (chrnum(io.buffer_data, '\246')>5) |
595 | if (chrnum(io.buffer_data, '\246')>5) |
599 | || (strstr(io.buffer_data, "пр")) real_encoding = CH_CP1251; |
596 | || (strstr(io.buffer_data, "пр")) real_encoding = CH_CP1251; |
600 | } |
597 | } |
601 | } |
598 | } |
602 | if (real_encoding != CH_CP866) |
599 | if (real_encoding != CH_CP866) |
603 | ChangeCharset(real_encoding, "CP866", io.buffer_data); |
600 | ChangeCharset(real_encoding, "CP866", io.buffer_data); |
604 | } |
601 | } |
605 | 602 | ||
606 | void LoadFile(dword f_path) |
603 | void LoadFile(dword f_path) |
607 | { |
604 | { |
608 | if (io.buffer_data) free(io.buffer_data); |
605 | if (io.buffer_data) free(io.buffer_data); |
609 | if (ESBYTE[f_path]) { |
606 | if (ESBYTE[f_path]) { |
610 | strcpy(#param, f_path); |
607 | strcpy(#param, f_path); |
611 | if (!io.read(#param)) goto NO_DATA; |
608 | if (!io.read(#param)) goto NO_DATA; |
612 | sprintf(#title, "%s - %s", #param, #short_app_name); |
609 | sprintf(#title, "%s - %s", #param, #short_app_name); |
613 | EncodeToDos(); |
610 | EncodeToDos(); |
614 | } |
611 | } |
615 | else { |
612 | else { |
616 | NO_DATA: |
613 | NO_DATA: |
617 | io.buffer_data = malloc(sizeof(intro)); |
614 | io.buffer_data = malloc(sizeof(intro)); |
618 | strcpy(io.buffer_data, #intro); |
615 | strcpy(io.buffer_data, #intro); |
619 | strcpy(#title, #short_app_name); |
616 | strcpy(#title, #short_app_name); |
620 | } |
617 | } |
621 | list.ClearList(); |
618 | list.ClearList(); |
622 | } |
619 | } |
623 | 620 | ||
624 | int AddTopBarButton(dword _event, _hotkey, char image_id, int x, pressed) { |
621 | int AddTopBarButton(dword _event, _hotkey, char image_id, int x, pressed) { |
625 | if (_hotkey) key.add_n(_hotkey, _event); |
622 | if (_hotkey) key.add_n(_hotkey, _event); |
626 | return DrawTopPanelButton(button.add(_event), x, 5, image_id, pressed); |
623 | return DrawTopPanelButton(button.add(_event), x, 5, image_id, pressed); |
627 | } |
624 | } |
628 | 625 | ||
629 | 626 | ||
630 | void DrawToolbar() |
627 | void DrawToolbar() |
631 | { |
628 | { |
632 | #define SMALL_GAP 26+5 |
629 | #define SMALL_GAP 26+5 |
633 | #define BIG_GAP 26+18 |
630 | #define BIG_GAP 26+18 |
634 | incn x; |
631 | incn x; |
635 | bool thema = false; |
632 | bool thema = false; |
636 | bool reopa = false; |
633 | bool reopa = false; |
637 | 634 | ||
638 | bool serha = search.draw(BTN_FIND_NEXT+10, BTN_FIND_CLOSE+10, Form.cheight - SEARCH_H - STATUSBAR_H); |
635 | bool serha = search.draw(BTN_FIND_NEXT+10, BTN_FIND_CLOSE+10, Form.cheight - SEARCH_H - STATUSBAR_H); |
639 | if (menu_id == COLOR_SCHEME) thema = true; |
636 | if (menu_id == COLOR_SCHEME) thema = true; |
640 | if (menu_id == REOPEN_IN_APP) reopa = true; |
637 | if (menu_id == REOPEN_IN_APP) reopa = true; |
641 | 638 | ||
642 | DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work); |
639 | DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work); |
643 | DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.work_graph); |
640 | DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.work_graph); |
644 | 641 | ||
645 | //AddTopBarButton(#EventNewFile, ECTRL+SCAN_CODE_KEY_N, 2, x.set(8), false); |
642 | //AddTopBarButton(#EventNewFile, ECTRL+SCAN_CODE_KEY_N, 2, x.set(8), false); |
646 | AddTopBarButton(#EventOpenDialog, ECTRL+SCAN_CODE_KEY_O, 0, x.set(8), false); |
643 | AddTopBarButton(#EventOpenDialog, ECTRL+SCAN_CODE_KEY_O, 0, x.set(8), false); |
647 | //AddTopBarButton(#EventSave, ECTRL+SCAN_CODE_KEY_S, 5, x.inc(SMALL_GAP), false); |
644 | //AddTopBarButton(#EventSave, ECTRL+SCAN_CODE_KEY_S, 5, x.inc(SMALL_GAP), false); |
648 | AddTopBarButton(#EventShowFileInfo, ECTRL+SCAN_CODE_KEY_I, 10, x.inc(SMALL_GAP), false); |
645 | AddTopBarButton(#EventShowFileInfo, ECTRL+SCAN_CODE_KEY_I, 10, x.inc(SMALL_GAP), false); |
649 | AddTopBarButton(#EventMagnifyMinus, ECTRL+SCAN_CODE_MINUS, 32, x.inc(BIG_GAP), false); |
646 | AddTopBarButton(#EventMagnifyMinus, ECTRL+SCAN_CODE_MINUS, 33, x.inc(BIG_GAP), false); |
650 | AddTopBarButton(#EventMagnifyPlus, ECTRL+SCAN_CODE_PLUS, 33, x.inc(SMALL_GAP), false); |
647 | AddTopBarButton(#EventMagnifyPlus, ECTRL+SCAN_CODE_PLUS, 32, x.inc(SMALL_GAP), false); |
651 | AddTopBarButton(#EventClickSearch, ECTRL+SCAN_CODE_KEY_F, 49, x.inc(BIG_GAP), serha); search_mx = EAX; |
648 | AddTopBarButton(#EventClickSearch, ECTRL+SCAN_CODE_KEY_F, 49, x.inc(BIG_GAP), serha); search_mx = EAX; |
652 | x.set(Form.cwidth-4); |
649 | x.set(Form.cwidth-4); |
653 | AddTopBarButton(#EventShowInfo, NULL, -1, x.inc(-SMALL_GAP), false); burger_mx = EAX; |
650 | //AddTopBarButton(#EventShowInfo, NULL, -1, x.inc(-SMALL_GAP), false); burger_mx = EAX; |
654 | AddTopBarButton(#EventShowThemesList, NULL, 40, x.inc(-BIG_GAP), thema); theme_mx = EAX; |
651 | AddTopBarButton(#EventShowThemesList, NULL, 40, x.inc(-SMALL_GAP), thema); theme_mx = EAX; |
655 | AddTopBarButton(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-SMALL_GAP), reopa); reopenin_mx = EAX; |
652 | AddTopBarButton(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-SMALL_GAP), reopa); reopenin_mx = EAX; |
656 | //AddTopBarButton(#EventOpenSysfuncs, NULL, 18, x.inc(-SMALL_GAP), false); |
653 | //AddTopBarButton(#EventOpenSysfuncs, NULL, 18, x.inc(-SMALL_GAP), false); |
657 | //AddTopBarButton(#EventOpenPipet, NULL, 39, x.inc(-SMALL_GAP), false); |
654 | //AddTopBarButton(#EventOpenPipet, NULL, 39, x.inc(-SMALL_GAP), false); |
658 | DefineHiddenButton(Form.cwidth-70, Form.cheight - STATUSBAR_H + 1, |
- | |
659 | 60, 12, button.add(#EventShowCharsetsList)); |
- | |
660 | } |
655 | } |
661 | 656 | ||
662 | void DrawStatusBar(dword _in_text) |
657 | void DrawStatusBar(dword _in_text) |
663 | { |
658 | { |
664 | static char status_text[64]; |
659 | static char status_text[64]; |
665 | if (Form.status_window>2) return; |
660 | if (Form.status_window>2) return; |
666 | if (_in_text) strncpy(#status_text, _in_text, sizeof(status_text)); |
661 | if (_in_text) strncpy(#status_text, _in_text, sizeof(status_text)); |
667 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph); |
662 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph); |
668 | DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work); |
663 | DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work); |
- | 664 | WriteText(5, Form.cheight - STATUSBAR_H + 4, 0x80, sc.work_text, #status_text); |
|
- | 665 | if (param[0]) { |
|
669 | WriteTextCenter(Form.cwidth-70, Form.cheight - STATUSBAR_H + 4, |
666 | WriteTextCenter(Form.cwidth-70, Form.cheight - STATUSBAR_H + 4, |
670 | 60, sc.work_text, real_encoding*10+#charsets); |
667 | 60, sc.work_text, real_encoding*10+#charsets); |
671 | WriteText(5, Form.cheight - STATUSBAR_H + 4, 0x80, sc.work_text, #status_text); |
668 | DefineHiddenButton(Form.cwidth-70, Form.cheight - STATUSBAR_H + 1, |
- | 669 | 60, 12, BTN_CHANGE_CHARSET+10); |
|
- | 670 | } |
|
672 | } |
671 | } |
673 | 672 | ||
674 | void draw_window() |
673 | void draw_window() |
675 | { |
674 | { |
676 | int old_w = list.w; |
675 | int old_w = list.w; |
677 | DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0); |
676 | DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0); |
678 | GetProcessInfo(#Form, SelfInfo); |
677 | GetProcessInfo(#Form, SelfInfo); |
679 | sc.get(); |
678 | sc.get(); |
680 | if (Form.status_window>2) return; |
679 | if (Form.status_window>2) return; |
681 | if (Form.width < 430) { MoveSize(OLD,OLD,430,OLD); return; } |
680 | if (Form.width < 430) { MoveSize(OLD,OLD,430,OLD); return; } |
682 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } |
681 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; } |
683 | 682 | ||
684 | button.init(40); |
683 | button.init(40); |
685 | key.init(40); |
684 | key.init(40); |
686 | 685 | ||
687 | SetSizes(font_size); |
686 | SetSizes(font_size); |
688 | 687 | ||
689 | if ((list.w == old_w) && (list.count)) { |
688 | if ((list.w == old_w) && (list.count)) { |
690 | DrawPage(); |
689 | DrawPage(); |
691 | } else { |
690 | } else { |
692 | ParseAndPaint(); |
691 | ParseAndPaint(); |
693 | } |
692 | } |
694 | 693 | ||
695 | DrawToolbar(); |
694 | DrawToolbar(); |
696 | DrawStatusBar(NULL); |
695 | DrawStatusBar(NULL); |
697 | } |
696 | } |
698 | 697 | ||
699 | void DrawPage() |
698 | void DrawPage() |
700 | { |
699 | { |
701 | scroll.max_area = list.count; |
700 | scroll.max_area = list.count; |
702 | scroll.cur_area = list.visible; |
701 | scroll.cur_area = list.visible; |
703 | scroll.position = list.first; |
702 | scroll.position = list.first; |
704 | scroll.all_redraw = 0; |
703 | scroll.all_redraw = 0; |
705 | scroll.start_x = list.x + list.w; |
704 | scroll.start_x = list.x + list.w; |
706 | scroll.start_y = list.y; |
705 | scroll.start_y = list.y; |
707 | scroll.size_y = list.h; |
706 | scroll.size_y = list.h; |
708 | scrollbar_v_draw(#scroll); |
707 | scrollbar_v_draw(#scroll); |
709 | 708 | ||
710 | DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, |
709 | DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, |
711 | scroll.size_y-1, scroll.bckg_col); |
710 | scroll.size_y-1, scroll.bckg_col); |
712 | PaintVisible(); |
711 | PaintVisible(); |
713 | } |
712 | } |
714 | 713 | ||
715 | 714 | ||
716 | void SetSizes(char _size) |
715 | void SetSizes(char _size) |
717 | { |
716 | { |
718 | font_size = _size; |
717 | font_size = _size; |
719 | if (font_size == 'S') list.SetFont(6, 9, 00001000b); |
718 | if (font_size == 'S') list.SetFont(6, 9, 00001000b); |
720 | if (font_size == 'M') list.SetFont(8, 14, 00011000b); |
719 | if (font_size == 'M') list.SetFont(8, 14, 00011000b); |
721 | list.item_w = list.font_w; |
720 | list.item_w = list.font_w; |
722 | list.horisontal_selelection = true; |
721 | list.horisontal_selelection = true; |
723 | list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, |
722 | list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, |
724 | Form.cheight - TOOLBAR_H - search.height() - STATUSBAR_H /*- TAB_H*/, |
723 | Form.cheight - TOOLBAR_H - search.height() - STATUSBAR_H /*- TAB_H*/, |
725 | math.round(list.font_h * 1.4)); |
724 | math.round(list.font_h * 1.4)); |
726 | }>>>=> |
725 | }>>>=> |