Category : Utilities for DOS and Windows Machines
Archive   : 4MAP.ZIP
Filename : 4MAP.DOC

 
Output of file : 4MAP.DOC contained in archive : 4MAP.ZIP





4MAP
Version 1.01

A Keybinding Program for 4DOS
by
Ho-Ping Tseng

(c) Copyright 1990 by Ho-Ping Tseng, ALL RIGHTS RESERVED










4DOS a registered trademark of J.P. Software






This program may be freely distributed for non-commercial, non-business,
and non-governmental uses, provided this notice is attached with it. My
only request is that if you plan to use it regularly, you let me know of
it through e-mail or postal mail, so that I have an idea of how useful
this program is. Please let me know of any comments that you may have
and any suggestions or criticisms.


Ho-Ping Tseng
575 S. Rengstorff Ave., #26
Mountain View, Ca. 94040
e-mail: [email protected]







1. INTRODUCTION

This program provides two basic capabilities for the 4DOS command
line processing. First, it filters keyboard inputs through a user-defined
keymap, before they reach 4DOS. Second, it can launch executable programs
in response to keystrokes while within the 4DOS command line.


With these two functions, a user can customize and remap 4DOS key
definitions. In addition, 4DOS command line editing functions may be
expanded. As an example, a minimal vi-like implementation is included that
uses many of the keys familiar to vi users and provides similar edit and
insert modes.


Note that this program differs in purpose to that of the conventional
keymapping programs. It is meant to take effect only during command line
processing, and it can map keystrokes sequences, not just a single keystroke.
Also, editing functions can be added on top of that provided by 4DOS with
its program launching capability.



2. REQUIREMENTS

This program is implemented as a terminate and stay resident routine
(TSR). It takes up about 2500 bytes of memory. It has been tested on the
latest versions of 4DOS (3.01 and 3.02).



3. FILES

The basic functionalities of this program is included in 3 files:
"4map.exe," "putmap.exe," and "mapdef." 4map.exe implements the filter and
stays resident in memory. Putmap.exe installs the user-defined keymap into
memory. And finally, mapdef contains an example keymap.


Also included is "edit.zip," which contains programs that perform
miscellaneous command line editing functions. They are invoked by 4map.exe
in response to keystroke sequences defined by mapdef.



4. INSTALLATION

4map.exe and putmap.exe can be run from the command line or more
conveniently placed in autoexec.bat. They can be run either before or
after starting 4DOS. To run, type the following or include them in
autoexec.bat:
4map
putmap mapdef


This assumes, of course, that 4map.exe and putmap.exe are placed
in a directory that is in the search path. Also, if mapdef is not in the
current directory (root if these were invoked in autoexec.bat), its full
pathname must be specified.


To install the programs in edit.zip, as defined by the contents of
mapdef, make a directory on the C partition of the disk called MAP and copy
edit.zip into it. Then unzip edit.zip.


Note that the functionalities provided by edit.zip is optional, and
map.exe would function equally well (albeit without these functions) even
if it is not installed.


The contents and format of the map definition are discussed next,
plus a description of mapdef and edit.zip.



5. MAP DEFINITIONS

A keymap file contains definitions of keystroke mappings that 4MAP
uses to perform its operations. Several sets of mappings are allowed in
this file (with the first set being the default used when a keymap is first
installed), and 4MAP gives provisions for switching from one to another.
This will be described in more detail later. For convenience, when a "map"
is referred to below, it will mean a set of these mappings.


Each map is defined by the construct:

mapname = { rule1 ;
rule2 ;
.
.
.
ruleN ; }

where "mapname" is a name given to this map and "ruleX" refers to the Xth
mapping rule. '= {', ';', and '}' correspond to delimiters required by
4MAP.


Each rule is further represented by two fields, the "pattern" and
its "binding", defined by the construct:

pattern => binding

"Pattern" denotes a sequence of keystrokes that is used to match the
keyboard input. 4MAP successively examines each pattern according to
its location in the map, with the ones closer to the beginning of the
map searched first. When a partial match occurs (the input sequence
matches the pattern so far but is shorter than the pattern), the search
is suspended until more input is received. At the first instance that
4MAP can determine whether or not the input sequence produces a match,
certain actions are performed. If a match did occur, "binding" is
executed. Otherwise the input sequence is sent to 4DOS unmodified.



5.1 The Pattern

Each pattern may contain keynames (such as "del" and "home")
ascii codes, random keystrokes (e.g. abcd), and wildcard characters.
Keynames are reserved words and are provided for convenience. A list
of them is provided in the Appendix. Ascii codes may be specified in
octal (preceded by 0, such as 0101 for the character 'A'), decimal
(such as 65 for 'A'), or hex format (preceded by 0x, such as 0x41 for
'A'). Wildcard characters include '?' for matching any single keystroke
and '*' for matching any sequence of keystrokes. The special character
'\' is used as an escape character, so that the character immediately
following it is used literally as part of the pattern. To use '\' in
the pattern, just enter '\\' instead. Also, commas, spaces, tabs, and
carriage returns are treated as delimiters and ignored; they must be
preceded by '\' to be part of the pattern (or specified by keynames
where appropriate or in ascii codes).


