'encoding UTF-8 Do not remove or change this line!
'**************************************************************
'
' Licensed to the Apache Software Foundation (ASF) under one
' or more contributor license agreements. See the NOTICE file
' distributed with this work for additional information
' regarding copyright ownership. The ASF licenses this file
' to you under the Apache License, Version 2.0 (the
' "License"); you may not use this file except in compliance
' with the License. You may obtain a copy of the License at
'
' http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing,
' software distributed under the License is distributed on an
' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
' KIND, either express or implied. See the License for the
' specific language governing permissions and limitations
' under the License.
'
'**************************************************************
'*
'* short description : handle accelerators
'*
'*******************************************************************************
'**
' #1 hGetAccel ' function to retrieve a language specific accelerator
'**
'\******************************************************************************
function hGetAccel( cCommand as string ) as string
'///
Retrieve a keyboard accelerator for a specific function
'///Uses: global/input/accelerators.txt
'///NOTE: Accelerator is language dependent
'///Input:
'///
'///+- Name of the action to be executed (string). Valid options are:
'///
'///+- "FileOpen"
'///+- "FileSave"
'///+- "Print"
'///+- "SelectAll"
'///+- "Copy"
'///+- "DocumentConverter_ShowLog"
'///+- "IDE_SWITCH_TAB+"
'///+- "IDE_SWITCH_TAB-"
'///
'///
'///Returns:
'///
'///+- Accelerator (string)
'///
'///+- A string ready to use by .typeKeys(...) method
'///+- "Error" if the requested Accelerator is unknown
'///
'///
'///Description:
'///
const CFN = "hGetAccel::"
const DEFAULT_LANGUAGE = "en-us"
dim cAccel as string
dim lsAccelerators( 1000 ) as string
dim cFile as string
cFile = gTesttoolpath & "global/input/accelerators.txt"
cFile = convertpath( cFile )
dim cProximityLocale as string
dim iLang as integer
printlog( CFN & "Enter with option: " & cCommand )
'printlog( CFN & "Current Language.: <" & gISOLang & ">" )
'///+- Get the section from the accelerators file
hGetDatafileSection( cFile , lsAccelerators() , cCommand , "" , "" )
'///+- Find the matching string for the current language
cAccel = hGetValueForKeyAsString( lsAccelerators() , gISOLang )
'///+- In case of a miss we retry with a modified string
'///
if ( instr( cAccel , "Error" ) <> 0 ) then
iLang = len( gISOLang )
select case iLang
case 2 :
'///+- Try xx-XX
cProximityLocale = gISOLang & "-" & ucase( gISOLang )
printlog( CFN & "Trying alternative locale: " & cProximityLocale )
cAccel = hGetValueForKeyAsString( lsAccelerators() , cProximityLocale )
case 5 :
'///+- Try xx
cProximityLocale = mid( cUpperCaseLocale , 1, 2 )
printlog( CFN & "Trying alternative locale: " & cProximityLocale )
cAccel = hGetValueForKeyAsString( lsAccelerators() , cProximityLocale )
case else :
'///+- Try en-US
cProximityLocale = "en-US"
printlog( CFN & "Trying default locale: " & cProximityLocale )
cAccel = hGetValueForKeyAsString( lsAccelerators() , DEFAULT_LANGUAGE )
end select
endif
'///
'///+- Build the complete accelerator-string so it can be used by "TypeKeys"
'///+- Print it to the log and return the string to the calling function
cAccel = "<" & cAccel & ">"
printlog( CFN & "Requested accelerator: " & cAccel & " for language: " & gISOLang )
hGetAccel() = cAccel
'///
end function