Use the new UTF-8 system by default. Can be disabled by define DisableUTF8RTL. EnableUTF8RTL is removed.

git-svn-id: trunk@50129 -
This commit is contained in:
juha 2015-10-20 17:20:11 +00:00
parent 162c962047
commit 5fc7132693
14 changed files with 192 additions and 190 deletions

View File

@ -16,10 +16,6 @@ unit FPCAdds;
{$mode objfpc}{$H+}{$inline on}
{$IF defined(EnableUTF8RTL) and (FPC_FULLVERSION<20701)}
{$error UTF8 RTL requires fpc 2.7.1+}
{$ENDIF}
interface
uses
@ -68,11 +64,11 @@ begin
{$ENDIF}
end;
{$IFDEF EnableUTF8RTL}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
initialization
SetMultiByteConversionCodePage(CP_UTF8);
// SetMultiByteFileSystemCodePage(CP_UTF8); not needed, this is the default under Windows
SetMultiByteRTLFileSystemCodePage(CP_UTF8);
{$ENDIF}
{$IFEND}
end.

View File

@ -18,17 +18,16 @@ unit LazUTF8;
{$mode objfpc}{$H+}{$inline on}
{$IF defined(EnableUTF8RTL) and (FPC_FULLVERSION<20701)}
{$error UTF8 in RTL requires fpc 2.7.1+}
{$ENDIF}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
{$DEFINE ReallyUseUTF8RTL}
{$IFEND}
interface
uses
{$IFDEF EnableUTF8RTL}
{$ifdef unix}
cwstring, // UTF8 RTL on Unix requires this. Must be used although it pulls in clib.
{$endif}
{$IFDEF ReallyUseUTF8RTL}
{$ifdef unix}
cwstring, // UTF8 RTL on Unix requires this. Must be used although it pulls in clib.
{$endif}
FPCAdds,
{$ENDIF}
{$ifdef windows}
@ -43,8 +42,8 @@ function NeedRTLAnsi: boolean;// true if system encoding is not UTF-8
procedure SetNeedRTLAnsi(NewValue: boolean);
// UTF8ToSys works like UTF8ToAnsi but more independent of widestringmanager
function UTF8ToSys(const s: string): string; overload; {$IFDEF EnableUTF8RTL}inline;{$ENDIF}
function UTF8ToSys(const AFormatSettings: TFormatSettings): TFormatSettings; overload; {$IFDEF EnableUTF8RTL}inline;{$ENDIF}
function UTF8ToSys(const s: string): string; overload; {$IFDEF ReallyUseUTF8RTL}inline;{$ENDIF}
function UTF8ToSys(const AFormatSettings: TFormatSettings): TFormatSettings; overload; {$IFDEF ReallyUseUTF8RTL}inline;{$ENDIF}
// SysToUTF8 works like AnsiToUTF8 but more independent of widestringmanager
function SysToUTF8(const s: string): string; overload;
@ -252,7 +251,7 @@ end;
function UTF8ToSys(const s: string): string;
begin
{$IFDEF EnableUTF8RTL}
{$IFDEF ReallyUseUTF8RTL}
Result:=s;
{$ELSE}
if NeedRTLAnsi and (not IsASCII(s)) then
@ -264,7 +263,7 @@ end;
function SysToUTF8(const s: string): string;
begin
{$IFDEF EnableUTF8RTL}
{$IFDEF ReallyUseUTF8RTL}
Result:=s;
{$ELSE}
if NeedRTLAnsi and (not IsASCII(s)) then
@ -298,13 +297,13 @@ begin
end;
function UTF8ToSys(const AFormatSettings: TFormatSettings): TFormatSettings;
{$IFNDEF EnableUTF8RTL}
{$IFnDEF ReallyUseUTF8RTL}
var
i: Integer;
{$ENDIF}
begin
Result := AFormatSettings;
{$IFNDEF EnableUTF8RTL}
{$IFnDEF ReallyUseUTF8RTL}
Result.CurrencyString := UTF8ToSys(AFormatSettings.CurrencyString);
for i:=1 to 12 do begin
Result.LongMonthNames[i] := UTF8ToSys(AFormatSettings.LongMonthNames[i]);

View File

