home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 2
/
FFMCD02.bin
/
new
/
amigalibdisks
/
disk933
/
editkeys
/
loadkeymap.e
< prev
next >
Wrap
Text File
|
1993-12-21
|
3KB
|
118 lines
/*************************/
/* */
/* LoadKeymap v1.0 */
/* © 1993 David Kinder */
/* */
/*************************/
OPT OSVERSION = 36
MODULE 'asl','libraries/asl',
'devices/console','devices/keymap',
'exec/io','exec/nodes','exec/ports',
'intuition/intuition',
'utility/tagitem',
'workbench/startup'
DEF wb : PTR TO wbstartup,
mapname[256] : STRING,
gotone,version,olddir
PROC main()
version := '$VER: LoadKeymap 1.0 (11.9.93)'
IF (wb := wbmessage) = NIL THEN getargs() ELSE wbargs()
IF gotone THEN loadmap()
ENDPROC
PROC pickmap()
DEF req : PTR TO filerequestr
IF aslbase := OpenLibrary('asl.library',36)
IF req := AllocAslRequest(ASL_FILEREQUEST,
[ASL_HAIL,'Load keymap',
ASL_OKTEXT,'Load',
ASL_PATTERN,'~(#?.info)',
TAG_DONE])
IF AslRequest(req,[TAG_DONE])
StrCopy(mapname,req.dir,ALL)
AddPart(mapname,req.file,256)
IF StrLen(req.file) > 0 THEN gotone := TRUE
ENDIF
FreeAslRequest(req)
ENDIF
CloseLibrary(aslbase)
ELSE
exit('Could not open asl.library')
ENDIF
ENDPROC
PROC wbargs()
DEF args : PTR TO wbarg
args := wb.arglist
IF wb.numargs = 1
olddir := CurrentDir(args[0].lock)
pickmap()
ELSE
olddir := CurrentDir(args[1].lock)
StrCopy(mapname,args[1].name,ALL)
gotone := TRUE
ENDIF
ENDPROC
PROC exit(errstring)
IF stdout = NIL
EasyRequestArgs(0,[SIZEOF easystruct,0,'LoadKeymap',errstring,'Cancel'],
0,NIL)
ELSE
WriteF('\s\n',errstring)
ENDIF
finish()
ENDPROC
PROC finish()
IF olddir <> NIL THEN CurrentDir(olddir)
CleanUp(0)
ENDPROC
PROC getargs()
DEF myarg : PTR TO LONG,
rdargs
myarg := [0]
rdargs := [0,0,0,0,0,0,'LoadKeymap v1.0\n© 1993 David Kinder\nKEYMAP',0]
IF ReadArgs('KEYMAP',myarg,rdargs)
StrCopy(mapname,myarg[0],ALL)
ELSE
PrintFault(IoErr(),NIL)
FreeArgs(rdargs)
finish()
ENDIF
FreeArgs(rdargs)
IF StrLen(mapname) = 0 THEN pickmap() ELSE gotone := TRUE
ENDPROC
PROC loadmap()
DEF iomsg : PTR TO mp,
ior : PTR TO iostd,
seg
IF seg := LoadSeg(mapname)
IF iomsg := CreateMsgPort()
IF ior := CreateIORequest(iomsg,SIZEOF iostd)
IF OpenDevice('console.device',-1,ior,0) = 0
ior.command := CD_SETDEFAULTKEYMAP
ior.length := SIZEOF keymap
ior.data := Shl(seg,2) + SIZEOF ln + 4
DoIO(ior)
CloseDevice(ior)
ENDIF
DeleteIORequest(ior)
ENDIF
DeleteMsgPort(iomsg)
ENDIF
ELSE
exit('Could not load keymap')
ENDIF
ENDPROC