|
From: <wp...@us...> - 2009-08-11 17:45:50
|
Revision: 820
http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=820&view=rev
Author: wp2udk
Date: 2009-08-11 17:45:41 +0000 (Tue, 11 Aug 2009)
Log Message:
-----------
* D2009: DclIOCore_D12 has only two warnings left that FileAge is deprecated.
- InstantOTA ReadEditorSource and WriteEditorSource can now read UTF8 encoded source code.
Modified Paths:
--------------
trunk/Source/Design/InstantModelExpert.pas
trunk/Source/Design/InstantOTA.pas
Modified: trunk/Source/Design/InstantModelExpert.pas
===================================================================
--- trunk/Source/Design/InstantModelExpert.pas 2009-08-10 21:21:19 UTC (rev 819)
+++ trunk/Source/Design/InstantModelExpert.pas 2009-08-11 17:45:41 UTC (rev 820)
@@ -24,7 +24,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Nando Dessena, Steven Mitchell
+ * Nando Dessena, Steven Mitchell, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -1000,7 +1000,7 @@
Editor := FIDEInterface.SourceEditor(Module);
{$IFDEF D12+}
- Source := UTF8ToUnicodeString(FIDEInterface.ReadEditorSource(Editor));
+ Source := FIDEInterface.ReadEditorSource(Editor);
Stream := TStringStream.Create(Source, TEncoding.Unicode);
{$ELSE}
Source := FIDEInterface.ReadEditorSource(Editor);
Modified: trunk/Source/Design/InstantOTA.pas
===================================================================
--- trunk/Source/Design/InstantOTA.pas 2009-08-10 21:21:19 UTC (rev 819)
+++ trunk/Source/Design/InstantOTA.pas 2009-08-11 17:45:41 UTC (rev 820)
@@ -24,7 +24,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- * Nando Dessena, Steven Mitchell
+ * Nando Dessena, Steven Mitchell, Brian Andersen
*
* ***** END LICENSE BLOCK ***** *)
@@ -42,6 +42,13 @@
Classes, ToolsAPI, InstantTypes, Forms;
type
+{$IFDEF D12+}
+ InstantOTAString = UTF8String;
+{$ELSE}
+ InstantOTAString = string;
+{$ENDIF}
+ PInstantOTAString = ^InstantOTAString;
+
TInstantOTAIDEInterface = class;
{$IFDEF D9+}
TInstantOTAIDENotifier8 = class;
@@ -106,11 +113,11 @@
function CurrentModule: IOTAModule;
function FindModule(const Name: string): IOTAModule;
procedure GotoFilePos(const FileName: string; Line, Column: Integer);
- function ReadEditorSource(Editor: IOTASourceEditor): AnsiString;
- function ReadModuleSource(Module: IOTAModule): AnsiString;
+ function ReadEditorSource(Editor: IOTASourceEditor): string;
+ function ReadModuleSource(Module: IOTAModule): string;
procedure ShowMessages;
function SourceEditor(Module: IOTAModule): IOTASourceEditor;
- procedure WriteEditorSource(Editor: IOTASourceEditor; const Source: AnsiString;
+ procedure WriteEditorSource(Editor: IOTASourceEditor; const Source: string;
ReplaceLen: Integer; Undoable: Boolean = False);
property EditActions: IOTAEditActions read GetEditActions;
property MessageServices: IOTAMessageServices read GetMessageServices;
@@ -496,10 +503,10 @@
end;
function TInstantOTAIDEInterface.ReadEditorSource(
- Editor: IOTASourceEditor): AnsiString;
+ Editor: IOTASourceEditor): string;
var
Reader: IOTAEditReader;
- Buffer: AnsiString;
+ Buffer: InstantOTAString;
BufferLen, ReadLen, Position: Integer;
begin
if Assigned(Editor) then
@@ -511,18 +518,19 @@
repeat
SetLength(Buffer, BufferLen);
ReadLen := Reader.GetText(Position, PAnsiChar(Buffer), BufferLen);
- if ReadLen < BufferLen then
- Dec(ReadLen, 2);
+ if ReadLen < BufferLen then // ?? What does these two lines do??
+ Dec(ReadLen, 2); // ??
SetLength(Buffer, ReadLen);
- Result := Result + Buffer;
+ Result := Result + string(Buffer);
Inc(Position, ReadLen);
until ReadLen < BufferLen - 1;
end else
Result := '';
+// ShowMessage(Result);
end;
function TInstantOTAIDEInterface.ReadModuleSource(
- Module: IOTAModule): AnsiString;
+ Module: IOTAModule): string;
begin
Result := ReadEditorSource(SourceEditor(Module));
end;
@@ -585,7 +593,7 @@
end;
procedure TInstantOTAIDEInterface.WriteEditorSource(
- Editor: IOTASourceEditor; const Source: AnsiString; ReplaceLen: Integer;
+ Editor: IOTASourceEditor; const Source: string; ReplaceLen: Integer;
Undoable: Boolean);
var
Writer: IOTAEditWriter;
@@ -596,7 +604,7 @@
Writer := Editor.CreateUndoableWriter else
Writer := Editor.CreateWriter;
Writer.DeleteTo(ReplaceLen);
- Writer.Insert(PAnsiChar(Source));
+ Writer.Insert(PAnsiChar(InstantOTAString(Source)));
end;
{ TInstantOTAIDENotifier5 }
|