mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 08:29:29 +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
|
||||
protected
|
||||
FModified: Boolean;
|
||||
FLineWidth,
|
||||
FLineCount: LongInt;
|
||||
FLines: PLineArray;
|
||||
FViewInfos: TCollection;
|
||||
@ -93,6 +94,7 @@ type
|
||||
procedure RemoveLine(LineNumber: Integer);
|
||||
|
||||
property Modified: Boolean read FModified write SetModified;
|
||||
property LineWidth: Integer read FLineWidth;
|
||||
property LineCount: Integer read FLineCount;
|
||||
property LineText[LineNumber: Integer]: String
|
||||
read GetLineText write SetLineText;
|
||||
@ -113,6 +115,7 @@ begin
|
||||
FModified := false;
|
||||
FLines := nil;
|
||||
FLineCount := 0;
|
||||
FLineWidth := 0;
|
||||
FViewInfos := TCollection.Create(TViewInfo);
|
||||
end;
|
||||
|
||||
@ -130,6 +133,9 @@ begin
|
||||
if assigned(FLines) then
|
||||
FreeMem(FLines);
|
||||
|
||||
FLineCount:=0;
|
||||
FLineWidth:=0;
|
||||
|
||||
for i := 0 to FViewInfos.Count - 1 do
|
||||
if Assigned(TViewInfo(FViewInfos.Items[i]).OnLineRemove) then
|
||||
TViewInfo(FViewInfos.Items[i]).OnLineRemove(Self, 0);
|
||||
@ -140,14 +146,18 @@ var
|
||||
l: PLine;
|
||||
i: Integer;
|
||||
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));
|
||||
Move(FLines^[BeforeLine], FLines^[BeforeLine + 1],(FLineCount - BeforeLine) * SizeOf(TLine));
|
||||
l := @(FLines^[BeforeLine]);
|
||||
FillChar(l^, SizeOf(TLine), 0);
|
||||
l^.len := Length(s);
|
||||
l^.s := StrNew(PChar(s));
|
||||
|
||||
Inc(FLineCount);
|
||||
if l^.Len>FLineWidth then
|
||||
FLineWidth:=l^.len;
|
||||
|
||||
for i := 0 to FViewInfos.Count - 1 do
|
||||
if Assigned(TViewInfo(FViewInfos.Items[i]).OnLineInsert) then
|
||||
@ -225,6 +235,8 @@ begin
|
||||
StrDispose(FLines^[LineNumber].s);
|
||||
FLines^[LineNumber].len := Length(NewText);
|
||||
FLines^[LineNumber].s := StrNew(PChar(NewText));
|
||||
if Length(NewText)>FLineWidth then
|
||||
FLineWidth:=Length(NewText);
|
||||
Modified := True;
|
||||
end;
|
||||
end;
|
||||
@ -256,7 +268,14 @@ end.
|
||||
|
||||
{
|
||||
$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
|
||||
|
||||
Revision 1.1 1999/10/29 15:59:03 peter
|
||||
|
@ -99,9 +99,15 @@ type
|
||||
procedure HideCursor(x, y: Integer); override;
|
||||
|
||||
// Scrolling support
|
||||
function GetHorzPos: Integer; override;
|
||||
procedure SetHorzPos(x: Integer); override;
|
||||
function GetVertPos: Integer; override;
|
||||
procedure SetVertPos(y: Integer); override;
|
||||
function GetPageWidth: Integer; override;
|
||||
function GetPageHeight: Integer; override;
|
||||
function GetLineWidth: Integer; override;
|
||||
procedure SetLineWidth(count: Integer); override;
|
||||
function GetLineCount: Integer; override;
|
||||
procedure SetLineCount(count: Integer); override;
|
||||
|
||||
// Clipboard support
|
||||
@ -166,12 +172,22 @@ begin
|
||||
GDK_KP_Page_Up : KeyCode:=GDK_Page_Up;
|
||||
GDK_KP_Page_Down : KeyCode:=GDK_Page_Down;
|
||||
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
|
||||
KeyCode:=Event^.KeyVal;
|
||||
end;
|
||||
|
||||
KeyMods := [];
|
||||
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 2) <> 0 then KeyMods := KeyMods + [ssCaps];
|
||||
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 $2000) <> 0 then KeyMods := KeyMods + [ssAltGr];
|
||||
|
||||
WriteLn('KeyCode ', KeyCode);
|
||||
|
||||
edit.Edit.KeyPressed(KeyCode,KeyMods);
|
||||
|
||||
writeln(edit.Edit.Selection.StartX);
|
||||
end;
|
||||
|
||||
function TGtkSHEdit_ButtonPressEvent(GtkWidget: PGtkWidget; event: PGdkEventButton ; edit: TGtkSHEdit): Integer; cdecl;
|
||||
@ -272,7 +288,7 @@ begin
|
||||
Edit := AEdit;
|
||||
shWhitespace := AddSHStyle('Whitespace', 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 }
|
||||
Edit.AddKeyDef(@Edit.CursorUp, 'Cursor up', GDK_Up, []);
|
||||
Edit.AddKeyDef(@Edit.CursorDown, 'Cursor down', GDK_Down, []);
|
||||
@ -282,6 +298,19 @@ begin
|
||||
Edit.AddKeyDef(@Edit.CursorEnd, 'Cursor Home', GDK_End, []);
|
||||
Edit.AddKeyDef(@Edit.CursorPageUp, 'Cursor PageUp', GDK_Page_Up, []);
|
||||
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.EditDelLeft, 'Delete char left of cursor', GDK_Backspace, []);
|
||||
@ -364,7 +393,6 @@ var
|
||||
hs : pchar;
|
||||
begin
|
||||
// WriteLn(Format('DrawTextLine(%d) for %s ', [y, ClassName]));
|
||||
|
||||
// Erase the (potentially multi-coloured) background
|
||||
|
||||
rx1 := x1;
|
||||
@ -457,12 +485,13 @@ end;
|
||||
|
||||
|
||||
procedure TGtkSHEdit.ShowCursor(x, y: Integer);
|
||||
var
|
||||
r : TGdkRectangle;
|
||||
begin
|
||||
writeln('Showcursor ',x,',',y);
|
||||
SetGCColor(colBlack);
|
||||
gdk_draw_rectangle(PGdkDrawable(GdkWnd), GC, 1, x*CharW + LeftIndent, y*CharH, 2, CharH);
|
||||
// writeln('Showcursor ',x,',',y);
|
||||
if assigned(GdkWnd) then
|
||||
begin
|
||||
SetGCColor(colBlack);
|
||||
gdk_draw_rectangle(PGdkDrawable(GdkWnd), GC, 1, x*CharW + LeftIndent, y*CharH, 2, CharH);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -470,7 +499,7 @@ procedure TGtkSHEdit.HideCursor(x, y: Integer);
|
||||
var
|
||||
r : TGdkRectangle;
|
||||
begin
|
||||
writeln('Hidecursor ',x,',',y);
|
||||
// writeln('Hidecursor ',x,',',y);
|
||||
r.x := x * CharW + LeftIndent;
|
||||
r.y := y * CharH;
|
||||
r.Width := 2;
|
||||
@ -479,6 +508,26 @@ begin
|
||||
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);
|
||||
begin
|
||||
vadj^.upper := count * CharH;
|
||||
@ -487,6 +536,22 @@ begin
|
||||
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;
|
||||
begin
|
||||
Result := Trunc(vadj^.value) div CharH;
|
||||
@ -499,6 +564,12 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TGtkSHEdit.GetPageWidth: Integer;
|
||||
begin
|
||||
Result := Trunc(hadj^.page_size) div CharW;
|
||||
end;
|
||||
|
||||
|
||||
function TGtkSHEdit.GetPageHeight: Integer;
|
||||
begin
|
||||
Result := Trunc(vadj^.page_size) div CharH;
|
||||
@ -507,7 +578,14 @@ end;
|
||||
end.
|
||||
{
|
||||
$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
|
||||
correct
|
||||
|
||||
|
@ -47,16 +47,16 @@ begin
|
||||
AddKeyboardAction(AMethod, ADescr));
|
||||
end;
|
||||
|
||||
|
||||
procedure TSHTextEdit.ToggleOverwriteMode;
|
||||
begin
|
||||
OverwriteMode := not OverwriteMode; // *** specify signal for change
|
||||
end;
|
||||
|
||||
|
||||
procedure TSHTextEdit.CursorUp;
|
||||
begin
|
||||
if FCursorY = 0 then
|
||||
FCursorX := 0
|
||||
else
|
||||
if FCursorY > 0 then
|
||||
Dec(FCursorY);
|
||||
if FCursorY<Renderer.VertPos then
|
||||
Renderer.VertPos := Renderer.VertPos - 1;
|
||||
@ -66,10 +66,8 @@ end;
|
||||
procedure TSHTextEdit.CursorDown;
|
||||
begin
|
||||
if FCursorY < FDoc.LineCount - 1 then
|
||||
Inc(FCursorY)
|
||||
else
|
||||
FCursorX := FDoc.LineLen[FCursorY];
|
||||
if FCursorY>Renderer.VertPos+Renderer.PageHeight then
|
||||
Inc(FCursorY);
|
||||
if FCursorY>=Renderer.VertPos+Renderer.PageHeight then
|
||||
Renderer.VertPos := Renderer.VertPos + 1;
|
||||
end;
|
||||
|
||||
@ -77,7 +75,11 @@ end;
|
||||
procedure TSHTextEdit.CursorLeft;
|
||||
begin
|
||||
if FCursorX > 0 then
|
||||
Dec(FCursorX)
|
||||
begin
|
||||
Dec(FCursorX);
|
||||
if FCursorX<Renderer.HorzPos then
|
||||
Renderer.HorzPos:=Renderer.HorzPos-1;
|
||||
end
|
||||
else
|
||||
if FCursorY > 0 then
|
||||
begin
|
||||
@ -85,6 +87,8 @@ begin
|
||||
FCursorX := FDoc.LineLen[FCursorY];
|
||||
if FCursorY<Renderer.VertPos then
|
||||
Renderer.VertPos := Renderer.VertPos - 1;
|
||||
if FCursorX>=Renderer.HorzPos+Renderer.PageWidth then
|
||||
Renderer.HorzPos:=Renderer.HorzPos+1;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -92,36 +96,55 @@ end;
|
||||
procedure TSHTextEdit.CursorRight;
|
||||
begin
|
||||
Inc(FCursorX);
|
||||
if FCursorX > FDoc.LineLen[FCursorY] then
|
||||
if FCursorY < FDoc.LineCount - 1 then
|
||||
begin
|
||||
Inc(FCursorY);
|
||||
FCursorX := 0;
|
||||
if FCursorY>Renderer.VertPos+Renderer.PageHeight then
|
||||
Renderer.VertPos := Renderer.VertPos + 1;
|
||||
end
|
||||
else
|
||||
FCursorX := FDoc.LineLen[FCursorY];
|
||||
if FCursorX>=Renderer.HorzPos+Renderer.PageWidth then
|
||||
Renderer.HorzPos:=FCursorX-Renderer.PageWidth+1;
|
||||
if FCursorX>=Renderer.LineWidth then
|
||||
Renderer.LineWidth:=FCursorX+1;
|
||||
end;
|
||||
|
||||
|
||||
procedure TSHTextEdit.CursorDocBegin;
|
||||
begin
|
||||
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;
|
||||
|
||||
|
||||
procedure TSHTextEdit.CursorHome;
|
||||
begin
|
||||
FCursorX := 0;
|
||||
Renderer.HorzPos:=0;
|
||||
end;
|
||||
|
||||
|
||||
procedure TSHTextEdit.CursorEnd;
|
||||
begin
|
||||
FCursorX := FDoc.LineLen[FCursorY];
|
||||
if FCursorX >= Renderer.HorzPos+Renderer.PageWidth then
|
||||
Renderer.HorzPos:=FCursorX-Renderer.PageWidth+1;
|
||||
end;
|
||||
|
||||
|
||||
procedure TSHTextEdit.CursorPageUp;
|
||||
begin
|
||||
if FCursorY = 0 then
|
||||
FCursorX := 0
|
||||
else
|
||||
if FCursorY > 0 then
|
||||
begin
|
||||
Dec(FCursorY, Renderer.PageHeight);
|
||||
if FCursorY < 0 then
|
||||
@ -136,18 +159,19 @@ end;
|
||||
|
||||
|
||||
procedure TSHTextEdit.CursorPageDown;
|
||||
var
|
||||
py : integer;
|
||||
begin
|
||||
if FCursorY = FDoc.LineCount - 1 then
|
||||
FCursorX := FDoc.LineLen[FCursorY]
|
||||
else
|
||||
if FCursorY < FDoc.LineCount - 1 then
|
||||
begin
|
||||
Inc(FCursorY, Renderer.PageHeight);
|
||||
if FCursorY >= FDoc.LineCount then
|
||||
begin
|
||||
FCursorY := FDoc.LineCount - Renderer.PageHeight;
|
||||
if FCursorY < 0 then
|
||||
FCursorY:=0;
|
||||
Renderer.VertPos := FCursorY;
|
||||
FCursorY:=FDoc.LineCount-1;
|
||||
py := FDoc.LineCount - Renderer.PageHeight;
|
||||
if py < 0 then
|
||||
py:=0;
|
||||
Renderer.VertPos := py;
|
||||
end
|
||||
else
|
||||
Renderer.VertPos := Renderer.VertPos + Renderer.PageHeight;
|
||||
@ -155,6 +179,109 @@ begin
|
||||
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;
|
||||
var
|
||||
s: String;
|
||||
@ -315,12 +442,16 @@ begin
|
||||
AddUndoInfo(TUndoEdit.Create, True);
|
||||
if not BlockMode then KeyReturn;
|
||||
end;
|
||||
#32..#255: begin
|
||||
#32..#255:
|
||||
begin
|
||||
s := FDoc.LineText[FCursorY];
|
||||
if OverwriteMode then
|
||||
s := Copy(s, 1, FCursorX) + Key + Copy(s, FCursorX + 2, Length(s))
|
||||
if FCursorX>=Length(s) then
|
||||
s := s + Space(FCursorX-length(s)) + Key
|
||||
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;
|
||||
Inc(FCursorX);
|
||||
AddUndoInfo(TUndoEdit.Create, True);
|
||||
@ -372,8 +503,10 @@ begin
|
||||
while (KeysPos <= Length(Keys)) and (Keys[KeysPos] >= #32) do begin
|
||||
Key := Keys[KeysPos];
|
||||
s := FDoc.LineText[FCursorY];
|
||||
s := Copy(s, 1, FCursorX) + Key +
|
||||
Copy(s, FCursorX + 1 + Ord(OverwriteMode), Length(s));
|
||||
if FCursorX>=Length(s) then
|
||||
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;
|
||||
Inc(FCursorX);
|
||||
Inc(i);
|
||||
@ -584,7 +717,14 @@ end;
|
||||
|
||||
{
|
||||
$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
|
||||
correct
|
||||
|
||||
|
@ -127,13 +127,22 @@ type
|
||||
procedure HideCursor(x, y: Integer); virtual; abstract;
|
||||
|
||||
// Scrolling support
|
||||
function GetHorzPos: Integer; virtual; abstract;
|
||||
procedure SetHorzPos(x: Integer); virtual; abstract;
|
||||
function GetVertPos: Integer; virtual; abstract;
|
||||
procedure SetVertPos(y: Integer); virtual; abstract;
|
||||
function GetPageWidth: 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;
|
||||
property HorzPos: Integer read GetHorzPos write SetHorzPos;
|
||||
property VertPos: Integer read GetVertPos write SetVertPos;
|
||||
property PageWidth: Integer read GetPageWidth;
|
||||
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
|
||||
function GetClipboard: String; virtual; abstract;
|
||||
@ -190,16 +199,32 @@ type
|
||||
procedure MultiDelLeft(Count: Integer);
|
||||
|
||||
public
|
||||
// Keyboard command handlers
|
||||
// Cursor movement
|
||||
procedure CursorUp;
|
||||
procedure CursorDown;
|
||||
procedure CursorLeft;
|
||||
procedure CursorRight;
|
||||
procedure CursorHome;
|
||||
procedure CursorEnd;
|
||||
procedure CursorDocBegin;
|
||||
procedure CursorDocEnd;
|
||||
procedure CursorPageUp;
|
||||
procedure CursorPageDown;
|
||||
|
||||
// Keyboard command handlers
|
||||
// Selection movement
|
||||
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 EditDelLeft;
|
||||
procedure EditDelRight;
|
||||
@ -235,6 +260,7 @@ type
|
||||
property Doc: TTextDoc read FDoc;
|
||||
property CursorX: Integer read FCursorX write SetCursorX;
|
||||
property CursorY: Integer read FCursorY write SetCursorY;
|
||||
property Selection: TSelection read FSel write FSel;
|
||||
property OnModifiedChange: TNotifyEvent
|
||||
read FOnModifiedChange write FOnModifiedChange;
|
||||
property Renderer: ISHRenderer read FRenderer;
|
||||
@ -328,7 +354,8 @@ begin
|
||||
KeyboardActions := TCollection.Create(TKeyboardActionDescr);
|
||||
Shortcuts := TCollection.Create(TShortcut);
|
||||
|
||||
FRenderer.SetLineCount(FDoc.LineCount);
|
||||
Renderer.LineCount := FDoc.LineCount;
|
||||
Renderer.LineWidth := FDoc.LineWidth;
|
||||
CursorX:=0;
|
||||
CursorY:=0;
|
||||
end;
|
||||
@ -368,6 +395,7 @@ end;
|
||||
procedure TSHTextEdit.LineInserted(Sender: TTextDoc; Line: Integer);
|
||||
begin
|
||||
Renderer.LineCount := FDoc.LineCount;
|
||||
Renderer.LineWidth := FDoc.LineWidth;
|
||||
ChangeInLine(Line);
|
||||
end;
|
||||
|
||||
@ -382,7 +410,14 @@ end.
|
||||
|
||||
{
|
||||
$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
|
||||
x1 and x2
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user