Dispatch->dispatch, some trans work

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2254 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-07-16 15:42:57 +00:00
parent 0a10c64616
commit efe0b0b8eb
30 changed files with 283 additions and 101 deletions

View File

@ -598,7 +598,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
bool paste_internally = false; bool paste_internally = false;
if (button == 2 if (button == 2
&& bv_->text->selection.set()) { && bv_->text->selection.set()) {
owner_->getLyXFunc()->Dispatch(LFUN_COPY); owner_->getLyXFunc()->dispatch(LFUN_COPY);
paste_internally = true; paste_internally = true;
} }
@ -644,9 +644,9 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
// insert this // insert this
if (button == 2) { if (button == 2) {
if (paste_internally) if (paste_internally)
owner_->getLyXFunc()->Dispatch(LFUN_PASTE); owner_->getLyXFunc()->dispatch(LFUN_PASTE);
else else
owner_->getLyXFunc()->Dispatch(LFUN_PASTESELECTION, owner_->getLyXFunc()->dispatch(LFUN_PASTESELECTION,
"paragraph"); "paragraph");
selection_possible = false; selection_possible = false;
return; return;

View File

@ -1,3 +1,7 @@
2001-07-12 Lars Gullik Bjønnes <larsbj@birdstep.com>
* lyxfunc.h: change more methods to begin with lower char.
2001-07-16 Dekel Tsur <dekelts@tau.ac.il> 2001-07-16 Dekel Tsur <dekelts@tau.ac.il>
* buffer.C (parseSingleLyXformat2Token): Generate error insets * buffer.C (parseSingleLyXformat2Token): Generate error insets

View File

@ -177,7 +177,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
if (lfun) { if (lfun) {
ostringstream str; ostringstream str;
str << _("LaTeX run number") << ' ' << count; str << _("LaTeX run number") << ' ' << count;
lfun->Dispatch(LFUN_MESSAGE, str.str().c_str()); lfun->dispatch(LFUN_MESSAGE, str.str().c_str());
} }
@ -214,7 +214,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) { if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
// no checks for now // no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("Running MakeIndex.")); if (lfun) lfun->dispatch(LFUN_MESSAGE, _("Running MakeIndex."));
// WriteStatus(minib, _("Running MakeIndex.")); // WriteStatus(minib, _("Running MakeIndex."));
rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
} }
@ -227,7 +227,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
// tags is found -> run bibtex and set rerun = true; // tags is found -> run bibtex and set rerun = true;
// no checks for now // no checks for now
lyxerr[Debug::LATEX] << "Running BibTeX." << endl; lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("Running BibTeX.")); if (lfun) lfun->dispatch(LFUN_MESSAGE, _("Running BibTeX."));
//WriteStatus(minib, _("Running BibTeX.")); //WriteStatus(minib, _("Running BibTeX."));
updateBibtexDependencies(head, bibtex_info); updateBibtexDependencies(head, bibtex_info);
rerun |= runBibTeX(bibtex_info); rerun |= runBibTeX(bibtex_info);
@ -259,7 +259,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
if (lfun) { if (lfun) {
ostringstream str; ostringstream str;
str << _("LaTeX run number") << ' ' << count; str << _("LaTeX run number") << ' ' << count;
lfun->Dispatch(LFUN_MESSAGE, str.str().c_str()); lfun->dispatch(LFUN_MESSAGE, str.str().c_str());
} }
// WriteStatus(minib, // WriteStatus(minib,
@ -290,7 +290,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) { if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) {
// no checks for now // no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl; lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
if (lfun) lfun->Dispatch(LFUN_MESSAGE, _("Running MakeIndex.")); if (lfun) lfun->dispatch(LFUN_MESSAGE, _("Running MakeIndex."));
//WriteStatus(minib, _("Running MakeIndex.")); //WriteStatus(minib, _("Running MakeIndex."));
rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx")));
} }
@ -315,7 +315,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun)
if (lfun) { if (lfun) {
ostringstream str; ostringstream str;
str << _("LaTeX run number") << ' ' << count; str << _("LaTeX run number") << ' ' << count;
lfun->Dispatch(LFUN_MESSAGE, str.str().c_str()); lfun->dispatch(LFUN_MESSAGE, str.str().c_str());
} }
// WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count)); // WriteStatus(minib, string(_("LaTeX run number ")) + tostr(count));

View File

@ -56,6 +56,6 @@ void ControlCommand::applyParamsToInset()
void ControlCommand::applyParamsNoInset() void ControlCommand::applyParamsNoInset()
{ {
if (action_ == LFUN_NOACTION) return; if (action_ == LFUN_NOACTION) return;
lv_.getLyXFunc()->Dispatch(action_, params().getAsString()); lv_.getLyXFunc()->dispatch(action_, params().getAsString());
} }

View File

@ -43,13 +43,13 @@ std::vector<string> const ControlRef::getLabelList() const
void ControlRef::gotoRef(string const & ref) const void ControlRef::gotoRef(string const & ref) const
{ {
lv_.getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0"); lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0");
lv_.getLyXFunc()->Dispatch(LFUN_REF_GOTO, ref); lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref);
} }
void ControlRef::gotoBookmark() const void ControlRef::gotoBookmark() const
{ {
lv_.getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0"); lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0");
} }