@ -16,14 +16,14 @@ unit LConvEncoding;
interface
{ $Define DisableAsianCodePages}
{$if FPC_FULLVERSION >= 20701}
{$if FPC_FULLVERSION >= 30000}
{$Define HasCP} // AnsiString has codepage
{$ifdef EnableUTF8RTL}
{$IFnDEF DisableUTF8RTL}
// Windows provides conversion functions.
// Unix: unit cwstring provides conversion functions, which is used by EnableUTF8RTL.
// Unix: unit cwstring provides conversion functions which are used by default UTF-8 encoding system.
{$Define UseSystemCPConv} // use system conversions
{$endif}
{$endif}
{$ENDIF}
{$IFEND}
{$ifdef UseLCPConv}{$undef UseSystemCPConv}{$endif}
uses

View File

@ -21,16 +21,12 @@ unit PasWString;
// non utf-8 ansistring is rare in UNIXes and lconvencoding makes the executable big
// sanity checks for defines
{$IFDEF EnableUTF8RTL}
{$IF FPC_FULLVERSION<20701}
{$error UTF8 RTl requires fpc 2.7.1+}
{$IF FPC_FULLVERSION >= 30000}
{$IFnDEF DisableUTF8RTL}
{$IFDEF PASWSTRING_SUPPORT_NONUTF8_ANSISTRING}
{$error UTF8 or not UTF8}
{$ENDIF}
{$ENDIF}
{$IFDEF PASWSTRING_SUPPORT_NONUTF8_ANSISTRING}
{$error UTF8 or not UTF8}
{$ENDIF}
{$ENDIF}
{$IF FPC_FULLVERSION>=20701}
{$DEFINE DisablePasWString}
{$ENDIF}
@ -41,13 +37,13 @@ uses
{$ifdef PASWSTRING_SUPPORT_NONUTF8_ANSISTRING}, lconvencoding{$endif}
;
{$IFNDEF DisablePasWString}
{$IFnDEF DisablePasWString}
procedure SetPasWidestringManager;
{$ENDIF}
implementation
{$IFNDEF DisablePasWString}
{$IFnDEF DisablePasWString}
procedure fpc_rangeerror; [external name 'FPC_RANGEERROR'];
function IsASCII(const s: string): boolean; inline;

View File

@ -535,13 +535,15 @@ begin
{$endif}
end;
{$IF DEFINED(WinCE) OR (FPC_FULLVERSION>=20701)}
{$IF DEFINED(WinCE) OR (FPC_FULLVERSION>=30000)}
{$define FindData_W}
{$endif}
{$IFEND}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
{$DEFINE ReallyUseUTF8RTL}
{$IFEND}
function FindMatch(var f: TSearchRec) : Longint;
{$IFnDEF EnableUTF8RTL}
{$IFnDEF ReallyUseUTF8RTL}
var
Dummy: String;
{$ENDIF}
@ -563,7 +565,7 @@ begin
in win32 it is the ansi structure with a utf-8 string
in wince it is a wide structure }
{$ifdef FindData_W}
{$IFDEF EnableUTF8RTL}
{$IFDEF ReallyUseUTF8RTL}
f.Name:=UTF8Encode(UnicodeString(F.FindData.cFileName));
{$ELSE}
Dummy := '';

View File

@ -7,10 +7,10 @@ var
var
ArgsW: Array of WideString;
ArgsWCount: Integer; // length(ArgsW)+1
{$IFDEF EnableUTF8RTL}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
ArgsUTF8: Array of String; // the ArgsW array as UTF8
OldArgV: PPChar = nil;
{$ENDIF}
{$IFEND}
//************ START "Stubs" that just call Ansi or Wide implementation
@ -188,7 +188,7 @@ begin
end;
Dec(ArgsWCount);
{$IFDEF EnableUTF8RTL}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
if DefaultSystemCodePage=CP_UTF8 then begin
SetLength(ArgsUTF8,length(ArgsW));
OldArgV:=argv;
@ -199,7 +199,7 @@ begin
argv[i]:=PChar(ArgsUTF8[i]);
end;
end;
{$ENDIF}
{$IFEND}
end;
function ParamStrUtf8Wide(Param: Integer): String;
@ -331,7 +331,7 @@ begin
end;
{$endif}
{$IFDEF EnableUTF8RTL}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
function GetLocaleStr(aLocaleID, aLCType: Longint; const Def: string): String;
var
L: Integer;
@ -465,7 +465,7 @@ begin
end else
Result:=0;
end;
{$ENDIF}
{$IFEND}
procedure InitLazUtf8;
begin
@ -493,7 +493,7 @@ begin
end;
end;
end;
{$ifdef EnableUTF8RTL}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
GetFormatSettingsUTF8(GetThreadLocale,FormatSettings);
widestringmanager.UpperAnsiStringProc:=@UTF8UpperString;
widestringmanager.LowerAnsiStringProc:=@UTF8LowerString;
@ -506,16 +506,16 @@ begin
// Does anyone need these two?
//widestringmanager.StrLowerAnsiStringProc;
//widestringmanager.StrUpperAnsiStringProc;
{$endif}
{$IFEND}
end;
procedure FinalizeLazUTF8;
{$IFDEF EnableUTF8RTL}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
var
p: PPChar;
{$ENDIF}
{$IFEND}
begin
{$IFDEF EnableUTF8RTL}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
// restore argv and free memory
if OldArgV<>nil then
begin
@ -523,5 +523,5 @@ begin
argv:=OldArgV;
Freemem(p);
end;
{$ENDIF}
{$IFEND}
end;

