-
-// Extract shortcut from <ident>|<shortcut> string
-char const * flyx_shortcut_extract(char const * sc)
-{
- // Find '|' in the sc and return the string after that.
- register char const * sd = sc;
- while(sd[0]!= 0 && sd[0] != '|') ++sd;
-
- if (sd[0] == '|') {
- ++sd;
- //lyxerr << sd << endl;
- return sd;
- }
- return "";
-}
-
-
-// Extract identifier from <ident>|<shortcut> string
-char const * flyx_ident_extract(char const * sc)
-{
- register char const * se = sc;
- while(se[0]!= 0 && se[0] != '|') ++se;
-
- if (se[0] == 0) return sc;
-
- char * sb = new char[se - sc + 1];
- int index = 0;
- register char const * sd = sc;
- while (sd != se) {
- sb[index] = sd[0];
- ++index; ++sd;
- }
- sb[index] = 0;
- return sb;
-}
-
-
-//
-void WriteAlert(string const & s1, string const & s2, string const & s3)
-{
- MiniBuffer * minibuffer = 0;
- if (current_view && current_view->owner())
- minibuffer = current_view->owner()->getMiniBuffer();
- if (minibuffer) {
- ProhibitInput(current_view);
- minibuffer->Set(s1, s2, s3);
- }
-
- fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
- fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
- if (minibuffer) {
- AllowInput(current_view);
- }
-}
-
-
-// Alarms user of something related to files
-void WriteFSAlert(string const & s1, string const & s2)
-{
- WriteAlert (s1, s2, strerror(errno));
-}
-
-
-bool AskQuestion(string const & s1, string const & s2, string const & s3)
-{
- fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y")));
- fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n")));
- return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
-}
-
-
-// Returns 1 for yes, 2 for no, 3 for cancel.
-int AskConfirmation(string const & s1, string const & s2, string const & s3)
-{
- fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
- scex(_("No|Nn#n")),
- scex(_("Cancel|^[")));
- return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(),
- 3, idex(_("Yes|Yy#y")),
- idex(_("No|Nn#n")),
- idex(_("Cancel|^[")), 3);
-}
-
-
-// Asks for a text
-pair<bool, string> const
-askForText(string const & msg, string const & dflt)
-{
- fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")));
- fl_set_resource("flInput.ok.label", idex(_("OK|#O")));
- fl_set_resource("flInput.clear.label", idex(_("Clear|#e")));
- char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
- if (tmp != 0)
- return make_pair<bool, string>(true, string(tmp));
- else
- return make_pair<bool, string>(false, string());
-}
-
-
-// Inform the user that the buffer is read-only, and that changes in the
-// dialog box that is to appear will be ignored.
-void WarnReadonly(string const & file)
-{
- WriteAlert(_("Any changes will be ignored"),
- _("The document is read-only:"),
- MakeDisplayPath(file));
-}
-
-/// Get the dpi setting of the current screen
-float getScreenDPI()
-{
- Screen * scr = DefaultScreenOfDisplay(fl_get_display());
- return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
- (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
-}