View File

@ -54,5 +54,5 @@ void ControlTabularCreate::apply()
string const val(tostr(params().first) + " " + tostr(params().second)); string const val(tostr(params().first) + " " + tostr(params().second));
lv_.getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, val); lv_.getLyXFunc()->dispatch(LFUN_INSET_TABULAR, val);
} }

View File

@ -42,7 +42,7 @@ ControlToc::ControlToc(LyXView & lv, Dialogs & d)
void ControlToc::Goto(int const & id) const void ControlToc::Goto(int const & id) const
{ {
string const tmp = tostr(id); string const tmp = tostr(id);
lv_.getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp); lv_.getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tmp);
} }

View File

@ -86,7 +86,7 @@ void FormMathsDelim::apply()
ostringstream ost; ostringstream ost;
ost << delim_values[left] << ' ' << delim_values[right]; ost << delim_values[left] << ' ' << delim_values[right];
lv_->getLyXFunc()->Dispatch(LFUN_MATH_DELIM, ost.str().c_str()); lv_->getLyXFunc()->dispatch(LFUN_MATH_DELIM, ost.str().c_str());
} }
bool FormMathsDelim::input(FL_OBJECT *, long) bool FormMathsDelim::input(FL_OBJECT *, long)

View File

@ -88,7 +88,7 @@ void FormMathsMatrix::apply()
ostringstream ost; ostringstream ost;
ost << nx << ' ' << ny << ' ' << c << sh; ost << nx << ' ' << ny << ' ' << c << sh;
lv_->getLyXFunc()->Dispatch(LFUN_INSERT_MATRIX, ost.str().c_str()); lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATRIX, ost.str().c_str());
} }
bool FormMathsMatrix::input(FL_OBJECT * ob, long) bool FormMathsMatrix::input(FL_OBJECT * ob, long)

View File

@ -249,13 +249,13 @@ bool FormMathsPanel::input(FL_OBJECT *, long data)
void FormMathsPanel::insertSymbol(string const & sym) const void FormMathsPanel::insertSymbol(string const & sym) const
{ {
lv_->getLyXFunc()->Dispatch(LFUN_INSERT_MATH, sym); lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATH, sym);
} }
void FormMathsPanel::mathDisplay() const void FormMathsPanel::mathDisplay() const
{ {
lv_->getLyXFunc()->Dispatch(LFUN_MATH_DISPLAY); lv_->getLyXFunc()->dispatch(LFUN_MATH_DISPLAY);
} }

View File

@ -158,7 +158,7 @@ void FormPreferences::ok()
colors_.modifiedXformsPrefs = !XformsColor::write(filename); colors_.modifiedXformsPrefs = !XformsColor::write(filename);
} }
lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES); lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
} }
@ -468,7 +468,7 @@ void FormPreferences::Colors::apply()
string const s = lcolor.getLyXName(lc) + string(" ") + string const s = lcolor.getLyXName(lc) + string(" ") +
hexname; hexname;
parent_.lv_->getLyXFunc()->Dispatch(LFUN_SET_COLOR, s); parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
} }
} }
} }
@ -778,7 +778,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
string const arg = lcolor.getLyXName(lc) + " black"; string const arg = lcolor.getLyXName(lc) + " black";
parent_.lv_->getLyXFunc()-> parent_.lv_->getLyXFunc()->
Dispatch(LFUN_SET_COLOR, arg); dispatch(LFUN_SET_COLOR, arg);
continue; continue;
} }
@ -2553,7 +2553,7 @@ void FormPreferences::ScreenFonts::apply() const
if (changed) { if (changed) {
// Now update the buffers // Now update the buffers
// Can anything below here affect the redraw process? // Can anything below here affect the redraw process?
parent_.lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE); parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
} }
} }

View File

@ -578,16 +578,15 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
// If the action value is too low, then it is not a // If the action value is too low, then it is not a
// valid action, but something else. // valid action, but something else.
if (choice >= action_offset + 1) { if (choice >= action_offset + 1) {
view->getLyXFunc()->Dispatch(choice - action_offset); view->getLyXFunc()->dispatch(choice - action_offset);
} } else {
else {
lyxerr[Debug::GUI] lyxerr[Debug::GUI]
<< "MenuCallback: ignoring bogus action " << "MenuCallback: ignoring bogus action "
<< choice << endl; << choice << endl;
} }
} } else {
else
lyxerr << "Error in MenuCallback" << endl; lyxerr << "Error in MenuCallback" << endl;
}
std::for_each(submenus.begin(), submenus.end(), fl_freepup); std::for_each(submenus.begin(), submenus.end(), fl_freepup);
// restore tabstop length // restore tabstop length

View File

