From 4bc16b2c8761368ccd19c9e9f265fbdd6617fc9b Mon Sep 17 00:00:00 2001 From: Steffen Winterfeldt Date: Tue, 26 May 2020 14:12:47 +0200 Subject: [PATCH 1/2] add F8-shortcut for language selection (jsc#SLE-12810, jsc#SLE-12479) And use to switch between Chinese/English. --- themes/openSUSE/src/common.inc | 50 ++------------------------------- themes/openSUSE/src/gfxboot.cfg | 6 +++- themes/openSUSE/src/main.bc | 1 + themes/openSUSE/src/panel.inc | 1 + 4 files changed, 10 insertions(+), 48 deletions(-) diff --git a/themes/openSUSE/src/common.inc b/themes/openSUSE/src/common.inc index fbb020a8..5a2d5416 100644 --- a/themes/openSUSE/src/common.inc +++ b/themes/openSUSE/src/common.inc @@ -1305,7 +1305,7 @@ moveto setcolor } if - dup keyF8 eq syslinux and { + dup keyF11 eq syslinux and { kroete.file .undef eq { /kroete.file "kroete.dat" findfile def } if kroete.file kroete.dir idle /kroete.dir kroete.dir 1 xor def @@ -1341,7 +1341,7 @@ moveto setcolor } if - dup keyShiftF8 eq debug 3 ge and { + dup keyShiftF11 eq debug 3 ge and { currentcolor debug 1 and { white } { black } ifelse setcolor currentpoint 300 0 moveto @@ -1375,10 +1375,6 @@ /debug debug 1 add def } if - dup keyShiftF11 eq { - 400 0 moveto "ani_%04d.jpg" play_movie - } if - dup keyShiftF1 eq { /transp transp 0x10 sub 0 max def @@ -1415,47 +1411,6 @@ } if - dup keyF11 eq debug 1 ge and { - - /dit { - dup 0xff and rand 0xff and gt { 0xff add } if - 8 shr - } def - - /c13.r rand 0x7f00 and def - /c02_13.r rand 0x7f00 and c13.r sub def - /c23.r rand 0x7f00 and def - /c01_23.r rand 0x7f00 and c23.r sub def - /c13.g rand 0x7f00 and def - /c02_13.g rand 0x7f00 and c13.g sub def - /c23.g rand 0x7f00 and def - /c01_23.g rand 0x7f00 and c23.g sub def - /c13.b rand 0x7f00 and def - /c02_13.b rand 0x7f00 and c13.b sub def - /c23.b rand 0x7f00 and def - /c01_23.b rand 0x7f00 and c23.b sub def - - screen.size /h exch def /w exch def - - 0 1 screen.size exch pop { - 0 1 screen.size pop { - over moveto - - currentpoint c01_23.r mul h div exch c02_13.r mul w div add c13.r add c23.r add - dit 0 max 0xff min 16 shl - currentpoint c01_23.g mul h div exch c02_13.g mul w div add c13.g add c23.g add - dit 0 max 0xff min 8 shl - currentpoint c01_23.b mul h div exch c02_13.b mul w div add c13.b add c23.b add - dit 0 max 0xff min add add - - setcolor putpixel - } for - pop - } for - - pop 0 - } if - dup keyF12 eq debug 6 ge and { % mouse support testing @@ -1775,6 +1730,7 @@ config.livecd { /keymap.default "keymap" "" gfxconfig.set.str /config.addopt.lang "addopt.lang" false gfxconfig.set.bool /config.addopt.keytable "addopt.keytable" false gfxconfig.set.bool +/config.extralang.locales "extralang.locales" [ ] gfxconfig.set.array_str % default value for initrd size (in bytes) /config.initrd.size "initrd.size" 0 gfxconfig.set.int diff --git a/themes/openSUSE/src/gfxboot.cfg b/themes/openSUSE/src/gfxboot.cfg index b189d115..2ddec713 100644 --- a/themes/openSUSE/src/gfxboot.cfg +++ b/themes/openSUSE/src/gfxboot.cfg @@ -166,7 +166,7 @@ spl=1 autodown=1 ; F-key assignments ; value can be one of: lang, video, install, kernelopts, dud, bits, keymap, -; profile, restore, otheropts +; profile, restore, otheropts, extralang ; note1: 'bits' is only shown on x86_64, 'profile' only when a file 'profile' ; exists, 'restore' only when there is a boot entry 'restore' ; note2: F1 is always help, F9 enables speech output, F10 exits gfxboot @@ -176,12 +176,16 @@ key.F4=install key.F5=kernelopts key.F6=dud key.F7=bits +key.F8=extralang ; add 'lang' option with current locale addopt.lang=1 ; add 'keytable' option with current keymap addopt.keytable=1 ; initrd size in bytes (fallback for progress bar) initrd.size=0 +; languages to use for extralang option +; use locale in long form (e.g. en_US) +extralang.locales=zh_CN,en_US [boot] ; show welcome animation diff --git a/themes/openSUSE/src/main.bc b/themes/openSUSE/src/main.bc index fc0f8bda..c47a839c 100644 --- a/themes/openSUSE/src/main.bc +++ b/themes/openSUSE/src/main.bc @@ -25,6 +25,7 @@ %% include dia_restore.inc %% include dia_net.inc %% include dia_otheropts.inc +%% include dia_extralang.inc %% include panel.inc %% include keytables.inc %% include locale.inc diff --git a/themes/openSUSE/src/panel.inc b/themes/openSUSE/src/panel.inc index 9a611b3f..ea7670a2 100644 --- a/themes/openSUSE/src/panel.inc +++ b/themes/openSUSE/src/panel.inc @@ -170,6 +170,7 @@ dup "otheropts" eq { pop [ /panel.otheropts /panel.otheropts.width /panel.otheropts.update /otheropts.init ] return } if dup "dud" eq { pop [ /panel.dud /panel.dud.width /panel.dud.update /dud.init ] return } if dup "keymap" eq { pop [ /panel.keymap /panel.keymap.width /panel.keymap.update /keymap.init ] return } if + dup "extralang" eq { pop [ /panel.extralang /panel.extralang.width /panel.extralang.update /extralang.init ] return } if dup "bits" eq { pop .undef From 318ba54d6ba0865722bf030c7bbad748de3d8423 Mon Sep 17 00:00:00 2001 From: Steffen Winterfeldt Date: Tue, 26 May 2020 14:19:56 +0200 Subject: [PATCH 2/2] actual implementation of language switch --- themes/openSUSE/src/dia_extralang.inc | 85 +++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 themes/openSUSE/src/dia_extralang.inc diff --git a/themes/openSUSE/src/dia_extralang.inc b/themes/openSUSE/src/dia_extralang.inc new file mode 100644 index 00000000..f083d8c7 --- /dev/null +++ b/themes/openSUSE/src/dia_extralang.inc @@ -0,0 +1,85 @@ +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% +% extra language switch button +% +% Iterate through the locales in config.extralang.locales array. +% +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Initialize. +% +% ( ) ==> ( ) +% +/extralang.init { + /extralang.current 0 def +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Get index in language menu. +% +% ( ) ==> ( ) +% +/extralang.index { + 0 1 lang.items length 1 sub { + lang.items over get config.extralang.locales extralang.current get eq { return } { pop } ifelse + } for + 0 +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Get language name. +% +% ( ) ==> ( ) +% +/extralang.name { + config.extralang.locales extralang.current get lang.getdefname +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Set a new language. +% +% ( ) ==> ( ) +% +/extralang.update { + xmenu.lang .xm_current extralang.index put + lang.update +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Activate selected language. +% +% And also move to next language in list. +% +% ( ) => ( ) +% +/panel.extralang { + extralang.update + % go to next language + /extralang.current extralang.current 1 add config.extralang.locales length mod def +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Return width of panel entry. +% +% ( ) => ( width ) +% +/panel.extralang.width { + extralang.name strsize pop +} def + + +% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +% Redraw panel entry. +% +% ( panel ) => ( ) +% +/panel.extralang.update { + panel.text.moveto + extralang.name show.rtl +} def