update font.h from PavelJakovlev, Eolite 3.1, restore encoding.h

git-svn-id: svn://kolibrios.org@5753 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2015-08-20 15:04:18 +00:00
parent 6830167e8a
commit 9873529078
6 changed files with 342 additions and 122 deletions

View File

@ -35,6 +35,7 @@ struct path_string { char Item[4096]; };
byte active_about=0;
word about_window;
word settings_window;
byte active_settings=0;
dword _not_draw = false;
byte menu_call_mouse=0;
@ -74,8 +75,7 @@ int rand_n;
byte CMD_REFRESH;
//struct t_settings {
byte font_size=9,
sort_num=2,
byte sort_num=2,
show_dev_name=true,
real_files_names_case=false,
info_after_copy=false,
@ -128,6 +128,8 @@ void main()
Open_Dir(#path,ONLY_OPEN);
strcpy(#inactive_path, #path);
llist_copy(#files_inactive, #files);
font.no_bg_copy = true;
font.load("/sys/font/Tahoma.kf");
SetEventMask(1100111b);
loop(){
switch(WaitEvent())
@ -686,7 +688,7 @@ void Line_ReDraw(dword color, filenum){
if (text_col==0xA6A6B7) text_col=0xFFFFFF;
}
if (file.selected) text_col=0xFF0000;
if (font_size==9) || (!font.data)
if (font.size.text==9) || (!font.data)
{
if (Form.width>=480)
{
@ -702,7 +704,7 @@ void Line_ReDraw(dword color, filenum){
else
{
font.bg_color = color;
font.text(files.x + 23, files.line_h - font.height / 2 - 1 + y, file_name_off, 0, font_size);
font.text(files.x + 23, files.line_h - font.height / 2 - 1 + y, file_name_off);
}
DrawBar(files.x+files.w-141,y,1,files.line_h,system.color.work); //gray line 1
DrawBar(files.x+files.w-68,y,1,files.line_h,system.color.work); //gray line 2
@ -1118,7 +1120,7 @@ void FnProcess(byte N)
CreateThread(#properties_dialog, properties_stak+8092);
break;
case 10: //F10
if (!settings_window)
if (!active_settings)
{
settings_stak = malloc(4096);
settings_window = CreateThread(#settings_dialog, settings_stak+4092);

View File

@ -115,7 +115,7 @@ void GetSystemDiscs()
void DrawSystemDiscs()
{
char dev_name[15], disc_name[100], i, dev_icon, is_active;
char dev_name[15], disc_name[100], i, dev_icon, is_active, name_len;
int pos_y, pos_x=2;
for (i=disc_num; i<30; i++) DeleteButton(100+i);
@ -185,11 +185,12 @@ void DrawSystemDiscs()
else
{
pos_y = 43;
DrawBar(pos_x, pos_y, strlen(#dev_name)*6 + 29, 17, 0xFFFFFF);
DefineButton(pos_x+2, pos_y, strlen(#dev_name)*6 + 25, 16, 100+i+BT_HIDE,0xFFFFFF);
name_len = strlen(#dev_name)-1*8;
DrawBar(pos_x, pos_y, name_len + 31, 17, 0xFFFFFF);
DefineButton(pos_x+2, pos_y, name_len + 27, 16, 100+i+BT_HIDE,0xFFFFFF);
_PutImage(pos_x + 5, pos_y, 18,17, is_active*6+dev_icon*17*18*3+#devices);
WriteText(pos_x + 24, pos_y+5, 0x80, 0, #dev_name);
pos_x += strlen(#dev_name)*6 + 29;
WriteText(pos_x + 24, pos_y+1, 10110000b, 0, #dev_name+1);
pos_x += name_len + 31;
}
}
if (two_panels)

View File

@ -47,8 +47,8 @@ void settings_dialog()
else if (id==26) && (files.line_h>18) files.line_h--;
else if (id==27) MOUSE_TIME++;
else if (id==28) && (MOUSE_TIME>29) MOUSE_TIME--;
else if (id==30) && (font_size<22) { font_size++; BigFontsChange(); }
else if (id==31) && (font_size>9) { font_size--; BigFontsChange(); }
else if (id==30) && (font.size.text<22) { font.size.text++; BigFontsChange(); }
else if (id==31) && (font.size.text>9) { font.size.text--; BigFontsChange(); }
SaveIniSettings();
EventRedrawWindow(Form.left,Form.top);
DrawSettingsCheckBoxes();
@ -69,6 +69,7 @@ void settings_dialog()
void ExitSettings()
{
active_settings=0;
settings_window = 0;
cmd_free = 4;
SaveIniSettings();
@ -83,7 +84,7 @@ void DrawSettingsCheckBoxes()
CheckBox2(10, 77, 24, USE_TWO_PANELS, two_panels);
MoreLessBox(10, 103, 18, 27, 28, #system.color, MOUSE_TIME, T_DOUBLE_CLICK);
MoreLessBox(10, 130, 18, 25, 26, #system.color, files.line_h, LIST_LINE_HEIGHT);
if (font.data) MoreLessBox(10, 157, 18, 30, 31, #system.color, font_size, FONT_SIZE_LABEL);
if (font.data) MoreLessBox(10, 157, 18, 30, 31, #system.color, font.size.text, FONT_SIZE_LABEL);
}
@ -93,7 +94,7 @@ void LoadIniSettings()
ini_get_int stdcall (eolite_ini_path, #config_section, "ShowDeviceName", 1); show_dev_name = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "RealFileNamesCase", 0); real_files_names_case = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "InfoAfterCopy", 0); info_after_copy = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "FontSize", 9); font_size = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "FontSize", 9); font.size.text = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "TwoPanels", 0); two_panels = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "LineHeight", 18); files.line_h = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "TimeDoubleClick", 50); MOUSE_TIME = EAX;
@ -102,8 +103,6 @@ void LoadIniSettings()
ini_get_int stdcall (eolite_ini_path, #config_section, "WinW", 550); WinW = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "WinH", 500); WinH = EAX;
BigFontsChange();
font.no_bg_copy = true;
font.load("/sys/font/Tahoma.kf");
}
@ -112,7 +111,7 @@ void SaveIniSettings()
ini_set_int stdcall (eolite_ini_path, #config_section, "ShowDeviceName", show_dev_name);
ini_set_int stdcall (eolite_ini_path, #config_section, "RealFileNamesCase", real_files_names_case);
ini_set_int stdcall (eolite_ini_path, #config_section, "InfoAfterCopy", info_after_copy);
ini_set_int stdcall (eolite_ini_path, #config_section, "FontSize", font_size);
ini_set_int stdcall (eolite_ini_path, #config_section, "FontSize", font.size.text);
ini_set_int stdcall (eolite_ini_path, #config_section, "TwoPanels", two_panels);
ini_set_int stdcall (eolite_ini_path, #config_section, "LineHeight", files.line_h);
ini_set_int stdcall (eolite_ini_path, #config_section, "TimeDoubleClick", MOUSE_TIME);

View File

@ -1,5 +1,5 @@
#define TITLE "Eolite File Manager v3.08"
#define ABOUT_TITLE "Eolite 3.08"
#define TITLE "Eolite File Manager v3.1"
#define ABOUT_TITLE "Eolite 3.1"
#ifdef LANG_RUS
?define T_FILE "” ©«"

175
programs/cmm/lib/encoding.h Normal file
View File

@ -0,0 +1,175 @@
#ifndef INCLUDE_ENCODING_H
#define INCLUDE_ENCODING_H
#print "[include <encoding.h>]\n"
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
inline fastcall void wintodos( ESI)
{
while (BL=ESBYTE[ESI])
{
if (BL>=192)
{
if (BL>=240) ESBYTE[ESI] = BL - 16;
else ESBYTE[ESI] = BL - 64;
}
else
{
if (BL==178) ESBYTE[ESI] = 73; //I
if (BL==179) ESBYTE[ESI] = 105; //i
if (BL==175) ESBYTE[ESI] = 244; //J
if (BL==191) ESBYTE[ESI] = 245; //j
if (BL==170) ESBYTE[ESI] = 242; //E
if (BL==186) ESBYTE[ESI] = 243; //e
if (BL==168) ESBYTE[ESI] = 240; //ð
if (BL==184) ESBYTE[ESI] = 'e'; //e
if (BL==180) ESBYTE[ESI] = 254; //ã
if ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34;
if ((BL==150) || (BL==151)) ESBYTE[ESI] = 45;
}
ESI++;
}
}
byte mas[66] = "椥ä£å¨©ª«¬­®¯ïàáâ㦢ìë§èíéçꞀ<EFBFBD>„…”ƒ•ˆ‰ŠŒ<EFBFBD>Ž<EFBFBD>Ÿ<EFBFBD>“†œ˜<EFBFBD>™—š";
inline fastcall void koitodos( EDI)
{
while (BL=ESBYTE[EDI])
{
if (BL >= 0xC0)
{
BL -= 0xC0;
ESBYTE[EDI] = mas[BL];
}
//if (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i';
EDI++;
}
}
//Asper, lev
//uncomplete
inline fastcall void utf8rutodos( ESI)
{
EDI=ESI;
while (BL=ESBYTE[ESI])
{
if (BL == 0xD0) || (BL == 0xD1) EDI--;
else if (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //ø
else if (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //ì
//0xE2 0x80 - ñãðóïïèðîâàòü
else if (BL == 0xE2) && (ESBYTE[ESI+1]==0x80)
switch (ESBYTE[ESI+2])
{
case 0x93: //long defis
case 0x94:
{
ESBYTE[EDI] = '-';
ESI+=2;
break;
}
case 0xA2: //central point
{
ESBYTE[EDI] = '*';
ESI+=2;
break;
}
case 0xA6: //ìíîãîòî÷èå
{
ESBYTE[EDI] = ESBYTE[EDI+1] = ESBYTE[EDI+2] = '.';
EDI+=2;
ESI+=2;
break;
}
}
else if (BL == 0xC2) //òàáëèöó ïåðåêîäèðîâîê?
switch(ESBYTE[ESI+1]) {
case 0xAB: //"
case 0xBB: //"
{
ESBYTE[EDI] = '\"';
ESI++;
break;
}
case 0xB7: // _
{
ESBYTE[EDI] = '_';
ESI++;
break;
}
case 0xA0: // Alt+160 - íåðàçáèâàþùèé ïðîáåë
{
ESBYTE[EDI] = ' ';
ESI++;
break;
}
case 0xB0: // ãðàäóñ
{
ESBYTE[EDI] = '\29';
ESI++;
break;
}
case 0xA9: // (c) --- âûëåò Î_î
{
ESBYTE[EDI] = 'c';
ESI++;
break;
}
case 0xAE: // (r)
{
ESBYTE[EDI] = 'r';
ESI++;
break;
}
}
else if (BL >= 0x90) && (BL <= 0xAF)
{
BL -= 0x10;
ESBYTE[EDI] = BL;
}
else if (BL >= 0x80) && (BL <= 0x8F)
{
BL += 0x60;
ESBYTE[EDI] = BL;
}
else if (BL >= 0xB0) && (BL <= 0xBF)
{
BL -= 0x10;
ESBYTE[EDI] = BL;
}
else ESBYTE[EDI] = BL;
ESI++;
EDI++;
}
while (EDI<ESI)
{
ESBYTE[EDI] = ' ';
EDI++;
}
}
//------------------------------------------------------------------------------
:dword Hex2Symb(char* htmlcolor)
{
dword j=0, symbol=0;
char ch=0x00;
for (;j<2;j++)
{
ch=ESBYTE[htmlcolor+j];
if (ch==0x0d) || (ch=='\9') RETURN 0;
if ((ch>='0') && (ch<='9')) ch -= '0';
if ((ch>='A') && (ch<='F')) ch -= 'A'-10;
if ((ch>='a') && (ch<='f')) ch -= 'a'-10;
symbol = symbol*0x10 + ch;
}
wintodos(#symbol);
AL=symbol;
}
#endif

View File

@ -9,10 +9,17 @@
#include "../lib/io.h"
#endif
:struct __SIZE
{
word width,height;
signed offset_x,offset_y;
byte text;
};
:struct FONT
{
byte width,height,offsetLine,r,g,b;
word width_buffer;
__SIZE size;
byte width,height,offsetLine,r,g,b,weight;
dword color;
dword file_size;
dword buffer;
dword buffer_size;
@ -23,10 +30,10 @@
byte load(...);
byte symbol(word x;byte s;dword c);
byte symbol_size(byte s);
dword text(word x,y;dword text1,c;byte size);
dword text_width(dword text1;byte size);
dword textarea(word x,y;dword text,c;byte size);
byte changeSIZE(byte size);
dword text(word x,y;dword text1,c);
dword getsize(dword text1);
dword textarea(word x,y;dword text,c);
byte changeSIZE();
void PixelRGB(word x,y);
dword tmp_y,tmp_height,tmp_x;
byte no_bg_copy;
@ -37,7 +44,7 @@ FONT font = 0;
:void FONT::PixelRGB(dword x,y)
{
dword tmp;
tmp = y*width_buffer*3;
tmp = y*size.width*3;
tmp += x*3;
tmp += buffer;
@ -47,14 +54,14 @@ FONT font = 0;
tmp++;
DSBYTE[tmp] = b;
}
:byte FONT::changeSIZE(byte size)
:byte FONT::changeSIZE()
{
dword TMP_DATA;
dword ofs;
byte s;
IF(size<9) size = 8;
IF(size>45)size = 45;
s = size-8;
IF(size.text<9) size.text = 8;
IF(size.text>45)size.text = 45;
s = size.text-8;
data = begin;
TMP_DATA = data;
TMP_DATA +=s*4;
@ -74,16 +81,23 @@ FONT font = 0;
}
:proc_info Form_SELF_FONTS;
:dword FONT::text_width(dword text1;byte size)
:dword FONT::getsize(dword text1)
{
dword len=0;
IF(size)IF(!changeSIZE(size))return 0;
size.height = size.width = 0;
size.offset_x = size.offset_y = -1;
IF(size.text)IF(!changeSIZE())return 0;
WHILE(DSBYTE[text1])
{
len += symbol_size(DSBYTE[text1]);
symbol_size(DSBYTE[text1]);
text1++;
}
return len;
$neg size.offset_y
$neg size.offset_x
size.height++;
size.height += size.offset_y;
size.width += size.offset_x;
size.width++;
return size.width;
}
:byte FONT::symbol_size(byte s)
{
@ -91,94 +105,19 @@ FONT font = 0;
dword tmp,_;
dword iii;
byte rw=0;
IF(s==32)return width/4;
IF(s==9)return width;
yi = 0;
iii = 0;
tmp = 4*block*s;
tmp +=data;
WHILE(yi<height)
{
xi = 0;
WHILE(xi<width)
{
IF(iii%32) _ >>= 1;
ELSE
{
tmp += 4;
_ = DSDWORD[tmp];
}
IF(_&1) IF(xi>rw)rw=xi;
xi++;
iii++;
}
yi++;
}
return rw;
}
:dword FONT::text(word x,y;dword text1,c;byte size)
{
signed len=0;
IF(size)IF(!changeSIZE(size))return 0;
GetProcessInfo(#Form_SELF_FONTS, SelfInfo);
IF(y>Form_SELF_FONTS.cheight) return 0;
IF(x>Form_SELF_FONTS.cwidth) return 0;
tmp_y = y;
AX = c;
r = AL;
g = AH;
c>>=16;
AX = c;
b = AL;
width_buffer = text_width(text1,size);
//width_buffer *= strlen(text1);
IF(!buffer_size)
{
buffer_size = width_buffer*height*3;
buffer = malloc(buffer_size);
}
ELSE IF(buffer_size<width_buffer*height*3)
{
buffer_size = width_buffer*height*3;
buffer = realloc(buffer,buffer_size);
}
IF (no_bg_copy)
{
EBX = bg_color;
EAX = buffer_size+buffer;
EDI = buffer;
WHILE (EDI<EAX)
byte X;
IF(s==32)
{
ESDWORD[EDI] = EBX;
$add edi,3
size.width += width/4;
IF(weight) size.width++;
return;
}
IF(s==9)
{
size.width += width;
IF(weight) size.width++;
return;
}
}
ELSE CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),width_buffer,height);
//width_buffer = text_width(text1);
WHILE(DSBYTE[text1])
{
symbol(len,DSBYTE[text1],c);
len+=EAX;
text1++;
}
_PutImage(x,y,width_buffer,height,buffer);
return len;
}
:dword FONT::textarea(word x,y;dword text1,c;byte size)
{
}
:byte FONT::symbol(signed x;byte s;dword c)
{
dword xi,yi;
dword tmp,_;
dword iii;
dword ___x;
byte rw=0;
x -= 2;
IF(s==32)return width/4;
IF(s==9)return width;
yi = 0;
iii = 0;
tmp = 4*block*s;
@ -187,6 +126,106 @@ FONT font = 0;
{
xi = 0;
WHILE(xi<width)
{
IF(iii%32) _ >>= 1;
ELSE
{
tmp += 4;
_ = DSDWORD[tmp];
}
IF(_&1)
{
IF(xi>rw)rw=xi;
IF(size.height<yi)size.height = yi;
IF(size.offset_y<0)size.offset_y = yi;
ELSE IF(yi<size.offset_y)size.offset_y = yi;
IF(!X) X = xi;
ELSE IF(X>xi)X = xi;
}
xi++;
iii++;
}
yi++;
}
size.width += rw;
IF(weight) size.width++;
IF(s=='_') size.width--;
IF(size.offset_x<0)size.offset_x = X;
}
:dword FONT::text(word x,y;dword text1)
{
signed len=0;
dword c;
word _tmp_h;
c = color;
IF(size.text)IF(!changeSIZE())return 0;
GetProcessInfo(#Form_SELF_FONTS, SelfInfo);
IF(y>Form_SELF_FONTS.cheight) return 0;
IF(x>Form_SELF_FONTS.cwidth) return 0;
tmp_y = y;
AX = c;
r = AL;
g = AH;
c>>=16;
AX = c;
b = AL;
getsize(text1);
IF(!buffer_size)
{
buffer_size = size.width*size.height*3;
buffer = malloc(buffer_size);
}
ELSE IF(buffer_size<size.width*size.height*3)
{
buffer_size = size.width*size.height*3;
buffer = realloc(buffer,buffer_size);
}
IF (no_bg_copy)
{
EBX = bg_color;
EAX = buffer_size+buffer;
EDI = buffer;
WHILE (EDI<EAX)
{
ESDWORD[EDI] = EBX;
$add edi,3
}
}
ELSE CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),size.width,size.height);
WHILE(DSBYTE[text1])
{
IF(DSBYTE[text1]=='_') len--;
len+=symbol(len,DSBYTE[text1],c);
IF(weight)len++;
text1++;
}
_PutImage(x,y-size.offset_y,size.width,size.height,buffer);
return len;
}
:dword FONT::textarea(word x,y;dword text1,c;byte size)
{
}
:byte FONT::symbol(signed x;byte s;dword c)
{
dword xi,yi;
dword tmp,_;
dword iii;
dword ___x;
byte rw=0;
x += size.offset_x;
IF(s==32)return width/4;
IF(s==9)return width;
yi = 0;
iii = 0;
tmp = 4*block*s;
tmp +=data;
while(yi<height)
{
xi = 0;
while(xi<width)
{
IF(iii%32) _ >>= 1;
ELSE
@ -198,7 +237,11 @@ FONT font = 0;
{
IF(xi>rw)rw=xi;
___x = x+xi;
IF(___x<Form_SELF_FONTS.cwidth)&&(tmp_y+yi<Form_SELF_FONTS.cheight)PixelRGB(___x,yi);
IF(___x<Form_SELF_FONTS.cwidth)&&(tmp_y+yi<Form_SELF_FONTS.cheight)
{
PixelRGB(___x,size.offset_y+yi);
IF(weight) PixelRGB(___x+1,size.offset_y+yi);
}
}
xi++;
iii++;