@ -157,7 +157,7 @@ void Toolbar::Pimpl::layoutSelectedCB(int sel, void * arg, Combox *)
void Toolbar::Pimpl::layoutSelected(int sel) void Toolbar::Pimpl::layoutSelected(int sel)
{ {
string const tmp = tostr(sel); string const tmp = tostr(sel);
owner->getLyXFunc()->Dispatch(LFUN_LAYOUTNO, tmp); owner->getLyXFunc()->dispatch(LFUN_LAYOUTNO, tmp);
} }
@ -270,7 +270,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac)
{ {
XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata); XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
string res = owner->getLyXFunc()->Dispatch(int(ac)); string res = owner->getLyXFunc()->dispatch(int(ac));
if (!res.empty()) if (!res.empty())
lyxerr[Debug::GUI] << "ToolbarCB: Function returned: " lyxerr[Debug::GUI] << "ToolbarCB: Function returned: "
<< res << endl; << res << endl;

View File

@ -78,7 +78,7 @@ bool Importer::Import(LyXView * lv, string const & filename,
: ChangeExtension(filename, : ChangeExtension(filename,
formats.Extension(loader_format)); formats.Extension(loader_format));
InsertAsciiFile(lv->view(), filename2, as_paragraphs); InsertAsciiFile(lv->view(), filename2, as_paragraphs);
lv->getLyXFunc()->Dispatch(LFUN_MARK_OFF); lv->getLyXFunc()->dispatch(LFUN_MARK_OFF);
} }
// we are done // we are done

View File

@ -1,3 +1,7 @@
2001-07-16 Lars Gullik Bjønnes <larsbj@birdstep.com>
* insetert.C (latex): write out all paragraphs.
2001-07-17 Baruch Even <baruch@lyx.org> 2001-07-17 Baruch Even <baruch@lyx.org>
* insetgraphics.C (draw): Removed unneeded casts. * insetgraphics.C (draw): Removed unneeded casts.

View File

@ -117,18 +117,23 @@ void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/, int InsetERT::latex(Buffer const *, std::ostream & os, bool /*fragile*/,
bool /*free_spc*/) const bool /*free_spc*/) const
{ {
Paragraph::size_type siz = inset.paragraph()->size(); Paragraph * par = inset.paragraph();
for (Paragraph::size_type i = 0; i != siz; ++i) { while (par) {
char c = inset.paragraph()->getChar(i); Paragraph::size_type siz = inset.paragraph()->size();
switch (c) { for (Paragraph::size_type i = 0; i != siz; ++i) {
case Paragraph::META_NEWLINE: char c = inset.paragraph()->getChar(i);
os << '\n'; switch (c) {
break; case Paragraph::META_NEWLINE:
default: os << '\n';
os << c; break;
break; default:
os << c;
break;
}
} }
par = par->next();
} }
return 1; return 1;
} }

View File

@ -46,7 +46,7 @@ string const InsetParent::getScreenLabel() const
void InsetParent::edit(BufferView * bv, int, int, unsigned int) void InsetParent::edit(BufferView * bv, int, int, unsigned int)
{ {
bv->owner()->getLyXFunc()-> bv->owner()->getLyXFunc()->
Dispatch(LFUN_CHILDOPEN, getContents()); dispatch(LFUN_CHILDOPEN, getContents());
} }

View File

@ -27,7 +27,7 @@ void InsetRef::edit(BufferView * bv, int, int, unsigned int button)
// Eventually trigger dialog with button 3 not 1 // Eventually trigger dialog with button 3 not 1
if (button == 3 ) if (button == 3 )
bv->owner()->getLyXFunc()-> bv->owner()->getLyXFunc()->
Dispatch(LFUN_REF_GOTO, getContents()); dispatch(LFUN_REF_GOTO, getContents());
else if (button == 1 ) else if (button == 1 )
bv->owner()->getDialogs()->showRef( this ); bv->owner()->getDialogs()->showRef( this );
} }

View File

@ -1120,7 +1120,7 @@ InsetText::localDispatch(BufferView * bv,
// see if we found the layout number: // see if we found the layout number:
if (!layout.first) { if (!layout.first) {
string const msg = string(N_("Layout ")) + arg + N_(" not known"); string const msg = string(N_("Layout ")) + arg + N_(" not known");
bv->owner()->getLyXFunc()->Dispatch(LFUN_MESSAGE, msg); bv->owner()->getLyXFunc()->dispatch(LFUN_MESSAGE, msg);
break; break;
} }

View File

@ -169,7 +169,7 @@ LyX::LyX(int * argc, char * argv[])
// otherwise, let the GUI handle the batch command // otherwise, let the GUI handle the batch command
lyxGUI->regBuf(last_loaded); lyxGUI->regBuf(last_loaded);
lyxGUI->getLyXView()->getLyXFunc()->Dispatch(batch_command); lyxGUI->getLyXView()->getLyXFunc()->dispatch(batch_command);
// fall through... // fall through...
} }

View File

