~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/amunits/units/keymap.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
    This file is part of the Free Pascal run time library.
 
3
 
 
4
    A file in Amiga system run time library.
 
5
    Copyright (c) 1998-2003 by Nils Sjoholm
 
6
    member of the Amiga RTL development team.
 
7
 
 
8
    See the file COPYING.FPC, included in this distribution,
 
9
    for details about the copyright.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
14
 
 
15
 **********************************************************************}
 
16
 
 
17
{
 
18
        keymap.resource definitions and console.device key map definitions
 
19
}
 
20
 
 
21
{
 
22
    History:
 
23
 
 
24
    Added the defines use_amiga_smartlink and
 
25
    use_auto_openlib. Implemented autoopening
 
26
    of the library.
 
27
    14 Jan 2003.
 
28
 
 
29
    Changed integer > smallint,
 
30
            cardinal > longword.
 
31
    09 Feb 2003.
 
32
 
 
33
    nils.sjoholm@mailbox.swipnet.se Nils Sjoholm
 
34
}
 
35
 
 
36
{$I useamigasmartlink.inc}
 
37
{$ifdef use_amiga_smartlink}
 
38
   {$smartlink on}
 
39
{$endif use_amiga_smartlink}
 
40
 
 
41
unit keymap;
 
42
 
 
43
INTERFACE
 
44
 
 
45
uses exec, inputevent;
 
46
 
 
47
Type
 
48
 
 
49
    pKeyMap = ^tKeyMap;
 
50
    tKeyMap = record
 
51
        km_LoKeyMapTypes        : Pointer;
 
52
        km_LoKeyMap             : Pointer;
 
53
        km_LoCapsable           : Pointer;
 
54
        km_LoRepeatable         : Pointer;
 
55
        km_HiKeyMapTypes        : Pointer;
 
56
        km_HiKeyMap             : Pointer;
 
57
        km_HiCapsable           : Pointer;
 
58
        km_HiRepeatable         : Pointer;
 
59
    end;
 
60
 
 
61
 
 
62
    pKeymapNode = ^tKeyMapNode;
 
63
    tKeyMapNode = record
 
64
        kn_Node         : tNode;         { including name of keymap }
 
65
        kn_KeyMap       : tKeyMap;
 
66
    end;
 
67
 
 
68
{ the structure of keymap.resource }
 
69
 
 
70
    pKeyMapResource = ^tKeyMapResource;
 
71
    tKeyMapResource = record
 
72
        kr_Node         : tNode;
 
73
        kr_List         : tList;         { a list of KeyMapNodes }
 
74
    end;
 
75
 
 
76
 
 
77
Const
 
78
 
 
79
{ Key Map Types }
 
80
 
 
81
    KC_NOQUAL           = 0;
 
82
    KC_VANILLA          = 7;    { note that SHIFT+ALT+CTRL is VANILLA }
 
83
    KCB_SHIFT           = 0;
 
84
    KCF_SHIFT           = $01;
 
85
    KCB_ALT             = 1;
 
86
    KCF_ALT             = $02;
 
87
    KCB_CONTROL         = 2;
 
88
    KCF_CONTROL         = $04;
 
89
    KCB_DOWNUP          = 3;
 
90
    KCF_DOWNUP          = $08;
 
91
 
 
92
    KCB_DEAD            = 5;    { may be dead or modified by dead key:  }
 
93
    KCF_DEAD            = $20;  {   use dead prefix bytes               }
 
94
 
 
95
    KCB_STRING          = 6;
 
96
    KCF_STRING          = $40;
 
97
 
 
98
    KCB_NOP             = 7;
 
99
    KCF_NOP             = $80;
 
100
 
 
101
 
 
102
{ Dead Prefix Bytes }
 
103
 
 
104
    DPB_MOD             = 0;
 
105
    DPF_MOD             = $01;
 
106
    DPB_DEAD            = 3;
 
107
    DPF_DEAD            = $08;
 
108
 
 
109
    DP_2DINDEXMASK      = $0f;  { mask for index for 1st of two dead keys }
 
110
    DP_2DFACSHIFT       = 4;    { shift for factor for 1st of two dead keys }
 
111
 
 
112
VAR KeymapBase : pLibrary;
 
113
 
 
114
const
 
115
    KEYMAPNAME : PChar = 'keymap.library';
 
