mirror of
https://github.com/elliotnunn/mac-rom.git
synced 2024-12-29 07:29:15 +00:00
1950 lines
82 KiB
Plaintext
1950 lines
82 KiB
Plaintext
|
;
|
|||
|
; File: ScriptMgrKbdMenu.a
|
|||
|
;
|
|||
|
; Contains: Initialization of the new Keyboard Menu in the System Menu bar.
|
|||
|
;
|
|||
|
; Written by: SMB Sue Bartalo
|
|||
|
;
|
|||
|
; Copyright: <09> 1990-1993 by Apple Computer, Inc., all rights reserved.
|
|||
|
;
|
|||
|
; Change History (most recent first):
|
|||
|
;
|
|||
|
; <43> 4/2/93 YK Initialize D0 to zero before getting a length byte into the
|
|||
|
; lowest byte.
|
|||
|
; <42> 3/27/93 YK Use system script font for <20>About Keyboards<64><73> menu item.
|
|||
|
; <41> 1/19/93 PKE Update include file names: PackMacs.a->Packages.a. No effect on
|
|||
|
; objects.
|
|||
|
; <40> 6/26/92 SMB #1033660,<kst>: When we realized that Simplified Chinese
|
|||
|
; TSM-style IMs were not getting correctly installed as a result
|
|||
|
; of a flag value being defined incorrectly, we discovered some
|
|||
|
; other minor bugs: extra TSM-style IMs were getting installed
|
|||
|
; because the inputMethodCount also reflected the old-style IM
|
|||
|
; count. Will now use this only for the count of TSM-style IMs and
|
|||
|
; will use CJKcount to determine if any input methods are
|
|||
|
; installed as appropriate (in BuildKCHRTable, etc.)
|
|||
|
; <39> 6/18/92 csd #1030826 <SMB>: Fixed a bug in BuildIMTable where register d5
|
|||
|
; was being initialized too late. It would get used with garbage
|
|||
|
; in it if there were no input methods installed.
|
|||
|
; <38> 6/17/92 SMB #1030826,<ha>: Check if an old-style IM is "ready" before
|
|||
|
; installing it and if not, am updating the KCHR count and IM
|
|||
|
; count appropriately. Now using STR# (kKeyboardMenuItemsID)
|
|||
|
; instead of STR# (kKeyboardMenuID) Now using intfName instead of
|
|||
|
; intfFile for the IM name in the menu.
|
|||
|
; <37> 5/31/92 FM Removed obsolete conditional ScriptMgrKeyboardMenu. I would
|
|||
|
; like to remove DoCmdKeyEquivalents too but I guess I'll wait on
|
|||
|
; that.
|
|||
|
; <36> 5/12/92 SMB #1026017,<pke>: Removed code that error exited if 'kcs4' is not
|
|||
|
; available. If 'kcs4' icon is not available will simply use
|
|||
|
; 'kcs#' icon. Also, fixed stupid code in RebuildKeybdMenu that
|
|||
|
; causes rebuilding of menu d.s. to crash when a menu isn't
|
|||
|
; available. #1029051, 1029243, 1024274 also.
|
|||
|
; <35> 4/8/92 SMB #1026904,<ys>: #1026904,<ys>: Must set ResLoad to true around
|
|||
|
; call to localGetIndString for the <20>About Keyboards<64><73> string. The
|
|||
|
; resource was getting purged so was using an empty handle; also
|
|||
|
; changed the localGetIndString code to test the dereferenced
|
|||
|
; handle and to do a LoadResource if the handle was empty (for
|
|||
|
; correctness). This removes the dependency on ResLoad being true.
|
|||
|
; <34> 4/6/92 SMB #1024274,<pke>: General cleanup: remove hardcoding of "About
|
|||
|
; Keyboards<64>" added in <33> when the resource isn't available. Now
|
|||
|
; getting "About Keyboards<64>" using GetIndString; removed
|
|||
|
; unnecessary code. Since using "oldJIMCount" for a test rather
|
|||
|
; than for a count, now setting a bit "HaveOldJapanIMbit" in
|
|||
|
; CJKcount instead. No longer testing for existance of component
|
|||
|
; mgr (it exists). Fixed bug in AddMenuItem where old-style IM
|
|||
|
; itemRsrcID was getting written to script word instead of
|
|||
|
; language word of scriptLangRec. In AddMenuItem, need to call
|
|||
|
; SetScript with secret script flag 'kUsingOldInputMethodVerb'
|
|||
|
; when old-style IM becomes the default (after call to InformTSM).
|
|||
|
; In RebuildKeybdMenu, the equ for frame size was above the local
|
|||
|
; variable menuH, so the link instruction wasn't actually grabbing
|
|||
|
; enough stack space. Fixed now; been around since the routines
|
|||
|
; inception. (also, probably the writing to 0 bug: 1024274).
|
|||
|
; <33> 2/22/92 KST Fixed 2 bugs related to "menuItemStringHdl": 1. If we can't get
|
|||
|
; the resource, menuItemStringHdl was not cleared. 2. Need to make
|
|||
|
; menuItemStringHdl non-purgeable because the code set ResLoad to
|
|||
|
; false. Bad thing happened when the resource got purged.
|
|||
|
; <32> 2/22/92 KST Rewrite code to get IconSuite from Component. Changed TSM design
|
|||
|
; and removed "GetKeyboardIconSuite" call. Also add a field
|
|||
|
; "oldJIMCount" in the stack frame to keep the old Japanese input
|
|||
|
; method count.
|
|||
|
; <31> 2/19/92 KST Fixed a bug in "MakeIMIconSuite" which trashes A3.
|
|||
|
; <30> 2/11/92 DCL Changed the name of TSMEqu.[aph] to TextServices.[aph] for
|
|||
|
; better read-ability.
|
|||
|
; <29> 2/10/92 KST We now consolidate all default input methods info in one
|
|||
|
; resource managed by TSM. So keyboard menu should get this info
|
|||
|
; from TSM by calling GetDefaultInputMethod at boot time.
|
|||
|
; <28> 1/30/92 JH Right before the loop which starts at label @OldIMLoop the
|
|||
|
; intfArray handle is dereferenced and the first long is moved
|
|||
|
; into d4. There needs to be a check to see if that first long is
|
|||
|
; 0. So adding a beq.s to NoMoreIMs.
|
|||
|
; <27> 1/16/92 pvh In OldIMLoop, clear D0 before using it to hold a long word value
|
|||
|
; for _BlockMove (D0 had residual trash in the upper word byte
|
|||
|
; causing _BlockMove to hose memory). D1 also held the bogus D0
|
|||
|
; value too.
|
|||
|
; <26> 1/16/92 DTY Double check the handle to Japanese system globals to make sure
|
|||
|
; there actually is a handle. If there is no handle, assume there
|
|||
|
; are no old Japanese input methods.
|
|||
|
; <25> 1/15/92 SMB Adding code to support old Input Methods<64> want old-style
|
|||
|
; (pre-7.0) Japanese input methods in the kbd menu. Cleanup stack
|
|||
|
; problem in MakeKCHRIconSuite & MakeIMIconSuite.
|
|||
|
; <24> 1/13/92 SMB Word-align menuFrame again: eliminate tempTwo field since meant
|
|||
|
; to replace it with CJKcount in last checkin.
|
|||
|
; <23> 1/10/92 SMB #1013637: be sure a script is enabled and not just installed.
|
|||
|
; Now adding KCHRs for double-byte scripts when no input methods
|
|||
|
; are available.
|
|||
|
; <22> 12/13/91 DTY #1018116: BuildIMTable will trash the system heap when it tries
|
|||
|
; to add information about components to the end of the installed
|
|||
|
; items record but there were no components in the system. Bad
|
|||
|
; form, Boss! ;)
|
|||
|
; <21> 12/11/91 SMB Rewrite to include Input Methods as well as KCHRs. Renamed
|
|||
|
; AuxKeyboardMenuInfo members and KCHRInstalledRec (is now
|
|||
|
; ItemInstalledRec) with new names. Bug #1013637 fixed - don't
|
|||
|
; show inputs in menu if their script is installed but not
|
|||
|
; enabled. Renamed scriptRecord's scriptKCHRCount member to
|
|||
|
; scriptInputCount.
|
|||
|
; <20> 11/8/91 SMB #1015613 (for CubeE & Bruges) - Fix bug that shows up when an
|
|||
|
; application has no menu bar. We really want to use the system
|
|||
|
; menu bar (SystemMenuList) and not the current menu bar which may
|
|||
|
; be an application's menu bar.
|
|||
|
; <19> 2/11/91 PKE smb,#PKE-Sys-020: RebuildKeybdMenu should perform some disposing
|
|||
|
; and rebuilding even without a Keyboard menu, so we update if
|
|||
|
; Mover has updated the keyboard layouts. Otherwise user can't
|
|||
|
; switch to layouts they moved in, or code will try to switch to
|
|||
|
; layouts that have been moved out. Note: this fix also requires
|
|||
|
; the previous bug fix in <18>.
|
|||
|
; <18> 2/11/91 PKE smb,#PKE-Sys-021: RebuildKeybdMenu (called by Mover) trashes a2
|
|||
|
; and d3 (because it doesn't do proper setup and cleanup for its
|
|||
|
; call to InitKeybdMenu).
|
|||
|
; <17> 1/27/91 PKE stb,#PKE-Sys-016: (Whiteboard bug in 800K install, with no keybd
|
|||
|
; icons) InitKeybdMenu error handling code was putting menuH
|
|||
|
; handle for DisposHandle on the stack instead of in a0, thus
|
|||
|
; messing up the stack and trashing regs across InitKeybdMenu.
|
|||
|
; Once menuH was being put in the right place, then another
|
|||
|
; problem had to be fixed: it was not valid if there was no menu.
|
|||
|
; <16> 1/22/91 SMB (csd) When no kcs resources are installed, needed to pop a3 off
|
|||
|
; the stack before an error exit (actually we just don't display a
|
|||
|
; keyboard menu. See branches to @ErrCleanup & @StkCleanup.
|
|||
|
; <15> 1/7/91 SMB (JDR) Need to modify to always have the Keyboard menu structures
|
|||
|
; so the KeyScript verb "NextKeybdInScript" is meaningful (and
|
|||
|
; functions!). Now testing smgrKbdMenuAvail in order to do the
|
|||
|
; right thing when a menu does/doesn't exist! In RebuildKeybdMenu
|
|||
|
; set script manager munged count to tell the Keybd CDEV to
|
|||
|
; rebuild it's list of KCHRs. Renamed Icons.a to IconUtilsPriv.a.
|
|||
|
; <14> 12/15/90 SMB (gbm) Modified to use the 'kcs4' icon if the 'kcs8' is missing,
|
|||
|
; and to guarantee fetching resources from the system resource
|
|||
|
; file. Used 'extra' byte in local frame for a new flag,
|
|||
|
; usingGenericIcon. Modified use of ResLoad to be a byte op and
|
|||
|
; not a word op. Fixed bug in SortKCHRs by looping in the
|
|||
|
; outerloop through KCHRcount-1 KCHR in the buffers (instead of
|
|||
|
; the KCHRcount-2 KCHRs). This was causing a KCHR to not be
|
|||
|
; included in the menu but it would show in the Keybd CDEV since
|
|||
|
; it was in the system file.
|
|||
|
; <13> 10/30/90 SMB NEEDED for 7.0b2: restore ResLoad before calling SortKCHRs since
|
|||
|
; _IUTextOrderSys depends on certain resources being in the system
|
|||
|
; heap.
|
|||
|
; <12> 9/1/90 SMB Rearranged initial conditions for displaying a menu. Bug fix: if
|
|||
|
; only 1 KCHR then don't need to sort in SortKCHRs.
|
|||
|
; <11> 8/10/90 SMB Removed the KeyScript call to re-enable the keyboards since
|
|||
|
; Mover is now making the call. Added <20>About Keyboards<64> support
|
|||
|
; now.
|
|||
|
; <10> 8/7/90 SMB Adding guts to RebuildKeybdMenu. Added call to IUTextOrderSys to
|
|||
|
; sort the KCHRs alphabetically based on the 'itlm'. Changed
|
|||
|
; script's default KCHR indicator to be localizable in the STR#
|
|||
|
; resource for the kbd menu. Adding <20>About Keyboards<64><73> (but
|
|||
|
; conditionalized out until later.) Temporarily making a KeyScript
|
|||
|
; call to re-enable the keyboards if in RebuildKeybdMenu if they
|
|||
|
; were disabled.
|
|||
|
; <9> 7/16/90 PKE Use new name for field in ExpandMemRec: emItlCache2Ptr is now
|
|||
|
; emItlSysCachePtr. Renamed Cache2Rec to NewItlCacheRec.
|
|||
|
; <8> 6/22/90 SMB Conditionalizing out more code that expects the Next Keyboard
|
|||
|
; and Next Script menu items to exist. Using flag
|
|||
|
; DoCmdKeyEquivalents.
|
|||
|
; <7> 6/13/90 PKE Put in framework for private RebuildKeybdMenu routine called by
|
|||
|
; Mover. This call lets us know that keyboards have been moved
|
|||
|
; into or out of the System file.
|
|||
|
; <6> 6/13/90 SMB Removing the Next Keyboard and Next Script menu items until
|
|||
|
; their command key equivalents can be displayed in the menu.
|
|||
|
; <5> 6/5/90 SMB Fixed odd address problem that occurred when initializing the
|
|||
|
; menuTitleString and DisabledDashSep by adding a dummy member to
|
|||
|
; the Strings record. Also cleaned up some inefficient code and
|
|||
|
; initialized a register! Disabled cmd key equivalents for Next
|
|||
|
; Keyboard and Next Script menu items.
|
|||
|
; <4> 6/1/90 SMB Extended Keyboard Menu to display using sorted script list
|
|||
|
; (itl2Cache), and added Next Keyboard and Next Script menu items,
|
|||
|
; as well as disabled dividing lines between scripts. Also testing
|
|||
|
; itlc showIcon flag to determine whether or not to display the
|
|||
|
; keyboard menu.
|
|||
|
; <3> 5/31/90 SMB Renaming IconUtils.a to Icons.a.
|
|||
|
; <2> 5/13/90 SMB Adding InitKeyboardMenu guts!
|
|||
|
; <1> 5/5/90 PKE Added a butchered version of Sue<75>s new file with a temporary
|
|||
|
; stub for InitKeybdMenu routine. Sue will fill this in later.
|
|||
|
;___________________________________________________________________________________________________
|
|||
|
; To Do:
|
|||
|
; <09> Update use of d4 (was KCHRcount, is now total menu contents count) to be a long instead of a word
|
|||
|
; <09> If can't get a handle to use for the name of an IM (see @GetIMInfo) need to zero-out the itemInfo
|
|||
|
; field and set update the count correctly. May need to do better error-handling after
|
|||
|
; _GetComponentInfo too.
|
|||
|
; <09> clean up componentFlags and componentFlagsMask: should the componentFlags be #$00008F00 instead?
|
|||
|
; <09> search for <??>
|
|||
|
; <09> make RebuildKeybdMenu its own proc and move localGetIndString above it.
|
|||
|
; <09> Are the menuitems numbered correctly if no kbd menu is desired and the About menu
|
|||
|
; item isn't there? Should check ScriptMgrKeyGetSet for all of this as well.
|
|||
|
; <09> what to do about err result from _DisposeIconSuite? already deleted menu items if a menu exists
|
|||
|
; and possibly already deleted icon suites so these leave the menu in a bad state.
|
|||
|
;___________________________________________________________________________________________________
|
|||
|
|
|||
|
load 'StandardEqu.d' ; Private.a, ScriptEqu.a, ...
|
|||
|
include 'ScriptPriv.a'
|
|||
|
include 'Packages.a' ; <10><41>
|
|||
|
include 'IconUtilsPriv.a' ; <15>
|
|||
|
include 'IntlUtilsPriv.a' ; <10>
|
|||
|
include 'MenuMgrPriv.a' ; <20>
|
|||
|
include 'TextServices.a' ; <21> <29>
|
|||
|
include 'TSMPrivate.a' ; <29>
|
|||
|
include 'Components.a' ; <21>
|
|||
|
include 'GestaltEqu.a' ; <21>
|
|||
|
|
|||
|
string pascal
|
|||
|
|
|||
|
proc
|
|||
|
export InitKeybdMenu
|
|||
|
export RebuildKeybdMenu ; <7>
|
|||
|
import StdUnlink ; std unlink & exit <1>
|
|||
|
|
|||
|
;-------------------------------------------------------------------------------
|
|||
|
; FUNCTION InitKeybdMenu: OSErr;
|
|||
|
;-------------------------------------------------------------------------------
|
|||
|
|
|||
|
menuFrame record {a6link},decr
|
|||
|
result ds.w 1 ; OSErr result code. <1>
|
|||
|
menuArgs equ *-8 ; size of arguments. <1>
|
|||
|
selector ds.l 1 ; ScriptMgr selector on stack <1>
|
|||
|
return ds.l 1 ; return address. <1>
|
|||
|
a6link ds.l 1 ; old link pointer
|
|||
|
rebuildFlag ds.b 1 ; indicates rebuilding so don't call _InsertMenu <10>
|
|||
|
ds.b 1 ; unused <21><34>
|
|||
|
byteAvail ds.b 1 ; word-aligning the stack: use me <25>
|
|||
|
CJKcount ds.b 1 ; Using low 5 bits: which dbl-byte scripts have an IM: 0 => no IM, ow 1 <23>
|
|||
|
; xxxOCCJK
|
|||
|
KCHRcount ds.w 1 ; number of KCHRs installed <10><21>
|
|||
|
TSMInputMthdCount ds.l 1 ; input method count (old & new) <21> renamed <25> renamed again (added 'TSM') <40>
|
|||
|
menuH ds.l 1 ; menuHandle
|
|||
|
ScriptOrderPtr ds.l 1 ; ptr to ordering of scripts (in emItlSysCache)
|
|||
|
ItemInstalledRecPtr ds.l 1 ; ptr to ItemInstalledRec
|
|||
|
ItemOffsetsPtr ds.l 1 ; ptr to record of offsets of ItemInstalledRec for sorting
|
|||
|
KeyboardMenuPtr ds.l 1 ; ptr to AuxKeyboardMenuInfo record
|
|||
|
menuItem ds.w 1 ; menuItem number
|
|||
|
defaultMark ds.w 1 ; marker for default KCHR in each script
|
|||
|
scriptCount ds.b 1 ; number of scripts still to process <10>
|
|||
|
usingGenericIcon ds.b 1 ; T=> using a generic icon <14>
|
|||
|
scriptLangRec ds.l 1 ; contains the script (w) & language (w) <21>
|
|||
|
compID ds.l 1 ; component identifier <21>
|
|||
|
NextItemString ds.b 256
|
|||
|
CompDesc ds ComponentDescription ; <21>
|
|||
|
menuLocals equ * ; size of locals
|
|||
|
endr
|
|||
|
|
|||
|
; definitions for creating an IconSuite of small color icons for scripts.
|
|||
|
string asis
|
|||
|
kcsTable dc.l 'kcs#',Small1BitMask,'kcs4',Small4BitData,'kcs8',Small8BitData
|
|||
|
|
|||
|
string pascal
|
|||
|
|
|||
|
NumItemsAfterKCHRs equ 2 ; Next Keyboard and Next Script
|
|||
|
|
|||
|
KeyboardMenuRegs reg d2-d4/a2-a4
|
|||
|
|
|||
|
;***********************************************************************************************
|
|||
|
|
|||
|
InitKeybdMenu
|
|||
|
with menuFrame,ItemInstalledRec
|
|||
|
link a6,#menuLocals
|
|||
|
clr.w result(a6) ; initialize to return noErr
|
|||
|
|
|||
|
;----------------------------------------------------------------------------------- <10>
|
|||
|
; INITIALIZATIONS
|
|||
|
;----------------------------------------------------------------------------------- <10>
|
|||
|
movem.l KeyboardMenuRegs,-(sp)
|
|||
|
|
|||
|
; get # of enabled scripts <4>
|
|||
|
with SmgrRecord
|
|||
|
GetSMgrCore a2
|
|||
|
st smgrKbdMenuAvail(a2) ; assume want menu to display <15>
|
|||
|
cmp.b #1,smgrEnabled(a2) ; > 1 script enabled? <12>
|
|||
|
bhi.s @HaveMenuStatus ; yep, display menu <12>
|
|||
|
|
|||
|
; otherwise, check itlc flag (smfShowIcon) to determine whether or not to show the menu <4>
|
|||
|
move.l smgrGenFlags(a2),d0 ; <5>
|
|||
|
btst.l #smfShowIcon,d0 ; bit 31 ON => show icon even if only one script <5>
|
|||
|
bne.s @HaveMenuStatus ; <15>
|
|||
|
sf smgrKbdMenuAvail(a2) ; don't want menu to display <15>
|
|||
|
clr.l menuH(a6) ; set menu handle to NIL <17>
|
|||
|
@HaveMenuStatus
|
|||
|
move.b smgrEnabled(a2),scriptCount(a6) ; save count <12>
|
|||
|
endWith ; <12>
|
|||
|
|
|||
|
; setup for resource fetch from the system file <14>
|
|||
|
subq.w #2,sp ; storage for current resource file <14>
|
|||
|
_CurResFile ; <14>
|
|||
|
move.w #0,-(sp) ; use system resource file <14>
|
|||
|
_UseResFile ; <14>
|
|||
|
|
|||
|
move.b ResLoad,-(sp) ; <14>
|
|||
|
st ResLoad ; set to true <14>
|
|||
|
|
|||
|
; setup defaultMark for the menu
|
|||
|
move.w #KeybdDefaultMrk,defaultMark(a6) ; initialize to empty, 0x00
|
|||
|
pea NextItemString(a6) ; ptr to Str255 <34>
|
|||
|
move.w #kKeyboardMenuItemsID,-(sp) ; strListID <34><38>
|
|||
|
move.w #DefMarkIndex,-(sp) ; string index <34>
|
|||
|
import localGetIndString ; <34>
|
|||
|
bsr localGetIndString ; making a pString (rather than a ptr to text) <34>
|
|||
|
sf ResLoad ; reset to F <14>
|
|||
|
|
|||
|
tst.b NextItemString(a6) ; do we have a string? <34>
|
|||
|
beq.s @useDefMarker ; if empty, use default marker <32>
|
|||
|
; fetch the localized character
|
|||
|
move.b NextItemString+1(a6),defaultMark+1(a6) ; write out the default marker byte (skip length) <34>
|
|||
|
@useDefMarker
|
|||
|
|
|||
|
; Test if menu already exists so know if called from RebuildKeybdMenu <10>
|
|||
|
sf rebuildFlag(a6) ; assume first time <10>
|
|||
|
; Use the system menuBar and not the application menuBar in case appl doesn't have a menuBar (GetMHandle would fail). <20>
|
|||
|
move.l MenuList,-(sp) ; save the current menuList since it may be an apps menu <20>
|
|||
|
move.l SystemMenuList,MenuList ; <20>
|
|||
|
subq #4,sp ; result <10>
|
|||
|
move.w #kKeyboardMenuID, -(sp) ; menuID <10>
|
|||
|
_GetMHandle ; <10>
|
|||
|
move.l (sp)+,menuH(a6) ; <10>
|
|||
|
move.l (sp)+,MenuList ; restore the menuList <20>
|
|||
|
tst.l menuH(a6) ; <10>
|
|||
|
beq.s @NewMenu
|
|||
|
; If menu already exists then called from RebuildKeybdMenu <10>
|
|||
|
st rebuildFlag(a6) ; don't do _InsertMenu <10>
|
|||
|
|
|||
|
;-----------------------------------------------------------------------------------
|
|||
|
; MENU setup
|
|||
|
;-----------------------------------------------------------------------------------
|
|||
|
|
|||
|
@NewMenu
|
|||
|
bsr CountMenuContents ; returns d4.l = to total # of installed inputs
|
|||
|
|
|||
|
; Allocate ItemInstalledRec table for # of installed KCHRs and Input Methods:
|
|||
|
move.l d4,d0 ; total number of KCHRs and Input Methods <21>
|
|||
|
mulu #ItemInstalledRecSz,d0
|
|||
|
_NewPtr ,SYS,CLEAR
|
|||
|
move.l a0,ItemInstalledRecPtr(a6)
|
|||
|
move.l a0,a4
|
|||
|
|
|||
|
with smgrRecord,ScriptRecord,itlbRecord,ItemInstalledRec,AuxKeyboardMenuInfo
|
|||
|
;-----------------------------------------------------------------------------------
|
|||
|
bsr BuildIMTable ; Init the ItemInstalledRec table for input methods <21>
|
|||
|
bsr BuildKCHRTable ; Init the ItemInstalledRec table for KCHRs <21>
|
|||
|
;-----------------------------------------------------------------------------------
|
|||
|
st ResLoad ; must be T for _IUTextOrderSys <14>
|
|||
|
bsr SortItems ; sort the Items <10>
|
|||
|
sf ResLoad ; reset to F <14>
|
|||
|
;-------------------------------------------
|
|||
|
|
|||
|
; Allocate AuxKeyboardMenuInfo record for IconSuite handles for MF and other info for SystemMenu patch
|
|||
|
move.w d4,d0 ; total number of inputs
|
|||
|
add.b scriptCount(a6),d0 ; # of scripts = # of disabled (separating) lines
|
|||
|
|
|||
|
IF DoCmdKeyEquivalents THEN ; <8>
|
|||
|
; Allocate space for empty entry (so can index by menu item #) and entries for items
|
|||
|
; beyond KCHRs (so that the iconSuiteH is 0). NumItemsAfterKCHRs=0 if no cmd key items
|
|||
|
; so would only +1. Added above in disabled line count <8>
|
|||
|
add.w #(1+NumItemsAfterKCHRs),d0 ; 1=dummy entry
|
|||
|
ENDIF
|
|||
|
|
|||
|
add.w #2,d0 ; for "About Keyboards<64>" & disabled line items <11>
|
|||
|
mulu #AuxMenuInfoSize,d0
|
|||
|
_NewPtr ,SYS,CLEAR
|
|||
|
move.l a0,KeyboardMenuPtr(a6)
|
|||
|
GetSmgrCore a1 ; get script manager core.
|
|||
|
move.l a0,smgrKeyboardMenuPtr(a1) ; save in Smgr Record for MF
|
|||
|
move.l a0,a2
|
|||
|
; in order to index by menuItem # (not 0-based), must have a dummy entry at the beginning
|
|||
|
add.w #AuxMenuInfoSize,a2 ; point past empty entry to storage for 1st menuItem.
|
|||
|
|
|||
|
;----------------------------------------------------------------------------------- <10>
|
|||
|
; Make a menu now<6F>
|
|||
|
;----------------------------------------------------------------------------------- <10>
|
|||
|
|
|||
|
; Test if a menu is desired: if not, must still build menu d.s. so that the command-key <15>
|
|||
|
; equivalent, cmd-opt-space bar (to switch between keybds. in a script) works. <15>
|
|||
|
move.w #1,menuItem(a6) ; initialize earlier for bra <15>
|
|||
|
tst.b smgrKbdMenuAvail(a1) ; do we want to display a menu? <15>
|
|||
|
beq.s @BuildMenuRec ; <15>
|
|||
|
; Do we already have a menu? (are we called from RebuildKeybdMenu?)
|
|||
|
tst.b rebuildFlag(a6) ; do we already have a menu? <21>
|
|||
|
bne.s @GotMenuH ; bra if so <21>
|
|||
|
|
|||
|
; Add a new menu for the Keyboard Menu
|
|||
|
subq #4,sp ; result: menuHandle
|
|||
|
move.w #kKeyboardMenuID, -(sp) ; menuID
|
|||
|
pea #'Susan' ; pString <21>
|
|||
|
_NewMenu
|
|||
|
move.l (sp)+,menuH(a6)
|
|||
|
@GotMenuH
|
|||
|
|
|||
|
; Add the About Keyboards<64> menuitem followed by a disabled line <10>
|
|||
|
st ResLoad ; set to true <35> <14>
|
|||
|
pea NextItemString(a6) ; ptr to Str255 <34>
|
|||
|
move.w #kKeyboardMenuItemsID,-(sp) ; strListID <34><38>
|
|||
|
move.w #AboutKybdsIndex,-(sp) ; string index <34>
|
|||
|
import localGetIndString ; <34>
|
|||
|
bsr localGetIndString ; <34>
|
|||
|
sf ResLoad ; reset to false <35>
|
|||
|
tst.b NextItemString(a6) ; do we have the string <34>
|
|||
|
beq.s @BuildMenuRec ; no, don't add AboutKeyboards<64> <34>
|
|||
|
|
|||
|
; name the menu item
|
|||
|
move.l menuH(a6),-(sp)
|
|||
|
pea NextItemString(a6) ; name of this KCHR: pString
|
|||
|
move.w menuItem(a6),-(sp) ; insert <20>after<65> this menuItem
|
|||
|
_InsMenuItem
|
|||
|
move.l menuH(a6),-(sp)
|
|||
|
move.w #1,-(sp) ; the first item has a script code. <42>
|
|||
|
move.w #$1C,-(sp)
|
|||
|
_SetItemCmd
|
|||
|
move.l menuH(a6),-(sp)
|
|||
|
move.w #1,-(SP)
|
|||
|
move.w #smSystemScript,-(sp) ; the script code is the sytem script <42>
|
|||
|
_SetItmIcon
|
|||
|
add.w #1,menuItem(a6)
|
|||
|
add.w #AuxMenuInfoSize,a2 ; point past 1st menuItem now
|
|||
|
bsr AddDisabledLine ; separate scripts by a disabled line <8>
|
|||
|
|
|||
|
;---------------------------------------------------------------------------
|
|||
|
; Add the menu guts<74>
|
|||
|
;---------------------------------------------------------------------------
|
|||
|
@BuildMenuRec ; <15>
|
|||
|
move.l ItemInstalledRecPtr(a6),a4 ; reset to first KCHR<48>s info <10>
|
|||
|
move.l ItemOffsetsPtr(a6),a3 ; reset ptr
|
|||
|
move.w (a3)+,d0 ; get offset to KCHR info for this item <10>
|
|||
|
add.w d0,a4
|
|||
|
;-------------------------------------------
|
|||
|
; Currently:
|
|||
|
; a2 = ptr to AuxKeyboardMenuInfo (storage for aux menu info for each input)
|
|||
|
; a3 = ItemOffsetsPtr
|
|||
|
; a4 = ptr to ItemInstalledRec
|
|||
|
; d3 = current script #
|
|||
|
; d4 = total number of inputs
|
|||
|
; d5 = total num of input items thus far in this script
|
|||
|
;--------------------------------------------
|
|||
|
; Time to build each menu item and it's auxilliary menu information record
|
|||
|
; For each enabled script, loop for the input items and add menu items for each one
|
|||
|
|
|||
|
;--------------------
|
|||
|
; Scripts loop<6F>
|
|||
|
;--------------------
|
|||
|
@EnabledScriptLoop
|
|||
|
subq.b #1,scriptCount(a6) ; decr enabled script count
|
|||
|
moveq #0,d5 ; initialize script's input item count to 0
|
|||
|
move.w ItemScript(a4),d3 ; script code
|
|||
|
|
|||
|
; be sure this script is enabled (bug #1013637) <21>
|
|||
|
GetSMgrCore a0
|
|||
|
move.w d3,d0
|
|||
|
lsl.w #2,d0 ; long word offset
|
|||
|
move.l smgrEntry(a0,d0.w),a0 ; script record of installed script
|
|||
|
|
|||
|
; loop until cross a script boundary in the KCHR table
|
|||
|
;-------------------------------
|
|||
|
; Items_within_a_script loop<6F>
|
|||
|
;-------------------------------
|
|||
|
@ScriptItemsLoop
|
|||
|
; if script not enabled, loop for next input. (a0 set above)
|
|||
|
tst.b scriptEnabled(a0) ; script enabled?
|
|||
|
beq.s @NextInput ; bra to fetch next input item if not a valid script
|
|||
|
|
|||
|
; find out the type of input to build the iconsuite
|
|||
|
move.b itemInpuType(a4), itemType(a2) ; type of input <25>
|
|||
|
beq.s @KCHRinput ; bra if this is a KCHR <25>
|
|||
|
cmp.b #TSMIMitem, itemInpuType(a4) ; is this a new-style input method? <25>
|
|||
|
bne.s @OldIM ; no, is an old-style input method <34>- replaced 2 branches
|
|||
|
|
|||
|
@NewIM
|
|||
|
; this input type is a TSM-style IM
|
|||
|
move.l itemInfo(a4), auxItemInfo(a2) ; store the component identifier here <21>
|
|||
|
bra.s @IMIconSuite ; <25>
|
|||
|
@OldIM
|
|||
|
move.w itemResID(a4),itemRsrcID(a2) ; save id in AuxKeyboardMenuInfo record
|
|||
|
move.l #0, auxItemInfo(a2) ; NIL indicates it's not a new-style IM <25>
|
|||
|
@IMIconSuite
|
|||
|
bsr MakeIMIconSuite ; <21>
|
|||
|
bra.s @Add2Menu
|
|||
|
|
|||
|
@KCHRinput
|
|||
|
; this input type is a KCHR
|
|||
|
move.w itemResID(a4),itemRsrcID(a2) ; save id in AuxKeyboardMenuInfo record
|
|||
|
movem.l d2/d3,-(sp) ; save <36>
|
|||
|
move.w itemRsrcID(a2),d2 ; store the desired KCHR icon ID <36>
|
|||
|
move.w #kKeyboardMenuID,d3 ; store the default KCHR icon ID <36>
|
|||
|
sf usingGenericIcon(a6) ; initial assumption <36>
|
|||
|
bsr MakeIconSuite ; <36>
|
|||
|
movem.l (sp)+,d2/d3 ; restore <36>
|
|||
|
move.l #0, auxItemInfo(a2) ; NIL indicates it's not a new-style Input Method
|
|||
|
|
|||
|
@Add2Menu
|
|||
|
; create a new menuItem and save the item order w/in the script in the AuxKeyboardMenuInfo record
|
|||
|
bsr AddMenuItem ; preserves a0
|
|||
|
|
|||
|
;--------------------------------------------
|
|||
|
@NextInput
|
|||
|
; Get next input!
|
|||
|
sub.w #1,d4 ; are we out of inputs/menuItems to add?
|
|||
|
IF NOT DoCmdKeyEquivalents THEN ; bra if done <8>
|
|||
|
beq.s @SetTitle ; <3>;temporary<6>
|
|||
|
ELSE
|
|||
|
beq @SetCmdKeyEquiv ; add Next Keyboard and Next Script <3>;temporary<6>
|
|||
|
ENDIF
|
|||
|
add.w #AuxMenuInfoSize,a2 ; point to storage for next menuItem.
|
|||
|
|
|||
|
; Loop on next input in this script?
|
|||
|
move.l ItemInstalledRecPtr(a6),a4 ; reset to first KCHR<48>s info <10>
|
|||
|
move.w (a3)+,d0 ; get offset to KCHR info for this item
|
|||
|
add.w d0,a4
|
|||
|
move.w ItemScript(a4),d0
|
|||
|
cmp.w d3,d0 ; cmp to current script
|
|||
|
beq.s @ScriptItemsLoop ; get next KCHR for this script
|
|||
|
|
|||
|
; Crossed a script boundary
|
|||
|
IF NOT DoCmdKeyEquivalents THEN ; <8>
|
|||
|
tst.b scriptCount(a6) ; more enabled scripts? <8>
|
|||
|
beq.s @SetTitle ; don<6F>t add disabled line after last KCHR <8>
|
|||
|
; if script not enabled, don't add a line. (a0 set above at @EnabledScriptLoop) <23>
|
|||
|
tst.b scriptEnabled(a0) ; script enabled? <23>
|
|||
|
beq @EnabledScriptLoop ; bra to fetch next input item if not a valid script <23>
|
|||
|
bsr AddDisabledLine ; separate scripts by a disabled line <8>
|
|||
|
; a2 incremented for next menuitem's info <32>
|
|||
|
bra @EnabledScriptLoop ; <8>
|
|||
|
ELSE
|
|||
|
; Not really a routine- just a place I've moved the code to get it out of the
|
|||
|
; middle of here. Should be put back here if we want to use it.
|
|||
|
bsr AddCmdKeyMenuItems
|
|||
|
ENDIF ; <6>
|
|||
|
|
|||
|
;------------------------------------------------------------------------------------------
|
|||
|
; FINALIZATION
|
|||
|
;------------------------------------------------------------------------------------------
|
|||
|
|
|||
|
; change the title of the menu to the icon of the system script<70>s keybd by stuffing
|
|||
|
; the iconSuite handle into the string posn holder "Susan"
|
|||
|
@SetTitle
|
|||
|
GetSmgrCore a3 ; get script manager core. <15>
|
|||
|
tst.b smgrKbdMenuAvail(a3) ; do we want to display a menu? <15>
|
|||
|
beq.s @Cleanup ; <15>
|
|||
|
move.l menuH(a6),a0
|
|||
|
move.l (a0),a0 ; deref
|
|||
|
; stuff the length (5 bytes) and special byte into the name: 01 indicates a handle is following
|
|||
|
move.w #$0501, menuData(a0) ; <21>
|
|||
|
|
|||
|
; stuff the system script's iconSuite handle into the name
|
|||
|
move.l KeyboardMenuPtr(a6),a1
|
|||
|
|
|||
|
; get item # of default script's KCHR <10><15>
|
|||
|
move.w smgrSysScript(a3),d0 ; <10>
|
|||
|
lsl.w #2,d0 ; long word offset <10>
|
|||
|
move.l smgrEntry(a3,d0.w),a3 ; script record <10>
|
|||
|
clr.w d0 ; <10>
|
|||
|
move.b ScriptKeysItemNum(a3),d0 ; <10>
|
|||
|
mulu.w #AuxMenuInfoSize,d0 ; offset into AuxMenuInfoRec <10>
|
|||
|
add.w d0,a1 ; <3><10>
|
|||
|
move.l iconSuiteH(a1),menuData+2(a0) ; now at system script entry <3>
|
|||
|
endwith ; with smgrRecord,ScriptRecord,itlbRecord,ItemInstalledRec,AuxKeyboardMenuInfo
|
|||
|
|
|||
|
tst.b rebuildFlag(a6) ; if rebuilding don<6F>t insert menu <10>
|
|||
|
bne.s @CleanUp ; <10>
|
|||
|
|
|||
|
; insert the menu now!
|
|||
|
move.l menuH(a6),-(sp)
|
|||
|
move.w #0,-(sp)
|
|||
|
_InsertMenu
|
|||
|
|
|||
|
@Cleanup
|
|||
|
move.b (sp)+,ResLoad ; <14>
|
|||
|
; restore previous (current) resource file <14>
|
|||
|
_UseResFile ; current resource file ID on stack <14>
|
|||
|
|
|||
|
move.l ItemInstalledRecPtr(a6),a0
|
|||
|
_DisposPtr
|
|||
|
tst.w result(a6)
|
|||
|
bne.s @done ; don't overwrite with potential DisposPtr error
|
|||
|
tst.w d0
|
|||
|
beq.s @done
|
|||
|
move.w d0,result(a6) ; will override DisposHandle error if one existed
|
|||
|
move.l ItemOffsetsPtr(a6),a0
|
|||
|
_DisposPtr
|
|||
|
tst.w result(a6)
|
|||
|
bne.s @done ; don't overwrite with potential DisposPtr error
|
|||
|
tst.w d0
|
|||
|
beq.s @done
|
|||
|
move.w d0,result(a6) ; will override DisposHandle error if one existed
|
|||
|
|
|||
|
@done |