@ -344,7 +344,7 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
bool tmp_sc = show_sc; bool tmp_sc = show_sc;
show_sc = false; show_sc = false;
Dispatch(action, argument); dispatch(action, argument);
show_sc = tmp_sc; show_sc = tmp_sc;
//return 0; //return 0;
@ -638,23 +638,23 @@ func_status::value_type LyXFunc::getStatus(int ac,
void LyXFunc::miniDispatch(string const & s) void LyXFunc::miniDispatch(string const & s)
{ {
if (!s.empty()) { if (!s.empty()) {
Dispatch(s); dispatch(s);
} }
} }
string const LyXFunc::Dispatch(string const & s) string const LyXFunc::dispatch(string const & s)
{ {
// Split command string into command and argument // Split command string into command and argument
string cmd; string cmd;
string line = frontStrip(s); string line = frontStrip(s);
string const arg = strip(frontStrip(split(line, cmd, ' '))); string const arg = strip(frontStrip(split(line, cmd, ' ')));
return Dispatch(lyxaction.LookupFunc(cmd), arg); return dispatch(lyxaction.LookupFunc(cmd), arg);
} }
string const LyXFunc::Dispatch(int ac, string const LyXFunc::dispatch(int ac,
string const & do_not_use_this_arg) string const & do_not_use_this_arg)
{ {
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
@ -897,7 +897,7 @@ string const LyXFunc::Dispatch(int ac,
meta_fake_bit = 0; meta_fake_bit = 0;
if (owner->view()->available()) if (owner->view()->available())
// cancel any selection // cancel any selection
Dispatch(LFUN_MARK_OFF); dispatch(LFUN_MARK_OFF);
setMessage(N_("Cancel")); setMessage(N_("Cancel"));
break; break;
@ -925,15 +925,15 @@ string const LyXFunc::Dispatch(int ac,
// --- Menus ----------------------------------------------- // --- Menus -----------------------------------------------
case LFUN_MENUNEW: case LFUN_MENUNEW:
MenuNew(false); menuNew(false);
break; break;
case LFUN_MENUNEWTMPLT: case LFUN_MENUNEWTMPLT:
MenuNew(true); menuNew(true);
break; break;
case LFUN_CLOSEBUFFER: case LFUN_CLOSEBUFFER:
CloseBuffer(); closeBuffer();
break; break;
case LFUN_MENUWRITE: case LFUN_MENUWRITE:
@ -1182,7 +1182,7 @@ string const LyXFunc::Dispatch(int ac,
break; break;
case LFUN_FILE_OPEN: case LFUN_FILE_OPEN:
Open(argument); open(argument);
break; break;
case LFUN_LATEX_LOG: case LFUN_LATEX_LOG:
@ -1202,7 +1202,7 @@ string const LyXFunc::Dispatch(int ac,
--sel; // sel 1..., but layout 0... --sel; // sel 1..., but layout 0...
// Pretend we got the name instead. // Pretend we got the name instead.
Dispatch(int(LFUN_LAYOUT), dispatch(int(LFUN_LAYOUT),
textclasslist.NameOfLayout(owner->view() textclasslist.NameOfLayout(owner->view()
->buffer()->params.textclass, ->buffer()->params.textclass,
sel)); sel));
@ -1422,7 +1422,7 @@ string const LyXFunc::Dispatch(int ac,
} else { } else {
p.setContents( argument ); p.setContents( argument );
} }
Dispatch(LFUN_CITATION_INSERT, p.getAsString()); dispatch(LFUN_CITATION_INSERT, p.getAsString());
} else } else
owner->getDialogs()->createCitation( p.getAsString() ); owner->getDialogs()->createCitation( p.getAsString() );
} }
@ -1469,7 +1469,7 @@ string const LyXFunc::Dispatch(int ac,
while (argument.find(';') != string::npos) { while (argument.find(';') != string::npos) {
string first; string first;
argument = split(argument, first, ';'); argument = split(argument, first, ';');
Dispatch(first); dispatch(first);
} }
} }
break; break;
@ -1619,7 +1619,7 @@ void LyXFunc::setupLocalKeymap()
} }
void LyXFunc::MenuNew(bool fromTemplate) void LyXFunc::menuNew(bool fromTemplate)
{ {
string initpath = lyxrc.document_path; string initpath = lyxrc.document_path;
@ -1745,7 +1745,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
} }
void LyXFunc::Open(string const & fname) void LyXFunc::open(string const & fname)
{ {
string initpath = lyxrc.document_path; string initpath = lyxrc.document_path;
@ -1906,7 +1906,7 @@ void LyXFunc::reloadBuffer()
} }
void LyXFunc::CloseBuffer() void LyXFunc::closeBuffer()
{ {
if (bufferlist.close(owner->buffer()) && !quitting) { if (bufferlist.close(owner->buffer()) && !quitting) {
if (bufferlist.empty()) { if (bufferlist.empty()) {

View File

@ -30,10 +30,10 @@ public:
LyXFunc(LyXView *); LyXFunc(LyXView *);
/// LyX dispatcher, executes lyx actions. /// LyX dispatcher, executes lyx actions.
string const Dispatch(int action, string const & arg = string()); string const dispatch(int action, string const & arg = string());
/// The same but uses the name of a lyx command. /// The same but uses the name of a lyx command.
string const Dispatch(string const & cmd); string const dispatch(string const & cmd);
/// ///
void miniDispatch(string const & cmd); void miniDispatch(string const & cmd);
@ -109,16 +109,16 @@ private:
// I think the following should be moved to BufferView. (Asger) // I think the following should be moved to BufferView. (Asger)
/// ///
void MenuNew(bool fromTemplate); void menuNew(bool fromTemplate);
/// ///
void Open(string const &); void open(string const &);
/// ///
void doImport(string const &); void doImport(string const &);
/// ///
void CloseBuffer(); void closeBuffer();
/// ///
void reloadBuffer(); void reloadBuffer();
/// ///

View File

@ -528,7 +528,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
string rval, buf; string rval, buf;
if (action>= 0) { if (action>= 0) {
rval = serv->func->Dispatch(action, arg); rval = serv->func->dispatch(action, arg);
} else { } else {
rval = "Unknown command"; rval = "Unknown command";
} }

View File

@ -87,7 +87,7 @@ void LyXVC::registrer()
MakeDisplayPath(vcs->owner()->fileName(), 50), MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Save document and proceed?"))) { _("Save document and proceed?"))) {
vcs->owner()->getUser()->owner() vcs->owner()->getUser()->owner()
->getLyXFunc()->Dispatch(LFUN_MENUWRITE); ->getLyXFunc()->dispatch(LFUN_MENUWRITE);
} }
// Maybe the save fails, or we answered "no". In both cases, // Maybe the save fails, or we answered "no". In both cases,
@ -120,7 +120,7 @@ void LyXVC::checkIn()
MakeDisplayPath(vcs->owner()->fileName(), 50), MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Save document and proceed?"))) { _("Save document and proceed?"))) {
vcs->owner()->getUser()->owner() vcs->owner()->getUser()->owner()
->getLyXFunc()->Dispatch(LFUN_MENUWRITE); ->getLyXFunc()->dispatch(LFUN_MENUWRITE);
} }
// Maybe the save fails, or we answered "no". In both cases, // Maybe the save fails, or we answered "no". In both cases,

View File

@ -18,10 +18,13 @@ using std::endl;
// KmodInfo // KmodInfo
KmodInfo::KmodInfo() KmodInfo::KmodInfo()
{ {
#if 0
exception_list = 0; exception_list = 0;
#endif
} }
#if 0
// Default Trans // Default Trans
bool DefaultTrans::init_ = false; bool DefaultTrans::init_ = false;
@ -49,14 +52,16 @@ string const DefaultTrans::process(char c, TransManager & k)
return k.normalkey(c); return k.normalkey(c);
} }
#endif #endif
#endif
// Trans class // Trans class
Trans::Trans() Trans::Trans()
{ {
#if 0
for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i) for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i)
kmod_list_[i] = 0; kmod_list_[i] = 0;
#endif
} }
@ -66,9 +71,10 @@ Trans::~Trans()
} }
void Trans::InsertException(Trans::keyexc & exclist, char c, void Trans::InsertException(KmodException & exclist, char c,
string const & data, bool flag, tex_accent accent) string const & data, bool flag, tex_accent accent)
{ {
#if 0
keyexc p = new Keyexc; keyexc p = new Keyexc;
p->next = exclist; p->next = exclist;
p->c = c; p->c = c;
@ -78,22 +84,37 @@ void Trans::InsertException(Trans::keyexc & exclist, char c,
p->accent = accent; p->accent = accent;
exclist = p; exclist = p;
#else
Keyexc p;
p.c = c;
p.data = data;
p.combined = flag;
p.accent = accent;
exclist.insert(exclist.begin(), p);
// or just
// exclist.push_back(p);
#endif
} }
void Trans::FreeException(Trans::keyexc & exclist) void Trans::FreeException(KmodException & exclist)
{ {
#if 0
Trans::keyexc p = exclist; Trans::keyexc p = exclist;
while (p) { while (p) {
p = exclist->next; p = exclist->next;
delete exclist; delete exclist;
exclist = p; exclist = p;
} }
#else
exclist.clear();
#endif
} }
void Trans::FreeKeymap() void Trans::FreeKeymap()
{ {
#if 0
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
if (!keymap_[i].empty()) { if (!keymap_[i].empty()) {
keymap_[i].erase(); keymap_[i].erase();
@ -104,6 +125,10 @@ void Trans::FreeKeymap()
delete kmod_list_[i]; delete kmod_list_[i];
kmod_list_[i] = 0; kmod_list_[i] = 0;
} }
#else
kmod_list_.clear();
keymap_.clear();
#endif
} }
@ -146,27 +171,29 @@ void Trans::AddDeadkey(tex_accent accent, string const & keys,
void Trans::AddDeadkey(tex_accent accent, string const & keys) void Trans::AddDeadkey(tex_accent accent, string const & keys)
#endif #endif
{ {
#if 0
if (kmod_list_[accent]) { if (kmod_list_[accent]) {
FreeException(kmod_list_[accent]->exception_list); FreeException(kmod_list_[accent]->exception_list);
delete kmod_list_[accent]; delete kmod_list_[accent];
} }
kmod_list_[accent] = new kmod_list_decl; kmod_list_[accent] = new KmodInfo;
kmod_list_[accent]->data = keys; kmod_list_[accent]->data = keys;
kmod_list_[accent]->accent = accent; kmod_list_[accent]->accent = accent;
#else
KmodInfo tmp;
tmp.data = keys;
tmp.accent = accent;
kmod_list_[accent] = tmp;
#endif
#if 0 #if 0
if (allowed == "native") { if (allowed == "native") {
kmod_list_[accent]->allowed= lyx_accent_table[accent].native; kmod_list_[accent]->allowed= lyx_accent_table[accent].native;
} else { } else {
#endif
#if 0
kmod_list_[accent]->allowed = allowed; kmod_list_[accent]->allowed = allowed;
#endif
#if 0
} }
#endif
for (string::size_type i = 0; i < keys.length(); ++i) { for (string::size_type i = 0; i < keys.length(); ++i) {
string & temp = string & temp =
keymap_[static_cast<unsigned char>(keys[i])]; keymap_[static_cast<unsigned char>(keys[i])];
@ -179,7 +206,17 @@ void Trans::AddDeadkey(tex_accent accent, string const & keys)
temp += char(0); temp += char(0);
temp += char(accent); temp += char(accent);
} }
#else
for (string::size_type i = 0; i < keys.length(); ++i) {
string tmp;
tmp += char(0);
tmp += char(accent);
keymap_[keys[i]] = tmp;
}
#endif
#if 0
kmod_list_[accent]->exception_list = 0; kmod_list_[accent]->exception_list = 0;
#endif
} }
@ -254,12 +291,24 @@ int Trans::Load(LyXLex & lex)
tex_accent accent_2= getkeymod(str); tex_accent accent_2= getkeymod(str);
if (accent_2 == TEX_NOACCENT) return -1; if (accent_2 == TEX_NOACCENT) return -1;
#if 0
if (kmod_list_[accent_1] == 0 if (kmod_list_[accent_1] == 0
|| kmod_list_[accent_2] == 0) || kmod_list_[accent_2] == 0)
return -1; return -1;
#else
std::map<int, KmodInfo>::iterator it1 =
kmod_list_.find(accent_1);
std::map<int, KmodInfo>::iterator it2 =
kmod_list_.find(accent_2);
if (it1 == kmod_list_.end()
|| it2 == kmod_list_.end()) {
return -1;
}
#endif
// Find what key accent_2 is on - should // Find what key accent_2 is on - should
// check about accent_1 also // check about accent_1 also
#if 0
int key = 0; int key = 0;
for (; key < 256; ++key) { for (; key < 256; ++key) {
if (!keymap_[key].empty() if (!keymap_[key].empty()
@ -276,9 +325,31 @@ int Trans::Load(LyXLex & lex)
} else } else
return -1; return -1;
InsertException(kmod_list_[accent_1]->exception_list, InsertException(kmod_list_[accent_1].exception_list,
static_cast<char>(key), allowed, static_cast<char>(key), allowed,
true, accent_2); true, accent_2);
#else
std::map<int, string>::iterator it = keymap_.begin();
std::map<int, string>::iterator end = keymap_.end();
for (; it != end; ++it) {
if (!it->second.empty()
&& it->second[0] == 0
&& it->second[1] == accent_2)
break;
}
string allowed;
if (lex.next()) {
allowed = lex.GetString();
lyxerr[Debug::KBMAP] << "allowed: "
<< allowed << endl;
} else {
return -1;
}
InsertException(kmod_list_[accent_1].exception_list,
static_cast<char>(it->first), allowed,
true, accent_2);
#endif
} }
break; break;
case KMAP: { case KMAP: {
@ -296,9 +367,11 @@ int Trans::Load(LyXLex & lex)
if (lex.next(true)) { if (lex.next(true)) {
string string_to = lex.text(); string string_to = lex.text();
//char * string_to = #if 0
// strcpy(new char[strlen(t)+1], t);
keymap_[key_from] = string_to; keymap_[key_from] = string_to;
#else
keymap_[key_from] = string_to;
#endif
if (lyxerr.debugging(Debug::KBMAP)) if (lyxerr.debugging(Debug::KBMAP))
lyxerr << "\t`" << string_to << "'" lyxerr << "\t`" << string_to << "'"
<< endl; << endl;
@ -338,7 +411,7 @@ int Trans::Load(LyXLex & lex)
} else } else
return -1; return -1;
InsertException(kmod_list_[accent]->exception_list, InsertException(kmod_list_[accent].exception_list,
key, str); key, str);
break; break;
} }
@ -357,11 +430,20 @@ int Trans::Load(LyXLex & lex)
bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i) const bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i) const
{ {
#if 0
if (kmod_list_[accent] != 0) { if (kmod_list_[accent] != 0) {
i = *kmod_list_[accent]; i = *kmod_list_[accent];
return true; return true;
} }
return false; return false;
#else
std::map<int, KmodInfo>::const_iterator cit = kmod_list_.find(accent);
if (cit != kmod_list_.end()) {
i = cit->second;
return true;
}
return false;
#endif
} }
@ -390,10 +472,16 @@ string const Trans::process(char c, TransManager & k)
if (t.empty() && c != 0) { if (t.empty() && c != 0) {
return k.normalkey(c); return k.normalkey(c);
} else if (!t.empty() && t[0] != char(0)) { } else if (!t.empty() && t[0] != char(0)) {
return k.normalkey(c); //return k.normalkey(c);
return t;
} else { } else {
#if 0
return k.deadkey(c, return k.deadkey(c,
*kmod_list_[static_cast<tex_accent>(t[1])]); *kmod_list_[static_cast<tex_accent>(t[1])]);
#else
return k.deadkey(c,
kmod_list_[static_cast<tex_accent>(t[1])]);
#endif
} }
} }
#endif #endif

