mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-14 06:57:01 +00:00
scex and idex now receive and return string, not char *.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5747 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
88d8d44fe4
commit
08001ad6df
@ -34,29 +34,29 @@ void alert_pimpl(string const & s1, string const & s2, string const & s3)
|
||||
|
||||
bool askQuestion_pimpl(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")));
|
||||
fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y")).c_str());
|
||||
fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n")).c_str());
|
||||
return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0);
|
||||
}
|
||||
|
||||
|
||||
int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3)
|
||||
{
|
||||
fl_set_choices_shortcut(scex(_("Yes|Yy#y")),
|
||||
scex(_("No|Nn#n")),
|
||||
scex(_("Cancel|^[")));
|
||||
fl_set_choices_shortcut(scex(_("Yes|Yy#y")).c_str(),
|
||||
scex(_("No|Nn#n")).c_str(),
|
||||
scex(_("Cancel|^[")).c_str());
|
||||
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);
|
||||
3, idex(_("Yes|Yy#y")).c_str(),
|
||||
idex(_("No|Nn#n")).c_str(),
|
||||
idex(_("Cancel|^[")).c_str(), 3);
|
||||
}
|
||||
|
||||
|
||||
pair<bool, string> const askForText_pimpl(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")));
|
||||
fl_set_resource("flInput.cancel.label", idex(_("Cancel|^[")).c_str());
|
||||
fl_set_resource("flInput.ok.label", idex(_("OK|#O")).c_str());
|
||||
fl_set_resource("flInput.clear.label", idex(_("Clear|#e")).c_str());
|
||||
char const * tmp = fl_show_input(msg.c_str(), dflt.c_str());
|
||||
if (tmp != 0)
|
||||
return make_pair<bool, string>(true, string(tmp));
|
||||
|
@ -1,3 +1,14 @@
|
||||
2002-11-29 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* forms_gettext.[Ch] (scex, idex): re-written to receive and return
|
||||
string not char *. The old idex function was new-ing memory and nothing
|
||||
that used it was ensuring that this memory didn't leak. Now safe.
|
||||
|
||||
* Alert_pimpl.C:
|
||||
* FormFiledialog.C:
|
||||
* FormPreferences.C:
|
||||
* forms/fdfixc.sed: associated changes.
|
||||
|
||||
2002-11-28 Rob Lahaye <lahaye@snu.ac.kr>
|
||||
|
||||
* forms/fdfixh.sed: bug fix.
|
||||
|
@ -453,8 +453,8 @@ void FileDialog::Private::SetButton(int index, string const & name,
|
||||
}
|
||||
|
||||
if (!name.empty()) {
|
||||
fl_set_object_label(ob, idex(name.c_str()));
|
||||
fl_set_button_shortcut(ob, scex(name.c_str()), 1);
|
||||
fl_set_object_label(ob, idex(name).c_str());
|
||||
fl_set_button_shortcut(ob, scex(name).c_str(), 1);
|
||||
fl_show_object(ob);
|
||||
*tmp = path;
|
||||
} else {
|
||||
|
@ -103,13 +103,14 @@ void FormMathsBitmap::build()
|
||||
}
|
||||
bitmaps_.clear();
|
||||
|
||||
char const * const label = _("Close|^[");
|
||||
x_ = (fdui->form->w - 90) / 2;
|
||||
y_ = y_close + 10;
|
||||
|
||||
char const * const label = _("Close|^[");
|
||||
FL_OBJECT * button_close =
|
||||
fl_add_button(FL_NORMAL_BUTTON, x_, y_, 90, 30, idex(_(label)));
|
||||
fl_set_button_shortcut(button_close, scex(_(label)), 1);
|
||||
fl_add_button(FL_NORMAL_BUTTON, x_, y_, 90, 30,
|
||||
idex(_(label)).c_str());
|
||||
fl_set_button_shortcut(button_close, scex(_(label)).c_str(), 1);
|
||||
fl_set_object_lsize(button_close, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(button_close, C_FormBaseCancelCB, 0);
|
||||
|
||||
|
@ -1092,8 +1092,9 @@ bool FormPreferences::Converters::Browser()
|
||||
fl_set_input(dialog_->input_converter, c.command.c_str());
|
||||
fl_set_input(dialog_->input_flags, c.flags.c_str());
|
||||
|
||||
fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
|
||||
fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
|
||||
fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
|
||||
fl_set_button_shortcut(dialog_->button_add,
|
||||
scex(_("Modify|#M")).c_str(), 1);
|
||||
|
||||
setEnabled(dialog_->button_add, false);
|
||||
setEnabled(dialog_->button_delete, true);
|
||||
@ -1123,17 +1124,19 @@ bool FormPreferences::Converters::Input()
|
||||
fl_freeze_form(dialog_->form);
|
||||
|
||||
if (sel < 0) {
|
||||
fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
|
||||
fl_set_object_label(dialog_->button_add,
|
||||
idex(_("Add|#A")).c_str());
|
||||
fl_set_button_shortcut(dialog_->button_add,
|
||||
scex(_("Add|#A")), 1);
|
||||
scex(_("Add|#A")).c_str(), 1);
|
||||
|
||||
fl_deselect_browser(dialog_->browser_all);
|
||||
setEnabled(dialog_->button_delete, false);
|
||||
|
||||
} else {
|
||||
fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
|
||||
fl_set_object_label(dialog_->button_add,
|
||||
idex(_("Modify|#M")).c_str());
|
||||
fl_set_button_shortcut(dialog_->button_add,
|
||||
scex(_("Modify|#M")), 1);
|
||||
scex(_("Modify|#M")).c_str(), 1);
|
||||
|
||||
int top = max(sel-5, 0);
|
||||
fl_set_browser_topline(dialog_->browser_all, top);
|
||||
@ -1366,8 +1369,10 @@ bool FormPreferences::Formats::Browser()
|
||||
fl_set_input(dialog_->input_extension, f.extension().c_str());
|
||||
fl_set_input(dialog_->input_viewer, f.viewer().c_str());
|
||||
|
||||
fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
|
||||
fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
|
||||
fl_set_object_label(dialog_->button_add,
|
||||
idex(_("Modify|#M")).c_str());
|
||||
fl_set_button_shortcut(dialog_->button_add,
|
||||
scex(_("Modify|#M")).c_str(), 1);
|
||||
|
||||
setEnabled(dialog_->button_add, false);
|
||||
setEnabled(dialog_->button_delete, true);
|
||||
@ -1402,18 +1407,18 @@ bool FormPreferences::Formats::Input()
|
||||
|
||||
if (sel < 0) {
|
||||
fl_set_object_label(dialog_->button_add,
|
||||
idex(_("Add|#A")));
|
||||
idex(_("Add|#A")).c_str());
|
||||
fl_set_button_shortcut(dialog_->button_add,
|
||||
scex(_("Add|#A")), 1);
|
||||
scex(_("Add|#A")).c_str(), 1);
|
||||
|
||||
fl_deselect_browser(dialog_->browser_all);
|
||||
setEnabled(dialog_->button_delete, false);
|
||||
|
||||
} else {
|
||||
fl_set_object_label(dialog_->button_add,
|
||||
idex(_("Modify|#M")));
|
||||
idex(_("Modify|#M")).c_str());
|
||||
fl_set_button_shortcut(dialog_->button_add,
|
||||
scex(_("Modify|#M")), 1);
|
||||
scex(_("Modify|#M")).c_str(), 1);
|
||||
|
||||
int const top = max(sel-5, 0);
|
||||
fl_set_browser_topline(dialog_->browser_all, top);
|
||||
|
@ -80,8 +80,8 @@ s/\( fdui->form\)\(.*bgn_form.*\)/\1\2\
|
||||
|
||||
|
||||
# For all lines containing "_shortcut" and a string containing |,
|
||||
# replace the string with scex(_(string))
|
||||
/_shortcut/ s/".*[|].*"/scex(_(&))/
|
||||
# replace the string with scex(_(string)).c_str()
|
||||
/_shortcut/ s/".*[|].*"/scex(_(&)).c_str()/
|
||||
|
||||
|
||||
# For all lines containing "fl_add" and a string containing |
|
||||
@ -89,12 +89,12 @@ s/\( fdui->form\)\(.*bgn_form.*\)/\1\2\
|
||||
# fdui->counter_zoom = obj = fl_add_counter(...,"Zoom %|#Z");
|
||||
# becomes
|
||||
# c_str = _("Zoom %|#Z");
|
||||
# fdui->counter_zoom = obj = fl_add_counter(...,idex(c_str));
|
||||
# fl_set_button_shortcut(obj,scex(c_str),1);
|
||||
# fdui->counter_zoom = obj = fl_add_counter(...,idex(c_str).c_str());
|
||||
# fl_set_button_shortcut(obj,scex(c_str).c_str(),1);
|
||||
|
||||
/fl_add.*".*[|].*"/s/fdui\(.*\)"\(.*\)".*/c_str = _("\2");\
|
||||
fdui\1idex(c_str));\
|
||||
fl_set_button_shortcut(obj,scex(c_str),1);/
|
||||
fdui\1idex(c_str).c_str());\
|
||||
fl_set_button_shortcut(obj,scex(c_str).c_str(),1);/
|
||||
|
||||
|
||||
# gettext will get confused if the string contains a "%" unless the line is
|
||||
@ -105,10 +105,8 @@ s/\( fdui->form\)\(.*bgn_form.*\)/\1\2\
|
||||
|
||||
# Someone got busy and put spaces in after commas but didn't allow for the
|
||||
# autogeneration of the files so their pretty formatting got lost. Not anymore.
|
||||
#
|
||||
s/,\([^ ]\)/, \1/g
|
||||
|
||||
# Clean up one special case where a comma appears at the end of a string
|
||||
# while ensuring "...", "..." isn't affected.
|
||||
#
|
||||
s/\("[^"]+,\) \("\)/\1\2/g
|
||||
|
@ -14,39 +14,19 @@
|
||||
#endif
|
||||
|
||||
#include "forms_gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
// Extract shortcut from "<ident>|<shortcut>" string
|
||||
char const * scex(char const * sc)
|
||||
// Extract shortcut from "<identifier>|<shortcut>" string
|
||||
string const scex(string const & str)
|
||||
{
|
||||
// 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;
|
||||
return sd;
|
||||
}
|
||||
return "";
|
||||
return split(str, '|');
|
||||
}
|
||||
|
||||
|
||||
// Extract identifier from "<ident>|<shortcut>" string
|
||||
char const * idex(char const * sc)
|
||||
// Extract identifier from "<identifier>|<shortcut>" string
|
||||
string const idex(string const & str)
|
||||
{
|
||||
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;
|
||||
string identifier;
|
||||
split(str, identifier, '|');
|
||||
return identifier;
|
||||
}
|
||||
|
@ -16,10 +16,12 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
/// Extract shortcut from "<ident>|<shortcut>" string
|
||||
char const * scex(char const *);
|
||||
#include "LString.h"
|
||||
|
||||
/// Extract identifier from "<ident>|<shortcut>" string
|
||||
char const * idex(char const *);
|
||||
/// Extract shortcut from "<identifer>|<shortcut>" string
|
||||
string const scex(string const &);
|
||||
|
||||
/// Extract identifier from "<identifer>|<shortcut>" string
|
||||
string const idex(string const &);
|
||||
|
||||
#endif // FORMS_GETTEXT_H
|
||||
|
Loading…
Reference in New Issue
Block a user