fixed keypress/keyup, createcaret on synedit focus

git-svn-id: trunk@4467 -
This commit is contained in:
mattias 2003-08-12 14:02:54 +00:00
parent bd2a719afd
commit 51083ebbab
7 changed files with 89 additions and 16 deletions

View File

@ -58,6 +58,8 @@ unit SynEdit;
interface
{ $DEFINE VerboseKeys}
uses
{$IFDEF SYN_LAZARUS}
LCLLinux,
@ -1735,8 +1737,10 @@ var
C: char;
Cmd: TSynEditorCommand;
begin
//writeln('[TCustomSynEdit.KeyDown] ',Key
// ,' Shift=',ssShift in Shift,' Ctrl=',ssCtrl in Shift,' Alt=',ssAlt in Shift);
{$IFDEF VerboseKeys}
writeln('[TCustomSynEdit.KeyDown] ',Key
,' Shift=',ssShift in Shift,' Ctrl=',ssCtrl in Shift,' Alt=',ssAlt in Shift);
{$ENDIF}
inherited;
{$IFDEF SYN_LAZARUS}
if fLastControlIsPressed<>(GetKeyShiftState=[ssCtrl]) then
@ -1765,6 +1769,10 @@ end;
{$IFDEF SYN_LAZARUS}
procedure TCustomSynEdit.KeyUp(var Key: Word; Shift: TShiftState);
begin
{$IFDEF VerboseKeys}
writeln('[TCustomSynEdit.KeyUp] ',Key
,' Shift=',ssShift in Shift,' Ctrl=',ssCtrl in Shift,' Alt=',ssAlt in Shift);
{$ENDIF}
inherited KeyUp(Key, Shift);
if fLastControlIsPressed<>(GetKeyShiftState=[ssCtrl]) then
UpdateCtrlMouse;
@ -4209,8 +4217,7 @@ begin
{$IFDEF VerboseFocus}
writeln('[TCustomSynEdit.WMSetFocus] A ',Name,':',ClassName);
{$ENDIF}
UpdateCaret;
//InitializeCaret;
InitializeCaret;
//if FHideSelection and SelAvail then
// Invalidate;
//writeln('[TCustomSynEdit.WMSetFocus] END');
@ -5657,6 +5664,10 @@ end;
procedure TCustomSynEdit.CommandProcessor(Command: TSynEditorCommand;
AChar: char; Data: pointer);
begin
{$IFDEF VerboseKeys}
writeln('[TCustomSynEdit.CommandProcessor] ',Command
,' AChar=',AChar,' Data=',HexStr(Cardinal(Data),8));
{$ENDIF}
// first the program event handler gets a chance to process the command
DoOnProcessCommand(Command, AChar, Data);
if Command <> ecNone then begin

View File

@ -32,8 +32,9 @@ type
PascalHighligher: TSynPasSyn;
procedure Form1Resize(Sender: TObject);
private
procedure LoadText(const Filename: string);
public
procedure LoadDefaultText;
procedure LoadText(const Filename: string);
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
end;
@ -46,6 +47,47 @@ begin
SetBounds(10,10,Parent.ClientWidth-10,Parent.ClientHeight-20);
end;
procedure TForm1.LoadDefaultText;
var
E: String;
begin
E:=#13#10;
SynEdit1.Lines.Text:=
'{'+e+
' SynEdit Test'+e+
'}'+e+
'program synedit1;'+e+
''+e+
'{$mode objfpc}{$H+}'+e+
''+e+
'uses'+e+
' Interfaces, Classes, SysUtils, Forms, Controls, GraphType, Graphics, SynEdit,'+e+
' SynHighlighterPas;'+e+
''+e+
'type'+e+
' TForm1 = class(TForm)'+e+
' SynEdit1: TSynEdit;'+e+
' PascalHighligher: TSynPasSyn;'+e+
' procedure Form1Resize(Sender: TObject);'+e+
' private'+e+
' public'+e+
' procedure LoadDefaultText;'+e+
' procedure LoadText(const Filename: string);'+e+
' constructor Create(TheOwner: TComponent); override;'+e+
' destructor Destroy; override;'+e+
' end;'+e+
''+e+
'{ TForm1 }'+e+
''+e+
'procedure TForm1.Form1Resize(Sender: TObject);'+e+
'begin'+e+
' with SynEdit1 do'+e+
' SetBounds(10,10,Parent.ClientWidth-10,Parent.ClientHeight-20);'+e+
'end;'+e+
''+e+
'end.'+e;
end;
procedure TForm1.LoadText(const Filename: string);
begin
SynEdit1.Lines.LoadFromFile(Filename);
@ -59,12 +101,13 @@ begin
SynEdit1:=TSynEdit.Create(Self);
with SynEdit1 do begin
Name:='SynEdit1';
Parent:=Self;
end;
PascalHighligher:=TSynPasSyn.Create(Self);
with PascalHighligher do begin
Name:='PascalHighligher';
CommentAttri.Foreground:=clBlue;
CommentAttri.Style:=[fsBold];
KeyAttri.Style:=[fsBold];
@ -74,7 +117,7 @@ begin
SynEdit1.Highlighter:=PascalHighligher;
LoadText('synedit1.pas');
LoadDefaultText;
OnResize(nil);
end;

