From: Lars Gullik Bjønnes Date: Mon, 16 Jul 2001 15:42:57 +0000 (+0000) Subject: Dispatch->dispatch, some trans work X-Git-Tag: 1.6.10~21071 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=efe0b0b8eb340b7c34ead8afe5d81b410d5e7865;p=features.git Dispatch->dispatch, some trans work git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2254 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 7fde8f3361..45ec862af5 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -598,7 +598,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, bool paste_internally = false; if (button == 2 && bv_->text->selection.set()) { - owner_->getLyXFunc()->Dispatch(LFUN_COPY); + owner_->getLyXFunc()->dispatch(LFUN_COPY); paste_internally = true; } @@ -644,9 +644,9 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, // insert this if (button == 2) { if (paste_internally) - owner_->getLyXFunc()->Dispatch(LFUN_PASTE); + owner_->getLyXFunc()->dispatch(LFUN_PASTE); else - owner_->getLyXFunc()->Dispatch(LFUN_PASTESELECTION, + owner_->getLyXFunc()->dispatch(LFUN_PASTESELECTION, "paragraph"); selection_possible = false; return; diff --git a/src/ChangeLog b/src/ChangeLog index eae98645e1..6f975a09f3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-07-12 Lars Gullik Bjønnes + + * lyxfunc.h: change more methods to begin with lower char. + 2001-07-16 Dekel Tsur * buffer.C (parseSingleLyXformat2Token): Generate error insets diff --git a/src/LaTeX.C b/src/LaTeX.C index 1b7c5bb16d..5a83f1d9e4 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -177,7 +177,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (lfun) { ostringstream str; 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")))) { // no checks for now 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.")); 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; // no checks for now 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.")); updateBibtexDependencies(head, bibtex_info); rerun |= runBibTeX(bibtex_info); @@ -259,7 +259,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (lfun) { ostringstream str; str << _("LaTeX run number") << ' ' << count; - lfun->Dispatch(LFUN_MESSAGE, str.str().c_str()); + lfun->dispatch(LFUN_MESSAGE, str.str().c_str()); } // WriteStatus(minib, @@ -290,7 +290,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (head.haschanged(OnlyFilename(ChangeExtension(file, ".idx")))) { // no checks for now 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.")); rerun = runMakeIndex(OnlyFilename(ChangeExtension(file, ".idx"))); } @@ -315,7 +315,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) if (lfun) { ostringstream str; 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)); diff --git a/src/frontends/controllers/ControlCommand.C b/src/frontends/controllers/ControlCommand.C index e68a300651..9a81d08cc6 100644 --- a/src/frontends/controllers/ControlCommand.C +++ b/src/frontends/controllers/ControlCommand.C @@ -56,6 +56,6 @@ void ControlCommand::applyParamsToInset() void ControlCommand::applyParamsNoInset() { if (action_ == LFUN_NOACTION) return; - lv_.getLyXFunc()->Dispatch(action_, params().getAsString()); + lv_.getLyXFunc()->dispatch(action_, params().getAsString()); } diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C index b909d5bb88..c208a6dbdb 100644 --- a/src/frontends/controllers/ControlRef.C +++ b/src/frontends/controllers/ControlRef.C @@ -43,13 +43,13 @@ std::vector const ControlRef::getLabelList() const void ControlRef::gotoRef(string const & ref) const { - lv_.getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0"); - lv_.getLyXFunc()->Dispatch(LFUN_REF_GOTO, ref); + lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_SAVE, "0"); + lv_.getLyXFunc()->dispatch(LFUN_REF_GOTO, ref); } void ControlRef::gotoBookmark() const { - lv_.getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0"); + lv_.getLyXFunc()->dispatch(LFUN_BOOKMARK_GOTO, "0"); } diff --git a/src/frontends/controllers/ControlTabularCreate.C b/src/frontends/controllers/ControlTabularCreate.C index cad18eccde..fa55e9e6a1 100644 --- a/src/frontends/controllers/ControlTabularCreate.C +++ b/src/frontends/controllers/ControlTabularCreate.C @@ -54,5 +54,5 @@ void ControlTabularCreate::apply() string const val(tostr(params().first) + " " + tostr(params().second)); - lv_.getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, val); + lv_.getLyXFunc()->dispatch(LFUN_INSET_TABULAR, val); } diff --git a/src/frontends/controllers/ControlToc.C b/src/frontends/controllers/ControlToc.C index c4eae44f55..9498787396 100644 --- a/src/frontends/controllers/ControlToc.C +++ b/src/frontends/controllers/ControlToc.C @@ -42,7 +42,7 @@ ControlToc::ControlToc(LyXView & lv, Dialogs & d) void ControlToc::Goto(int const & id) const { string const tmp = tostr(id); - lv_.getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp); + lv_.getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tmp); } diff --git a/src/frontends/xforms/FormMathsDelim.C b/src/frontends/xforms/FormMathsDelim.C index 414fcb04da..27432b56d8 100644 --- a/src/frontends/xforms/FormMathsDelim.C +++ b/src/frontends/xforms/FormMathsDelim.C @@ -86,7 +86,7 @@ void FormMathsDelim::apply() ostringstream ost; 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) diff --git a/src/frontends/xforms/FormMathsMatrix.C b/src/frontends/xforms/FormMathsMatrix.C index 2421d32674..6e5ec9d286 100644 --- a/src/frontends/xforms/FormMathsMatrix.C +++ b/src/frontends/xforms/FormMathsMatrix.C @@ -88,7 +88,7 @@ void FormMathsMatrix::apply() ostringstream ost; 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) diff --git a/src/frontends/xforms/FormMathsPanel.C b/src/frontends/xforms/FormMathsPanel.C index fffe677b2d..ef7a55cb9c 100644 --- a/src/frontends/xforms/FormMathsPanel.C +++ b/src/frontends/xforms/FormMathsPanel.C @@ -249,13 +249,13 @@ bool FormMathsPanel::input(FL_OBJECT *, long data) 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 { - lv_->getLyXFunc()->Dispatch(LFUN_MATH_DISPLAY); + lv_->getLyXFunc()->dispatch(LFUN_MATH_DISPLAY); } diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index ea746e0d38..0f2a087a56 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -158,7 +158,7 @@ void FormPreferences::ok() 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(" ") + 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"; parent_.lv_->getLyXFunc()-> - Dispatch(LFUN_SET_COLOR, arg); + dispatch(LFUN_SET_COLOR, arg); continue; } @@ -2553,7 +2553,7 @@ void FormPreferences::ScreenFonts::apply() const if (changed) { // Now update the buffers // Can anything below here affect the redraw process? - parent_.lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE); + parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE); } } diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index 5fbcc6b716..878b73f41d 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -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 // valid action, but something else. if (choice >= action_offset + 1) { - view->getLyXFunc()->Dispatch(choice - action_offset); - } - else { + view->getLyXFunc()->dispatch(choice - action_offset); + } else { lyxerr[Debug::GUI] << "MenuCallback: ignoring bogus action " << choice << endl; } - } - else + } else { lyxerr << "Error in MenuCallback" << endl; + } std::for_each(submenus.begin(), submenus.end(), fl_freepup); // restore tabstop length diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index fee4d5e182..833642632d 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -157,7 +157,7 @@ void Toolbar::Pimpl::layoutSelectedCB(int sel, void * arg, Combox *) void Toolbar::Pimpl::layoutSelected(int 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(ob->u_vdata); - string res = owner->getLyXFunc()->Dispatch(int(ac)); + string res = owner->getLyXFunc()->dispatch(int(ac)); if (!res.empty()) lyxerr[Debug::GUI] << "ToolbarCB: Function returned: " << res << endl; diff --git a/src/importer.C b/src/importer.C index 8b71939547..21310d7e02 100644 --- a/src/importer.C +++ b/src/importer.C @@ -78,7 +78,7 @@ bool Importer::Import(LyXView * lv, string const & filename, : ChangeExtension(filename, formats.Extension(loader_format)); InsertAsciiFile(lv->view(), filename2, as_paragraphs); - lv->getLyXFunc()->Dispatch(LFUN_MARK_OFF); + lv->getLyXFunc()->dispatch(LFUN_MARK_OFF); } // we are done diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 7b574e2850..cb8dbae101 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2001-07-16 Lars Gullik Bjønnes + + * insetert.C (latex): write out all paragraphs. + 2001-07-17 Baruch Even * insetgraphics.C (draw): Removed unneeded casts. diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 2528a5a50d..d81701590e 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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*/, bool /*free_spc*/) const { - Paragraph::size_type siz = inset.paragraph()->size(); - for (Paragraph::size_type i = 0; i != siz; ++i) { - char c = inset.paragraph()->getChar(i); - switch (c) { - case Paragraph::META_NEWLINE: - os << '\n'; - break; - default: - os << c; - break; + Paragraph * par = inset.paragraph(); + while (par) { + Paragraph::size_type siz = inset.paragraph()->size(); + for (Paragraph::size_type i = 0; i != siz; ++i) { + char c = inset.paragraph()->getChar(i); + switch (c) { + case Paragraph::META_NEWLINE: + os << '\n'; + break; + default: + os << c; + break; + } } + par = par->next(); } + return 1; } diff --git a/src/insets/insetparent.C b/src/insets/insetparent.C index d63c783a5e..5df4a8d7ee 100644 --- a/src/insets/insetparent.C +++ b/src/insets/insetparent.C @@ -46,7 +46,7 @@ string const InsetParent::getScreenLabel() const void InsetParent::edit(BufferView * bv, int, int, unsigned int) { bv->owner()->getLyXFunc()-> - Dispatch(LFUN_CHILDOPEN, getContents()); + dispatch(LFUN_CHILDOPEN, getContents()); } diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 1e9cf3ceee..4624c1d97b 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -27,7 +27,7 @@ void InsetRef::edit(BufferView * bv, int, int, unsigned int button) // Eventually trigger dialog with button 3 not 1 if (button == 3 ) bv->owner()->getLyXFunc()-> - Dispatch(LFUN_REF_GOTO, getContents()); + dispatch(LFUN_REF_GOTO, getContents()); else if (button == 1 ) bv->owner()->getDialogs()->showRef( this ); } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 6d33d8496f..bbb7aa4cf0 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1120,7 +1120,7 @@ InsetText::localDispatch(BufferView * bv, // see if we found the layout number: if (!layout.first) { 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; } diff --git a/src/lyx_main.C b/src/lyx_main.C index 3332523282..367911132c 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -169,7 +169,7 @@ LyX::LyX(int * argc, char * argv[]) // otherwise, let the GUI handle the batch command lyxGUI->regBuf(last_loaded); - lyxGUI->getLyXView()->getLyXFunc()->Dispatch(batch_command); + lyxGUI->getLyXView()->getLyXFunc()->dispatch(batch_command); // fall through... } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 6369647b40..9a6fbe629a 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -344,7 +344,7 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state) bool tmp_sc = show_sc; show_sc = false; - Dispatch(action, argument); + dispatch(action, argument); show_sc = tmp_sc; //return 0; @@ -638,23 +638,23 @@ func_status::value_type LyXFunc::getStatus(int ac, void LyXFunc::miniDispatch(string const & s) { 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 string cmd; string line = frontStrip(s); 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) { lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac @@ -897,7 +897,7 @@ string const LyXFunc::Dispatch(int ac, meta_fake_bit = 0; if (owner->view()->available()) // cancel any selection - Dispatch(LFUN_MARK_OFF); + dispatch(LFUN_MARK_OFF); setMessage(N_("Cancel")); break; @@ -925,15 +925,15 @@ string const LyXFunc::Dispatch(int ac, // --- Menus ----------------------------------------------- case LFUN_MENUNEW: - MenuNew(false); + menuNew(false); break; case LFUN_MENUNEWTMPLT: - MenuNew(true); + menuNew(true); break; case LFUN_CLOSEBUFFER: - CloseBuffer(); + closeBuffer(); break; case LFUN_MENUWRITE: @@ -1182,7 +1182,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_FILE_OPEN: - Open(argument); + open(argument); break; case LFUN_LATEX_LOG: @@ -1202,7 +1202,7 @@ string const LyXFunc::Dispatch(int ac, --sel; // sel 1..., but layout 0... // Pretend we got the name instead. - Dispatch(int(LFUN_LAYOUT), + dispatch(int(LFUN_LAYOUT), textclasslist.NameOfLayout(owner->view() ->buffer()->params.textclass, sel)); @@ -1422,7 +1422,7 @@ string const LyXFunc::Dispatch(int ac, } else { p.setContents( argument ); } - Dispatch(LFUN_CITATION_INSERT, p.getAsString()); + dispatch(LFUN_CITATION_INSERT, p.getAsString()); } else owner->getDialogs()->createCitation( p.getAsString() ); } @@ -1469,7 +1469,7 @@ string const LyXFunc::Dispatch(int ac, while (argument.find(';') != string::npos) { string first; argument = split(argument, first, ';'); - Dispatch(first); + dispatch(first); } } break; @@ -1619,7 +1619,7 @@ void LyXFunc::setupLocalKeymap() } -void LyXFunc::MenuNew(bool fromTemplate) +void LyXFunc::menuNew(bool fromTemplate) { 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; @@ -1906,7 +1906,7 @@ void LyXFunc::reloadBuffer() } -void LyXFunc::CloseBuffer() +void LyXFunc::closeBuffer() { if (bufferlist.close(owner->buffer()) && !quitting) { if (bufferlist.empty()) { diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 0572daf6bb..735e2798fe 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -30,10 +30,10 @@ public: LyXFunc(LyXView *); /// 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. - string const Dispatch(string const & cmd); + string const dispatch(string const & cmd); /// void miniDispatch(string const & cmd); @@ -109,16 +109,16 @@ private: // 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 CloseBuffer(); + void closeBuffer(); /// void reloadBuffer(); /// diff --git a/src/lyxserver.C b/src/lyxserver.C index 86be56793a..0d6662cd96 100644 --- a/src/lyxserver.C +++ b/src/lyxserver.C @@ -528,7 +528,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg) string rval, buf; if (action>= 0) { - rval = serv->func->Dispatch(action, arg); + rval = serv->func->dispatch(action, arg); } else { rval = "Unknown command"; } diff --git a/src/lyxvc.C b/src/lyxvc.C index b1b94c6861..40dcf2547d 100644 --- a/src/lyxvc.C +++ b/src/lyxvc.C @@ -87,7 +87,7 @@ void LyXVC::registrer() MakeDisplayPath(vcs->owner()->fileName(), 50), _("Save document and proceed?"))) { vcs->owner()->getUser()->owner() - ->getLyXFunc()->Dispatch(LFUN_MENUWRITE); + ->getLyXFunc()->dispatch(LFUN_MENUWRITE); } // Maybe the save fails, or we answered "no". In both cases, @@ -120,7 +120,7 @@ void LyXVC::checkIn() MakeDisplayPath(vcs->owner()->fileName(), 50), _("Save document and proceed?"))) { vcs->owner()->getUser()->owner() - ->getLyXFunc()->Dispatch(LFUN_MENUWRITE); + ->getLyXFunc()->dispatch(LFUN_MENUWRITE); } // Maybe the save fails, or we answered "no". In both cases, diff --git a/src/trans.C b/src/trans.C index 29621b4ca6..ff0fbf3986 100644 --- a/src/trans.C +++ b/src/trans.C @@ -18,10 +18,13 @@ using std::endl; // KmodInfo KmodInfo::KmodInfo() { +#if 0 exception_list = 0; +#endif } +#if 0 // Default Trans bool DefaultTrans::init_ = false; @@ -49,14 +52,16 @@ string const DefaultTrans::process(char c, TransManager & k) return k.normalkey(c); } #endif - +#endif // Trans class Trans::Trans() { +#if 0 for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i) 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) { +#if 0 keyexc p = new Keyexc; p->next = exclist; p->c = c; @@ -78,22 +84,37 @@ void Trans::InsertException(Trans::keyexc & exclist, char c, p->accent = accent; 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; while (p) { p = exclist->next; delete exclist; exclist = p; } +#else + exclist.clear(); +#endif } void Trans::FreeKeymap() { +#if 0 for (int i = 0; i < 256; ++i) if (!keymap_[i].empty()) { keymap_[i].erase(); @@ -104,6 +125,10 @@ void Trans::FreeKeymap() delete kmod_list_[i]; 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) #endif { +#if 0 if (kmod_list_[accent]) { FreeException(kmod_list_[accent]->exception_list); delete kmod_list_[accent]; } - kmod_list_[accent] = new kmod_list_decl; + kmod_list_[accent] = new KmodInfo; kmod_list_[accent]->data = keys; kmod_list_[accent]->accent = accent; +#else + KmodInfo tmp; + tmp.data = keys; + tmp.accent = accent; + kmod_list_[accent] = tmp; +#endif #if 0 if (allowed == "native") { kmod_list_[accent]->allowed= lyx_accent_table[accent].native; } else { -#endif -#if 0 kmod_list_[accent]->allowed = allowed; -#endif -#if 0 } -#endif - + for (string::size_type i = 0; i < keys.length(); ++i) { string & temp = keymap_[static_cast(keys[i])]; @@ -179,7 +206,17 @@ void Trans::AddDeadkey(tex_accent accent, string const & keys) temp += char(0); 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; +#endif } @@ -254,12 +291,24 @@ int Trans::Load(LyXLex & lex) tex_accent accent_2= getkeymod(str); if (accent_2 == TEX_NOACCENT) return -1; +#if 0 if (kmod_list_[accent_1] == 0 || kmod_list_[accent_2] == 0) return -1; +#else + std::map::iterator it1 = + kmod_list_.find(accent_1); + std::map::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 // check about accent_1 also +#if 0 int key = 0; for (; key < 256; ++key) { if (!keymap_[key].empty() @@ -276,9 +325,31 @@ int Trans::Load(LyXLex & lex) } else return -1; - InsertException(kmod_list_[accent_1]->exception_list, + InsertException(kmod_list_[accent_1].exception_list, static_cast(key), allowed, true, accent_2); +#else + std::map::iterator it = keymap_.begin(); + std::map::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(it->first), allowed, + true, accent_2); +#endif } break; case KMAP: { @@ -296,9 +367,11 @@ int Trans::Load(LyXLex & lex) if (lex.next(true)) { string string_to = lex.text(); - //char * string_to = - // strcpy(new char[strlen(t)+1], t); +#if 0 + keymap_[key_from] = string_to; +#else keymap_[key_from] = string_to; +#endif if (lyxerr.debugging(Debug::KBMAP)) lyxerr << "\t`" << string_to << "'" << endl; @@ -338,7 +411,7 @@ int Trans::Load(LyXLex & lex) } else return -1; - InsertException(kmod_list_[accent]->exception_list, + InsertException(kmod_list_[accent].exception_list, key, str); break; } @@ -357,11 +430,20 @@ int Trans::Load(LyXLex & lex) bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i) const { +#if 0 if (kmod_list_[accent] != 0) { i = *kmod_list_[accent]; return true; } return false; +#else + std::map::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) { return k.normalkey(c); } else if (!t.empty() && t[0] != char(0)) { - return k.normalkey(c); + //return k.normalkey(c); + return t; } else { +#if 0 return k.deadkey(c, *kmod_list_[static_cast(t[1])]); +#else + return k.deadkey(c, + kmod_list_[static_cast(t[1])]); +#endif } } #endif diff --git a/src/trans.h b/src/trans.h index bb896ee9a7..4b923e87e6 100644 --- a/src/trans.h +++ b/src/trans.h @@ -6,6 +6,8 @@ #pragma interface #endif +#include + #include "tex-accent.h" #include "LString.h" #include "trans_decl.h" @@ -14,6 +16,7 @@ class LyXLex; class TransManager; +#if 0 /** TransInterface: the interface that every translation class should obey too. @@ -41,17 +44,18 @@ private: /// static bool init_; }; - +#endif /** Trans: holds a .kmap file */ -class Trans : public TransInterface { +//class Trans : public TransInterface { +class Trans { public: /// Trans(); /// - virtual ~Trans(); + ~Trans(); /// int Load(string const & language); @@ -65,10 +69,12 @@ public: bool isAccentDefined(tex_accent, KmodInfo &) const; private: +#if 0 /// typedef KmodInfo kmod_list_decl; /// typedef KmodException keyexc; +#endif #if 0 /// void AddDeadkey(tex_accent, string const &, string const &); @@ -83,26 +89,44 @@ private: /// inline string const & Match(unsigned char c); /// - void InsertException(keyexc & exclist, char c, + void InsertException(KmodException & exclist, char c, string const & data, bool = false, tex_accent = TEX_NOACCENT); /// - void FreeException(keyexc & exclist); + void FreeException(KmodException & exclist); /// string name_; +#if 0 /// string keymap_[256]; +#else + std::map keymap_; +#endif +#if 0 /// kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1]; - +#else + /// + //KmodInfo * kmod_list_[TEX_MAX_ACCENT+1]; + std::map kmod_list_; +#endif }; /// string const & Trans::Match(unsigned char c) { +#if 0 return keymap_[c]; +#else + std::map::iterator it = keymap_.find(c); + if (it != keymap_.end()) { + return it->second; + } + static string dummy; + return dummy; +#endif } #endif diff --git a/src/trans_decl.h b/src/trans_decl.h index d26f05cecf..71ab9d5d59 100644 --- a/src/trans_decl.h +++ b/src/trans_decl.h @@ -2,6 +2,8 @@ #ifndef Trans_Decl_h #define Trans_Decl_h +#include + #include "LString.h" #include "tex-accent.h" @@ -11,16 +13,23 @@ struct Keyexc { char c; /// exception data string data; +#if 0 /// Keyexc * next; +#endif /// Combination with another deadkey bool combined; /// The accent comined with tex_accent accent; }; +#if 0 /// typedef Keyexc * KmodException; +#else +/// +typedef std::list KmodException; +#endif /// struct KmodInfo { diff --git a/src/trans_mgr.C b/src/trans_mgr.C index f158438e6d..3c5a6904d9 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -30,7 +30,9 @@ TransFSMData::TransFSMData() { deadkey_ = deadkey2_ = 0; deadkey_info_.accent = deadkey2_info_.accent = TEX_NOACCENT; +#if 0 comb_info_ = 0; +#endif } @@ -112,6 +114,7 @@ string const TransDeadkeyState::normalkey(char c, string const & trans) #else string const TransDeadkeyState::normalkey(char c) { +#if 0 string res; // Check if it is an exception @@ -128,6 +131,24 @@ string const TransDeadkeyState::normalkey(char c) } currentState = init_state_; 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 @@ -146,6 +167,7 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d) } // Check if it is a combination or an exception +#if 0 KmodException l; l = deadkey_info_.exception_list; @@ -166,7 +188,26 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d) } 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. // Output deadkey1 and keep deadkey2 @@ -359,13 +400,15 @@ void TransManager::insert(string const & str, LyXText * text) // Could not find an encoding InsetLatexAccent ins(str); if (ins.canDisplay()) { - text->insertInset(current_view, new InsetLatexAccent(ins)); + text->insertInset(current_view, + new InsetLatexAccent(ins)); } else { insertVerbatim(str, text); } return; } - string tmp; tmp += static_cast(enc.second); + string tmp; + tmp += static_cast(enc.second); insertVerbatim(tmp, text); } @@ -391,8 +434,9 @@ void TransManager::deadkey(char c, tex_accent accent, LyXText * t) i.allowed = lyx_accent_table[accent].native; #endif i.data.erase(); +#if 0 i.exception_list = 0; - +#endif string res = trans_fsm_.currentState->deadkey(c, i); insert(res, t); } else { diff --git a/src/trans_mgr.h b/src/trans_mgr.h index 2145f6a5df..7b7e812c32 100644 --- a/src/trans_mgr.h +++ b/src/trans_mgr.h @@ -48,8 +48,13 @@ protected: char deadkey2_; /// KmodInfo deadkey2_info_; +#if 0 /// KmodException comb_info_; +#else + /// + Keyexc comb_info_; +#endif /// TransState * init_state_; /// diff --git a/src/vc-backend.C b/src/vc-backend.C index d903a232d9..b624f72fbd 100644 --- a/src/vc-backend.C +++ b/src/vc-backend.C @@ -147,7 +147,7 @@ void RCS::registrer(string const & msg) cmd += OnlyFilename(owner_->fileName()); cmd += "\""; 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 + "\" \"" + 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(); doVCCommand("co -q -l \"" + 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! owner_->markLyxClean(); 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 + "\" \"" + 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 + "\" \"" + OnlyFilename(owner_->fileName()) + "\"", 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_->markLyxClean(); owner_->getUser()->owner() - ->getLyXFunc()->Dispatch("buffer-reload"); + ->getLyXFunc()->dispatch("buffer-reload"); }