|
@@ -1,22 +1,15 @@
|
|
{
|
|
{
|
|
- $Id$
|
|
|
|
|
|
+ $Id$
|
|
|
|
|
|
- "shedit" - Text editor with syntax highlighting
|
|
|
|
- Copyright (C) 1999 Sebastian Guenther ([email protected])
|
|
|
|
|
|
+ "SHEdit" - Text editor with syntax highlighting
|
|
|
|
+ Copyright (C) 1999 Sebastian Guenther ([email protected])
|
|
|
|
|
|
- This program is free software; you can redistribute it and/or modify
|
|
|
|
- it under the terms of the GNU General Public License as published by
|
|
|
|
- the Free Software Foundation; either version 2 of the License, or
|
|
|
|
- (at your option) any later version.
|
|
|
|
|
|
+ See the file COPYING.FPC, included in this distribution,
|
|
|
|
+ for details about the copyright.
|
|
|
|
|
|
- This program is distributed in the hope that it will be useful,
|
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
- GNU General Public License for more details.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the GNU General Public License
|
|
|
|
- along with this program; if not, write to the Free Software
|
|
|
|
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
+ This program is distributed in the hope that it will be useful,
|
|
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
}
|
|
}
|
|
|
|
|
|
// ===================================================================
|
|
// ===================================================================
|
|
@@ -36,6 +29,7 @@ uses
|
|
type
|
|
type
|
|
|
|
|
|
TSHTextEdit = class;
|
|
TSHTextEdit = class;
|
|
|
|
+ TSHTextEditClass = class of TSHTextEdit;
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
// -------------------------------------------------------------------
|
|
@@ -114,19 +108,17 @@ type
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
// -------------------------------------------------------------------
|
|
-// SHRenderer interface
|
|
|
|
|
|
+// SHWidget interface
|
|
// -------------------------------------------------------------------
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
- ISHRenderer = class
|
|
|
|
-
|
|
|
|
|
|
+ ISHWidget = class
|
|
|
|
+ // Drawing
|
|
procedure InvalidateRect(x1, y1, x2, y2: Integer); virtual; abstract;
|
|
procedure InvalidateRect(x1, y1, x2, y2: Integer); virtual; abstract;
|
|
procedure InvalidateLines(y1, y2: Integer); virtual; abstract;
|
|
procedure InvalidateLines(y1, y2: Integer); virtual; abstract;
|
|
-
|
|
|
|
- // Drawing
|
|
|
|
procedure ClearRect(x1, y1, x2, y2: Integer); virtual; abstract;
|
|
procedure ClearRect(x1, y1, x2, y2: Integer); virtual; abstract;
|
|
procedure DrawTextLine(x1, x2, y: Integer; s: PChar); virtual; abstract;
|
|
procedure DrawTextLine(x1, x2, y: Integer; s: PChar); virtual; abstract;
|
|
|
|
|
|
- // Cursor
|
|
|
|
|
|
+ // Cursor placement
|
|
procedure ShowCursor(x, y: Integer); virtual; abstract;
|
|
procedure ShowCursor(x, y: Integer); virtual; abstract;
|
|
procedure HideCursor(x, y: Integer); virtual; abstract;
|
|
procedure HideCursor(x, y: Integer); virtual; abstract;
|
|
|
|
|
|
@@ -141,16 +133,19 @@ type
|
|
procedure SetLineWidth(count: Integer); virtual; abstract;
|
|
procedure SetLineWidth(count: Integer); virtual; abstract;
|
|
function GetLineCount: Integer; virtual; abstract;
|
|
function GetLineCount: Integer; virtual; abstract;
|
|
procedure SetLineCount(count: Integer); virtual; abstract;
|
|
procedure SetLineCount(count: Integer); virtual; abstract;
|
|
|
|
+
|
|
|
|
+ // Clipboard support
|
|
|
|
+ function GetClipboard: String; virtual; abstract;
|
|
|
|
+ procedure SetClipboard(Content: String); virtual; abstract;
|
|
|
|
+
|
|
|
|
+
|
|
property HorzPos: Integer read GetHorzPos write SetHorzPos;
|
|
property HorzPos: Integer read GetHorzPos write SetHorzPos;
|
|
property VertPos: Integer read GetVertPos write SetVertPos;
|
|
property VertPos: Integer read GetVertPos write SetVertPos;
|
|
property PageWidth: Integer read GetPageWidth;
|
|
property PageWidth: Integer read GetPageWidth;
|
|
property PageHeight: Integer read GetPageHeight;
|
|
property PageHeight: Integer read GetPageHeight;
|
|
property LineWidth: Integer read GetLineWidth write SetLineWidth;
|
|
property LineWidth: Integer read GetLineWidth write SetLineWidth;
|
|
property LineCount: Integer read GetLineCount write SetLineCount;
|
|
property LineCount: Integer read GetLineCount write SetLineCount;
|
|
-
|
|
|
|
- // Clipboard support
|
|
|
|
- function GetClipboard: String; virtual; abstract;
|
|
|
|
- procedure SetClipboard(Content: String); virtual; abstract;
|
|
|
|
|
|
+ property Clipboard: String read GetClipboard write SetClipboard;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -189,7 +184,7 @@ type
|
|
FDoc: TTextDoc; // Document object for text
|
|
FDoc: TTextDoc; // Document object for text
|
|
FCursorX, FCursorY: Integer; // 0/0 = upper left corner
|
|
FCursorX, FCursorY: Integer; // 0/0 = upper left corner
|
|
FOnModifiedChange: TNotifyEvent;
|
|
FOnModifiedChange: TNotifyEvent;
|
|
- FRenderer: ISHRenderer;
|
|
|
|
|
|
+ FWidget: ISHWidget;
|
|
|
|
|
|
procedure SetCursorX(NewCursorX: Integer);
|
|
procedure SetCursorX(NewCursorX: Integer);
|
|
procedure SetCursorY(NewCursorY: Integer);
|
|
procedure SetCursorY(NewCursorY: Integer);
|
|
@@ -233,7 +228,7 @@ type
|
|
procedure KeyReturn; virtual;
|
|
procedure KeyReturn; virtual;
|
|
|
|
|
|
public
|
|
public
|
|
- constructor Create(ADoc: TTextDoc; ARenderer: ISHRenderer); virtual;
|
|
|
|
|
|
+ constructor Create(ADoc: TTextDoc; AWidget: ISHWidget); virtual;
|
|
function AddKeyboardAction(AMethod: TKeyboardActionProc;ASelectionAction:TSelectionAction;ADescr: String): TKeyboardActionDescr;
|
|
function AddKeyboardAction(AMethod: TKeyboardActionProc;ASelectionAction:TSelectionAction;ADescr: String): TKeyboardActionDescr;
|
|
function AddKeyboardAssignment(AKeyCode: Integer; AShiftState: TShiftState;
|
|
function AddKeyboardAssignment(AKeyCode: Integer; AShiftState: TShiftState;
|
|
AAction: TKeyboardActionDescr): TShortcut;
|
|
AAction: TKeyboardActionDescr): TShortcut;
|
|
@@ -255,7 +250,7 @@ type
|
|
property Selection: TSelection read FSel write FSel;
|
|
property Selection: TSelection read FSel write FSel;
|
|
property OnModifiedChange: TNotifyEvent
|
|
property OnModifiedChange: TNotifyEvent
|
|
read FOnModifiedChange write FOnModifiedChange;
|
|
read FOnModifiedChange write FOnModifiedChange;
|
|
- property Renderer: ISHRenderer read FRenderer;
|
|
|
|
|
|
+ property Widget: ISHWidget read FWidget;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -325,28 +320,28 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-constructor TSHTextEdit.Create(ADoc: TTextDoc; ARenderer: ISHRenderer);
|
|
|
|
|
|
+constructor TSHTextEdit.Create(ADoc: TTextDoc; AWidget: ISHWidget);
|
|
var
|
|
var
|
|
i: Integer;
|
|
i: Integer;
|
|
begin
|
|
begin
|
|
|
|
+ ASSERT(Assigned(ADoc) and Assigned(AWidget));
|
|
|
|
+
|
|
FDoc := ADoc;
|
|
FDoc := ADoc;
|
|
- // The document must not be empty
|
|
|
|
- if FDoc.LineCount = 0 then
|
|
|
|
- FDoc.AddLine('');
|
|
|
|
|
|
+
|
|
ViewInfo := TViewInfo(FDoc.ViewInfos.Add);
|
|
ViewInfo := TViewInfo(FDoc.ViewInfos.Add);
|
|
ViewInfo.OnLineInsert := @LineInserted;
|
|
ViewInfo.OnLineInsert := @LineInserted;
|
|
ViewInfo.OnLineRemove := @LineRemoved;
|
|
ViewInfo.OnLineRemove := @LineRemoved;
|
|
ViewInfo.OnModifiedChange := @ModifiedChanged;
|
|
ViewInfo.OnModifiedChange := @ModifiedChanged;
|
|
|
|
|
|
- FRenderer := ARenderer;
|
|
|
|
|
|
+ FWidget := AWidget;
|
|
|
|
|
|
FSel := TSelection.Create;
|
|
FSel := TSelection.Create;
|
|
|
|
|
|
KeyboardActions := TCollection.Create(TKeyboardActionDescr);
|
|
KeyboardActions := TCollection.Create(TKeyboardActionDescr);
|
|
Shortcuts := TCollection.Create(TShortcut);
|
|
Shortcuts := TCollection.Create(TShortcut);
|
|
|
|
|
|
- Renderer.LineCount := FDoc.LineCount;
|
|
|
|
- Renderer.LineWidth := FDoc.LineWidth;
|
|
|
|
|
|
+ Widget.LineCount := FDoc.LineCount;
|
|
|
|
+ Widget.LineWidth := FDoc.LineWidth;
|
|
CursorX:=0;
|
|
CursorX:=0;
|
|
CursorY:=0;
|
|
CursorY:=0;
|
|
end;
|
|
end;
|
|
@@ -391,8 +386,8 @@ end;
|
|
|
|
|
|
procedure TSHTextEdit.LineInserted(Sender: TTextDoc; Line: Integer);
|
|
procedure TSHTextEdit.LineInserted(Sender: TTextDoc; Line: Integer);
|
|
begin
|
|
begin
|
|
- Renderer.LineCount := FDoc.LineCount;
|
|
|
|
- Renderer.LineWidth := FDoc.LineWidth;
|
|
|
|
|
|
+ Widget.LineCount := FDoc.LineCount;
|
|
|
|
+ Widget.LineWidth := FDoc.LineWidth;
|
|
ChangeInLine(Line);
|
|
ChangeInLine(Line);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -407,10 +402,9 @@ end.
|
|
|
|
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.7 1999-12-23 09:47:09 sg
|
|
|
|
- * Calling SetCursorX or SetCursorY with negative values will result in
|
|
|
|
- setting these coordinates to 0 instead (as negative cursor coordinates
|
|
|
|
- are impossible)
|
|
|
|
|
|
+ Revision 1.8 1999-12-30 21:12:43 sg
|
|
|
|
+ * Support for empty documents (0 lines)
|
|
|
|
+ * Renaming of *Renderer to *Widget
|
|
|
|
|
|
Revision 1.6 1999/12/22 22:28:09 peter
|
|
Revision 1.6 1999/12/22 22:28:09 peter
|
|
* updates for cursor setting
|
|
* updates for cursor setting
|