mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 14:29:14 +02:00
* cursor walking is now possible, both horz and vert ranges are now
adapted * filter key modifiers * selection move routines added, but still no correct output to the screen
This commit is contained in:
parent
038c73aed0
commit
eaf3767d85
@ -73,6 +73,7 @@ type
|
|||||||
TTextDoc = class
|
TTextDoc = class
|
||||||
protected
|
protected
|
||||||
FModified: Boolean;
|
FModified: Boolean;
|
||||||
|
FLineWidth,
|
||||||
FLineCount: LongInt;
|
FLineCount: LongInt;
|
||||||
FLines: PLineArray;
|
FLines: PLineArray;
|
||||||
FViewInfos: TCollection;
|
FViewInfos: TCollection;
|
||||||
@ -93,6 +94,7 @@ type
|
|||||||
procedure RemoveLine(LineNumber: Integer);
|
procedure RemoveLine(LineNumber: Integer);
|
||||||
|
|
||||||
property Modified: Boolean read FModified write SetModified;
|
property Modified: Boolean read FModified write SetModified;
|
||||||
|
property LineWidth: Integer read FLineWidth;
|
||||||
property LineCount: Integer read FLineCount;
|
property LineCount: Integer read FLineCount;
|
||||||
property LineText[LineNumber: Integer]: String
|
property LineText[LineNumber: Integer]: String
|
||||||
read GetLineText write SetLineText;
|
read GetLineText write SetLineText;
|
||||||
@ -113,6 +115,7 @@ begin
|
|||||||
FModified := false;
|
FModified := false;
|
||||||
FLines := nil;
|
FLines := nil;
|
||||||
FLineCount := 0;
|
FLineCount := 0;
|
||||||
|
FLineWidth := 0;
|
||||||
FViewInfos := TCollection.Create(TViewInfo);
|
FViewInfos := TCollection.Create(TViewInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -130,6 +133,9 @@ begin
|
|||||||
if assigned(FLines) then
|
if assigned(FLines) then
|
||||||
FreeMem(FLines);
|
FreeMem(FLines);
|
||||||
|
|
||||||
|
FLineCount:=0;
|
||||||
|
FLineWidth:=0;
|
||||||
|
|
||||||
for i := 0 to FViewInfos.Count - 1 do
|
for i := 0 to FViewInfos.Count - 1 do
|
||||||
if Assigned(TViewInfo(FViewInfos.Items[i]).OnLineRemove) then
|
if Assigned(TViewInfo(FViewInfos.Items[i]).OnLineRemove) then
|
||||||
TViewInfo(FViewInfos.Items[i]).OnLineRemove(Self, 0);
|
TViewInfo(FViewInfos.Items[i]).OnLineRemove(Self, 0);
|
||||||
@ -140,14 +146,18 @@ var
|
|||||||
l: PLine;
|
l: PLine;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if BeforeLine > FLineCount then exit; // *** throw an intelligent exception
|
if BeforeLine > FLineCount then
|
||||||
|
exit; // *** throw an intelligent exception
|
||||||
ReAllocMem(FLines, (FLineCount + 1) * SizeOf(TLine));
|
ReAllocMem(FLines, (FLineCount + 1) * SizeOf(TLine));
|
||||||
Move(FLines^[BeforeLine], FLines^[BeforeLine + 1],(FLineCount - BeforeLine) * SizeOf(TLine));
|
Move(FLines^[BeforeLine], FLines^[BeforeLine + 1],(FLineCount - BeforeLine) * SizeOf(TLine));
|
||||||
l := @(FLines^[BeforeLine]);
|
l := @(FLines^[BeforeLine]);
|
||||||
FillChar(l^, SizeOf(TLine), 0);
|
FillChar(l^, SizeOf(TLine), 0);
|
||||||
l^.len := Length(s);
|
l^.len := Length(s);
|
||||||
l^.s := StrNew(PChar(s));
|
l^.s := StrNew(PChar(s));
|
||||||
|
|
||||||
Inc(FLineCount);
|
Inc(FLineCount);
|
||||||
|
if l^.Len>FLineWidth then
|
||||||
|
FLineWidth:=l^.len;
|
||||||
|
|
||||||
for i := 0 to FViewInfos.Count - 1 do
|
for i := 0 to FViewInfos.Count - 1 do
|
||||||
if Assigned(TViewInfo(FViewInfos.Items[i]).OnLineInsert) then
|
if Assigned(TViewInfo(FViewInfos.Items[i]).OnLineInsert) then
|
||||||
@ -225,6 +235,8 @@ begin
|
|||||||
StrDispose(FLines^[LineNumber].s);
|
StrDispose(FLines^[LineNumber].s);
|
||||||
FLines^[LineNumber].len := Length(NewText);
|
FLines^[LineNumber].len := Length(NewText);
|
||||||
FLines^[LineNumber].s := StrNew(PChar(NewText));
|
FLines^[LineNumber].s := StrNew(PChar(NewText));
|
||||||
|
if Length(NewText)>FLineWidth then
|
||||||
|
FLineWidth:=Length(NewText);
|
||||||
Modified := True;
|
Modified := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -256,7 +268,14 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.2 1999-11-14 21:32:55 peter
|
Revision 1.3 1999-12-09 23:16:41 peter
|
||||||
|
* cursor walking is now possible, both horz and vert ranges are now
|
||||||
|
adapted
|
||||||
|
* filter key modifiers
|
||||||
|
* selection move routines added, but still no correct output to the
|
||||||
|
screen
|
||||||
|
|
||||||
|
Revision 1.2 1999/11/14 21:32:55 peter
|
||||||
* fixes to get it working without crashes
|
* fixes to get it working without crashes
|
||||||
|
|
||||||
Revision 1.1 1999/10/29 15:59:03 peter
|
Revision 1.1 1999/10/29 15:59:03 peter
|
||||||
|
@ -99,9 +99,15 @@ type
|
|||||||
procedure HideCursor(x, y: Integer); override;
|
procedure HideCursor(x, y: Integer); override;
|
||||||
|
|
||||||
// Scrolling support
|
// Scrolling support
|
||||||
|
function GetHorzPos: Integer; override;
|
||||||
|
procedure SetHorzPos(x: Integer); override;
|
||||||
function GetVertPos: Integer; override;
|
function GetVertPos: Integer; override;
|
||||||
procedure SetVertPos(y: Integer); override;
|
procedure SetVertPos(y: Integer); override;
|
||||||
|
function GetPageWidth: Integer; override;
|
||||||
function GetPageHeight: Integer; override;
|
function GetPageHeight: Integer; override;
|
||||||
|
function GetLineWidth: Integer; override;
|
||||||
|
procedure SetLineWidth(count: Integer); override;
|
||||||
|
function GetLineCount: Integer; override;
|
||||||
procedure SetLineCount(count: Integer); override;
|
procedure SetLineCount(count: Integer); override;
|
||||||
|
|
||||||
// Clipboard support
|
// Clipboard support
|
||||||
@ -166,12 +172,22 @@ begin
|
|||||||
GDK_KP_Page_Up : KeyCode:=GDK_Page_Up;
|
GDK_KP_Page_Up : KeyCode:=GDK_Page_Up;
|
||||||
GDK_KP_Page_Down : KeyCode:=GDK_Page_Down;
|
GDK_KP_Page_Down : KeyCode:=GDK_Page_Down;
|
||||||
GDK_KP_End : KeyCode:=GDK_End;
|
GDK_KP_End : KeyCode:=GDK_End;
|
||||||
|
GDK_Scroll_Lock,
|
||||||
|
GDK_Num_Lock,
|
||||||
|
GDK_Shift_L..GDK_Hyper_R :
|
||||||
|
begin
|
||||||
|
// Don't let modifier keys trough as normal keys
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
KeyCode:=Event^.KeyVal;
|
KeyCode:=Event^.KeyVal;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
KeyMods := [];
|
|
||||||
KeyState:=Event^.State;
|
KeyState:=Event^.State;
|
||||||
|
|
||||||
|
WriteLn('KeyCode ', KeyCode,' keystate ',KeyState);
|
||||||
|
|
||||||
|
// Calculate the Key modifiers (shiftstate)
|
||||||
|
KeyMods := [];
|
||||||
if (KeyState and 1) <> 0 then KeyMods := KeyMods + [ssShift];
|
if (KeyState and 1) <> 0 then KeyMods := KeyMods + [ssShift];
|
||||||
if (KeyState and 2) <> 0 then KeyMods := KeyMods + [ssCaps];
|
if (KeyState and 2) <> 0 then KeyMods := KeyMods + [ssCaps];
|
||||||
if (KeyState and 4) <> 0 then KeyMods := KeyMods + [ssCtrl];
|
if (KeyState and 4) <> 0 then KeyMods := KeyMods + [ssCtrl];
|
||||||
@ -184,9 +200,9 @@ begin
|
|||||||
if (KeyState and $400) <> 0 then KeyMods := KeyMods + [ssRight];
|
if (KeyState and $400) <> 0 then KeyMods := KeyMods + [ssRight];
|
||||||
if (KeyState and $2000) <> 0 then KeyMods := KeyMods + [ssAltGr];
|
if (KeyState and $2000) <> 0 then KeyMods := KeyMods + [ssAltGr];
|
||||||
|
|
||||||
WriteLn('KeyCode ', KeyCode);
|
|
||||||
|
|
||||||
edit.Edit.KeyPressed(KeyCode,KeyMods);
|
edit.Edit.KeyPressed(KeyCode,KeyMods);
|
||||||
|
|
||||||
|
writeln(edit.Edit.Selection.StartX);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtkSHEdit_ButtonPressEvent(GtkWidget: PGtkWidget; event: PGdkEventButton ; edit: TGtkSHEdit): Integer; cdecl;
|
function TGtkSHEdit_ButtonPressEvent(GtkWidget: PGtkWidget; event: PGdkEventButton ; edit: TGtkSHEdit): Integer; cdecl;
|
||||||
@ -272,7 +288,7 @@ begin
|
|||||||
Edit := AEdit;
|
Edit := AEdit;
|
||||||
shWhitespace := AddSHStyle('Whitespace', colBlack, colWhite, fsNormal);
|
shWhitespace := AddSHStyle('Whitespace', colBlack, colWhite, fsNormal);
|
||||||
Edit.shDefault := AddSHStyle('Default', colBlack, colWhite, fsNormal);
|
Edit.shDefault := AddSHStyle('Default', colBlack, colWhite, fsNormal);
|
||||||
Edit.shSelected := AddSHStyle('Selected', colWhite, colBlack, fsNormal);
|
Edit.shSelected := AddSHStyle('Selected', colWhite, colBlue, fsNormal);
|
||||||
{ Install keys }
|
{ Install keys }
|
||||||
Edit.AddKeyDef(@Edit.CursorUp, 'Cursor up', GDK_Up, []);
|
Edit.AddKeyDef(@Edit.CursorUp, 'Cursor up', GDK_Up, []);
|
||||||
Edit.AddKeyDef(@Edit.CursorDown, 'Cursor down', GDK_Down, []);
|
Edit.AddKeyDef(@Edit.CursorDown, 'Cursor down', GDK_Down, []);
|
||||||
@ -282,6 +298,19 @@ begin
|
|||||||
Edit.AddKeyDef(@Edit.CursorEnd, 'Cursor Home', GDK_End, []);
|
Edit.AddKeyDef(@Edit.CursorEnd, 'Cursor Home', GDK_End, []);
|
||||||
Edit.AddKeyDef(@Edit.CursorPageUp, 'Cursor PageUp', GDK_Page_Up, []);
|
Edit.AddKeyDef(@Edit.CursorPageUp, 'Cursor PageUp', GDK_Page_Up, []);
|
||||||
Edit.AddKeyDef(@Edit.CursorPageDown, 'Cursor PageDown', GDK_Page_Down, []);
|
Edit.AddKeyDef(@Edit.CursorPageDown, 'Cursor PageDown', GDK_Page_Down, []);
|
||||||
|
Edit.AddKeyDef(@Edit.CursorDocBegin, 'Cursor Document Start', GDK_Page_Up, [ssCtrl]);
|
||||||
|
Edit.AddKeyDef(@Edit.CursorDocEnd, 'Cursor Document End', GDK_Page_Down, [ssCtrl]);
|
||||||
|
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionUp, 'Selection up', GDK_Up, [ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionDown, 'Selection down', GDK_Down, [ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionLeft, 'Selection left', GDK_Left, [ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionRight, 'Selection right', GDK_Right, [ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionHome, 'Selection Home', GDK_Home, [ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionEnd, 'Selection Home', GDK_End, [ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionPageUp, 'Selection PageUp', GDK_Page_Up, [ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionPageDown, 'Selection PageDown', GDK_Page_Down, [ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionDocBegin, 'Selection Document Start', GDK_Page_Up, [ssCtrl,ssShift]);
|
||||||
|
Edit.AddKeyDef(@Edit.SelectionDocEnd, 'Selection Document End', GDK_Page_Down, [ssCtrl,ssShift]);
|
||||||
|
|
||||||
Edit.AddKeyDef(@Edit.ToggleOverwriteMode, 'Toggle overwrite mode', GDK_Insert, []);
|
Edit.AddKeyDef(@Edit.ToggleOverwriteMode, 'Toggle overwrite mode', GDK_Insert, []);
|
||||||
Edit.AddKeyDef(@Edit.EditDelLeft, 'Delete char left of cursor', GDK_Backspace, []);
|
Edit.AddKeyDef(@Edit.EditDelLeft, 'Delete char left of cursor', GDK_Backspace, []);
|
||||||
@ -364,7 +393,6 @@ var
|
|||||||
hs : pchar;
|
hs : pchar;
|
||||||
begin
|
begin
|
||||||
// WriteLn(Format('DrawTextLine(%d) for %s ', [y, ClassName]));
|
// WriteLn(Format('DrawTextLine(%d) for %s ', [y, ClassName]));
|
||||||
|
|
||||||
// Erase the (potentially multi-coloured) background
|
// Erase the (potentially multi-coloured) background
|
||||||
|
|
||||||
rx1 := x1;
|
rx1 := x1;
|
||||||
@ -457,12 +485,13 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
procedure TGtkSHEdit.ShowCursor(x, y: Integer);
|
procedure TGtkSHEdit.ShowCursor(x, y: Integer);
|
||||||
var
|
|
||||||
r : TGdkRectangle;
|
|
||||||
begin
|
begin
|
||||||
writeln('Showcursor ',x,',',y);
|
// writeln('Showcursor ',x,',',y);
|
||||||
SetGCColor(colBlack);
|
if assigned(GdkWnd) then
|
||||||
gdk_draw_rectangle(PGdkDrawable(GdkWnd), GC, 1, x*CharW + LeftIndent, y*CharH, 2, CharH);
|
begin
|
||||||
|
SetGCColor(colBlack);
|
||||||
|
gdk_draw_rectangle(PGdkDrawable(GdkWnd), GC, 1, x*CharW + LeftIndent, y*CharH, 2, CharH);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -470,7 +499,7 @@ procedure TGtkSHEdit.HideCursor(x, y: Integer);
|
|||||||
var
|
var
|
||||||
r : TGdkRectangle;
|
r : TGdkRectangle;
|
||||||
begin
|
begin
|
||||||
writeln('Hidecursor ',x,',',y);
|
// writeln('Hidecursor ',x,',',y);
|
||||||
r.x := x * CharW + LeftIndent;
|
r.x := x * CharW + LeftIndent;
|
||||||
r.y := y * CharH;
|
r.y := y * CharH;
|
||||||
r.Width := 2;
|
r.Width := 2;
|
||||||
@ -479,6 +508,26 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TGtkSHEdit.GetLineWidth: Integer;
|
||||||
|
begin
|
||||||
|
Result := (Trunc(hadj^.upper)-LeftIndent) div CharW;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TGtkSHEdit.SetLineWidth(count: Integer);
|
||||||
|
begin
|
||||||
|
hadj^.upper := count * CharW + LeftIndent;
|
||||||
|
gtk_adjustment_changed(hadj);
|
||||||
|
gtk_widget_set_usize(PaintBox, Trunc(hadj^.upper), Trunc(vadj^.upper));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TGtkSHEdit.GetLineCount: Integer;
|
||||||
|
begin
|
||||||
|
Result := Trunc(vadj^.upper) div CharH;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TGtkSHEdit.SetLineCount(count: Integer);
|
procedure TGtkSHEdit.SetLineCount(count: Integer);
|
||||||
begin
|
begin
|
||||||
vadj^.upper := count * CharH;
|
vadj^.upper := count * CharH;
|
||||||
@ -487,6 +536,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TGtkSHEdit.GetHorzPos: Integer;
|
||||||
|
begin
|
||||||
|
Result := Trunc(hadj^.value);
|
||||||
|
if Result>0 then
|
||||||
|
Result:=(Result-LeftIndent) div CharW;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TGtkSHEdit.SetHorzPos(x: Integer);
|
||||||
|
begin
|
||||||
|
if x>0 then
|
||||||
|
x:=x*CharW+LeftIndent;
|
||||||
|
gtk_adjustment_set_value(hadj, x);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TGtkSHEdit.GetVertPos: Integer;
|
function TGtkSHEdit.GetVertPos: Integer;
|
||||||
begin
|
begin
|
||||||
Result := Trunc(vadj^.value) div CharH;
|
Result := Trunc(vadj^.value) div CharH;
|
||||||
@ -499,6 +564,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TGtkSHEdit.GetPageWidth: Integer;
|
||||||
|
begin
|
||||||
|
Result := Trunc(hadj^.page_size) div CharW;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TGtkSHEdit.GetPageHeight: Integer;
|
function TGtkSHEdit.GetPageHeight: Integer;
|
||||||
begin
|
begin
|
||||||
Result := Trunc(vadj^.page_size) div CharH;
|
Result := Trunc(vadj^.page_size) div CharH;
|
||||||
@ -507,7 +578,14 @@ end;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.4 1999-12-08 01:03:15 peter
|
Revision 1.5 1999-12-09 23:16:41 peter
|
||||||
|
* cursor walking is now possible, both horz and vert ranges are now
|
||||||
|
adapted
|
||||||
|
* filter key modifiers
|
||||||
|
* selection move routines added, but still no correct output to the
|
||||||
|
screen
|
||||||
|
|
||||||
|
Revision 1.4 1999/12/08 01:03:15 peter
|
||||||
* changes so redrawing and walking with the cursor finally works
|
* changes so redrawing and walking with the cursor finally works
|
||||||
correct
|
correct
|
||||||
|
|
||||||
|
@ -47,16 +47,16 @@ begin
|
|||||||
AddKeyboardAction(AMethod, ADescr));
|
AddKeyboardAction(AMethod, ADescr));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TSHTextEdit.ToggleOverwriteMode;
|
procedure TSHTextEdit.ToggleOverwriteMode;
|
||||||
begin
|
begin
|
||||||
OverwriteMode := not OverwriteMode; // *** specify signal for change
|
OverwriteMode := not OverwriteMode; // *** specify signal for change
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TSHTextEdit.CursorUp;
|
procedure TSHTextEdit.CursorUp;
|
||||||
begin
|
begin
|
||||||
if FCursorY = 0 then
|
if FCursorY > 0 then
|
||||||
FCursorX := 0
|
|
||||||
else
|
|
||||||
Dec(FCursorY);
|
Dec(FCursorY);
|
||||||
if FCursorY<Renderer.VertPos then
|
if FCursorY<Renderer.VertPos then
|
||||||
Renderer.VertPos := Renderer.VertPos - 1;
|
Renderer.VertPos := Renderer.VertPos - 1;
|
||||||
@ -66,10 +66,8 @@ end;
|
|||||||
procedure TSHTextEdit.CursorDown;
|
procedure TSHTextEdit.CursorDown;
|
||||||
begin
|
begin
|
||||||
if FCursorY < FDoc.LineCount - 1 then
|
if FCursorY < FDoc.LineCount - 1 then
|
||||||
Inc(FCursorY)
|
Inc(FCursorY);
|
||||||
else
|
if FCursorY>=Renderer.VertPos+Renderer.PageHeight then
|
||||||
FCursorX := FDoc.LineLen[FCursorY];
|
|
||||||
if FCursorY>Renderer.VertPos+Renderer.PageHeight then
|
|
||||||
Renderer.VertPos := Renderer.VertPos + 1;
|
Renderer.VertPos := Renderer.VertPos + 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -77,7 +75,11 @@ end;
|
|||||||
procedure TSHTextEdit.CursorLeft;
|
procedure TSHTextEdit.CursorLeft;
|
||||||
begin
|
begin
|
||||||
if FCursorX > 0 then
|
if FCursorX > 0 then
|
||||||
Dec(FCursorX)
|
begin
|
||||||
|
Dec(FCursorX);
|
||||||
|
if FCursorX<Renderer.HorzPos then
|
||||||
|
Renderer.HorzPos:=Renderer.HorzPos-1;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if FCursorY > 0 then
|
if FCursorY > 0 then
|
||||||
begin
|
begin
|
||||||
@ -85,6 +87,8 @@ begin
|
|||||||
FCursorX := FDoc.LineLen[FCursorY];
|
FCursorX := FDoc.LineLen[FCursorY];
|
||||||
if FCursorY<Renderer.VertPos then
|
if FCursorY<Renderer.VertPos then
|
||||||
Renderer.VertPos := Renderer.VertPos - 1;
|
Renderer.VertPos := Renderer.VertPos - 1;
|
||||||
|
if FCursorX>=Renderer.HorzPos+Renderer.PageWidth then
|
||||||
|
Renderer.HorzPos:=Renderer.HorzPos+1;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -92,36 +96,55 @@ end;
|
|||||||
procedure TSHTextEdit.CursorRight;
|
procedure TSHTextEdit.CursorRight;
|
||||||
begin
|
begin
|
||||||
Inc(FCursorX);
|
Inc(FCursorX);
|
||||||
if FCursorX > FDoc.LineLen[FCursorY] then
|
if FCursorX>=Renderer.HorzPos+Renderer.PageWidth then
|
||||||
if FCursorY < FDoc.LineCount - 1 then
|
Renderer.HorzPos:=FCursorX-Renderer.PageWidth+1;
|
||||||
begin
|
if FCursorX>=Renderer.LineWidth then
|
||||||
Inc(FCursorY);
|
Renderer.LineWidth:=FCursorX+1;
|
||||||
FCursorX := 0;
|
end;
|
||||||
if FCursorY>Renderer.VertPos+Renderer.PageHeight then
|
|
||||||
Renderer.VertPos := Renderer.VertPos + 1;
|
|
||||||
end
|
procedure TSHTextEdit.CursorDocBegin;
|
||||||
else
|
begin
|
||||||
FCursorX := FDoc.LineLen[FCursorY];
|
FCursorX := 0;
|
||||||
|
FCursorY := 0;
|
||||||
|
Renderer.HorzPos:=0;
|
||||||
|
Renderer.VertPos:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.CursorDocEnd;
|
||||||
|
var
|
||||||
|
py : integer;
|
||||||
|
begin
|
||||||
|
FCursorY:=FDoc.LineCount-1;
|
||||||
|
FCursorX := FDoc.LineLen[FCursorY];
|
||||||
|
py := FDoc.LineCount - Renderer.PageHeight;
|
||||||
|
if py < 0 then
|
||||||
|
py:=0;
|
||||||
|
Renderer.VertPos := py;
|
||||||
|
if FCursorX >= Renderer.HorzPos+Renderer.PageWidth then
|
||||||
|
Renderer.HorzPos:=FCursorX-Renderer.PageWidth+1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TSHTextEdit.CursorHome;
|
procedure TSHTextEdit.CursorHome;
|
||||||
begin
|
begin
|
||||||
FCursorX := 0;
|
FCursorX := 0;
|
||||||
|
Renderer.HorzPos:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TSHTextEdit.CursorEnd;
|
procedure TSHTextEdit.CursorEnd;
|
||||||
begin
|
begin
|
||||||
FCursorX := FDoc.LineLen[FCursorY];
|
FCursorX := FDoc.LineLen[FCursorY];
|
||||||
|
if FCursorX >= Renderer.HorzPos+Renderer.PageWidth then
|
||||||
|
Renderer.HorzPos:=FCursorX-Renderer.PageWidth+1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TSHTextEdit.CursorPageUp;
|
procedure TSHTextEdit.CursorPageUp;
|
||||||
begin
|
begin
|
||||||
if FCursorY = 0 then
|
if FCursorY > 0 then
|
||||||
FCursorX := 0
|
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
Dec(FCursorY, Renderer.PageHeight);
|
Dec(FCursorY, Renderer.PageHeight);
|
||||||
if FCursorY < 0 then
|
if FCursorY < 0 then
|
||||||
@ -136,18 +159,19 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
procedure TSHTextEdit.CursorPageDown;
|
procedure TSHTextEdit.CursorPageDown;
|
||||||
|
var
|
||||||
|
py : integer;
|
||||||
begin
|
begin
|
||||||
if FCursorY = FDoc.LineCount - 1 then
|
if FCursorY < FDoc.LineCount - 1 then
|
||||||
FCursorX := FDoc.LineLen[FCursorY]
|
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
Inc(FCursorY, Renderer.PageHeight);
|
Inc(FCursorY, Renderer.PageHeight);
|
||||||
if FCursorY >= FDoc.LineCount then
|
if FCursorY >= FDoc.LineCount then
|
||||||
begin
|
begin
|
||||||
FCursorY := FDoc.LineCount - Renderer.PageHeight;
|
FCursorY:=FDoc.LineCount-1;
|
||||||
if FCursorY < 0 then
|
py := FDoc.LineCount - Renderer.PageHeight;
|
||||||
FCursorY:=0;
|
if py < 0 then
|
||||||
Renderer.VertPos := FCursorY;
|
py:=0;
|
||||||
|
Renderer.VertPos := py;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Renderer.VertPos := Renderer.VertPos + Renderer.PageHeight;
|
Renderer.VertPos := Renderer.VertPos + Renderer.PageHeight;
|
||||||
@ -155,6 +179,109 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SetSelectionStart;
|
||||||
|
begin
|
||||||
|
if not FSel.IsValid then
|
||||||
|
begin
|
||||||
|
FSel.StartX := FCursorX;
|
||||||
|
FSel.StartY := FCursorY;
|
||||||
|
FSel.EndX := FCursorX;
|
||||||
|
FSel.EndY := FCursorY;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SetSelectionEnd;
|
||||||
|
begin
|
||||||
|
if FSel.IsValid then
|
||||||
|
begin
|
||||||
|
FSel.EndX := FCursorX;
|
||||||
|
FSel.EndY := FCursorY;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionUp;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorUp;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionDown;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorDown;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionLeft;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorLeft;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionRight;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorRight;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionHome;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorHome;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionEnd;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorEnd;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionDocBegin;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorDocBegin;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionDocEnd;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorDocEnd;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionPageUp;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorPageUp;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSHTextEdit.SelectionPageDown;
|
||||||
|
begin
|
||||||
|
SetSelectionStart;
|
||||||
|
CursorPageDown;
|
||||||
|
SetSelectionEnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TSHTextEdit.EditDelLeft;
|
procedure TSHTextEdit.EditDelLeft;
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
@ -315,12 +442,16 @@ begin
|
|||||||
AddUndoInfo(TUndoEdit.Create, True);
|
AddUndoInfo(TUndoEdit.Create, True);
|
||||||
if not BlockMode then KeyReturn;
|
if not BlockMode then KeyReturn;
|
||||||
end;
|
end;
|
||||||
#32..#255: begin
|
#32..#255:
|
||||||
|
begin
|
||||||
s := FDoc.LineText[FCursorY];
|
s := FDoc.LineText[FCursorY];
|
||||||
if OverwriteMode then
|
if FCursorX>=Length(s) then
|
||||||
s := Copy(s, 1, FCursorX) + Key + Copy(s, FCursorX + 2, Length(s))
|
s := s + Space(FCursorX-length(s)) + Key
|
||||||
else
|
else
|
||||||
s := Copy(s, 1, FCursorX) + Key + Copy(s, FCursorX + 1, Length(s));
|
if OverwriteMode then
|
||||||
|
s := Copy(s, 1, FCursorX) + Key + Copy(s, FCursorX + 2, Length(s))
|
||||||
|
else
|
||||||
|
s := Copy(s, 1, FCursorX) + Key + Copy(s, FCursorX + 1, Length(s));
|
||||||
FDoc.LineText[FCursorY] := s;
|
FDoc.LineText[FCursorY] := s;
|
||||||
Inc(FCursorX);
|
Inc(FCursorX);
|
||||||
AddUndoInfo(TUndoEdit.Create, True);
|
AddUndoInfo(TUndoEdit.Create, True);
|
||||||
@ -372,8 +503,10 @@ begin
|
|||||||
while (KeysPos <= Length(Keys)) and (Keys[KeysPos] >= #32) do begin
|
while (KeysPos <= Length(Keys)) and (Keys[KeysPos] >= #32) do begin
|
||||||
Key := Keys[KeysPos];
|
Key := Keys[KeysPos];
|
||||||
s := FDoc.LineText[FCursorY];
|
s := FDoc.LineText[FCursorY];
|
||||||
s := Copy(s, 1, FCursorX) + Key +
|
if FCursorX>=Length(s) then
|
||||||
Copy(s, FCursorX + 1 + Ord(OverwriteMode), Length(s));
|
s := s + Space(FCursorX-length(s)) + Key
|
||||||
|
else
|
||||||
|
s := Copy(s, 1, FCursorX) + Key + Copy(s, FCursorX + 1 + Ord(OverwriteMode), Length(s));
|
||||||
FDoc.LineText[FCursorY] := s;
|
FDoc.LineText[FCursorY] := s;
|
||||||
Inc(FCursorX);
|
Inc(FCursorX);
|
||||||
Inc(i);
|
Inc(i);
|
||||||
@ -584,7 +717,14 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 1999-12-08 01:03:15 peter
|
Revision 1.4 1999-12-09 23:16:41 peter
|
||||||
|
* cursor walking is now possible, both horz and vert ranges are now
|
||||||
|
adapted
|
||||||
|
* filter key modifiers
|
||||||
|
* selection move routines added, but still no correct output to the
|
||||||
|
screen
|
||||||
|
|
||||||
|
Revision 1.3 1999/12/08 01:03:15 peter
|
||||||
* changes so redrawing and walking with the cursor finally works
|
* changes so redrawing and walking with the cursor finally works
|
||||||
correct
|
correct
|
||||||
|
|
||||||
|
@ -127,13 +127,22 @@ type
|
|||||||
procedure HideCursor(x, y: Integer); virtual; abstract;
|
procedure HideCursor(x, y: Integer); virtual; abstract;
|
||||||
|
|
||||||
// Scrolling support
|
// Scrolling support
|
||||||
|
function GetHorzPos: Integer; virtual; abstract;
|
||||||
|
procedure SetHorzPos(x: Integer); virtual; abstract;
|
||||||
function GetVertPos: Integer; virtual; abstract;
|
function GetVertPos: Integer; virtual; abstract;
|
||||||
procedure SetVertPos(y: Integer); virtual; abstract;
|
procedure SetVertPos(y: Integer); virtual; abstract;
|
||||||
|
function GetPageWidth: Integer; virtual; abstract;
|
||||||
function GetPageHeight: Integer; virtual; abstract;
|
function GetPageHeight: Integer; virtual; abstract;
|
||||||
|
function GetLineWidth: Integer; virtual; abstract;
|
||||||
|
procedure SetLineWidth(count: Integer); virtual; abstract;
|
||||||
|
function GetLineCount: Integer; virtual; abstract;
|
||||||
procedure SetLineCount(count: Integer); virtual; abstract;
|
procedure SetLineCount(count: Integer); virtual; abstract;
|
||||||
|
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 PageHeight: Integer read GetPageHeight;
|
property PageHeight: Integer read GetPageHeight;
|
||||||
property LineCount: Integer write SetLineCount;
|
property LineWidth: Integer read GetLineWidth write SetLineWidth;
|
||||||
|
property LineCount: Integer read GetLineCount write SetLineCount;
|
||||||
|
|
||||||
// Clipboard support
|
// Clipboard support
|
||||||
function GetClipboard: String; virtual; abstract;
|
function GetClipboard: String; virtual; abstract;
|
||||||
@ -190,16 +199,32 @@ type
|
|||||||
procedure MultiDelLeft(Count: Integer);
|
procedure MultiDelLeft(Count: Integer);
|
||||||
|
|
||||||
public
|
public
|
||||||
|
// Keyboard command handlers
|
||||||
|
// Cursor movement
|
||||||
procedure CursorUp;
|
procedure CursorUp;
|
||||||
procedure CursorDown;
|
procedure CursorDown;
|
||||||
procedure CursorLeft;
|
procedure CursorLeft;
|
||||||
procedure CursorRight;
|
procedure CursorRight;
|
||||||
procedure CursorHome;
|
procedure CursorHome;
|
||||||
procedure CursorEnd;
|
procedure CursorEnd;
|
||||||
|
procedure CursorDocBegin;
|
||||||
|
procedure CursorDocEnd;
|
||||||
procedure CursorPageUp;
|
procedure CursorPageUp;
|
||||||
procedure CursorPageDown;
|
procedure CursorPageDown;
|
||||||
|
// Selection movement
|
||||||
// Keyboard command handlers
|
procedure SetSelectionStart;
|
||||||
|
procedure SetSelectionEnd;
|
||||||
|
procedure SelectionUp;
|
||||||
|
procedure SelectionDown;
|
||||||
|
procedure SelectionLeft;
|
||||||
|
procedure SelectionRight;
|
||||||
|
procedure SelectionHome;
|
||||||
|
procedure SelectionEnd;
|
||||||
|
procedure SelectionDocBegin;
|
||||||
|
procedure SelectionDocEnd;
|
||||||
|
procedure SelectionPageUp;
|
||||||
|
procedure SelectionPageDown;
|
||||||
|
// Misc
|
||||||
procedure ToggleOverwriteMode;
|
procedure ToggleOverwriteMode;
|
||||||
procedure EditDelLeft;
|
procedure EditDelLeft;
|
||||||
procedure EditDelRight;
|
procedure EditDelRight;
|
||||||
@ -235,6 +260,7 @@ type
|
|||||||
property Doc: TTextDoc read FDoc;
|
property Doc: TTextDoc read FDoc;
|
||||||
property CursorX: Integer read FCursorX write SetCursorX;
|
property CursorX: Integer read FCursorX write SetCursorX;
|
||||||
property CursorY: Integer read FCursorY write SetCursorY;
|
property CursorY: Integer read FCursorY write SetCursorY;
|
||||||
|
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 Renderer: ISHRenderer read FRenderer;
|
||||||
@ -328,7 +354,8 @@ begin
|
|||||||
KeyboardActions := TCollection.Create(TKeyboardActionDescr);
|
KeyboardActions := TCollection.Create(TKeyboardActionDescr);
|
||||||
Shortcuts := TCollection.Create(TShortcut);
|
Shortcuts := TCollection.Create(TShortcut);
|
||||||
|
|
||||||
FRenderer.SetLineCount(FDoc.LineCount);
|
Renderer.LineCount := FDoc.LineCount;
|
||||||
|
Renderer.LineWidth := FDoc.LineWidth;
|
||||||
CursorX:=0;
|
CursorX:=0;
|
||||||
CursorY:=0;
|
CursorY:=0;
|
||||||
end;
|
end;
|
||||||
@ -368,6 +395,7 @@ end;
|
|||||||
procedure TSHTextEdit.LineInserted(Sender: TTextDoc; Line: Integer);
|
procedure TSHTextEdit.LineInserted(Sender: TTextDoc; Line: Integer);
|
||||||
begin
|
begin
|
||||||
Renderer.LineCount := FDoc.LineCount;
|
Renderer.LineCount := FDoc.LineCount;
|
||||||
|
Renderer.LineWidth := FDoc.LineWidth;
|
||||||
ChangeInLine(Line);
|
ChangeInLine(Line);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -382,7 +410,14 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 1999-12-06 21:27:27 peter
|
Revision 1.4 1999-12-09 23:16:41 peter
|
||||||
|
* cursor walking is now possible, both horz and vert ranges are now
|
||||||
|
adapted
|
||||||
|
* filter key modifiers
|
||||||
|
* selection move routines added, but still no correct output to the
|
||||||
|
screen
|
||||||
|
|
||||||
|
Revision 1.3 1999/12/06 21:27:27 peter
|
||||||
* gtk updates, redrawing works now much better and clears only between
|
* gtk updates, redrawing works now much better and clears only between
|
||||||
x1 and x2
|
x1 and x2
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user