View File

@ -6,6 +6,8 @@
#pragma interface #pragma interface
#endif #endif
#include <map>
#include "tex-accent.h" #include "tex-accent.h"
#include "LString.h" #include "LString.h"
#include "trans_decl.h" #include "trans_decl.h"
@ -14,6 +16,7 @@ class LyXLex;
class TransManager; class TransManager;
#if 0
/** /**
TransInterface: the interface that every translation class TransInterface: the interface that every translation class
should obey too. should obey too.
@ -41,17 +44,18 @@ private:
/// ///
static bool init_; static bool init_;
}; };
#endif
/** /**
Trans: holds a .kmap file Trans: holds a .kmap file
*/ */
class Trans : public TransInterface { //class Trans : public TransInterface {
class Trans {
public: public:
/// ///
Trans(); Trans();
/// ///
virtual ~Trans(); ~Trans();
/// ///
int Load(string const & language); int Load(string const & language);
@ -65,10 +69,12 @@ public:
bool isAccentDefined(tex_accent, KmodInfo &) const; bool isAccentDefined(tex_accent, KmodInfo &) const;
private: private:
#if 0
/// ///
typedef KmodInfo kmod_list_decl; typedef KmodInfo kmod_list_decl;
/// ///
typedef KmodException keyexc; typedef KmodException keyexc;
#endif
#if 0 #if 0
/// ///
void AddDeadkey(tex_accent, string const &, string const &); void AddDeadkey(tex_accent, string const &, string const &);
@ -83,26 +89,44 @@ private:
/// ///
inline string const & Match(unsigned char c); inline string const & Match(unsigned char c);
/// ///
void InsertException(keyexc & exclist, char c, void InsertException(KmodException & exclist, char c,
string const & data, bool = false, string const & data, bool = false,
tex_accent = TEX_NOACCENT); tex_accent = TEX_NOACCENT);
/// ///
void FreeException(keyexc & exclist); void FreeException(KmodException & exclist);
/// ///
string name_; string name_;
#if 0
/// ///
string keymap_[256]; string keymap_[256];
#else
std::map<int, string> keymap_;
#endif
#if 0
/// ///
kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1]; kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
#else
///
//KmodInfo * kmod_list_[TEX_MAX_ACCENT+1];
std::map<int, KmodInfo> kmod_list_;
#endif
}; };
/// ///
string const & Trans::Match(unsigned char c) string const & Trans::Match(unsigned char c)
{ {
#if 0
return keymap_[c]; return keymap_[c];
#else
std::map<int, string>::iterator it = keymap_.find(c);
if (it != keymap_.end()) {
return it->second;
}
static string dummy;
return dummy;
#endif
} }
#endif #endif

