diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2010-06-10 23:55:50 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2010-06-10 23:55:50 +0200 |
commit | 1c254deea5bdbca3737c0f826542bdf7c8f07752 (patch) | |
tree | 8bbf687f0276eaeb594206a517dbc1a23ef836ea | |
parent | 2362c529cc4d99e0d477ca7f2cdd2feeadc8fac1 (diff) | |
download | fpGUI-1c254deea5bdbca3737c0f826542bdf7c8f07752.tar.xz |
TextEdit: Implemented Home and End keyboard navigation.
-rw-r--r-- | prototypes/textedit/demo_textedit.lpr | 2 | ||||
-rw-r--r-- | prototypes/textedit/fpg_textedit.pas | 93 |
2 files changed, 94 insertions, 1 deletions
diff --git a/prototypes/textedit/demo_textedit.lpr b/prototypes/textedit/demo_textedit.lpr index da961ce5..06e19d63 100644 --- a/prototypes/textedit/demo_textedit.lpr +++ b/prototypes/textedit/demo_textedit.lpr @@ -289,7 +289,7 @@ begin FontDesc := 'Bitstream Vera Sans Mono-10'; // Lines.Insert(1,'0 Beforje 1 after'); ParentShowHint := True; - OnDrawLine := @TextEditDrawLine; +// OnDrawLine := @TextEditDrawLine; end; btnLoad := TfpgButton.Create(self); diff --git a/prototypes/textedit/fpg_textedit.pas b/prototypes/textedit/fpg_textedit.pas index bb313717..8346ce3d 100644 --- a/prototypes/textedit/fpg_textedit.pas +++ b/prototypes/textedit/fpg_textedit.pas @@ -887,10 +887,103 @@ begin keyHome: begin + if not (ssCtrl in ShiftState) and not (ssShift in ShiftState) then + begin + CaretPos.X := 0; + if FSelected then + begin + FSelected := False; + Exit; + end; + end; + if ssCtrl in ShiftState then + begin + if ssShift in ShiftState then + begin + if not FSelected then + begin + FSelStartNo := CaretPos.Y; + FSelStartOffs := CaretPos.X; + FSelected := True; + end; + CaretPos.Y := 0; + CaretPos.X := 0; + FSelEndNo := 0; + FSelEndOffs := 0; + end + else + begin + CaretPos.Y := 0; + CaretPos.X := 0; + end; + Exit; + end; + if ssShift in ShiftState then + begin + if not FSelected then + begin + FSelStartNo := CaretPos.Y; + FSelStartOffs := CaretPos.X; + FSelected := True; + end; + CaretPos.X := 0; + FSelEndNo := CaretPos.Y; + FSelEndOffs := 0; + if FSelEndNo = FSelStartNo then + FSelected := (FSelStartOffs <> FSelEndOffs); + end; end; keyEnd: begin + if not (ssCtrl in ShiftState) and not (ssShift in ShiftState) then + begin + if CaretPos.Y <= pred(FLines.Count) then + CaretPos.X := Length(FLines[CaretPos.Y]) + else + CaretPos.X := 0; + end; + if ssCtrl in ShiftState then + begin + if ssShift in ShiftState then + begin + if not FSelected then + begin + FSelStartNo := CaretPos.Y; + FSelStartOffs := CaretPos.X; + FSelected := True; + end; + CaretPos.Y := pred(FLines.Count); + CaretPos.X := Length(FLines[CaretPos.Y]); + FSelEndNo := pred(FLines.Count); + FSelEndOffs := Length(FLines[CaretPos.Y]); + end else + begin + CaretPos.Y := pred(FLines.Count); + CaretPos.X := Length(FLines[CaretPos.Y]); + end; + Exit; + end; + if ssShift in ShiftState then + begin + if not FSelected then + begin + FSelStartNo := CaretPos.Y; + if CaretPos.Y <= pred(FLines.Count) then + if CaretPos.X > Length(FLines[CaretPos.Y]) then + CaretPos.X := Length(FLines[CaretPos.Y]); + FSelStartOffs := CaretPos.X; + FSelected := True; + end; + if CaretPos.Y <= pred(FLines.Count) then + CaretPos.X := Length(FLines[CaretPos.Y]) + else + CaretPos.X := 0; + FSelEndNo := CaretPos.Y; + FSelEndOffs := CaretPos.X; + if FSelEndNo = FSelStartNo then + FSelected := (FSelStartOffs <> FSelEndOffs); + end; end; keyPrior, keyNext: |