"Bo Peng" <[EMAIL PROTECTED]> writes: > My idea about an information inset does not trigger much discussion. > The attached is an almost complete patch that adds InsetInfo
I am always a bit slow unfortunately. However, I am very interested by your patch and I am glad you finally did that. > This inset is displayed as a non-editable button. To avoid the trouble > of a separate GUI, this inset is not editable. The *only* method to > create such an inset is to write something like 'shortcut:font-bold', > select, and Ctrl-Shift-I (defined in cua.bind, trigger info-insert). You should also allow to do "info-inset arg". > This inset will display the information as requested (e.g. shortcut > for font-bold). The name of this inset (shortcut:font-bold) is > displayed in the status bar when it is under mouse (hover). > > The .lyx definition is > > \begin_inset Info "shortcut:copy" > \end_inset I really think that you should switch to a representation like \begin_inset Info type "shortcut" arg "copy" \end_inset There is little point in keeping the info as foo:bar and then split the string every time it is needed... I understand it is done only once, but still I do not like it. I'd even prefer to keep the type as an enum, even if it seems to be more work for now. BTW, did you investigate using InsetCommand as a base? Would it help at all? > This inset can only handle shortcut:blah, if needed, people can add > other types of information to InsetInfo:getInfo() easily. I am not sure that the new support for LyXRC is worth it. Where would you need it? (besides "why not?"). This information is available in a better version in the prefs dialog. If the goal was to make this information available outside, then a lyxrc-get LFUN would be more useful. Actually, the idea I had about this functionality earlier was more like an InsetLFUN that would output the result of an LFUN. Use would be like lfun-insert shortcut-get copy This means that the information would also be made available to the lyxserver. I do not insist on this particular implementation, but I thought it was worth mentioning. To finish with lyxrc, you do heavy changes in lyxrc and the ugliness of the code is even worse than it was. Unless you have a specific application in mind, I'd propose to drop this code. Concerning shortcuts, I do not think it is wise to change a KeyMap mathod that is used elsewhere just because it does not look right for your use case. Actually, since the goal is to show the shortcut in the GUI (for the documentation), I'd suggest to stick with the first element only like the menus. KeyMap::print(true) is fine for that. About ideas for other entries, I do not thin that bufferparams is useful. However I'd like to see "package" and "textclass" entries, since they are used in LaTeXConfig.lyx.in and we should aim at dropping the generation of these files. [comments about updated patch below] > + } else if (prefixIs(name_, "lyxrc:")) { > + string rc = name_.substr(6); > + if (rc.empty()) > + return docstring(); > + ostringstream oss; > + lyxrc.write(oss, true, rc); > + string result = oss.str(); > + // remove leading \\name > + result = result.substr(rc.size() + 2); > + // remove \n and "" > + result = rtrim(result, "\n"); > + result = trim(result, "\""); > + return from_utf8(result); When code is this ugly, you are clearly abusing some interface :) > + case LFUN_INFO_INSERT: { > + if (!cur.selection()) > + break; > + Inset * inset = createInset(&cur.bv(), cmd); > + if (!inset) > + break; > + // use selected text as info to avoid a separate UI > + docstring ds = cur.selectionAsString(false); > + cutSelection(cur, true, false); > + insertInset(cur, inset); > + static_cast<InsetInfo *>(inset)->setInfo(to_utf8(ds)); > + cur.posRight(); > + updateLabels(bv->buffer()); > + break; Do you need updateLabels? > + LyXRCTags tag = RC_LAST; > + > + if (name.empty()) > + tag = RC_LAST; > + else { > + for (size_t i = 0; i < lyxrcCount; ++i) > + if ("\\" + name == lyxrcTags[i].tag) > + tag = static_cast<LyXRCTags>(lyxrcTags[i].code); Rather if (!name.empty()) { } > Index: lib/bind/cua.bind > =================================================================== > --- lib/bind/cua.bind (revision 20861) > +++ lib/bind/cua.bind (working copy) > @@ -89,6 +89,7 @@ > \bind "M-S-Left" "depth-decrement" > \bind "C-S-L" "ligature-break-insert" > \bind "C-l" "ert-insert" # 'l' for LaTeX > +\bind "C-S-I" "info-insert" > > #bind "F1" "help" # Not yet implemented! > #bind "C-F1" "help-context" # Not yet implemented! If this goes in, you should investigate the other bind files. > Index: lib/ui/stdmenus.inc > =================================================================== > --- lib/ui/stdmenus.inc (revision 20861) > +++ lib/ui/stdmenus.inc (working copy) > @@ -488,6 +488,7 @@ > Item "User's Guide|U" "help-open UserGuide" > Item "Extended Features|E" "help-open Extended" > Item "Embedded Objects|m" "help-open EmbeddedObjects" > + Item "Shortcuts|s" "help-open Shortcuts" > Item "Customization|C" "help-open Customization" > Item "FAQ|F" "help-open FAQ" > Item "Table of Contents|a" "help-open TOC" Keep this for later, unless you have a pretty complete LyX file. JMarc