View File

@ -2,6 +2,8 @@
#ifndef Trans_Decl_h #ifndef Trans_Decl_h
#define Trans_Decl_h #define Trans_Decl_h
#include <list>
#include "LString.h" #include "LString.h"
#include "tex-accent.h" #include "tex-accent.h"
@ -11,16 +13,23 @@ struct Keyexc {
char c; char c;
/// exception data /// exception data
string data; string data;
#if 0
/// ///
Keyexc * next; Keyexc * next;
#endif
/// Combination with another deadkey /// Combination with another deadkey
bool combined; bool combined;
/// The accent comined with /// The accent comined with
tex_accent accent; tex_accent accent;
}; };
#if 0
/// ///
typedef Keyexc * KmodException; typedef Keyexc * KmodException;
#else
///
typedef std::list<Keyexc> KmodException;
#endif
/// ///
struct KmodInfo { struct KmodInfo {

View File

@ -30,7 +30,9 @@ TransFSMData::TransFSMData()
{ {
deadkey_ = deadkey2_ = 0; deadkey_ = deadkey2_ = 0;
deadkey_info_.accent = deadkey2_info_.accent = TEX_NOACCENT; deadkey_info_.accent = deadkey2_info_.accent = TEX_NOACCENT;
#if 0
comb_info_ = 0; comb_info_ = 0;
#endif
} }
@ -112,6 +114,7 @@ string const TransDeadkeyState::normalkey(char c, string const & trans)
#else #else
string const TransDeadkeyState::normalkey(char c) string const TransDeadkeyState::normalkey(char c)
{ {
#if 0
string res; string res;
// Check if it is an exception // Check if it is an exception
@ -128,6 +131,24 @@ string const TransDeadkeyState::normalkey(char c)
} }
currentState = init_state_; currentState = init_state_;
return res; return res;
#else
string res;
KmodException::iterator it = deadkey_info_.exception_list.begin();
KmodException::iterator end = deadkey_info_.exception_list.end();
for (; it != end; ++it) {
if (it->c == c) {
res = it->data;
break;
}
}
if (it == end) {
res = DoAccent(c, deadkey_info_.accent);
}
currentState = init_state_;
return res;
#endif
} }
#endif #endif
@ -146,6 +167,7 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d)
} }
// Check if it is a combination or an exception // Check if it is a combination or an exception
#if 0
KmodException l; KmodException l;
l = deadkey_info_.exception_list; l = deadkey_info_.exception_list;
@ -166,7 +188,26 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d)
} }
l = l->next; l = l->next;
} }
#else
KmodException::const_iterator cit = deadkey_info_.exception_list.begin();
KmodException::const_iterator end = deadkey_info_.exception_list.end();
for (; cit != end; ++cit) {
if (cit->combined == true && cit->accent == d.accent) {
deadkey2_ = c;
deadkey2_info_ = d;
comb_info_ = (*cit);
currentState = combined_state_;
return string();
}
if (cit->c == c) {
res = cit->data;
deadkey_ = 0;
deadkey_info_.accent = TEX_NOACCENT;
currentState = init_state_;
return res;
}
}
#endif
// Not a combination or an exception. // Not a combination or an exception.
// Output deadkey1 and keep deadkey2 // Output deadkey1 and keep deadkey2
@ -359,13 +400,15 @@ void TransManager::insert(string const & str, LyXText * text)
// Could not find an encoding // Could not find an encoding
InsetLatexAccent ins(str); InsetLatexAccent ins(str);
if (ins.canDisplay()) { if (ins.canDisplay()) {
text->insertInset(current_view, new InsetLatexAccent(ins)); text->insertInset(current_view,
new InsetLatexAccent(ins));
} else { } else {
insertVerbatim(str, text); insertVerbatim(str, text);
} }
return; return;
} }
string tmp; tmp += static_cast<char>(enc.second); string tmp;
tmp += static_cast<char>(enc.second);
insertVerbatim(tmp, text); insertVerbatim(tmp, text);
} }
@ -391,8 +434,9 @@ void TransManager::deadkey(char c, tex_accent accent, LyXText * t)
i.allowed = lyx_accent_table[accent].native; i.allowed = lyx_accent_table[accent].native;
#endif #endif
i.data.erase(); i.data.erase();
#if 0
i.exception_list = 0; i.exception_list = 0;
#endif
string res = trans_fsm_.currentState->deadkey(c, i); string res = trans_fsm_.currentState->deadkey(c, i);
insert(res, t); insert(res, t);
} else { } else {

View File

@ -48,8 +48,13 @@ protected:
char deadkey2_; char deadkey2_;
/// ///
KmodInfo deadkey2_info_; KmodInfo deadkey2_info_;
#if 0
/// ///
KmodException comb_info_; KmodException comb_info_;
#else
///
Keyexc comb_info_;
#endif
/// ///
TransState * init_state_; TransState * init_state_;
/// ///

View File

@ -147,7 +147,7 @@ void RCS::registrer(string const & msg)
cmd += OnlyFilename(owner_->fileName()); cmd += OnlyFilename(owner_->fileName());
cmd += "\""; cmd += "\"";
doVCCommand(cmd, owner_->filepath); doVCCommand(cmd, owner_->filepath);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload"); owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
} }
@ -155,7 +155,7 @@ void RCS::checkIn(string const & msg)
{ {
doVCCommand("ci -q -u -m\"" + msg + "\" \"" doVCCommand("ci -q -u -m\"" + msg + "\" \""
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath); + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload"); owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
} }
@ -164,7 +164,7 @@ void RCS::checkOut()
owner_->markLyxClean(); owner_->markLyxClean();
doVCCommand("co -q -l \"" doVCCommand("co -q -l \""
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath); + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload"); owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
} }
@ -175,7 +175,7 @@ void RCS::revert()
// We ignore changes and just reload! // We ignore changes and just reload!
owner_->markLyxClean(); owner_->markLyxClean();
owner_->getUser()->owner() owner_->getUser()->owner()
->getLyXFunc()->Dispatch("buffer-reload"); ->getLyXFunc()->dispatch("buffer-reload");
} }
@ -277,7 +277,7 @@ void CVS::registrer(string const & msg)
{ {
doVCCommand("cvs -q add -m \"" + msg + "\" \"" doVCCommand("cvs -q add -m \"" + msg + "\" \""
+ OnlyFilename(owner_->fileName()) + "\"", owner_->filepath); + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload"); owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
} }
@ -286,7 +286,7 @@ void CVS::checkIn(string const & msg)
doVCCommand("cvs -q commit -m \"" + msg + "\" \"" doVCCommand("cvs -q commit -m \"" + msg + "\" \""
+ OnlyFilename(owner_->fileName()) + "\"", + OnlyFilename(owner_->fileName()) + "\"",
owner_->filepath); owner_->filepath);
owner_->getUser()->owner()->getLyXFunc()->Dispatch("buffer-reload"); owner_->getUser()->owner()->getLyXFunc()->dispatch("buffer-reload");
} }
@ -307,7 +307,7 @@ void CVS::revert()
owner_->filepath); owner_->filepath);
owner_->markLyxClean(); owner_->markLyxClean();
owner_->getUser()->owner() owner_->getUser()->owner()
->getLyXFunc()->Dispatch("buffer-reload"); ->getLyXFunc()->dispatch("buffer-reload");
} }