neovars: on-screen-board keycap symbols moved to associative array

Replace global variables lookups of the form val := dict%key% with
associative array lookup, improving on-screen-board performance
(especially the first time a new level is displayed) and no longer
spamming global namespace.
This commit is contained in:
ferdinym 2020-10-21 15:02:33 +02:00
parent 42231d3ea3
commit 9a2e731253
1 changed files with 21 additions and 8 deletions

View File

@ -1,5 +1,7 @@
; -*- encoding:utf-8 -*-
BSTSymbols := {}
UniFontVersion := "2.37"
UniFontFilename := "DejaVuSans-Bold.ttf"
UniFontName := "DejaVu Sans"
@ -165,7 +167,7 @@ BSTUpdate() {
guiText := guiCP
}
; Replace symbols for screen view
guiSym := GSYM%guiText%
guiSym := BSTSymbols[guiText]
if (guiSym != "") {
guiText := SubStr(guiSym,2)
; Apply special symbol styles unless standalone follows
@ -183,7 +185,7 @@ BSTUpdate() {
if (hasCompFirstFontChanges and CM%guiCP% == 1 and CF%guiCP% == "")
guiFontOpts := guiCompFirstFontOpts
; Replace symbols for screen view
guiSym := GSYM%guiCP%
guiSym := BSTSymbols[guiCP]
if (guiSym != "") {
guiText .= SubStr(guiSym,2)
; Apply special symbol styles
@ -890,14 +892,25 @@ CharProc__BSTK() {
BSTToggleKeyboardLayout()
}
; Replace 'chars' with 'sym' on screen.
; Set style="t" to highlight chars as a tool (typically starts on "P")
GUISYM(sym,chars,style:=" ") {
; Add keycap symbol to on-screen-board
;
; Arguments:
;
; sym
; Keycap symbol to be displayed on the on-screen board screen.
; String, can be one or more characters (space is limited by keycap size).
; keyIdSeq
; Characters to be replaced by symbol.
; String of one or more keyIds (7-character UCodes or special key names).
; style (optional)
; Set style="t" to highlight chars as a tool (typically starts on "P")
GUISYM(keyIdSeq,sym,style:=" ") {
global
GSYM%sym% := style . util_str2UCodes(chars)
BSTSymbols[keyIdSeq] := style . util_str2UCodes(sym)
}
BSTSymbols() {
BSTAddSymbols() {
global
; diverse Ersatz-Symbole für Spezialzeichen
GUISYM("T__cflx","◌̂")
@ -1026,7 +1039,7 @@ BSTRegister() {
BSThidden := 1
BSTalwaysOnTop := 1
BSTSymbols()
BSTAddSymbols()
IniRead,useBST,%ini%,Global,useBST,0
IniRead,useDBST,%ini%,Global,useDBST,0