编辑器

编辑器加入不能识别编码判断,避免错误修改文件
This commit is contained in:
tslediter 2024-03-15 17:39:11 +08:00
parent ee97a84884
commit e8c5223f00
3 changed files with 28 additions and 13 deletions

View File

@ -1,5 +1,6 @@
type teditorform = class(TVCform) //±à¼­Æ÷Ö÷´°¿Ú
uses utslvclauxiliary,tslvcl,UTslSynMemo,UtslCodeEditor;
const c_e_none = "None";
const c_e_ansi = "ANSI";
const c_e_utf8 = "UTF8";
const c_e_utf8bom = "UTF8 BOM";
@ -136,19 +137,19 @@ type teditorform = class(TVCform) //
FEnCodeMenu := new TMenu(self);
FEnCodeMenu.Caption := c_m_encode;
FCodeMenus := array();
for i,v in array(c_e_ansi,c_e_utf8,c_e_utf8bom,c_e_ucs2big,c_e_ucs2little,c_e_separator,c_e_to_ansi,c_e_to_utf8,c_e_to_utf8bom,c_e_to_ucs2big,c_e_to_ucs2little) do
for i,v in array(c_e_None,c_e_ansi,c_e_utf8,c_e_utf8bom,c_e_ucs2big,c_e_ucs2little,c_e_separator,c_e_to_ansi,c_e_to_utf8,c_e_to_utf8bom,c_e_to_ucs2big,c_e_to_ucs2little) do
begin
it := new TMenu(self);
it.Caption := v;
FCodeMenus[i] := it;
if v=c_e_separator then it.TSeparator := true;
else
if v in array(c_e_ucs2big,c_e_ucs2little,c_e_utf8bom) then
begin
it.Enabled := false;
end else
if v in array(c_e_ucs2big,c_e_ucs2little,c_e_utf8bom) then
begin
it.Enabled := false;
end else
begin
it.OnClick := thisfunction(ClickEnCodeMenu);
it.OnClick := thisfunction(ClickEnCodeMenu);
end
it.Parent := FEnCodeMenu;
end
@ -799,7 +800,7 @@ type teditorform = class(TVCform) //
bm := it.EnCode;
for i,v in FCodeMenus do
begin
if i>5 then break;
if i>6 then break;
if v.Caption = bm then
begin
v.Checked := true;

View File

@ -1403,6 +1403,7 @@ type TPageEditerItem=class(TPageItem)
function ToUnicode_big();
begin
if FEnCode="UCS2-big" then return;
if FEnCode = "None" then return ;
FEnCode := "UCS2-big";
FEditer.ChangedFlag := true;
FLastVersion := "";
@ -1410,6 +1411,7 @@ type TPageEditerItem=class(TPageItem)
function ToUniocode_little();
begin
if FEnCode="UCS2-little" then return;
if FEnCode = "None" then return ;
FEnCode := "UCS2-little";
FEditer.ChangedFlag := true;
FLastVersion := "";
@ -1417,6 +1419,7 @@ type TPageEditerItem=class(TPageItem)
function ToUTF8();
begin
if FEnCode="UTF8" then return;
if FEnCode = "None" then return ;
FEnCode := "UTF8";
FEditer.ChangedFlag := true;
FLastVersion := "";
@ -1425,6 +1428,7 @@ type TPageEditerItem=class(TPageItem)
function ToUTF8BOM();
begin
if FEnCode="UTF8 BOM" then return;
if FEnCode = "None" then return ;
FEditer.ChangedFlag := true;
FEnCode := "UTF8 BOM";
FLastversion := "";
@ -1432,6 +1436,7 @@ type TPageEditerItem=class(TPageItem)
function ToANSI();
begin
if FEnCode="ANSI" then return;
if FEnCode = "None" then return ;
FEditer.ChangedFlag := true;
FEnCode := "ANSI";
FLastversion := "";
@ -1460,7 +1465,7 @@ type TPageEditerItem=class(TPageItem)
begin
if not ifstring(s)then return;
strcode := 0;
FEnCode := "ANSI";
FEnCode := "None";
if(length(s)>= 2)and ord(s[1])=0xFE and ord(s[2])=0xFF then //ucs2-big
begin
strcode := 2;
@ -1502,12 +1507,19 @@ type TPageEditerItem=class(TPageItem)
FEnCode := "UTF8";
strcode := 1;
s := utf8toansi(s);
end
end else
begin
if isTextGBK(s)=1 then
begin
FEnCode := "ANSI";
end
end
end
FLastVersion := s;
FEditer.Text := s;
FEditer.ExecuteCommand(FEditer.ecGotoXY,array(1,1));
FEditer.ClearUndo();
if FEnCode = "None" then FEditer.ReadOnly := true;
FEditer.ChangedFlag := false;
if not FTslSynText then return;
if not(s)then return;
@ -6052,9 +6064,11 @@ type TFindWnd=class(TPage)
FCheck_subdir.parent := self;
FCheck_reg.OnClick := function(o,e)
begin
FCheck_revers.Enabled := not(o.Checked);
FCheck_wrap.Enabled := not(o.Checked);
FCheck_case.Enabled := not(o.Checked);
ck := o.Checked;
FCheck_revers.Enabled := not(ck);
FCheck_wrap.Enabled := not(ck);
//FCheck_case.Enabled := not(ck);
FCheck_cycle.Enabled := not(ck);
end
FStatus := new TStatusBar(self);
//FStatus.Align := alNone;

View File

@ -3638,7 +3638,7 @@ begin
ordi <= 0xfe and
ordi2 >= 0x40 and
ordi2 <= 0xfe and
ordi2 <> 0xf7) then
ordi2 <> 0x7f) then
begin
i += 2;
continue;