Bo Peng wrote:
The attached patch is updated with JMarc' input and uses InsetText
instead of a button. The patch is growing bigger and bigger so I think
it is time to put it in so that we can improve it bit by bit.

Please find attached an updated patch that solves the problems of

1. display special triangle for menu info. This was made possible by
deriving InsetInfo from InsetText.

2. load bind file and ui in batch mode so use_gui is not needed.


Just some stylish issue with nested loops and ifs. The code is really easier to maintain and understand if we try to avoid indentation to the maximum by breaking/returning/continuing early in the loop or the 'if' condition. Example:

+       case MENU_INFO: {
+               stack<docstring> names;
+               FuncRequest func = lyxaction.lookupFunc(name_);
+               if (func.action == LFUN_UNKNOWN_ACTION) {
+                       setText(_("No menu entry for "), bp_.getFont(), false);
+                       break;
+               }
+               // iterate through the menubackend to find it
+               Menu menu = menubackend.getMenubar();
+               if (menu.searchFunc(func, names)) {
+                       // if find, return its path.
+                       InsetText::clear();
+                       Paragraph & info = paragraphs().front();
+                       while (!names.empty()) {
...
+                       }
+                       break;
+               }
+               // not found
+               setText(_("No menu entry for "), bp_.getFont(), false);
+               break;
+       }

I'd prefer

                if (!menu.searchFunc(func, names)) {
                        setText(_("No menu entry for "), bp_.getFont(), false);
                        break;
                }

And then deindent the rest.

Abdel.

Reply via email to