Eolite 1.99: Just OpenWith. F*ck Yea.

git-svn-id: svn://kolibrios.org@4049 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-10-17 21:02:47 +00:00
parent 4c545a80b6
commit eedc7e81df
5 changed files with 161 additions and 81 deletions

View File

@ -6,7 +6,7 @@
#endif
//libraries
#define MEMSIZE 0xA0000
#define MEMSIZE 0xD0000
#include "..\lib\kolibri.h"
#include "..\lib\strings.h"
#include "..\lib\mem.h"
@ -38,6 +38,7 @@
?define T_PASTE_WINDOW "Š®¯¨àãî..."
?define T_PASTE_WINDOW_TEXT "Š®¯¨àã¥âáï ä ©«:"
?define T_CANCEL_PASTE "Š®¯¨à®¢ ­¨¥ ¯à¥ªà é¥­®. <20> ¯ª  ᪮¯¨à®¢ ­  ­¥ ¯®«­®áâìî."
?define T_SELECT_APP_TO_OPEN_WITH "‚ë¡¥à¨â¥ ¯à®£à ¬¬ã ¤«ï ®âªàëâ¨ï ä ©« "
#elif LANG_EST
?define T_FILE "Fail"
?define T_TYPE "Tüüp"
@ -55,6 +56,7 @@
?define T_PASTE_WINDOW "Kopeerin..."
?define T_PASTE_WINDOW_TEXT "Kopeerin faili:"
?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
#else
?define T_FILE "File"
?define T_TYPE "Type"
@ -72,12 +74,13 @@
?define T_PASTE_WINDOW "Copying..."
?define T_PASTE_WINDOW_TEXT "Copying file:"
?define T_CANCEL_PASTE "Copy process terminated. Folder copied incompletely."
?define T_SELECT_APP_TO_OPEN_WITH "Select application to open file"
#endif
enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir
#define TITLE "Eolite File Manager v1.98.8"
#define ABOUT_TITLE "Eolite v1.98.8"
#define TITLE "Eolite File Manager v1.99"
#define ABOUT_TITLE "Eolite v1.99"
dword col_work = 0xE4DFE1;
dword col_border = 0x9098B0; //A0A0B8; //0x819FC5;
dword col_padding = 0xC8C9C9;
@ -422,7 +425,6 @@ void menu_action(dword id)
if (id==100) Open();
if (id==201)
{
pause(10);
SwitchToAnotherThread();
CreateThread(#OpenWith,#open_with_stak);
}
@ -570,14 +572,14 @@ void Line_ReDraw(dword color, filenum){
if (! TestBit(attr, 4) ) //file or folder?
{
Put_icon(off+_strrchr(off,'.'), files.line_h/2-7+y, color);
Put_icon(off+_strrchr(off,'.'), files.x+3, 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("..", files.line_h/2-7+y, color);
Put_icon("..", files.x+3, files.line_h/2-7+y, color);
else
Put_icon("<DIR>", files.line_h/2-7+y, color);
Put_icon("<DIR>", files.x+3, files.line_h/2-7+y, color);
if ( TestBit(attr, 1) ) || ( TestBit(attr, 2) ) text_col=0xA6A6B7; //system or hiden?
if (color!=0xFFFfff)
{

View File

@ -30,14 +30,14 @@ char *ext[]={
#include "imgs\icons.txt"
void Put_icon(dword extension, yy, fairing_color)
void Put_icon(dword extension, xx, yy, fairing_color)
{
int icon_n=0, i;
for (i=0; ext[i]!=0; i+=2;) if (!strcmp(extension, ext[i])) { icon_n = ext[i+1]; break; }
ficons_pal[0] = fairing_color;
PutPaletteImage(icon_n*16*15+#ficons,16,15,files.x+3,yy,8,#ficons_pal);
if (fairing_color!=0xFFFfff) IconFairing(icon_n, files.x+3, yy, fairing_color);
PutPaletteImage(icon_n*16*15+#ficons,16,15,xx,yy,8,#ficons_pal);
if (fairing_color!=0xFFFfff) IconFairing(icon_n, xx, yy, fairing_color);
if (icon_n<>17) && (strlen(extension)<9) WriteText(-strlen(extension)*3+Form.cwidth-120,yy+4,0x80,0,extension);
}
@ -49,16 +49,16 @@ void IconFairing(dword filenum, x,y, color)
case 0...1: //file
case 3: //íàñòðîéêè
RIGHT_PAINT:
DrawBar(205,y,4,1,color);
DrawBar(206,y+1,3,1,color);
DrawBar(207,y+2,2,1,color);
PutPixel(208,y+3,color);
PutPixel(x+10,y,color);
PutPixel(x+11,y+1,color);
PutPixel(x+12,y+2,color);
PutPixel(x+13,y+3,color);
return;
case 2: //html
DrawBar(195,y,1,7,color);
DrawBar(196,y,1,6,color);
DrawBar(195,y+10,1,5,color);
DrawBar(196,y+11,1,4,color);
DrawBar(x,y,1,7,color);
DrawBar(x+1,y,1,6,color);
DrawBar(x,y+10,1,5,color);
DrawBar(x+1,y+11,1,4,color);
GOTO RIGHT_PAINT;
case 9: //inc
DrawBar(208,y,1,3,color);
@ -75,7 +75,7 @@ void IconFairing(dword filenum, x,y, color)
PutPixel(209,y+5,color);
return;
case 10: //font
DrawBar(196,y+1,1,13,color);
DrawBar(x+1,y+1,1,13,color);
DrawBar(197,y+1,1,11,color);
DrawBar(198,y+1,1,10,color);
DrawBar(199,y+1,1,9,color);
@ -104,42 +104,42 @@ void IconFairing(dword filenum, x,y, color)
PutPixel(210,y,color);
return;
case 16...17: //folder
DrawBar(195,y,1,15,color);
DrawBar(x,y,1,15,color);
DrawBar(203,y,8,2,color);
IF (filenum==17) PutPixel(206,y+1,0x1A7B17); //green arrow part
DrawBar(196,y+13,15,2,color);
PutPixel(196,y,color); //.òî÷êè
DrawBar(x+1,y+13,15,2,color);
PutPixel(x+1,y,color); //.òî÷êè
PutPixel(202,y,color);
PutPixel(210,y+2,color);
PutPixel(196,y+12,color);
PutPixel(x+1,y+12,color);
PutPixel(210,y+12,color);
return;
case 18: //êàðòðèäæ
DrawBar(195,y+11,1,2,color);
DrawBar(x,y+11,1,2,color);
DrawBar(210,y+11,1,2,color);
DrawBar(195,y+13,16,1,color);
DrawBar(x,y+13,16,1,color);
return;
case 24: //îáðàç
DrawBar(195,y,6,1,color);
DrawBar(195,y+1,4,1,color);
DrawBar(195,y+2,3,1,color);
DrawBar(195,y+3,2,2,color);
DrawBar(x,y,6,1,color);
DrawBar(x,y+1,4,1,color);
DrawBar(x,y+2,3,1,color);
DrawBar(x,y+3,2,2,color);
DrawBar(195,y+5,1,5,color);
DrawBar(x,y+5,1,5,color);
DrawBar(195,y+10,2,2,color);
DrawBar(195,y+12,3,1,color);
DrawBar(195,y+13,4,1,color);
DrawBar(195,y+14,6,1,color);
DrawBar(x,y+10,2,2,color);
DrawBar(x,y+12,3,1,color);
DrawBar(x,y+13,4,1,color);
DrawBar(x,y+14,6,1,color);
DrawBar(195+11,y,5,1,color);
DrawBar(195+13,y+1,3,1,color);
DrawBar(195+14,y+2,2,1,color);
DrawBar(195+15,y+3,1,2,color);
DrawBar(x+11,y,5,1,color);
DrawBar(x+13,y+1,3,1,color);
DrawBar(x+14,y+2,2,1,color);
DrawBar(x+15,y+3,1,2,color);
DrawBar(195+15,y+10,1,2,color);
DrawBar(195+14,y+12,2,1,color);
DrawBar(195+13,y+13,3,1,color);
DrawBar(195+11,y+14,5,1,color);
DrawBar(x+15,y+10,1,2,color);
DrawBar(x+14,y+12,2,1,color);
DrawBar(x+13,y+13,3,1,color);
DrawBar(x+11,y+14,5,1,color);
}
}

View File

@ -13,31 +13,20 @@ void GetIni(byte onload)
char bukva[2];
int errornum, tj;
static dword buff, fsize;
//÷èòàåì ôàéë
if (onload==1)
{
free(buff);
if (!GetFile(#buff, #fsize, abspath("Eolite.ini"))) notify("Eolite.ini not found. Defaults will be used.");
}
//ïàðñèì åãî
for (tj=0; tj<fsize; tj++;)
{
bukva = ESBYTE[buff+tj];
switch (bukva)
{
case ';':
InfType=COMMENT;
break;
case '[':
InfType=SECTION;
section=NULL;
break;
case ']':
InfType=PARAM;
break;
case '=':
InfType=OPTION;
break;
case ';': InfType=COMMENT; break;
case '[': InfType=SECTION; section=NULL; break;
case ']': InfType=PARAM; break;
case '=': InfType=OPTION; break;
case 0x0a:
case 0x0d:
InfType=PARAM;
@ -45,16 +34,10 @@ void GetIni(byte onload)
IF (!strcmp(#parametr,"LineHeight")) files.line_h = atoi(#option);
IF (!strcmp(#parametr,"ShowDeviceName")) show_dev_name=atoi(#option);
/*if (!strcmp(#section,"UserDirectories")) && (parametr) && (onload)
{
copystr(#parametr, #disk_list[disc_num].Item);
disc_num++;
}*/
IF (parametr) && (!strcmp(#file_name+strrchr(#file_name,'.'),#parametr)) && (!onload)
{
errornum=RunProgram(#option,#file_path);
IF (errornum<0) Write_Error(errornum); //åñëè îøèáî÷êà âûøëà ïðè çàïóñêå
IF (errornum<0) Write_Error(errornum);
return;
}
parametr=option=NULL;
@ -68,7 +51,8 @@ void GetIni(byte onload)
if (file_path) && (!onload)
{
errornum=RunProgram(#file_path,NULL);
if (errornum<0) Write_Error(errornum); //åñëè îøèáî÷êà âûøëà ïðè çàïóñêå
if (errornum==-31) menu_action(201); else if (errornum<0) Write_Error(errornum);
return;
}
}

View File

@ -1,17 +1,75 @@
//Leency 2013
llist app_list;
struct app_list_string { char item[1024]; char icon; };
app_list_string app_paths[100];
int GetListOfPrograms()
{
byte section[32], parametr[32], option[256], InfType=0;
char bukva[2];
int tj, ti;
static dword buff, fsize;
debug("GetListOfPrograms()");
free(buff);
if (!GetFile(#buff, #fsize, abspath("Eolite.ini")))
{
notify("Eolite.ini not found. Don't know any programm.");
return -1;
}
for (tj=0; tj<fsize; tj++;)
{
bukva = ESBYTE[buff+tj];
switch (bukva)
{
case ';': InfType=COMMENT; break;
case '[': InfType=SECTION; section=NULL; break;
case ']': InfType=PARAM; break;
case '=': InfType=OPTION; break;
case 0x0a:
case 0x0d:
InfType=PARAM;
if (!strcmp(#section,"Associations")) && (option)
{
for (ti=0; ti<app_list.count; ti++) //do not add duplications
{
if (strcmp(#app_paths[ti].item, #option)==0) GOTO _OUT;
}
// for (i=0; ext[i]!=0; i+=2;) if (!strcmp(extension, ext[i])) { icon_n = ext[i+1]; break; }
strcpy(#app_paths[app_list.count].item, #option);
app_list.count++;
}
_OUT:
parametr=option=NULL;
break;
default:
IF (InfType==SECTION) chrcat(#section, bukva);
IF (InfType==PARAM) chrcat(#parametr, bukva);
IF (InfType==OPTION) chrcat(#option, bukva);
}
}
}
void OpenWith()
{
?define OPEN_LIST_W 300
?define OPEN_LIST_H 300
#define WIN_W 290
#define OPEN_LIST_VISIBLE_N 12
#define OPEN_LIST_LINE_H 20
#define PANEL_H 40
#define PADDING 8;
int WIN_H;
mouse mm;
word key, slot, index, start_y;
llist app_list;
word key, slot;
proc_info MenuForm;
int texty, newi;
app_list.ClearList();
app_list.SetSizes(files.w-OPEN_LIST_W/2+files.x+Form.left+4,files.h-OPEN_LIST_H/2+files.y+Form.top+GetSkinHeight(),OPEN_LIST_W,OPEN_LIST_H,150,18);
app_list.SetSizes(PADDING,PANEL_H+1,WIN_W-PADDING-PADDING,OPEN_LIST_VISIBLE_N*OPEN_LIST_LINE_H,150,OPEN_LIST_LINE_H);
if (!app_list.count) if (GetListOfPrograms()==-1) return;
SetEventMask(100111b);
goto _APP_LIST_DRAW;
@ -21,23 +79,59 @@ void OpenWith()
slot = GetProcessSlot(MenuForm.ID);
if (slot != GetActiveProcess()) ExitProcess();
mm.get();
if (mm.lkm) ExitProcess();
//if (mm.lkm) ExitProcess();
if (mm.vert)
{
app_list.MouseScroll(mm.vert);
DrawAppList();
}
if (mm.x>app_list.x) && (mm.x<app_list.x+app_list.w) && (mm.y>app_list.y) && (mm.y<app_list.y+app_list.h)
{
app_list.current_temp = mm.y - app_list.y / app_list.line_h + app_list.first;
if (app_list.current_temp != app_list.current)
{
app_list.current = app_list.current_temp;
DrawAppList();
}
}
break;
case evKey:
key = GetKey();
if (key==27) ExitProcess();
break;
case evButton:
RunProgram(#app_paths[GetButtonID()-10].item, #file_path);
ExitProcess();
break;
case evReDraw: _APP_LIST_DRAW:
DefineAndDrawWindow(app_list.x, app_list.y,app_list.w+3,app_list.h+6,0x01, 0, 0, 0x01fffFFF);
WIN_H = app_list.h+PANEL_H+PADDING+2;
DefineAndDrawWindow(files.w-WIN_W/2+files.x+Form.left+6,
files.h-WIN_H/2+files.y+Form.top+GetSkinHeight(),WIN_W+1,WIN_H,0x01, 0, 0, 0x01fffFFF);
GetProcessInfo(#MenuForm, SelfInfo);
DrawPopup(0,0,app_list.w,app_list.h,0, col_work,col_border);
WriteText(10,10, 0x80, 0, "Select application to open file"w);
WriteText(10,23, 0x80, 0, #file_name);
WriteTextB(app_list.w/2-25,app_list.h/2, 0x90, 0, "S O O N");
DrawPopup(0,0,MenuForm.width-2,MenuForm.height-2,0, col_work, col_border);
DrawRectangle(app_list.x-1, app_list.y-2, app_list.w+1, app_list.h+2, col_border);
_APP_LIST_ITEMS_DRAW:
break;
Put_icon(#file_name+_strrchr(#file_name,'.'), 10, 13, col_work);
WriteText(35,10, 0x80, 0, T_SELECT_APP_TO_OPEN_WITH);
WriteText(35,23, 0x80, 0, #file_name);
DrawAppList();
}
}
void DrawAppList()
{
dword index, col_bg;
for (index = 0; (index<app_list.visible) && (index+app_list.first<app_list.count); index++)
{
DefineButton(app_list.x, index*app_list.line_h+app_list.y, app_list.w, app_list.line_h-1, index+app_list.first+10+BT_HIDE+BT_NOFRAME, 0);
if (index+app_list.first==app_list.current) col_bg = col_selec; else col_bg = 0xFFFfff;
DrawBar(app_list.x, index*app_list.line_h+app_list.y, app_list.w, app_list.line_h, col_bg);
Put_icon("kex", app_list.x+4, index*app_list.line_h+app_list.y+2, col_bg);
WriteText(app_list.x+23, index*app_list.line_h+app_list.y+7, 0x80, 0, #app_paths[index+app_list.first].item);
}
}

View File

@ -2,9 +2,9 @@
struct llist
{
int x, y, w, h, min_h;
int line_h;
int x, y, w, h, min_h, line_h;
int count, visible, first, current;
int current_temp;
void ClearList();
void SetSizes(int xx, yy, ww, hh, min_hh, line_hh);
int MouseScroll(dword scroll_state);