John's spellchecker patch plus a new helper function getStringFromBrowser.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3309 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-01-08 10:05:53 +00:00
parent cbfe82a689
commit 13daca767e
4 changed files with 41 additions and 5 deletions

View File

@ -1,3 +1,12 @@
2002-01-08 Angus Leeming <a.leeming@ic.ac.uk>
* xform_helpers.[Ch] (getStringFromBrowser): a littel wrapper function
for fl_get_browser_line that is guaranteed to return a valid string.
2002-01-08 John Levon <moz@compsoc.man.ac.uk>
* FormSpellchecker.C: fix possible crash on clicking a suggestion
2002-01-07 Angus Leeming <a.leeming@ic.ac.uk>
* FormDocument.C:

View File

@ -63,7 +63,7 @@ void FormSpellchecker::hide()
ButtonPolicy::SMInput FormSpellchecker::input(FL_OBJECT * obj, long)
{
if (obj == dialog_->replace) {
string tmp = fl_get_input(dialog_->input);
string const tmp = fl_get_input(dialog_->input);
controller().replace(tmp);
} else if (obj == dialog_->start) {
controller().check();
@ -80,13 +80,19 @@ ButtonPolicy::SMInput FormSpellchecker::input(FL_OBJECT * obj, long)
} else if (obj == dialog_->options) {
controller().options();
} else if (obj == dialog_->browser) {
int sel = fl_get_browser(dialog_->browser);
int const sel = fl_get_browser(dialog_->browser);
if (sel < 1)
return ButtonPolicy::SMI_NOOP;
if (clickline_ == sel) {
string tmp = fl_get_input(dialog_->input);
string const tmp = fl_get_input(dialog_->input);
controller().replace(tmp);
}
clickline_ = sel;
string tmp = fl_get_browser_line(dialog_->browser, clickline_);
char const * cptmp = fl_get_browser_line(dialog_->browser,
clickline_);
string const tmp = (cptmp) ? cptmp : "";
fl_set_input(dialog_->input, tmp.c_str());
}

View File

@ -90,6 +90,19 @@ vector<string> const getVectorFromChoice(FL_OBJECT * ob)
}
// Given an fl_browser, return the contents of the currently
// highlighted line.
// If nothing is selected, return an empty string
string const getStringFromBrowser(FL_OBJECT * ob, int line)
{
if (!ob || ob->objclass != FL_BROWSER ||
line < 1 || line > fl_get_browser_maxline(ob))
return string();
char const * tmp = fl_get_browser_line(ob, line);
return (tmp) ? tmp : string();
}
// Given an fl_browser, create a vector of its entries
vector<string> const getVectorFromBrowser(FL_OBJECT * ob)
{

View File

@ -39,6 +39,14 @@ std::vector<string> const getVectorFromChoice(FL_OBJECT *);
/// Given an fl_browser, create a vector of its entries
std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
/** Given an fl_browser, return the contents of the currently
highlighted line (xforms numbering convention; starts at 1).
If nothing is selected, return an empty string.
This function, although apparently overkill, ensures that we don't get
unexpected crashes.
*/
string const getStringFromBrowser(FL_OBJECT * ob, int line);
/// Given input and choice widgets, create a string such as "1cm"
string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);