From: André Pönitz Date: Sat, 16 Jul 2005 10:35:43 +0000 (+0000) Subject: * lyxfont.h: Change order of declarations to give the compiler X-Git-Tag: 1.6.10~14103 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3f54e51eb3f816788557f260f39272bbc907873f;p=features.git * lyxfont.h: Change order of declarations to give the compiler a better chance to inline things * lyx_cb.[Ch]: Add 'force' argument to QuitLyX suppressing questions on unsaved docs for better scritability git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10236 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index d34ed386b5..2a0752a89e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,12 @@ +2005-07-16 André Pönitz + + * lyxfont.h: Change order of declarations to give the compiler + a better chance to inline things + + * lyx_cb.[Ch]: Add 'force' argument to QuitLyX suppressing + questions on unsaved docs for better scritability + 2005-07-16 André Pönitz * paragraph.h (getChar): remove asserts as the same kind of security diff --git a/src/frontends/gtk/GView.C b/src/frontends/gtk/GView.C index e695c21e65..dd91b1e730 100644 --- a/src/frontends/gtk/GView.C +++ b/src/frontends/gtk/GView.C @@ -117,7 +117,7 @@ Gtk::Box & GView::getBox(Position pos) bool GView::on_delete_event(GdkEventAny * /*event*/) { - QuitLyX(); + QuitLyX(false); return true; } diff --git a/src/frontends/qt2/QtView.C b/src/frontends/qt2/QtView.C index 5eb054c797..5722d8957f 100644 --- a/src/frontends/qt2/QtView.C +++ b/src/frontends/qt2/QtView.C @@ -152,7 +152,7 @@ bool QtView::hasFocus() const void QtView::closeEvent(QCloseEvent *) { - QuitLyX(); + QuitLyX(false); } diff --git a/src/frontends/xforms/XFormsView.C b/src/frontends/xforms/XFormsView.C index 9abe89488a..43f7058516 100644 --- a/src/frontends/xforms/XFormsView.C +++ b/src/frontends/xforms/XFormsView.C @@ -34,7 +34,7 @@ using std::endl; using std::string; //extern void AutoSave(BufferView *); -extern void QuitLyX(); +extern void QuitLyX(bool); namespace lyx { @@ -173,7 +173,7 @@ FL_FORM * XFormsView::getForm() const // Callback for close main form from window manager int XFormsView::atCloseMainFormCB(FL_FORM *, void *) { - QuitLyX(); + QuitLyX(false); return FL_IGNORE; } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index c58ee30d7f..ff6eeb49ac 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -188,12 +188,12 @@ bool WriteAs(Buffer * buffer, string const & filename) } -void QuitLyX() +void QuitLyX(bool noask) { lyxerr[Debug::INFO] << "Running QuitLyX." << endl; if (lyx_gui::use_gui) { - if (!bufferlist.quitWriteAll()) + if (!noask && !bufferlist.quitWriteAll()) return; LyX::cref().lastfiles().writeFile(lyxrc.lastfiles); diff --git a/src/lyx_cb.h b/src/lyx_cb.h index 67bc2bddd8..fa191c4fc2 100644 --- a/src/lyx_cb.h +++ b/src/lyx_cb.h @@ -25,7 +25,7 @@ bool MenuWrite(Buffer * buffer); /// write the given file, or ask if no name given bool WriteAs(Buffer * buffer, std::string const & filename = std::string()); /// -void QuitLyX(); +void QuitLyX(bool noask); /// void AutoSave(BufferView * bv); /// diff --git a/src/lyx_main.C b/src/lyx_main.C index 9a42be6b3f..8ecd3edabc 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -87,7 +87,7 @@ using std::system; #endif -extern void QuitLyX(); +extern void QuitLyX(bool); extern LyXServer * lyxserver; @@ -271,7 +271,7 @@ void LyX::priv_exec(int & argc, char * argv[]) if (last_loaded) { bool success = false; if (last_loaded->dispatch(batch_command, &success)) { - QuitLyX(); + QuitLyX(false); exit(!success); } } @@ -282,7 +282,7 @@ void LyX::priv_exec(int & argc, char * argv[]) lyx_gui::start(batch_command, files); else { // Something went wrong above - QuitLyX(); + QuitLyX(false); exit(EXIT_FAILURE); } } diff --git a/src/lyxfont.C b/src/lyxfont.C index 6416713986..6fefc131c9 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -197,11 +197,6 @@ LyXFont::LyXFont(LyXFont::FONT_INIT3, Language const * l) {} -LyXFont::FONT_MISC_STATE LyXFont::underbar() const -{ - return bits.underbar; -} - LColor_color LyXFont::color() const { @@ -215,12 +210,6 @@ Language const * LyXFont::language() const } -LyXFont::FONT_MISC_STATE LyXFont::number() const -{ - return bits.number; -} - - bool LyXFont::isRightToLeft() const { return lang->RightToLeft(); @@ -470,30 +459,30 @@ LyXFont & LyXFont::realize(LyXFont const & tmplt) return *this; } - if (bits.family == INHERIT_FAMILY) { + if (bits.family == INHERIT_FAMILY) bits.family = tmplt.bits.family; - } - if (bits.series == INHERIT_SERIES) { + + if (bits.series == INHERIT_SERIES) bits.series = tmplt.bits.series; - } - if (bits.shape == INHERIT_SHAPE) { + + if (bits.shape == INHERIT_SHAPE) bits.shape = tmplt.bits.shape; - } - if (bits.size == INHERIT_SIZE) { + + if (bits.size == INHERIT_SIZE) bits.size = tmplt.bits.size; - } - if (bits.emph == INHERIT) { + + if (bits.emph == INHERIT) bits.emph = tmplt.bits.emph; - } - if (bits.underbar == INHERIT) { + + if (bits.underbar == INHERIT) bits.underbar = tmplt.bits.underbar; - } - if (bits.noun == INHERIT) { + + if (bits.noun == INHERIT) bits.noun = tmplt.bits.noun; - } - if (bits.color == LColor::inherit) { + + if (bits.color == LColor::inherit) bits.color = tmplt.bits.color; - } + return *this; } @@ -580,11 +569,11 @@ LyXFont & LyXFont::setLyXShape(string const & sha) string const s = ascii_lowercase(sha); int i = 0; - while (LyXShapeNames[i] != s && - LyXShapeNames[i] != string("error")) ++i; - if (s == LyXShapeNames[i]) { + while (LyXShapeNames[i] != s && LyXShapeNames[i] != string("error")) + ++i; + if (s == LyXShapeNames[i]) setShape(LyXFont::FONT_SHAPE(i)); - } else + else lyxerr << "LyXFont::setLyXShape: Unknown shape `" << s << '\'' << endl; return *this; @@ -596,8 +585,8 @@ LyXFont & LyXFont::setLyXSize(string const & siz) { string const s = ascii_lowercase(siz); int i = 0; - while (LyXSizeNames[i] != s && - LyXSizeNames[i] != string("error")) ++i; + while (LyXSizeNames[i] != s && LyXSizeNames[i] != string("error")) + ++i; if (s == LyXSizeNames[i]) { setSize(LyXFont::FONT_SIZE(i)); } else @@ -704,24 +693,18 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const { os << "\n"; - if (orgfont.family() != family()) { + if (orgfont.family() != family()) os << "\\family " << LyXFamilyNames[family()] << "\n"; - } - if (orgfont.series() != series()) { + if (orgfont.series() != series()) os << "\\series " << LyXSeriesNames[series()] << "\n"; - } - if (orgfont.shape() != shape()) { + if (orgfont.shape() != shape()) os << "\\shape " << LyXShapeNames[shape()] << "\n"; - } - if (orgfont.size() != size()) { + if (orgfont.size() != size()) os << "\\size " << LyXSizeNames[size()] << "\n"; - } - if (orgfont.emph() != emph()) { + if (orgfont.emph() != emph()) os << "\\emph " << LyXMiscNames[emph()] << "\n"; - } - if (orgfont.number() != number()) { + if (orgfont.number() != number()) os << "\\numeric " << LyXMiscNames[number()] << "\n"; - } if (orgfont.underbar() != underbar()) { // This is only for backwards compatibility switch (underbar()) { diff --git a/src/lyxfont.h b/src/lyxfont.h index 06eef154ea..58943b749b 100644 --- a/src/lyxfont.h +++ b/src/lyxfont.h @@ -157,6 +157,28 @@ public: ALL_SANE }; + struct FontBits { + /// + FONT_FAMILY family; + /// + FONT_SERIES series; + /// + FONT_SHAPE shape; + /// + FONT_SIZE size; + /** We store the LColor::color value as an int to get LColor.h out + * of the header file. + */ + int color; + /// + FONT_MISC_STATE emph; + /// + FONT_MISC_STATE underbar; + /// + FONT_MISC_STATE noun; + /// + FONT_MISC_STATE number; + }; /// LyXFont(); @@ -178,46 +200,32 @@ public: /// Decreases font size by one LyXFont & decSize(); - /// Increases font size by one LyXFont & incSize(); - /// - FONT_FAMILY family() const; - + FONT_FAMILY family() const { return bits.family; } /// - FONT_SERIES series() const; - + FONT_SERIES series() const { return bits.series; } /// - FONT_SHAPE shape() const; - + FONT_SHAPE shape() const { return bits.shape; } /// - FONT_SIZE size() const; - + FONT_SIZE size() const { return bits.size; } /// - FONT_MISC_STATE emph() const; - + FONT_MISC_STATE emph() const { return bits.emph; } /// - FONT_MISC_STATE underbar() const; - + FONT_MISC_STATE underbar() const { return bits.underbar; } /// - FONT_MISC_STATE noun() const; - + FONT_MISC_STATE noun() const { return bits.noun; } /// - FONT_MISC_STATE number() const; - + FONT_MISC_STATE number() const { return bits.number; } /// LColor_color color() const; - /// Language const * language() const; - /// bool isRightToLeft() const; - /// bool isVisibleRightToLeft() const; - /// bool isSymbolFont() const; @@ -316,28 +324,6 @@ public: /** Compaq cxx 6.5 requires that the definition be public so that it can compile operator==() */ - struct FontBits { - /// - FONT_FAMILY family; - /// - FONT_SERIES series; - /// - FONT_SHAPE shape; - /// - FONT_SIZE size; - /** We store the LColor::color value as an int to get LColor.h out - * of the header file. - */ - int color; - /// - FONT_MISC_STATE emph; - /// - FONT_MISC_STATE underbar; - /// - FONT_MISC_STATE noun; - /// - FONT_MISC_STATE number; - }; private: /// FontBits bits; @@ -372,48 +358,6 @@ private: -inline -LyXFont::FONT_SHAPE LyXFont::shape() const -{ - return bits.shape; -} - - -inline -LyXFont::FONT_FAMILY LyXFont::family() const -{ - return bits.family; -} - - -inline -LyXFont::FONT_SERIES LyXFont::series() const -{ - return bits.series; -} - - -inline -LyXFont::FONT_SIZE LyXFont::size() const -{ - return bits.size; -} - - -inline -LyXFont::FONT_MISC_STATE LyXFont::emph() const -{ - return bits.emph; -} - - -inline -LyXFont::FONT_MISC_STATE LyXFont::noun() const -{ - return bits.noun; -} - - inline bool LyXFont::isSymbolFont() const { diff --git a/src/lyxfunc.C b/src/lyxfunc.C index dd84ab6bd7..a679f52b4b 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -952,7 +952,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; case LFUN_QUIT: - QuitLyX(); + QuitLyX(argument == "force"); break; case LFUN_TOCVIEW: {