|
@@ -37,15 +37,9 @@ const
|
|
cmReadBlock = 51246;
|
|
cmReadBlock = 51246;
|
|
cmPrintBlock = 51247;
|
|
cmPrintBlock = 51247;
|
|
|
|
|
|
-{$ifdef FPC}
|
|
|
|
- EditorTextBufSize = 32768;
|
|
|
|
- MaxLineLength = 255;
|
|
|
|
- MaxLineCount = 16380;
|
|
|
|
-{$else}
|
|
|
|
- EditorTextBufSize = 4096;
|
|
|
|
- MaxLineLength = 255;
|
|
|
|
- MaxLineCount = 16380;
|
|
|
|
-{$endif}
|
|
|
|
|
|
+ EditorTextBufSize = {$ifdef FPC}32768{$else} 4096{$endif};
|
|
|
|
+ MaxLineLength = {$ifdef FPC} 255{$else} 255{$endif};
|
|
|
|
+ MaxLineCount = {$ifdef FPC}16380{$else}16380{$endif};
|
|
|
|
|
|
efBackupFiles = $00000001;
|
|
efBackupFiles = $00000001;
|
|
efInsertMode = $00000002;
|
|
efInsertMode = $00000002;
|
|
@@ -59,6 +53,7 @@ const
|
|
efHighlightColumn = $00000200;
|
|
efHighlightColumn = $00000200;
|
|
efHighlightRow = $00000400;
|
|
efHighlightRow = $00000400;
|
|
efAutoBrackets = $00000800;
|
|
efAutoBrackets = $00000800;
|
|
|
|
+ efStoreContent = $80000000;
|
|
|
|
|
|
attrAsm = 1;
|
|
attrAsm = 1;
|
|
attrComment = 2;
|
|
attrComment = 2;
|
|
@@ -220,9 +215,10 @@ type
|
|
procedure LimitsChanged; virtual;
|
|
procedure LimitsChanged; virtual;
|
|
procedure SelectionChanged; virtual;
|
|
procedure SelectionChanged; virtual;
|
|
procedure HighlightChanged; virtual;
|
|
procedure HighlightChanged; virtual;
|
|
|
|
+ procedure Update; virtual;
|
|
procedure ScrollTo(X, Y: sw_Integer);
|
|
procedure ScrollTo(X, Y: sw_Integer);
|
|
procedure SetInsertMode(InsertMode: boolean); virtual;
|
|
procedure SetInsertMode(InsertMode: boolean); virtual;
|
|
- procedure SetCurPtr(X, Y: sw_Integer); virtual;
|
|
|
|
|
|
+ procedure SetCurPtr(X,Y: sw_integer); virtual;
|
|
procedure SetSelection(A, B: TPoint); virtual;
|
|
procedure SetSelection(A, B: TPoint); virtual;
|
|
procedure SetHighlight(A, B: TPoint); virtual;
|
|
procedure SetHighlight(A, B: TPoint); virtual;
|
|
procedure SetHighlightRow(Row: sw_integer); virtual;
|
|
procedure SetHighlightRow(Row: sw_integer); virtual;
|
|
@@ -233,6 +229,8 @@ type
|
|
function IsClipboard: Boolean;
|
|
function IsClipboard: Boolean;
|
|
constructor Load(var S: TStream);
|
|
constructor Load(var S: TStream);
|
|
procedure Store(var S: TStream);
|
|
procedure Store(var S: TStream);
|
|
|
|
+ function LoadFromStream(Stream: PStream): boolean; virtual;
|
|
|
|
+ function SaveToStream(Stream: PStream): boolean; virtual;
|
|
destructor Done; virtual;
|
|
destructor Done; virtual;
|
|
public
|
|
public
|
|
{ Text & info storage abstraction }
|
|
{ Text & info storage abstraction }
|
|
@@ -264,6 +262,7 @@ type
|
|
Bookmarks : array[0..9] of TEditorBookmark;
|
|
Bookmarks : array[0..9] of TEditorBookmark;
|
|
LockFlag : integer;
|
|
LockFlag : integer;
|
|
DrawCalled : boolean;
|
|
DrawCalled : boolean;
|
|
|
|
+ CurEvent : PEvent;
|
|
function Overwrite: boolean;
|
|
function Overwrite: boolean;
|
|
function GetLine(I: sw_integer): PLine;
|
|
function GetLine(I: sw_integer): PLine;
|
|
procedure CheckSels;
|
|
procedure CheckSels;
|
|
@@ -272,6 +271,7 @@ type
|
|
procedure DrawLines(FirstLine: sw_integer);
|
|
procedure DrawLines(FirstLine: sw_integer);
|
|
procedure HideHighlight;
|
|
procedure HideHighlight;
|
|
procedure AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: string);
|
|
procedure AddAction(AAction: byte; AStartPos, AEndPos: TPoint; AText: string);
|
|
|
|
+ function ShouldExtend: boolean;
|
|
function ValidBlock: boolean;
|
|
function ValidBlock: boolean;
|
|
public
|
|
public
|
|
{ Syntax highlight support }
|
|
{ Syntax highlight support }
|
|
@@ -1050,7 +1050,7 @@ end;
|
|
*****************************************************************************}
|
|
*****************************************************************************}
|
|
|
|
|
|
constructor TCodeEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
|
|
constructor TCodeEditor.Init(var Bounds: TRect; AHScrollBar, AVScrollBar:
|
|
- PScrollBar; AIndicator: PIndicator; AbufSize:Sw_Word);
|
|
|
|
|
|
+ PScrollBar; AIndicator: PIndicator; ABufSize:Sw_Word);
|
|
begin
|
|
begin
|
|
inherited Init(Bounds,AHScrollBar,AVScrollBar);
|
|
inherited Init(Bounds,AHScrollBar,AVScrollBar);
|
|
StoreUndo:=false;
|
|
StoreUndo:=false;
|
|
@@ -1105,7 +1105,7 @@ procedure TCodeEditor.UnLock;
|
|
begin
|
|
begin
|
|
{$ifdef DEBUG}
|
|
{$ifdef DEBUG}
|
|
if lockflag=0 then
|
|
if lockflag=0 then
|
|
- messagebox('Error: negative lockflag',nil,mferror+mfcancelbutton)
|
|
|
|
|
|
+ Bug('negative lockflag',nil)
|
|
else
|
|
else
|
|
{$endif DEBUG}
|
|
{$endif DEBUG}
|
|
Dec(LockFlag);
|
|
Dec(LockFlag);
|
|
@@ -1212,7 +1212,7 @@ var
|
|
begin
|
|
begin
|
|
if Event.What = evKeyDown then
|
|
if Event.What = evKeyDown then
|
|
begin
|
|
begin
|
|
- if (GetShiftState and kbShift <> 0) and
|
|
|
|
|
|
+ if (Event.KeyShift and kbShift <> 0) and
|
|
(Event.ScanCode >= $47) and (Event.ScanCode <= $51) then
|
|
(Event.ScanCode >= $47) and (Event.ScanCode <= $51) then
|
|
Event.CharCode := #0;
|
|
Event.CharCode := #0;
|
|
Key := Event.KeyCode;
|
|
Key := Event.KeyCode;
|
|
@@ -1259,7 +1259,10 @@ var DontClear : boolean;
|
|
|
|
|
|
var
|
|
var
|
|
StartP,P: TPoint;
|
|
StartP,P: TPoint;
|
|
|
|
+ E: TEvent;
|
|
begin
|
|
begin
|
|
|
|
+ E:=Event;
|
|
|
|
+ CurEvent:=@E;
|
|
if (InASCIIMode=false) or (Event.What<>evKeyDown) then
|
|
if (InASCIIMode=false) or (Event.What<>evKeyDown) then
|
|
ConvertEvent(Event);
|
|
ConvertEvent(Event);
|
|
case Event.What of
|
|
case Event.What of
|
|
@@ -1380,6 +1383,8 @@ begin
|
|
end;
|
|
end;
|
|
evBroadcast :
|
|
evBroadcast :
|
|
case Event.Command of
|
|
case Event.Command of
|
|
|
|
+ cmUpdate :
|
|
|
|
+ Update;
|
|
cmClearLineHighlights :
|
|
cmClearLineHighlights :
|
|
SetHighlightRow(-1);
|
|
SetHighlightRow(-1);
|
|
cmScrollBarChanged:
|
|
cmScrollBarChanged:
|
|
@@ -1392,6 +1397,15 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
inherited HandleEvent(Event);
|
|
inherited HandleEvent(Event);
|
|
|
|
+ CurEvent:=nil;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TCodeEditor.Update;
|
|
|
|
+begin
|
|
|
|
+ LimitsChanged;
|
|
|
|
+ SelectionChanged; HighlightChanged;
|
|
|
|
+ UpdateIndicator;
|
|
|
|
+ DrawView;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TCodeEditor.GetLocalMenu: PMenu;
|
|
function TCodeEditor.GetLocalMenu: PMenu;
|
|
@@ -2340,6 +2354,7 @@ var LineDelta, LineCount, CurLine: Sw_integer;
|
|
begin
|
|
begin
|
|
if IsReadOnly then Exit;
|
|
if IsReadOnly then Exit;
|
|
if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
|
|
if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
|
|
|
|
+ Lock;
|
|
LineCount:=(SelEnd.Y-SelStart.Y)+1;
|
|
LineCount:=(SelEnd.Y-SelStart.Y)+1;
|
|
LineDelta:=0; LastX:=CurPos.X;
|
|
LineDelta:=0; LastX:=CurPos.X;
|
|
CurLine:=SelStart.Y;
|
|
CurLine:=SelStart.Y;
|
|
@@ -2376,11 +2391,13 @@ begin
|
|
DrawLines(CurPos.Y);
|
|
DrawLines(CurPos.Y);
|
|
Modified:=true;
|
|
Modified:=true;
|
|
UpdateIndicator;
|
|
UpdateIndicator;
|
|
|
|
+ UnLock;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TCodeEditor.HideSelect;
|
|
procedure TCodeEditor.HideSelect;
|
|
begin
|
|
begin
|
|
SetSelection(CurPos,CurPos);
|
|
SetSelection(CurPos,CurPos);
|
|
|
|
+ DrawLines(Delta.Y);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TCodeEditor.CopyBlock;
|
|
procedure TCodeEditor.CopyBlock;
|
|
@@ -2901,9 +2918,14 @@ end;
|
|
because GetShitState tells to extend the
|
|
because GetShitState tells to extend the
|
|
selection which gives wrong results (PM) }
|
|
selection which gives wrong results (PM) }
|
|
|
|
|
|
-function ShouldExtend : boolean;
|
|
|
|
|
|
+function TCodeEditor.ShouldExtend: boolean;
|
|
|
|
+var ShiftInEvent: boolean;
|
|
begin
|
|
begin
|
|
- ShouldExtend:=((GetShiftState and kbShift)<>0) and
|
|
|
|
|
|
+ ShiftInEvent:=false;
|
|
|
|
+ if Assigned(CurEvent) then
|
|
|
|
+ if CurEvent^.What=evKeyDown then
|
|
|
|
+ ShiftInEvent:=((CurEvent^.KeyShift and kbShift)<>0);
|
|
|
|
+ ShouldExtend:=ShiftInEvent and
|
|
not DontConsiderShiftState;
|
|
not DontConsiderShiftState;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -2988,7 +3010,9 @@ var
|
|
|
|
|
|
var MatchedSymbol: boolean;
|
|
var MatchedSymbol: boolean;
|
|
MatchingSymbol: string;
|
|
MatchingSymbol: string;
|
|
- function MatchesAnySpecSymbol(What: string; SClass: TSpecSymbolClass; PartialMatch, CaseInsensitive: boolean): boolean;
|
|
|
|
|
|
+ type TPartialType = (pmNone,pmLeft,pmRight,pmAny);
|
|
|
|
+ function MatchesAnySpecSymbol(What: string; SClass: TSpecSymbolClass; PartialMatch: TPartialType;
|
|
|
|
+ CaseInsensitive: boolean): boolean;
|
|
var S: string;
|
|
var S: string;
|
|
I: Sw_integer;
|
|
I: Sw_integer;
|
|
Match,Found: boolean;
|
|
Match,Found: boolean;
|
|
@@ -3001,12 +3025,25 @@ var
|
|
begin
|
|
begin
|
|
SymbolIndex:=I;
|
|
SymbolIndex:=I;
|
|
S:=GetSpecSymbol(SClass,I-1);
|
|
S:=GetSpecSymbol(SClass,I-1);
|
|
- if CaseInsensitive then
|
|
|
|
- S:=UpcaseStr(S);
|
|
|
|
- if PartialMatch then Match:=MatchSymbol(What,S)
|
|
|
|
- else Match:=What=S;
|
|
|
|
|
|
+ if (length(What)<length(S)) or
|
|
|
|
+ ((PartialMatch=pmNone) and (length(S)<>length(What)))
|
|
|
|
+ then
|
|
|
|
+ Match:=false
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ if CaseInsensitive then
|
|
|
|
+ S:=UpcaseStr(S);
|
|
|
|
+ case PartialMatch of
|
|
|
|
+ pmNone : Match:=What=S;
|
|
|
|
+ pmRight:
|
|
|
|
+ Match:=copy(What,length(What)-length(S)+1,length(S))=S;
|
|
|
|
+ else Match:=MatchSymbol(What,S);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
if Match then
|
|
if Match then
|
|
- begin MatchingSymbol:=S; Found:=true; Break; end;
|
|
|
|
|
|
+ begin
|
|
|
|
+ MatchingSymbol:=S; Found:=true; Break;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
MatchedSymbol:=MatchedSymbol or Found;
|
|
MatchedSymbol:=MatchedSymbol or Found;
|
|
MatchesAnySpecSymbol:=Found;
|
|
MatchesAnySpecSymbol:=Found;
|
|
@@ -3014,48 +3051,48 @@ var
|
|
|
|
|
|
function IsCommentPrefix: boolean;
|
|
function IsCommentPrefix: boolean;
|
|
begin
|
|
begin
|
|
- IsCommentPrefix:=MatchesAnySpecSymbol(SymbolConcat,ssCommentPrefix,true,false);
|
|
|
|
|
|
+ IsCommentPrefix:=MatchesAnySpecSymbol(SymbolConcat,ssCommentPrefix,pmLeft,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
function IsSingleLineCommentPrefix: boolean;
|
|
function IsSingleLineCommentPrefix: boolean;
|
|
begin
|
|
begin
|
|
- IsSingleLineCommentPrefix:=MatchesAnySpecSymbol(SymbolConcat,ssCommentSingleLinePrefix,true,false);
|
|
|
|
|
|
+ IsSingleLineCommentPrefix:=MatchesAnySpecSymbol(SymbolConcat,ssCommentSingleLinePrefix,pmLeft,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
function IsCommentSuffix: boolean;
|
|
function IsCommentSuffix: boolean;
|
|
begin
|
|
begin
|
|
- IsCommentSuffix:=(MatchesAnySpecSymbol(SymbolConcat,ssCommentSuffix,true,false))
|
|
|
|
|
|
+ IsCommentSuffix:=(MatchesAnySpecSymbol(SymbolConcat,ssCommentSuffix,pmRight,false))
|
|
and (CurrentCommentType=SymbolIndex);
|
|
and (CurrentCommentType=SymbolIndex);
|
|
end;
|
|
end;
|
|
|
|
|
|
function IsStringPrefix: boolean;
|
|
function IsStringPrefix: boolean;
|
|
begin
|
|
begin
|
|
- IsStringPrefix:=MatchesAnySpecSymbol(SymbolConcat,ssStringPrefix,true,false);
|
|
|
|
|
|
+ IsStringPrefix:=MatchesAnySpecSymbol(SymbolConcat,ssStringPrefix,pmLeft,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
function IsStringSuffix: boolean;
|
|
function IsStringSuffix: boolean;
|
|
begin
|
|
begin
|
|
- IsStringSuffix:=MatchesAnySpecSymbol(SymbolConcat,ssStringSuffix,true,false);
|
|
|
|
|
|
+ IsStringSuffix:=MatchesAnySpecSymbol(SymbolConcat,ssStringSuffix,pmRight,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
function IsDirectivePrefix: boolean;
|
|
function IsDirectivePrefix: boolean;
|
|
begin
|
|
begin
|
|
- IsDirectivePrefix:=MatchesAnySpecSymbol(SymbolConcat,ssDirectivePrefix,true,false);
|
|
|
|
|
|
+ IsDirectivePrefix:=MatchesAnySpecSymbol(SymbolConcat,ssDirectivePrefix,pmLeft,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
function IsDirectiveSuffix: boolean;
|
|
function IsDirectiveSuffix: boolean;
|
|
begin
|
|
begin
|
|
- IsDirectiveSuffix:=MatchesAnySpecSymbol(SymbolConcat,ssDirectiveSuffix,true,false);
|
|
|
|
|
|
+ IsDirectiveSuffix:=MatchesAnySpecSymbol(SymbolConcat,ssDirectiveSuffix,pmRight,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
function IsAsmPrefix(const WordS: string): boolean;
|
|
function IsAsmPrefix(const WordS: string): boolean;
|
|
begin
|
|
begin
|
|
- IsAsmPrefix:=MatchesAnySpecSymbol(WordS,ssAsmPrefix,false,true);
|
|
|
|
|
|
+ IsAsmPrefix:=MatchesAnySpecSymbol(WordS,ssAsmPrefix,pmNone,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
function IsAsmSuffix(const WordS: string): boolean;
|
|
function IsAsmSuffix(const WordS: string): boolean;
|
|
begin
|
|
begin
|
|
- IsAsmSuffix:=MatchesAnySpecSymbol(WordS,ssAsmSuffix,false,true);
|
|
|
|
|
|
+ IsAsmSuffix:=MatchesAnySpecSymbol(WordS,ssAsmSuffix,pmNone,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
function GetCharClass(C: char): TCharClass;
|
|
function GetCharClass(C: char): TCharClass;
|
|
@@ -3263,6 +3300,7 @@ end;
|
|
|
|
|
|
procedure TCodeEditor.DrawLines(FirstLine: sw_integer);
|
|
procedure TCodeEditor.DrawLines(FirstLine: sw_integer);
|
|
begin
|
|
begin
|
|
|
|
+ if FirstLine>=(Delta.Y+Size.Y) then Exit; { falls outside of the screen }
|
|
DrawView;
|
|
DrawView;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -3409,6 +3447,12 @@ end;
|
|
procedure TCodeEditor.SelectionChanged;
|
|
procedure TCodeEditor.SelectionChanged;
|
|
var Enable,CanPaste: boolean;
|
|
var Enable,CanPaste: boolean;
|
|
begin
|
|
begin
|
|
|
|
+ if SelEnd.Y>GetLineCount-1 then
|
|
|
|
+ begin
|
|
|
|
+ SelEnd.Y:=GetLineCount-1;
|
|
|
|
+ SelEnd.X:=length(GetDisplayText(SelEnd.Y));
|
|
|
|
+ end;
|
|
|
|
+
|
|
Enable:=((SelStart.X<>SelEnd.X) or (SelStart.Y<>SelEnd.Y)) and (Clipboard<>nil);
|
|
Enable:=((SelStart.X<>SelEnd.X) or (SelStart.Y<>SelEnd.Y)) and (Clipboard<>nil);
|
|
SetCmdState(ToClipCmds,Enable and (Clipboard<>@Self));
|
|
SetCmdState(ToClipCmds,Enable and (Clipboard<>@Self));
|
|
SetCmdState(NulClipCmds,Enable);
|
|
SetCmdState(NulClipCmds,Enable);
|
|
@@ -3437,6 +3481,8 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
constructor TCodeEditor.Load(var S: TStream);
|
|
constructor TCodeEditor.Load(var S: TStream);
|
|
|
|
+var TS: PSubStream;
|
|
|
|
+ TSize: longint;
|
|
begin
|
|
begin
|
|
inherited Load(S);
|
|
inherited Load(S);
|
|
|
|
|
|
@@ -3446,6 +3492,17 @@ begin
|
|
Lines^.Insert(NewLine(''));
|
|
Lines^.Insert(NewLine(''));
|
|
|
|
|
|
GetPeerViewPtr(S,Indicator);
|
|
GetPeerViewPtr(S,Indicator);
|
|
|
|
+ S.Read(Flags,SizeOf(Flags));
|
|
|
|
+ S.Read(TabSize,SizeOf(TabSize));
|
|
|
|
+
|
|
|
|
+ if (Flags and efStoreContent)<>0 then
|
|
|
|
+ begin
|
|
|
|
+ S.Read(TSize,SizeOf(TSize));
|
|
|
|
+ New(TS, Init(@S,S.GetPos,TSize));
|
|
|
|
+ LoadFromStream(TS);
|
|
|
|
+ Dispose(TS, Done);
|
|
|
|
+ end;
|
|
|
|
+
|
|
S.Read(SelStart,SizeOf(SelStart));
|
|
S.Read(SelStart,SizeOf(SelStart));
|
|
S.Read(SelEnd,SizeOf(SelEnd));
|
|
S.Read(SelEnd,SizeOf(SelEnd));
|
|
S.Read(Highlight,SizeOf(Highlight));
|
|
S.Read(Highlight,SizeOf(Highlight));
|
|
@@ -3453,17 +3510,34 @@ begin
|
|
S.Read(StoreUndo,SizeOf(StoreUndo));
|
|
S.Read(StoreUndo,SizeOf(StoreUndo));
|
|
S.Read(IsReadOnly,SizeOf(IsReadOnly));
|
|
S.Read(IsReadOnly,SizeOf(IsReadOnly));
|
|
S.Read(NoSelect,SizeOf(NoSelect));
|
|
S.Read(NoSelect,SizeOf(NoSelect));
|
|
- S.Read(Flags,SizeOf(Flags));
|
|
|
|
- S.Read(TabSize,SizeOf(TabSize));
|
|
|
|
S.Read(HighlightRow,SizeOf(HighlightRow));
|
|
S.Read(HighlightRow,SizeOf(HighlightRow));
|
|
|
|
|
|
- UpdateIndicator; LimitsChanged;
|
|
|
|
|
|
+ LimitsChanged;
|
|
|
|
+ SelectionChanged; HighlightChanged;
|
|
|
|
+ UpdateIndicator;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TCodeEditor.Store(var S: TStream);
|
|
procedure TCodeEditor.Store(var S: TStream);
|
|
|
|
+var NS: TNulStream;
|
|
|
|
+ TSize: longint;
|
|
begin
|
|
begin
|
|
inherited Store(S);
|
|
inherited Store(S);
|
|
|
|
+
|
|
PutPeerViewPtr(S,Indicator);
|
|
PutPeerViewPtr(S,Indicator);
|
|
|
|
+ S.Write(Flags,SizeOf(Flags));
|
|
|
|
+ S.Write(TabSize,SizeOf(TabSize));
|
|
|
|
+
|
|
|
|
+ if (Flags and efStoreContent)<>0 then
|
|
|
|
+ begin
|
|
|
|
+ NS.Init;
|
|
|
|
+ SaveToStream(@NS);
|
|
|
|
+ TSize:=NS.GetSize;
|
|
|
|
+ NS.Done;
|
|
|
|
+
|
|
|
|
+ S.Write(TSize,SizeOf(TSize));
|
|
|
|
+ SaveToStream(@S);
|
|
|
|
+ end;
|
|
|
|
+
|
|
S.Write(SelStart,SizeOf(SelStart));
|
|
S.Write(SelStart,SizeOf(SelStart));
|
|
S.Write(SelEnd,SizeOf(SelEnd));
|
|
S.Write(SelEnd,SizeOf(SelEnd));
|
|
S.Write(Highlight,SizeOf(Highlight));
|
|
S.Write(Highlight,SizeOf(Highlight));
|
|
@@ -3471,11 +3545,55 @@ begin
|
|
S.Write(StoreUndo,SizeOf(StoreUndo));
|
|
S.Write(StoreUndo,SizeOf(StoreUndo));
|
|
S.Write(IsReadOnly,SizeOf(IsReadOnly));
|
|
S.Write(IsReadOnly,SizeOf(IsReadOnly));
|
|
S.Write(NoSelect,SizeOf(NoSelect));
|
|
S.Write(NoSelect,SizeOf(NoSelect));
|
|
- S.Write(Flags,SizeOf(Flags));
|
|
|
|
- S.Write(TabSize,SizeOf(TabSize));
|
|
|
|
S.Write(HighlightRow,SizeOf(HighlightRow));
|
|
S.Write(HighlightRow,SizeOf(HighlightRow));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TCodeEditor.LoadFromStream(Stream: PStream): boolean;
|
|
|
|
+var S: string;
|
|
|
|
+ OK: boolean;
|
|
|
|
+ Line: Sw_integer;
|
|
|
|
+begin
|
|
|
|
+ DeleteAllLines;
|
|
|
|
+ OK:=(Stream^.Status=stOK);
|
|
|
|
+ if eofstream(Stream) then
|
|
|
|
+ AddLine('')
|
|
|
|
+ else
|
|
|
|
+ while OK and (eofstream(Stream)=false) and (GetLineCount<MaxLineCount) do
|
|
|
|
+ begin
|
|
|
|
+ readlnfromstream(Stream,S);
|
|
|
|
+ OK:=OK and (Stream^.Status=stOK);
|
|
|
|
+ if OK then AddLine(S);
|
|
|
|
+ end;
|
|
|
|
+ LimitsChanged;
|
|
|
|
+ if (Flags and efSyntaxHighlight)<>0 then
|
|
|
|
+ UpdateAttrsRange(0,GetLineCount-1,attrAll+attrForceFull);
|
|
|
|
+ TextStart;
|
|
|
|
+ LoadFromStream:=OK;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TCodeEditor.SaveToStream(Stream: PStream): boolean;
|
|
|
|
+var S: string;
|
|
|
|
+ OK: boolean;
|
|
|
|
+ Line: Sw_integer;
|
|
|
|
+ P: PLine;
|
|
|
|
+ EOL: string[2];
|
|
|
|
+begin
|
|
|
|
+ {$ifdef Linux}EOL:=#10;{$else}EOL:=#13#10;{$endif}
|
|
|
|
+ OK:=(Stream^.Status=stOK); Line:=0;
|
|
|
|
+ while OK and (Line<GetLineCount) do
|
|
|
|
+ begin
|
|
|
|
+ P:=Lines^.At(Line);
|
|
|
|
+ if P^.Text=nil then S:='' else S:=P^.Text^;
|
|
|
|
+ if (Flags and efUseTabCharacters)<>0 then
|
|
|
|
+ S:=CompressUsingTabs(S,TabSize);
|
|
|
|
+ Stream^.Write(S[1],length(S));
|
|
|
|
+ Stream^.Write(EOL[1],length(EOL));
|
|
|
|
+ Inc(Line);
|
|
|
|
+ OK:=OK and (Stream^.Status=stOK);
|
|
|
|
+ end;
|
|
|
|
+ SaveToStream:=OK;
|
|
|
|
+end;
|
|
|
|
+
|
|
destructor TCodeEditor.Done;
|
|
destructor TCodeEditor.Done;
|
|
begin
|
|
begin
|
|
inherited Done;
|
|
inherited Done;
|
|
@@ -3500,7 +3618,7 @@ begin
|
|
Message(@Self,evBroadcast,cmFileNameChanged,@Self);
|
|
Message(@Self,evBroadcast,cmFileNameChanged,@Self);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TFileEditor.LoadFile: boolean;
|
|
|
|
|
|
+(*function TFileEditor.LoadFile: boolean;
|
|
var S: string;
|
|
var S: string;
|
|
OK: boolean;
|
|
OK: boolean;
|
|
f: text;
|
|
f: text;
|
|
@@ -3510,6 +3628,7 @@ begin
|
|
DeleteAllLines;
|
|
DeleteAllLines;
|
|
GetMem(Buf,EditorTextBufSize);
|
|
GetMem(Buf,EditorTextBufSize);
|
|
{$I-}
|
|
{$I-}
|
|
|
|
+ EatIO;
|
|
FM:=FileMode; FileMode:=0;
|
|
FM:=FileMode; FileMode:=0;
|
|
Assign(f,FileName);
|
|
Assign(f,FileName);
|
|
SetTextBuf(f,Buf^,EditorTextBufSize);
|
|
SetTextBuf(f,Buf^,EditorTextBufSize);
|
|
@@ -3529,25 +3648,31 @@ begin
|
|
EatIO;
|
|
EatIO;
|
|
{$I+}
|
|
{$I+}
|
|
LimitsChanged;
|
|
LimitsChanged;
|
|
- Line:=-1;
|
|
|
|
- repeat
|
|
|
|
- Line:=UpdateAttrs(Line+1,attrAll+attrForceFull);
|
|
|
|
- until Line>=GetLineCount-1;
|
|
|
|
|
|
+ if (Flags and efSyntaxHighlight)<>0 then
|
|
|
|
+ UpdateAttrsRange(0,GetLineCount-1,attrAll+attrForceFull);
|
|
TextStart;
|
|
TextStart;
|
|
LoadFile:=OK;
|
|
LoadFile:=OK;
|
|
FreeMem(Buf,EditorTextBufSize);
|
|
FreeMem(Buf,EditorTextBufSize);
|
|
|
|
+end;*)
|
|
|
|
+
|
|
|
|
+function TFileEditor.LoadFile: boolean;
|
|
|
|
+var S: PBufStream;
|
|
|
|
+ OK: boolean;
|
|
|
|
+begin
|
|
|
|
+ New(S, Init(FileName,stOpenRead,EditorTextBufSize));
|
|
|
|
+ OK:=Assigned(S);
|
|
|
|
+ if OK then OK:=LoadFromStream(S);
|
|
|
|
+ if Assigned(S) then Dispose(S, Done);
|
|
|
|
+
|
|
|
|
+ LoadFile:=OK;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TFileEditor.SaveFile: boolean;
|
|
function TFileEditor.SaveFile: boolean;
|
|
-var S: string;
|
|
|
|
- OK: boolean;
|
|
|
|
- f: text;
|
|
|
|
- Line: Sw_integer;
|
|
|
|
- P: PLine;
|
|
|
|
|
|
+var OK: boolean;
|
|
BAKName: string;
|
|
BAKName: string;
|
|
- Buf : Pointer;
|
|
|
|
|
|
+ S: PBufStream;
|
|
|
|
+ f: text;
|
|
begin
|
|
begin
|
|
- GetMem(Buf,EditorTextBufSize);
|
|
|
|
{$I-}
|
|
{$I-}
|
|
if (Flags and efBackupFiles)<>0 then
|
|
if (Flags and efBackupFiles)<>0 then
|
|
begin
|
|
begin
|
|
@@ -3559,26 +3684,13 @@ begin
|
|
Rename(F,BAKName);
|
|
Rename(F,BAKName);
|
|
EatIO;
|
|
EatIO;
|
|
end;
|
|
end;
|
|
- Assign(f,FileName);
|
|
|
|
- Rewrite(f);
|
|
|
|
- SetTextBuf(f,Buf^,EditorTextBufSize);
|
|
|
|
- OK:=(IOResult=0); Line:=0;
|
|
|
|
- while OK and (Line<GetLineCount) do
|
|
|
|
- begin
|
|
|
|
- P:=Lines^.At(Line);
|
|
|
|
- if P^.Text=nil then S:='' else S:=P^.Text^;
|
|
|
|
- if (Flags and efUseTabCharacters)<>0 then
|
|
|
|
- S:=CompressUsingTabs(S,TabSize);
|
|
|
|
- writeln(f,S);
|
|
|
|
- Inc(Line);
|
|
|
|
- OK:=OK and (IOResult=0);
|
|
|
|
- end;
|
|
|
|
- Close(F);
|
|
|
|
- EatIO;
|
|
|
|
{$I+}
|
|
{$I+}
|
|
|
|
+ New(S, Init(FileName,stCreate,EditorTextBufSize));
|
|
|
|
+ OK:=Assigned(S);
|
|
|
|
+ if OK then OK:=SaveToStream(S);
|
|
|
|
+ if Assigned(S) then Dispose(S, Done);
|
|
if OK then begin Modified:=false; UpdateIndicator; end;
|
|
if OK then begin Modified:=false; UpdateIndicator; end;
|
|
SaveFile:=OK;
|
|
SaveFile:=OK;
|
|
- FreeMem(Buf,EditorTextBufSize);
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
function TFileEditor.ShouldSave: boolean;
|
|
function TFileEditor.ShouldSave: boolean;
|
|
@@ -3661,6 +3773,8 @@ end;
|
|
|
|
|
|
constructor TFileEditor.Load(var S: TStream);
|
|
constructor TFileEditor.Load(var S: TStream);
|
|
var P: PString;
|
|
var P: PString;
|
|
|
|
+ SSP,SEP,CP,DP: TPoint;
|
|
|
|
+ HR: TRect;
|
|
begin
|
|
begin
|
|
inherited Load(S);
|
|
inherited Load(S);
|
|
P:=S.ReadStr;
|
|
P:=S.ReadStr;
|
|
@@ -3668,7 +3782,23 @@ begin
|
|
if P<>nil then DisposeStr(P);
|
|
if P<>nil then DisposeStr(P);
|
|
|
|
|
|
UpdateIndicator;
|
|
UpdateIndicator;
|
|
- Message(@Self,evBroadcast,cmFileNameChanged,@Self);
|
|
|
|
|
|
+{ Message(@Self,evBroadcast,cmFileNameChanged,@Self);}
|
|
|
|
+
|
|
|
|
+ SSP:=SelStart; SEP:=SelEnd;
|
|
|
|
+ CP:=CurPos;
|
|
|
|
+ HR:=Highlight;
|
|
|
|
+ DP:=Delta;
|
|
|
|
+
|
|
|
|
+ if FileName<>'' then
|
|
|
|
+ LoadFile;
|
|
|
|
+
|
|
|
|
+ SetHighlight(HR.A,HR.B);
|
|
|
|
+ SetSelection(SSP,SEP);
|
|
|
|
+ SetCurPtr(CP.X,CP.Y);
|
|
|
|
+ ScrollTo(DP.X,DP.Y);
|
|
|
|
+ Modified:=false;
|
|
|
|
+
|
|
|
|
+ LimitsChanged; UpdateIndicator;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TFileEditor.Store(var S: TStream);
|
|
procedure TFileEditor.Store(var S: TStream);
|
|
@@ -3677,7 +3807,6 @@ begin
|
|
S.WriteStr(@FileName);
|
|
S.WriteStr(@FileName);
|
|
end;
|
|
end;
|
|
|
|
|
|
-
|
|
|
|
function CreateFindDialog: PDialog;
|
|
function CreateFindDialog: PDialog;
|
|
var R,R1,R2: TRect;
|
|
var R,R1,R2: TRect;
|
|
D: PDialog;
|
|
D: PDialog;
|
|
@@ -3959,7 +4088,29 @@ end;
|
|
END.
|
|
END.
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.39 1999-07-28 23:11:26 peter
|
|
|
|
|
|
+ Revision 1.40 1999-08-03 20:22:42 peter
|
|
|
|
+ + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
|
|
|
|
+ + Desktop saving should work now
|
|
|
|
+ - History saved
|
|
|
|
+ - Clipboard content saved
|
|
|
|
+ - Desktop saved
|
|
|
|
+ - Symbol info saved
|
|
|
|
+ * syntax-highlight bug fixed, which compared special keywords case sensitive
|
|
|
|
+ (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
|
|
|
|
+ * with 'whole words only' set, the editor didn't found occourences of the
|
|
|
|
+ searched text, if the text appeared previously in the same line, but didn't
|
|
|
|
+ satisfied the 'whole-word' condition
|
|
|
|
+ * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
|
|
|
|
+ (ie. the beginning of the selection)
|
|
|
|
+ * when started typing in a new line, but not at the start (X=0) of it,
|
|
|
|
+ the editor inserted the text one character more to left as it should...
|
|
|
|
+ * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
|
|
|
|
+ * Shift shouldn't cause so much trouble in TCodeEditor now...
|
|
|
|
+ * Syntax highlight had problems recognizing a special symbol if it was
|
|
|
|
+ prefixed by another symbol character in the source text
|
|
|
|
+ * Auto-save also occours at Dos shell, Tool execution, etc. now...
|
|
|
|
+
|
|
|
|
+ Revision 1.39 1999/07/28 23:11:26 peter
|
|
* fixes from gabor
|
|
* fixes from gabor
|
|
|
|
|
|
Revision 1.38 1999/07/12 13:14:24 pierre
|
|
Revision 1.38 1999/07/12 13:14:24 pierre
|