View File

@ -2,9 +2,9 @@ object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
Left = 0
Height = 429
Top = 0
Width = 550
Width = 614
ClientHeight = 429
ClientWidth = 550
ClientWidth = 614
TabOrder = 0
DesignLeft = 414
DesignTop = 101
@ -12,7 +12,7 @@ object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
Left = 0
Height = 26
Top = 0
Width = 550
Width = 614
ButtonHeight = 25
Caption = 'BMMatrixToolBar'
EdgeBorders = []
@ -28,7 +28,7 @@ object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
ShowHint = True
end
object BMMMoveDownButton: TToolButton
Left = 24
Left = 26
Top = 0
Caption = 'Down'
OnClick = BMMMoveDownButtonClick
@ -36,7 +36,7 @@ object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
ShowHint = True
end
object BMMUndoButton: TToolButton
Left = 74
Left = 79
Top = 0
Caption = 'Undo'
OnClick = BMMUndoButtonClick
@ -44,7 +44,7 @@ object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
ShowHint = True
end
object BMMRedoToolButton: TToolButton
Left = 111
Left = 120
Top = 0
Caption = 'Redo'
OnClick = BMMRedoToolButtonClick
@ -52,7 +52,7 @@ object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
ShowHint = True
end
object BMMDeleteButton: TToolButton
Left = 385
Left = 555
Top = 0
Caption = 'Delete'
OnClick = BMMDeleteButtonClick
@ -60,28 +60,31 @@ object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
ShowHint = True
end
object MoveSepToolButton: TToolButton
Left = 64
Left = 69
Height = 25
Top = 0
Width = 10
Caption = 'MoveSepToolButton'
Style = tbsSeparator
end
object DoSepToolButton: TToolButton
Left = 148
Left = 159
Height = 25
Top = 0
Width = 10
Caption = 'DoSepToolButton'
Style = tbsSeparator
end
object AddOtherSepToolButton: TToolButton
Left = 375
object SystemEncodingSepToolButton: TToolButton
Left = 545
Height = 25
Top = 0
Width = 10
Caption = 'AddOtherSepToolButton'
Caption = 'SystemEncodingSepToolButton'
Style = tbsSeparator
end
object BMMAddOtherButton: TToolButton
Left = 297
Left = 319
Top = 0
Caption = 'Add Other'
DropdownMenu = BMMAddOtherPopupMenu
@ -89,19 +92,36 @@ object CompOptModeMatrixFrame: TCompOptModeMatrixFrame
Style = tbsDropDown
end
object BMMAddLclWidgetButton: TToolButton
Left = 158
Left = 169
Top = 0
Caption = 'Add LCLWidgetType'
OnClick = BMMAddLclWidgetButtonClick
Style = tbsDropDown
end
object LCLMacroSepToolButton: TToolButton
Left = 287
Left = 309
Height = 25
Top = 0
Width = 10
Caption = 'LCLMacroSepToolButton'
Style = tbsSeparator
end
object BMMSystemEncodingButton: TToolButton
Left = 411
Top = 0
Caption = 'Use system encoding'
OnClick = BMMSystemEncodingButtonClick
ParentShowHint = False
ShowHint = True
end
object AddOtherSepToolButton: TToolButton
Left = 401
Height = 25
Top = 0
Width = 10
Caption = 'AddOtherSepToolButton'
Style = tbsSeparator
end
end
object BMMAddOtherPopupMenu: TPopupMenu
left = 240

View File

