move to the contrib location where the datatype resides
[AROS-Contrib.git] / fish / cfn / readme_programmer
bloba3fd6032ae4dccd6552899cecd9febf75ce42df3
1 Here is a brief description of how CFN works:
4 Generally, all input have to be filtered just before the console device.
5 So I install an input handler at priority 1 (console.device has 0,
6 intuition 50).
8 This input handler gets all input for a console window (== a Shell),
9 but it does only look at the keys.
11 Normally, all incoming characters are buffered (all RAWKEY-events)
12 and returned to the input.device.
13 The buffer is cleared when either a SPACE, a RETURN or an Arrow-Key 
14 is pressed. So, when the user is typing a filename, the buffer contains 
15 the part of the filename which is typed so far.
16 Just the plain RAWKEY-events are buffered for speed reasons. (The
17 RKM says it is best to write an input handler in assembler, but for
18 convenience, I used C...)
20 When the TAB-key is encoutered, the buffer is locked (buf_busy=TRUE;)
21 so that no more characters are buffered, and the main process
22 (serve_handler()) gets a signal. This process converts the RAWKEY-events
23 contained in the buffer to a sensible string (using the keymap.device)
24 and tries to complete the filename whose first part is in the buffer.
27 And here is one of the problems I had:
28 I did not found any possibility to find out, in which CLI-process the user
29 is working. But I need the process structure to find the current
30 directory :(
31 As a solution, I use the following method:
32 The program "cfn_newshell" is started whenever a new shell process is
33 launched, because it's executed in the S:shell-startup script. This
34 little program gets a pointer to the current process structure and
35 stores it in the window->UserData pointer of the currently active
36 window (which is the Shell-window) if there is one.
37 I told you it's a hack :)
39 To get the process pointer back, I examine the UserData field of the
40 currently active window. btw: The current window is contained in the
41 IntuitionBase structure.
44 Now, back to our process:
45 It sets its current dir to the one of the Shell process, searches the
46 typed file/directory with a concatenated pattern and filters the 
47 biggest common part of all found names.
48 Then the found completion is send to the input.device, the buffer is
49 unlocked and the CurrentDir is set back (to prevent the locks from
50 staying unused in memory).
52 The input.device then handles the completion as if they were typed
53 on the keyboard, which has the nice effect that our input-handler
54 gets them and appends them to our buffer and that they are received
55 by the console.device and the Shell itself.
59 For more details, look into the source code and the RKM's (especially
60 the "Devices"-part for the input-handler).
64 Yours,
65         Andreas
70 my address:
72 Andreas Günther               Tel.:  05251/63412
73 Alfener Weg 10                email: guenther@uni-paderborn.de
74 D-33100 Paderborn