For example,

ab, del \4 ?s

denotes a keystroke sequence of: 'a', 'b', the delete key, '4', any keystroke,
and 's'. Note that in order to avoid '4' from being treated as control-d
rather than the key '4', it must be preceded by the escape character. In
general, all numerals are treated as ascii codes unless preceded by '\'.


To use the sequence 'd', 'e', 'l' as part of the pattern rather
than to specify the delete key, the above pattern may be changed to:

ab, \del \4 ?s
or ab, d el \4 ?s

or variations of these.



5.2 The Binding

A binding represents a list of actions that is performed when
its corresponding pattern matches the keyboard input. It is separated
from the pattern by the delimiter '=>' and can be classified into two
basic types. Each of these are described below.


The first type simply performs the mapping function--given an
input that matches the pattern, certain keystroke sequence is sent to
4DOS as though it had just been typed by the user. To specify the
sequence, similar mechanism to that used to specify the patterns is
used here--it is specified with keynames, ascii codes, and random
keystrokes. As with patterns, commas, spaces, tabs, and carriage
returns are used as delimiters, and '\' is used as the escape character.
The various rules described above for the pattern specifications apply
here as well (except wildcard characters are not used here). For example,

k => del ins a ins

maps 'k' into the sequence: del, ins, 'a', and ins. In the context of 4DOS,
this would mean that whenever 'k' is typed, the character at the cursor is
replaced by the character 'a'.


The second type consists of command requests to 4MAP. It currently
includes a command to change the current map and one to invoke a program.


Switching to another map is facilitated by the keyword "changemap".
When the binding containing this keyword is executed, the current map is
changed to the one specified by the argument of "changemap", and subsequent
inputs are mapped according to the definitions given in this new map. Thus,

i => changemap insert

would change the current map to "insert". Using this mechanism, several
maps may be defined that could provide different mapping characteristics
or "modes." In the keymap provided, this is used to simulate the insert
and edit modes of vi. Note that when a keymap file is first installed,
the first map becomes the current one.


Invoking a program requires enclosing the full pathname of the
program file and its arguments inside the special character '`' (back
quote). It is used to launch a program in response to an input sequence.
For example,

i => changemap insert, `\map\prog.exe 2`

changes the current map to "insert" and executes \map\prog.exe with an
argument of 2 when 'i' is typed. Note that to accommodate DOS and for
convenience, '\' is not recognized as an escape character within the back
quotes--there is no escape mechanism for program name specification. Also,
no error message is displayed if an error is encountered while executing the
program. In particular, if the program file does not exist, no action is
performed.



5.3 Comments

Comments may be inserted anywhere in the keymap file to increase
readability. They are delimited by '/*' at the beginning and '*/' at
the end--everything in between is ignored.



5.4 Special Characters

As a summary, characters or character sequences possessing special
meanings to 4MAP are listed below:

\ Escape character used in the patterns and the parts
of the bindings which specify the character mappings
= { Beginning of a map definition
=> End of pattern field and beginning of binding field
; End of binding field and a mapping rule definition
} End of a map definition
/* Beginning of a comment
*/ End of a comment
, Delimiter used in the pattern and binding
0 through 9 Denote literal ascii codes
white spaces Delimit keynames and otherwise ignored



6. MAPDEF and EDIT.ZIP

As an example of the capabilities of 4MAP, a keymap definition
file is included. It defines three modes: command, insert, and edit.
In the following descriptions, '^X' will denote control-X (the keystroke
where the control key is held down while simultaneously hitting 'X').


6.1 Command Mode

At the beginning of each command line editing session, the command map
is used. This mode has very similar key-bindings to the 4DOS specifications,
with a few modifications:

^U Deletes the whole line
^W Deletes the previous word
^D Filename completion
^B Filename completion looping opposite direction to ^D
^K Previous command line in the history list
^J Next command line in the history list
esc Changes to edit mode
ins Changes to insert mode


6.2 Insert Mode

In this mode, all inputs are entered onto the command line without
deleting what was originally there. Aside from that, it is very similar
to the command mode:

^U Deletes the whole line
^W Deletes the previous word
^D Filename completion
^B Filename completion looping opposite direction to ^D
esc Changes to edit mode
ins Changes to command mode


6.3 Edit Mode

In this mode, all keystrokes correspond to commands and are not
considered input to the command line:

a Moves one space to the right and changes to insert mode
b Moves one word back
dd Deletes the whole line
dw Deletes the word to the right of the cursor
f Finds the character to the right corresponding to
the character
h Moves one character to the left
i Changes to insert mode
j Next command line in the history list
k Previous command line in the history list
l Moves one character to the right
r Changes the character to
w Moves one word forward
x Deletes character
D Deletes the rest of the line
0 Goes to the beginning of the line
$ Goes to the end of the line
space Moves one character to the right
^U Deletes the whole line
^W Deletes the previous word
^D Filename completion
^B Filename completion looping opposite direction to ^D
^K Previous command line in the history list
^J Next command line in the history list
esc Changes to command mode
ins Changes to insert mode


6.4 Edit.zip

This file contains programs that are invoked in mapdef. These
include the following:

f.exe Implements the find character function in edit mode
on.exe Prints 'EDIT' on the right upper corner of the screen
off.exe Erases 'EDIT' on the right upper corner of the screen
ion.exe Prints 'INS' on the right upper corner of the screen
ioff.exe Erases 'INS' on the right upper corner of the screen
r.exe Implements the replace character function in edit mode


As it is, these programs must be located in C:\MAP. To move them into
a different directory, mapdef must be modified to incorporate the new path.



7. CAVEATS

Care should be taken if a program is to be bound and launched. In
particular, it is found that launching command.com does not work and may
hang the machine.


To keep the size down, the internal buffer sizes are minimized.
This reduces the size of the resident keymap definitions to a total of
about 550 bytes. (The keymap file can be slightly larger than this but
is roughly proportional.) Mapdef, as it is, takes up a great portion of
the 550 bytes. Also as a consequence of the small buffers, "f.exe" can
only advance at most 16 characters to the right at a time, even though it
may find a matching character farther away.


These limitation and further improvements may occur in future
versions depending on the demand and the author's time.



APPENDIX

Here is a list of keynames that 4MAP recognizes with their
corresponding scan code or ascii code:

nul 0x00
ctrl_a 0x01
ctrl_b 0x02
ctrl_c 0x03
ctrl_d 0x04
ctrl_e 0x05
ctrl_f 0x06
ctrl_g 0x07
ctrl_h 0x08
ctrl_i 0x09
ctrl_j 0x0a
ctrl_k 0x0b
ctrl_l 0x0c
ctrl_m 0x0d
ctrl_n 0x0e
ctrl_o 0x0f
ctrl_p 0x10
ctrl_q 0x11
ctrl_r 0x12
ctrl_s 0x13
ctrl_t 0x14
ctrl_u 0x15
ctrl_v 0x16
ctrl_w 0x17
ctrl_x 0x18
ctrl_y 0x19
ctrl_z 0x1a
esc 0x1b
sp 0x20
cr 0x0d
lf 0x0a
tab 0x09
f1 0x00 0x3b
f2 0x00 0x3c
f3 0x00 0x3d
f4 0x00 0x3e
f5 0x00 0x3f
f6 0x00 0x40
f7 0x00 0x41
f8 0x00 0x42
f9 0x00 0x43
f10 0x00 0x44
home 0x00 0x47
up 0x00 0x48
pageup 0x00 0x49
left 0x00 0x4b
right 0x00 0x4d
end 0x00 0x4f
down 0x00 0x50
pagedown 0x00 0x51
ins 0x00 0x52
del 0x00 0x53
shft_f1 0x00 0x54
shft_f2 0x00 0x55
shft_f3 0x00 0x56
shft_f4 0x00 0x57
shft_f5 0x00 0x58
shft_f6 0x00 0x59
shft_f7 0x00 0x5a
shft_f8 0x00 0x5b
shft_f9 0x00 0x5c
shft_f10 0x00 0x5d
ctrl_f1 0x00 0x5e
ctrl_f2 0x00 0x5f
ctrl_f3 0x00 0x60
ctrl_f4 0x00 0x61
ctrl_f5 0x00 0x62
ctrl_f6 0x00 0x63
ctrl_f7 0x00 0x64
ctrl_f8 0x00 0x65
ctrl_f9 0x00 0x66
ctrl_f10 0x00 0x67
alt_f1 0x00 0x68
alt_f2 0x00 0x69
alt_f3 0x00 0x6a
alt_f4 0x00 0x6b
alt_f5 0x00 0x6c
alt_f6 0x00 0x6d
alt_f7 0x00 0x6e
alt_f8 0x00 0x6f
alt_f9 0x00 0x70
alt_f10 0x00 0x71
ctrl_left 0x00 0x73
ctrl_right 0x00 0x74
ctrl_end 0x00 0x75
ctrl_pagedown 0x00 0x76
ctrl_home 0x00 0x77
ctrl_pageup 0x00 0x84


  3 Responses to “Category : Utilities for DOS and Windows Machines
Archive   : 4MAP.ZIP
Filename : 4MAP.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/