View File

@ -101,9 +101,9 @@ begin
if (Index >= 0) and
(Index < fPageList.Count) then
begin
NewPageIndex:=fNoteBook.PageIndex;
if not (csLoading in fNoteBook.ComponentState) then begin
// If that page is showing, then show the next page before deleting it
NewPageIndex:=fNoteBook.PageIndex;
if (Index = fNoteBook.PageIndex) then begin
if NewPageIndex<fPageList.Count-1 then
// switch current page to next (right) page
@ -756,6 +756,9 @@ end;}
{ =============================================================================
$Log$
Revision 1.32 2003/08/12 14:02:54 mattias
fixed keypress/keyup, createcaret on synedit focus
Revision 1.31 2003/06/10 17:23:35 mattias
implemented tabstop

View File

@ -2493,7 +2493,7 @@ end;
------------------------------------------------------------------------------}
Procedure TWinControl.WMKeyDown(Var Message : TLMKeyDown);
begin
Assert(False, Format('Trace:[TWinControl.WMKeyDown] %s', [ClassName]));
//writeln('TWinControl.WMKeyDown ',Name,':',ClassName);
if not DoKeyDown(Message) then begin
{inherited} ; // there is nothing to inherit
end;
@ -2946,6 +2946,9 @@ end;
{ =============================================================================
$Log$
Revision 1.157 2003/08/12 14:02:54 mattias
fixed keypress/keyup, createcaret on synedit focus
Revision 1.156 2003/07/30 13:03:44 mattias
replaced label with memo

View File

@ -273,9 +273,11 @@ Begin
PLMsg:=@LMKey;
With LMKey Do
Begin
Msg := LM_SYSKEYDOWN;
Msg := LM_KEYDOWN;
KeyData := LParam;
CharCode := WParam;
writeln('WM_KEYDOWN KeyData=',KeyData,' CharCode=',CharCode);
writeln(' OwnerObject=',TComponent(OwnerObject).Name,':',OwnerObject.ClassName);
End;
End;
WM_KEYUP:
@ -283,9 +285,10 @@ Begin
PLMsg:=@LMKey;
With LMKey Do
Begin
Msg := LM_SYSKEYUP;
Msg := LM_KEYUP;
KeyData := LParam;
CharCode := WParam;
writeln('WM_KEYUP KeyData=',KeyData,' CharCode=',CharCode);
End;
End;
WM_KILLFOCUS:
@ -409,6 +412,7 @@ Begin
XPos := LoWord(LParam);
YPos := HiWord(LParam);
end;
Win32PosToLCLPos(OwnerObject, XPos, YPos);
End;
End;
//TODO:LM_MOVEPAGE,LM_MOVETOROW,LM_MOVETOCOLUMN
@ -434,7 +438,6 @@ Begin
idFrom := SendMessage(HWndFrom, TCM_GETCURSEL, 0, 0);
end;
end;
Win32PosToLCLPos(OwnerObject, XPos, YPos);
End;
End;
WM_PAINT:
@ -642,6 +645,9 @@ end;
{
$Log$
Revision 1.49 2003/08/12 14:02:54 mattias
fixed keypress/keyup, createcaret on synedit focus
Revision 1.48 2003/08/11 20:18:46 mattias
fixed position of control in TGroupBox from Micha

View File

@ -205,9 +205,6 @@ End;
------------------------------------------------------------------------------}
Procedure TWin32ListStringList.Insert(Index: Integer; Const S: String);
Begin
If (FSender.FCompStyle = csComboBox)
and (GetCount <> 0) Then
FSender.Height := (FSender.Height + (FSender.Height Div GetCount));
If FSorted Then
SendMessage(FWin32List,FFlagAddString, 0, LPARAM(PChar(S)))
Else
@ -381,6 +378,9 @@ End;
{ =============================================================================
$Log$
Revision 1.11 2003/08/12 14:02:54 mattias
fixed keypress/keyup, createcaret on synedit focus
Revision 1.10 2003/07/28 06:42:42 mattias
removed debuggging SetName, Patch from Karl Brandt

View File

@ -653,7 +653,11 @@ activate_time : the time at which the activation event occurred.
end
end;
R := Rect(Left, Top, R.Right - R.Left, R.Bottom - R.Top);
ResizeChild(Sender, R.Left, R.Top, R.Right , R.Bottom);
{Adjust for scrollbar}
// if (Windows.GetWindowLong(TWinControl(Sender).Handle, GWL_STYLE) and WS_VSCROLL) <> 0 then
// R.Right := R.Right + GetSystemMetrics(SM_CXVSCROLL);
// if (Windows.GetWindowLong(TWinControl(Sender).Handle, GWL_STYLE) and WS_HSCROLL) <> 0 then
// R.Bottom := R.Bottom + GetSystemMetrics(SM_CYHSCROLL); ResizeChild(Sender, R.Left, R.Top, R.Right , R.Bottom);
end;
end;
End;
@ -2730,6 +2734,9 @@ End;
{
$Log$
Revision 1.83 2003/08/12 14:02:54 mattias
fixed keypress/keyup, createcaret on synedit focus
Revision 1.82 2003/08/11 20:18:46 mattias
fixed position of control in TGroupBox from Micha