In a previous post, I modified the Main Defaults screen to display the ListPlus Enabled switch status. This status simply reads the variable lp_options and shows whether the cfl_enable bit is on or off, which we had defined in an earlier post. I’ll write about what I did to give the WWIV BBS user the ability to toggle that bit.
Since I want ListPlus to be available to users who have ANSI enabled, it makes sense to make the toggle as well as the switch visible to users who have okansi() = True. In defaults(), a section of code adds keys that the BBS tests for input. I simply add L to our allowable keys.
737 bout.outstr("|#9Defaults: ");
738 std::string allowable = "Q?1234567BCDIKMNTUW";
739 if (okansi()) {
740 allowable.append("89AS");
741 if (a()->fullscreen_read_prompt()) {
742 allowable.push_back('G');
743 }
744 }
745 switch (const auto ch = onek(allowable, true); ch) {
I modify line 740 to:
740 allowable.append("89ALS");
This makes the onek() function call in line 745, to accept L as input, aside from the other keys in the string allowable.
Now that onek() will accept L, I need to define a switch case, to handle what to do if the BBS receives an L. To make it easier to find the code, I insert the case definition for ‘L’ right after that for ‘K’.
802 case 'K':
803 wwiv::bbs::menus::ConfigUserMenuSet("");
804 need_menu_reload = true;
805 break;
+ case 'L':
+ a()->user()->data.lp_options ^= cfl_enable;
+ break;
806 case 'M':
807 a()->user()->toggle_flag(User::noMsgs);
808 break;
I used XOR assignment to toggle the cfl_enable bit of lp_options of the user. If it is currently on, XOR will set it off. If it is currently off, XOR will set it on.
That’s it. I’ve made the user’s cfl_enable bit (ListPlus) toggleable from the Main Defaults menu of WWIV.
Next time, I’ll describe the rest of the code modifications needed to make the switch actually turn ListPlus on or off in WWIV.