Rev 3877 | Rev 3883 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3877 | Rev 3878 | ||
---|---|---|---|
1 | //Leency & Veliant 2008-2013 |
1 | //Leency & Veliant 2008-2013 |
2 | //GNU GPL licence. |
2 | //GNU GPL licence. |
3 | 3 | ||
4 | //libraries |
4 | //libraries |
5 | #define MEMSIZE 0xA0000 |
5 | #define MEMSIZE 0xA0000 |
6 | #include "..\lib\kolibri.h" |
6 | #include "..\lib\kolibri.h" |
7 | #include "..\lib\strings.h" |
7 | #include "..\lib\strings.h" |
8 | #include "..\lib\mem.h" |
8 | #include "..\lib\mem.h" |
9 | #include "..\lib\dll.h" |
9 | #include "..\lib\dll.h" |
10 | #include "..\lib\lib.obj\box_lib.h" |
10 | #include "..\lib\lib.obj\box_lib.h" |
11 | #include "..\lib\file_system.h" |
11 | #include "..\lib\file_system.h" |
12 | #include "..\lib\figures.h" |
12 | #include "..\lib\figures.h" |
13 | #include "..\lib\encoding.h" |
13 | #include "..\lib\encoding.h" |
14 | #include "..\lib\list_box.h" |
14 | #include "..\lib\list_box.h" |
15 | #include "..\lib\copyf.h" |
15 | #include "..\lib\copyf.h" |
16 | //images |
16 | //images |
17 | #include "imgs\toolbar.txt" |
17 | #include "imgs\toolbar.txt" |
18 | #include "imgs\left_p.txt" |
18 | #include "imgs\left_p.txt" |
19 | 19 | ||
20 | #ifndef AUTOBUILD |
20 | #ifndef AUTOBUILD |
21 | #include "lang.h--" |
21 | #include "lang.h--" |
22 | #endif |
22 | #endif |
23 | 23 | ||
24 | #ifdef LANG_RUS |
24 | #ifdef LANG_RUS |
25 | ?define T_FILE " ©«" |
25 | ?define T_FILE " ©«" |
26 | ?define T_TYPE "¨¯" |
26 | ?define T_TYPE "¨¯" |
27 | ?define T_SIZE " §¬¥à" |
27 | ?define T_SIZE " §¬¥à" |
28 | ?define T_NEW_FOLDER "®¢ ï ¯ ¯ª " |
28 | ?define T_NEW_FOLDER "®¢ ï ¯ ¯ª " |
29 | ?define T_NEW_FILE "®¢ë© ä ©«" |
29 | ?define T_NEW_FILE "®¢ë© ä ©«" |
30 | ?define T_DELETE_FILE "ë ¤¥©áâ¢¨â¥«ì® å®â¨â¥ 㤠«¨âì" |
30 | ?define T_DELETE_FILE "ë ¤¥©áâ¢¨â¥«ì® å®â¨â¥ 㤠«¨âì" |
31 | ?define T_YES " " |
31 | ?define T_YES " " |
32 | ?define T_NO "¥â" |
32 | ?define T_NO "¥â" |
33 | ?define T_DEL_ERROR_1 "訡ª . ¯ª ¥ ¯ãáâ ï." |
33 | ?define T_DEL_ERROR_1 "訡ª . ¯ª ¥ ¯ãáâ ï." |
34 | ?define T_DEL_ERROR_2 "訡ª . ©«®¢ ï á¨á⥬ ⮫쪮 ¤«ï ç⥨ï." |
34 | ?define T_DEL_ERROR_2 "訡ª . ©«®¢ ï á¨á⥬ ⮫쪮 ¤«ï ç⥨ï." |
35 | ?define NOT_CREATE_FOLDER "¥ 㤠«®áì ᮧ¤ âì ¯ ¯ªã." |
35 | ?define NOT_CREATE_FOLDER "¥ 㤠«®áì ᮧ¤ âì ¯ ¯ªã." |
36 | ?define NOT_CREATE_FILE "¥ 㤠«®áì ᮧ¤ âì ä ©«." |
36 | ?define NOT_CREATE_FILE "¥ 㤠«®áì ᮧ¤ âì ä ©«." |
37 | ?define ERROR_1 "訡ª ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ /rd/1/lib/box_lib.obj" |
37 | ?define ERROR_1 "訡ª ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ /rd/1/lib/box_lib.obj" |
38 | 38 | ||
39 | #else |
39 | #else |
40 | ?define T_FILE "File" |
40 | ?define T_FILE "File" |
41 | ?define T_TYPE "Type" |
41 | ?define T_TYPE "Type" |
42 | ?define T_SIZE "Size" |
42 | ?define T_SIZE "Size" |
43 | ?define T_NEW_FOLDER "New folder" |
43 | ?define T_NEW_FOLDER "New folder" |
44 | ?define T_NEW_FILE "New file" |
44 | ?define T_NEW_FILE "New file" |
45 | ?define T_DELETE_FILE "Do you really want to delete" |
45 | ?define T_DELETE_FILE "Do you really want to delete" |
46 | ?define T_YES "Yes" |
46 | ?define T_YES "Yes" |
47 | ?define T_NO "No" |
47 | ?define T_NO "No" |
48 | ?define T_DEL_ERROR_1 "Error. Folder isn't empty." |
48 | ?define T_DEL_ERROR_1 "Error. Folder isn't empty." |
49 | ?define T_DEL_ERROR_2 "Error. Filesystem read-only." |
49 | ?define T_DEL_ERROR_2 "Error. Filesystem read-only." |
50 | ?define NOT_CREATE_FOLDER "Folder can not be created." |
50 | ?define NOT_CREATE_FOLDER "Folder can not be created." |
51 | ?define NOT_CREATE_FILE "File can not be created." |
51 | ?define NOT_CREATE_FILE "File can not be created." |
52 | ?define ERROR_1 "Error while loading library /rd/1/lib/box_lib.obj" |
52 | ?define ERROR_1 "Error while loading library /rd/1/lib/box_lib.obj" |
53 | #endif |
53 | #endif |
54 | 54 | ||
55 | enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir |
55 | enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir |
56 | 56 | ||
57 | #define TITLE "Eolite File Manager v1.94" |
57 | #define TITLE "Eolite File Manager v1.94" |
58 | #define ABOUT_TITLE "Eolite v1.94" |
58 | #define ABOUT_TITLE "Eolite v1.94" |
59 | dword col_work = 0xE4DFE1; |
59 | dword col_work = 0xE4DFE1; |
60 | dword col_border = 0x9098B0; //A0A0B8; //0x819FC5; |
60 | dword col_border = 0x9098B0; //A0A0B8; //0x819FC5; |
61 | dword col_padding = 0xC8C9C9; |
61 | dword col_padding = 0xC8C9C9; |
62 | dword col_selec = 0x94AECE; |
62 | dword col_selec = 0x94AECE; |
63 | dword col_lpanel = 0x00699C; |
63 | dword col_lpanel = 0x00699C; |
64 | 64 | ||
65 | int toolbar_buttons_x[7]={9,46,85,134,167,203}; |
65 | int toolbar_buttons_x[7]={9,46,85,134,167,203}; |
66 | char tmp_disk_del_param[3]="d0"; |
66 | char tmp_disk_del_param[3]="d0"; |
67 | struct path_string { char Item[4096]; }; |
67 | struct path_string { char Item[4096]; }; |
68 | 68 | ||
69 | llist files; |
69 | llist files; |
70 | 70 | ||
71 | byte |
71 | byte |
72 | path[4096], |
72 | path[4096], |
73 | file_path[4096], |
73 | file_path[4096], |
74 | file_name[256], |
74 | file_name[256], |
75 | temp[4096]; |
75 | temp[4096]; |
76 | byte |
76 | byte |
77 | rename_active=0, |
77 | rename_active=0, |
78 | del_active=0, |
78 | del_active=0, |
79 | show_dev_name=1, |
79 | show_dev_name=1, |
80 | sort_num=2, |
80 | sort_num=2, |
81 | itdir; |
81 | itdir; |
82 | 82 | ||
83 | proc_info Form; |
83 | proc_info Form; |
84 | mouse m; |
84 | mouse m; |
85 | int mouse_dd, scroll_used, scroll_size; |
85 | int mouse_dd, scroll_used, scroll_size; |
86 | dword buf, off; |
86 | dword buf, off; |
87 | dword file_mas[6898]; |
87 | dword file_mas[6898]; |
88 | int j, i; |
88 | int j, i; |
89 | 89 | ||
90 | edit_box edit2= {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6}; |
90 | edit_box edit2= {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6}; |
91 | PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0}; |
91 | PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0}; |
92 | PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0}; |
92 | PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0}; |
93 | 93 | ||
94 | #include "include\copypaste.h" |
94 | #include "include\copypaste.h" |
95 | #include "include\some_code.h" |
95 | #include "include\some_code.h" |
96 | #include "include\sorting.h" |
96 | #include "include\sorting.h" |
97 | #include "include\icons_f.h" |
97 | #include "include\icons_f.h" |
98 | #include "include\ini.h" |
98 | #include "include\ini.h" |
99 | #include "include\left_panel.h" |
99 | #include "include\left_panel.h" |
100 | #include "include\history.h" |
100 | #include "include\history.h" |
101 | #include "include\file_menu.h" |
101 | #include "include\file_menu.h" |
102 | #include "include\about_dialog.h" |
102 | #include "include\about_dialog.h" |
103 | 103 | ||
104 | void main() |
104 | void main() |
105 | { |
105 | { |
106 | word key, id, can_show, can_select, m_selected; |
106 | word key, id, can_show, can_select, m_selected; |
107 | 107 | ||
108 | files.line_h=18; |
108 | files.line_h=18; |
109 | mem_Init(); |
109 | mem_Init(); |
110 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1); |
110 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1); |
111 | SystemDiscsGet(); |
111 | SystemDiscsGet(); |
112 | GetIni(1); |
112 | GetIni(1); |
113 | if (param) |
113 | if (param) |
114 | { |
114 | { |
115 | strcpy(#path, #param); |
115 | strcpy(#path, #param); |
116 | if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string |
116 | if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string |
117 | } |
117 | } |
118 | else |
118 | else |
119 | { |
119 | { |
120 | strcpy(#path, "/rd/1/"); |
120 | strcpy(#path, "/rd/1/"); |
121 | } |
121 | } |
122 | Open_Dir(#path,ONLY_OPEN); |
122 | Open_Dir(#path,ONLY_OPEN); |
123 | SetEventMask(0x27); |
123 | SetEventMask(0x27); |
124 | loop() switch(WaitEvent()) |
124 | loop() switch(WaitEvent()) |
125 | { |
125 | { |
126 | case evMouse: |
126 | case evMouse: |
127 | IF (del_active) break; |
127 | IF (del_active) break; |
128 | id=GetProcessSlot(Form.ID); |
128 | id=GetProcessSlot(Form.ID); |
129 | IF (id!=GetActiveProcess()) || (Form.status_window>2) break; |
129 | IF (id!=GetActiveProcess()) || (Form.status_window>2) break; |
130 | IF (rename_active) { edit_box_mouse stdcall(#edit2); break; } |
130 | IF (rename_active) { edit_box_mouse stdcall(#edit2); break; } |
131 | - | ||
132 | if (isdir(#file_path)) debug("dir"); else debug("file"); |
131 | |
133 | m.get(); |
132 | m.get(); |
134 | 133 | ||
135 | if (m.x > files.x) && (m.x < files.x + files.w) && (m.y > files.y) && (m.y < files.y+files.h) && (!can_select) |
134 | if (m.x > files.x) && (m.x < files.x + files.w) && (m.y > files.y) && (m.y < files.y+files.h) && (!can_select) |
136 | { |
135 | { |
137 | m_selected = m.y - 57 / files.line_h; |
136 | m_selected = m.y - 57 / files.line_h; |
138 | if (m.lkm) can_select = 1; |
137 | if (m.lkm) can_select = 1; |
139 | if (m.pkm) |
138 | if (m.pkm) |
140 | { |
139 | { |
141 | can_show = 1; |
140 | can_show = 1; |
142 | if (m.y - 57 / files.line_h != files.current) can_select = 1; |
141 | if (m.y - 57 / files.line_h != files.current) can_select = 1; |
143 | } |
142 | } |
144 | } |
143 | } |
145 | 144 | ||
146 | //select/open file { |
145 | //select/open file { |
147 | if (!m.lkm) && (!m.pkm) && (can_select) |
146 | if (!m.lkm) && (!m.pkm) && (can_select) |
148 | { |
147 | { |
149 | can_select = 0; |
148 | can_select = 0; |
150 | if (m.y>=57) |
149 | if (m.y>=57) |
151 | { |
150 | { |
152 | id = m.y - 57 / files.line_h; |
151 | id = m.y - 57 / files.line_h; |
153 | if (id!=m_selected) |
152 | if (id!=m_selected) |
154 | { |
153 | { |
155 | can_show=0; |
154 | can_show=0; |
156 | break; |
155 | break; |
157 | } |
156 | } |
158 | if (files.current!=id) |
157 | if (files.current!=id) |
159 | { |
158 | { |
160 | if (id |
159 | if (id |
161 | } |
160 | } |
162 | else |
161 | else |
163 | Open(); |
162 | Open(); |
164 | } |
163 | } |
165 | }; |
164 | }; |
166 | // } select/open file |
165 | // } select/open file |
167 | 166 | ||
168 | //file menu { |
167 | //file menu { |
169 | if (!m.pkm) && (!m.lkm) && (can_show) |
168 | if (!m.pkm) && (!m.lkm) && (can_show) |
170 | { |
169 | { |
171 | can_show = 0; |
170 | can_show = 0; |
172 | if (m.y>=57) |
171 | if (m.y>=57) |
173 | { |
172 | { |
174 | SwitchToAnotherThread(); |
173 | SwitchToAnotherThread(); |
175 | CreateThread(#FileMenu,#menu_stak); |
174 | CreateThread(#FileMenu,#menu_stak); |
176 | } |
175 | } |
177 | break; |
176 | break; |
178 | } |
177 | } |
179 | // } file menu |
178 | // } file menu |
180 | 179 | ||
181 | if (m.vert) |
180 | if (m.vert) |
182 | { |
181 | { |
183 | files.MouseScroll(m.vert); |
182 | files.MouseScroll(m.vert); |
184 | List_ReDraw(); |
183 | List_ReDraw(); |
185 | break; |
184 | break; |
186 | } |
185 | } |
187 | 186 | ||
188 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<57) |
187 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<57) |
189 | { |
188 | { |
190 | IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF); |
189 | IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF); |
191 | WHILE (m.lkm==1) && (files.first>0) |
190 | WHILE (m.lkm==1) && (files.first>0) |
192 | { |
191 | { |
193 | pause(8); |
192 | pause(8); |
194 | files.first--; |
193 | files.first--; |
195 | List_ReDraw(); |
194 | List_ReDraw(); |
196 | m.get(); |
195 | m.get(); |
197 | } |
196 | } |
198 | DrawRectangle3D(onLeft(26,0),41,14,14,0xFFFFFF,0xC7C7C7); |
197 | DrawRectangle3D(onLeft(26,0),41,14,14,0xFFFFFF,0xC7C7C7); |
199 | } |
198 | } |
200 | 199 | ||
201 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y |
200 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y |
202 | { |
201 | { |
203 | IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xC7C7C7,0xFFFFFF); |
202 | IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xC7C7C7,0xFFFFFF); |
204 | while (m.lkm==1) && (files.first |
203 | while (m.lkm==1) && (files.first |
205 | { |
204 | { |
206 | pause(8); |
205 | pause(8); |
207 | files.first++; |
206 | files.first++; |
208 | List_ReDraw(); |
207 | List_ReDraw(); |
209 | m.get(); |
208 | m.get(); |
210 | } |
209 | } |
211 | DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xFFFFFF,0xC7C7C7); |
210 | DrawRectangle3D(onLeft(26,0),onTop(21,0),14,14,0xFFFFFF,0xC7C7C7); |
212 | } |
211 | } |
213 | 212 | ||
214 | //Scrooll |
213 | //Scrooll |
215 | if (!m.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); } |
214 | if (!m.lkm) && (scroll_used) { scroll_used=NULL; Scroll(); } |
216 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y |
215 | if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y |
217 | 216 | ||
218 | if (scroll_used) |
217 | if (scroll_used) |
219 | { |
218 | { |
220 | IF (scroll_size/2+57>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+57; //anee eo?ni? iaa ieiii |
219 | IF (scroll_size/2+57>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+57; //anee eo?ni? iaa ieiii |
221 | id=files.first; |
220 | id=files.first; |
222 | j= scroll_size/2; |
221 | j= scroll_size/2; |
223 | files.first = m.y -j -57 * files.count; |
222 | files.first = m.y -j -57 * files.count; |
224 | files.first /= onTop(22,57); |
223 | files.first /= onTop(22,57); |
225 | IF (files.visible+files.first>files.count) files.first=files.count-files.visible; |
224 | IF (files.visible+files.first>files.count) files.first=files.count-files.visible; |
226 | IF (id!=files.first) List_ReDraw(); |
225 | IF (id!=files.first) List_ReDraw(); |
227 | } |
226 | } |
228 | break; |
227 | break; |
229 | //Button pressed----------------------------------------------------------------------------- |
228 | //Button pressed----------------------------------------------------------------------------- |
230 | case evButton: |
229 | case evButton: |
231 | id=GetButtonID(); |
230 | id=GetButtonID(); |
232 | if (id==1) ExitProcess(); |
231 | if (id==1) ExitProcess(); |
233 | if (rename_active) break; |
232 | if (rename_active) break; |
234 | if (del_active) |
233 | if (del_active) |
235 | { |
234 | { |
236 | IF (id==301) || (id==302) Del_File(302-id); |
235 | IF (id==301) || (id==302) Del_File(302-id); |
237 | break; |
236 | break; |
238 | } |
237 | } |
239 | 238 | ||
240 | switch(id) |
239 | switch(id) |
241 | { |
240 | { |
242 | case 21: //Back |
241 | case 21: //Back |
243 | GoBack(); |
242 | GoBack(); |
244 | break; |
243 | break; |
245 | case 22: //Forward |
244 | case 22: //Forward |
246 | if (HistoryPath(GO_FORWARD)) |
245 | if (HistoryPath(GO_FORWARD)) |
247 | { |
246 | { |
248 | files.first=files.current=NULL; //aaa?o nienea |
247 | files.first=files.current=NULL; //aaa?o nienea |
249 | Open_Dir(#path,WITH_REDRAW); |
248 | Open_Dir(#path,WITH_REDRAW); |
250 | } |
249 | } |
251 | break; |
250 | break; |
252 | case 23: //up! |
251 | case 23: //up! |
253 | Dir_Up(); |
252 | Dir_Up(); |
254 | break; |
253 | break; |
255 | case 24: //cut |
254 | case 24: //cut |
256 | Copy(#file_path, CUT); |
255 | Copy(#file_path, CUT); |
257 | break; |
256 | break; |
258 | case 25: //copy |
257 | case 25: //copy |
259 | Copy(#file_path, NOCUT); |
258 | Copy(#file_path, NOCUT); |
260 | break; |
259 | break; |
261 | case 26: //paste |
260 | case 26: //paste |
262 | CreateThread(#Paste,#copy_stak); |
261 | CreateThread(#Paste,#copy_stak); |
263 | break; |
262 | break; |
264 | case 31...33: //sort |
263 | case 31...33: //sort |
265 | IF(sort_num==1) DrawFilledBar(onLeft(192,168)/2+210,42,6,10); |
264 | IF(sort_num==1) DrawFilledBar(onLeft(192,168)/2+210,42,6,10); |
266 | IF(sort_num==2) DrawFilledBar(onLeft(115,0),42,6,10); |
265 | IF(sort_num==2) DrawFilledBar(onLeft(115,0),42,6,10); |
267 | IF(sort_num==3) DrawFilledBar(onLeft(44,0),42,6,10); |
266 | IF(sort_num==3) DrawFilledBar(onLeft(44,0),42,6,10); |
268 | sort_num=id-30; |
267 | sort_num=id-30; |
269 | Open_Dir(#path,WITH_REDRAW); |
268 | Open_Dir(#path,WITH_REDRAW); |
270 | break; |
269 | break; |
271 | case 50...60: //Actions |
270 | case 50...60: //Actions |
272 | FnProcess(id-50); |
271 | FnProcess(id-50); |
273 | break; |
272 | break; |
274 | case 100...120: |
273 | case 100...120: |
275 | DEVICE_MARK: |
274 | DEVICE_MARK: |
276 | DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea |
275 | DrawRectangle(17,id-100*16+74,159,16, 0); //auaaeaiea |
277 | strcpy(#path, #disk_list[id-100].Item); |
276 | strcpy(#path, #disk_list[id-100].Item); |
278 | files.first=files.current=0; |
277 | files.first=files.current=0; |
279 | Open_Dir(#path,WITH_REDRAW); |
278 | Open_Dir(#path,WITH_REDRAW); |
280 | pause(5); |
279 | pause(5); |
281 | DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF); |
280 | DrawRectangle(17,id-100*16+74,159,16, 0xFFFFFF); |
282 | break; |
281 | break; |
283 | case 130...160: |
282 | case 130...160: |
284 | tmp_disk_del_param[1]=disk_list[id-130].Item[4]; |
283 | tmp_disk_del_param[1]=disk_list[id-130].Item[4]; |
285 | RunProgram("/sys/tmpdisk", #tmp_disk_del_param); |
284 | RunProgram("/sys/tmpdisk", #tmp_disk_del_param); |
286 | pause(10); |
285 | pause(10); |
287 | SystemDiscsGet(); |
286 | SystemDiscsGet(); |
288 | Open_Dir(#path,WITH_REDRAW); |
287 | Open_Dir(#path,WITH_REDRAW); |
289 | DrawLeftPanel(); |
288 | DrawLeftPanel(); |
290 | break; |
289 | break; |
291 | } |
290 | } |
292 | break; |
291 | break; |
293 | //Key pressed----------------------------------------------------------------------------- |
292 | //Key pressed----------------------------------------------------------------------------- |
294 | case evKey: |
293 | case evKey: |
295 | key = GetKey(); |
294 | key = GetKey(); |
296 | if (Form.status_window>2) break; |
295 | if (Form.status_window>2) break; |
297 | IF (del_active) |
296 | IF (del_active) |
298 | { |
297 | { |
299 | IF (key==013) Del_File(true); |
298 | IF (key==013) Del_File(true); |
300 | IF (key==027) Del_File(false); |
299 | IF (key==027) Del_File(false); |
301 | break; |
300 | break; |
302 | } |
301 | } |
303 | IF (edit2.flags!=64) && (key!=13) && (key!=27) |
302 | IF (edit2.flags!=64) && (key!=13) && (key!=27) |
304 | { |
303 | { |
305 | EAX=key<<8; |
304 | EAX=key<<8; |
306 | edit_box_key stdcall (#edit2); |
305 | edit_box_key stdcall (#edit2); |
307 | break; |
306 | break; |
308 | } |
307 | } |
309 | switch (key) |
308 | switch (key) |
310 | { |
309 | { |
311 | case 209...217: |
310 | case 209...217: |
312 | id=key-110; |
311 | id=key-110; |
313 | IF (id-100>=disc_num) break; |
312 | IF (id-100>=disc_num) break; |
314 | GOTO DEVICE_MARK; |
313 | GOTO DEVICE_MARK; |
315 | case 008: |
314 | case 008: |
316 | //GoBack(); |
315 | //GoBack(); |
317 | Dir_Up(); |
316 | Dir_Up(); |
318 | break; |
317 | break; |
319 | case 004: //Ctrl+D set as bg |
318 | case 004: //Ctrl+D set as bg |
320 | strcpy(#temp, "\\S__"); |
319 | strcpy(#temp, "\\S__"); |
321 | strcat(#temp, #file_path); |
320 | strcat(#temp, #file_path); |
322 | RunProgram("/sys/media/kiv", #temp); |
321 | RunProgram("/sys/media/kiv", #temp); |
323 | break; |
322 | break; |
324 | case 014: //Ctrl+N new window |
323 | case 014: //Ctrl+N new window |
325 | IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD); |
324 | IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD); |
326 | RunProgram("/sys/File Managers/Eolite", #path); |
325 | RunProgram("/sys/File Managers/Eolite", #path); |
327 | break; |
326 | break; |
328 | case 024: //Ctrl+X |
327 | case 024: //Ctrl+X |
329 | Copy(#file_path, CUT); |
328 | Copy(#file_path, CUT); |
330 | break; |
329 | break; |
331 | case 003: //Ctrl+C |
330 | case 003: //Ctrl+C |
332 | Copy(#file_path, NOCUT); |
331 | Copy(#file_path, NOCUT); |
333 | break; |
332 | break; |
334 | case 022: //Ctrl+V |
333 | case 022: //Ctrl+V |
335 | CreateThread(#Paste,#copy_stak); |
334 | CreateThread(#Paste,#copy_stak); |
336 | break; |
335 | break; |
337 | case 027: //Esc |
336 | case 027: //Esc |
338 | IF (rename_active==1) ReName(false); |
337 | IF (rename_active==1) ReName(false); |
339 | break; |
338 | break; |
340 | case 013: //Enter |
339 | case 013: //Enter |
341 | IF (rename_active==1) {ReName(true); break;} |
340 | IF (rename_active==1) {ReName(true); break;} |
342 | Open(); |
341 | Open(); |
343 | break; |
342 | break; |
344 | case 178: //up |
343 | case 178: //up |
345 | List_Current(-1); |
344 | List_Current(-1); |
346 | break; |
345 | break; |
347 | case 177: //down |
346 | case 177: //down |
348 | List_Current(1); |
347 | List_Current(1); |
349 | break; |
348 | break; |
350 | case 180: //home |
349 | case 180: //home |
351 | files.first=0; |
350 | files.first=0; |
352 | files.current=0; |
351 | files.current=0; |
353 | List_ReDraw(); |
352 | List_ReDraw(); |
354 | break; |
353 | break; |
355 | case 181: //end |
354 | case 181: //end |
356 | files.first = files.count - files.visible; |
355 | files.first = files.count - files.visible; |
357 | files.current = files.visible - 1; |
356 | files.current = files.visible - 1; |
358 | List_ReDraw(); |
357 | List_ReDraw(); |
359 | break; |
358 | break; |
360 | case 183: //Page Down |
359 | case 183: //Page Down |
361 | List_Current(files.visible-1); |
360 | List_Current(files.visible-1); |
362 | break; |
361 | break; |
363 | case 184: //Page Up |
362 | case 184: //Page Up |
364 | List_Current(-files.visible+1); |
363 | List_Current(-files.visible+1); |
365 | break; |
364 | break; |
366 | case 182: //del |
365 | case 182: //del |
367 | Del_Form(); |
366 | Del_Form(); |
368 | break; |
367 | break; |
369 | case 050...059: //F1-F10 |
368 | case 050...059: //F1-F10 |
370 | FnProcess(key-49); |
369 | FnProcess(key-49); |
371 | break; |
370 | break; |
372 | default: |
371 | default: |
373 | for (i=files.current+files.first+1; i |
372 | for (i=files.current+files.first+1; i |
374 | { |
373 | { |
375 | strcpy(#temp, file_mas[i]*304+buf+72); |
374 | strcpy(#temp, file_mas[i]*304+buf+72); |
376 | IF (temp[0]==key) || (temp[0]==key-32) |
375 | IF (temp[0]==key) || (temp[0]==key-32) |
377 | { |
376 | { |
378 | List_Current(i-files.current-files.first); |
377 | List_Current(i-files.current-files.first); |
379 | break; |
378 | break; |
380 | } |
379 | } |
381 | } |
380 | } |
382 | } |
381 | } |
383 | break; |
382 | break; |
384 | case evReDraw: |
383 | case evReDraw: |
385 | draw_window(); |
384 | draw_window(); |
386 | } |
385 | } |
387 | } |
386 | } |
388 | 387 | ||
389 | 388 | ||
390 | void draw_window() |
389 | void draw_window() |
391 | { |
390 | { |
392 | DefineAndDrawWindow(40,20,550,500,0x73,col_work,TITLE); |
391 | DefineAndDrawWindow(40,20,550,500,0x73,col_work,TITLE); |
393 | GetProcessInfo(#Form, SelfInfo); |
392 | GetProcessInfo(#Form, SelfInfo); |
394 | if (Form.status_window>2) return; |
393 | if (Form.status_window>2) return; |
395 | files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h); |
394 | files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h); |
396 | if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h); |
395 | if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h); |
397 | if (Form.width<480) MoveSize(OLD,OLD,480,OLD); |
396 | if (Form.width<480) MoveSize(OLD,OLD,480,OLD); |
398 | GetProcessInfo(#Form, SelfInfo); //if win_size changed |
397 | GetProcessInfo(#Form, SelfInfo); //if win_size changed |
399 | 398 | ||
400 | PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal); |
399 | PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal); |
401 | DrawBar(127, 8, 1, 25, col_border); |
400 | DrawBar(127, 8, 1, 25, col_border); |
402 | for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,col_work); |
401 | for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,col_work); |
403 | for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,col_work); |
402 | for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,col_work); |
404 | DrawBar(246,0,onLeft(246,60),12, col_work); //upper editbox |
403 | DrawBar(246,0,onLeft(246,60),12, col_work); //upper editbox |
405 | DrawBar(246,29,onLeft(246,60),5,col_work); //under editbox |
404 | DrawBar(246,29,onLeft(246,60),5,col_work); //under editbox |
406 | DrawRectangle(246,12,onLeft(66,246),16,col_border); |
405 | DrawRectangle(246,12,onLeft(66,246),16,col_border); |
407 | DefineButton(onLeft(34,0),6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about |
406 | DefineButton(onLeft(34,0),6,27,28,51+BT_HIDE+BT_NOFRAME,0); //about |
408 | PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal); |
407 | PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal); |
409 | //main rectangles |
408 | //main rectangles |
410 | DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),col_border); |
409 | DrawRectangle(1,40,Form.cwidth-3,onTop(46,0),col_border); |
411 | DrawRectangle(0,39,Form.cwidth-1,onTop(44,0),col_palette[4]); //bg |
410 | DrawRectangle(0,39,Form.cwidth-1,onTop(44,0),col_palette[4]); //bg |
412 | for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]); |
411 | for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]); |
413 | DrawLeftPanel(); |
412 | DrawLeftPanel(); |
414 | //ListBox |
413 | //ListBox |
415 | DrawFlatButton(files.x,40,onLeft(files.x,168),16,31,col_work,T_FILE); |
414 | DrawFlatButton(files.x,40,onLeft(files.x,168),16,31,col_work,T_FILE); |
416 | DrawFlatButton(onLeft(168,0),40,73,16,32,col_work,T_TYPE); |
415 | DrawFlatButton(onLeft(168,0),40,73,16,32,col_work,T_TYPE); |
417 | DrawFlatButton(onLeft(95,0),40,68,16,33,col_work,T_SIZE); |
416 | DrawFlatButton(onLeft(95,0),40,68,16,33,col_work,T_SIZE); |
418 | DrawBar(onLeft(27,0),57,1,onTop(22,57),col_border); //line to the left from the scroll |
417 | DrawBar(onLeft(27,0),57,1,onTop(22,57),col_border); //line to the left from the scroll |
419 | DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18"); |
418 | DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18"); |
420 | DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19"); |
419 | DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19"); |
421 | Open_Dir(#path,ONLY_SHOW); |
420 | Open_Dir(#path,ONLY_SHOW); |
422 | if (del_active) Del_Form(); |
421 | if (del_active) Del_Form(); |
423 | if (rename_active) FnProcess(2); |
422 | if (rename_active) FnProcess(2); |
424 | } |
423 | } |
425 | 424 | ||
426 | 425 | ||
427 | void KEdit() |
426 | void KEdit() |
428 | { |
427 | { |
429 | if (Form.width<480) return; |
428 | if (Form.width<480) return; |
430 | PathShow.area_size_x = Form.cwidth-306; |
429 | PathShow.area_size_x = Form.cwidth-306; |
431 | DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff); |
430 | DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff); |
432 | PathShow_prepare stdcall(#PathShow); |
431 | PathShow_prepare stdcall(#PathShow); |
433 | PathShow_draw stdcall(#PathShow); |
432 | PathShow_draw stdcall(#PathShow); |
434 | } |
433 | } |
435 | 434 | ||
436 | 435 | ||
437 | void List_Current(int cur) |
436 | void List_Current(int cur) |
438 | { |
437 | { |
439 | if (cur<=0) //up |
438 | if (cur<=0) //up |
440 | { |
439 | { |
441 | IF (files.first==0) && (files.current<=0) return; |
440 | IF (files.first==0) && (files.current<=0) return; |
442 | IF (-cur-1 |
441 | IF (-cur-1 |
443 | { |
442 | { |
444 | Line_ReDraw(0xFFFFFF, files.current); |
443 | Line_ReDraw(0xFFFFFF, files.current); |
445 | files.current+=cur; |
444 | files.current+=cur; |
446 | Line_ReDraw(col_selec, files.current); |
445 | Line_ReDraw(col_selec, files.current); |
447 | return; |
446 | return; |
448 | } |
447 | } |
449 | ELSE |
448 | ELSE |
450 | { |
449 | { |
451 | IF (-cur |
450 | IF (-cur |
452 | files.current=0; |
451 | files.current=0; |
453 | List_ReDraw(); |
452 | List_ReDraw(); |
454 | return; |
453 | return; |
455 | } |
454 | } |
456 | } |
455 | } |
457 | else //down |
456 | else //down |
458 | { |
457 | { |
459 | IF (files.first==files.count-files.visible) && (files.current==files.visible-1) return; |
458 | IF (files.first==files.count-files.visible) && (files.current==files.visible-1) return; |
460 | IF (files.visible-files.current>cur) |
459 | IF (files.visible-files.current>cur) |
461 | { |
460 | { |
462 | Line_ReDraw(0xFFFFFF, files.current); |
461 | Line_ReDraw(0xFFFFFF, files.current); |
463 | files.current+=cur; |
462 | files.current+=cur; |
464 | Line_ReDraw(col_selec, files.current); |
463 | Line_ReDraw(col_selec, files.current); |
465 | return; |
464 | return; |
466 | } |
465 | } |
467 | else |
466 | else |
468 | { |
467 | { |
469 | IF(files.first+files.current+cur>=files.count) |
468 | IF(files.first+files.current+cur>=files.count) |
470 | { |
469 | { |
471 | files.first=files.count-files.visible; |
470 | files.first=files.count-files.visible; |
472 | files.current=cur-files.first+files.current; |
471 | files.current=cur-files.first+files.current; |
473 | } |
472 | } |
474 | ELSE |
473 | ELSE |
475 | { |
474 | { |
476 | files.first+=cur+files.current-files.visible+1; |
475 | files.first+=cur+files.current-files.visible+1; |
477 | files.current=files.visible-1; |
476 | files.current=files.visible-1; |
478 | } |
477 | } |
479 | 478 | ||
480 | IF (files.current<0) || (files.current>files.visible) |
479 | IF (files.current<0) || (files.current>files.visible) |
481 | { |
480 | { |
482 | files.current=files.visible-1; |
481 | files.current=files.visible-1; |
483 | } |
482 | } |
484 | List_ReDraw(); |
483 | List_ReDraw(); |
485 | } |
484 | } |
486 | } |
485 | } |
487 | } |
486 | } |
488 | 487 | ||
489 | 488 | ||
490 | void List_ReDraw() |
489 | void List_ReDraw() |
491 | { |
490 | { |
492 | int paint_y; |
491 | int paint_y; |
493 | //we are in the end of the list => maximize window => there will be white lines after the last element |
492 | //we are in the end of the list => maximize window => there will be white lines after the last element |
494 | if (files.count-files.first |
493 | if (files.count-files.first |
495 | { files.first=files.count-files.visible; files.current=files.visible-1; } |
494 | { files.first=files.count-files.visible; files.current=files.visible-1; } |
496 | for (j=0; j |
495 | for (j=0; j |
497 | //in the bottom |
496 | //in the bottom |
498 | paint_y = j * files.line_h + files.y; |
497 | paint_y = j * files.line_h + files.y; |
499 | DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF); |
498 | DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF); |
500 | DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),col_work); |
499 | DrawBar(Form.cwidth-159,paint_y,1,onTop(paint_y,6),col_work); |
501 | DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),col_work); |
500 | DrawBar(Form.cwidth-86,paint_y,1,onTop(paint_y,6),col_work); |
502 | Scroll(); |
501 | Scroll(); |
503 | } |
502 | } |
504 | 503 | ||
505 | 504 | ||
506 | void Line_ReDraw(dword color, filenum){ |
505 | void Line_ReDraw(dword color, filenum){ |
507 | dword text_col=0, |
506 | dword text_col=0, |
508 | name_len=0, |
507 | name_len=0, |
509 | attr, |
508 | attr, |
510 | y=filenum*files.line_h+57; |
509 | y=filenum*files.line_h+57; |
511 | DrawBar(files.x,y,3,files.line_h,color); |
510 | DrawBar(files.x,y,3,files.line_h,color); |
512 | DrawBar(files.x+19,y,files.w-19,files.line_h,color); |
511 | DrawBar(files.x+19,y,files.w-19,files.line_h,color); |
513 | DrawBar(files.x+3,y+17,16,1,color); |
512 | DrawBar(files.x+3,y+17,16,1,color); |
514 | if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color); |
513 | if (files.line_h>18) DrawBar(files.x+3,y+18,16,files.line_h-18,color); |
515 | if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color); |
514 | if (files.line_h>15) DrawBar(files.x+3,y,16,files.line_h-15,color); |
516 | 515 | ||
517 | off=file_mas[filenum+files.first]*304 + buf+72; |
516 | off=file_mas[filenum+files.first]*304 + buf+72; |
518 | attr = ESDWORD[off - 40]; |
517 | attr = ESDWORD[off - 40]; |
519 | 518 | ||
520 | if (! TestBit(attr, 4) ) //file or folder? |
519 | if (! TestBit(attr, 4) ) //file or folder? |
521 | { |
520 | { |
522 | Put_icon(off+_strrchr(off,'.'), files.line_h/2-7+y, color); |
521 | Put_icon(off+_strrchr(off,'.'), files.line_h/2-7+y, color); |
523 | WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size |
522 | WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size |
524 | } |
523 | } |
525 | else |
524 | else |
526 | if (!strcmp("..",off)) |
525 | if (!strcmp("..",off)) |
527 | Put_icon("..", files.line_h/2-7+y, color); |
526 | Put_icon("..", files.line_h/2-7+y, color); |
528 | else |
527 | else |
529 | Put_icon(" |
528 | Put_icon(" |
530 | if ( TestBit(attr, 1) ) || ( TestBit(attr, 2) ) text_col=0xA6A6B7; //system or hiden? |
529 | if ( TestBit(attr, 1) ) || ( TestBit(attr, 2) ) text_col=0xA6A6B7; //system or hiden? |
531 | if (color!=0xFFFfff) |
530 | if (color!=0xFFFfff) |
532 | { |
531 | { |
533 | itdir = TestBit(attr, 4); |
532 | itdir = TestBit(attr, 4); |
534 | strcpy(#file_name, off); |
533 | strcpy(#file_name, off); |
535 | strcpy(#file_path, #path); |
534 | strcpy(#file_path, #path); |
536 | strcat(#file_path, #file_name); |
535 | strcat(#file_path, #file_name); |
537 | if (text_col==0xA6A6B7) text_col=0xFFFFFF; |
536 | if (text_col==0xA6A6B7) text_col=0xFFFFFF; |
538 | } |
537 | } |
539 | if (Form.width>=480) |
538 | if (Form.width>=480) |
540 | { |
539 | { |
541 | FileShow.start_x = files.x + 23; |
540 | FileShow.start_x = files.x + 23; |
542 | FileShow.font_color = text_col; |
541 | FileShow.font_color = text_col; |
543 | FileShow.area_size_x = Form.width - 380; |
542 | FileShow.area_size_x = Form.width - 380; |
544 | FileShow.text_pointer = off; |
543 | FileShow.text_pointer = off; |
545 | FileShow.start_y = files.line_h/2-3+y; |
544 | FileShow.start_y = files.line_h/2-3+y; |
546 | PathShow_prepare stdcall(#FileShow); |
545 | PathShow_prepare stdcall(#FileShow); |
547 | PathShow_draw stdcall(#FileShow); |
546 | PathShow_draw stdcall(#FileShow); |
548 | } |
547 | } |
549 | DrawBar(Form.cwidth-159,y,1,files.line_h,col_work); //gray line 1 |
548 | DrawBar(Form.cwidth-159,y,1,files.line_h,col_work); //gray line 1 |
550 | DrawBar(Form.cwidth-86,y,1,files.line_h,col_work); //gray line 2 |
549 | DrawBar(Form.cwidth-86,y,1,files.line_h,col_work); //gray line 2 |
551 | } |
550 | } |
552 | 551 | ||
553 | 552 | ||
554 | void Open_Dir(dword dir_path, redraw){ |
553 | void Open_Dir(dword dir_path, redraw){ |
555 | int errornum, maxcount; |
554 | int errornum, maxcount; |
556 | 555 | ||
557 | if (redraw!=ONLY_SHOW) |
556 | if (redraw!=ONLY_SHOW) |
558 | { |
557 | { |
559 | if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0'; |
558 | if (ESBYTE[dir_path+1]!='\0') ESBYTE[dir_path+strlen(dir_path)-1] = '\0'; |
560 | if (buf) free(buf); |
559 | if (buf) free(buf); |
561 | errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT); |
560 | errornum = GetDir(#buf, #files.count, dir_path, DIRS_NOROOT); |
562 | if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/'); |
561 | if (ESBYTE[dir_path+1]!='\0') chrcat(dir_path, '/'); |
563 | if (errornum) |
562 | if (errornum) |
564 | { |
563 | { |
565 | HistoryPath(ADD_NEW_PATH); |
564 | HistoryPath(ADD_NEW_PATH); |
566 | GoBack(); |
565 | GoBack(); |
567 | Write_Error(errornum); |
566 | Write_Error(errornum); |
568 | return; |
567 | return; |
569 | } |
568 | } |
570 | maxcount = sizeof(file_mas)/sizeof(dword)-1; |
569 | maxcount = sizeof(file_mas)/sizeof(dword)-1; |
571 | if (files.count>maxcount) files.count = maxcount; |
570 | if (files.count>maxcount) files.count = maxcount; |
572 | } |
571 | } |
573 | if (files.count!=-1) |
572 | if (files.count!=-1) |
574 | { |
573 | { |
575 | KEdit(); |
574 | KEdit(); |
576 | HistoryPath(ADD_NEW_PATH); |
575 | HistoryPath(ADD_NEW_PATH); |
577 | files.visible = files.h / files.line_h; |
576 | files.visible = files.h / files.line_h; |
578 | IF (files.count < files.visible) files.visible = files.count; |
577 | IF (files.count < files.visible) files.visible = files.count; |
579 | IF (sort_num==1) WriteText(Form.width+60/2,45,0x80,col_border,"\x19"); |
578 | IF (sort_num==1) WriteText(Form.width+60/2,45,0x80,col_border,"\x19"); |
580 | IF (sort_num==2) WriteText(Form.width-115,45,0x80,col_border,"\x19"); |
579 | IF (sort_num==2) WriteText(Form.width-115,45,0x80,col_border,"\x19"); |
581 | IF (sort_num==3) WriteText(Form.width-44,45,0x80,col_border,"\x19"); |
580 | IF (sort_num==3) WriteText(Form.width-44,45,0x80,col_border,"\x19"); |
582 | IF (redraw!=ONLY_SHOW) Sorting(); |
581 | IF (redraw!=ONLY_SHOW) Sorting(); |
583 | IF (redraw!=ONLY_OPEN) List_ReDraw(); |
582 | IF (redraw!=ONLY_OPEN) List_ReDraw(); |
584 | } |
583 | } |
585 | IF (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();} |
584 | IF (files.count==-1) && (redraw!=ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();} |
586 | } |
585 | } |
587 | 586 | ||
588 | 587 | ||
589 | inline Sorting() |
588 | inline Sorting() |
590 | { |
589 | { |
591 | dword k=0, l=1; |
590 | dword k=0, l=1; |
592 | int i; |
591 | int i; |
593 | if (!strcmp(#path,"/")) //do not sort |
592 | if (!strcmp(#path,"/")) //do not sort |
594 | { |
593 | { |
595 | FOR(k=1;k |
594 | FOR(k=1;k |
596 | return; |
595 | return; |
597 | } |
596 | } |
598 | FOR (j=files.count-1, off=files.count-1*304+buf+32; j>=0; j--, off-=304;) //files | folders |
597 | FOR (j=files.count-1, off=files.count-1*304+buf+32; j>=0; j--, off-=304;) //files | folders |
599 | { |
598 | { |
600 | strttl(off+40); |
599 | strttl(off+40); |
601 | if (TestBit(ESDWORD[off],4)) //directory? |
600 | if (TestBit(ESDWORD[off],4)) //directory? |
602 | { |
601 | { |
603 | file_mas[k]=j; |
602 | file_mas[k]=j; |
604 | k++; |
603 | k++; |
605 | } |
604 | } |
606 | else |
605 | else |
607 | { |
606 | { |
608 | file_mas[files.count-l]=j; |
607 | file_mas[files.count-l]=j; |
609 | l++; |
608 | l++; |
610 | } |
609 | } |
611 | } |
610 | } |
612 | //sorting: files first, then folders |
611 | //sorting: files first, then folders |
613 | Sort_by_Name(0,k-1); |
612 | Sort_by_Name(0,k-1); |
614 | IF (sort_num==1) Sort_by_Name(k,files.count-1); |
613 | IF (sort_num==1) Sort_by_Name(k,files.count-1); |
615 | IF (sort_num==2) Sort_by_Type(k,files.count-1); |
614 | IF (sort_num==2) Sort_by_Type(k,files.count-1); |
616 | IF (sort_num==3) Sort_by_Size(k,files.count-1); |
615 | IF (sort_num==3) Sort_by_Size(k,files.count-1); |
617 | //".." should be first |
616 | //".." should be first |
618 | IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")!=0) |
617 | IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")!=0) |
619 | FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) {file_mas[k]> |
618 | FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) {file_mas[k]> |
620 | } |
619 | } |
621 | 620 | ||
622 | 621 | ||
623 | void Del_Form() |
622 | void Del_Form() |
624 | { |
623 | { |
625 | int dform_x = files.w - 200 / 2 + files.x; |
624 | int dform_x = files.w - 200 / 2 + files.x; |
626 | //oeia ieii |
625 | //oeia ieii |
627 | if (!files.count) return; |
626 | if (!files.count) return; |
628 | #ifdef LANG_RUS |
627 | #ifdef LANG_RUS |
629 | DrawFlatButton(dform_x,160,215,80,0,col_work, ""); //oi?ia |
628 | DrawFlatButton(dform_x,160,215,80,0,col_work, ""); //oi?ia |
630 | #else |
629 | #else |
631 | DrawFlatButton(dform_x,160,200,80,0,col_work, ""); //oi?ia |
630 | DrawFlatButton(dform_x,160,200,80,0,col_work, ""); //oi?ia |
632 | #endif |
631 | #endif |
633 | WriteText(dform_x+19,175,0x80,0,T_DELETE_FILE); |
632 | WriteText(dform_x+19,175,0x80,0,T_DELETE_FILE); |
634 | IF (strlen(#file_name)<28) |
633 | IF (strlen(#file_name)<28) |
635 | { |
634 | { |
636 | WriteText(strlen(#file_name)*6+dform_x+20,190,0x80,0,"?"); |
635 | WriteText(strlen(#file_name)*6+dform_x+20,190,0x80,0,"?"); |
637 | WriteText(dform_x+20,190,0x80,0,#file_name); //ieoai eiy |
636 | WriteText(dform_x+20,190,0x80,0,#file_name); //ieoai eiy |
638 | } |
637 | } |
639 | ELSE |
638 | ELSE |
640 | { |
639 | { |
641 | WriteText(164+dform_x,190,0x80,0,"...?"); |
640 | WriteText(164+dform_x,190,0x80,0,"...?"); |
642 | ESI = 24; |
641 | ESI = 24; |
643 | WriteText(dform_x+20,190,0,0,#file_name); //ieoai eiy |
642 | WriteText(dform_x+20,190,0,0,#file_name); //ieoai eiy |
644 | } |
643 | } |
645 | DrawFlatButton(dform_x+20,208,70,20,301,0xFFB6B5,T_YES); |
644 | DrawFlatButton(dform_x+20,208,70,20,301,0xFFB6B5,T_YES); |
646 | DrawFlatButton(dform_x+111,208,70,20,302,0xC6DFC6,T_NO); |
645 | DrawFlatButton(dform_x+111,208,70,20,302,0xC6DFC6,T_NO); |
647 | del_active=1; |
646 | del_active=1; |
648 | } |
647 | } |
649 | 648 | ||
650 | 649 | ||
651 | void Del_File(byte dodel) |
650 | void Del_File(byte dodel) |
652 | { |
651 | { |
653 | int del_rezult; |
652 | int del_rezult; |
654 | IF (dodel==true) |
653 | IF (dodel==true) |
655 | { |
654 | { |
656 | del_rezult = DeleteFile(#file_path); |
655 | del_rezult = DeleteFile(#file_path); |
657 | IF (del_rezult) |
656 | IF (del_rezult) |
658 | { |
657 | { |
659 | Write_Error(del_rezult); |
658 | Write_Error(del_rezult); |
660 | IF ( itdir) ShowMessage(T_DEL_ERROR_1); |
659 | IF ( itdir) ShowMessage(T_DEL_ERROR_1); |
661 | IF (!itdir) ShowMessage(T_DEL_ERROR_2); |
660 | IF (!itdir) ShowMessage(T_DEL_ERROR_2); |
662 | } |
661 | } |
663 | } |
662 | } |
664 | del_active=0; |
663 | del_active=0; |
665 | DeleteButton(301); DeleteButton(302); |
664 | DeleteButton(301); DeleteButton(302); |
666 | Open_Dir(#path,WITH_REDRAW); |
665 | Open_Dir(#path,WITH_REDRAW); |
667 | } |
666 | } |
668 | 667 | ||
669 | 668 | ||
670 | void ReName(byte rename) |
669 | void ReName(byte rename) |
671 | { |
670 | { |
672 | int del_rezult, copy_rezult; |
671 | int del_rezult, copy_rezult; |
673 | char edit_name[256]; |
672 | char edit_name[256]; |
674 | rename_active=0; |
673 | rename_active=0; |
675 | edit2.flags=64; |
674 | edit2.flags=64; |
676 | if (rename==true) |
675 | if (rename==true) |
677 | { |
676 | { |
678 | strcpy(#temp, #path); |
677 | strcpy(#temp, #path); |
679 | strcpy(#edit_name, #file_name); //save edit name to select it later |
678 | strcpy(#edit_name, #file_name); //save edit name to select it later |
680 | strcat(#temp, #file_name); |
679 | strcat(#temp, #file_name); |
681 | if (strcmp(#file_path,#temp)!=0) && (file_name) |
680 | if (strcmp(#file_path,#temp)!=0) && (file_name) |
682 | if (itdir) |
681 | if (itdir) |
683 | { |
682 | { |
684 | del_rezult = DeleteFile(#file_path); |
683 | del_rezult = DeleteFile(#file_path); |
685 | if (del_rezult!=0) |
684 | if (del_rezult!=0) |
686 | { |
685 | { |
687 | Write_Error(del_rezult); |
686 | Write_Error(del_rezult); |
688 | ShowMessage(T_DEL_ERROR_1); |
687 | ShowMessage(T_DEL_ERROR_1); |
689 | return; |
688 | return; |
690 | } |
689 | } |
691 | ELSE CreateDir(#temp); |
690 | ELSE CreateDir(#temp); |
692 | Open_Dir(#path,WITH_REDRAW); |
691 | Open_Dir(#path,WITH_REDRAW); |
693 | } |
692 | } |
694 | else |
693 | else |
695 | { |
694 | { |
696 | copy_rezult = CopyFile(#file_path,#temp); |
695 | copy_rezult = CopyFile(#file_path,#temp); |
697 | if (copy_rezult!=0) Write_Error(copy_rezult); else Del_File(true); |
696 | if (copy_rezult!=0) Write_Error(copy_rezult); else Del_File(true); |
698 | } |
697 | } |
699 | SelectFile(#edit_name); |
698 | SelectFile(#edit_name); |
700 | } |
699 | } |
701 | Line_ReDraw(col_selec,files.current); |
700 | Line_ReDraw(col_selec,files.current); |
702 | } |
701 | } |
703 | 702 | ||
704 | 703 | ||
705 | void SelectFile(dword that_file) |
704 | void SelectFile(dword that_file) |
706 | { |
705 | { |
707 | files.first=files.current=0; |
706 | files.first=files.current=0; |
708 | Open_Dir(#path,ONLY_OPEN); |
707 | Open_Dir(#path,ONLY_OPEN); |
709 | strttl(that_file); |
708 | strttl(that_file); |
710 | for (i=files.count-1; i>=0; i--;) |
709 | for (i=files.count-1; i>=0; i--;) |
711 | if (!strcmp(file_mas[i]*304+buf+72,that_file)) break; |
710 | if (!strcmp(file_mas[i]*304+buf+72,that_file)) break; |
712 | List_Current(i); |
711 | List_Current(i); |
713 | List_ReDraw(); |
712 | List_ReDraw(); |
714 | } |
713 | } |
715 | 714 | ||
716 | 715 | ||
717 | void Dir_Up() |
716 | void Dir_Up() |
718 | { |
717 | { |
719 | char cur_folder[4096]; |
718 | char cur_folder[4096]; |
720 | i=strlen(#path)-1; |
719 | i=strlen(#path)-1; |
721 | if (i==0) return; |
720 | if (i==0) return; |
722 | path[i]=0x00; |
721 | path[i]=0x00; |
723 | i = strrchr(#path, '/'); |
722 | i = strrchr(#path, '/'); |
724 | strcpy(#cur_folder, #path+i); |
723 | strcpy(#cur_folder, #path+i); |
725 | path[i]=0x00; |
724 | path[i]=0x00; |
726 | SelectFile(#cur_folder); |
725 | SelectFile(#cur_folder); |
727 | } |
726 | } |
728 | 727 | ||
729 | void Open() |
728 | void Open() |
730 | { |
729 | { |
731 | if (!files.count) return; |
730 | if (!files.count) return; |
732 | if (!itdir) |
731 | if (!itdir) |
733 | { |
732 | { |
734 | GetIni(0); |
733 | GetIni(0); |
735 | } |
734 | } |
736 | else |
735 | else |
737 | { |
736 | { |
738 | if (!strcmp(#file_name,"..")) { Dir_Up(); return; } |
737 | if (!strcmp(#file_name,"..")) { Dir_Up(); return; } |
739 | strcpy(#path, #file_path); |
738 | strcpy(#path, #file_path); |
740 | if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end |
739 | if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end |
741 | files.first=files.current=0; |
740 | files.first=files.current=0; |
742 | Open_Dir(#path,WITH_REDRAW); |
741 | Open_Dir(#path,WITH_REDRAW); |
743 | } |
742 | } |
744 | } |
743 | } |
745 | 744 | ||
746 | 745 | ||
747 | inline fastcall void GoBack() |
746 | inline fastcall void GoBack() |
748 | { |
747 | { |
749 | char cur_folder[4096]; |
748 | char cur_folder[4096]; |
750 | strcpy(#cur_folder, GetCurrentFolder()); |
749 | strcpy(#cur_folder, GetCurrentFolder()); |
751 | if (HistoryPath(GO_BACK)) SelectFile(#cur_folder); |
750 | if (HistoryPath(GO_BACK)) SelectFile(#cur_folder); |
752 | } |
751 | } |
753 | 752 | ||
754 | void FnProcess(char N) |
753 | void FnProcess(char N) |
755 | { |
754 | { |
756 | switch(N) |
755 | switch(N) |
757 | { |
756 | { |
758 | case 1: |
757 | case 1: |
759 | SwitchToAnotherThread(); |
758 | SwitchToAnotherThread(); |
760 | CreateThread(#about_dialog,#about_stak); |
759 | CreateThread(#about_dialog,#about_stak); |
761 | break; |
760 | break; |
762 | case 2: |
761 | case 2: |
763 | if (!files.count) break; |
762 | if (!files.count) break; |
764 | edit2.flags = 100000000000010b; //set active |
763 | edit2.flags = 100000000000010b; //set active |
765 | edit2.left = files.x + 21; |
764 | edit2.left = files.x + 21; |
766 | edit2.width = files.w - 26; |
765 | edit2.width = files.w - 26; |
767 | edit2.top=files.current*files.line_h+59; |
766 | edit2.top=files.current*files.line_h+59; |
768 | edit2.size=edit2.pos=strlen(#file_name); |
767 | edit2.size=edit2.pos=strlen(#file_name); |
769 | edit_box_draw stdcall (#edit2); |
768 | edit_box_draw stdcall (#edit2); |
770 | DrawBar(edit2.left,files.current*files.line_h+58,edit2.width+1,1,0xFFFFCC); //bg |
769 | DrawBar(edit2.left,files.current*files.line_h+58,edit2.width+1,1,0xFFFFCC); //bg |
771 | rename_active=1; |
770 | rename_active=1; |
772 | break; |
771 | break; |
773 | case 3: |
772 | case 3: |
774 | IF (!itdir) RunProgram("/sys/tinypad", #file_path); |
773 | IF (!itdir) RunProgram("/sys/tinypad", #file_path); |
775 | break; |
774 | break; |
776 | case 4: |
775 | case 4: |
777 | IF (!itdir) RunProgram("/sys/develop/heed", #file_path); |
776 | IF (!itdir) RunProgram("/sys/develop/heed", #file_path); |
778 | break; |
777 | break; |
779 | case 5: //refresh cur dir & devs |
778 | case 5: //refresh cur dir & devs |
780 | Tip(56, T_DEVICES, 55, "-"); |
779 | Tip(56, T_DEVICES, 55, "-"); |
781 | Open_Dir(#path,WITH_REDRAW); |
780 | Open_Dir(#path,WITH_REDRAW); |
782 | pause(10); |
781 | pause(10); |
783 | GetIni(1); |
782 | GetIni(1); |
784 | SystemDiscsGet(); |
783 | SystemDiscsGet(); |
785 | Open_Dir(#path,WITH_REDRAW); |
784 | Open_Dir(#path,WITH_REDRAW); |
786 | DrawLeftPanel(); |
785 | DrawLeftPanel(); |
787 | break; |
786 | break; |
788 | case 6: |
787 | case 6: |
789 | strcpy(#temp, #path); |
788 | strcpy(#temp, #path); |
790 | strcat(#temp, T_NEW_FOLDER); |
789 | strcat(#temp, T_NEW_FOLDER); |
791 | CreateDir(#temp); |
790 | CreateDir(#temp); |
792 | if (!EAX){ |
791 | if (!EAX){ |
793 | SelectFile(T_NEW_FOLDER); |
792 | SelectFile(T_NEW_FOLDER); |
794 | FnProcess(2); |
793 | FnProcess(2); |
795 | } |
794 | } |
796 | else |
795 | else |
797 | { |
796 | { |
798 | Write_Error(EAX); |
797 | Write_Error(EAX); |
799 | ShowMessage(NOT_CREATE_FOLDER); |
798 | ShowMessage(NOT_CREATE_FOLDER); |
800 | } |
799 | } |
801 | break; |
800 | break; |
802 | case 7: |
801 | case 7: |
803 | strcpy(#temp, #path); |
802 | strcpy(#temp, #path); |
804 | strcat(#temp, T_NEW_FILE); |
803 | strcat(#temp, T_NEW_FILE); |
805 | WriteFile(0, 0, #temp); |
804 | WriteFile(0, 0, #temp); |
806 | if (!EAX){ |
805 | if (!EAX){ |
807 | SelectFile(T_NEW_FILE); |
806 | SelectFile(T_NEW_FILE); |
808 | FnProcess(2); |
807 | FnProcess(2); |
809 | } |
808 | } |
810 | else |
809 | else |
811 | { |
810 | { |
812 | Write_Error(EAX); |
811 | Write_Error(EAX); |
813 | ShowMessage(NOT_CREATE_FILE); |
812 | ShowMessage(NOT_CREATE_FILE); |
814 | } |
813 | } |
815 | break; |
814 | break; |
816 | case 10: //F10 |
815 | case 10: //F10 |
817 | RunProgram(EDITOR_PATH, abspath("Eolite.ini")); |
816 | RunProgram(EDITOR_PATH, abspath("Eolite.ini")); |
818 | break; |
817 | break; |
819 | } |
818 | } |
820 | } |
819 | } |
821 | 820 | ||
822 | 821 | ||
823 | stop: |
822 | stop: |
824 | 823 | ||
825 | char about_stak[512]; |
824 | char about_stak[512]; |
826 | char menu_stak[512]; |
825 | char menu_stak[512]; |
827 | char copy_stak[4096];28)>>0)> |
826 | char copy_stak[4096];28)>>0)> |
828 | >=0)>=0)>480)>5;>6;>3;>480)>>8; |
827 | >=0)>=0)>480)>5;>6;>3;>480)>>8; |
829 | ><8; |
828 | ><8; |
830 | >0)>=Form.width-6)> |
829 | >0)>=Form.width-6)> |
831 | > |
830 | > |
832 | >=Form.width-6)>57) |
831 | >=Form.width-6)>57) |
833 | >=Form.width-6)>>> |
832 | >=Form.width-6)>>> |