116
 
 
117
FUNCTION AskKeyMapDefault : pKeyMap;
 
118
FUNCTION MapANSI(thestring : pCHAR; count : LONGINT; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
 
119
FUNCTION MapRawKey(event : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : smallint;
 
120
PROCEDURE SetKeyMapDefault(keyMap : pKeyMap);
 
121
 
 
122
IMPLEMENTATION
 
123
 
 
124
uses msgbox;
 
125
 
 
126
FUNCTION AskKeyMapDefault : pKeyMap;
 
127
BEGIN
 
128
  ASM
 
129
    MOVE.L  A6,-(A7)
 
130
    MOVEA.L KeymapBase,A6
 
131
    JSR -036(A6)
 
132
    MOVEA.L (A7)+,A6
 
133
    MOVE.L  D0,@RESULT
 
134
  END;
 
135
END;
 
136
 
 
137
FUNCTION MapANSI(thestring : pCHAR; count : LONGINT; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
 
138
BEGIN
 
139
  ASM
 
140
    MOVE.L  A6,-(A7)
 
141
    MOVEA.L thestring,A0
 
142
    MOVE.L  count,D0
 
143
    MOVEA.L buffer,A1
 
144
    MOVE.L  length,D1
 
145
    MOVEA.L keyMap,A2
 
146
    MOVEA.L KeymapBase,A6
 
147
    JSR -048(A6)
 
148
    MOVEA.L (A7)+,A6
 
149
    MOVE.L  D0,@RESULT
 
150
  END;
 
151
END;
 
152
 
 
153
FUNCTION MapRawKey(event : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : smallint;
 
154
BEGIN
 
155
  ASM
 
156
    MOVE.L  A6,-(A7)
 
157
    MOVEA.L event,A0
 
158
    MOVEA.L buffer,A1
 
159
    MOVE.L  length,D1
 
160
    MOVEA.L keyMap,A2
 
161
    MOVEA.L KeymapBase,A6
 
162
    JSR -042(A6)
 
163
    MOVEA.L (A7)+,A6
 
164
    MOVE.L  D0,@RESULT
 
165
  END;
 
166
END;
 
167
 
 
168
PROCEDURE SetKeyMapDefault(keyMap : pKeyMap);
 
169
BEGIN
 
170
  ASM
 
171
    MOVE.L  A6,-(A7)
 
172
    MOVEA.L keyMap,A0
 
173
    MOVEA.L KeymapBase,A6
 
174
    JSR -030(A6)
 
175
    MOVEA.L (A7)+,A6
 
176
  END;
 
177
END;
 
178
 
 
179
{$I useautoopenlib.inc}
 
180
{$ifdef use_auto_openlib}
 
181
  {$Info Compiling autoopening of keymap.library}
 
182
 
 
183
var
 
184
    keymap_exit : Pointer;
 
185
 
 
186
procedure ClosekeymapLibrary;
 
187
begin
 
188
    ExitProc := keymap_exit;
 
189
    if KeymapBase <> nil then begin
 
190
        CloseLibrary(KeymapBase);
 
191
        KeymapBase := nil;
 
192
    end;
 
193
end;
 
194
 
 
195
const
 
196
    { Change VERSION and LIBVERSION to proper values }
 
197
 
 
198
    VERSION : string[2] = '0';
 
199
    LIBVERSION : longword = 0;
 
200
 
 
201
begin
 
202
    KeymapBase := nil;
 
203
    KeymapBase := OpenLibrary(KEYMAPNAME,LIBVERSION);
 
204
    if KeymapBase <> nil then begin
 
205
        keymap_exit := ExitProc;
 
206
        ExitProc := @ClosekeymapLibrary
 
207
    end else begin
 
208
        MessageBox('FPC Pascal Error',
 
209
        'Can''t open keymap.library version ' + VERSION + #10 +
 
210
        'Deallocating resources and closing down',
 
211
        'Oops');
 
212
        halt(20);
 
213
    end;
 
214
 
 
215
{$else}
 
216
   {$Warning No autoopening of keymap.library compiled}
 
217
   {$Info Make sure you open keymap.library yourself}
 
218
{$endif use_auto_openlib}
 
219
 
 
220
 
 
221
END. (* UNIT KEYMAP *)
 
222
 
 
223
 
 
224