Hey all,
A while ago I was creating BeeBS II the successor to BeeBS (beebs.ddns.net) a BBS which supports Acorn mode 7 (teletext graphics) as well as ANSI and ASCII running on my BBC Micro. I've recently found my backup of BeeBSII (the synchronet successor) and would like to complete the project but this time "legally" i.e. still keeping a 40 col ascii mode rather than sending teletext control codes via that. Instead I've decided to create a localisation language (bbcmicro) and store the menu files in /text/menu/bbcmicro. Using text.bbcmicro.ini will allow me to create the Mode 7 prompts, but I'm struggling to use gettext.js to customise yesnobar.js I would like to replace "\x01h\x014\x01w\x01e[\x01~%s]\x01n\x01b\x01h \x01~%s" with "\x82(%s)\x81%s".
To yesnobar.js I have added/amended:
load("gettext.js");
str = format(gettext("\x01h\x014\x01w\x01e[\x01~%s]\x01n\x01b\x01h \x01~%s"), yes_str, no_str);
To the end of text.bbcmicro.ini I have added:
[JS]
\x01h\x014\x01w\x01e[\x01~%s]\x01n\x01b\x01h \x01~%s = \x82(%s)\x81%s
I get no errors, however the prompts appear as they originally did.
I can replace the string in yesnobar.js which works fine, but then (understandably) doesn't look great in ASCII/ANSI clients.
There is also a small typo in the example given here: http://wiki.synchro.net/custom:javascript:lib:gettext.js
print(getttext - should be - print(gettext
There's probably a better solution, like just using a custom replacment for the yesnobar/noyesbar mods when in this teletextmode.
To elaborate, in your text.bbcmicro.ini (root section, not [JS]): YesNoQuestion = @exec:bbcyesno@
NoYesQuestion = @exec:bbsnoyes@
(but the "exec" must be uppercase). Then you can create your mods/bbcyesno.js and bbcnoyes.js to do your thing. No change to yesnobar.js or noyesbar.js should be needed.
"\x01-\x01c\xfe \x01b\x01h" + gettext("Main") + " \x01n\x01c\xfe \x01h" + time_code +
" \x01n\x01c[\x01h@GN@\x01n\x01c] @GRP@\x01\\ [\x01h@SN@\x01n\x01c] @SUB@: \x01n",
I can't see an exec for it in text.dat so assuming not quite as simple to customise?
just use @codes to print the time
you can do an exec code in your text.dat or in your command shell.
i have an animated script i wrote for my prompt.
just use @codes to print the time
you can do an exec code in your text.dat or in your command shell.
i have an animated script i wrote for my prompt.
I think you may have misunderstood what I'm trying to do. I would like
the
main menu prompt located in default.js to use Acorn Mode 7 control codes if the user has their language set to BBC Micro, but continue to use the default control codes if not. In the same way the yesnobar now displays (thanks to Rob) \x01h\x014\x01w\x01e[\x01~%s]\x01n\x01b\x01h \x01~%s by default but \x82(%s)\x81%s on a Mode 7 terminal.
To elaborate, in your text.bbcmicro.ini (root section, not [JS]): YesNoQuestion = @exec:bbcyesno@
NoYesQuestion = @exec:bbsnoyes@
(but the "exec" must be uppercase). Then you can create your mods/bbcyesno.js and bbcnoyes.js to do your thing. No change to yesnobar.js or noyesbar.js should be needed.
Brilliant thank you, that has worked great. Is it possible to do something similar with the main prompt in default.js?
"\x01-\x01c\xfe \x01b\x01h" + gettext("Main") + " \x01n\x01c\xfe \x01h" + time_code +
" \x01n\x01c[\x01h@GN@\x01n\x01c] @GRP@\x01\\ [\x01h@SN@\x01n\x01c] @SUB@: \x01n",
I can't see an exec for it in text.dat so assuming not quite as simple to customise?
There's no text.dat string for a specific command shell prompt, no. We could possibly pull that prompt from a JSON file as using a .ini file (e.g. modopts.ini) is likely a pain (or likely impossible, currently) due to all the escape sequences and extra quotes. JSON would likely work better for that case.
I ended up doing something different/better, still using the text[.lang].ini file.
I ended up doing something
different/better, still using the
text[.lang].ini file. See my commits > and wiki updates for details. Let me > know if you have any questions.
Re: Help using gettext.js
By: Digital Man to vela025 on Mon Oct 14 2024 19:35:51
I ended up doing something different/better, still using the text[.lang].ini file. See my commits > and wiki updates for details. Let me > know if you have any questions.
Sorry to bother you again (again). I have no js knowledge but would it be possible to add a prompt just post
the password entry during the logon process (but pre-loading logon.*) asking the user for their language preferences. A bit of a hack I know, but that would allow me to store the different menus in their own respectivefolders: /menu/ansi
/menu/ascii
/menu/mode7
So that when swapping from a Mode 7 terminal to a 40 Col ASCII terminal theuser doesn't need to go through a few
screens of Mode 7 control codes before they can access D from the Main Menu tochange their Language preferences back
to English (or in this case ASCII).
This sounds like something you could add to the top of your logon.js file.
if(confirm("Are you using a BBC Micro Mode 7 terminal"))
user.lang = "bbcmicro";
else
user.lang = "";
Would something similar to this work:
if(confirm("Are you using a BBC Micro Mode 7 terminal"))
user.lang = "bbcmicro";
user.settings &= ~USER_AUTOTERM | USER_ANSI | USER_RIP | USER_WIP | USER_HTML | USER_PETSCII | USER_UTF8;
user.settings &= ~USER_EXASCII;
else
user.lang = "";
Yup, I think so. Did you try it?
--
digital man (rob)
Which worked!! So now I'm going to look at CASE (I think?) so that the user will initially get:
Please select terminal type:
(4) 0 Column ASCII
Acorn Mode (7)
(8) 0 Column ANSI
Enter 4, 7 or 8:
No I was a little worried it would corrupt a settings file somewhere. But I've backed up everything now and this:
if(confirm("Are you using a BBC Micro Mode 7 terminal"))
user.lang = "bbcmicro";
user.settings &= ~USER_AUTOTERM | USER_ANSI | USER_RIP | USER_WIP |
USER_HTML | USER_PETSCII | USER_UTF8;
user.settings &= ~USER_EXASCII;
else
user.lang = "";
Gives line 16:SyntaxError (which is the else line). Else is not indented and at the margin inline with IF. Indenting also give the same error. In
I thought I was doing so well! but there's now an odd issue occurring when swapping from one terminal type to another.
Scenario 1: Log in a Mode 7 terminal everything's fine, Next login using an ANSI terminal, message summary screen overlays some text over avatar, Log out, Log in again using ANSI terminal everything is fine.
Scenario 2: Login to Mode 7 after having previously used ANSI terminal and some prompts are not using the BBC "language.ini" customisation (but some are, and some are, but ignoring the colour codes). The main menu is shifted after the first row, log out, log back in using Mode 7 and everything is fine.
I've put screenshots here: http://beebs.ddns.net/BeeBS/My_Albums/Pages/Synchronet.html which probably make more sense.
Previously before I added the terminal type selection at logon when the user used to have to change the terminal settings manually (using D from the main menu) this also required the user to log out and back in for all settings to take effect. Is there a command that will "refresh" the settings to ensure they're all being used?
This is the terminal selection script I've cobbled together:
switch (userChoice) {
case "4":
user.lang = "ascii";
user.settings &= ~(USER_AUTOTERM | USER_ANSI | USER_RIP | USER_WIP | USER_HTML | USER_PETSCII | USER_UTF8);
user.settings &= ~USER_NO_EXASCII;
user.screen_columns = 40;
user.screen_rows = 25;
break;
case "7":
user.lang = "bbcmicro";
user.settings &= ~(USER_AUTOTERM | USER_ANSI | USER_RIP | USER_WIP | USER_HTML | USER_PETSCII | USER_UTF8);
user.settings &= ~USER_NO_EXASCII;
user.screen_columns = 40;
user.screen_rows = 25;
break;
case "8":
user.lang = "ansi";
user.settings &= ~(USER_AUTOTERM | USER_RIP | USER_WIP | USER_HTML | USER_PETSCII | USER_UTF8);
user.settings &= ~USER_NO_EXASCII;
user.settings |= USER_ANSI;
user.screen_columns = 80;
user.screen_rows = 25;
break;
default:
user.lang = "ascii";
user.settings &= ~(USER_AUTOTERM | USER_ANSI | USER_RIP | USER_WIP | USER_HTML | USER_PETSCII | USER_UTF8);
user.settings &= ~USER_NO_EXASCII;
user.screen_columns = 40;
user.screen_rows = 25;
break;
}
using a language file to control terminal typeI'm using the language file to use different control codes for the user prompts, but the script above to change the users terminal type settings is in logon.js.
Which "settings" are you referring to?Changing manually from one terminal type to another. i.e. changing from an ansi supported terminal to soley cp437 used to require the user to log out and back in again (same user account) for all the settings to take effect (this was before adding the terminal prompt at logon and before using the language files to customize prompts). After changing to terminal settings to just cp437 the Mode 7 menus did not display correctly, however when the same user logged out and back in the menus displayed as they should.
I looked at it, but doesn't tell me any specific cause.Yeah I'm not sure what the specific cause is. I think it might be column related as the Mode 7 screens corrupt just after @ANODE|L13@ and the ANSI screen is displaying the avatar too far left. Maybe there is something at logoff that re-confirms the users terminal settings and update a flag I've missed.
I would think an "ascii" terminal would want no extended ASCII (IBM CP437) characters, so that USER_NO_EXASCII flag should be set (not cleared)
If JS, you can just put "default:" on the line before the "case" statement you want to be the default.Great thanks JS is still very new to me I'll implement this.
Hi Rob, sorry for not being more specific/explaining seemingly odd choices :D >"next login" as the same user or a different user?
Same user
using a language file to control terminal typeI'm using the language file to use different control codes for the user prompts, but the script above to change the users terminal type settings is in logon.js.
Which "settings" are you referring to?Changing manually from one terminal type to another. i.e. changing from an ansi supported terminal to soley cp437 used to require the user to log out and back in again (same user account) for all the settings to take effect (this was before adding the terminal prompt at logon and before using the language files to customize prompts). After changing to terminal settings to just cp437 the Mode 7 menus did not display correctly, however when the same user logged out and back in the menus displayed as they should.
The odd terminal choices are because it's primarily designed for a BBC Micro to use, so if you're using ASCII you're most likely in Mode 7 (which leaves the most amount of free memory and displays best on a TV, which is 40 columns), if you're using an ANSI client (of which I think there are only 2 and only one of those supports a *massive* 4 colours) then that is 80 columns and does not support UTF-8
Okay, did you try a different user and see what happens?Yeah it happens to all users.
call bbs.load_user_text() to re-load the ctrl/text.<lang>.ini file.This has definaetly fixed mode 7 not using control codes after an ANSI login and ANSI using text.bbc.ini after a Mode 7 login! Thanks!
I still can't can't think of a reason why "ansi" and "ascii" would require different language files.Some prompts are >40 characters which looks a bit messy when it goes on to a seperate line. And some use [ ] which in mode 7 displays as a left and right arrow. Having each as their own lang is a simple way for me to detect which terminal type the client is using so that custom modules can be loaded for each terminal type. For example msglist.js now is a script detecting the terminal type (via checking the lang setting) and then branches off in to msglistbbc.js/msglist.js
Okay, did you try a different user and see what happens?Yeah it happens to all users.
call bbs.load_user_text() to re-load the ctrl/text.<lang>.ini file.This has definaetly fixed mode 7 not using control codes after an ANSI login and ANSI using text.bbc.ini after a Mode 7 login! Thanks!
I still can't can't think of a reason why "ansi" and "ascii" would require different language files.Some prompts are >40 characters which looks a bit messy when it goes on to a seperate line.
And some use [ ] which in mode 7 displays as a left and right
arrow.
Having each as their own lang is a simple way for me to detect which terminal type the client is using so that custom modules can be loaded for each terminal type. For example msglist.js now is a script detecting the terminal type (via checking the lang setting) and then branches off in to msglistbbc.js/msglist.js
So now the only issue seems to be that all terminal types for the first logon after a change of terminal type between Mode 7 and ANSI causes ANSI to scroll at row 13 and *Press any key to continue*. In terms of columns it is either adding or taking away 40 columns from the column width for both ANSI and Mode 7. Examples of how this manifests itself here: http://beebs.ddns.net/BeeBS/My_Albums/Pages/Term_Dim.html Is there something similar to bbs.load_user_text() for terminal row and height?
There's console.screen_rows and screen_columns, both are writable.
Sysop: | Karloch |
---|---|
Location: | Madrid, Spain |
Users: | 54 |
Nodes: | 8 (0 / 8) |
Uptime: | 127:36:15 |
Calls: | 700 |
Files: | 17,895 |
D/L today: |
128 files (60,769K bytes) |
Messages: | 66,010 |