@ -61,9 +61,11 @@ type
BMMNewOutDirMenuItem: TMenuItem;
MoveSepToolButton: TToolButton;
DoSepToolButton: TToolButton;
AddOtherSepToolButton: TToolButton;
SystemEncodingSepToolButton: TToolButton;
BMMAddLclWidgetButton: TToolButton;
LCLMacroSepToolButton: TToolButton;
BMMSystemEncodingButton: TToolButton;
AddOtherSepToolButton: TToolButton;
procedure BMMDeleteButtonClick(Sender: TObject);
procedure BMMMoveDownButtonClick(Sender: TObject);
procedure BMMMoveUpButtonClick(Sender: TObject);
@ -83,6 +85,7 @@ type
procedure GridShowHint(Sender: TObject; HintInfo: PHintInfo);
procedure OnAddMacroMenuItemClick(Sender: TObject);
procedure OnAddLCLWidgetTypeClick(Sender: TObject);
procedure BMMSystemEncodingButtonClick(Sender: TObject);
private
FDialog: TAbstractOptionsEditorDialog;
FErrorColor: TColor;
@ -102,6 +105,9 @@ type
procedure AddLCLWidgetTypeValues(ParentMenu: TPopupMenu; Mcr: TLazBuildMacro);
procedure AddMacroValues(ParentMI: TMenuItem; Mcr: TLazBuildMacro);
function ActiveModeAsText: string;
function CheckAndUpdateSystemEncoding(UpdateIt: Boolean; out WasUpdated: Boolean): Boolean;
function HasSystemEncoding: Boolean;
function SupportSystemEncoding: Boolean;
procedure DoWriteSettings;
procedure FillMenus;
procedure MoveRow(Direction: integer);
@ -113,8 +119,6 @@ type
procedure UpdateEnabledModesInGrid(Options: TBuildMatrixOptions;
StorageGroup: TGroupedMatrixGroup; var HasChanged: boolean);
procedure UpdateGridStorageGroups;
function CheckAndUpdateUtf8RtlSupport(UpdateIt: Boolean;
out WasUpdated: Boolean): Boolean;
protected
procedure VisibleChanged; override;
public
@ -126,8 +130,6 @@ type
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
procedure RestoreSettings(AOptions: TAbstractIDEOptions); override;
function HasSupportForUtf8Rtl: Boolean;
function SupportUtf8Rtl: Boolean;
procedure UpdateModes(UpdateGrid: boolean = true);
procedure UpdateActiveMode;
public
@ -166,7 +168,7 @@ var
implementation
const
EnableUTF8RTL = '-dEnableUTF8RTL';
DisableUTF8RTL = '-dDisableUTF8RTL';
function BuildMatrixOptionTypeCaption(Typ: TBuildMatrixOptionType): string;
begin
@ -539,6 +541,11 @@ begin
BMMAddOtherPopupMenu.PopUp(p.x,p.y);
end;
procedure TCompOptModeMatrixFrame.BMMSystemEncodingButtonClick(Sender: TObject);
begin
SupportSystemEncoding;
end;
procedure TCompOptModeMatrixFrame.GridEditingDone(Sender: TObject);
begin
//DebugLn(['TFrame1.GridEditingDone ']);
@ -907,7 +914,7 @@ begin
DoWriteSettings;
end;
function TCompOptModeMatrixFrame.CheckAndUpdateUtf8RtlSupport(UpdateIt: Boolean;
function TCompOptModeMatrixFrame.CheckAndUpdateSystemEncoding(UpdateIt: Boolean;
out WasUpdated: Boolean): Boolean;
// Returns True if the support already was there.
var
@ -929,7 +936,7 @@ begin
ValueRow := TGroupedMatrixValue(Target[i]);
if not (ValueRow is TGroupedMatrixValue) then
exit;
Result := (ValueRow.Typ = 'Custom') and (ValueRow.Value = EnableUTF8RTL);
Result := (ValueRow.Typ = 'Custom') and (ValueRow.Value = DisableUTF8RTL);
if Result then
begin
AMode := ActiveModeAsText;
@ -950,24 +957,23 @@ begin
end;
end;
function TCompOptModeMatrixFrame.HasSupportForUtf8Rtl: Boolean;
function TCompOptModeMatrixFrame.HasSystemEncoding: Boolean;
var
Dummy: Boolean;
begin
Result := CheckAndUpdateUtf8RtlSupport(False, Dummy);
Result := CheckAndUpdateSystemEncoding(False, Dummy);
end;
function TCompOptModeMatrixFrame.SupportUtf8Rtl: Boolean;
// Add a compiler flag to make FPC default string UTF-8,
// assign UTF-8 backends for Ansi...() functions etc.
function TCompOptModeMatrixFrame.SupportSystemEncoding: Boolean;
// Add a compiler flag to use system encoding for string.
// Returns true if the flag was really added and did not exist earlier.
var
WasUpdated: Boolean;
begin
Result := not CheckAndUpdateUtf8RtlSupport(True, WasUpdated);
Result := not CheckAndUpdateSystemEncoding(True, WasUpdated);
if Result and not WasUpdated then
begin
CreateNewOption(BuildMatrixOptionTypeCaption(bmotCustom), EnableUTF8RTL);
CreateNewOption(BuildMatrixOptionTypeCaption(bmotCustom), DisableUTF8RTL);
UpdateModes;
end;
end;
@ -1206,10 +1212,12 @@ begin
BMMMoveDownButton.ImageIndex:=IDEImages.LoadImage(16,'arrow_down');
BMMMoveDownButton.Hint:=lisMMMoveSelectedItemDown;
BMMUndoButton.Caption:=lisUndo;
BMMUndoButton.ShowCaption:=false;
BMMUndoButton.ImageIndex:=IDEImages.LoadImage(16,'menu_undo');
BMMUndoButton.Hint:=lisMMUndoLastChangeToThisGrid;
BMMRedoToolButton.Caption:=lisRedo;
BMMRedoToolButton.ShowCaption:=false;
BMMRedoToolButton.ImageIndex:=IDEImages.LoadImage(16,'menu_redo');
BMMRedoToolButton.Hint:=lisMMRedoLastUndoToThisGrid;
BMMDeleteButton.Caption:=lisDelete;
@ -1228,6 +1236,9 @@ begin
BMMAddLclWidgetButton.Caption:=Format(fCaptionPatternMacroName,['LCLWidgetType']);
BMMAddOtherButton.Caption:=lisAdd;
BMMSystemEncodingButton.Caption:=lisMMUseSystemEncoding;
BMMSystemEncodingButton.Hint:=lisMMUseSystemEncodingHint;
UpdateButtons;
end;

View File

@ -15,15 +15,15 @@ object CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
Width = 521
Align = alBottom
Caption = 'grpConditionals'
ClientHeight = 178
ClientWidth = 519
ClientHeight = 176
ClientWidth = 513
TabOrder = 0
inline CondSynEdit: TSynEdit
AnchorSideRight.Side = asrBottom
Left = 0
Height = 161
Height = 154
Top = 0
Width = 519
Width = 513
Align = alClient
Font.Height = 9
Font.Name = '-misc-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-iso10646-1'
@ -651,9 +651,9 @@ object CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
end
object CondStatusbar: TStatusBar
Left = 0
Height = 17
Top = 161
Width = 519
Height = 22
Top = 154
Width = 513
Panels = <
item
Width = 80
@ -683,19 +683,20 @@ object CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
Width = 521
Align = alClient
Caption = 'grpCustomOptions'
ClientHeight = 192
ClientWidth = 519
ClientHeight = 190
ClientWidth = 513
TabOrder = 2
object memoCustomOptions: TMemo
AnchorSideLeft.Control = grpCustomOptions
AnchorSideBottom.Control = grpCustomOptions
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 188
Height = 186
Top = 4
Width = 363
Width = 357
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 6
OnChange = memoCustomOptionsChange
ParentShowHint = False
ScrollBars = ssAutoBoth
ShowHint = True
@ -707,14 +708,16 @@ object CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = btnDefines
AnchorSideRight.Side = asrBottom
Left = 369
Height = 23
Left = 363
Height = 29
Top = 4
Width = 150
Anchors = [akTop, akLeft, akRight]
AutoSize = True
Caption = 'All options ...'
OnClick = btnAllOptionsClick
ParentShowHint = False
ShowHint = True
TabOrder = 1
end
object btnDefines: TBitBtn
@ -722,16 +725,37 @@ object CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
AnchorSideTop.Control = btnAllOptions
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 369
Height = 23
Top = 33
Left = 363
Height = 29
Top = 39
Width = 150
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
Caption = 'Defines ...'
OnClick = btnDefinesClick
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
object btnFcUTF8: TBitBtn
AnchorSideLeft.Control = btnDefines
AnchorSideTop.Control = btnDefines
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = btnDefines
AnchorSideRight.Side = asrBottom
Left = 363
Height = 29
Top = 81
Width = 150
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 13
Caption = 'Add -FcUTF8'
OnClick = btnFcUTF8Click
ParentShowHint = False
ShowHint = True
TabOrder = 3
end
end
end

View File

@ -42,6 +42,7 @@ type
TCompilerOtherOptionsFrame = class(TAbstractIDEOptionsEditor)
btnDefines: TBitBtn;
btnAllOptions: TBitBtn;
btnFcUTF8: TBitBtn;
grpCustomOptions: TGroupBox;
grpConditionals: TGroupBox;
CondStatusbar: TStatusBar;
@ -50,11 +51,13 @@ type
memoCustomOptions: TMemo;
procedure btnAllOptionsClick(Sender: TObject);
procedure btnDefinesClick(Sender: TObject);
procedure btnFcUTF8Click(Sender: TObject);
procedure CondSynEditChange(Sender: TObject);
procedure CondSynEditKeyPress(Sender: TObject; var {%H-}Key: char);
procedure CondSynEditProcessUserCommand(Sender: TObject;
var Command: TSynEditorCommand; var {%H-}AChar: TUTF8Char; {%H-}Data: pointer);
procedure CondSynEditStatusChange(Sender: TObject; {%H-}Changes: TSynStatusChanges);
procedure memoCustomOptionsChange(Sender: TObject);
private
FCompOptions: TBaseCompilerOptions;
FIdleConnected: Boolean;
@ -99,8 +102,7 @@ type
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
function HasSupportForUtf8Rtl: Boolean;
function SupportUtf8Rtl: Boolean;
function NoUtf8RtlSupportYet: Boolean;
property StatusMessage: string read FStatusMessage write SetStatusMessage;
property DefaultVariables: TCTCfgScriptVariables read FDefaultVariables;
property CompletionValues: TStrings read FCompletionValues;
@ -173,22 +175,24 @@ begin
end;
end;
function TCompilerOtherOptionsFrame.HasSupportForUtf8Rtl: Boolean;
procedure TCompilerOtherOptionsFrame.btnFcUTF8Click(Sender: TObject);
begin
Result := Pos(FcUTF8, memoCustomOptions.Text) > 0;
end;
function TCompilerOtherOptionsFrame.SupportUtf8Rtl: Boolean;
// Add a compiler flag for WideString/UnicodeString/UTF8String literals.
// Returns true if the flag was really added and did not exist earlier.
begin
Result := not HasSupportForUtf8Rtl;
if Result then
if NoUtf8RtlSupportYet then
memoCustomOptions.Lines.Add(FcUTF8);
end;
function TCompilerOtherOptionsFrame.NoUtf8RtlSupportYet: Boolean;
begin
Result := Pos(FcUTF8, memoCustomOptions.Text) = 0;
end;
// Events dealing with conditionals SynEdit :
procedure TCompilerOtherOptionsFrame.memoCustomOptionsChange(Sender: TObject);
begin
btnFcUTF8.Enabled := NoUtf8RtlSupportYet;
end;
procedure TCompilerOtherOptionsFrame.CondSynEditChange(Sender: TObject);
begin
UpdateStatusBar;
@ -722,6 +726,8 @@ begin
grpConditionals.Caption := lisConditionals;
btnAllOptions.Caption := lisDlgAllOptions;
btnDefines.Caption := lisDlgDefines;
btnFcUTF8.Caption := lisAddFcUTF8;
btnFcUTF8.Hint := lisAddFcUTF8Hint;
end;
procedure TCompilerOtherOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
@ -749,6 +755,7 @@ begin
// Custom Options
memoCustomOptions.Text := FCompOptions.CustomOptions;
memoCustomOptions.OnChange(Nil);
FUseComments := FCompOptions.UseCommentsInCustomOptions;
UpdateStatusBar;

View File

@ -18,8 +18,8 @@ object IDEOptionsDialog: TIDEOptionsDialog
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
Left = 6
Height = 36
Top = 458
Height = 37
Top = 457
Width = 788
BorderSpacing.Left = 6
BorderSpacing.Right = 6
@ -39,7 +39,7 @@ object IDEOptionsDialog: TIDEOptionsDialog
end
object CatTVSplitter: TSplitter
Left = 255
Height = 458
Height = 457
Top = 0
Width = 4
end
@ -47,12 +47,12 @@ object IDEOptionsDialog: TIDEOptionsDialog
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 0
Height = 458
Height = 457
Top = 0
Width = 255
Align = alLeft
BevelOuter = bvNone
ClientHeight = 458
ClientHeight = 457
ClientWidth = 255
Constraints.MinWidth = 150
TabOrder = 2
@ -64,12 +64,11 @@ object IDEOptionsDialog: TIDEOptionsDialog
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SettingsPanel
Left = 6
Height = 401
Top = 37
Height = 398
Top = 39
Width = 249
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
DefaultItemHeight = 18
ReadOnly = True
TabOrder = 0
OnChange = CategoryTreeChange
@ -83,7 +82,7 @@ object IDEOptionsDialog: TIDEOptionsDialog
AnchorSideTop.Control = CategoryPanel
AnchorSideRight.Side = asrBottom
Left = 6
Height = 25
Height = 27
Top = 6
Width = 249
OnFilterItem = FilterEditFilterItem
@ -96,12 +95,13 @@ object IDEOptionsDialog: TIDEOptionsDialog
MaxLength = 0
ParentFont = False
TabOrder = 1
TextHint = '(suodatin)'
FilteredTreeview = CategoryTree
end
object SettingsPanel: TPanel
Left = 0
Height = 20
Top = 438
Top = 437
Width = 255
Align = alBottom
AutoSize = True
@ -130,12 +130,12 @@ object IDEOptionsDialog: TIDEOptionsDialog
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = UseBuildModeCheckBox
AnchorSideTop.Side = asrCenter
Left = 112
Height = 29
Left = 124
Height = 27
Top = 5
Width = 154
BorderSpacing.Left = 7
ItemHeight = 0
ItemHeight = 23
OnSelect = BuildModeComboBoxSelect
Style = csDropDownList
TabOrder = 0
@ -145,9 +145,9 @@ object IDEOptionsDialog: TIDEOptionsDialog
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BuildModeComboBox
AnchorSideTop.Side = asrCenter
Left = 277
Left = 289
Height = 25
Top = 7
Top = 6
Width = 25
BorderSpacing.Left = 11
Caption = '...'
@ -157,9 +157,9 @@ object IDEOptionsDialog: TIDEOptionsDialog
object UseBuildModeCheckBox: TCheckBox
AnchorSideTop.Side = asrCenter
Left = 12
Height = 24
Height = 22
Top = 7
Width = 93
Width = 105
BorderSpacing.Left = 6
Caption = 'Build modes'
OnChange = UseBuildModeCheckBoxChange
@ -167,21 +167,6 @@ object IDEOptionsDialog: TIDEOptionsDialog
ShowHint = True
TabOrder = 2
end
object SetUtf8InRtlButton: TButton
AnchorSideLeft.Control = BuildModeManageButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BuildModeManageButton
AnchorSideTop.Side = asrCenter
Left = 317
Height = 27
Top = 6
Width = 102
AutoSize = True
BorderSpacing.Left = 15
Caption = 'Set UTF-8 in RTL'
OnClick = SetUtf8InRtlButtonClick
TabOrder = 3
end
end
object EditorsPanel: TScrollBox
AnchorSideLeft.Control = CatTVSplitter
@ -192,7 +177,7 @@ object IDEOptionsDialog: TIDEOptionsDialog
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel
Left = 259
Height = 418
Height = 417
Top = 40
Width = 535
HorzScrollBar.Page = 1

View File

@ -51,7 +51,6 @@ type
TIDEOptionsDialog = class(TAbstractOptionsEditorDialog)
BuildModeComboBox: TComboBox;
SetUtf8InRtlButton: TButton;
UseBuildModeCheckBox: TCheckBox;
BuildModeManageButton: TButton;
BuildModeSelectPanel: TPanel;
@ -62,7 +61,6 @@ type
EditorsPanel: TScrollBox;
FilterEdit: TTreeFilterEdit;
SettingsPanel: TPanel;
procedure SetUtf8InRtlButtonClick(Sender: TObject);
procedure UseBuildModeCheckBoxChange(Sender: TObject);
procedure BuildModeComboBoxSelect(Sender: TObject);
procedure BuildModeManageButtonClick(Sender: TObject);
@ -98,7 +96,6 @@ type
function AllBuildModes: boolean;
procedure UpdateBuildModeButtons;
procedure SetBuildModeVisibility(AVisibility: Boolean);
procedure UpdateUtf8RtlButtonState;
public
constructor Create(AOwner: TComponent); override;
function ShowModal: Integer; override;
@ -157,7 +154,6 @@ begin
SettingsPanel.Constraints.MinHeight:=0;
SetBuildModeVisibility(False);
UseBuildModeCheckBox.Caption:=lisBuildModes;
SetUtf8InRtlButton.Caption := lisSetUTF8InRTL;
IDEDialogLayoutList.ApplyLayout(Self, Width, Height);
Caption := dlgIDEOptions;
@ -232,40 +228,6 @@ procedure TIDEOptionsDialog.UseBuildModeCheckBoxChange(Sender: TObject);
begin
EnvironmentOptions.UseBuildModes:=(Sender as TCheckBox).Checked;
UpdateBuildModeButtons;
UpdateUtf8RtlButtonState;
end;
procedure TIDEOptionsDialog.UpdateUtf8RtlButtonState;
var
OtherOptions: TCompilerOtherOptionsFrame;
ModeMatrix: TCompOptModeMatrixFrame;
begin
OtherOptions:=TCompilerOtherOptionsFrame(FindEditor(TCompilerOtherOptionsFrame));
ModeMatrix:=TCompOptModeMatrixFrame(FindEditor(TCompOptModeMatrixFrame));
if Assigned(OtherOptions) and Assigned(ModeMatrix) then
SetUtf8InRtlButton.Enabled := not (OtherOptions.HasSupportForUtf8Rtl
and ModeMatrix.HasSupportForUtf8Rtl
and HasLazUtilsDependency);
end;
procedure TIDEOptionsDialog.SetUtf8InRtlButtonClick(Sender: TObject);
var
OtherOptions: TCompilerOtherOptionsFrame;
ModeMatrix: TCompOptModeMatrixFrame;
begin
OtherOptions:=TCompilerOtherOptionsFrame(FindEditor(TCompilerOtherOptionsFrame));
ModeMatrix:=TCompOptModeMatrixFrame(FindEditor(TCompOptModeMatrixFrame));
if Assigned(OtherOptions) and Assigned(ModeMatrix) then begin
// For WideString/UnicodeString/UTF8String literals.
OtherOptions.SupportUtf8Rtl;
// Make FPC default string UTF-8. Assign UTF-8 backends for Ansi...() functions etc.
ModeMatrix.SupportUtf8Rtl;
// Add dependency for LazUtils if the project does not have it yet.
AddLazUtilsDependency;
// Update GUI state and show message.
UpdateUtf8RtlButtonState;
ShowMessage(Format(lisThisBuildModeNowSetsUTF8InRTL, [LineEnding]));
end;
end;
procedure TIDEOptionsDialog.BuildModeComboBoxSelect(Sender: TObject);
@ -276,7 +238,6 @@ begin
else begin
Assert(BuildModeSelectPanel.Visible, 'BuildModeComboBoxSelect: BuildModeSelectPanel not Visible');
SwitchBuildMode(BuildModeComboBox.Text);
UpdateUtf8RtlButtonState;
end;
end;
@ -285,7 +246,6 @@ begin
if ShowBuildModesDlg(Project1.SessionStorage in pssHasSeparateSession) <> mrOK then
exit;
UpdateBuildModeCombo(BuildModeComboBox);
UpdateUtf8RtlButtonState;
end;
procedure TIDEOptionsDialog.CategoryTreeCollapsed(Sender: TObject; Node: TTreeNode);
@ -810,7 +770,6 @@ procedure TIDEOptionsDialog.UpdateBuildModeGUI;
begin
UpdateBuildModeCombo(BuildModeComboBox);
UpdateBuildModeButtons;
UpdateUtf8RtlButtonState;
end;
end.

View File

@ -5610,7 +5610,8 @@ resourcestring
+'not-found errors. This can take a minute.';
lisActive = 'Active';
lisBuildModes = 'Build modes';
lisSetUTF8InRTL = 'Set UTF-8 in RTL';
lisAddFcUTF8 = 'Add -FcUTF8';
lisAddFcUTF8Hint = 'May be needed if source files have non-ansistring literals.';
lisInSession = 'In session';
lisTheDefaultModeMustBeStoredInProject =
'The default mode must be stored in project, not in session.';
@ -5977,6 +5978,8 @@ resourcestring
lisMMCustomOption = 'Custom Option';
lisMMIDEMacro = 'IDE Macro';
lisMMOverrideOutputDirectory = 'Override output directory (-FU)';
lisMMUseSystemEncoding = 'Use system encoding';
lisMMUseSystemEncodingHint = 'Disable support for UTF-8 default string encoding.';
lisPriority = 'Priority';
lisUDScanningUnits = 'Scanning: %s units ...';
lisUDFile = 'File: %s';

View File

@ -23,9 +23,9 @@ unit Interfaces;
interface
uses
{$IFDEF EnableUTF8RTL}
{$IF (FPC_FULLVERSION >= 30000) AND NOT DEFINED(DisableUTF8RTL)}
LazUTF8,
{$ENDIF}
{$IFEND}
InterfaceBase;
implementation