diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 9ad2cf9ac4..88da320462 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -2,7 +2,6 @@ //GNU GPL licence. //копировать через поток -//иконка действительно нужна другая для неизвесных устройств и папок в будующем. //libraries #define MEMSIZE 0xA0000 @@ -14,79 +13,57 @@ #include "..\lib\file_system.h" #include "..\lib\figures.h" #include "..\lib\encoding.h" +#include "..\lib\list_box.h" +#include "..\lib\copyf.h" //images #include "imgs\toolbar.txt" #include "imgs\left_p.txt" -int BUTTON_HEIGHT=18; - //for OpenDir #define ONLY_SHOW 0 #define WITH_REDRAW 1 #define ONLY_OPEN 2 -//переменные -#define TITLE "Eolite File Manager v1.65" -#define ABOUT_TITLE "Eolite v1.65" +#define TITLE "Eolite File Manager v1.77" +#define ABOUT_TITLE "Eolite v1.77" dword col_work = 0xE4DFE1; dword col_border = 0x819FC5; dword col_padding = 0xC8C9C9; dword col_selec = 0x94AECE; dword col_lpanel = 0x00699C; +int toolbar_buttons_x[7]={9,46,85,134,167,203}; +char tmp_disk_del_param[3]="d0"; +struct path_string { char Item[4096]; }; -int f_visible, - count, - za_kadrom, - curbtn; - - -byte cut_active, - rename_active, - del_active; -byte show_actions=1, - show_dev_name=1, - sort_num=2, - isdir; -unsigned char +llist files; + +byte path[4096], - edit_path[4096], file_path[4096], file_name[256], copy_file[4096], - temp[4096]; -int scroll_size; - -struct path_string { -char Item[4096]; -}; - -int toolbar_buttons_x[7]={9,46,85,134,167,203}; -char tmp_disk_del_param[3]="d0"; - -dword file_mas[6898]; -int j, i, mouse_dd; -int scroll_used; + temp[4096]; +byte + cut_active, + rename_active, + del_active; +byte + show_dev_name=1, + sort_num=2, + isdir; proc_info Form; mouse m; -dword buf, off; //для текста и буфера +int mouse_dd, scroll_used, scroll_size; +dword buf, off; +dword file_mas[6898]; +int j, i; edit_box edit2= {250,213,80,0xFFFFCC,0x94AECE,0xFFFFCC,0xffffff,0,248,#file_name,#mouse_dd,64,6,6}; -PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #edit_path, 0}; +PathShow_data PathShow = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, #path, #temp, 0}; PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #temp, 0}; -inline fastcall signed int _strrchr( ESI,BL) -{ - int jj=0, last=strlen(ESI); - do{ - jj++; - $lodsb - IF(AL==BL) last=jj; - } while(AL!=0); - return last; -} - #include "include\some_code.h" #include "include\about_dialog.h" #include "include\sorting.h" @@ -94,52 +71,83 @@ inline fastcall signed int _strrchr( ESI,BL) #include "include\ini.h" #include "include\left_panel.h" #include "include\history.h" +#include "include\file_menu.h" void main() { - word key, id, can_show; - int min_win_h; + word key, id, can_show, can_select; + files.line_h=18; mem_Init(); if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj"); - GetSystemDiscs(); + SystemDiscsGet(); GetIni(1); if (param) { strcpy(#path, #param); - if (strcmp(#path+strlen(#path)-1,"/")<>0) strcat(#path, "/"); //если нет, + "/" + if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //add "/" to the end of the string } else strcpy(#path, "/rd/1/"); Open_Dir(#path,ONLY_OPEN); SetEventMask(0x27); - loop() switch(WaitEvent()) + loop() switch(WaitEvent()) { case evMouse: - IF (del_active) break; - + IF (del_active) break; id=GetProcessSlot(Form.ID); - IF (id<>GetActiveProcess()) break; //если окно не активно на события мыши не реагируем - - IF (rename_active) edit_box_mouse stdcall(#edit2); + IF (id<>GetActiveProcess()) || (Form.status_window>2) break; + IF (rename_active) { edit_box_mouse stdcall(#edit2); break; } m.get(); - /*if (m.pkm) && (m.x > 192) && (m.y > 57) can_show = 1; - if (!m.pkm) && (can_show) + if (m.x > files.x) && (m.x < files.x + files.w) && (m.y > files.y) && (m.y < files.y+files.h) { + if (m.lkm) can_select = 1; + if (m.pkm) + { + can_show = 1; + if (m.y - 57 / files.line_h != files.current) can_select = 1; + } + } + + //select/open file { + if (!m.lkm) && (!m.pkm) && (can_select) + { + can_select = 0; + if (m.y<57) break; + id = m.y - 57 / files.line_h; + if (files.current!=id) FileList_ReDraw(id-files.current); + else Open(); + }; + // } select/open file + + //file menu { + if (!m.pkm) && (!m.lkm) && (can_show) + { + can_show = 0; + if (m.y<57) break; SwitchToAnotherThread(); CreateThread(#FileMenu,#stak2); - can_show = 0; - }*/ + break; + } + // } file menu + + + if (m.vert) + { + files.MouseScroll(m.vert); + List_ReDraw(); + break; + } if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>40) && (m.y<57) { IF (m.lkm==1) DrawRectangle3D(onLeft(26,0),41,14,14,0xC7C7C7,0xFFFFFF); - WHILE (m.lkm==1) && (za_kadrom>0) + WHILE (m.lkm==1) && (files.first>0) { - pause(10); - za_kadrom--; + pause(8); + files.first--; List_ReDraw(); m.get(); } @@ -149,48 +157,29 @@ void main() if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>onTop(22,0)+1) && (m.y0) - { - if (za_kadrom>0) za_kadrom--; - if (curbtn0) za_kadrom--; - if (curbtn0) curbtn--; - List_ReDraw(); - if (za_kadrom0) curbtn--; - List_ReDraw(); - } - //скролл - if (!m.lkm) && (scroll_used) { scroll_used=NULL; TVScroll(); } - if (m.x>=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.y=Form.width-26) && (m.x<=Form.width-6) && (m.y>56) && (m.ym.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+57; //если курсор над окном - id=za_kadrom; //сохраняем старое количество + IF (scroll_size/2+57>m.y) || (m.y<0) || (m.y>4000) m.y=scroll_size/2+57; //anee eo?ni? iaa ieiii + id=files.first; j= scroll_size/2; - za_kadrom = m.y -j -57 * count; - za_kadrom /= onTop(22,57); - IF (f_visible+za_kadrom>count) za_kadrom=count-f_visible; - IF (id<>za_kadrom) List_ReDraw(); //чтоб лишний раз не перерисовывать + files.first = m.y -j -57 * files.count; + files.first /= onTop(22,57); + IF (files.visible+files.first>files.count) files.first=files.count-files.visible; + IF (id<>files.first) List_ReDraw(); } break; //Button pressed----------------------------------------------------------------------------- @@ -211,7 +200,7 @@ void main() case 22: //Forward if (HistoryPath(GO_FORWARD)) { - za_kadrom=curbtn=NULL; //вверх списка + files.first=files.current=NULL; //aaa?o nienea Open_Dir(#path,WITH_REDRAW); } break; @@ -230,49 +219,24 @@ void main() IF(sort_num==2) DrawFilledBar(onLeft(115,0),42,6,10); IF(sort_num==3) DrawFilledBar(onLeft(44,0),42,6,10); sort_num=id-30; - Open_Dir(#path,1); - break; - case 30: //about - SwitchToAnotherThread(); - CreateThread(#about_dialog,#stak1); - break; - case 77: - IF (show_actions==1) show_actions=0; ELSE show_actions=1; - DrawLeftPanel(); + Open_Dir(#path,WITH_REDRAW); break; case 78: //rescan devices Tip(56, "Devices", 78, "-"); pause(10); GetIni(1); - GetSystemDiscs(); + SystemDiscsGet(); Open_Dir(#path,WITH_REDRAW); DrawLeftPanel(); break; - case 80: //rename - goto REN_MARK; - case 81: //Delete file - Del_Form(); - break; - case 82: //create folder - NEW_FOLDER_MARK: - strcpy(#temp, #path); - strcat(#temp, "New folder"); - CreateDir(#temp); - IF (!EAX){ - SelectFile("New folder"); - goto REN_MARK; - } - ELSE - { - Write_Error(EAX); - ShowMessage("Folder can not be created."); - } + case 50...60: //Actions + ActionsProcess(id-50); break; case 100...120: DEVICE_MARK: - DrawRectangle3D(17,id-100*16+74,159,16, 0, 0); //выделение + DrawRectangle3D(17,id-100*16+74,159,16, 0, 0); //auaaeaiea strcpy(#path, #disk_list[id-100].Item); - za_kadrom=curbtn=0; + files.first=files.current=0; Open_Dir(#path,1); pause(5); DrawRectangle3D(17,id-100*16+74,159,16, 0xFFFFFF, 0xFFFFFF); @@ -281,30 +245,10 @@ void main() tmp_disk_del_param[1]=disk_list[id-130].Item[4]; RunProgram("/sys/tmpdisk", #tmp_disk_del_param); pause(10); - GetSystemDiscs(); + SystemDiscsGet(); Open_Dir(#path,WITH_REDRAW); DrawLeftPanel(); break; - default: - if (id<200) break; //кнопки из списка файлов - if (curbtn!=id-201) {FileList_ReDraw(id-201-curbtn); break;} - else - { - OPEN_MARK: - if (!isdir) - { - GetIni(0); - } - else - { - if (!strcmp(#file_name,"..")) { Dir_Up(); break; } - OPEN_DEV: - strcpy(#path, #file_path); - IF (strcmp(#path+strlen(#path)-1,"/")<>0) strcat(#path,"/"); //если нет, + "/" - za_kadrom=curbtn=0; - Open_Dir(#path,1); - } - } } break; //Key pressed----------------------------------------------------------------------------- @@ -329,24 +273,24 @@ void main() id=key-110; IF (id-100>=disc_num) break; GOTO DEVICE_MARK; - case 8: //Назад + case 008: //GoBack(); Dir_Up(); break; - case 004: //Ctrl+D рис на раб стол растянуть + case 004: //Ctrl+D set as bg strcpy(#temp, "\\S__"); strcat(#temp, #file_path); RunProgram("/sys/media/kiv", #temp); break; - case 014: //Ctrl+N новое окно + case 014: //Ctrl+N new window IF (Form.left==98) MoveSize(Form.left-20,Form.top-20,OLD,OLD); RunProgram("/sys/File Managers/Eolite", #path); break; case 024: //Ctrl+X case 003: //Ctrl+C CTRLC_MARK: - IF (isdir) break; //папки пока что копировать не умеем - strcpy(#copy_file, #file_path); //вычисляем какой файл копировать + IF (isdir) break; + strcpy(#copy_file, #file_path); IF (key==24) cut_active=1; ELSE cut_active=0; break; case 022: //Ctrl+V @@ -357,11 +301,8 @@ void main() break; case 013: //Enter IF (rename_active==1) {ReName(true); break;} - GOTO OPEN_MARK; + Open(); break; - case 55: //F6 - new folder - goto NEW_FOLDER_MARK; - case 56: //IF (rename_active==1) break;//up case 178: //up FileList_ReDraw(-1); break; @@ -369,52 +310,34 @@ void main() FileList_ReDraw(1); break; case 180: //home - za_kadrom=0; - curbtn=0; + files.first=0; + files.current=0; List_ReDraw(); break; case 181: //end - za_kadrom=count-f_visible; - curbtn=f_visible-1; + files.first=files.count-files.visible; + files.current=files.visible-1; List_ReDraw(); break; case 183: //Page Down - FileList_ReDraw(f_visible-1); + FileList_ReDraw(files.visible-1); break; case 184: //Page Up - FileList_ReDraw(-f_visible+1); + FileList_ReDraw(-files.visible+1); break; - case 051: //Нажата F2 - REN_MARK: - if (!count) break; - DeleteButton(curbtn+201); //это чтоб можно было выделять мышью - edit2.flags=66; //делаем компонент активным - edit2.width=onLeft(24,217); - edit2.top=curbtn*BUTTON_HEIGHT+59; - edit2.size=edit2.pos=strlen(#file_name); - edit_box_draw stdcall (#edit2); - DrawBar(213,curbtn*BUTTON_HEIGHT+58,edit2.width+1,1,0xFFFFCC); //полоса желтая сверху для одинаковости - rename_active=1; - break; - case 052: //Нажата F3 - IF (!isdir) RunProgram("/sys/tinypad", #file_path); - break; - case 053: //Нажата F4 - IF (!isdir) RunProgram("/sys/develop/heed", #file_path); - break; - case 054: //F5 - Open_Dir(#path,1); - break; - case 182: //delete file + case 182: //del Del_Form(); + break; + case 050...059: //F1-F10 + ActionsProcess(key-49); break; default: - for (i=curbtn+za_kadrom+1; i2) break; - min_win_h = disc_num*16+195; - if (Form.height < min_win_h) MoveSize(OLD,OLD,OLD,min_win_h); + files.SetSizes(192, 57, onLeft(192,27), onTop(57,6), disc_num*16+195,files.line_h); + if (Form.height < files.min_h) MoveSize(OLD,OLD,OLD,files.min_h); if (Form.width<480) MoveSize(OLD,OLD,480,OLD); draw_window(); } @@ -434,38 +357,35 @@ void main() inline fastcall void draw_window() { - //toolbar buttons + //toolbar PutPaletteImage(#toolbar,246,34,0,0,8,#toolbar_pal); for (j=0; j<3; j++) DefineButton(toolbar_buttons_x[j]+2,5+2,31-5,29-5,21+j+BT_HIDE,col_work); for (j=3; j<6; j++) DefineButton(toolbar_buttons_x[j],5,31,29,21+j+BT_HIDE,col_work); - //полоса адреса DrawBar(246,0,onLeft(246,60),12, col_work); //фон над полосой адреса - DrawBar(246,29,onLeft(246,60),5,col_work); //фон под полосой адреса - DrawRectangle3D(246,12,onLeft(66,246),16,col_border,col_border); //ободок - DefineButton(onLeft(34,0),6,27,28,30+BT_HIDE+BT_NOFRAME,col_work); //about + DrawBar(246,29,onLeft(246,60),5,col_work); //фон под полосой адреса + DrawRectangle3D(246,12,onLeft(66,246),16,col_border,col_border); + DefineButton(onLeft(34,0),6,27,28,51+BT_HIDE+BT_NOFRAME,col_work); //about PutPaletteImage(#goto_about,56,34,Form.width-65,0,8,#goto_about_pal); - //прямоугольники внутри - DrawRectangle3D(1,40,Form.cwidth-3,onTop(46,0),col_border,col_border); //синий ободок - DrawRectangle3D(0,39,Form.cwidth-1,onTop(44,0),col_palette[4],col_palette[4]); //фон + //main rectangles + DrawRectangle3D(1,40,Form.cwidth-3,onTop(46,0),col_border,col_border); + DrawRectangle3D(0,39,Form.cwidth-1,onTop(44,0),col_palette[4],col_palette[4]); //bg for (i=0; i<5; i++) DrawBar(0, 34+i, Form.cwidth, 1, col_palette[8-i]); DrawLeftPanel(); - //SortButtons - DrawFlatButton(192,40,onLeft(192,168),16,31,col_work,"File"); + //ListBox + DrawFlatButton(files.x,40,onLeft(files.x,168),16,31,col_work,"File"); DrawFlatButton(onLeft(168,0),40,73,16,32,col_work,"Type"); DrawFlatButton(onLeft(95,0),40,68,16,33,col_work,"Size"); - //Перерисовываем список + DrawBar(onLeft(27,0),57,1,onTop(22,57),col_border); //line to the left from the scroll + DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18"); + DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19"); Open_Dir(#path,ONLY_SHOW); - //прокрутка - DrawBar(onLeft(27,0),57,1,onTop(22,57),col_border); //линия слева от прокрутки - DrawFlatButton(onLeft(27,0),40,16,16,0,col_work,"\x18"); //прокрутка вверх - DrawFlatButton(onLeft(27,0),onTop(22,0),16,16,0,col_work,"\x19");//прокрутка вниз if (del_active) Del_Form(); - DefineButton(onLeft(34,0),6,27,28,30+BT_HIDE+BT_NOFRAME,col_work); //about } void KEdit() { + if (Form.width<480) return; PathShow.area_size_x = Form.cwidth-306; DrawBar(PathShow.start_x-3, PathShow.start_y-4, PathShow.area_size_x+2, 15, 0xFFFfff); PathShow_prepare stdcall(#PathShow); @@ -473,52 +393,52 @@ void KEdit() } -void FileList_ReDraw(int curbtn_) +void FileList_ReDraw(int cur) { - if (curbtn_<=0) //вверх + if (cur<=0) //up { - IF (za_kadrom==0) && (curbtn<=0) return; - IF (-curbtn_-1curbtn_) + IF (files.first==files.count-files.visible) && (files.current==files.visible-1) return; + IF (files.visible-files.current>cur) { - Line_ReDraw(0xFFFFFF, curbtn); //белая полоса - curbtn+=curbtn_; - Line_ReDraw(col_selec, curbtn); //выделение + Line_ReDraw(0xFFFFFF, files.current); + files.current+=cur; + Line_ReDraw(col_selec, files.current); return; } else { - IF(za_kadrom+curbtn+curbtn_>=count) + IF(files.first+files.current+cur>=files.count) { - za_kadrom=count-f_visible; - curbtn=curbtn_-za_kadrom+curbtn; + files.first=files.count-files.visible; + files.current=cur-files.first+files.current; } ELSE { - za_kadrom+=curbtn_+curbtn-f_visible+1; - curbtn=f_visible-1; + files.first+=cur+files.current-files.visible+1; + files.current=files.visible-1; } - IF (curbtn<0) || (curbtn>f_visible) + IF (files.current<0) || (files.current>files.visible) { - curbtn=f_visible-1; + files.current=files.visible-1; } List_ReDraw(); } @@ -530,67 +450,70 @@ void FileList_ReDraw(int curbtn_) void List_ReDraw() { - int paint_x=f_visible*BUTTON_HEIGHT+57; - IF (count-za_kadromf_visible-1) //если мы в конце списка файлов развернём окно появяться пустяе белые кнопки - { za_kadrom=count-f_visible; curbtn=f_visible-1; } //это если выделение после схлопывания окна за кадром + int paint_y; + //если мы в конце списка файлов развернём окно появяться пустяе белые кнопки + //это если выделение после схлопывания окна за кадром + if (files.count-files.firstfiles.visible-1) + { files.first=files.count-files.visible; files.current=files.visible-1; } - FOR (j=0; jj) Line_ReDraw(0xFFFFFF, j); ELSE Line_ReDraw(col_selec, curbtn); - DrawBar(192,paint_x,onLeft(27,192),onTop(paint_x,6),0xFFFFFF); //заливка белым доконца - DrawBar(onLeft(168,0),paint_x,1,onTop(paint_x,6),col_work); //полоса серая вертикальная 1 - DrawBar(onLeft(95,0),paint_x,1,onTop(paint_x,6),col_work); //полоса серая вертикальная 2 - TVScroll(); + for (j=0; jj) Line_ReDraw(0xFFFFFF, j); else Line_ReDraw(col_selec, files.current); + //in the bottom + paint_y = j * files.line_h + files.y; + DrawBar(files.x,paint_y,files.w,onTop(paint_y,6),0xFFFFFF); + DrawBar(onLeft(168,0),paint_y,1,onTop(paint_y,6),col_work); + DrawBar(onLeft(95,0),paint_y,1,onTop(paint_y,6),col_work); + Scroll(); } void Line_ReDraw(dword color, filenum){ - dword text_col=0, name_len=0, y=filenum*BUTTON_HEIGHT+57; //положение текста по Y + dword text_col=0, name_len=0, y=filenum*files.line_h+57; IF (rename_active==1) ReName(false); - DefineButton(192,y,onLeft(28,192),BUTTON_HEIGHT,201+filenum+BT_HIDE+BT_NOFRAME,color); //кнопа - //да, я не спорю что изврат, но зато перерисовки не видно - DrawBar(192,y,3,BUTTON_HEIGHT,color); - DrawBar(192+19,y,onLeft(46,192),BUTTON_HEIGHT,color); DrawBar(195,y+17,16,1,color); - if (BUTTON_HEIGHT>18) DrawBar(195,y+18,16,BUTTON_HEIGHT-18,color); - if (BUTTON_HEIGHT>15) DrawBar(195,y,16,BUTTON_HEIGHT-15,color); + DrawBar(192,y,3,files.line_h,color); + DrawBar(192+19,y,onLeft(46,192),files.line_h,color); DrawBar(195,y+17,16,1,color); + if (files.line_h>18) DrawBar(195,y+18,16,files.line_h-18,color); + if (files.line_h>15) DrawBar(195,y,16,files.line_h-15,color); - off=file_mas[filenum+za_kadrom]*304 + buf+72; + off=file_mas[filenum+files.first]*304 + buf+72; - if (!TestBit(ESDWORD[off-40], 4)) //это ФАЙЛ или папка? + if (!TestBit(ESDWORD[off-40], 4)) //file or folder? { strcpy(#temp, off); - Put_icon(#temp+_strrchr(#temp,'.'), BUTTON_HEIGHT/2-7+y, color); - WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),BUTTON_HEIGHT-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size + Put_icon(#temp+_strrchr(#temp,'.'), files.line_h/2-7+y, color); + WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),files.line_h-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size } else if (!strcmp("..",off)) - Put_icon("..", BUTTON_HEIGHT/2-7+y, color); + Put_icon("..", files.line_h/2-7+y, color); else - Put_icon("", BUTTON_HEIGHT/2-7+y, color); - - if (TestBit(ESDWORD[off-40],1)) || (TestBit(ESDWORD[off-40],2)) text_col=0xA6A6B7; //файл скрытый или системный? + Put_icon("", files.line_h/2-7+y, color); + if (TestBit(ESDWORD[off-40],1)) || (TestBit(ESDWORD[off-40],2)) text_col=0xA6A6B7; //system or hiden? if (color<>0xFFFfff) { isdir=TestBit(ESDWORD[off-40], 4); strcpy(#file_name, off); strcpy(#file_path, #path); - strcat(#file_path, #file_name); //полный путь к файлу + strcat(#file_path, #file_name); if (text_col==0xA6A6B7) text_col=0xFFFFFF; } - FileShow.font_color = text_col; - FileShow.area_size_x = Form.width - 380; - FileShow.text_pointer = off; - FileShow.start_y = BUTTON_HEIGHT/2-3+y; - PathShow_prepare stdcall(#FileShow); - PathShow_draw stdcall(#FileShow); - - DrawBar(onLeft(168,0),y,1,BUTTON_HEIGHT,col_work); //полоса серая вертикальная 1 - DrawBar(onLeft(95,0),y,1,BUTTON_HEIGHT,col_work); //полоса серая вертикальная 2 + if (Form.width>=480) + { + FileShow.font_color = text_col; + FileShow.area_size_x = Form.width - 380; + FileShow.text_pointer = off; + FileShow.start_y = files.line_h/2-3+y; + PathShow_prepare stdcall(#FileShow); + PathShow_draw stdcall(#FileShow); + } + DrawBar(onLeft(168,0),y,1,files.line_h,col_work); //gray line 1 + DrawBar(onLeft(95,0),y,1,files.line_h,col_work); //gray line 2 } void Open_Dir(dword temp_, redraw){ - int errornum, max_count; + int errornum, count; char path_[4096], somelen=strlen(temp_)-1; - + if (redraw<>ONLY_SHOW) { strcpy(#path_, temp_); @@ -599,37 +522,35 @@ void Open_Dir(dword temp_, redraw){ if (buf) free(buf); buf = malloc(32); errornum=ReadDir(0, buf, #path_); - if (errornum<>0) //ошибка при чтении папки + if (errornum<>0) { HistoryPath(ADD_NEW_PATH); GoBack(); Write_Error(errornum); return; } - count = ESDWORD[buf+8]; - buf = realloc(buf, count * 304 + 32); - ReadDir(count, buf, #path_); - count=EBX; - max_count = sizeof(file_mas)/sizeof(dword)-1; - if (count>max_count) count=max_count; + files.count = ESDWORD[buf+8]; + buf = realloc(buf, files.count * 304 + 32); + ReadDir(files.count, buf, #path_); + files.count=EBX; + count = sizeof(file_mas)/sizeof(dword)-1; + if (files.count>count) files.count=count; } - if (count<>-1) + if (files.count<>-1) { KEdit(); HistoryPath(ADD_NEW_PATH); - IF (!strcmp(".",buf+72)) {count--; memmov(buf,buf+304,count*304);} //фильтруем элемент "." - FOR (j=0;jONLY_SHOW) Sorting(); //для больших папок при репеинте окна + IF (redraw<>ONLY_SHOW) Sorting(); IF (redraw<>ONLY_OPEN) List_ReDraw(); } - IF (count==-1) && (redraw<>ONLY_OPEN) {f_visible=count=0; List_ReDraw();} + IF (files.count==-1) && (redraw<>ONLY_OPEN) {files.visible=files.count=0; List_ReDraw();} } @@ -638,31 +559,31 @@ inline Sorting() { dword k=0, l=1; int i; - if (!strcmp(#path,"/")) //не сортировать папки и не менять регистр в "/" + if (!strcmp(#path,"/")) //do not sort { - FOR(k=1;k=0; j--, off-=304;) //папки вверх, файлы вниз + FOR (j=files.count-1, off=files.count-1*304+buf+32; j>=0; j--, off-=304;) //files | folders { strttl(off+40); - if (TestBit(ESDWORD[off],4)) //папка? + if (TestBit(ESDWORD[off],4)) //isdir? { file_mas[k]=j; k++; } else { - file_mas[count-l]=j; + file_mas[files.count-l]=j; l++; } } - //Собственно сортировка: вначале папки, потом файлы + //sorting: files first, then folders Sort_by_Name(0,k-1); - IF (sort_num==1) Sort_by_Name(k,count-1); - IF (sort_num==2) Sort_by_Type(k,count-1); - IF (sort_num==3) Sort_by_Size(k,count-1); - //если папка ".." не первая, ставим её туда + IF (sort_num==1) Sort_by_Name(k,files.count-1); + IF (sort_num==2) Sort_by_Type(k,files.count-1); + IF (sort_num==3) Sort_by_Size(k,files.count-1); + //".." should be first IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")<>0) FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) file_mas[k]>0) && (file_name) IF (isdir) @@ -774,16 +693,16 @@ void ReName(byte rename) } SelectFile(#edit_name); } - Line_ReDraw(col_selec,curbtn); + Line_ReDraw(col_selec,files.current); } void SelectFile(dword that_file) { - za_kadrom=curbtn=0; //вверх списка + files.first=files.current=0; Open_Dir(#path,ONLY_OPEN); strttl(that_file); - for (i=count-1; i>=0; i--;) + for (i=files.count-1; i>=0; i--;) if (!strcmp(file_mas[i]*304+buf+72,that_file)) break; FileList_ReDraw(i); List_ReDraw(); @@ -802,15 +721,97 @@ void Dir_Up() SelectFile(#cur_folder); } +void Open() +{ + if (!isdir) + { + GetIni(0); + } + else + { + if (!strcmp(#file_name,"..")) { Dir_Up(); return; } + strcpy(#path, #file_path); + if (path[strlen(#path)-1]!='/') chrcat(#path, '/'); //need "/" in the end + files.first=files.current=0; + Open_Dir(#path,1); + } +} -inline fastcall void GoBack() //вначале удаляем текущий путь, а потом копируем то, что осталось + +inline fastcall void GoBack() { char cur_folder[4096]; strcpy(#cur_folder, GetCurrentFolder()); if (HistoryPath(GO_BACK)) SelectFile(#cur_folder); } +void ActionsProcess(char N) +{ + switch(N) + { + case 1: + SwitchToAnotherThread(); + CreateThread(#about_dialog,#stak1); + break; + case 2: + if (!files.count) break; + DeleteButton(files.current+201); + edit2.flags=100000000000010b; //set active + edit2.width=onLeft(24,217); + edit2.top=files.current*files.line_h+59; + edit2.size=edit2.pos=strlen(#file_name); + edit_box_draw stdcall (#edit2); + DrawBar(213,files.current*files.line_h+58,edit2.width+1,1,0xFFFFCC); //bg + rename_active=1; + break; + case 3: + IF (!isdir) RunProgram("/sys/tinypad", #file_path); + break; + case 4: + IF (!isdir) RunProgram("/sys/develop/heed", #file_path); + break; + case 5: + Open_Dir(#path,1); + break; + case 6: + strcpy(#temp, #path); + strcat(#temp, "New folder"); + CreateDir(#temp); + if (!EAX){ + SelectFile("New folder"); + ActionsProcess(2); + } + else + { + Write_Error(EAX); + ShowMessage("Folder can not be created."); + } + break; + case 7: + strcpy(#temp, #path); + strcat(#temp, "New file"); + WriteFile(0, 0, #temp); + if (!EAX){ + SelectFile("New file"); + ActionsProcess(2); + } + else + { + Write_Error(EAX); + ShowMessage("File can not be created."); + } + break; + case 10: //F10 + RunProgram(EDITOR_PATH, abspath("Eolite.ini")); + break; + } +} + +void copyf_Action() { + return; +} + stop: -char stak1[100]; -char stak2[100]; \ No newline at end of file +char stak1[512]; +char stak2[512]; \ No newline at end of file diff --git a/programs/cmm/eolite/imgs/actions.raw b/programs/cmm/eolite/imgs/actions.raw index 7b958bb240..fc32edb0db 100644 Binary files a/programs/cmm/eolite/imgs/actions.raw and b/programs/cmm/eolite/imgs/actions.raw differ diff --git a/programs/cmm/eolite/imgs/left_p.txt b/programs/cmm/eolite/imgs/left_p.txt index ddd99f3ff6..f35e5314c6 100644 --- a/programs/cmm/eolite/imgs/left_p.txt +++ b/programs/cmm/eolite/imgs/left_p.txt @@ -20,7 +20,7 @@ dword blue_hl_pal[]= {0x0001699C,0x0000699C,0x00026A9C,0x0002699C, unsigned char devices[14*78]= FROM "imgs\dev.raw"; -unsigned char factions[16*44] = FROM "imgs\actions.raw"; +unsigned char factions[14*39] = FROM "imgs\actions.raw"; unsigned char logo[7225] = FROM "imgs\logo8b.raw"; diff --git a/programs/cmm/eolite/imgs/png/actions.png b/programs/cmm/eolite/imgs/png/actions.png new file mode 100644 index 0000000000..d8c903ef1d Binary files /dev/null and b/programs/cmm/eolite/imgs/png/actions.png differ diff --git a/programs/cmm/eolite/imgs/png/file_actions.png b/programs/cmm/eolite/imgs/png/file_actions.png deleted file mode 100644 index d3c20f2421..0000000000 Binary files a/programs/cmm/eolite/imgs/png/file_actions.png and /dev/null differ diff --git a/programs/cmm/eolite/imgs/png/icons.png b/programs/cmm/eolite/imgs/png/icons.png index b0d42b1d91..296ddfdaca 100644 Binary files a/programs/cmm/eolite/imgs/png/icons.png and b/programs/cmm/eolite/imgs/png/icons.png differ diff --git a/programs/cmm/eolite/include/about_dialog.h b/programs/cmm/eolite/include/about_dialog.h index 28df23e9f4..8fb896ae90 100644 --- a/programs/cmm/eolite/include/about_dialog.h +++ b/programs/cmm/eolite/include/about_dialog.h @@ -14,7 +14,6 @@ void about_dialog() id=GetButtonID(); IF (id==1) || (id==10) ExitProcess(); IF (id==23) RunProgram(BROWSER_PATH, BROWSER_LINK); - IF (id==33) RunProgram(EDITOR_PATH, abspath("Eolite.ini")); break; case evKey: @@ -33,8 +32,6 @@ void about_dialog() WriteText(29,170,0x80,0,"Visit"); DrawLink(66,170,0x80,23, "kolibri-n.org"); DrawFlatButton(85,190,70,22,10,0xE4DFE1, "Close"); - DefineButton(20-1,195-1, 16+1,15+1, 33+BT_HIDE, 0); - PutPaletteImage(8*16*15+#ficons,16,15,20,195,8,#ficons_pal); DrawFilledBar(0, 216, 172, 12); } } \ No newline at end of file diff --git a/programs/cmm/eolite/include/file_menu.h b/programs/cmm/eolite/include/file_menu.h new file mode 100644 index 0000000000..54e779f345 --- /dev/null +++ b/programs/cmm/eolite/include/file_menu.h @@ -0,0 +1,66 @@ +//Leency 2008-2013 + +char *captions[] = { + "Open", "Enter", + "Open with...", "Ctrl+Ent", + "View as text", "F3", + "View as HEX", "F4", + "Rename", "F2", + "Delete", "Del", + 0}; + +void FileMenu() +{ + proc_info MenuForm; + word id, key, slot; + int ccount=0, linew=10, lineh=18, texty; + for (i=0; captions[i]!=0; i+=2) + { + ccount++; + if (strlen(captions[i])>linew) linew = strlen(captions[i]); + } + linew = linew + 3 * 6 + 70; + texty = lineh/2-4; + SetEventMask(100111b); + + goto _MENU_DRAW; + loop() switch(WaitEvent()) + { + case evMouse: + slot = GetProcessSlot(MenuForm.ID); + if (slot != GetActiveProcess()) ExitProcess(); + break; + + case evButton: + id=GetButtonID(); + if (id==100) Open(); + if (id==101) notify("Not compleated yet"); + if (id==102) ActionsProcess(3); + if (id==103) ActionsProcess(4); + if (id==104) ActionsProcess(2); + if (id==105) Del_Form(); + ExitProcess(); + break; + + case evKey: + IF (GetKey()==27) ExitProcess(); + break; + + case evReDraw: _MENU_DRAW: + DefineAndDrawWindow(m.x+Form.left+5,m.y+Form.top+GetSkinHeight(),linew+2,ccount*lineh+2,0x01,0xEEEeee,0x01fffFFF); + GetProcessInfo(#MenuForm, SelfInfo); + /* _PutImage(1,23, 16,44, #factions); //иконки */ + DrawRectangle(0,0,linew+1,ccount*lineh+1,col_border); + PutShadow(linew+2,1,1,ccount*lineh+1,0,1); + PutShadow(1,ccount*lineh+2,linew+1,1,0,1); + + for (i=0; captions[i*2]!=0; i++) + { + DefineButton(1,i*lineh,linew,lineh-1,i+100+BT_HIDE,0xFFFFFF); + DrawBar(1,i*lineh+1,1,lineh,0xFFFfff); + DrawBar(2,i*lineh+1,linew-1,lineh,col_work); + WriteText(6,i*lineh+texty+1,0x80,0x000000,captions[i*2]); + WriteText(-strlen(captions[i*2+1])*6-7+linew,i*lineh+texty+1,0x80,0x999999,captions[i*2+1]); + } + } +} \ No newline at end of file diff --git a/programs/cmm/eolite/include/ini.h b/programs/cmm/eolite/include/ini.h index 2b2c3bc851..f9f3a0cea7 100644 --- a/programs/cmm/eolite/include/ini.h +++ b/programs/cmm/eolite/include/ini.h @@ -6,25 +6,6 @@ #define PARAM 2 #define OPTION 3 -unsigned char *ERROR_TEXT[]={ -"Code #0 - No error", -"Error #1 - Base or partition of a hard disk is not defined", -"Error #2 - Function isn't supported for this file system", -"Error #3 - Unknown file system", -"Error #4 - Reserved, is never returned", -"Error #5 - File or folder not found", -"Error #6 - End of file, EOF", -"Error #7 - Pointer lies outside of application memory", -"Error #8 - Too less disk space", -"Error #9 - FAT table is destroyed", -"Error #10 - Access denied", -"Error #11 - Device error", -0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, -"Error #30 - Not enough memory", -"Error #31 - File is not executable", -"Error #32 - Too many processes", -0}; void GetIni(byte onload) { @@ -61,7 +42,7 @@ void GetIni(byte onload) case 0x0d: InfType=PARAM; IF (!strcmp(#parametr,"SelectionColor")) edit2.shift_color=col_selec=StrToCol(#option); - IF (!strcmp(#parametr,"LineHeight")) BUTTON_HEIGHT=atoi(#option); + IF (!strcmp(#parametr,"LineHeight")) files.line_h = atoi(#option); IF (!strcmp(#parametr,"ShowDeviceName")) show_dev_name=atoi(#option); /*if (!strcmp(#section,"UserDirectories")) && (parametr) && (onload) @@ -94,20 +75,9 @@ void GetIni(byte onload) void Write_Error(int error_number) { - char error[256]; - - if (error_number<0) error_number=-1*error_number; - - if (error_number<33) - strcpy(#error, ERROR_TEXT[error_number]); - else - { - strcpy(#error, itoa(error_number)); - strcat(#error, " - Unknown error number O_o"); - } - if (curbtn>=0) Line_ReDraw(0xFF0000, curbtn); + if (files.current>=0) Line_ReDraw(0xFF0000, files.current); pause(5); - notify(#error); + notify(get_error(error_number)); } diff --git a/programs/cmm/eolite/include/left_panel.h b/programs/cmm/eolite/include/left_panel.h index f64a345da1..0f4b9a1477 100644 --- a/programs/cmm/eolite/include/left_panel.h +++ b/programs/cmm/eolite/include/left_panel.h @@ -16,7 +16,7 @@ path_string disk_list[30]; int disc_num; dword devbuf; -void GetSystemDiscs() +void SystemDiscsGet() { unsigned char dev_name[10], sys_discs[10]; unsigned int i1, j1, dev_num, dev_disc_num; @@ -32,8 +32,8 @@ void GetSystemDiscs() strcat(#dev_name, i1*304+ devbuf+72); // /rd strcat(#dev_name, "/"); // /rd/ Open_Dir(#dev_name, ONLY_OPEN); - dev_disc_num = count; - //if (count<=0) copystr(#dev_name,#disk_list[disc_num].Item); else + dev_disc_num = files.count; + //if (files.count<=0) copystr(#dev_name,#disk_list[disc_num].Item); else for (j1=0; j1onTop(22,57)-on_y+56) || (za_kadrom+f_visible>=count) on_y=onTop(23+scroll_size,0); //для большого списка + if (scroll_size>onTop(22,57)-on_y+56) || (files.first+files.visible>=files.count) on_y=onTop(23+scroll_size,0); //для большого списка } DrawFlatButton(onLeft(27,0),on_y,16,scroll_size,0,-1,"");//ползунок if (!scroll_used) for (i=0; i<13; i++) DrawBar(onLeft(25-i,0), on_y+2, 1, scroll_size-3, col_palette[13-i]); if (scroll_used) for (i=0; i<13; i++) DrawBar(onLeft(25-i,0), on_y+2, 1, scroll_size-3, col_palette[i]); //поле до ползунка - if (on_y>58) DrawBar(onLeft(26,0),57,15,1, 0xC7C9C9); + if (on_y>58) DrawBar(onLeft(26,0),57,15,1, 0xC7C9C9); DrawBar(onLeft(26,0),58,1, on_y-58,0xC7C9C9); DrawBar(onLeft(25,0),58,14,on_y-58,0xCED0D0); //поле после ползунка diff --git a/programs/cmm/eolite/txt/History.txt b/programs/cmm/eolite/txt/History.txt index 4aaed15674..940ed0eaad 100644 --- a/programs/cmm/eolite/txt/History.txt +++ b/programs/cmm/eolite/txt/History.txt @@ -1,3 +1,11 @@ +01.05.13 -- v1.77 +- исправлено падение при изменении размера окна (нашёл 0CodErr); +- меню файлов (не закончено); +- перевод программы на элемент list_box: упрощение кода, гибкость элемента, + задел на двупанельность; +- вместо кнопок файлов теперь используются события мыши; +- очень много других исправлений и оптимизаций. + 03.03.13 -- v1.64 - перенос программы на общую библиотеку (очень хотел s1n). Это даёт доступ к множествам наработок основной ветви; diff --git a/programs/cmm/installer/installation.c b/programs/cmm/installer/installation.c index a6c687b3bb..e1b13c6d12 100644 --- a/programs/cmm/installer/installation.c +++ b/programs/cmm/installer/installation.c @@ -71,6 +71,14 @@ void Install() EndLoop(); } +void copyf_Action(dword filename) +{ + if (CheckEvent()==evReDraw) { DefineWindow("Installation Started", "Stop"); ShowProgress("Copying files..."); } + ShowProgress(NULL); + DrawBar(TEXTX, BLACK_H+50, Form.cwidth-TEXTX, 12, 0xFFFfff); + WriteText(TEXTX, BLACK_H+50, 0x80, 0, filename); +} + void EndLoop() { diff --git a/programs/cmm/installer/main.c b/programs/cmm/installer/main.c index aa3a8f476e..a432f0bdb5 100644 --- a/programs/cmm/installer/main.c +++ b/programs/cmm/installer/main.c @@ -6,6 +6,7 @@ #include "..\lib\file_system.h" #include "..\lib\mem.h" #include "..\lib\dll.h" +#include "..\lib\copyf.h" //*.obj libraries #include "..\lib\lib.obj\box_lib.h" #include "..\lib\lib.obj\libio_lib.h" @@ -47,7 +48,6 @@ int DefineWindow(dword wtitle, wbutton) return 1; } -#include "copyf.c" #include "tmp_add.c" #include "hallo.c"; #include "installation.c"; diff --git a/programs/cmm/installer/copyf.c b/programs/cmm/lib/copyf.h similarity index 81% rename from programs/cmm/installer/copyf.c rename to programs/cmm/lib/copyf.h index e3fc657739..2b216c9e28 100644 --- a/programs/cmm/installer/copyf.c +++ b/programs/cmm/lib/copyf.h @@ -75,10 +75,7 @@ void CopyFolder(dword from, to) strcpy(#copy_in, to); strcat(#copy_in, filename); - if (CheckEvent()==evReDraw) { DefineWindow("Installation Started", "Stop"); ShowProgress("Copying files..."); } - ShowProgress(NULL); - DrawBar(TEXTX, BLACK_H+50, Form.cwidth-TEXTX, 12, 0xFFFfff); - WriteText(TEXTX, BLACK_H+50, 0x80, 0, filename); + copyf_Action(filename); error = CopyFile(#copy_from, #copy_in); if (error) error = CopyFile(#copy_from, #copy_in); // #2 :) @@ -88,7 +85,6 @@ void CopyFolder(dword from, to) free(dirbuf); } - unsigned char *ERROR_TEXT[]={ "Code #0 - No error", "Error #1 - Base or partition of a hard disk is not defined", @@ -109,19 +105,24 @@ unsigned char *ERROR_TEXT[]={ "Error #32 - Too many processes", 0}; -void debug_error(int path, error_number) +dword get_error(int N) { char error[256]; - if (path) debug(path); - if (error_number<0) error_number*=-1; - if (error_number<33) + if (N<0) N*=-1; + if (N<33) { - strcpy(#error, ERROR_TEXT[error_number]); + strcpy(#error, ERROR_TEXT[N]); } else { - strcpy(#error, itoa(error_number)); + strcpy(#error, itoa(N)); strcat(#error, " - Unknown error number O_o"); } - debug(#error); + return #error; } + +void debug_error(dword path, error_number) +{ + if (path) debug(path); + debug(get_error(error_number)); +} \ No newline at end of file diff --git a/programs/cmm/lib/figures.h b/programs/cmm/lib/figures.h index ce29bcbe97..731f617476 100644 --- a/programs/cmm/lib/figures.h +++ b/programs/cmm/lib/figures.h @@ -101,9 +101,8 @@ void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text) proc_info wForm; dword shadow_buf, skin_height; shadow_buf = mem_Alloc(w*h*3); - //skin_height = GetSkinHeight(); GetProcessInfo(#wForm, SelfInfo); - CopyScreen(shadow_buf, x+wForm.left, y+wForm.top, w, h); + CopyScreen(shadow_buf, 5*border+x+wForm.left, GetSkinHeight()*border+y+wForm.top, w, h); ShadowImage(shadow_buf, w, h, strength); _PutImage(x,y,w,h,shadow_buf); mem_Free(shadow_buf); diff --git a/programs/cmm/lib/file_system.h b/programs/cmm/lib/file_system.h index aebcb195d4..e573c915ee 100644 --- a/programs/cmm/lib/file_system.h +++ b/programs/cmm/lib/file_system.h @@ -155,6 +155,7 @@ f70 read_dir_70; :int GetDir(dword dir_buf, file_count, path) { dword buf, fcount, error; + ESDWORD[file_count] = 0; buf = malloc(32); error = ReadDir(0, buf, path); if (!error) diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h index c5013e0b55..844b99dea9 100644 --- a/programs/cmm/lib/kolibri.h +++ b/programs/cmm/lib/kolibri.h @@ -65,6 +65,7 @@ void mouse::get() $and ebx,0x0000FFFF //hor = EAX; vert = EBX; + if (y>6000) y=0; } diff --git a/programs/cmm/rb/rb.c b/programs/cmm/rb/rb.c index e7919a16ce..5c83354e27 100644 --- a/programs/cmm/rb/rb.c +++ b/programs/cmm/rb/rb.c @@ -35,7 +35,7 @@ 0}; #endif -char stak[100]; +char stak[512]; #define ITEM_HEIGHT 18 int ITEM_WIDTH; @@ -82,9 +82,8 @@ void window() case evMouse: m.get(); - GetProcessInfo(#MenuForm, SelfInfo); id1=GetProcessSlot(MenuForm.ID); - if (id1<>GetActiveProcess()) ExitProcess(); + if (id1<>GetActiveProcess()) ExitProcess(); id1=m.y-1/ITEM_HEIGHT; if (m.y<0) || (id1+1>items_num) || (m.x<0) || (m.x>ITEM_WIDTH) break; if (m.lkm) || (m.pkm) @@ -130,6 +129,7 @@ void window() while (ITEMS_LIST[items_num*3]) items_num++; m.get(); DefineAndDrawWindow(m.x+1,m.y,ITEM_WIDTH+1,items_num*ITEM_HEIGHT+2,0x01,sc.work,0, 0x01fffFFF); + GetProcessInfo(#MenuForm, SelfInfo); DrawRectangle(0,0,ITEM_WIDTH,items_num*ITEM_HEIGHT+1,sc.work_graph); //ободок PutShadow(ITEM_WIDTH+1,1,1,items_num*ITEM_HEIGHT+1,0,1); PutShadow(1,items_num*ITEM_HEIGHT+2,ITEM_WIDTH+1,1,0,1);