diff options
author | Jean-Marc Levecque <jean-marc.levecque@jmlesite.fr> | 2013-03-06 14:11:29 +0100 |
---|---|---|
committer | David Laurence Emerson <dle3ab@angelbase.com> | 2013-05-28 00:42:50 -0700 |
commit | 823c7db4e8374fb01985a0669642b03d5915726d (patch) | |
tree | 1428458de1b10434ff45f40c6581440391897e15 /src | |
parent | fdc1a846f4a47a65de5983ee6fcf2462ffdce151 (diff) | |
download | fpGUI-823c7db4e8374fb01985a0669642b03d5915726d.tar.xz |
Add common procedures in fpg_base for deadkeys
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/fpg_base.pas | 64 | ||||
-rw-r--r-- | src/gui/fpg_edit.pas | 33 | ||||
-rw-r--r-- | src/gui/fpg_editcombo.pas | 33 | ||||
-rw-r--r-- | src/gui/fpg_memo.pas | 33 |
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: |