summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Marc Levecque <jean-marc.levecque@jmlesite.fr>2013-03-06 14:11:29 +0100
committerGraeme Geldenhuys <graemeg@gmail.com>2013-03-22 16:29:58 +0000
commitccfd4b2ae0a9dfae0d19ae7ba673118af70c75da (patch)
tree9e9c310c4a04170bd66b4e2d47a575359cb96dcc /src
parent5ee5b79db4825a3b2afa03dde72ddbe7e46b3c47 (diff)
downloadfpGUI-ccfd4b2ae0a9dfae0d19ae7ba673118af70c75da.tar.xz
Add common procedures in fpg_base for deadkeys
Diffstat (limited to 'src')
-rw-r--r--src/corelib/fpg_base.pas64
-rw-r--r--src/gui/fpg_edit.pas33
-rw-r--r--src/gui/fpg_editcombo.pas33
-rw-r--r--src/gui/fpg_memo.pas33
4 files changed, 73 insertions, 90 deletions
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas
index 3eae947a..5158540e 100644
--- a/src/corelib/fpg_base.pas
+++ b/src/corelib/fpg_base.pas
@@ -744,6 +744,8 @@ type
{ Keyboard }
function KeycodeToText(AKey: Word; AShiftState: TShiftState): string;
function CheckClipboardKey(AKey: Word; AShiftstate: TShiftState): TClipboardKeyType;
+function UseDeadKey(AChar: TfpgChar; AKey: word): TfpgChar;
+function ReadDeadKey(AKey: word): integer;
{ Color }
function fpgColorToRGBTriple(const AColor: TfpgColor): TRGBTriple;
@@ -965,6 +967,68 @@ begin
end { if/else }
end;
+function UseDeadKey(AChar: TfpgChar; AKey: word): TfpgChar;
+begin
+ case AKey of
+ keyDeadCircumflex:
+ case AChar of
+ 'a':
+ Result:= 'â';
+ 'e':
+ Result:= 'ê';
+ 'i':
+ Result:= 'î';
+ 'o':
+ Result:= 'ô';
+ 'u':
+ Result:= 'û';
+ 'A':
+ Result:= 'Â';
+ 'E':
+ Result:= 'Ê';
+ 'I':
+ Result:= 'Î';
+ 'O':
+ Result:= 'Ô';
+ 'U':
+ Result:= 'Û';
+ end;
+ keyDeadDiaeresis:
+ case AChar of
+ 'a':
+ Result:= 'ä';
+ 'e':
+ Result:= 'ë';
+ 'i':
+ Result:= 'ï';
+ 'o':
+ Result:= 'ö';
+ 'u':
+ Result:= 'ü';
+ 'A':
+ Result:= 'Ä';
+ 'E':
+ Result:= 'Ë';
+ 'I':
+ Result:= 'Ï';
+ 'O':
+ Result:= 'Ö';
+ 'U':
+ Result:= 'Ü';
+ end;
+ end;
+end;
+
+function ReadDeadKey(AKey: word): integer;
+begin
+ case AKey of
+ keyDeadCircumflex, keyDeadDiaeresis:
+ Result := AKey;
+ else
+ Result := -1;
+ end;
+end;
+
function fpgColorToRGBTriple(const AColor: TfpgColor): TRGBTriple;
begin
with Result do
diff --git a/src/gui/fpg_edit.pas b/src/gui/fpg_edit.pas
index 01c52d4c..21e6895e 100644
--- a/src/gui/fpg_edit.pas
+++ b/src/gui/fpg_edit.pas
@@ -758,34 +758,7 @@ begin
prevval := Text;
if FDeadKeyChar> -1 then
begin
- case FDeadKeyChar of
- keyDeadDiaeresis:
- case AText of
- 'a':
- AText:= 'â';
- 'e':
- AText:= 'ë';
- 'i':
- AText:= 'ï';
- 'o':
- AText:= 'ö';
- 'u':
- AText:= 'ü';
- end;
- keyDeadCircumflex:
- case AText of
- 'a':
- AText:= 'â';
- 'e':
- AText:= 'ê';
- 'i':
- AText:= 'î';
- 'o':
- AText:= 'ô';
- 'u':
- AText:= 'û';
- end;
- end;
+ AText:= UseDeadKey(AText, FDeadKeyChar);
FDeadKeyChar:= -1;
end;
s := AText;
@@ -831,8 +804,8 @@ begin
hasChanged := False;
fpgApplication.HideHint;
- if (keycode= keyDeadCircumflex) or (keycode= keyDeadDiaeresis) then
- FDeadKeyChar:= keycode;
+ if FDeadKeyChar = -1 then
+ FDeadKeyChar:= ReadDeadKey(keycode);
Consumed := True;
case CheckClipBoardKey(keycode, shiftstate) of
diff --git a/src/gui/fpg_editcombo.pas b/src/gui/fpg_editcombo.pas
index 72b804ef..9145d641 100644
--- a/src/gui/fpg_editcombo.pas
+++ b/src/gui/fpg_editcombo.pas
@@ -526,34 +526,7 @@ begin
prevval := FText;
if FDeadKeyChar> -1 then
begin
- case FDeadKeyChar of
- keyDeadDiaeresis:
- case AText of
- 'a':
- AText:= 'â';
- 'e':
- AText:= 'ë';
- 'i':
- AText:= 'ï';
- 'o':
- AText:= 'ö';
- 'u':
- AText:= 'ü';
- end;
- keyDeadCircumflex:
- case AText of
- 'a':
- AText:= 'â';
- 'e':
- AText:= 'ê';
- 'i':
- AText:= 'î';
- 'o':
- AText:= 'ô';
- 'u':
- AText:= 'û';
- end;
- end;
+ AText:= UseDeadKey(AText, FDeadKeyChar);
FDeadKeyChar:= -1;
end;
s := AText;
@@ -617,8 +590,8 @@ var
begin
hasChanged := False;
- if (keycode= 58536) or (keycode= 58462) then
- FDeadKeyChar:= keycode;
+ if FDeadKeyChar = -1 then
+ FDeadKeyChar:= ReadDeadKey(keycode);
if not Enabled then
consumed := False
diff --git a/src/gui/fpg_memo.pas b/src/gui/fpg_memo.pas
index c0b227ae..2769e4d4 100644
--- a/src/gui/fpg_memo.pas
+++ b/src/gui/fpg_memo.pas
@@ -1064,34 +1064,7 @@ begin
prevval := Text;
if FDeadKeyChar> -1 then
begin
- case FDeadKeyChar of
- keyDeadDiaeresis:
- case AText of
- 'a':
- AText:= 'â';
- 'e':
- AText:= 'ë';
- 'i':
- AText:= 'ï';
- 'o':
- AText:= 'ö';
- 'u':
- AText:= 'ü';
- end;
- keyDeadCircumflex:
- case AText of
- 'a':
- AText:= 'â';
- 'e':
- AText:= 'ê';
- 'i':
- AText:= 'î';
- 'o':
- AText:= 'ô';
- 'u':
- AText:= 'û';
- end;
- end;
+ AText:= UseDeadKey(AText, FDeadKeyChar);
FDeadKeyChar:= -1;
end;
s := AText;
@@ -1142,8 +1115,8 @@ begin
Consumed := True;
hasChanged := False;
- if (keycode= 58536) or (keycode= 58462) then
- FDeadKeyChar:= keycode;
+ if FDeadKeyChar = -1 then
+ FDeadKeyChar:= ReadDeadKey(keycode);
case CheckClipBoardKey(keycode, shiftstate) of
ckCopy: